Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt42
-rw-r--r--build_files/build_environment/cmake/numpy.cmake4
-rw-r--r--build_files/build_environment/cmake/openal.cmake1
-rw-r--r--build_files/build_environment/cmake/openjpeg.cmake2
-rw-r--r--build_files/build_environment/cmake/options.cmake25
-rw-r--r--build_files/build_environment/cmake/x264.cmake2
-rw-r--r--build_files/build_environment/patches/openal.diff13
-rw-r--r--build_files/build_environment/patches/osl.diff4
-rw-r--r--build_files/build_environment/windows/build_deps.cmd18
-rw-r--r--build_files/cmake/Modules/FindAlembic.cmake2
-rw-r--r--build_files/cmake/Modules/FindEigen3.cmake2
-rw-r--r--build_files/cmake/Modules/FindFftw3.cmake2
-rw-r--r--build_files/cmake/Modules/FindGLEW.cmake2
-rw-r--r--build_files/cmake/Modules/FindIcuLinux.cmake2
-rw-r--r--build_files/cmake/Modules/FindJack.cmake2
-rw-r--r--build_files/cmake/Modules/FindJeMalloc.cmake2
-rw-r--r--build_files/cmake/Modules/FindLZO.cmake2
-rw-r--r--build_files/cmake/Modules/FindOpenCOLLADA.cmake4
-rw-r--r--build_files/cmake/Modules/FindOpenColorIO.cmake2
-rw-r--r--build_files/cmake/Modules/FindOpenEXR.cmake4
-rw-r--r--build_files/cmake/Modules/FindOpenImageIO.cmake2
-rw-r--r--build_files/cmake/Modules/FindOpenJPEG.cmake2
-rw-r--r--build_files/cmake/Modules/FindPCRE.cmake2
-rw-r--r--build_files/cmake/Modules/FindPugiXML.cmake2
-rw-r--r--build_files/cmake/Modules/FindPythonLibsUnix.cmake2
-rw-r--r--build_files/cmake/Modules/FindSndFile.cmake2
-rw-r--r--build_files/cmake/Modules/FindSpacenav.cmake2
-rw-r--r--build_files/cmake/Modules/FindXML2.cmake2
-rw-r--r--build_files/cmake/Modules/GTestTesting.cmake1
-rw-r--r--build_files/cmake/RpmBuild.cmake6
-rw-r--r--build_files/cmake/config/blender_headless.cmake2
-rw-r--r--build_files/cmake/macros.cmake9
-rw-r--r--build_files/cmake/platform/platform_apple_xcode.cmake8
-rw-r--r--build_files/cmake/platform/platform_win32.cmake15
-rw-r--r--build_files/windows/configure_msbuild.cmd13
-rw-r--r--build_files/windows/configure_ninja.cmd16
-rw-r--r--build_files/windows/detect_msvc2017.cmd5
-rw-r--r--build_files/windows/parse_arguments.cmd7
-rw-r--r--build_files/windows/reset_variables.cmd5
-rw-r--r--build_files/windows/show_help.cmd12
-rw-r--r--extern/audaspace/plugins/ffmpeg/FFMPEG.cpp2
-rw-r--r--extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp124
-rw-r--r--extern/audaspace/plugins/ffmpeg/FFMPEGReader.h5
-rw-r--r--extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp216
-rw-r--r--extern/audaspace/plugins/ffmpeg/FFMPEGWriter.h13
-rw-r--r--intern/cycles/blender/addon/__init__.py4
-rw-r--r--intern/cycles/blender/addon/properties.py47
-rw-r--r--intern/cycles/blender/addon/ui.py956
-rw-r--r--intern/cycles/blender/addon/version_update.py11
-rw-r--r--intern/cycles/blender/blender_camera.cpp2
-rw-r--r--intern/cycles/blender/blender_curves.cpp12
-rw-r--r--intern/cycles/blender/blender_mesh.cpp2
-rw-r--r--intern/cycles/blender/blender_object.cpp56
-rw-r--r--intern/cycles/blender/blender_particles.cpp8
-rw-r--r--intern/cycles/blender/blender_session.cpp16
-rw-r--r--intern/cycles/blender/blender_session.h1
-rw-r--r--intern/cycles/blender/blender_shader.cpp71
-rw-r--r--intern/cycles/blender/blender_sync.cpp134
-rw-r--r--intern/cycles/blender/blender_sync.h6
-rw-r--r--intern/cycles/blender/blender_util.h2
-rw-r--r--intern/cycles/bvh/bvh_params.h5
-rw-r--r--intern/cycles/kernel/closure/alloc.h2
-rw-r--r--intern/cycles/kernel/osl/osl_services.cpp4
-rw-r--r--intern/cycles/kernel/osl/osl_shader.cpp2
-rw-r--r--intern/cycles/kernel/split/kernel_split_common.h5
-rw-r--r--intern/cycles/render/camera.cpp2
-rw-r--r--intern/cycles/render/image.cpp33
-rw-r--r--intern/cycles/render/image.h4
-rw-r--r--intern/cycles/render/nodes.cpp33
-rw-r--r--intern/cycles/render/nodes.h2
-rw-r--r--intern/cycles/render/scene.cpp4
-rw-r--r--intern/cycles/render/shader.cpp1
-rw-r--r--intern/cycles/render/shader.h1
-rw-r--r--intern/cycles/render/svm.cpp2
-rw-r--r--intern/cycles/util/util_vector.h6
-rw-r--r--intern/eigen/CMakeLists.txt2
-rw-r--r--intern/eigen/eigen_capi.h1
-rw-r--r--intern/eigen/intern/matrix.cc55
-rw-r--r--intern/eigen/intern/matrix.h40
-rw-r--r--intern/eigen/intern/svd.cc3
-rw-r--r--intern/gawain/gawain/gwn_common.h2
-rw-r--r--intern/gawain/src/gwn_batch.c2
-rw-r--r--intern/gawain/src/gwn_immediate.c2
-rw-r--r--intern/gawain/src/gwn_vertex_array_id.cpp5
-rw-r--r--intern/ghost/CMakeLists.txt4
-rw-r--r--intern/ghost/GHOST_C-api.h12
-rw-r--r--intern/ghost/GHOST_IEvent.h10
-rw-r--r--intern/ghost/GHOST_ISystem.h2
-rw-r--r--intern/ghost/GHOST_ISystemPaths.h4
-rw-r--r--intern/ghost/GHOST_ITimerTask.h6
-rw-r--r--intern/ghost/GHOST_IWindow.h2
-rw-r--r--intern/ghost/GHOST_Path-api.h4
-rw-r--r--intern/ghost/GHOST_Types.h20
-rw-r--r--intern/ghost/intern/GHOST_Buttons.h2
-rw-r--r--intern/ghost/intern/GHOST_C-api.cpp48
-rw-r--r--intern/ghost/intern/GHOST_ContextGLX.cpp32
-rw-r--r--intern/ghost/intern/GHOST_ContextGLX.h2
-rw-r--r--intern/ghost/intern/GHOST_ContextWGL.cpp43
-rw-r--r--intern/ghost/intern/GHOST_ContextWGL.h4
-rw-r--r--intern/ghost/intern/GHOST_Debug.h4
-rw-r--r--intern/ghost/intern/GHOST_DisplayManager.cpp4
-rw-r--r--intern/ghost/intern/GHOST_DisplayManager.h8
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerCocoa.h8
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerWin32.cpp14
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerWin32.h6
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerX11.cpp2
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerX11.h8
-rw-r--r--intern/ghost/intern/GHOST_DropTargetWin32.cpp36
-rw-r--r--intern/ghost/intern/GHOST_DropTargetWin32.h22
-rw-r--r--intern/ghost/intern/GHOST_Event.h4
-rw-r--r--intern/ghost/intern/GHOST_EventDragnDrop.h16
-rw-r--r--intern/ghost/intern/GHOST_EventKey.h4
-rw-r--r--intern/ghost/intern/GHOST_EventManager.cpp2
-rw-r--r--intern/ghost/intern/GHOST_EventManager.h2
-rw-r--r--intern/ghost/intern/GHOST_EventNDOF.h2
-rw-r--r--intern/ghost/intern/GHOST_EventPrinter.cpp12
-rw-r--r--intern/ghost/intern/GHOST_ISystemPaths.cpp2
-rw-r--r--intern/ghost/intern/GHOST_NDOFManager.cpp2
-rw-r--r--intern/ghost/intern/GHOST_NDOFManager.h2
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerCocoa.h2
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerUnix.cpp2
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerUnix.h4
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerWin32.cpp4
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerWin32.h2
-rw-r--r--intern/ghost/intern/GHOST_Rect.cpp2
-rw-r--r--intern/ghost/intern/GHOST_System.cpp6
-rw-r--r--intern/ghost/intern/GHOST_System.h16
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.h30
-rw-r--r--intern/ghost/intern/GHOST_SystemPaths.h4
-rw-r--r--intern/ghost/intern/GHOST_SystemPathsCocoa.h4
-rw-r--r--intern/ghost/intern/GHOST_SystemPathsUnix.cpp4
-rw-r--r--intern/ghost/intern/GHOST_SystemPathsUnix.h6
-rw-r--r--intern/ghost/intern/GHOST_SystemPathsWin32.cpp2
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp146
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.h18
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp190
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.h27
-rw-r--r--intern/ghost/intern/GHOST_TaskbarWin32.h2
-rw-r--r--intern/ghost/intern/GHOST_TaskbarX11.cpp2
-rw-r--r--intern/ghost/intern/GHOST_TimerManager.cpp6
-rw-r--r--intern/ghost/intern/GHOST_TimerManager.h4
-rw-r--r--intern/ghost/intern/GHOST_TimerTask.h10
-rw-r--r--intern/ghost/intern/GHOST_Window.cpp10
-rw-r--r--intern/ghost/intern/GHOST_Window.h42
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.h34
-rw-r--r--intern/ghost/intern/GHOST_WindowManager.cpp10
-rw-r--r--intern/ghost/intern/GHOST_WindowManager.h18
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.cpp10
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.h20
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.cpp62
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.h26
-rw-r--r--intern/ghost/test/CMakeLists.txt4
-rw-r--r--intern/ghost/test/gears/GHOST_C-Test.c68
-rw-r--r--intern/ghost/test/gears/GHOST_Test.cpp4
-rw-r--r--intern/ghost/test/multitest/Basic.h8
-rw-r--r--intern/ghost/test/multitest/EventToBuf.c4
-rw-r--r--intern/ghost/test/multitest/MultiTest.c168
-rw-r--r--intern/ghost/test/multitest/ScrollBar.c8
-rw-r--r--intern/ghost/test/multitest/ScrollBar.h2
-rw-r--r--intern/ghost/test/multitest/Util.c10
-rw-r--r--intern/ghost/test/multitest/WindowData.c2
-rw-r--r--intern/ghost/test/multitest/WindowData.h4
-rw-r--r--intern/libmv/libmv/base/vector.h2
-rw-r--r--intern/opencolorio/ocio_impl_glsl.cc339
-rw-r--r--release/datafiles/studiolights/matcap/license.txt3
-rw-r--r--release/datafiles/studiolights/matcap/mc01.jpgbin0 -> 20830 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc02.jpgbin0 -> 23428 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc03.jpgbin0 -> 17550 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc04.jpgbin0 -> 29197 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc05.jpgbin0 -> 25454 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc06.jpgbin0 -> 19864 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc07.jpgbin0 -> 59262 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc08.jpgbin0 -> 24133 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc09.jpgbin0 -> 31101 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc10.jpgbin0 -> 28973 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc11.jpgbin0 -> 21395 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc12.jpgbin0 -> 23797 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc13.jpgbin0 -> 45661 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc14.jpgbin0 -> 44762 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc15.jpgbin0 -> 27456 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc16.jpgbin0 -> 33401 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc17.jpgbin0 -> 49292 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc18.jpgbin0 -> 40254 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc19.jpgbin0 -> 46330 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc20.jpgbin0 -> 52893 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc21.jpgbin0 -> 28717 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc22.jpgbin0 -> 33801 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc23.jpgbin0 -> 26688 bytes
-rw-r--r--release/datafiles/studiolights/matcap/mc24.jpgbin0 -> 14149 bytes
m---------release/scripts/addons0
m---------release/scripts/addons_contrib0
-rw-r--r--release/scripts/modules/keyingsets_utils.py6
-rw-r--r--release/scripts/presets/interface_theme/flatty_dark_blueberry.xml14
-rw-r--r--release/scripts/presets/interface_theme/flatty_light.xml4
-rw-r--r--release/scripts/startup/bl_operators/image.py2
-rw-r--r--release/scripts/startup/bl_operators/mask.py2
-rw-r--r--release/scripts/startup/bl_operators/object.py6
-rw-r--r--release/scripts/startup/bl_operators/screen_play_rendered_anim.py2
-rw-r--r--release/scripts/startup/bl_operators/sequencer.py2
-rw-r--r--release/scripts/startup/bl_operators/uvcalc_lightmap.py19
-rw-r--r--release/scripts/startup/bl_operators/wm.py172
-rw-r--r--release/scripts/startup/bl_ui/__init__.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_animviz.py31
-rw-r--r--release/scripts/startup/bl_ui/properties_constraint.py1
-rw-r--r--release/scripts/startup/bl_ui/properties_data_armature.py59
-rw-r--r--release/scripts/startup/bl_ui/properties_data_bone.py320
-rw-r--r--release/scripts/startup/bl_ui/properties_data_camera.py195
-rw-r--r--release/scripts/startup/bl_ui/properties_data_curve.py334
-rw-r--r--release/scripts/startup/bl_ui/properties_data_empty.py11
-rw-r--r--release/scripts/startup/bl_ui/properties_data_lamp.py152
-rw-r--r--release/scripts/startup/bl_ui/properties_data_lattice.py31
-rw-r--r--release/scripts/startup/bl_ui/properties_data_lightprobe.py56
-rw-r--r--release/scripts/startup/bl_ui/properties_data_mesh.py15
-rw-r--r--release/scripts/startup/bl_ui/properties_data_metaball.py46
-rw-r--r--release/scripts/startup/bl_ui/properties_data_modifier.py7
-rw-r--r--release/scripts/startup/bl_ui/properties_data_speaker.py52
-rw-r--r--release/scripts/startup/bl_ui/properties_data_workspace.py8
-rw-r--r--release/scripts/startup/bl_ui/properties_freestyle.py19
-rw-r--r--release/scripts/startup/bl_ui/properties_grease_pencil_common.py5
-rw-r--r--release/scripts/startup/bl_ui/properties_mask_common.py32
-rw-r--r--release/scripts/startup/bl_ui/properties_material.py31
-rw-r--r--release/scripts/startup/bl_ui/properties_object.py221
-rw-r--r--release/scripts/startup/bl_ui/properties_paint_common.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_particle.py1267
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_cloth.py1
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_common.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_rigidbody.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_render.py212
-rw-r--r--release/scripts/startup/bl_ui/properties_scene.py178
-rw-r--r--release/scripts/startup/bl_ui/properties_texture.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_view_layer.py2
-rw-r--r--release/scripts/startup/bl_ui/space_clip.py26
-rw-r--r--release/scripts/startup/bl_ui/space_dopesheet.py89
-rw-r--r--release/scripts/startup/bl_ui/space_graph.py84
-rw-r--r--release/scripts/startup/bl_ui/space_image.py70
-rw-r--r--release/scripts/startup/bl_ui/space_node.py68
-rw-r--r--release/scripts/startup/bl_ui/space_outliner.py14
-rw-r--r--release/scripts/startup/bl_ui/space_properties.py1
-rw-r--r--release/scripts/startup/bl_ui/space_statusbar.py1
-rw-r--r--release/scripts/startup/bl_ui/space_time.py27
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_common.py105
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_toolbar.py3
-rw-r--r--release/scripts/startup/bl_ui/space_topbar.py41
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py93
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py636
-rw-r--r--release/scripts/startup/bl_ui/space_view3d_toolbar.py199
-rw-r--r--source/blender/alembic/ABC_alembic.h15
-rw-r--r--source/blender/alembic/intern/abc_camera.cc6
-rw-r--r--source/blender/alembic/intern/abc_camera.h4
-rw-r--r--source/blender/alembic/intern/abc_curves.cc53
-rw-r--r--source/blender/alembic/intern/abc_curves.h21
-rw-r--r--source/blender/alembic/intern/abc_exporter.cc101
-rw-r--r--source/blender/alembic/intern/abc_exporter.h18
-rw-r--r--source/blender/alembic/intern/abc_hair.cc60
-rw-r--r--source/blender/alembic/intern/abc_hair.h9
-rw-r--r--source/blender/alembic/intern/abc_mball.cc9
-rw-r--r--source/blender/alembic/intern/abc_mball.h3
-rw-r--r--source/blender/alembic/intern/abc_mesh.cc366
-rw-r--r--source/blender/alembic/intern/abc_mesh.h42
-rw-r--r--source/blender/alembic/intern/abc_nurbs.cc20
-rw-r--r--source/blender/alembic/intern/abc_nurbs.h4
-rw-r--r--source/blender/alembic/intern/abc_object.cc16
-rw-r--r--source/blender/alembic/intern/abc_object.h16
-rw-r--r--source/blender/alembic/intern/abc_points.cc56
-rw-r--r--source/blender/alembic/intern/abc_points.h12
-rw-r--r--source/blender/alembic/intern/abc_transform.cc17
-rw-r--r--source/blender/alembic/intern/abc_transform.h3
-rw-r--r--source/blender/alembic/intern/abc_util.cc10
-rw-r--r--source/blender/alembic/intern/alembic_capi.cc38
-rw-r--r--source/blender/blenfont/BLF_api.h6
-rw-r--r--source/blender/blenfont/intern/blf.c2
-rw-r--r--source/blender/blenfont/intern/blf_dir.c20
-rw-r--r--source/blender/blenfont/intern/blf_font.c6
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c8
-rw-r--r--source/blender/blenfont/intern/blf_internal.h4
-rw-r--r--source/blender/blenfont/intern/blf_internal_types.h6
-rw-r--r--source/blender/blenfont/intern/blf_util.c4
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h26
-rw-r--r--source/blender/blenkernel/BKE_anim.h36
-rw-r--r--source/blender/blenkernel/BKE_animsys.h16
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenkernel/BKE_brush.h6
-rw-r--r--source/blender/blenkernel/BKE_cachefile.h3
-rw-r--r--source/blender/blenkernel/BKE_cdderivedmesh.h2
-rw-r--r--source/blender/blenkernel/BKE_collection.h1
-rw-r--r--source/blender/blenkernel/BKE_colortools.h2
-rw-r--r--source/blender/blenkernel/BKE_customdata.h36
-rw-r--r--source/blender/blenkernel/BKE_displist.h7
-rw-r--r--source/blender/blenkernel/BKE_dynamicpaint.h5
-rw-r--r--source/blender/blenkernel/BKE_global.h7
-rw-r--r--source/blender/blenkernel/BKE_image.h18
-rw-r--r--source/blender/blenkernel/BKE_library.h9
-rw-r--r--source/blender/blenkernel/BKE_main.h2
-rw-r--r--source/blender/blenkernel/BKE_material.h16
-rw-r--r--source/blender/blenkernel/BKE_mball.h2
-rw-r--r--source/blender/blenkernel/BKE_mball_tessellate.h1
-rw-r--r--source/blender/blenkernel/BKE_mesh.h39
-rw-r--r--source/blender/blenkernel/BKE_mesh_runtime.h85
-rw-r--r--source/blender/blenkernel/BKE_modifier.h9
-rw-r--r--source/blender/blenkernel/BKE_movieclip.h2
-rw-r--r--source/blender/blenkernel/BKE_multires.h2
-rw-r--r--source/blender/blenkernel/BKE_node.h11
-rw-r--r--source/blender/blenkernel/BKE_object.h23
-rw-r--r--source/blender/blenkernel/BKE_packedFile.h14
-rw-r--r--source/blender/blenkernel/BKE_paint.h10
-rw-r--r--source/blender/blenkernel/BKE_particle.h4
-rw-r--r--source/blender/blenkernel/BKE_pbvh.h2
-rw-r--r--source/blender/blenkernel/BKE_screen.h113
-rw-r--r--source/blender/blenkernel/BKE_sequencer.h5
-rw-r--r--source/blender/blenkernel/BKE_shrinkwrap.h2
-rw-r--r--source/blender/blenkernel/BKE_studiolight.h40
-rw-r--r--source/blender/blenkernel/BKE_tracking.h4
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c146
-rw-r--r--source/blender/blenkernel/intern/action.c12
-rw-r--r--source/blender/blenkernel/intern/anim.c87
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c244
-rw-r--r--source/blender/blenkernel/intern/appdir.c4
-rw-r--r--source/blender/blenkernel/intern/armature_update.c7
-rw-r--r--source/blender/blenkernel/intern/blender_undo.c12
-rw-r--r--source/blender/blenkernel/intern/blendfile.c44
-rw-r--r--source/blender/blenkernel/intern/bpath.c6
-rw-r--r--source/blender/blenkernel/intern/brush.c62
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c1
-rw-r--r--source/blender/blenkernel/intern/cachefile.c29
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c7
-rw-r--r--source/blender/blenkernel/intern/cloth.c2
-rw-r--r--source/blender/blenkernel/intern/collection.c41
-rw-r--r--source/blender/blenkernel/intern/colortools.c2
-rw-r--r--source/blender/blenkernel/intern/constraint.c18
-rw-r--r--source/blender/blenkernel/intern/customdata.c32
-rw-r--r--source/blender/blenkernel/intern/data_transfer.c1
-rw-r--r--source/blender/blenkernel/intern/data_transfer_intern.h4
-rw-r--r--source/blender/blenkernel/intern/displist.c95
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c17
-rw-r--r--source/blender/blenkernel/intern/fcurve.c4
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c10
-rw-r--r--source/blender/blenkernel/intern/font.c6
-rw-r--r--source/blender/blenkernel/intern/image.c71
-rw-r--r--source/blender/blenkernel/intern/ipo.c10
-rw-r--r--source/blender/blenkernel/intern/lattice.c13
-rw-r--r--source/blender/blenkernel/intern/layer.c13
-rw-r--r--source/blender/blenkernel/intern/library.c35
-rw-r--r--source/blender/blenkernel/intern/library_remap.c5
-rw-r--r--source/blender/blenkernel/intern/material.c46
-rw-r--r--source/blender/blenkernel/intern/mball.c7
-rw-r--r--source/blender/blenkernel/intern/mball_tessellate.c3
-rw-r--r--source/blender/blenkernel/intern/mesh.c78
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c422
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c14
-rw-r--r--source/blender/blenkernel/intern/mesh_runtime.c22
-rw-r--r--source/blender/blenkernel/intern/modifier.c50
-rw-r--r--source/blender/blenkernel/intern/movieclip.c18
-rw-r--r--source/blender/blenkernel/intern/multires.c1
-rw-r--r--source/blender/blenkernel/intern/nla.c14
-rw-r--r--source/blender/blenkernel/intern/node.c64
-rw-r--r--source/blender/blenkernel/intern/object.c218
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c96
-rw-r--r--source/blender/blenkernel/intern/object_update.c84
-rw-r--r--source/blender/blenkernel/intern/packedFile.c49
-rw-r--r--source/blender/blenkernel/intern/paint.c140
-rw-r--r--source/blender/blenkernel/intern/particle.c53
-rw-r--r--source/blender/blenkernel/intern/particle_system.c58
-rw-r--r--source/blender/blenkernel/intern/pbvh.c7
-rw-r--r--source/blender/blenkernel/intern/pointcache.c4
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c17
-rw-r--r--source/blender/blenkernel/intern/scene.c27
-rw-r--r--source/blender/blenkernel/intern/screen.c82
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c15
-rw-r--r--source/blender/blenkernel/intern/sequencer.c38
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c20
-rw-r--r--source/blender/blenkernel/intern/smoke.c8
-rw-r--r--source/blender/blenkernel/intern/sound.c4
-rw-r--r--source/blender/blenkernel/intern/studiolight.c614
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c5
-rw-r--r--source/blender/blenkernel/intern/suggestions.c4
-rw-r--r--source/blender/blenkernel/intern/text.c8
-rw-r--r--source/blender/blenkernel/intern/tracking.c4
-rw-r--r--source/blender/blenkernel/intern/undo_system.c2
-rw-r--r--source/blender/blenkernel/intern/workspace.c7
-rw-r--r--source/blender/blenkernel/intern/world.c9
-rw-r--r--source/blender/blenkernel/intern/writeavi.c2
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c16
-rw-r--r--source/blender/blenkernel/nla_private.h6
-rw-r--r--source/blender/blenlib/BLI_blenlib.h4
-rw-r--r--source/blender/blenlib/BLI_dial_2d.h14
-rw-r--r--source/blender/blenlib/BLI_dlrbTree.h2
-rw-r--r--source/blender/blenlib/BLI_fnmatch.h6
-rw-r--r--source/blender/blenlib/BLI_math_base.h18
-rw-r--r--source/blender/blenlib/BLI_memarena.h2
-rw-r--r--source/blender/blenlib/BLI_noise.h2
-rw-r--r--source/blender/blenlib/BLI_task.h2
-rw-r--r--source/blender/blenlib/BLI_threads.h2
-rw-r--r--source/blender/blenlib/BLI_timecode.h4
-rw-r--r--source/blender/blenlib/BLI_utildefines.h8
-rw-r--r--source/blender/blenlib/BLI_vfontdata.h2
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c10
-rw-r--r--source/blender/blenlib/intern/BLI_kdtree.c2
-rw-r--r--source/blender/blenlib/intern/boxpack_2d.c4
-rw-r--r--source/blender/blenlib/intern/jitter_2d.c2
-rw-r--r--source/blender/blenlib/intern/listbase.c2
-rw-r--r--source/blender/blenlib/intern/math_geom.c2
-rw-r--r--source/blender/blenlib/intern/math_matrix.c91
-rw-r--r--source/blender/blenlib/intern/path_util.c58
-rw-r--r--source/blender/blenlib/intern/string.c2
-rw-r--r--source/blender/blenlib/intern/string_utils.c2
-rw-r--r--source/blender/blenlib/intern/threads.c18
-rw-r--r--source/blender/blenlib/intern/timecode.c4
-rw-r--r--source/blender/blenloader/BLO_runtime.h2
-rw-r--r--source/blender/blenloader/intern/blend_validate.c2
-rw-r--r--source/blender/blenloader/intern/readfile.c43
-rw-r--r--source/blender/blenloader/intern/readfile.h16
-rw-r--r--source/blender/blenloader/intern/undofile.c2
-rw-r--r--source/blender/blenloader/intern/versioning_250.c254
-rw-r--r--source/blender/blenloader/intern/versioning_260.c390
-rw-r--r--source/blender/blenloader/intern/versioning_270.c270
-rw-r--r--source/blender/blenloader/intern/versioning_280.c295
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c24
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c427
-rw-r--r--source/blender/blenloader/intern/writefile.c15
-rw-r--r--source/blender/blentranslation/BLT_lang.h2
-rw-r--r--source/blender/blentranslation/BLT_translation.h2
-rw-r--r--source/blender/blentranslation/intern/blt_lang.c4
-rw-r--r--source/blender/blentranslation/intern/blt_translation.c2
-rw-r--r--source/blender/bmesh/bmesh_class.h8
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c58
-rw-r--r--source/blender/bmesh/intern/bmesh_delete.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_edgeloop.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_interp.c44
-rw-r--r--source/blender/bmesh/intern/bmesh_iterators.c10
-rw-r--r--source/blender/bmesh/intern/bmesh_iterators_inline.h2
-rw-r--r--source/blender/bmesh/intern/bmesh_log.c14
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.c16
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c20
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_conv.c1
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.c36
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c48
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c8
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_structure.c14
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers.c6
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers_impl.c32
-rw-r--r--source/blender/bmesh/operators/bmo_create.c4
-rw-r--r--source/blender/bmesh/operators/bmo_dissolve.c12
-rw-r--r--source/blender/bmesh/operators/bmo_dupe.c20
-rw-r--r--source/blender/bmesh/operators/bmo_extrude.c20
-rw-r--r--source/blender/bmesh/operators/bmo_hull.c18
-rw-r--r--source/blender/bmesh/operators/bmo_mirror.c12
-rw-r--r--source/blender/bmesh/operators/bmo_primitive.c34
-rw-r--r--source/blender/bmesh/operators/bmo_removedoubles.c8
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide.c78
-rw-r--r--source/blender/bmesh/operators/bmo_triangulate.c12
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c24
-rw-r--r--source/blender/collada/AnimationExporter.cpp74
-rw-r--r--source/blender/collada/AnimationExporter.h22
-rw-r--r--source/blender/collada/AnimationImporter.cpp123
-rw-r--r--source/blender/collada/AnimationImporter.h28
-rw-r--r--source/blender/collada/ArmatureExporter.cpp21
-rw-r--r--source/blender/collada/ArmatureExporter.h4
-rw-r--r--source/blender/collada/ArmatureImporter.cpp57
-rw-r--r--source/blender/collada/ArmatureImporter.h10
-rw-r--r--source/blender/collada/CameraExporter.cpp4
-rw-r--r--source/blender/collada/ControllerExporter.cpp22
-rw-r--r--source/blender/collada/DocumentExporter.cpp21
-rw-r--r--source/blender/collada/DocumentExporter.h2
-rw-r--r--source/blender/collada/DocumentImporter.cpp96
-rw-r--r--source/blender/collada/DocumentImporter.h6
-rw-r--r--source/blender/collada/EffectExporter.cpp22
-rw-r--r--source/blender/collada/EffectExporter.h10
-rw-r--r--source/blender/collada/ErrorHandler.cpp2
-rw-r--r--source/blender/collada/ExtraHandler.cpp4
-rw-r--r--source/blender/collada/ExtraHandler.h18
-rw-r--r--source/blender/collada/ExtraTags.cpp2
-rw-r--r--source/blender/collada/ExtraTags.h16
-rw-r--r--source/blender/collada/GeometryExporter.cpp92
-rw-r--r--source/blender/collada/GeometryExporter.h8
-rw-r--r--source/blender/collada/ImageExporter.cpp10
-rw-r--r--source/blender/collada/ImageExporter.h2
-rw-r--r--source/blender/collada/InstanceWriter.cpp8
-rw-r--r--source/blender/collada/LightExporter.cpp16
-rw-r--r--source/blender/collada/MaterialExporter.h2
-rw-r--r--source/blender/collada/MeshImporter.cpp86
-rw-r--r--source/blender/collada/MeshImporter.h10
-rw-r--r--source/blender/collada/SceneExporter.cpp28
-rw-r--r--source/blender/collada/SceneExporter.h8
-rw-r--r--source/blender/collada/SkinInfo.cpp8
-rw-r--r--source/blender/collada/SkinInfo.h4
-rw-r--r--source/blender/collada/TransformReader.cpp6
-rw-r--r--source/blender/collada/TransformReader.h2
-rw-r--r--source/blender/collada/TransformWriter.cpp2
-rw-r--r--source/blender/collada/collada.cpp5
-rw-r--r--source/blender/collada/collada.h4
-rw-r--r--source/blender/collada/collada_internal.h8
-rw-r--r--source/blender/collada/collada_utils.cpp26
-rw-r--r--source/blender/collada/collada_utils.h8
-rw-r--r--source/blender/compositor/COM_compositor.h6
-rw-r--r--source/blender/compositor/COM_defines.h4
-rw-r--r--source/blender/compositor/intern/COM_CPUDevice.cpp4
-rw-r--r--source/blender/compositor/intern/COM_CPUDevice.h4
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrder.cpp4
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrder.h4
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp4
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrderHotspot.h4
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.cpp4
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.h4
-rw-r--r--source/blender/compositor/intern/COM_Converter.cpp4
-rw-r--r--source/blender/compositor/intern/COM_Converter.h4
-rw-r--r--source/blender/compositor/intern/COM_Debug.cpp2
-rw-r--r--source/blender/compositor/intern/COM_Debug.h2
-rw-r--r--source/blender/compositor/intern/COM_Device.cpp4
-rw-r--r--source/blender/compositor/intern/COM_Device.h4
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.cpp4
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.h4
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.cpp4
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.h4
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.cpp4
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.h4
-rw-r--r--source/blender/compositor/intern/COM_MemoryProxy.cpp4
-rw-r--r--source/blender/compositor/intern/COM_MemoryProxy.h4
-rw-r--r--source/blender/compositor/intern/COM_Node.cpp4
-rw-r--r--source/blender/compositor/intern/COM_Node.h4
-rw-r--r--source/blender/compositor/intern/COM_NodeConverter.cpp2
-rw-r--r--source/blender/compositor/intern/COM_NodeConverter.h2
-rw-r--r--source/blender/compositor/intern/COM_NodeGraph.cpp2
-rw-r--r--source/blender/compositor/intern/COM_NodeGraph.h2
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.cpp4
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.h4
-rw-r--r--source/blender/compositor/intern/COM_NodeOperationBuilder.cpp2
-rw-r--r--source/blender/compositor/intern/COM_NodeOperationBuilder.h2
-rw-r--r--source/blender/compositor/intern/COM_OpenCLDevice.cpp4
-rw-r--r--source/blender/compositor/intern/COM_OpenCLDevice.h4
-rw-r--r--source/blender/compositor/intern/COM_SingleThreadedOperation.cpp4
-rw-r--r--source/blender/compositor/intern/COM_SingleThreadedOperation.h4
-rw-r--r--source/blender/compositor/intern/COM_SocketReader.cpp4
-rw-r--r--source/blender/compositor/intern/COM_SocketReader.h4
-rw-r--r--source/blender/compositor/intern/COM_WorkPackage.cpp4
-rw-r--r--source/blender/compositor/intern/COM_WorkPackage.h4
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp4
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.h4
-rw-r--r--source/blender/compositor/intern/COM_compositor.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_AlphaOverNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_AlphaOverNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_BilateralBlurNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_BilateralBlurNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_BokehBlurNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_BokehBlurNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_BokehImageNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_BokehImageNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_BoxMaskNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_BoxMaskNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_BrightnessNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_BrightnessNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_ColorBalanceNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_ColorBalanceNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_ColorCorrectionNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_ColorCurveNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_ColorCurveNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_ColorNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_ColorNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_ColorRampNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_ColorRampNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_ColorToBWNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_ColorToBWNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_CombineColorNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_CombineColorNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_CompositorNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_CompositorNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_CropNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_CropNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_DifferenceMatteNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_DirectionalBlurNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_DisplaceNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_EllipseMaskNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_EllipseMaskNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_FilterNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_FilterNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_FlipNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_FlipNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_GammaNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_GammaNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_GlareNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_GlareNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_IDMaskNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_IDMaskNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_InpaintNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_InpaintNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_InvertNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_InvertNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_LensDistortionNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_LensDistortionNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_MapRangeNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_MapRangeNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_MapUVNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_MapValueNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_MapValueNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_MathNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_MathNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_MixNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_MixNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_MovieClipNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_MovieClipNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_MovieDistortionNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_MovieDistortionNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_NormalNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_NormalNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_OutputFileNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_OutputFileNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_PixelateNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_RotateNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_RotateNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_ScaleNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_SeparateColorNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_SeparateColorNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_SetAlphaNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_SetAlphaNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_SocketProxyNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_SocketProxyNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_SplitViewerNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_SplitViewerNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_Stabilize2dNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_Stabilize2dNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_SwitchNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_SwitchNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_TextureNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_TextureNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_TimeNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_TimeNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_TonemapNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_TonemapNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_TransformNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_TransformNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_TranslateNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_TranslateNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_ValueNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_ValueNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_VectorBlurNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_VectorBlurNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_VectorCurveNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_VectorCurveNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_ViewLevelsNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_ViewLevelsNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_ViewerNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_ViewerNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_ZCombineNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_ZCombineNode.h4
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverKeyOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverMixedOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_AntiAliasOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_BilateralBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_BilateralBlurOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_BoxMaskOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_BoxMaskOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_BrightnessOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_BrightnessOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_CalculateMeanOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_CalculateMeanOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ChangeHSVOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ChangeHSVOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ColorCorrectionOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ColorCurveOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ColorCurveOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ColorRampOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ColorRampOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.cpp3
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorProfileOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ConvertOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ConvertOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionFilterOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_CurveBaseOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_CurveBaseOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_DifferenceMatteOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_DilateErodeOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_DilateErodeOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_DirectionalBlurOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_DotproductOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_DotproductOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_EllipseMaskOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_EllipseMaskOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_FlipOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_FlipOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_GammaCorrectOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_GammaCorrectOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_GammaOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_GammaOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_GlareBaseOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_IDMaskOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_IDMaskOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_InpaintOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_InpaintOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_InvertOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_InvertOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_MapRangeOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_MapRangeOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_MapValueOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_MapValueOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_MixOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_MixOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.cpp11
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_QualityStepHelper.cpp4
-rw-r--r--source/blender/compositor/operations/COM_QualityStepHelper.h4
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.cpp4
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.h4
-rw-r--r--source/blender/compositor/operations/COM_RotateOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_RotateOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_SetAlphaOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_SetAlphaOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_SetColorOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_SetSamplerOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_SetSamplerOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_SetValueOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_SetValueOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_SetVectorOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_SetVectorOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_SplitOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_SplitOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_SunBeamsOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_TonemapOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_TonemapOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_TranslateOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_VectorCurveOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_VectorCurveOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_WrapOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ZCombineOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ZCombineOperation.h4
-rw-r--r--source/blender/datatoc/CMakeLists.txt4
-rw-r--r--source/blender/datatoc/datatoc_icon.c2
-rw-r--r--source/blender/depsgraph/DEG_depsgraph.h18
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_query.h33
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder.cc9
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_cycle.cc4
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc280
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.h35
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc51
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc26
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc480
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.h23
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc44
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc16
-rw-r--r--source/blender/depsgraph/intern/depsgraph.cc50
-rw-r--r--source/blender/depsgraph/intern/depsgraph.h17
-rw-r--r--source/blender/depsgraph/intern/depsgraph_build.cc4
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query.cc21
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query_iter.cc80
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc163
-rw-r--r--source/blender/depsgraph/intern/depsgraph_type_defines.cc2
-rw-r--r--source/blender/depsgraph/intern/depsgraph_types.h15
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval.cc3
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc145
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_flush.cc21
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_component.cc2
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_id.cc8
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_time.cc1
-rw-r--r--source/blender/depsgraph/util/deg_util_function.h2
-rw-r--r--source/blender/draw/CMakeLists.txt17
-rw-r--r--source/blender/draw/engines/basic/basic_engine.c2
-rw-r--r--source/blender/draw/engines/clay/clay_engine.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_effects.c7
-rw-r--r--source/blender/draw/engines/eevee/eevee_engine.c50
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightprobes.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c144
-rw-r--r--source/blender/draw/engines/eevee/eevee_lookdev.c65
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c220
-rw-r--r--source/blender/draw/engines/eevee/eevee_motion_blur.c4
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h11
-rw-r--r--source/blender/draw/engines/eevee/eevee_render.c32
-rw-r--r--source/blender/draw/engines/eevee/eevee_volumes.c2
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl14
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_direct_lib.glsl186
-rw-r--r--source/blender/draw/engines/eevee/shaders/default_frag.glsl28
-rw-r--r--source/blender/draw/engines/eevee/shaders/default_world_frag.glsl19
-rw-r--r--source/blender/draw/engines/eevee/shaders/lamps_lib.glsl85
-rw-r--r--source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl59
-rw-r--r--source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl32
-rw-r--r--source/blender/draw/engines/eevee/shaders/prepass_vert.glsl17
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl2
-rw-r--r--source/blender/draw/engines/external/external_engine.c4
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_cavity_frag.glsl71
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl79
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_checkerboard_depth_frag.glsl33
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl58
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl16
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl70
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl31
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl66
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_revealage_frag.glsl7
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl67
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl58
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl33
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl3
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl44
-rw-r--r--source/blender/draw/engines/workbench/workbench_data.c155
-rw-r--r--source/blender/draw/engines/workbench/workbench_deferred.c302
-rw-r--r--source/blender/draw/engines/workbench/workbench_forward.c265
-rw-r--r--source/blender/draw/engines/workbench/workbench_materials.c101
-rw-r--r--source/blender/draw/engines/workbench/workbench_private.h80
-rw-r--r--source/blender/draw/engines/workbench/workbench_studiolight.c33
-rw-r--r--source/blender/draw/intern/DRW_render.h22
-rw-r--r--source/blender/draw/intern/draw_anim_viz.c351
-rw-r--r--source/blender/draw/intern/draw_armature.c64
-rw-r--r--source/blender/draw/intern/draw_cache.c58
-rw-r--r--source/blender/draw/intern/draw_cache.h6
-rw-r--r--source/blender/draw/intern/draw_cache_impl.h6
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c266
-rw-r--r--source/blender/draw/intern/draw_cache_impl_metaball.c29
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c892
-rw-r--r--source/blender/draw/intern/draw_common.c43
-rw-r--r--source/blender/draw/intern/draw_common.h29
-rw-r--r--source/blender/draw/intern/draw_debug.c4
-rw-r--r--source/blender/draw/intern/draw_hair.c179
-rw-r--r--source/blender/draw/intern/draw_hair_private.h92
-rw-r--r--source/blender/draw/intern/draw_instance_data.c51
-rw-r--r--source/blender/draw/intern/draw_instance_data.h5
-rw-r--r--source/blender/draw/intern/draw_manager.c128
-rw-r--r--source/blender/draw/intern/draw_manager.h27
-rw-r--r--source/blender/draw/intern/draw_manager_data.c138
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c51
-rw-r--r--source/blender/draw/intern/draw_manager_shader.c61
-rw-r--r--source/blender/draw/intern/draw_view.c18
-rw-r--r--source/blender/draw/modes/draw_mode_engines.h1
-rw-r--r--source/blender/draw/modes/edit_curve_mode.c2
-rw-r--r--source/blender/draw/modes/edit_lattice_mode.c2
-rw-r--r--source/blender/draw/modes/edit_mesh_mode.c11
-rw-r--r--source/blender/draw/modes/edit_mesh_mode_text.c53
-rw-r--r--source/blender/draw/modes/edit_metaball_mode.c2
-rw-r--r--source/blender/draw/modes/object_mode.c154
-rw-r--r--source/blender/draw/modes/overlay_mode.c96
-rw-r--r--source/blender/draw/modes/particle_mode.c6
-rw-r--r--source/blender/draw/modes/pose_mode.c26
-rw-r--r--source/blender/draw/modes/shaders/animviz_mpath_lines_geom.glsl38
-rw-r--r--source/blender/draw/modes/shaders/animviz_mpath_lines_vert.glsl91
-rw-r--r--source/blender/draw/modes/shaders/animviz_mpath_points_vert.glsl47
-rw-r--r--source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl2
-rw-r--r--source/blender/draw/modes/shaders/common_globals_lib.glsl4
-rw-r--r--source/blender/draw/modes/shaders/common_hair_lib.glsl190
-rw-r--r--source/blender/draw/modes/shaders/common_hair_refine_vert.glsl55
-rw-r--r--source/blender/draw/modes/shaders/object_outline_prepass_geom.glsl40
-rw-r--r--source/blender/draw/modes/shaders/object_outline_prepass_vert.glsl16
-rw-r--r--source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl53
-rw-r--r--source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl78
-rw-r--r--source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl175
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c1147
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c906
-rw-r--r--source/blender/editors/animation/anim_deps.c116
-rw-r--r--source/blender/editors/animation/anim_draw.c50
-rw-r--r--source/blender/editors/animation/anim_filter.c932
-rw-r--r--source/blender/editors/animation/anim_intern.h8
-rw-r--r--source/blender/editors/animation/anim_ipo_utils.c60
-rw-r--r--source/blender/editors/animation/anim_markers.c242
-rw-r--r--source/blender/editors/animation/anim_ops.c114
-rw-r--r--source/blender/editors/animation/drivers.c423
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c252
-rw-r--r--source/blender/editors/animation/keyframes_draw.c266
-rw-r--r--source/blender/editors/animation/keyframes_edit.c334
-rw-r--r--source/blender/editors/animation/keyframes_general.c224
-rw-r--r--source/blender/editors/animation/keyframing.c687
-rw-r--r--source/blender/editors/animation/keyingsets.c301
-rw-r--r--source/blender/editors/armature/armature_add.c178
-rw-r--r--source/blender/editors/armature/armature_edit.c265
-rw-r--r--source/blender/editors/armature/armature_intern.h14
-rw-r--r--source/blender/editors/armature/armature_naming.c84
-rw-r--r--source/blender/editors/armature/armature_ops.c104
-rw-r--r--source/blender/editors/armature/armature_relations.c248
-rw-r--r--source/blender/editors/armature/armature_select.c60
-rw-r--r--source/blender/editors/armature/armature_skinning.c63
-rw-r--r--source/blender/editors/armature/armature_utils.c94
-rw-r--r--source/blender/editors/armature/editarmature_retarget.c2644
-rw-r--r--source/blender/editors/armature/meshlaplacian.c53
-rw-r--r--source/blender/editors/armature/pose_edit.c274
-rw-r--r--source/blender/editors/armature/pose_group.c98
-rw-r--r--source/blender/editors/armature/pose_lib.c489
-rw-r--r--source/blender/editors/armature/pose_select.c188
-rw-r--r--source/blender/editors/armature/pose_slide.c434
-rw-r--r--source/blender/editors/armature/pose_transform.c199
-rw-r--r--source/blender/editors/armature/pose_utils.c80
-rw-r--r--source/blender/editors/curve/curve_intern.h4
-rw-r--r--source/blender/editors/curve/curve_ops.c22
-rw-r--r--source/blender/editors/curve/editcurve.c228
-rw-r--r--source/blender/editors/curve/editcurve_paint.c4
-rw-r--r--source/blender/editors/curve/editfont.c132
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c26
-rw-r--r--source/blender/editors/gpencil/editaction_gpencil.c152
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c446
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c328
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c164
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c581
-rw-r--r--source/blender/editors/gpencil/gpencil_intern.h4
-rw-r--r--source/blender/editors/gpencil/gpencil_interpolate.c280
-rw-r--r--source/blender/editors/gpencil/gpencil_ops.c184
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c503
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c324
-rw-r--r--source/blender/editors/gpencil/gpencil_undo.c52
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c155
-rw-r--r--source/blender/editors/include/ED_anim_api.h110
-rw-r--r--source/blender/editors/include/ED_armature.h17
-rw-r--r--source/blender/editors/include/ED_curve.h15
-rw-r--r--source/blender/editors/include/ED_datafiles.h4
-rw-r--r--source/blender/editors/include/ED_fileselect.h4
-rw-r--r--source/blender/editors/include/ED_gpencil.h2
-rw-r--r--source/blender/editors/include/ED_image.h10
-rw-r--r--source/blender/editors/include/ED_keyframes_draw.h14
-rw-r--r--source/blender/editors/include/ED_keyframes_edit.h16
-rw-r--r--source/blender/editors/include/ED_keyframing.h40
-rw-r--r--source/blender/editors/include/ED_markers.h6
-rw-r--r--source/blender/editors/include/ED_mball.h4
-rw-r--r--source/blender/editors/include/ED_mesh.h4
-rw-r--r--source/blender/editors/include/ED_node.h8
-rw-r--r--source/blender/editors/include/ED_object.h50
-rw-r--r--source/blender/editors/include/ED_outliner.h7
-rw-r--r--source/blender/editors/include/ED_screen.h11
-rw-r--r--source/blender/editors/include/ED_screen_types.h6
-rw-r--r--source/blender/editors/include/ED_sculpt.h2
-rw-r--r--source/blender/editors/include/ED_sound.h4
-rw-r--r--source/blender/editors/include/ED_space_api.h8
-rw-r--r--source/blender/editors/include/ED_text.h4
-rw-r--r--source/blender/editors/include/ED_transform_snap_object_context.h4
-rw-r--r--source/blender/editors/include/ED_types.h4
-rw-r--r--source/blender/editors/include/ED_undo.h2
-rw-r--r--source/blender/editors/include/ED_util.h4
-rw-r--r--source/blender/editors/include/ED_uvedit.h4
-rw-r--r--source/blender/editors/include/ED_view3d.h12
-rw-r--r--source/blender/editors/include/UI_icons.h32
-rw-r--r--source/blender/editors/include/UI_interface.h36
-rw-r--r--source/blender/editors/include/UI_interface_icons.h4
-rw-r--r--source/blender/editors/include/UI_resources.h49
-rw-r--r--source/blender/editors/include/UI_view2d.h14
-rw-r--r--source/blender/editors/interface/interface.c58
-rw-r--r--source/blender/editors/interface/interface_align.c5
-rw-r--r--source/blender/editors/interface/interface_anim.c4
-rw-r--r--source/blender/editors/interface/interface_eyedropper_color.c4
-rw-r--r--source/blender/editors/interface/interface_eyedropper_depth.c5
-rw-r--r--source/blender/editors/interface/interface_handlers.c49
-rw-r--r--source/blender/editors/interface/interface_icons.c5
-rw-r--r--source/blender/editors/interface/interface_intern.h2
-rw-r--r--source/blender/editors/interface/interface_layout.c703
-rw-r--r--source/blender/editors/interface/interface_ops.c2
-rw-r--r--source/blender/editors/interface/interface_panel.c296
-rw-r--r--source/blender/editors/interface/interface_region_menu_pie.c12
-rw-r--r--source/blender/editors/interface/interface_region_popover.c10
-rw-r--r--source/blender/editors/interface/interface_templates.c4
-rw-r--r--source/blender/editors/interface/interface_widgets.c45
-rw-r--r--source/blender/editors/interface/resources.c26
-rw-r--r--source/blender/editors/io/io_alembic.c8
-rw-r--r--source/blender/editors/io/io_cache.c2
-rw-r--r--source/blender/editors/io/io_collada.c29
-rw-r--r--source/blender/editors/io/io_collada.h4
-rw-r--r--source/blender/editors/io/io_ops.c6
-rw-r--r--source/blender/editors/io/io_ops.h4
-rw-r--r--source/blender/editors/lattice/lattice_ops.c4
-rw-r--r--source/blender/editors/mask/mask_editaction.c10
-rw-r--r--source/blender/editors/mesh/editface.c28
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c10
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c4
-rw-r--r--source/blender/editors/mesh/editmesh_knife_project.c27
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c36
-rw-r--r--source/blender/editors/mesh/editmesh_select.c6
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c7
-rw-r--r--source/blender/editors/mesh/mesh_data.c36
-rw-r--r--source/blender/editors/mesh/mesh_intern.h2
-rw-r--r--source/blender/editors/mesh/mesh_navmesh.c8
-rw-r--r--source/blender/editors/mesh/mesh_ops.c63
-rw-r--r--source/blender/editors/mesh/meshtools.c147
-rw-r--r--source/blender/editors/metaball/mball_edit.c34
-rw-r--r--source/blender/editors/metaball/mball_intern.h4
-rw-r--r--source/blender/editors/metaball/mball_ops.c16
-rw-r--r--source/blender/editors/object/object_add.c35
-rw-r--r--source/blender/editors/object/object_bake_api.c7
-rw-r--r--source/blender/editors/object/object_constraint.c470
-rw-r--r--source/blender/editors/object/object_data_transfer.c1
-rw-r--r--source/blender/editors/object/object_edit.c367
-rw-r--r--source/blender/editors/object/object_group.c46
-rw-r--r--source/blender/editors/object/object_hook.c187
-rw-r--r--source/blender/editors/object/object_intern.h5
-rw-r--r--source/blender/editors/object/object_modes.c18
-rw-r--r--source/blender/editors/object/object_modifier.c301
-rw-r--r--source/blender/editors/object/object_ops.c57
-rw-r--r--source/blender/editors/object/object_relations.c27
-rw-r--r--source/blender/editors/object/object_select.c112
-rw-r--r--source/blender/editors/object/object_shapekey.c16
-rw-r--r--source/blender/editors/object/object_transform.c98
-rw-r--r--source/blender/editors/object/object_vgroup.c73
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c26
-rw-r--r--source/blender/editors/physics/particle_boids.c44
-rw-r--r--source/blender/editors/physics/particle_edit.c240
-rw-r--r--source/blender/editors/physics/particle_edit_undo.c2
-rw-r--r--source/blender/editors/physics/particle_object.c191
-rw-r--r--source/blender/editors/physics/physics_fluid.c274
-rw-r--r--source/blender/editors/physics/physics_ops.c10
-rw-r--r--source/blender/editors/physics/physics_pointcache.c24
-rw-r--r--source/blender/editors/physics/rigidbody_world.c6
-rw-r--r--source/blender/editors/render/render_intern.h4
-rw-r--r--source/blender/editors/render/render_internal.c45
-rw-r--r--source/blender/editors/render/render_opengl.c24
-rw-r--r--source/blender/editors/render/render_ops.c4
-rw-r--r--source/blender/editors/render/render_preview.c126
-rw-r--r--source/blender/editors/render/render_shading.c86
-rw-r--r--source/blender/editors/render/render_update.c16
-rw-r--r--source/blender/editors/render/render_view.c16
-rw-r--r--source/blender/editors/screen/area.c334
-rw-r--r--source/blender/editors/screen/glutil.c18
-rw-r--r--source/blender/editors/screen/screen_context.c44
-rw-r--r--source/blender/editors/screen/screen_edit.c187
-rw-r--r--source/blender/editors/screen/screen_intern.h6
-rw-r--r--source/blender/editors/screen/screen_ops.c944
-rw-r--r--source/blender/editors/screen/screendump.c84
-rw-r--r--source/blender/editors/screen/workspace_edit.c8
-rw-r--r--source/blender/editors/screen/workspace_layout_edit.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_curve.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_hide.c24
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c54
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c114
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h4
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c70
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c24
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c26
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c51
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_color_ops.c1
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_proj.c1
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c1
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c106
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c35
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c11
-rw-r--r--source/blender/editors/sound/sound_intern.h4
-rw-r--r--source/blender/editors/sound/sound_ops.c6
-rw-r--r--source/blender/editors/space_action/action_buttons.c16
-rw-r--r--source/blender/editors/space_action/action_data.c212
-rw-r--r--source/blender/editors/space_action/action_draw.c86
-rw-r--r--source/blender/editors/space_action/action_edit.c534
-rw-r--r--source/blender/editors/space_action/action_intern.h12
-rw-r--r--source/blender/editors/space_action/action_ops.c82
-rw-r--r--source/blender/editors/space_action/action_select.c468
-rw-r--r--source/blender/editors/space_action/space_action.c173
-rw-r--r--source/blender/editors/space_api/spacetypes.c36
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c21
-rw-r--r--source/blender/editors/space_buttons/buttons_intern.h17
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c17
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c16
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c207
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_draw.c4
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_ops.c2
-rw-r--r--source/blender/editors/space_clip/clip_editor.c2
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c2
-rw-r--r--source/blender/editors/space_clip/clip_ops.c4
-rw-r--r--source/blender/editors/space_clip/clip_utils.c2
-rw-r--r--source/blender/editors/space_clip/space_clip.c4
-rw-r--r--source/blender/editors/space_clip/tracking_ops_intern.h2
-rw-r--r--source/blender/editors/space_clip/tracking_ops_orient.c27
-rw-r--r--source/blender/editors/space_console/console_draw.c12
-rw-r--r--source/blender/editors/space_console/console_intern.h2
-rw-r--r--source/blender/editors/space_console/console_ops.c105
-rw-r--r--source/blender/editors/space_console/space_console.c80
-rw-r--r--source/blender/editors/space_file/file_draw.c34
-rw-r--r--source/blender/editors/space_file/file_intern.h10
-rw-r--r--source/blender/editors/space_file/file_ops.c212
-rw-r--r--source/blender/editors/space_file/file_panels.c4
-rw-r--r--source/blender/editors/space_file/filelist.c43
-rw-r--r--source/blender/editors/space_file/filesel.c46
-rw-r--r--source/blender/editors/space_file/fsmenu.c26
-rw-r--r--source/blender/editors/space_file/fsmenu.h4
-rw-r--r--source/blender/editors/space_file/space_file.c48
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c366
-rw-r--r--source/blender/editors/space_graph/graph_draw.c234
-rw-r--r--source/blender/editors/space_graph/graph_edit.c870
-rw-r--r--source/blender/editors/space_graph/graph_intern.h10
-rw-r--r--source/blender/editors/space_graph/graph_ops.c213
-rw-r--r--source/blender/editors/space_graph/graph_select.c504
-rw-r--r--source/blender/editors/space_graph/graph_utils.c70
-rw-r--r--source/blender/editors/space_graph/space_graph.c196
-rw-r--r--source/blender/editors/space_image/image_buttons.c72
-rw-r--r--source/blender/editors/space_image/image_draw.c16
-rw-r--r--source/blender/editors/space_image/image_edit.c9
-rw-r--r--source/blender/editors/space_image/image_intern.h4
-rw-r--r--source/blender/editors/space_image/image_ops.c269
-rw-r--r--source/blender/editors/space_image/space_image.c118
-rw-r--r--source/blender/editors/space_info/info_draw.c6
-rw-r--r--source/blender/editors/space_info/info_intern.h4
-rw-r--r--source/blender/editors/space_info/info_ops.c118
-rw-r--r--source/blender/editors/space_info/info_stats.c20
-rw-r--r--source/blender/editors/space_info/space_info.c54
-rw-r--r--source/blender/editors/space_info/textview.c12
-rw-r--r--source/blender/editors/space_info/textview.h2
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c130
-rw-r--r--source/blender/editors/space_nla/nla_channels.c212
-rw-r--r--source/blender/editors/space_nla/nla_draw.c138
-rw-r--r--source/blender/editors/space_nla/nla_edit.c906
-rw-r--r--source/blender/editors/space_nla/nla_intern.h4
-rw-r--r--source/blender/editors/space_nla/nla_ops.c134
-rw-r--r--source/blender/editors/space_nla/nla_select.c202
-rw-r--r--source/blender/editors/space_nla/space_nla.c136
-rw-r--r--source/blender/editors/space_node/drawnode.c325
-rw-r--r--source/blender/editors/space_node/node_add.c102
-rw-r--r--source/blender/editors/space_node/node_buttons.c40
-rw-r--r--source/blender/editors/space_node/node_draw.c250
-rw-r--r--source/blender/editors/space_node/node_edit.c379
-rw-r--r--source/blender/editors/space_node/node_group.c305
-rw-r--r--source/blender/editors/space_node/node_intern.h9
-rw-r--r--source/blender/editors/space_node/node_manipulators.c13
-rw-r--r--source/blender/editors/space_node/node_ops.c74
-rw-r--r--source/blender/editors/space_node/node_relationships.c122
-rw-r--r--source/blender/editors/space_node/node_select.c186
-rw-r--r--source/blender/editors/space_node/node_templates.c67
-rw-r--r--source/blender/editors/space_node/node_toolbar.c10
-rw-r--r--source/blender/editors/space_node/node_view.c41
-rw-r--r--source/blender/editors/space_node/space_node.c101
-rw-r--r--source/blender/editors/space_outliner/outliner_collections.c35
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c203
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c341
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h12
-rw-r--r--source/blender/editors/space_outliner/outliner_ops.c33
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c230
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c225
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c214
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c48
-rw-r--r--source/blender/editors/space_script/script_intern.h4
-rw-r--r--source/blender/editors/space_script/space_script.c56
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c109
-rw-r--r--source/blender/editors/space_sequencer/sequencer_buttons.c8
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c113
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c341
-rw-r--r--source/blender/editors/space_sequencer/sequencer_intern.h8
-rw-r--r--source/blender/editors/space_sequencer/sequencer_ops.c6
-rw-r--r--source/blender/editors/space_sequencer/sequencer_preview.c24
-rw-r--r--source/blender/editors/space_sequencer/sequencer_scopes.c26
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c136
-rw-r--r--source/blender/editors/space_sequencer/sequencer_view.c7
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c50
-rw-r--r--source/blender/editors/space_text/space_text.c86
-rw-r--r--source/blender/editors/space_text/text_draw.c56
-rw-r--r--source/blender/editors/space_text/text_format.c2
-rw-r--r--source/blender/editors/space_text/text_format.h4
-rw-r--r--source/blender/editors/space_text/text_format_lua.c12
-rw-r--r--source/blender/editors/space_text/text_format_osl.c2
-rw-r--r--source/blender/editors/space_text/text_header.c26
-rw-r--r--source/blender/editors/space_text/text_intern.h4
-rw-r--r--source/blender/editors/space_text/text_ops.c198
-rw-r--r--source/blender/editors/space_userpref/space_userpref.c12
-rw-r--r--source/blender/editors/space_userpref/userpref_intern.h4
-rw-r--r--source/blender/editors/space_userpref/userpref_ops.c4
-rw-r--r--source/blender/editors/space_view3d/drawobject.c3
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c142
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c83
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c14
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c12
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c53
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h8
-rw-r--r--source/blender/editors/space_view3d/view3d_iterators.c1
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_armature.c5
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_camera.c37
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_empty.c5
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_forcefield.c5
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_lamp.c34
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_navigate.c22
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_ruler.c7
-rw-r--r--source/blender/editors/space_view3d/view3d_ops.c72
-rw-r--r--source/blender/editors/space_view3d/view3d_project.c20
-rw-r--r--source/blender/editors/space_view3d/view3d_ruler.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c238
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c78
-rw-r--r--source/blender/editors/space_view3d/view3d_toolbar.c38
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c14
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c80
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c4
-rw-r--r--source/blender/editors/transform/transform.c12
-rw-r--r--source/blender/editors/transform/transform.h2
-rw-r--r--source/blender/editors/transform/transform_conversions.c221
-rw-r--r--source/blender/editors/transform/transform_generics.c8
-rw-r--r--source/blender/editors/transform/transform_manipulator_3d.c51
-rw-r--r--source/blender/editors/transform/transform_ops.c3
-rw-r--r--source/blender/editors/transform/transform_orientations.c12
-rw-r--r--source/blender/editors/transform/transform_snap.c8
-rw-r--r--source/blender/editors/transform/transform_snap_object.c18
-rw-r--r--source/blender/editors/undo/ed_undo.c5
-rw-r--r--source/blender/editors/undo/undo_intern.h2
-rw-r--r--source/blender/editors/util/ed_util.c15
-rw-r--r--source/blender/editors/uvedit/uvedit_buttons.c12
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c38
-rw-r--r--source/blender/editors/uvedit/uvedit_intern.h4
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c120
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c168
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.h4
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c58
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp4
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp2
-rw-r--r--source/blender/freestyle/intern/geometry/GeomUtils.h10
-rw-r--r--source/blender/freestyle/intern/geometry/normal_cycle.cpp4
-rw-r--r--source/blender/freestyle/intern/geometry/normal_cycle.h4
-rw-r--r--source/blender/freestyle/intern/stroke/CurveIterators.h2
-rw-r--r--source/blender/gpu/GPU_material.h19
-rw-r--r--source/blender/gpu/GPU_texture.h12
-rw-r--r--source/blender/gpu/GPU_uniformbuffer.h2
-rw-r--r--source/blender/gpu/intern/gpu_basic_shader.c4
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c4
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c265
-rw-r--r--source/blender/gpu/intern/gpu_codegen.h16
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c4
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.c4
-rw-r--r--source/blender/gpu/intern/gpu_init_exit.c6
-rw-r--r--source/blender/gpu/intern/gpu_material.c182
-rw-r--r--source/blender/gpu/intern/gpu_select_pick.c4
-rw-r--r--source/blender/gpu/intern/gpu_select_sample_query.c9
-rw-r--r--source/blender/gpu/intern/gpu_shader.c4
-rw-r--r--source/blender/gpu/intern/gpu_texture.c71
-rw-r--r--source/blender/gpu/intern/gpu_uniformbuffer.c79
-rw-r--r--source/blender/gpu/shaders/gpu_shader_basic_vert.glsl4
-rw-r--r--source/blender/gpu/shaders/gpu_shader_fx_dof_hq_vert.glsl2
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl38
-rw-r--r--source/blender/gpu/shaders/gpu_shader_vertex.glsl4
-rw-r--r--source/blender/ikplugin/BIK_api.h2
-rw-r--r--source/blender/ikplugin/CMakeLists.txt2
-rw-r--r--source/blender/ikplugin/intern/ikplugin_api.c4
-rw-r--r--source/blender/ikplugin/intern/ikplugin_api.h2
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.h2
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp2
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.h2
-rw-r--r--source/blender/imbuf/IMB_imbuf.h2
-rw-r--r--source/blender/imbuf/IMB_thumbs.h2
-rw-r--r--source/blender/imbuf/intern/filter.c2
-rw-r--r--source/blender/imbuf/intern/iris.c4
-rw-r--r--source/blender/imbuf/intern/metadata.c2
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.h2
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_multi.h2
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_stub.cpp2
-rw-r--r--source/blender/imbuf/intern/thumbs.c2
-rw-r--r--source/blender/imbuf/intern/thumbs_blend.c2
-rw-r--r--source/blender/imbuf/intern/tiff.c8
-rw-r--r--source/blender/makesdna/DNA_ID.h13
-rw-r--r--source/blender/makesdna/DNA_action_types.h50
-rw-r--r--source/blender/makesdna/DNA_anim_types.h32
-rw-r--r--source/blender/makesdna/DNA_constraint_types.h2
-rw-r--r--source/blender/makesdna/DNA_curve_types.h2
-rw-r--r--source/blender/makesdna/DNA_freestyle_types.h2
-rw-r--r--source/blender/makesdna/DNA_gpencil_types.h2
-rw-r--r--source/blender/makesdna/DNA_ipo_types.h2
-rw-r--r--source/blender/makesdna/DNA_linestyle_types.h2
-rw-r--r--source/blender/makesdna/DNA_material_types.h8
-rw-r--r--source/blender/makesdna/DNA_meshdata_types.h4
-rw-r--r--source/blender/makesdna/DNA_node_types.h2
-rw-r--r--source/blender/makesdna/DNA_object_enums.h3
-rw-r--r--source/blender/makesdna/DNA_object_types.h47
-rw-r--r--source/blender/makesdna/DNA_particle_types.h19
-rw-r--r--source/blender/makesdna/DNA_scene_types.h14
-rw-r--r--source/blender/makesdna/DNA_screen_types.h11
-rw-r--r--source/blender/makesdna/DNA_space_types.h419
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h3
-rw-r--r--source/blender/makesdna/DNA_vec_types.h2
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h39
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h4
-rw-r--r--source/blender/makesdna/intern/CMakeLists.txt1
-rw-r--r--source/blender/makesdna/intern/makesdna.c10
-rw-r--r--source/blender/makesrna/RNA_access.h5
-rw-r--r--source/blender/makesrna/RNA_define.h2
-rw-r--r--source/blender/makesrna/RNA_enum_types.h3
-rw-r--r--source/blender/makesrna/RNA_types.h32
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt1
-rw-r--r--source/blender/makesrna/intern/makesrna.c24
-rw-r--r--source/blender/makesrna/intern/rna_ID.c47
-rw-r--r--source/blender/makesrna/intern/rna_access.c193
-rw-r--r--source/blender/makesrna/intern/rna_action.c126
-rw-r--r--source/blender/makesrna/intern/rna_action_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_animation.c197
-rw-r--r--source/blender/makesrna/intern/rna_animation_api.c6
-rw-r--r--source/blender/makesrna/intern/rna_animviz.c86
-rw-r--r--source/blender/makesrna/intern/rna_armature.c156
-rw-r--r--source/blender/makesrna/intern/rna_boid.c20
-rw-r--r--source/blender/makesrna/intern/rna_brush.c44
-rw-r--r--source/blender/makesrna/intern/rna_cloth.c54
-rw-r--r--source/blender/makesrna/intern/rna_color.c54
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c170
-rw-r--r--source/blender/makesrna/intern/rna_curve.c124
-rw-r--r--source/blender/makesrna/intern/rna_define.c108
-rw-r--r--source/blender/makesrna/intern/rna_depsgraph.c235
-rw-r--r--source/blender/makesrna/intern/rna_dynamicpaint.c60
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c416
-rw-r--r--source/blender/makesrna/intern/rna_fluidsim.c36
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c150
-rw-r--r--source/blender/makesrna/intern/rna_group.c9
-rw-r--r--source/blender/makesrna/intern/rna_image.c66
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c17
-rw-r--r--source/blender/makesrna/intern/rna_internal_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_key.c62
-rw-r--r--source/blender/makesrna/intern/rna_lamp.c20
-rw-r--r--source/blender/makesrna/intern/rna_lattice.c10
-rw-r--r--source/blender/makesrna/intern/rna_layer.c34
-rw-r--r--source/blender/makesrna/intern/rna_main.c4
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c181
-rw-r--r--source/blender/makesrna/intern/rna_material.c80
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c2
-rw-r--r--source/blender/makesrna/intern/rna_mesh_api.c4
-rw-r--r--source/blender/makesrna/intern/rna_mesh_utils.h2
-rw-r--r--source/blender/makesrna/intern/rna_meta.c40
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c174
-rw-r--r--source/blender/makesrna/intern/rna_movieclip.c4
-rw-r--r--source/blender/makesrna/intern/rna_nla.c162
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c1080
-rw-r--r--source/blender/makesrna/intern/rna_object.c269
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c11
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c206
-rw-r--r--source/blender/makesrna/intern/rna_particle.c119
-rw-r--r--source/blender/makesrna/intern/rna_pose.c155
-rw-r--r--source/blender/makesrna/intern/rna_render.c28
-rw-r--r--source/blender/makesrna/intern/rna_rigidbody.c94
-rw-r--r--source/blender/makesrna/intern/rna_rna.c51
-rw-r--r--source/blender/makesrna/intern/rna_scene.c381
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c12
-rw-r--r--source/blender/makesrna/intern/rna_screen.c91
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c72
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c100
-rw-r--r--source/blender/makesrna/intern/rna_sequencer_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_smoke.c8
-rw-r--r--source/blender/makesrna/intern/rna_space.c380
-rw-r--r--source/blender/makesrna/intern/rna_test.c2
-rw-r--r--source/blender/makesrna/intern/rna_text.c18
-rw-r--r--source/blender/makesrna/intern/rna_texture.c88
-rw-r--r--source/blender/makesrna/intern/rna_ui.c98
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c92
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c546
-rw-r--r--source/blender/makesrna/intern/rna_vfont.c2
-rw-r--r--source/blender/makesrna/intern/rna_vfont_api.c8
-rw-r--r--source/blender/makesrna/intern/rna_wm.c42
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c28
-rw-r--r--source/blender/makesrna/intern/rna_wm_manipulator.c3
-rw-r--r--source/blender/makesrna/intern/rna_workspace.c11
-rw-r--r--source/blender/makesrna/intern/rna_world.c6
-rwxr-xr-xsource/blender/makesrna/rna_cleanup/rna_cleaner.py34
-rwxr-xr-xsource/blender/makesrna/rna_cleanup/rna_cleaner_merge.py20
-rw-r--r--source/blender/modifiers/intern/MOD_array.c12
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c35
-rw-r--r--source/blender/modifiers/intern/MOD_collision.c1
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c1
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c3
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c2
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache.c2
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c45
-rw-r--r--source/blender/modifiers/intern/MOD_meshsequencecache.c55
-rw-r--r--source/blender/modifiers/intern/MOD_normal_edit.c23
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c4
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c12
-rw-r--r--source/blender/modifiers/intern/MOD_remesh.c1
-rw-r--r--source/blender/modifiers/intern/MOD_shrinkwrap.c4
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c4
-rw-r--r--source/blender/modifiers/intern/MOD_softbody.c8
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c37
-rw-r--r--source/blender/modifiers/intern/MOD_util.c9
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c19
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c11
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c11
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c18
-rw-r--r--source/blender/nodes/NOD_socket.h2
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c42
-rw-r--r--source/blender/nodes/composite/node_composite_util.c4
-rw-r--r--source/blender/nodes/composite/node_composite_util.h2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_alphaOver.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bilateralblur.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_blur.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bokehblur.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bokehimage.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_boxmask.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_brightness.c14
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_channelMatte.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_colorMatte.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_colorSpill.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_colorbalance.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_colorcorrection.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_common.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_composite.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_crop.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_curves.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_defocus.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_dilate.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_directionalblur.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_displace.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_ellipsemask.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_filter.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_flip.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_gamma.c16
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_glare.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_hueSatVal.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_huecorrect.c8
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_idMask.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.c22
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_inpaint.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_invert.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_lensdist.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_levels.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_lummaMatte.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_mapRange.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_mapUV.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_mapValue.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_mask.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_math.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_mixrgb.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_moviedistortion.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_normal.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_normalize.c8
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_outputFile.c36
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_premulkey.c12
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_rgb.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_rotate.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_setalpha.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_splitViewer.c7
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_stabilize2d.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sunbeams.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_texture.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_tonemap.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_translate.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_valToRgb.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_value.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_vecBlur.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_viewer.c7
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_zcombine.c2
-rw-r--r--source/blender/nodes/intern/node_common.c102
-rw-r--r--source/blender/nodes/intern/node_common.h2
-rw-r--r--source/blender/nodes/intern/node_exec.c64
-rw-r--r--source/blender/nodes/intern/node_exec.h8
-rw-r--r--source/blender/nodes/intern/node_socket.c86
-rw-r--r--source/blender/nodes/intern/node_util.c40
-rw-r--r--source/blender/nodes/intern/node_util.h2
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c58
-rw-r--r--source/blender/nodes/shader/node_shader_util.c22
-rw-r--r--source/blender/nodes/shader/node_shader_util.h2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_blackbody.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_brightness.c16
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bump.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_camera.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_common.c44
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_curves.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_emission.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_fresnel.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_gamma.c16
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_geometry.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_hair_info.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_holdout.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_hueSatVal.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_invert.c10
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_layer_weight.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_light_falloff.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_light_path.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mapping.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_math.c14
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mixRgb.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mix_shader.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal.c12
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_object_info.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_lamp.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_material.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_world.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_rgb.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_script.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_squeeze.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_brick.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_checker.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_coord.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_environment.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_gradient.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_image.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_magic.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_noise.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_sky.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_wave.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_valToRgb.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_value.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vectMath.c26
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vectTransform.c10
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_volume_scatter.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_wavelength.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_wireframe.c2
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c60
-rw-r--r--source/blender/nodes/texture/node_texture_util.c16
-rw-r--r--source/blender/nodes/texture/node_texture_util.h2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_at.c8
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_bricks.c28
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_checker.c10
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_common.c30
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_compose.c8
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_coord.c6
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_curves.c16
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_decompose.c8
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_distance.c6
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_hueSatVal.c18
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_image.c18
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_invert.c12
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_mixRgb.c12
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_output.c28
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_proc.c40
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_rotate.c22
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_scale.c12
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_texture.c16
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_translate.c14
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_valToNor.c12
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_valToRgb.c12
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_viewer.c8
-rw-r--r--source/blender/physics/intern/BPH_mass_spring.cpp334
-rw-r--r--source/blender/physics/intern/ConstrainedConjugateGradient.h34
-rw-r--r--source/blender/physics/intern/eigen_utils.h42
-rw-r--r--source/blender/physics/intern/hair_volume.cpp276
-rw-r--r--source/blender/physics/intern/implicit.h2
-rw-r--r--source/blender/physics/intern/implicit_blender.c438
-rw-r--r--source/blender/physics/intern/implicit_eigen.cpp328
-rw-r--r--source/blender/python/bmesh/CMakeLists.txt2
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c2
-rw-r--r--source/blender/python/generic/CMakeLists.txt4
-rw-r--r--source/blender/python/generic/bgl.c8
-rw-r--r--source/blender/python/generic/bgl.h2
-rw-r--r--source/blender/python/generic/blf_py_api.c2
-rw-r--r--source/blender/python/generic/bpy_internal_import.c18
-rw-r--r--source/blender/python/generic/bpy_internal_import.h4
-rw-r--r--source/blender/python/generic/imbuf_py_api.c447
-rw-r--r--source/blender/python/generic/imbuf_py_api.h30
-rw-r--r--source/blender/python/generic/py_capi_utils.c18
-rw-r--r--source/blender/python/intern/bpy.c2
-rw-r--r--source/blender/python/intern/bpy_app.c8
-rw-r--r--source/blender/python/intern/bpy_capi_utils.c6
-rw-r--r--source/blender/python/intern/bpy_driver.c4
-rw-r--r--source/blender/python/intern/bpy_interface.c22
-rw-r--r--source/blender/python/intern/bpy_library_load.c2
-rw-r--r--source/blender/python/intern/bpy_library_write.c2
-rw-r--r--source/blender/python/intern/bpy_operator.c26
-rw-r--r--source/blender/python/intern/bpy_props.c32
-rw-r--r--source/blender/python/intern/bpy_rna_anim.c45
-rw-r--r--source/blender/python/intern/bpy_rna_array.c6
-rw-r--r--source/blender/python/intern/bpy_rna_callback.c2
-rw-r--r--source/blender/python/intern/gpu.c2
-rw-r--r--source/blender/python/intern/gpu_offscreen.c2
-rw-r--r--source/blender/python/intern/stubs.c4
-rw-r--r--source/blender/python/mathutils/CMakeLists.txt2
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.h2
-rw-r--r--source/blender/python/mathutils/mathutils_interpolate.c16
-rw-r--r--source/blender/python/mathutils/mathutils_noise.c10
-rw-r--r--source/blender/render/CMakeLists.txt4
-rw-r--r--source/blender/render/extern/include/RE_bake.h2
-rw-r--r--source/blender/render/extern/include/RE_engine.h6
-rw-r--r--source/blender/render/extern/include/RE_multires_bake.h2
-rw-r--r--source/blender/render/extern/include/RE_pipeline.h27
-rw-r--r--source/blender/render/extern/include/RE_render_ext.h2
-rw-r--r--source/blender/render/extern/include/RE_shader_ext.h2
-rw-r--r--source/blender/render/intern/include/initrender.h2
-rw-r--r--source/blender/render/intern/include/render_result.h2
-rw-r--r--source/blender/render/intern/include/render_types.h38
-rw-r--r--source/blender/render/intern/include/renderpipeline.h2
-rw-r--r--source/blender/render/intern/include/zbuf.h4
-rw-r--r--source/blender/render/intern/source/external_engine.c28
-rw-r--r--source/blender/render/intern/source/imagetexture.c134
-rw-r--r--source/blender/render/intern/source/initrender.c46
-rw-r--r--source/blender/render/intern/source/pipeline.c267
-rw-r--r--source/blender/render/intern/source/pointdensity.c44
-rw-r--r--source/blender/render/intern/source/render_result.c87
-rw-r--r--source/blender/render/intern/source/render_texture.c192
-rw-r--r--source/blender/render/intern/source/voxeldata.c571
-rw-r--r--source/blender/render/intern/source/zbuf.c52
-rw-r--r--source/blender/windowmanager/WM_api.h6
-rw-r--r--source/blender/windowmanager/WM_keymap.h10
-rw-r--r--source/blender/windowmanager/WM_toolsystem.h3
-rw-r--r--source/blender/windowmanager/WM_types.h42
-rw-r--r--source/blender/windowmanager/intern/wm.c35
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c60
-rw-r--r--source/blender/windowmanager/intern/wm_dragdrop.c70
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c26
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c444
-rw-r--r--source/blender/windowmanager/intern/wm_files.c135
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c20
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c20
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c50
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c112
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c78
-rw-r--r--source/blender/windowmanager/intern/wm_operator_props.c2
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c181
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c34
-rw-r--r--source/blender/windowmanager/intern/wm_subwindow.c2
-rw-r--r--source/blender/windowmanager/intern/wm_toolsystem.c47
-rw-r--r--source/blender/windowmanager/intern/wm_tooltip.c2
-rw-r--r--source/blender/windowmanager/intern/wm_window.c267
-rw-r--r--source/blender/windowmanager/wm.h8
-rw-r--r--source/blender/windowmanager/wm_cursors.h36
-rw-r--r--source/blender/windowmanager/wm_draw.h4
-rw-r--r--source/blender/windowmanager/wm_event_system.h4
-rw-r--r--source/blender/windowmanager/wm_event_types.h13
-rw-r--r--source/blender/windowmanager/wm_files.h4
-rw-r--r--source/blender/windowmanager/wm_window.h4
-rw-r--r--source/creator/creator.c4
-rw-r--r--source/creator/creator_args.c20
m---------source/tools0
-rw-r--r--tests/gtests/alembic/abc_export_test.cc10
-rw-r--r--tests/gtests/blenlib/BLI_heap_test.cc2
-rw-r--r--tests/python/bl_pyapi_mathutils.py2
-rw-r--r--tests/python/collada/animation/test_animation_simple.py236
-rw-r--r--tests/python/collada/mesh/test_mesh_simple.py6
-rwxr-xr-xtests/python/ffmpeg_tests.py2
-rwxr-xr-xtests/python/modules/test_utils.py2
-rw-r--r--tests/python/rna_array.py16
-rw-r--r--tests/python/view_layer/CMakeLists.txt4
1708 files changed, 46463 insertions, 32700 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 02aa3697d00..5f1b9b1643c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -196,7 +196,7 @@ mark_as_advanced(WITH_BLENDER)
option(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON)
option(WITH_PYTHON "Enable Embedded Python API (only disable for development)" ON)
-option(WITH_PYTHON_SECURITY "Disables execution of scripts within blend files by default" ON)
+option(WITH_PYTHON_SECURITY "Disables execution of scripts within blend files by default" ON)
mark_as_advanced(WITH_PYTHON) # dont want people disabling this unless they really know what they are doing.
mark_as_advanced(WITH_PYTHON_SECURITY) # some distributions see this as a security issue, rather than have them patch it, make a build option.
@@ -523,9 +523,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
-fsanitize=enum \
-fsanitize=float-cast-overflow \
-fsanitize=float-divide-by-zero \
--fsanitize=leak \
-fsanitize=nonnull-attribute \
--fsanitize=object-size \
-fsanitize=returns-nonnull-attribute \
-fsanitize=signed-integer-overflow \
-fsanitize=undefined \
@@ -533,6 +531,9 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
-fno-sanitize=alignment \
")
+ if(NOT MSVC) # not all sanitizers are supported with clang-cl, these two however are very vocal about it
+ set(_asan_defaults "${_asan_defaults} -fsanitize=leak -fsanitize=object-size" )
+ endif()
set(COMPILER_ASAN_CFLAGS "${_asan_defaults}" CACHE STRING "C flags for address sanitizer")
mark_as_advanced(COMPILER_ASAN_CFLAGS)
set(COMPILER_ASAN_CXXFLAGS "${_asan_defaults}" CACHE STRING "C++ flags for address sanitizer")
@@ -540,9 +541,16 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
unset(_asan_defaults)
- find_library(COMPILER_ASAN_LIBRARY asan ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES})
+ if(NOT MSVC)
+ find_library(COMPILER_ASAN_LIBRARY asan ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES})
+ else()
+ find_library( COMPILER_ASAN_LIBRARY NAMES clang_rt.asan-x86_64
+ PATHS
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\LLVM\\LLVM;]/lib/clang/7.0.0/lib/windows
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\LLVM\\LLVM;]/lib/clang/6.0.0/lib/windows
+ )
+ endif()
mark_as_advanced(COMPILER_ASAN_LIBRARY)
-
endif()
endif()
@@ -810,14 +818,20 @@ set(PLATFORM_LINKLIBS "")
set(PLATFORM_LINKFLAGS "")
set(PLATFORM_LINKFLAGS_DEBUG "")
-if(WITH_COMPILER_ASAN)
- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMPILER_ASAN_CFLAGS}")
- set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${COMPILER_ASAN_CFLAGS}")
-
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMPILER_ASAN_CXXFLAGS}")
- set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMPILER_ASAN_CXXFLAGS}")
+if (NOT CMAKE_BUILD_TYPE MATCHES "Release")
+ if(WITH_COMPILER_ASAN)
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMPILER_ASAN_CFLAGS}")
+ set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${COMPILER_ASAN_CFLAGS}")
- set(PLATFORM_LINKFLAGS_DEBUG "${COMPILER_ASAN_LIBRARY}")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMPILER_ASAN_CXXFLAGS}")
+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMPILER_ASAN_CXXFLAGS}")
+ if(MSVC)
+ set(COMPILER_ASAN_LINKER_FLAGS "/FUNCTIONPADMIN:6")
+ endif()
+ set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS};${COMPILER_ASAN_LIBRARY}")
+ set(PLATFORM_LINKFLAGS "${COMPILER_ASAN_LIBRARY} ${COMPILER_ASAN_LINKER_FLAGS}")
+ set(PLATFORM_LINKFLAGS_DEBUG "${COMPILER_ASAN_LIBRARY} ${COMPILER_ASAN_LINKER_FLAGS}")
+ endif()
endif()
#-----------------------------------------------------------------------------
@@ -1193,7 +1207,7 @@ else()
list(APPEND GL_DEFINITIONS -DGLEW_STATIC)
- # This won't affect the non-experimental glew library,
+ # This won't affect the non-experimental glew library,
# but is used for conditional compilation elsewhere.
list(APPEND GL_DEFINITIONS -DGLEW_NO_ES)
@@ -1483,7 +1497,7 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
"/wd4267" # conversion from 'size_t' to 'type', possible loss of data
"/wd4305" # truncation from 'type1' to 'type2'
"/wd4800" # forcing value to bool 'true' or 'false'
- "/wd4828" # The file contains a character that is illegal
+ "/wd4828" # The file contains a character that is illegal
# errors:
"/we4013" # 'function' undefined; assuming extern returning int
"/we4133" # incompatible pointer types
diff --git a/build_files/build_environment/cmake/numpy.cmake b/build_files/build_environment/cmake/numpy.cmake
index 3579042981f..0d5d8abf7ab 100644
--- a/build_files/build_environment/cmake/numpy.cmake
+++ b/build_files/build_environment/cmake/numpy.cmake
@@ -33,8 +33,8 @@ set(NUMPY_POSTFIX)
if(WIN32)
set(NUMPY_INSTALL
${CMAKE_COMMAND} -E copy_directory "${BUILD_DIR}/python/src/external_python/run/lib/site-packages/numpy/core/include/numpy" "${LIBDIR}/python/include/python${PYTHON_SHORT_VERSION}/numpy" &&
- ${CMAKE_COMMAND} -E chdir "${BUILD_DIR}/numpy/src/external_numpy/build/lib.${PYTHON_ARCH2}-${PYTHON_SHORT_VERSION}${NUMPY_DIR_POSTFIX}"
- ${CMAKE_COMMAND} -E tar "cfvz" "${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}${NUMPY_ARCHIVE_POSTFIX}.tar.gz" "."
+ ${CMAKE_COMMAND} -E chdir "${BUILD_DIR}/numpy/src/external_numpy/build/lib.${PYTHON_ARCH2}-${PYTHON_SHORT_VERSION}${NUMPY_DIR_POSTFIX}"
+ ${CMAKE_COMMAND} -E tar "cfvz" "${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}${NUMPY_ARCHIVE_POSTFIX}.tar.gz" "."
)
set(NUMPY_PATCH ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/numpy/src/external_numpy < ${PATCH_DIR}/numpy.diff )
else()
diff --git a/build_files/build_environment/cmake/openal.cmake b/build_files/build_environment/cmake/openal.cmake
index 3331361bfbc..0bc0452dd8c 100644
--- a/build_files/build_environment/cmake/openal.cmake
+++ b/build_files/build_environment/cmake/openal.cmake
@@ -39,5 +39,6 @@ if(BUILD_MODE STREQUAL Release)
PREFIX ${BUILD_DIR}/openal
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openal ${DEFAULT_CMAKE_FLAGS} ${OPENAL_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/openal
+ PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openal/src/external_openal < ${PATCH_DIR}/openal.diff
)
endif()
diff --git a/build_files/build_environment/cmake/openjpeg.cmake b/build_files/build_environment/cmake/openjpeg.cmake
index 37f9e6de32b..5cc49b1e519 100644
--- a/build_files/build_environment/cmake/openjpeg.cmake
+++ b/build_files/build_environment/cmake/openjpeg.cmake
@@ -46,7 +46,7 @@ if(MSVC)
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH SHA256=${OPENJPEG_HASH}
PREFIX ${BUILD_DIR}/openjpeg_msvc
- CMAKE_ARGS ${OPENJPEG_EXTRA_ARGS} -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openjpeg_msvc -DBUILD_SHARED_LIBS=Off -DBUILD_THIRDPARTY=OFF
+ CMAKE_ARGS ${OPENJPEG_EXTRA_ARGS} -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openjpeg_msvc -DBUILD_SHARED_LIBS=Off -DBUILD_THIRDPARTY=OFF
INSTALL_DIR ${LIBDIR}/openjpeg_msvc
)
if(BUILD_MODE STREQUAL Release)
diff --git a/build_files/build_environment/cmake/options.cmake b/build_files/build_environment/cmake/options.cmake
index 2dcf653db43..08d43d6a0a2 100644
--- a/build_files/build_environment/cmake/options.cmake
+++ b/build_files/build_environment/cmake/options.cmake
@@ -56,24 +56,27 @@ if(WIN32)
# For OIIO and OSL
set(COMMON_DEFINES /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS)
- # TODO FIXME highly MSVC specific
+ if(MSVC_VERSION GREATER 1909)
+ set(COMMON_MSVC_FLAGS "/Wv:18") #some deps with warnings as error aren't quite ready for dealing with the new 2017 warnings.
+ endif()
+
if(WITH_OPTIMIZED_DEBUG)
- set(BLENDER_CMAKE_C_FLAGS_DEBUG "/MTd /O2 /Ob2 /DNDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ set(BLENDER_CMAKE_C_FLAGS_DEBUG "/MTd ${COMMON_MSVC_FLAGS} /O2 /Ob2 /DNDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
else()
- set(BLENDER_CMAKE_C_FLAGS_DEBUG "/MTd /Zi /Ob0 /Od /RTC1 /D_DEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ set(BLENDER_CMAKE_C_FLAGS_DEBUG "/MTd ${COMMON_MSVC_FLAGS} /Zi /Ob0 /Od /RTC1 /D_DEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
endif()
- set(BLENDER_CMAKE_C_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /D NDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
- set(BLENDER_CMAKE_C_FLAGS_RELEASE "/MT /O2 /Ob2 /DNDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
- set(BLENDER_CMAKE_C_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /D NDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ set(BLENDER_CMAKE_C_FLAGS_MINSIZEREL "/MT ${COMMON_MSVC_FLAGS} /O1 /Ob1 /D NDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ set(BLENDER_CMAKE_C_FLAGS_RELEASE "/MT ${COMMON_MSVC_FLAGS} /O2 /Ob2 /DNDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ set(BLENDER_CMAKE_C_FLAGS_RELWITHDEBINFO "/MT ${COMMON_MSVC_FLAGS} /Zi /O2 /Ob1 /D NDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
if(WITH_OPTIMIZED_DEBUG)
- set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/MTd /O2 /Ob2 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/MTd ${COMMON_MSVC_FLAGS} /O2 /Ob2 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
else()
- set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /D PLATFORM_WINDOWS /MTd /Zi /Ob0 /Od /RTC1 /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /D PLATFORM_WINDOWS /MTd ${COMMON_MSVC_FLAGS} /Zi /Ob0 /Od /RTC1 /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
endif()
- set(BLENDER_CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
- set(BLENDER_CMAKE_CXX_FLAGS_RELEASE "/MT /O2 /Ob2 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
- set(BLENDER_CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ set(BLENDER_CMAKE_CXX_FLAGS_MINSIZEREL "/MT /${COMMON_MSVC_FLAGS} /O1 /Ob1 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ set(BLENDER_CMAKE_CXX_FLAGS_RELEASE "/MT ${COMMON_MSVC_FLAGS} /O2 /Ob2 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ set(BLENDER_CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MT ${COMMON_MSVC_FLAGS} /Zi /O2 /Ob1 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
set(PLATFORM_FLAGS)
set(PLATFORM_CXX_FLAGS)
diff --git a/build_files/build_environment/cmake/x264.cmake b/build_files/build_environment/cmake/x264.cmake
index 64029ca1b5e..f42015e4395 100644
--- a/build_files/build_environment/cmake/x264.cmake
+++ b/build_files/build_environment/cmake/x264.cmake
@@ -25,7 +25,7 @@ ExternalProject_Add(external_x264
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH SHA256=${X264_HASH}
PREFIX ${BUILD_DIR}/x264
- CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/x264
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/x264
--enable-static
--enable-pic
--disable-lavf
diff --git a/build_files/build_environment/patches/openal.diff b/build_files/build_environment/patches/openal.diff
new file mode 100644
index 00000000000..2c9862b95a0
--- /dev/null
+++ b/build_files/build_environment/patches/openal.diff
@@ -0,0 +1,13 @@
+diff -Naur external_openal_original/CMakeLists.txt external_openal/CMakeLists.txt
+--- external_openal_original/CMakeLists.txt 2016-01-24 20:12:39 -0700
++++ external_openal/CMakeLists.txt 2018-06-02 12:16:52 -0600
+@@ -885,7 +885,8 @@
+ OPTION(ALSOFT_REQUIRE_MMDEVAPI "Require MMDevApi backend" OFF)
+ IF(HAVE_WINDOWS_H)
+ # Check MMSystem backend
+- CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0502)
++ set(CMAKE_REQUIRED_FLAGS "-D_WIN32_WINNT=0x0502")
++ CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H)
+ IF(HAVE_MMSYSTEM_H)
+ CHECK_SHARED_FUNCTION_EXISTS(waveOutOpen "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
+ IF(HAVE_LIBWINMM)
diff --git a/build_files/build_environment/patches/osl.diff b/build_files/build_environment/patches/osl.diff
index 960a2506374..ccf34d99699 100644
--- a/build_files/build_environment/patches/osl.diff
+++ b/build_files/build_environment/patches/osl.diff
@@ -10,8 +10,8 @@ diff -Naur osl/src/external_osl/src/cmake/flexbison.cmake osl_bak/src/external_o
MAIN_DEPENDENCY ${flexsrc}
DEPENDS ${${compiler_headers}}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
---- a/src/include/OSL/oslconfig.h 2016-10-31 16:48:19 -0600
-+++ b/src/include/OSL/oslconfig.h 2018-05-27 11:18:08 -0600
+--- osl/src/external_osl/src/include/OSL/oslconfig.h 2016-10-31 16:48:19 -0600
++++ osl/src/external_osl/src/include/OSL/oslconfig.h 2018-05-27 11:18:08 -0600
@@ -44,12 +44,18 @@
// same if another packages is compiling against OSL and using these headers
// (OSL may be C++11 but the client package may be older, or vice versa --
diff --git a/build_files/build_environment/windows/build_deps.cmd b/build_files/build_environment/windows/build_deps.cmd
index 96280014df2..500e689cdc8 100644
--- a/build_files/build_environment/windows/build_deps.cmd
+++ b/build_files/build_environment/windows/build_deps.cmd
@@ -14,10 +14,18 @@ if NOT "%1" == "" (
set BuildDir=VS14
goto par2
)
+ if "%1" == "2017" (
+ echo "Building for VS2017"
+ set VSVER=15.0
+ set VSVER_SHORT=15
+ set BuildDir=VS15
+ goto par2
+ )
+
)
:usage
-Echo Usage build_deps 2013/2015 x64/x86
+Echo Usage build_deps 2013/2015/2017 x64/x86
goto exit
:par2
if NOT "%2" == "" (
@@ -31,6 +39,10 @@ if NOT "%2" == "" (
if "%1" == "2015" (
set CMAKE_BUILDER=Visual Studio 14 2015
)
+ if "%1" == "2017" (
+ set CMAKE_BUILDER=Visual Studio 15 2017
+ )
+
goto start
)
if "%2" == "x64" (
@@ -43,6 +55,10 @@ if NOT "%2" == "" (
if "%1" == "2015" (
set CMAKE_BUILDER=Visual Studio 14 2015 Win64
)
+ if "%1" == "2017" (
+ set CMAKE_BUILDER=Visual Studio 15 2017 Win64
+ )
+
goto start
)
)
diff --git a/build_files/cmake/Modules/FindAlembic.cmake b/build_files/cmake/Modules/FindAlembic.cmake
index 9f975c08e1a..59eb240804f 100644
--- a/build_files/cmake/Modules/FindAlembic.cmake
+++ b/build_files/cmake/Modules/FindAlembic.cmake
@@ -51,7 +51,7 @@ FIND_LIBRARY(ALEMBIC_LIBRARY
lib64 lib lib/static
)
-# handle the QUIETLY and REQUIRED arguments and set ALEMBIC_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set ALEMBIC_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ALEMBIC DEFAULT_MSG ALEMBIC_LIBRARY ALEMBIC_INCLUDE_DIR)
diff --git a/build_files/cmake/Modules/FindEigen3.cmake b/build_files/cmake/Modules/FindEigen3.cmake
index c1b25d4169c..2b23c2a6edc 100644
--- a/build_files/cmake/Modules/FindEigen3.cmake
+++ b/build_files/cmake/Modules/FindEigen3.cmake
@@ -40,7 +40,7 @@ FIND_PATH(EIGEN3_INCLUDE_DIR
include/eigen3
)
-# handle the QUIETLY and REQUIRED arguments and set EIGEN3_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set EIGEN3_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Eigen3 DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindFftw3.cmake b/build_files/cmake/Modules/FindFftw3.cmake
index 8917cc1c120..767846af015 100644
--- a/build_files/cmake/Modules/FindFftw3.cmake
+++ b/build_files/cmake/Modules/FindFftw3.cmake
@@ -52,7 +52,7 @@ FIND_LIBRARY(FFTW3_LIBRARY
lib64 lib
)
-# handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Fftw3 DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindGLEW.cmake b/build_files/cmake/Modules/FindGLEW.cmake
index 3057237f3c6..b36a3272e3d 100644
--- a/build_files/cmake/Modules/FindGLEW.cmake
+++ b/build_files/cmake/Modules/FindGLEW.cmake
@@ -49,7 +49,7 @@ FIND_LIBRARY(GLEW_LIBRARY
lib64 lib
)
-# handle the QUIETLY and REQUIRED arguments and set GLEW_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set GLEW_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Glew DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindIcuLinux.cmake b/build_files/cmake/Modules/FindIcuLinux.cmake
index 5ccd327da16..c5164913f7f 100644
--- a/build_files/cmake/Modules/FindIcuLinux.cmake
+++ b/build_files/cmake/Modules/FindIcuLinux.cmake
@@ -115,7 +115,7 @@ if(Boost_USE_STATIC_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_icu_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
-# handle the QUIETLY and REQUIRED arguments and set ICU_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set ICU_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Icu DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindJack.cmake b/build_files/cmake/Modules/FindJack.cmake
index ab4fdc99f25..dbfc30edb99 100644
--- a/build_files/cmake/Modules/FindJack.cmake
+++ b/build_files/cmake/Modules/FindJack.cmake
@@ -52,7 +52,7 @@ FIND_LIBRARY(JACK_LIBRARY
lib64 lib
)
-# handle the QUIETLY and REQUIRED arguments and set JACK_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set JACK_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Jack DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindJeMalloc.cmake b/build_files/cmake/Modules/FindJeMalloc.cmake
index 707739a3d98..506892b34ba 100644
--- a/build_files/cmake/Modules/FindJeMalloc.cmake
+++ b/build_files/cmake/Modules/FindJeMalloc.cmake
@@ -53,7 +53,7 @@ FIND_LIBRARY(JEMALLOC_LIBRARY
lib64 lib
)
-# handle the QUIETLY and REQUIRED arguments and set JEMALLOC_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set JEMALLOC_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(JeMalloc DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindLZO.cmake b/build_files/cmake/Modules/FindLZO.cmake
index 7aa4adca777..6a70186150f 100644
--- a/build_files/cmake/Modules/FindLZO.cmake
+++ b/build_files/cmake/Modules/FindLZO.cmake
@@ -50,7 +50,7 @@ FIND_LIBRARY(LZO_LIBRARY
lib64 lib
)
-# handle the QUIETLY and REQUIRED arguments and set LZO_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set LZO_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZO DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindOpenCOLLADA.cmake b/build_files/cmake/Modules/FindOpenCOLLADA.cmake
index ed9948b8a6c..45ef682cb61 100644
--- a/build_files/cmake/Modules/FindOpenCOLLADA.cmake
+++ b/build_files/cmake/Modules/FindOpenCOLLADA.cmake
@@ -1,7 +1,7 @@
# - Find OpenCOLLADA library
# Find the native OpenCOLLADA includes and library
# This module defines
-# OPENCOLLADA_INCLUDE_DIRS, where to find COLLADABaseUtils/ and
+# OPENCOLLADA_INCLUDE_DIRS, where to find COLLADABaseUtils/ and
# COLLADAFramework/, Set when OPENCOLLADA_INCLUDE_DIR is found.
# OPENCOLLADA_LIBRARIES, libraries to link against to use OpenCOLLADA.
# OPENCOLLADA_ROOT_DIR, The base directory to search for OpenCOLLADA.
@@ -129,7 +129,7 @@ FOREACH(COMPONENT ${_opencollada_FIND_STATIC_COMPONENTS})
ENDFOREACH()
-# handle the QUIETLY and REQUIRED arguments and set OPENCOLLADA_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set OPENCOLLADA_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenCOLLADA DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindOpenColorIO.cmake b/build_files/cmake/Modules/FindOpenColorIO.cmake
index bcc22f55bcc..1d26d6b0f86 100644
--- a/build_files/cmake/Modules/FindOpenColorIO.cmake
+++ b/build_files/cmake/Modules/FindOpenColorIO.cmake
@@ -68,7 +68,7 @@ FOREACH(COMPONENT ${_opencolorio_FIND_COMPONENTS})
ENDFOREACH()
-# handle the QUIETLY and REQUIRED arguments and set OPENCOLORIO_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set OPENCOLORIO_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenColorIO DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindOpenEXR.cmake b/build_files/cmake/Modules/FindOpenEXR.cmake
index ef8d76ea3a5..fa02d3f3f28 100644
--- a/build_files/cmake/Modules/FindOpenEXR.cmake
+++ b/build_files/cmake/Modules/FindOpenEXR.cmake
@@ -106,7 +106,7 @@ FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
FIND_LIBRARY(OPENEXR_${UPPERCOMPONENT}_LIBRARY
NAMES
- ${COMPONENT}-${_openexr_libs_ver} ${COMPONENT}
+ ${COMPONENT}-${_openexr_libs_ver} ${COMPONENT}
HINTS
${_openexr_SEARCH_DIRS}
PATH_SUFFIXES
@@ -117,7 +117,7 @@ ENDFOREACH()
UNSET(_openexr_libs_ver)
-# handle the QUIETLY and REQUIRED arguments and set OPENEXR_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set OPENEXR_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindOpenImageIO.cmake b/build_files/cmake/Modules/FindOpenImageIO.cmake
index 52b7856c79c..5652e1649c8 100644
--- a/build_files/cmake/Modules/FindOpenImageIO.cmake
+++ b/build_files/cmake/Modules/FindOpenImageIO.cmake
@@ -64,7 +64,7 @@ FIND_FILE(OPENIMAGEIO_IDIFF
bin
)
-# handle the QUIETLY and REQUIRED arguments and set OPENIMAGEIO_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set OPENIMAGEIO_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenImageIO DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindOpenJPEG.cmake b/build_files/cmake/Modules/FindOpenJPEG.cmake
index 4b021f13634..85a4c131fb1 100644
--- a/build_files/cmake/Modules/FindOpenJPEG.cmake
+++ b/build_files/cmake/Modules/FindOpenJPEG.cmake
@@ -53,7 +53,7 @@ FIND_LIBRARY(OPENJPEG_LIBRARY
lib64 lib
)
-# handle the QUIETLY and REQUIRED arguments and set OPENJPEG_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set OPENJPEG_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenJPEG DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindPCRE.cmake b/build_files/cmake/Modules/FindPCRE.cmake
index 1649a6cbb36..20b5c1d5c28 100644
--- a/build_files/cmake/Modules/FindPCRE.cmake
+++ b/build_files/cmake/Modules/FindPCRE.cmake
@@ -50,7 +50,7 @@ FIND_LIBRARY(PCRE_LIBRARY
lib64 lib
)
-# handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindPugiXML.cmake b/build_files/cmake/Modules/FindPugiXML.cmake
index 2a0dcf08c7e..629069c9032 100644
--- a/build_files/cmake/Modules/FindPugiXML.cmake
+++ b/build_files/cmake/Modules/FindPugiXML.cmake
@@ -53,7 +53,7 @@ FIND_LIBRARY(PUGIXML_LIBRARY
lib64 lib
)
-# handle the QUIETLY and REQUIRED arguments and set PUGIXML_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set PUGIXML_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PUGIXML DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindPythonLibsUnix.cmake b/build_files/cmake/Modules/FindPythonLibsUnix.cmake
index 493fb0df6a7..140f8be048a 100644
--- a/build_files/cmake/Modules/FindPythonLibsUnix.cmake
+++ b/build_files/cmake/Modules/FindPythonLibsUnix.cmake
@@ -175,7 +175,7 @@ UNSET(_IS_INC_CONF_DEF)
UNSET(_IS_LIB_DEF)
UNSET(_IS_LIB_PATH_DEF)
-# handle the QUIETLY and REQUIRED arguments and SET PYTHONLIBSUNIX_FOUND to TRUE IF
+# handle the QUIETLY and REQUIRED arguments and SET PYTHONLIBSUNIX_FOUND to TRUE IF
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibsUnix DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindSndFile.cmake b/build_files/cmake/Modules/FindSndFile.cmake
index c210c523c58..ef6fb73598f 100644
--- a/build_files/cmake/Modules/FindSndFile.cmake
+++ b/build_files/cmake/Modules/FindSndFile.cmake
@@ -50,7 +50,7 @@ FIND_LIBRARY(LIBSNDFILE_LIBRARY
lib64 lib
)
-# handle the QUIETLY and REQUIRED arguments and set LIBSNDFILE_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set LIBSNDFILE_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SndFile DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindSpacenav.cmake b/build_files/cmake/Modules/FindSpacenav.cmake
index 84599643c2d..593ed54a08e 100644
--- a/build_files/cmake/Modules/FindSpacenav.cmake
+++ b/build_files/cmake/Modules/FindSpacenav.cmake
@@ -52,7 +52,7 @@ FIND_LIBRARY(SPACENAV_LIBRARY
lib64 lib
)
-# handle the QUIETLY and REQUIRED arguments and set SPACENAV_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set SPACENAV_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Spacenav DEFAULT_MSG
diff --git a/build_files/cmake/Modules/FindXML2.cmake b/build_files/cmake/Modules/FindXML2.cmake
index d2df90fa2ec..e69a14c9306 100644
--- a/build_files/cmake/Modules/FindXML2.cmake
+++ b/build_files/cmake/Modules/FindXML2.cmake
@@ -50,7 +50,7 @@ FIND_LIBRARY(XML2_LIBRARY
lib64 lib
)
-# handle the QUIETLY and REQUIRED arguments and set XML2_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set XML2_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(XML2 DEFAULT_MSG
diff --git a/build_files/cmake/Modules/GTestTesting.cmake b/build_files/cmake/Modules/GTestTesting.cmake
index ba1334d750e..dd80013cb91 100644
--- a/build_files/cmake/Modules/GTestTesting.cmake
+++ b/build_files/cmake/Modules/GTestTesting.cmake
@@ -32,6 +32,7 @@ macro(BLENDER_SRC_GTEST_EX NAME SRC EXTRA_LIBS DO_ADD_TEST)
${EXTRA_LIBS}
${PLATFORM_LINKLIBS}
bf_testing_main
+ bf_intern_eigen
bf_intern_guardedalloc
extern_gtest
extern_gmock
diff --git a/build_files/cmake/RpmBuild.cmake b/build_files/cmake/RpmBuild.cmake
index f46c41e4d0e..36c8768dd0e 100644
--- a/build_files/cmake/RpmBuild.cmake
+++ b/build_files/cmake/RpmBuild.cmake
@@ -13,7 +13,7 @@ if(NOT DEFINED RPMBUILD)
if(RPMBUILD)
message(STATUS "RPM Build Found: ${RPMBUILD}")
- else()
+ else()
message(STATUS "RPM Build Not Found (rpmbuild). RPM generation will not be available")
endif()
@@ -21,6 +21,6 @@ endif()
if(RPMBUILD)
set(RPMBUILD_FOUND TRUE)
-else()
+else()
set(RPMBUILD_FOUND FALSE)
-endif() \ No newline at end of file
+endif()
diff --git a/build_files/cmake/config/blender_headless.cmake b/build_files/cmake/config/blender_headless.cmake
index 8f2ad03279c..73b43272643 100644
--- a/build_files/cmake/config/blender_headless.cmake
+++ b/build_files/cmake/config/blender_headless.cmake
@@ -5,7 +5,7 @@
# cmake -C../blender/build_files/cmake/config/blender_headless.cmake ../blender
#
-set(WITH_HEADLESS ON CACHE BOOL "" FORCE)
+set(WITH_HEADLESS ON CACHE BOOL "" FORCE)
# disable audio, its possible some devs may want this but for now disable
# so the python module doesnt hold the audio device and loads quickly.
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index a38a6805274..8cf90d0d22c 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -51,7 +51,7 @@ endmacro()
function(list_assert_duplicates
list_id
)
-
+
# message(STATUS "list data: ${list_id}")
list(LENGTH list_id _len_before)
@@ -242,7 +242,7 @@ function(blender_add_lib__impl
# listed is helpful for IDE's (QtCreator/MSVC)
blender_source_group("${sources}")
- #if enabled, set the FOLDER property for visual studio projects
+ #if enabled, set the FOLDER property for visual studio projects
if(WINDOWS_USE_VISUAL_STUDIO_FOLDERS)
get_filename_component(FolderDir ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
string(REPLACE ${CMAKE_SOURCE_DIR} "" FolderDir ${FolderDir})
@@ -352,6 +352,11 @@ function(SETUP_LIBDIRS)
endif()
endfunction()
+macro(setup_platform_linker_flags)
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}")
+ set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
+endmacro()
+
function(setup_liblinks
target
)
diff --git a/build_files/cmake/platform/platform_apple_xcode.cmake b/build_files/cmake/platform/platform_apple_xcode.cmake
index 8bb08b5a29f..1b8e13a0623 100644
--- a/build_files/cmake/platform/platform_apple_xcode.cmake
+++ b/build_files/cmake/platform/platform_apple_xcode.cmake
@@ -51,9 +51,9 @@ string(REPLACE "/Contents/Developer" "" XCODE_BUNDLE ${XCODE_CHECK}) # truncate
if(${CMAKE_GENERATOR} MATCHES "Xcode")
# earlier xcode has no bundled developer dir, no sense in getting xcode path from
- if(${XCODE_VERSION} VERSION_GREATER 4.2)
+ if(${XCODE_VERSION} VERSION_GREATER 4.2)
# reduce to XCode name without dp extension
- string(SUBSTRING "${XCODE_CHECK}" 14 6 DP_NAME)
+ string(SUBSTRING "${XCODE_CHECK}" 14 6 DP_NAME)
if(${DP_NAME} MATCHES Xcode5)
set(XCODE_VERSION 5)
endif()
@@ -64,7 +64,7 @@ if(${CMAKE_GENERATOR} MATCHES "Xcode")
message(FATAL_ERROR "Xcode 4.3 and higher must be used with cmake 2.8-8 or higher")
endif()
### end cmake incompatibility with xcode 4.3 and higher ###
-
+
if(${XCODE_VERSION} VERSION_EQUAL 4 OR ${XCODE_VERSION} VERSION_GREATER 4 AND ${XCODE_VERSION} VERSION_LESS 4.3)
# Xcode 4 defaults to the Apple LLVM Compiler.
# Override the default compiler selection because Blender only compiles with gcc up to xcode 4.2
@@ -85,7 +85,7 @@ if(${XCODE_VERSION} VERSION_LESS 4.3)
else()
# note: xcode-select path could be ambigous,
# cause /Applications/Xcode.app/Contents/Developer or /Applications/Xcode.app would be allowed
- # so i use a selfcomposed bundlepath here
+ # so i use a selfcomposed bundlepath here
set(OSX_SYSROOT_PREFIX ${XCODE_BUNDLE}/Contents/Developer/Platforms/MacOSX.platform)
message(STATUS "OSX_SYSROOT_PREFIX: " ${OSX_SYSROOT_PREFIX})
set(OSX_DEVELOPER_PREFIX /Developer/SDKs/MacOSX${OSX_SYSTEM}.sdk) # use guaranteed existing sdk
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index c14f6013394..468e82e8dac 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -31,7 +31,8 @@ endif()
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(MSVC_CLANG On)
- set(MSVC_REDIST_DIR $ENV{VCToolsRedistDir})
+ set(VC_TOOLS_DIR $ENV{VCToolsRedistDir} CACHE STRING "Location of the msvc redistributables")
+ set(MSVC_REDIST_DIR ${VC_TOOLS_DIR})
if (DEFINED MSVC_REDIST_DIR)
file(TO_CMAKE_PATH ${MSVC_REDIST_DIR} MSVC_REDIST_DIR)
else()
@@ -129,8 +130,8 @@ include(InstallRequiredSystemLibraries)
remove_cc_flag("/MDd" "/MD")
-if(MSVC_CLANG) # Clangs version of cl doesn't support all flags
- if(NOT WITH_CXX11) # C++11 is on by default in clang-cl and can't be turned off, if c++11 is not enabled in blender repress some c++11 related warnings.
+if(MSVC_CLANG) # Clangs version of cl doesn't support all flags
+ if(NOT WITH_CXX11) # C++11 is on by default in clang-cl and can't be turned off, if c++11 is not enabled in blender repress some c++11 related warnings.
set(CXX_WARN_FLAGS "-Wno-inconsistent-missing-override")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_WARN_FLAGS} /nologo /J /Gd /EHsc -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference ")
@@ -149,7 +150,7 @@ set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
-set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO ")
+set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO ")
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib ")
# Ignore meaningless for us linker warnings.
@@ -162,7 +163,7 @@ else()
set(PLATFORM_LINKFLAGS "/MACHINE:IX86 /LARGEADDRESSAWARE ${PLATFORM_LINKFLAGS}")
endif()
-set(PLATFORM_LINKFLAGS_DEBUG "/IGNORE:4099 /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib")
+set(PLATFORM_LINKFLAGS_DEBUG "${PLATFORM_LINKFLAGS_DEBUG} /IGNORE:4099 /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib")
if(NOT DEFINED LIBDIR)
@@ -424,7 +425,7 @@ if(WITH_OPENIMAGEIO)
set(OIIO_OPTIMIZED optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO.lib optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util.lib)
set(OIIO_DEBUG debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_d.lib debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util_d.lib)
set(OPENIMAGEIO_LIBRARIES ${OIIO_OPTIMIZED} ${OIIO_DEBUG})
-
+
set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0")
set(OPENCOLORIO_DEFINITIONS "-DOCIO_STATIC_BUILD")
set(OPENIMAGEIO_IDIFF "${OPENIMAGEIO}/bin/idiff.exe")
@@ -473,7 +474,7 @@ if(WITH_OPENVDB)
set(OPENVDB_LIBPATH ${LIBDIR}/openvdb/lib)
set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include ${TBB_INCLUDE_DIR})
set(OPENVDB_LIBRARIES optimized ${OPENVDB_LIBPATH}/openvdb.lib debug ${OPENVDB_LIBPATH}/openvdb_d.lib ${TBB_LIBRARIES} ${BLOSC_LIBRARIES})
-
+
endif()
if(WITH_ALEMBIC)
diff --git a/build_files/windows/configure_msbuild.cmd b/build_files/windows/configure_msbuild.cmd
index f06f3e317ee..f8c2a87de8e 100644
--- a/build_files/windows/configure_msbuild.cmd
+++ b/build_files/windows/configure_msbuild.cmd
@@ -1,5 +1,3 @@
-set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Visual Studio %BUILD_VS_VER% %BUILD_VS_YEAR%%WINDOWS_ARCH%" %TESTS_CMAKE_ARGS%
-
if "%BUILD_ARCH%"=="x64" (
set MSBUILD_PLATFORM=x64
) else if "%BUILD_ARCH%"=="x86" (
@@ -11,8 +9,17 @@ if "%BUILD_ARCH%"=="x64" (
)
if "%WITH_CLANG%"=="1" (
- set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -T"LLVM-vs2017"
+ set CLANG_CMAKE_ARGS=-T"LLVM-vs2017"
+ if "%WITH_ASAN%"=="1" (
+ set ASAN_CMAKE_ARGS=-DWITH_COMPILER_ASAN=On
+ )
+) else (
+ if "%WITH_ASAN%"=="1" (
+ echo ASAN is only supported with clang.
+ exit /b 1
+ )
)
+set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Visual Studio %BUILD_VS_VER% %BUILD_VS_YEAR%%WINDOWS_ARCH%" %TESTS_CMAKE_ARGS% %CLANG_CMAKE_ARGS% %ASAN_CMAKE_ARGS%
if NOT EXIST %BUILD_DIR%\nul (
mkdir %BUILD_DIR%
diff --git a/build_files/windows/configure_ninja.cmd b/build_files/windows/configure_ninja.cmd
index f882ca3dbf0..224d761adf6 100644
--- a/build_files/windows/configure_ninja.cmd
+++ b/build_files/windows/configure_ninja.cmd
@@ -1,3 +1,9 @@
+ninja --version 1>NUL 2>&1
+if %ERRORLEVEL% NEQ 0 (
+ echo "Ninja not detected in the path"
+ exit /b 1
+ )
+
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Ninja" %TESTS_CMAKE_ARGS% -DCMAKE_BUILD_TYPE=%BUILD_TYPE%
if "%WITH_CLANG%" == "1" (
@@ -27,6 +33,16 @@ set LLVM_DIR=
rem build and tested against 2017 15.7
set CFLAGS=-m64 -fmsc-version=1914
set CXXFLAGS=-m64 -fmsc-version=1914
+ if "%WITH_ASAN%"=="1" (
+ set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DWITH_COMPILER_ASAN=On
+ )
+)
+
+if "%WITH_ASAN%"=="1" (
+ if "%WITH_CLANG%" == "" (
+ echo ASAN is only supported with clang.
+ exit /b 1
+ )
)
if NOT "%verbose%" == "" (
diff --git a/build_files/windows/detect_msvc2017.cmd b/build_files/windows/detect_msvc2017.cmd
index 6a82adb5a4d..060e9f88617 100644
--- a/build_files/windows/detect_msvc2017.cmd
+++ b/build_files/windows/detect_msvc2017.cmd
@@ -12,6 +12,11 @@ if not exist "%vs_where%" (
goto FAIL
)
)
+
+if NOT "%verbose%" == "" (
+ echo "%vs_where%" -latest %VSWHERE_ARGS% -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64`
+ )
+
for /f "usebackq tokens=1* delims=: " %%i in (`"%vs_where%" -latest %VSWHERE_ARGS% -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64`) do (
if /i "%%i"=="installationPath" set VS_InstallDir=%%j
)
diff --git a/build_files/windows/parse_arguments.cmd b/build_files/windows/parse_arguments.cmd
index 016bc875c3b..8a6d743978d 100644
--- a/build_files/windows/parse_arguments.cmd
+++ b/build_files/windows/parse_arguments.cmd
@@ -40,7 +40,10 @@ if NOT "%1" == "" (
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS%
set WITH_CLANG=1
) else if "%1" == "release" (
+ set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\blender_release.cmake"
set TARGET=Release
+ ) else if "%1" == "asan" (
+ set WITH_ASAN=1
) else if "%1" == "x86" (
set BUILD_ARCH=x86
) else if "%1" == "x64" (
@@ -50,6 +53,10 @@ if NOT "%1" == "" (
) else if "%1" == "2017pre" (
set BUILD_VS_YEAR=2017
set VSWHERE_ARGS=-prerelease
+ set BUILD_VS_YEAR=2017
+ ) else if "%1" == "2017b" (
+ set BUILD_VS_YEAR=2017
+ set VSWHERE_ARGS=-products Microsoft.VisualStudio.Product.BuildTools
) else if "%1" == "2015" (
set BUILD_VS_YEAR=2015
) else if "%1" == "2013" (
diff --git a/build_files/windows/reset_variables.cmd b/build_files/windows/reset_variables.cmd
index d9a50a7f809..a522ed7407f 100644
--- a/build_files/windows/reset_variables.cmd
+++ b/build_files/windows/reset_variables.cmd
@@ -21,4 +21,7 @@ set BUILD_UPDATE=
set BUILD_SHOW_HASHES=
set SHOW_HELP=
set BUILD_WITH_NINJA=
-set WITH_CLANG= \ No newline at end of file
+set WITH_CLANG=
+set WITH_ASAN=
+set CLANG_CMAKE_ARGS=
+set ASAN_CMAKE_ARGS=
diff --git a/build_files/windows/show_help.cmd b/build_files/windows/show_help.cmd
index 0524e8a84fc..2b297120f4b 100644
--- a/build_files/windows/show_help.cmd
+++ b/build_files/windows/show_help.cmd
@@ -23,7 +23,13 @@ echo - buildir [newdir] ^(override default build folder^)
echo - x86 ^(override host auto-detect and build 32 bit code^)
echo - x64 ^(override host auto-detect and build 64 bit code^)
echo - 2013 ^(build with visual studio 2013^)
-echo - 2015 ^(build with visual studio 2015^) [EXPERIMENTAL]
-echo - 2017 ^(build with visual studio 2017^) [EXPERIMENTAL]
-echo - 2017pre ^(build with visual studio 2017 pre-release^) [EXPERIMENTAL]
+echo.
+echo Experimental options
+echo - 2015 ^(build with visual studio 2015^)
+echo - 2017 ^(build with visual studio 2017^)
+echo - 2017pre ^(build with visual studio 2017 pre-release^)
+echo - 2017b ^(build with visual studio 2017 Build Tools^)
+echo - clang ^(enable building with clang^)
+echo - asan ^(enable asan when building with clang^)
+echo - ninja ^(enable building with ninja instead of msbuild^)
echo.
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEG.cpp b/extern/audaspace/plugins/ffmpeg/FFMPEG.cpp
index 7f9b762f816..3ffe963b2b9 100644
--- a/extern/audaspace/plugins/ffmpeg/FFMPEG.cpp
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEG.cpp
@@ -23,7 +23,9 @@ AUD_NAMESPACE_BEGIN
FFMPEG::FFMPEG()
{
+#if LIBAVCODEC_VERSION_MAJOR < 58
av_register_all();
+#endif
}
void FFMPEG::registerPlugin()
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
index 6b79cc5abfd..2da84ce0d4c 100644
--- a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
@@ -22,37 +22,37 @@
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avio.h>
+#include <libavutil/avutil.h>
}
AUD_NAMESPACE_BEGIN
+#if LIBAVCODEC_VERSION_MAJOR < 58
+#define FFMPEG_OLD_CODE
+#endif
+
int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
{
- AVFrame* frame = nullptr;
+ int buf_size = buffer.getSize();
+ int buf_pos = 0;
+
+#ifdef FFMPEG_OLD_CODE
int got_frame;
int read_length;
uint8_t* orig_data = packet.data;
int orig_size = packet.size;
- int buf_size = buffer.getSize();
- int buf_pos = 0;
-
while(packet.size > 0)
{
got_frame = 0;
- if(!frame)
- frame = av_frame_alloc();
- else
- av_frame_unref(frame);
-
- read_length = avcodec_decode_audio4(m_codecCtx, frame, &got_frame, &packet);
+ read_length = avcodec_decode_audio4(m_codecCtx, m_frame, &got_frame, &packet);
if(read_length < 0)
break;
if(got_frame)
{
- int data_size = av_samples_get_buffer_size(nullptr, m_codecCtx->channels, frame->nb_samples, m_codecCtx->sample_fmt, 1);
+ int data_size = av_samples_get_buffer_size(nullptr, m_codecCtx->channels, m_frame->nb_samples, m_codecCtx->sample_fmt, 1);
if(buf_size - buf_pos < data_size)
{
@@ -62,18 +62,18 @@ int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
if(m_tointerleave)
{
- int single_size = data_size / m_codecCtx->channels / frame->nb_samples;
+ int single_size = data_size / m_codecCtx->channels / m_frame->nb_samples;
for(int channel = 0; channel < m_codecCtx->channels; channel++)
{
- for(int i = 0; i < frame->nb_samples; i++)
+ for(int i = 0; i < m_frame->nb_samples; i++)
{
std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos + ((m_codecCtx->channels * i) + channel) * single_size,
- frame->data[channel] + i * single_size, single_size);
+ m_frame->data[channel] + i * single_size, single_size);
}
}
}
else
- std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos, frame->data[0], data_size);
+ std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos, m_frame->data[0], data_size);
buf_pos += data_size;
}
@@ -83,7 +83,42 @@ int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
packet.data = orig_data;
packet.size = orig_size;
- av_free(frame);
+#else
+ avcodec_send_packet(m_codecCtx, &packet);
+
+ while(true)
+ {
+ auto ret = avcodec_receive_frame(m_codecCtx, m_frame);
+
+ if(ret != 0)
+ break;
+
+ int data_size = av_samples_get_buffer_size(nullptr, m_codecCtx->channels, m_frame->nb_samples, m_codecCtx->sample_fmt, 1);
+
+ if(buf_size - buf_pos < data_size)
+ {
+ buffer.resize(buf_size + data_size, true);
+ buf_size += data_size;
+ }
+
+ if(m_tointerleave)
+ {
+ int single_size = data_size / m_codecCtx->channels / m_frame->nb_samples;
+ for(int channel = 0; channel < m_codecCtx->channels; channel++)
+ {
+ for(int i = 0; i < m_frame->nb_samples; i++)
+ {
+ std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos + ((m_codecCtx->channels * i) + channel) * single_size,
+ m_frame->data[channel] + i * single_size, single_size);
+ }
+ }
+ }
+ else
+ std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos, m_frame->data[0], data_size);
+
+ buf_pos += data_size;
+ }
+#endif
return buf_pos;
}
@@ -101,7 +136,11 @@ void FFMPEGReader::init()
for(unsigned int i = 0; i < m_formatCtx->nb_streams; i++)
{
+#ifdef FFMPEG_OLD_CODE
if((m_formatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+#else
+ if((m_formatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
+#endif
&& (m_stream < 0))
{
m_stream=i;
@@ -112,12 +151,34 @@ void FFMPEGReader::init()
if(m_stream == -1)
AUD_THROW(FileException, "File couldn't be read, no audio stream found by ffmpeg.");
- m_codecCtx = m_formatCtx->streams[m_stream]->codec;
-
// get a decoder and open it
- AVCodec* aCodec = avcodec_find_decoder(m_codecCtx->codec_id);
+#ifndef FFMPEG_OLD_CODE
+ AVCodec* aCodec = avcodec_find_decoder(m_formatCtx->streams[m_stream]->codecpar->codec_id);
+
if(!aCodec)
AUD_THROW(FileException, "File couldn't be read, no decoder found with ffmpeg.");
+#endif
+
+ m_frame = av_frame_alloc();
+
+ if(!m_frame)
+ AUD_THROW(FileException, "File couldn't be read, ffmpeg frame couldn't be allocated.");
+
+#ifdef FFMPEG_OLD_CODE
+ m_codecCtx = m_formatCtx->streams[m_stream]->codec;
+
+ AVCodec* aCodec = avcodec_find_decoder(m_codecCtx->codec_id);
+#else
+ m_codecCtx = avcodec_alloc_context3(aCodec);
+#endif
+
+ if(!m_codecCtx)
+ AUD_THROW(FileException, "File couldn't be read, ffmpeg context couldn't be allocated.");
+
+#ifndef FFMPEG_OLD_CODE
+ if(avcodec_parameters_to_context(m_codecCtx, m_formatCtx->streams[m_stream]->codecpar) < 0)
+ AUD_THROW(FileException, "File couldn't be read, ffmpeg decoder parameters couldn't be copied to decoder context.");
+#endif
if(avcodec_open2(m_codecCtx, aCodec, nullptr) < 0)
AUD_THROW(FileException, "File couldn't be read, ffmpeg codec couldn't be opened.");
@@ -157,6 +218,8 @@ void FFMPEGReader::init()
FFMPEGReader::FFMPEGReader(std::string filename) :
m_pkgbuf(),
m_formatCtx(nullptr),
+ m_codecCtx(nullptr),
+ m_frame(nullptr),
m_aviocontext(nullptr),
m_membuf(nullptr)
{
@@ -177,12 +240,14 @@ FFMPEGReader::FFMPEGReader(std::string filename) :
FFMPEGReader::FFMPEGReader(std::shared_ptr<Buffer> buffer) :
m_pkgbuf(),
+ m_codecCtx(nullptr),
+ m_frame(nullptr),
m_membuffer(buffer),
m_membufferpos(0)
{
- m_membuf = reinterpret_cast<data_t*>(av_malloc(FF_MIN_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE));
+ m_membuf = reinterpret_cast<data_t*>(av_malloc(AV_INPUT_BUFFER_MIN_SIZE + AV_INPUT_BUFFER_PADDING_SIZE));
- m_aviocontext = avio_alloc_context(m_membuf, FF_MIN_BUFFER_SIZE, 0, this, read_packet, nullptr, seek_packet);
+ m_aviocontext = avio_alloc_context(m_membuf, AV_INPUT_BUFFER_MIN_SIZE, 0, this, read_packet, nullptr, seek_packet);
if(!m_aviocontext)
{
@@ -212,7 +277,14 @@ FFMPEGReader::FFMPEGReader(std::shared_ptr<Buffer> buffer) :
FFMPEGReader::~FFMPEGReader()
{
+ if(m_frame)
+ av_frame_free(&m_frame);
+#ifdef FFMPEG_OLD_CODE
avcodec_close(m_codecCtx);
+#else
+ if(m_codecCtx)
+ avcodec_free_context(&m_codecCtx);
+#endif
avformat_close_input(&m_formatCtx);
}
@@ -312,7 +384,7 @@ void FFMPEGReader::seek(int position)
}
}
}
- av_free_packet(&packet);
+ av_packet_unref(&packet);
}
}
else
@@ -343,7 +415,7 @@ Specs FFMPEGReader::getSpecs() const
void FFMPEGReader::read(int& length, bool& eos, sample_t* buffer)
{
// read packages and decode them
- AVPacket packet;
+ AVPacket packet = {};
int data_size = 0;
int pkgbuf_pos;
int left = length;
@@ -359,7 +431,7 @@ void FFMPEGReader::read(int& length, bool& eos, sample_t* buffer)
data_size = std::min(pkgbuf_pos, left * sample_size);
m_convert((data_t*) buf, (data_t*) m_pkgbuf.getBuffer(), data_size / AUD_FORMAT_SIZE(m_specs.format));
buf += data_size / AUD_FORMAT_SIZE(m_specs.format);
- left -= data_size/sample_size;
+ left -= data_size / sample_size;
}
// for each frame read as long as there isn't enough data already
@@ -375,9 +447,9 @@ void FFMPEGReader::read(int& length, bool& eos, sample_t* buffer)
data_size = std::min(pkgbuf_pos, left * sample_size);
m_convert((data_t*) buf, (data_t*) m_pkgbuf.getBuffer(), data_size / AUD_FORMAT_SIZE(m_specs.format));
buf += data_size / AUD_FORMAT_SIZE(m_specs.format);
- left -= data_size/sample_size;
+ left -= data_size / sample_size;
}
- av_free_packet(&packet);
+ av_packet_unref(&packet);
}
// read more data than necessary?
if(pkgbuf_pos > data_size)
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.h b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.h
index e2ae959912d..a69ac7709c8 100644
--- a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.h
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.h
@@ -80,6 +80,11 @@ private:
AVCodecContext* m_codecCtx;
/**
+ * The AVFrame structure for using ffmpeg.
+ */
+ AVFrame* m_frame;
+
+ /**
* The AVIOContext to read the data from.
*/
AVIOContext* m_aviocontext;
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
index f79f0f7fc6b..09b70897c31 100644
--- a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
@@ -27,6 +27,10 @@ extern "C" {
AUD_NAMESPACE_BEGIN
+#if LIBAVCODEC_VERSION_MAJOR < 58
+#define FFMPEG_OLD_CODE
+#endif
+
void FFMPEGWriter::encode()
{
sample_t* data = m_input_buffer.getBuffer();
@@ -58,82 +62,106 @@ void FFMPEGWriter::encode()
if(m_input_size)
m_convert(reinterpret_cast<data_t*>(data), reinterpret_cast<data_t*>(data), m_input_samples * m_specs.channels);
- AVPacket packet;
-
- packet.data = nullptr;
- packet.size = 0;
+#ifdef FFMPEG_OLD_CODE
+ m_packet->data = nullptr;
+ m_packet->size = 0;
- av_init_packet(&packet);
+ av_init_packet(m_packet);
- AVFrame* frame = av_frame_alloc();
- av_frame_unref(frame);
+ av_frame_unref(m_frame);
int got_packet;
+#endif
- frame->nb_samples = m_input_samples;
- frame->format = m_codecCtx->sample_fmt;
- frame->channel_layout = m_codecCtx->channel_layout;
+ m_frame->nb_samples = m_input_samples;
+ m_frame->format = m_codecCtx->sample_fmt;
+ m_frame->channel_layout = m_codecCtx->channel_layout;
- if(avcodec_fill_audio_frame(frame, m_specs.channels, m_codecCtx->sample_fmt, reinterpret_cast<data_t*>(data), m_input_buffer.getSize(), 0) < 0)
+ if(avcodec_fill_audio_frame(m_frame, m_specs.channels, m_codecCtx->sample_fmt, reinterpret_cast<data_t*>(data), m_input_buffer.getSize(), 0) < 0)
AUD_THROW(FileException, "File couldn't be written, filling the audio frame failed with ffmpeg.");
AVRational sample_time = { 1, static_cast<int>(m_specs.rate) };
- frame->pts = av_rescale_q(m_position - m_input_samples, m_codecCtx->time_base, sample_time);
+ m_frame->pts = av_rescale_q(m_position - m_input_samples, m_codecCtx->time_base, sample_time);
- if(avcodec_encode_audio2(m_codecCtx, &packet, frame, &got_packet))
+#ifdef FFMPEG_OLD_CODE
+ if(avcodec_encode_audio2(m_codecCtx, m_packet, m_frame, &got_packet))
{
- av_frame_free(&frame);
AUD_THROW(FileException, "File couldn't be written, audio encoding failed with ffmpeg.");
}
if(got_packet)
{
- packet.flags |= AV_PKT_FLAG_KEY;
- packet.stream_index = m_stream->index;
- if(av_write_frame(m_formatCtx, &packet) < 0)
+ m_packet->flags |= AV_PKT_FLAG_KEY;
+ m_packet->stream_index = m_stream->index;
+ if(av_write_frame(m_formatCtx, m_packet) < 0)
{
- av_free_packet(&packet);
- av_frame_free(&frame);
+ av_free_packet(m_packet);
AUD_THROW(FileException, "Frame couldn't be writen to the file with ffmpeg.");
}
- av_free_packet(&packet);
+ av_free_packet(m_packet);
}
+#else
+ if(avcodec_send_frame(m_codecCtx, m_frame) < 0)
+ AUD_THROW(FileException, "File couldn't be written, audio encoding failed with ffmpeg.");
+
+ while(avcodec_receive_packet(m_codecCtx, m_packet) == 0)
+ {
+ m_packet->stream_index = m_stream->index;
- av_frame_free(&frame);
+ if(av_write_frame(m_formatCtx, m_packet) < 0)
+ AUD_THROW(FileException, "Frame couldn't be writen to the file with ffmpeg.");
+ }
+#endif
}
void FFMPEGWriter::close()
{
+#ifdef FFMPEG_OLD_CODE
int got_packet = true;
while(got_packet)
{
- AVPacket packet;
+ m_packet->data = nullptr;
+ m_packet->size = 0;
- packet.data = nullptr;
- packet.size = 0;
+ av_init_packet(m_packet);
- av_init_packet(&packet);
-
- if(avcodec_encode_audio2(m_codecCtx, &packet, nullptr, &got_packet))
+ if(avcodec_encode_audio2(m_codecCtx, m_packet, nullptr, &got_packet))
AUD_THROW(FileException, "File end couldn't be written, audio encoding failed with ffmpeg.");
if(got_packet)
{
- packet.flags |= AV_PKT_FLAG_KEY;
- packet.stream_index = m_stream->index;
- if(av_write_frame(m_formatCtx, &packet))
+ m_packet->flags |= AV_PKT_FLAG_KEY;
+ m_packet->stream_index = m_stream->index;
+ if(av_write_frame(m_formatCtx, m_packet))
{
- av_free_packet(&packet);
+ av_free_packet(m_packet);
AUD_THROW(FileException, "Final frames couldn't be writen to the file with ffmpeg.");
}
- av_free_packet(&packet);
+ av_free_packet(m_packet);
}
}
+#else
+ if(avcodec_send_frame(m_codecCtx, nullptr) < 0)
+ AUD_THROW(FileException, "File couldn't be written, audio encoding failed with ffmpeg.");
+
+ while(avcodec_receive_packet(m_codecCtx, m_packet) == 0)
+ {
+ m_packet->stream_index = m_stream->index;
+
+ if(av_write_frame(m_formatCtx, m_packet) < 0)
+ AUD_THROW(FileException, "Frame couldn't be writen to the file with ffmpeg.");
+ }
+#endif
}
FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate) :
m_position(0),
m_specs(specs),
+ m_formatCtx(nullptr),
+ m_codecCtx(nullptr),
+ m_stream(nullptr),
+ m_packet(nullptr),
+ m_frame(nullptr),
m_input_samples(0),
m_deinterleave(false)
{
@@ -142,75 +170,105 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container fo
if(avformat_alloc_output_context2(&m_formatCtx, nullptr, formats[format], filename.c_str()) < 0)
AUD_THROW(FileException, "File couldn't be written, format couldn't be found with ffmpeg.");
- m_outputFmt = m_formatCtx->oformat;
+ AVOutputFormat* outputFmt = m_formatCtx->oformat;
- if(!m_outputFmt) {
+ if(!outputFmt) {
avformat_free_context(m_formatCtx);
AUD_THROW(FileException, "File couldn't be written, output format couldn't be found with ffmpeg.");
}
- m_outputFmt->audio_codec = AV_CODEC_ID_NONE;
+ outputFmt->audio_codec = AV_CODEC_ID_NONE;
switch(codec)
{
case CODEC_AAC:
- m_outputFmt->audio_codec = AV_CODEC_ID_AAC;
+ outputFmt->audio_codec = AV_CODEC_ID_AAC;
break;
case CODEC_AC3:
- m_outputFmt->audio_codec = AV_CODEC_ID_AC3;
+ outputFmt->audio_codec = AV_CODEC_ID_AC3;
break;
case CODEC_FLAC:
- m_outputFmt->audio_codec = AV_CODEC_ID_FLAC;
+ outputFmt->audio_codec = AV_CODEC_ID_FLAC;
break;
case CODEC_MP2:
- m_outputFmt->audio_codec = AV_CODEC_ID_MP2;
+ outputFmt->audio_codec = AV_CODEC_ID_MP2;
break;
case CODEC_MP3:
- m_outputFmt->audio_codec = AV_CODEC_ID_MP3;
+ outputFmt->audio_codec = AV_CODEC_ID_MP3;
break;
case CODEC_OPUS:
- m_outputFmt->audio_codec = AV_CODEC_ID_OPUS;
+ outputFmt->audio_codec = AV_CODEC_ID_OPUS;
break;
case CODEC_PCM:
switch(specs.format)
{
case FORMAT_U8:
- m_outputFmt->audio_codec = AV_CODEC_ID_PCM_U8;
+ outputFmt->audio_codec = AV_CODEC_ID_PCM_U8;
break;
case FORMAT_S16:
- m_outputFmt->audio_codec = AV_CODEC_ID_PCM_S16LE;
+ outputFmt->audio_codec = AV_CODEC_ID_PCM_S16LE;
break;
case FORMAT_S24:
- m_outputFmt->audio_codec = AV_CODEC_ID_PCM_S24LE;
+ outputFmt->audio_codec = AV_CODEC_ID_PCM_S24LE;
break;
case FORMAT_S32:
- m_outputFmt->audio_codec = AV_CODEC_ID_PCM_S32LE;
+ outputFmt->audio_codec = AV_CODEC_ID_PCM_S32LE;
break;
case FORMAT_FLOAT32:
- m_outputFmt->audio_codec = AV_CODEC_ID_PCM_F32LE;
+ outputFmt->audio_codec = AV_CODEC_ID_PCM_F32LE;
break;
case FORMAT_FLOAT64:
- m_outputFmt->audio_codec = AV_CODEC_ID_PCM_F64LE;
+ outputFmt->audio_codec = AV_CODEC_ID_PCM_F64LE;
break;
default:
- m_outputFmt->audio_codec = AV_CODEC_ID_NONE;
+ outputFmt->audio_codec = AV_CODEC_ID_NONE;
break;
}
break;
case CODEC_VORBIS:
- m_outputFmt->audio_codec = AV_CODEC_ID_VORBIS;
+ outputFmt->audio_codec = AV_CODEC_ID_VORBIS;
break;
default:
- m_outputFmt->audio_codec = AV_CODEC_ID_NONE;
+ outputFmt->audio_codec = AV_CODEC_ID_NONE;
+ break;
+ }
+
+ uint64_t channel_layout = 0;
+
+ switch(m_specs.channels)
+ {
+ case CHANNELS_MONO:
+ channel_layout = AV_CH_LAYOUT_MONO;
+ break;
+ case CHANNELS_STEREO:
+ channel_layout = AV_CH_LAYOUT_STEREO;
+ break;
+ case CHANNELS_STEREO_LFE:
+ channel_layout = AV_CH_LAYOUT_2POINT1;
+ break;
+ case CHANNELS_SURROUND4:
+ channel_layout = AV_CH_LAYOUT_QUAD;
+ break;
+ case CHANNELS_SURROUND5:
+ channel_layout = AV_CH_LAYOUT_5POINT0_BACK;
+ break;
+ case CHANNELS_SURROUND51:
+ channel_layout = AV_CH_LAYOUT_5POINT1_BACK;
+ break;
+ case CHANNELS_SURROUND61:
+ channel_layout = AV_CH_LAYOUT_6POINT1_BACK;
+ break;
+ case CHANNELS_SURROUND71:
+ channel_layout = AV_CH_LAYOUT_7POINT1;
break;
}
try
{
- if(m_outputFmt->audio_codec == AV_CODEC_ID_NONE)
+ if(outputFmt->audio_codec == AV_CODEC_ID_NONE)
AUD_THROW(FileException, "File couldn't be written, audio codec not found with ffmpeg.");
- AVCodec* codec = avcodec_find_encoder(m_outputFmt->audio_codec);
+ AVCodec* codec = avcodec_find_encoder(outputFmt->audio_codec);
if(!codec)
AUD_THROW(FileException, "File couldn't be written, audio encoder couldn't be found with ffmpeg.");
@@ -220,7 +278,14 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container fo
m_stream->id = m_formatCtx->nb_streams - 1;
+#ifdef FFMPEG_OLD_CODE
m_codecCtx = m_stream->codec;
+#else
+ m_codecCtx = avcodec_alloc_context3(codec);
+#endif
+
+ if(!m_codecCtx)
+ AUD_THROW(FileException, "File couldn't be written, context creation failed with ffmpeg.");
switch(m_specs.format)
{
@@ -247,7 +312,7 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container fo
}
if(m_formatCtx->oformat->flags & AVFMT_GLOBALHEADER)
- m_codecCtx->flags |= CODEC_FLAG_GLOBAL_HEADER;
+ m_codecCtx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
bool format_supported = false;
@@ -328,9 +393,13 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container fo
m_specs.rate = m_codecCtx->sample_rate;
- m_codecCtx->codec_id = m_outputFmt->audio_codec;
+#ifdef FFMPEG_OLD_CODE
+ m_codecCtx->codec_id = outputFmt->audio_codec;
+#endif
+
m_codecCtx->codec_type = AVMEDIA_TYPE_AUDIO;
m_codecCtx->bit_rate = bitrate;
+ m_codecCtx->channel_layout = channel_layout;
m_codecCtx->channels = m_specs.channels;
m_stream->time_base.num = m_codecCtx->time_base.num = 1;
m_stream->time_base.den = m_codecCtx->time_base.den = m_codecCtx->sample_rate;
@@ -338,6 +407,11 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container fo
if(avcodec_open2(m_codecCtx, codec, nullptr) < 0)
AUD_THROW(FileException, "File couldn't be written, encoder couldn't be opened with ffmpeg.");
+#ifndef FFMPEG_OLD_CODE
+ if(avcodec_parameters_from_context(m_stream->codecpar, m_codecCtx) < 0)
+ AUD_THROW(FileException, "File couldn't be written, codec parameters couldn't be copied to the context.");
+#endif
+
int samplesize = std::max(int(AUD_SAMPLE_SIZE(m_specs)), AUD_DEVICE_SAMPLE_SIZE(m_specs));
if((m_input_size = m_codecCtx->frame_size))
@@ -346,13 +420,26 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container fo
if(avio_open(&m_formatCtx->pb, filename.c_str(), AVIO_FLAG_WRITE))
AUD_THROW(FileException, "File couldn't be written, file opening failed with ffmpeg.");
- avformat_write_header(m_formatCtx, nullptr);
+ if(avformat_write_header(m_formatCtx, nullptr) < 0)
+ AUD_THROW(FileException, "File couldn't be written, writing the header failed.");
}
catch(Exception&)
{
+#ifndef FFMPEG_OLD_CODE
+ if(m_codecCtx)
+ avcodec_free_context(&m_codecCtx);
+#endif
avformat_free_context(m_formatCtx);
throw;
}
+
+#ifdef FFMPEG_OLD_CODE
+ m_packet = new AVPacket({});
+#else
+ m_packet = av_packet_alloc();
+#endif
+
+ m_frame = av_frame_alloc();
}
FFMPEGWriter::~FFMPEGWriter()
@@ -365,9 +452,26 @@ FFMPEGWriter::~FFMPEGWriter()
av_write_trailer(m_formatCtx);
+ if(m_frame)
+ av_frame_free(&m_frame);
+
+ if(m_packet)
+ {
+#ifdef FFMPEG_OLD_CODE
+ delete m_packet;
+#else
+ av_packet_free(&m_packet);
+#endif
+ }
+
+#ifdef FFMPEG_OLD_CODE
avcodec_close(m_codecCtx);
+#else
+ if(m_codecCtx)
+ avcodec_free_context(&m_codecCtx);
+#endif
- avio_close(m_formatCtx->pb);
+ avio_closep(&m_formatCtx->pb);
avformat_free_context(m_formatCtx);
}
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.h b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.h
index 690185deb64..c22f479d83c 100644
--- a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.h
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.h
@@ -66,14 +66,19 @@ private:
AVCodecContext* m_codecCtx;
/**
- * The AVOutputFormat structure for using ffmpeg.
+ * The AVStream structure for using ffmpeg.
*/
- AVOutputFormat* m_outputFmt;
+ AVStream* m_stream;
/**
- * The AVStream structure for using ffmpeg.
+ * The AVPacket structure for using ffmpeg.
*/
- AVStream* m_stream;
+ AVPacket* m_packet;
+
+ /**
+ * The AVFrame structure for using ffmpeg.
+ */
+ AVFrame* m_frame;
/**
* The input buffer for the format converted data before encoding.
diff --git a/intern/cycles/blender/addon/__init__.py b/intern/cycles/blender/addon/__init__.py
index 353f2a1ad5b..6e64ed609b7 100644
--- a/intern/cycles/blender/addon/__init__.py
+++ b/intern/cycles/blender/addon/__init__.py
@@ -78,7 +78,7 @@ class CyclesRender(bpy.types.RenderEngine):
engine.reset(self, data, depsgraph)
- def render_to_image(self, depsgraph):
+ def render(self, depsgraph):
engine.render(self, depsgraph)
def bake(self, depsgraph, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result):
@@ -93,7 +93,7 @@ class CyclesRender(bpy.types.RenderEngine):
engine.reset(self, context.blend_data, context.depsgraph)
engine.sync(self, context.depsgraph, context.blend_data)
- def render_to_view(self, context):
+ def view_draw(self, context):
engine.draw(self, context.depsgraph, context.region, context.space_data, context.region_data)
def update_script_node(self, node):
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index f3403602bea..3b79b6e52fd 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -1154,7 +1154,7 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
default='THICK',
)
cls.cull_backfacing = BoolProperty(
- name="Cull back-faces",
+ name="Cull Back-faces",
description="Do not test the back-face of each strand",
default=True,
)
@@ -1330,49 +1330,6 @@ class CyclesRenderLayerSettings(bpy.types.PropertyGroup):
del bpy.types.ViewLayer.cycles
-class CyclesCurveSettings(bpy.types.PropertyGroup):
- @classmethod
- def register(cls):
- bpy.types.ParticleSettings.cycles = PointerProperty(
- name="Cycles Hair Settings",
- description="Cycles hair settings",
- type=cls,
- )
- cls.radius_scale = FloatProperty(
- name="Radius Scaling",
- description="Multiplier of width properties",
- min=0.0, max=1000.0,
- default=0.01,
- )
- cls.root_width = FloatProperty(
- name="Root Size",
- description="Strand's width at root",
- min=0.0, max=1000.0,
- default=1.0,
- )
- cls.tip_width = FloatProperty(
- name="Tip Multiplier",
- description="Strand's width at tip",
- min=0.0, max=1000.0,
- default=0.0,
- )
- cls.shape = FloatProperty(
- name="Strand Shape",
- description="Strand shape parameter",
- min=-1.0, max=1.0,
- default=0.0,
- )
- cls.use_closetip = BoolProperty(
- name="Close tip",
- description="Set tip radius to zero",
- default=True,
- )
-
- @classmethod
- def unregister(cls):
- del bpy.types.ParticleSettings.cycles
-
-
class CyclesDeviceSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
@@ -1503,7 +1460,6 @@ def register():
bpy.utils.register_class(CyclesMeshSettings)
bpy.utils.register_class(CyclesObjectSettings)
bpy.utils.register_class(CyclesCurveRenderSettings)
- bpy.utils.register_class(CyclesCurveSettings)
bpy.utils.register_class(CyclesDeviceSettings)
bpy.utils.register_class(CyclesPreferences)
bpy.utils.register_class(CyclesRenderLayerSettings)
@@ -1519,7 +1475,6 @@ def unregister():
bpy.utils.unregister_class(CyclesObjectSettings)
bpy.utils.unregister_class(CyclesVisibilitySettings)
bpy.utils.unregister_class(CyclesCurveRenderSettings)
- bpy.utils.unregister_class(CyclesCurveSettings)
bpy.utils.unregister_class(CyclesDeviceSettings)
bpy.utils.unregister_class(CyclesPreferences)
bpy.utils.unregister_class(CyclesRenderLayerSettings)
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index f7749c16400..c514ec1704e 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -20,10 +20,10 @@ import bpy
from bpy_extras.node_utils import find_node_input, find_output_node
from bpy.types import (
- Panel,
- Menu,
- Operator,
- )
+ Panel,
+ Menu,
+ Operator,
+)
class CYCLES_MT_sampling_presets(Menu):
@@ -86,6 +86,7 @@ def use_sample_all_lights(context):
return cscene.sample_all_lights_direct or cscene.sample_all_lights_indirect
+
def show_device_active(context):
cscene = context.scene.cycles
if cscene.device != 'GPU':
@@ -145,6 +146,7 @@ class CYCLES_RENDER_PT_sampling(CyclesButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = False
scene = context.scene
cscene = scene.cycles
@@ -154,56 +156,68 @@ class CYCLES_RENDER_PT_sampling(CyclesButtonsPanel, Panel):
row.operator("render.cycles_sampling_preset_add", text="", icon="ZOOMIN")
row.operator("render.cycles_sampling_preset_add", text="", icon="ZOOMOUT").remove_active = True
- row = layout.row()
- sub = row.row()
- sub.prop(cscene, "progressive", text="")
- row.prop(cscene, "use_square_samples")
-
- split = layout.split()
-
- col = split.column()
- sub = col.column(align=True)
- sub.label("Settings:")
+ layout.use_property_split = True
- seed_sub = sub.row(align=True)
- seed_sub.prop(cscene, "seed")
- seed_sub.prop(cscene, "use_animated_seed", text="", icon="TIME")
-
- sub.prop(cscene, "sample_clamp_direct")
- sub.prop(cscene, "sample_clamp_indirect")
- sub.prop(cscene, "light_sampling_threshold")
+ layout.prop(cscene, "progressive")
if cscene.progressive == 'PATH' or use_branched_path(context) is False:
- col = split.column()
- sub = col.column(align=True)
- sub.label(text="Samples:")
- sub.prop(cscene, "samples", text="Render")
- sub.prop(cscene, "preview_samples", text="Preview")
+ col = layout.column(align=True)
+ col.prop(cscene, "samples", text="Render")
+ col.prop(cscene, "preview_samples", text="Viewport")
+ col.separator()
+ col.prop(cscene, "use_square_samples") # Duplicate below.
else:
- sub.label(text="AA Samples:")
- sub.prop(cscene, "aa_samples", text="Render")
- sub.prop(cscene, "preview_aa_samples", text="Preview")
-
- col = split.column()
- sub = col.column(align=True)
- sub.label(text="Samples:")
- sub.prop(cscene, "diffuse_samples", text="Diffuse")
- sub.prop(cscene, "glossy_samples", text="Glossy")
- sub.prop(cscene, "transmission_samples", text="Transmission")
- sub.prop(cscene, "ao_samples", text="AO")
- subsub = sub.row(align=True)
- subsub.active = use_sample_all_lights(context)
- subsub.prop(cscene, "mesh_light_samples", text="Mesh Light")
+ col = layout.column(align=True)
+ col.label(text="AA Samples")
+ col.prop(cscene, "aa_samples", text="Render")
+ col.prop(cscene, "preview_aa_samples", text="Preview")
- sub.prop(cscene, "subsurface_samples", text="Subsurface")
- sub.prop(cscene, "volume_samples", text="Volume")
+ col = layout.column(align=True)
+ col.label(text="Samples")
+ col.prop(cscene, "diffuse_samples", text="Diffuse")
+ col.prop(cscene, "glossy_samples", text="Glossy")
+ col.prop(cscene, "transmission_samples", text="Transmission")
+ col.prop(cscene, "ao_samples", text="AO")
+
+ sub = col.row(align=True)
+ sub.active = use_sample_all_lights(context)
+ sub.prop(cscene, "mesh_light_samples", text="Mesh Light")
+ col.prop(cscene, "subsurface_samples", text="Subsurface")
+ col.prop(cscene, "volume_samples", text="Volume")
+ col.separator()
+ col.prop(cscene, "use_square_samples") # Duplicate above.
col = layout.column(align=True)
col.prop(cscene, "sample_all_lights_direct")
col.prop(cscene, "sample_all_lights_indirect")
- layout.row().prop(cscene, "sampling_pattern", text="Pattern")
+ row = layout.row(align=True)
+ row.prop(cscene, "seed")
+ row.prop(cscene, "use_animated_seed", text="", icon="TIME")
+
+ layout.prop(cscene, "sampling_pattern", text="Pattern")
+
+
+class CYCLES_RENDER_PT_sampling_light(CyclesButtonsPanel, Panel):
+ bl_label = "Light"
+ bl_parent_id = "CYCLES_RENDER_PT_sampling"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ scene = context.scene
+ cscene = scene.cycles
+
+ col = layout.column(align=True)
+ col.prop(cscene, "light_sampling_threshold", text="Light Threshold")
+
+ col = layout.column(align=True)
+ col.prop(cscene, "sample_clamp_direct")
+ col.prop(cscene, "sample_clamp_indirect")
+
draw_samples_info(layout, context)
@@ -212,57 +226,90 @@ class CYCLES_RENDER_PT_geometry(CyclesButtonsPanel, Panel):
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
+ pass
+
+
+class CYCLES_RENDER_PT_geometry_subdivision(CyclesButtonsPanel, Panel):
+ bl_label = "Subdivision"
+ bl_parent_id = "CYCLES_RENDER_PT_geometry"
+
+ @classmethod
+ def poll(self, context):
+ return context.scene.cycles.feature_set == 'EXPERIMENTAL'
+
+ def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
scene = context.scene
cscene = scene.cycles
- ccscene = scene.cycles_curves
- row = layout.row()
- row.label("Volume Sampling:")
- row = layout.row()
- row.prop(cscene, "volume_step_size")
- row.prop(cscene, "volume_max_steps")
+ col = layout.column()
+ sub = col.column(align=True)
+ sub.prop(cscene, "dicing_rate", text="Dicing Rate Render")
+ sub.prop(cscene, "preview_dicing_rate", text="Preview")
- layout.separator()
+ col.separator()
- if cscene.feature_set == 'EXPERIMENTAL':
- layout.label("Subdivision Rate:")
- split = layout.split()
+ col.prop(cscene, "offscreen_dicing_scale", text="Offscreen Scale")
+ col.prop(cscene, "max_subdivisions")
- col = split.column()
- sub = col.column(align=True)
- sub.prop(cscene, "dicing_rate", text="Render")
- sub.prop(cscene, "preview_dicing_rate", text="Preview")
+ col.prop(cscene, "dicing_camera")
- col = split.column()
- col.prop(cscene, "offscreen_dicing_scale", text="Offscreen Scale")
- col.prop(cscene, "max_subdivisions")
- layout.prop(cscene, "dicing_camera")
+class CYCLES_RENDER_PT_geometry_volume(CyclesButtonsPanel, Panel):
+ bl_label = "Volume"
+ bl_parent_id = "CYCLES_RENDER_PT_geometry"
- layout.separator()
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ scene = context.scene
+ cscene = scene.cycles
+ ccscene = scene.cycles_curves
- layout.label("Hair:")
- layout.prop(ccscene, "use_curves", text="Use Hair")
col = layout.column()
- col.active = ccscene.use_curves
+ col.prop(cscene, "volume_step_size", text="Step Size")
+ col.prop(cscene, "volume_max_steps", text="Max Steps")
- col.prop(ccscene, "primitive", text="Primitive")
- col.prop(ccscene, "shape", text="Shape")
+class CYCLES_RENDER_PT_geometry_hair(CyclesButtonsPanel, Panel):
+ bl_label = "Hair"
+ bl_parent_id = "CYCLES_RENDER_PT_geometry"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ def draw_header(self, context):
+ layout = self.layout
+ scene = context.scene
+ cscene = scene.cycles
+ ccscene = scene.cycles_curves
+
+ layout.prop(ccscene, "use_curves", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ scene = context.scene
+ cscene = scene.cycles
+ ccscene = scene.cycles_curves
+
+ layout.active = ccscene.use_curves
+
+ col = layout.column()
+ col.prop(ccscene, "minimum_width", text="Min Pixels")
+ col.prop(ccscene, "maximum_width", text="Max Extension")
+ col.prop(ccscene, "shape", text="Shape")
if not (ccscene.primitive in {'CURVE_SEGMENTS', 'LINE_SEGMENTS'} and ccscene.shape == 'RIBBONS'):
col.prop(ccscene, "cull_backfacing", text="Cull back-faces")
+ col.prop(ccscene, "primitive", text="Primitive")
if ccscene.primitive == 'TRIANGLES' and ccscene.shape == 'THICK':
col.prop(ccscene, "resolution", text="Resolution")
elif ccscene.primitive == 'CURVE_SEGMENTS':
col.prop(ccscene, "subdivisions", text="Curve subdivisions")
- row = col.row()
- row.prop(ccscene, "minimum_width", text="Min Pixels")
- row.prop(ccscene, "maximum_width", text="Max Extension")
-
class CYCLES_RENDER_PT_light_paths(CyclesButtonsPanel, Panel):
bl_label = "Light Paths"
@@ -270,6 +317,7 @@ class CYCLES_RENDER_PT_light_paths(CyclesButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
scene = context.scene
cscene = scene.cycles
@@ -279,31 +327,45 @@ class CYCLES_RENDER_PT_light_paths(CyclesButtonsPanel, Panel):
row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMIN")
row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMOUT").remove_active = True
- split = layout.split()
- col = split.column()
+class CYCLES_RENDER_PT_light_paths_max_bounces(CyclesButtonsPanel, Panel):
+ bl_label = "Max Bounces"
+ bl_parent_id = "CYCLES_RENDER_PT_light_paths"
- sub = col.column(align=True)
- sub.label("Transparency:")
- sub.prop(cscene, "transparent_max_bounces", text="Max")
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
- col.separator()
+ scene = context.scene
+ cscene = scene.cycles
- col.prop(cscene, "caustics_reflective")
- col.prop(cscene, "caustics_refractive")
- col.prop(cscene, "blur_glossy")
+ col = layout.column(align=True)
+ col.prop(cscene, "max_bounces", text="Total")
- col = split.column()
+ col = layout.column(align=True)
+ col.prop(cscene, "diffuse_bounces", text="Diffuse")
+ col.prop(cscene, "glossy_bounces", text="Glossy")
+ col.prop(cscene, "transparent_max_bounces", text="Transparency")
+ col.prop(cscene, "transmission_bounces", text="Transmission")
+ col.prop(cscene, "volume_bounces", text="Volume")
- sub = col.column(align=True)
- sub.label(text="Bounces:")
- sub.prop(cscene, "max_bounces", text="Max")
- sub = col.column(align=True)
- sub.prop(cscene, "diffuse_bounces", text="Diffuse")
- sub.prop(cscene, "glossy_bounces", text="Glossy")
- sub.prop(cscene, "transmission_bounces", text="Transmission")
- sub.prop(cscene, "volume_bounces", text="Volume")
+class CYCLES_RENDER_PT_light_paths_caustics(CyclesButtonsPanel, Panel):
+ bl_label = "Caustics"
+ bl_parent_id = "CYCLES_RENDER_PT_light_paths"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ scene = context.scene
+ cscene = scene.cycles
+
+ col = layout.column()
+ col.prop(cscene, "blur_glossy")
+ col.prop(cscene, "caustics_reflective")
+ col.prop(cscene, "caustics_refractive")
class CYCLES_RENDER_PT_motion_blur(CyclesButtonsPanel, Panel):
@@ -317,6 +379,7 @@ class CYCLES_RENDER_PT_motion_blur(CyclesButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
scene = context.scene
cscene = scene.cycles
@@ -326,9 +389,29 @@ class CYCLES_RENDER_PT_motion_blur(CyclesButtonsPanel, Panel):
col = layout.column()
col.prop(cscene, "motion_blur_position", text="Position")
col.prop(rd, "motion_blur_shutter")
+ col.separator()
+ col.prop(cscene, "rolling_shutter_type", text="Rolling Shutter")
+ sub = col.column()
+ sub.active = cscene.rolling_shutter_type != 'NONE'
+ sub.prop(cscene, "rolling_shutter_duration")
+
+
+class CYCLES_RENDER_PT_motion_blur_curve(CyclesButtonsPanel, Panel):
+ bl_label = "Shutter Curve"
+ bl_parent_id = "CYCLES_RENDER_PT_motion_blur"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ scene = context.scene
+ cscene = scene.cycles
+ rd = scene.render
+ layout.active = rd.use_motion_blur
col = layout.column()
- col.label("Shutter curve:")
+
col.template_curve_mapping(rd, "motion_blur_shutter_curve")
col = layout.column(align=True)
@@ -340,40 +423,65 @@ class CYCLES_RENDER_PT_motion_blur(CyclesButtonsPanel, Panel):
row.operator("render.shutter_curve_preset", icon='LINCURVE', text="").shape = 'LINE'
row.operator("render.shutter_curve_preset", icon='NOCURVE', text="").shape = 'MAX'
- col = layout.column()
- col.prop(cscene, "rolling_shutter_type")
- row = col.row()
- row.active = cscene.rolling_shutter_type != 'NONE'
- row.prop(cscene, "rolling_shutter_duration")
-
class CYCLES_RENDER_PT_film(CyclesButtonsPanel, Panel):
bl_label = "Film"
+ bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+ scene = context.scene
+ cscene = scene.cycles
+
+ col = layout.column()
+ col.prop(cscene, "film_exposure")
+
+
+class CYCLES_RENDER_PT_film_transparency(CyclesButtonsPanel, Panel):
+ bl_label = "Transparency"
+ bl_parent_id = "CYCLES_RENDER_PT_film"
+
+ def draw_header(self, context):
+ layout = self.layout
+ rd = context.scene.render
scene = context.scene
cscene = scene.cycles
- split = layout.split()
+ layout.prop(cscene, "film_transparent", text="")
- col = split.column()
- col.prop(cscene, "film_exposure")
- col.separator()
- sub = col.column(align=True)
- sub.prop(cscene, "pixel_filter_type", text="")
- if cscene.pixel_filter_type != 'BOX':
- sub.prop(cscene, "filter_width", text="Width")
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+ scene = context.scene
+ cscene = scene.cycles
- col = split.column()
- col.prop(cscene, "film_transparent")
- sub = col.row()
- sub.prop(cscene, "film_transparent_glass", text="Transparent Glass")
- sub.active = cscene.film_transparent
- sub = col.row()
- sub.prop(cscene, "film_transparent_roughness", text="Roughness Threshold")
+ layout.active = cscene.film_transparent
+
+ col = layout.column()
+ col.prop(cscene, "film_transparent_glass", text="Transparent Glass")
+
+ sub = col.column()
sub.active = cscene.film_transparent and cscene.film_transparent_glass
+ sub.prop(cscene, "film_transparent_roughness", text="Roughness Threshold")
+
+
+class CYCLES_RENDER_PT_film_pixel_filter(CyclesButtonsPanel, Panel):
+ bl_label = "Pixel Filter"
+ bl_parent_id = "CYCLES_RENDER_PT_film"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+ scene = context.scene
+ cscene = scene.cycles
+
+ col = layout.column()
+ col.prop(cscene, "pixel_filter_type", text="Type")
+ if cscene.pixel_filter_type != 'BOX':
+ col.prop(cscene, "filter_width", text="Width")
class CYCLES_RENDER_PT_performance(CyclesButtonsPanel, Panel):
@@ -382,58 +490,125 @@ class CYCLES_RENDER_PT_performance(CyclesButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
scene = context.scene
rd = scene.render
cscene = scene.cycles
- split = layout.split()
+ col = layout.column()
+ col.active = show_device_active(context)
+ col.prop(cscene, "device")
- col = split.column(align=True)
+ from . import engine
+ if engine.with_osl() and use_cpu(context):
+ col.prop(cscene, "shading_system")
+
+
+class CYCLES_RENDER_PT_performance_threads(CyclesButtonsPanel, Panel):
+ bl_label = "Threads"
+ bl_parent_id = "CYCLES_RENDER_PT_performance"
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ scene = context.scene
+ rd = scene.render
+ cscene = scene.cycles
+
+ col = layout.column()
- col.label(text="Threads:")
- col.row(align=True).prop(rd, "threads_mode", expand=True)
+ col.prop(rd, "threads_mode")
sub = col.column(align=True)
sub.enabled = rd.threads_mode == 'FIXED'
sub.prop(rd, "threads")
- col.separator()
- sub = col.column(align=True)
- sub.label(text="Tiles:")
- sub.prop(cscene, "tile_order", text="")
+class CYCLES_RENDER_PT_performance_tiles(CyclesButtonsPanel, Panel):
+ bl_label = "Tiles"
+ bl_parent_id = "CYCLES_RENDER_PT_performance"
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ scene = context.scene
+ rd = scene.render
+ cscene = scene.cycles
+
+ col = layout.column()
- sub.prop(rd, "tile_x", text="X")
+ sub = col.column(align=True)
+ sub.prop(rd, "tile_x", text="Tiles X")
sub.prop(rd, "tile_y", text="Y")
+ col.prop(cscene, "tile_order", text="Order")
- subsub = sub.column()
- subsub.active = not rd.use_save_buffers
+ sub = col.column()
+ sub.active = not rd.use_save_buffers
for view_layer in scene.view_layers:
if view_layer.cycles.use_denoising:
- subsub.active = False
- subsub.prop(cscene, "use_progressive_refine")
+ sub.active = False
+ sub.prop(cscene, "use_progressive_refine")
- col = split.column()
- col.label(text="Final Render:")
- col.prop(rd, "use_save_buffers")
- col.prop(rd, "use_persistent_data", text="Persistent Images")
+class CYCLES_RENDER_PT_performance_acceleration_structure(CyclesButtonsPanel, Panel):
+ bl_label = "Acceleration Structure"
+ bl_parent_id = "CYCLES_RENDER_PT_performance"
+ bl_options = {'DEFAULT_CLOSED'}
- col.separator()
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ scene = context.scene
+ rd = scene.render
+ cscene = scene.cycles
+
+ col = layout.column()
- col.label(text="Acceleration structure:")
col.prop(cscene, "debug_use_spatial_splits")
col.prop(cscene, "debug_use_hair_bvh")
+ sub = col.column()
+ sub.active = not cscene.debug_use_spatial_splits
+ sub.prop(cscene, "debug_bvh_time_steps")
- row = col.row()
- row.active = not cscene.debug_use_spatial_splits
- row.prop(cscene, "debug_bvh_time_steps")
+
+class CYCLES_RENDER_PT_performance_final_render(CyclesButtonsPanel, Panel):
+ bl_label = "Final Render"
+ bl_parent_id = "CYCLES_RENDER_PT_performance"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ scene = context.scene
+ rd = scene.render
+ cscene = scene.cycles
+
+ col = layout.column()
+
+ col.prop(rd, "use_save_buffers")
+ col.prop(rd, "use_persistent_data", text="Persistent Images")
+
+
+class CYCLES_RENDER_PT_performance_viewport(CyclesButtonsPanel, Panel):
+ bl_label = "Viewport"
+ bl_parent_id = "CYCLES_RENDER_PT_performance"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ scene = context.scene
+ rd = scene.render
+ cscene = scene.cycles
col = layout.column()
- col.label(text="Viewport Resolution:")
- split = col.split()
- split.prop(rd, "preview_pixel_size", text="")
- split.prop(cscene, "preview_start_resolution")
+ col.prop(rd, "preview_pixel_size", text="Pixel Size")
+ col.prop(cscene, "preview_start_resolution", text="Start Pixels")
class CYCLES_RENDER_PT_filter(CyclesButtonsPanel, Panel):
@@ -450,7 +625,7 @@ class CYCLES_RENDER_PT_filter(CyclesButtonsPanel, Panel):
col = layout.column()
col.prop(view_layer, "use_sky", "Use Environment")
- col.prop(view_layer, "use_ao", "Use AO")
+ col.prop(view_layer, "use_ao", "Use Ambient Occlusion")
col.prop(view_layer, "use_solid", "Use Surfaces")
col.prop(view_layer, "use_strand", "Use Hair")
if with_freestyle:
@@ -489,7 +664,7 @@ class CYCLES_RENDER_PT_layer_passes(CyclesButtonsPanel, Panel):
col.prop(view_layer, "use_pass_material_index")
col.separator()
col.prop(view_layer, "use_pass_shadow")
- col.prop(view_layer, "use_pass_ambient_occlusion")
+ col.prop(view_layer, "use_pass_ambient_occlusion", text="Ambient Occlusion")
col.separator()
col.prop(view_layer, "pass_alpha_threshold")
@@ -554,6 +729,7 @@ class CYCLES_RENDER_PT_denoising(CyclesButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
scene = context.scene
cscene = scene.cycles
@@ -562,43 +738,66 @@ class CYCLES_RENDER_PT_denoising(CyclesButtonsPanel, Panel):
layout.active = cycles_view_layer.use_denoising
- split = layout.split()
-
- col = split.column()
- sub = col.column(align=True)
+ col = layout.column()
+ sub = col.column()
sub.prop(cycles_view_layer, "denoising_radius", text="Radius")
sub.prop(cycles_view_layer, "denoising_strength", slider=True, text="Strength")
- col = split.column()
sub = col.column(align=True)
sub.prop(cycles_view_layer, "denoising_feature_strength", slider=True, text="Feature Strength")
sub.prop(cycles_view_layer, "denoising_relative_pca")
+# layout.use_property_split = False
+
+ """
layout.separator()
- row = layout.row()
- row.label(text="Diffuse:")
- sub = row.row(align=True)
- sub.prop(cycles_view_layer, "denoising_diffuse_direct", text="Direct", toggle=True)
- sub.prop(cycles_view_layer, "denoising_diffuse_indirect", text="Indirect", toggle=True)
+ col = layout.column(align=True)
+ col.prop(cycles_view_layer, "denoising_diffuse_direct", text="Diffuse Direct")
+ col.prop(cycles_view_layer, "denoising_diffuse_indirect", text="Indirect")
- row = layout.row()
- row.label(text="Glossy:")
- sub = row.row(align=True)
- sub.prop(cycles_view_layer, "denoising_glossy_direct", text="Direct", toggle=True)
- sub.prop(cycles_view_layer, "denoising_glossy_indirect", text="Indirect", toggle=True)
+ col = layout.column(align=True)
+ col.prop(cycles_view_layer, "denoising_glossy_direct", text="Glossy Direct")
+ col.prop(cycles_view_layer, "denoising_glossy_indirect", text="Indirect")
- row = layout.row()
- row.label(text="Transmission:")
- sub = row.row(align=True)
- sub.prop(cycles_view_layer, "denoising_transmission_direct", text="Direct", toggle=True)
- sub.prop(cycles_view_layer, "denoising_transmission_indirect", text="Indirect", toggle=True)
+ col = layout.column(align=True)
+ col.prop(cycles_view_layer, "denoising_transmission_direct", text="Transmission Direct")
+ col.prop(cycles_view_layer, "denoising_transmission_indirect", text="Indirect")
- row = layout.row()
- row.label(text="Subsurface:")
- sub = row.row(align=True)
- sub.prop(cycles_view_layer, "denoising_subsurface_direct", text="Direct", toggle=True)
- sub.prop(cycles_view_layer, "denoising_subsurface_indirect", text="Indirect", toggle=True)
+ col = layout.column(align=True)
+ col.prop(cycles_view_layer, "denoising_subsurface_direct", text="Subsurface Direct")
+ col.prop(cycles_view_layer, "denoising_subsurface_indirect", text="Indirect")
+ """
+
+ layout.use_property_split = False
+
+ split = layout.split(percentage=0.5)
+ split.label(text="Diffuse")
+ col = split.column()
+ row = col.row(align=True)
+ row.prop(cycles_view_layer, "denoising_diffuse_direct", text="Direct", toggle=True)
+ row.prop(cycles_view_layer, "denoising_diffuse_indirect", text="Indirect", toggle=True)
+
+ split = layout.split(percentage=0.5)
+ split.label(text="Glossy")
+ col = split.column()
+ row = col.row(align=True)
+ row.prop(cycles_view_layer, "denoising_glossy_direct", text="Direct", toggle=True)
+ row.prop(cycles_view_layer, "denoising_glossy_indirect", text="Indirect", toggle=True)
+
+ split = layout.split(percentage=0.5)
+ split.label(text="Transmission")
+ col = split.column()
+ row = col.row(align=True)
+ row.prop(cycles_view_layer, "denoising_transmission_direct", text="Direct", toggle=True)
+ row.prop(cycles_view_layer, "denoising_transmission_indirect", text="Indirect", toggle=True)
+
+ split = layout.split(percentage=0.5)
+ split.label(text="Subsurface")
+ col = split.column()
+ row = col.row(align=True)
+ row.prop(cycles_view_layer, "denoising_subsurface_direct", text="Direct", toggle=True)
+ row.prop(cycles_view_layer, "denoising_subsurface_indirect", text="Indirect", toggle=True)
class CYCLES_PT_post_processing(CyclesButtonsPanel, Panel):
@@ -607,17 +806,15 @@ class CYCLES_PT_post_processing(CyclesButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
rd = context.scene.render
- split = layout.split()
-
- col = split.column()
+ col = layout.column(align=True)
col.prop(rd, "use_compositing")
col.prop(rd, "use_sequencer")
- col = split.column()
- col.prop(rd, "dither_intensity", text="Dither", slider=True)
+ layout.prop(rd, "dither_intensity", text="Dither", slider=True)
class CYCLES_CAMERA_PT_dof(CyclesButtonsPanel, Panel):
@@ -630,6 +827,7 @@ class CYCLES_CAMERA_PT_dof(CyclesButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
cam = context.camera
ccam = cam.cycles
@@ -638,16 +836,62 @@ class CYCLES_CAMERA_PT_dof(CyclesButtonsPanel, Panel):
split = layout.split()
col = split.column()
- col.label("Focus:")
- col.prop(cam, "dof_object", text="")
+ col.prop(cam, "dof_object", text="Focus Object")
sub = col.row()
sub.active = cam.dof_object is None
sub.prop(cam, "dof_distance", text="Distance")
+
+class CYCLES_CAMERA_PT_dof_aperture(CyclesButtonsPanel, Panel):
+ bl_label = "Aperture"
+ bl_parent_id = "CYCLES_CAMERA_PT_dof"
+
+ @classmethod
+ def poll(cls, context):
+ return context.camera and CyclesButtonsPanel.poll(context)
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+ flow = layout.grid_flow(row_major=True, num_columns=0, even_columns=True, even_rows=False, align=False)
+
+ cam = context.camera
+ ccam = cam.cycles
+ dof_options = cam.gpu_dof
+
+ col = flow.column()
+ col.prop(ccam, "aperture_type")
+ if ccam.aperture_type == 'RADIUS':
+ col.prop(ccam, "aperture_size", text="Size")
+ elif ccam.aperture_type == 'FSTOP':
+ col.prop(ccam, "aperture_fstop", text="Number")
+ col.separator()
+
+ col = flow.column()
+ col.prop(ccam, "aperture_blades", text="Blades")
+ col.prop(ccam, "aperture_rotation", text="Rotation")
+ col.prop(ccam, "aperture_ratio", text="Ratio")
+
+
+class CYCLES_CAMERA_PT_dof_viewport(CyclesButtonsPanel, Panel):
+ bl_label = "Viewport"
+ bl_parent_id = "CYCLES_CAMERA_PT_dof"
+
+ @classmethod
+ def poll(cls, context):
+ return context.camera and CyclesButtonsPanel.poll(context)
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+ flow = layout.grid_flow(row_major=True, num_columns=0, even_columns=True, even_rows=False, align=False)
+
+ cam = context.camera
+ dof_options = cam.gpu_dof
+
hq_support = dof_options.is_hq_supported
- sub = col.column(align=True)
- sub.label("Viewport:")
+ sub = flow.column(align=True)
subhq = sub.column()
subhq.active = hq_support
subhq.prop(dof_options, "use_high_quality")
@@ -655,21 +899,6 @@ class CYCLES_CAMERA_PT_dof(CyclesButtonsPanel, Panel):
if dof_options.use_high_quality and hq_support:
sub.prop(dof_options, "blades")
- col = split.column()
-
- col.label("Aperture:")
- sub = col.column(align=True)
- sub.prop(ccam, "aperture_type", text="")
- if ccam.aperture_type == 'RADIUS':
- sub.prop(ccam, "aperture_size", text="Size")
- elif ccam.aperture_type == 'FSTOP':
- sub.prop(ccam, "aperture_fstop", text="Number")
-
- sub = col.column(align=True)
- sub.prop(ccam, "aperture_blades", text="Blades")
- sub.prop(ccam, "aperture_rotation", text="Rotation")
- sub.prop(ccam, "aperture_ratio", text="Ratio")
-
class CYCLES_PT_context_material(CyclesButtonsPanel, Panel):
bl_label = ""
@@ -742,7 +971,7 @@ class CYCLES_OBJECT_PT_motion_blur(CyclesButtonsPanel, Panel):
if CyclesButtonsPanel.poll(context) and ob:
if ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META', 'CAMERA'}:
return True
- if ob.dupli_type == 'GROUP' and ob.dupli_group:
+ if ob.dupli_type == 'COLLECTION' and ob.dupli_group:
return True
# TODO(sergey): More duplicator types here?
return False
@@ -787,7 +1016,7 @@ class CYCLES_OBJECT_PT_cycles_settings(CyclesButtonsPanel, Panel):
ob = context.object
return (CyclesButtonsPanel.poll(context) and
ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LAMP'}) or
- (ob.dupli_type == 'GROUP' and ob.dupli_group)))
+ (ob.dupli_type == 'COLLECTION' and ob.dupli_group)))
def draw(self, context):
layout = self.layout
@@ -874,10 +1103,14 @@ class CYCLES_LAMP_PT_preview(CyclesButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- return context.lamp and \
- not (context.lamp.type == 'AREA' and
- context.lamp.cycles.is_portal) \
- and CyclesButtonsPanel.poll(context)
+ return (
+ context.lamp and
+ not (
+ context.lamp.type == 'AREA' and
+ context.lamp.cycles.is_portal
+ ) and
+ CyclesButtonsPanel.poll(context)
+ )
def draw(self, context):
self.layout.template_preview(context.lamp)
@@ -945,7 +1178,7 @@ class CYCLES_LAMP_PT_nodes(CyclesButtonsPanel, Panel):
def poll(cls, context):
return context.lamp and not (context.lamp.type == 'AREA' and
context.lamp.cycles.is_portal) and \
- CyclesButtonsPanel.poll(context)
+ CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
@@ -1030,6 +1263,7 @@ class CYCLES_WORLD_PT_volume(CyclesButtonsPanel, Panel):
class CYCLES_WORLD_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
bl_label = "Ambient Occlusion"
bl_context = "world"
+ bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
@@ -1041,15 +1275,16 @@ class CYCLES_WORLD_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
light = context.world.light_settings
scene = context.scene
- row = layout.row()
- sub = row.row()
+ col = layout.column()
+ sub = col.column()
sub.active = light.use_ambient_occlusion or scene.render.use_simplify
sub.prop(light, "ao_factor", text="Factor")
- row.prop(light, "distance", text="Distance")
+ col.prop(light, "distance", text="Distance")
class CYCLES_WORLD_PT_mist(CyclesButtonsPanel, Panel):
@@ -1114,33 +1349,65 @@ class CYCLES_WORLD_PT_settings(CyclesButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
world = context.world
cworld = world.cycles
# cscene = context.scene.cycles
- split = layout.split()
+ col = layout.column()
- col = split.column()
+class CYCLES_WORLD_PT_settings_surface(CyclesButtonsPanel, Panel):
+ bl_label = "Surface"
+ bl_parent_id = "CYCLES_WORLD_PT_settings"
+ bl_context = "world"
+
+ @classmethod
+ def poll(cls, context):
+ return context.world and CyclesButtonsPanel.poll(context)
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ world = context.world
+ cworld = world.cycles
- col.label(text="Surface:")
+ col = layout.column()
col.prop(cworld, "sample_as_light", text="Multiple Importance")
- sub = col.column(align=True)
+ sub = col.column()
sub.active = cworld.sample_as_light
sub.prop(cworld, "sample_map_resolution")
if use_branched_path(context):
- subsub = sub.row(align=True)
+ subsub = sub.column(align=True)
subsub.active = use_sample_all_lights(context)
subsub.prop(cworld, "samples")
sub.prop(cworld, "max_bounces")
- col = split.column()
- col.label(text="Volume:")
+
+class CYCLES_WORLD_PT_settings_volume(CyclesButtonsPanel, Panel):
+ bl_label = "Volume"
+ bl_parent_id = "CYCLES_WORLD_PT_settings"
+ bl_context = "world"
+
+ @classmethod
+ def poll(cls, context):
+ return context.world and CyclesButtonsPanel.poll(context)
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ world = context.world
+ cworld = world.cycles
+
+ col = layout.column()
+
sub = col.column()
sub.active = use_cpu(context)
- sub.prop(cworld, "volume_sampling", text="")
- col.prop(cworld, "volume_interpolation", text="")
+ sub.prop(cworld, "volume_sampling", text="Sampling")
+ col.prop(cworld, "volume_interpolation", text="Interpolation")
col.prop(cworld, "homogeneous_volume", text="Homogeneous")
@@ -1218,55 +1485,60 @@ class CYCLES_MATERIAL_PT_settings(CyclesButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
mat = context.material
cmat = mat.cycles
- split = layout.split()
- col = split.column()
- col.label(text="Surface:")
- col.prop(cmat, "sample_as_light", text="Multiple Importance")
- col.prop(cmat, "use_transparent_shadow")
+ layout.prop(mat, "pass_index")
- col.separator()
- col.label(text="Geometry:")
- col.prop(cmat, "displacement_method", text="")
- col = split.column()
- col.label(text="Volume:")
- sub = col.column()
- sub.active = use_cpu(context)
- sub.prop(cmat, "volume_sampling", text="")
- col.prop(cmat, "volume_interpolation", text="")
- col.prop(cmat, "homogeneous_volume", text="Homogeneous")
+class CYCLES_MATERIAL_PT_settings_surface(CyclesButtonsPanel, Panel):
+ bl_label = "Surface"
+ bl_parent_id = "CYCLES_MATERIAL_PT_settings"
+ bl_context = "material"
- col.separator()
- col.prop(mat, "pass_index")
+ @classmethod
+ def poll(cls, context):
+ return context.material and CyclesButtonsPanel.poll(context)
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
-class CYCLES_MATERIAL_PT_viewport(CyclesButtonsPanel, Panel):
- bl_label = "Viewport"
+ mat = context.material
+ cmat = mat.cycles
+
+ col = layout.column()
+ col.prop(cmat, "sample_as_light", text="Multiple Importance")
+ col.prop(cmat, "use_transparent_shadow")
+ col.prop(cmat, "displacement_method", text="Displacement Method")
+
+
+class CYCLES_MATERIAL_PT_settings_volume(CyclesButtonsPanel, Panel):
+ bl_label = "Volume"
+ bl_parent_id = "CYCLES_MATERIAL_PT_settings"
bl_context = "material"
- bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
return context.material and CyclesButtonsPanel.poll(context)
def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
mat = context.material
+ cmat = mat.cycles
- layout = self.layout
- split = layout.split()
+ col = layout.column()
+ sub = col.column()
+ sub.active = use_cpu(context)
+ sub.prop(cmat, "volume_sampling", text="Sampling")
+ col.prop(cmat, "volume_interpolation", text="Interpolation")
+ col.prop(cmat, "homogeneous_volume", text="Homogeneous")
- col = split.column(align=True)
- col.label("Color:")
- col.prop(mat, "diffuse_color", text="")
- col.prop(mat, "alpha")
- col = split.column(align=True)
- col.label("Specular:")
- col.prop(mat, "specular_color", text="")
class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
@@ -1277,31 +1549,27 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
scene = context.scene
cscene = scene.cycles
cbk = scene.render.bake
rd = scene.render
- if rd.use_bake_multires:
- layout.operator("object.bake_image", icon='RENDER_STILL')
- else:
- layout.operator("object.bake", icon='RENDER_STILL').type = cscene.bake_type
-
col = layout.column()
col.prop(rd, "use_bake_multires")
if rd.use_bake_multires:
col.prop(rd, "bake_type")
- split = layout.split()
-
- col = split.column()
+ col = layout.column()
col.prop(rd, "bake_margin")
col.prop(rd, "use_bake_clear")
- col = split.column()
if rd.bake_type == 'DISPLACEMENT':
col.prop(rd, "use_bake_lores_mesh")
+
+ col.operator("object.bake_image", icon='RENDER_STILL')
+
else:
col.prop(cscene, "bake_type")
@@ -1310,26 +1578,22 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
if cscene.bake_type == 'NORMAL':
col.prop(cbk, "normal_space", text="Space")
- row = col.row(align=True)
- row.label(text="Swizzle:")
- row.prop(cbk, "normal_r", text="")
- row.prop(cbk, "normal_g", text="")
- row.prop(cbk, "normal_b", text="")
+ sub = col.row(align=True)
+ sub.prop(cbk, "normal_r", text="Swizzle R")
+ sub.prop(cbk, "normal_g", text="G")
+ sub.prop(cbk, "normal_b", text="B")
elif cscene.bake_type == 'COMBINED':
row = col.row(align=True)
+ row.use_property_split = False
row.prop(cbk, "use_pass_direct", toggle=True)
row.prop(cbk, "use_pass_indirect", toggle=True)
- split = col.split()
- split.active = cbk.use_pass_direct or cbk.use_pass_indirect
-
- col = split.column()
+ col = col.column()
+ col.active = cbk.use_pass_direct or cbk.use_pass_indirect
col.prop(cbk, "use_pass_diffuse")
col.prop(cbk, "use_pass_glossy")
col.prop(cbk, "use_pass_transmission")
-
- col = split.column()
col.prop(cbk, "use_pass_subsurface")
col.prop(cbk, "use_pass_ambient_occlusion")
col.prop(cbk, "use_pass_emit")
@@ -1342,13 +1606,12 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
layout.separator()
- split = layout.split()
-
- col = split.column()
+ col = layout.column()
col.prop(cbk, "margin")
- col.prop(cbk, "use_clear")
+ col.prop(cbk, "use_clear", text="Clear Image")
+
+ col.separator()
- col = split.column()
col.prop(cbk, "use_selected_to_active")
sub = col.column()
sub.active = cbk.use_selected_to_active
@@ -1359,6 +1622,9 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
else:
sub.prop(cbk, "cage_extrusion", text="Ray Distance")
+ layout.operator("object.bake", icon='RENDER_STILL').type = cscene.bake_type
+
+
class CYCLES_RENDER_PT_debug(CyclesButtonsPanel, Panel):
bl_label = "Debug"
bl_context = "render"
@@ -1410,48 +1676,51 @@ class CYCLES_RENDER_PT_debug(CyclesButtonsPanel, Panel):
col.prop(cscene, "debug_bvh_type")
-class CYCLES_PARTICLE_PT_curve_settings(CyclesButtonsPanel, Panel):
- bl_label = "Cycles Hair Settings"
- bl_context = "particle"
+class CYCLES_SCENE_PT_simplify(CyclesButtonsPanel, Panel):
+ bl_label = "Simplify"
+ bl_context = "scene"
+ COMPAT_ENGINES = {'CYCLES'}
- @classmethod
- def poll(cls, context):
- scene = context.scene
- ccscene = scene.cycles_curves
- psys = context.particle_system
- use_curves = ccscene.use_curves and psys
- return CyclesButtonsPanel.poll(context) and use_curves and psys.settings.type == 'HAIR'
+ def draw_header(self, context):
+ rd = context.scene.render
+ self.layout.prop(rd, "use_simplify", text="")
def draw(self, context):
- layout = self.layout
+ pass
- psys = context.particle_settings
- cpsys = psys.cycles
- row = layout.row()
- row.prop(cpsys, "shape", text="Shape")
+class CYCLES_SCENE_PT_simplify_viewport(CyclesButtonsPanel, Panel):
+ bl_label = "Viewport"
+ bl_context = "scene"
+ bl_parent_id = "CYCLES_SCENE_PT_simplify"
+ COMPAT_ENGINES = {'CYCLES'}
- layout.label(text="Thickness:")
- row = layout.row()
- row.prop(cpsys, "root_width", text="Root")
- row.prop(cpsys, "tip_width", text="Tip")
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
- row = layout.row()
- row.prop(cpsys, "radius_scale", text="Scaling")
- row.prop(cpsys, "use_closetip", text="Close tip")
+ scene = context.scene
+ rd = scene.render
+ cscene = scene.cycles
+
+ layout.active = rd.use_simplify
+ col = layout.column()
+ col.prop(rd, "simplify_subdivision", text="Max Subdivision")
+ col.prop(rd, "simplify_child_particles", text="Child Particles")
+ col.prop(cscene, "texture_limit", text="Texture Limit")
+ col.prop(cscene, "ao_bounces", text="AO Bounces")
-class CYCLES_SCENE_PT_simplify(CyclesButtonsPanel, Panel):
- bl_label = "Simplify"
+
+class CYCLES_SCENE_PT_simplify_render(CyclesButtonsPanel, Panel):
+ bl_label = "Render"
bl_context = "scene"
+ bl_parent_id = "CYCLES_SCENE_PT_simplify"
COMPAT_ENGINES = {'CYCLES'}
- def draw_header(self, context):
- rd = context.scene.render
- self.layout.prop(rd, "use_simplify", text="")
-
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
scene = context.scene
rd = scene.render
@@ -1459,68 +1728,55 @@ class CYCLES_SCENE_PT_simplify(CyclesButtonsPanel, Panel):
layout.active = rd.use_simplify
- col = layout.column(align=True)
- col.label(text="Subdivision")
- row = col.row(align=True)
- row.prop(rd, "simplify_subdivision", text="Viewport")
- row.prop(rd, "simplify_subdivision_render", text="Render")
+ col = layout.column()
+ col.prop(rd, "simplify_subdivision_render", text="Max Subdivision")
+ col.prop(rd, "simplify_child_particles_render", text="Child Particles")
+ col.prop(cscene, "texture_limit_render", text="Texture Limit")
+ col.prop(cscene, "ao_bounces_render", text="AO Bounces")
- col = layout.column(align=True)
- col.label(text="Child Particles")
- row = col.row(align=True)
- row.prop(rd, "simplify_child_particles", text="Viewport")
- row.prop(rd, "simplify_child_particles_render", text="Render")
- col = layout.column(align=True)
- split = col.split()
- sub = split.column()
- sub.label(text="Texture Limit Viewport")
- sub.prop(cscene, "texture_limit", text="")
- sub = split.column()
- sub.label(text="Texture Limit Render")
- sub.prop(cscene, "texture_limit_render", text="")
+class CYCLES_SCENE_PT_simplify_culling(CyclesButtonsPanel, Panel):
+ bl_label = "Culling"
+ bl_context = "scene"
+ bl_parent_id = "CYCLES_SCENE_PT_simplify"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'CYCLES'}
- split = layout.split()
- col = split.column()
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ scene = context.scene
+ rd = scene.render
+ cscene = scene.cycles
+
+ layout.active = rd.use_simplify
+
+ col = layout.column()
col.prop(cscene, "use_camera_cull")
- row = col.row()
- row.active = cscene.use_camera_cull
- row.prop(cscene, "camera_cull_margin")
+ sub = col.column()
+ sub.active = cscene.use_camera_cull
+ sub.prop(cscene, "camera_cull_margin")
- col = split.column()
+ col = layout.column()
col.prop(cscene, "use_distance_cull")
- row = col.row()
- row.active = cscene.use_distance_cull
- row.prop(cscene, "distance_cull_margin", text="Distance")
-
- split = layout.split()
- col = split.column()
- col.prop(cscene, "ao_bounces")
+ sub = col.column()
+ sub.active = cscene.use_distance_cull
+ sub.prop(cscene, "distance_cull_margin", text="Distance")
- col = split.column()
- col.prop(cscene, "ao_bounces_render")
def draw_device(self, context):
scene = context.scene
layout = self.layout
+ layout.use_property_split = True
if context.engine == 'CYCLES':
from . import engine
cscene = scene.cycles
- split = layout.split(percentage=1 / 3)
- split.label("Feature Set:")
- split.prop(cscene, "feature_set", text="")
-
- split = layout.split(percentage=1 / 3)
- split.label("Device:")
- row = split.row()
- row.active = show_device_active(context)
- row.prop(cscene, "device", text="")
-
- if engine.with_osl() and use_cpu(context):
- layout.prop(cscene, "shading_system")
+ col = layout.column()
+ col.prop(cscene, "feature_set")
def draw_pause(self, context):
@@ -1530,8 +1786,9 @@ def draw_pause(self, context):
if context.engine == "CYCLES":
view = context.space_data
- cscene = scene.cycles
- layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
+ if view.shading.type == 'RENDERED':
+ cscene = scene.cycles
+ layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
def get_panels():
@@ -1548,7 +1805,7 @@ def get_panels():
'VIEWLAYER_PT_layer_passes',
'RENDER_PT_post_processing',
'SCENE_PT_simplify',
- }
+ }
panels = []
for panel in bpy.types.Panel.__subclasses__():
@@ -1563,16 +1820,32 @@ classes = (
CYCLES_MT_sampling_presets,
CYCLES_MT_integrator_presets,
CYCLES_RENDER_PT_sampling,
+ CYCLES_RENDER_PT_sampling_light,
CYCLES_RENDER_PT_geometry,
+ CYCLES_RENDER_PT_geometry_subdivision,
+ CYCLES_RENDER_PT_geometry_volume,
+ CYCLES_RENDER_PT_geometry_hair,
CYCLES_RENDER_PT_light_paths,
+ CYCLES_RENDER_PT_light_paths_max_bounces,
+ CYCLES_RENDER_PT_light_paths_caustics,
CYCLES_RENDER_PT_motion_blur,
+ CYCLES_RENDER_PT_motion_blur_curve,
CYCLES_RENDER_PT_film,
+ CYCLES_RENDER_PT_film_transparency,
+ CYCLES_RENDER_PT_film_pixel_filter,
CYCLES_RENDER_PT_performance,
+ CYCLES_RENDER_PT_performance_threads,
+ CYCLES_RENDER_PT_performance_tiles,
+ CYCLES_RENDER_PT_performance_acceleration_structure,
+ CYCLES_RENDER_PT_performance_final_render,
+ CYCLES_RENDER_PT_performance_viewport,
CYCLES_RENDER_PT_filter,
CYCLES_RENDER_PT_layer_passes,
CYCLES_RENDER_PT_denoising,
CYCLES_PT_post_processing,
CYCLES_CAMERA_PT_dof,
+ CYCLES_CAMERA_PT_dof_aperture,
+ CYCLES_CAMERA_PT_dof_viewport,
CYCLES_PT_context_material,
CYCLES_OBJECT_PT_motion_blur,
CYCLES_OBJECT_PT_cycles_settings,
@@ -1588,16 +1861,21 @@ classes = (
CYCLES_WORLD_PT_mist,
CYCLES_WORLD_PT_ray_visibility,
CYCLES_WORLD_PT_settings,
+ CYCLES_WORLD_PT_settings_surface,
+ CYCLES_WORLD_PT_settings_volume,
CYCLES_MATERIAL_PT_preview,
CYCLES_MATERIAL_PT_surface,
CYCLES_MATERIAL_PT_volume,
CYCLES_MATERIAL_PT_displacement,
CYCLES_MATERIAL_PT_settings,
- CYCLES_MATERIAL_PT_viewport,
+ CYCLES_MATERIAL_PT_settings_surface,
+ CYCLES_MATERIAL_PT_settings_volume,
CYCLES_RENDER_PT_bake,
CYCLES_RENDER_PT_debug,
- CYCLES_PARTICLE_PT_curve_settings,
CYCLES_SCENE_PT_simplify,
+ CYCLES_SCENE_PT_simplify_viewport,
+ CYCLES_SCENE_PT_simplify_render,
+ CYCLES_SCENE_PT_simplify_culling,
)
diff --git a/intern/cycles/blender/addon/version_update.py b/intern/cycles/blender/addon/version_update.py
index 2689fa63ca8..611ba5cae70 100644
--- a/intern/cycles/blender/addon/version_update.py
+++ b/intern/cycles/blender/addon/version_update.py
@@ -433,3 +433,14 @@ def do_versions(self):
(bpy.data.version >= (2, 80, 0) and bpy.data.version <= (2, 80, 4)):
# Switch to squared roughness convention
square_roughness_nodes_insert()
+
+ if bpy.data.version <= (2, 80, 15):
+ # Copy cycles hair settings to internal settings
+ for part in bpy.data.particles:
+ cpart = part.get("cycles", None)
+ if cpart:
+ part.shape = cpart.get("shape", 0.0)
+ part.root_radius = cpart.get("root_width", 1.0)
+ part.tip_radius = cpart.get("tip_width", 0.0)
+ part.radius_scale = cpart.get("radius_scale", 0.01)
+ part.use_close_tip = cpart.get("use_closetip", True)
diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp
index c7d37527d78..aea63b6b31f 100644
--- a/intern/cycles/blender/blender_camera.cpp
+++ b/intern/cycles/blender/blender_camera.cpp
@@ -90,7 +90,7 @@ struct BlenderCamera {
static void blender_camera_init(BlenderCamera *bcam,
BL::RenderSettings& b_render)
{
- memset(bcam, 0, sizeof(BlenderCamera));
+ memset((void *)bcam, 0, sizeof(BlenderCamera));
bcam->type = CAMERA_PERSPECTIVE;
bcam->zoom = 1.0f;
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index f2bb1b0158c..e9270ee5539 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -149,18 +149,16 @@ static bool ObtainCacheParticleData(Mesh *mesh,
if(b_part.kink() == BL::ParticleSettings::kink_SPIRAL)
ren_step += b_part.kink_extra_steps();
- PointerRNA cpsys = RNA_pointer_get(&b_part.ptr, "cycles");
-
CData->psys_firstcurve.push_back_slow(curvenum);
CData->psys_curvenum.push_back_slow(totcurves);
CData->psys_shader.push_back_slow(shader);
- float radius = get_float(cpsys, "radius_scale") * 0.5f;
+ float radius = b_part.radius_scale() * 0.5f;
- CData->psys_rootradius.push_back_slow(radius * get_float(cpsys, "root_width"));
- CData->psys_tipradius.push_back_slow(radius * get_float(cpsys, "tip_width"));
- CData->psys_shape.push_back_slow(get_float(cpsys, "shape"));
- CData->psys_closetip.push_back_slow(get_boolean(cpsys, "use_closetip"));
+ CData->psys_rootradius.push_back_slow(radius * b_part.root_radius());
+ CData->psys_tipradius.push_back_slow(radius * b_part.tip_radius());
+ CData->psys_shape.push_back_slow(b_part.shape());
+ CData->psys_closetip.push_back_slow(b_part.use_close_tip());
int pa_no = 0;
if(!(b_part.child_type() == 0) && totchild != 0)
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index 03d24c04e2a..6fe650f3699 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -1173,7 +1173,7 @@ Mesh *BlenderSync::sync_mesh(BL::Depsgraph& b_depsgraph,
* freed data from the blender side.
*/
if(preview && b_ob.type() != BL::Object::type_MESH)
- b_ob.update_from_editmode();
+ b_ob.update_from_editmode(b_data);
bool need_undeformed = mesh->need_attribute(scene, ATTR_STD_GENERATED);
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 090682c8e14..dbeab2fdf61 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -278,25 +278,25 @@ void BlenderSync::sync_background_light(bool use_portal)
/* Object */
Object *BlenderSync::sync_object(BL::Depsgraph& b_depsgraph,
- BL::Depsgraph::duplis_iterator& b_dupli_iter,
+ BL::DepsgraphObjectInstance& b_instance,
uint layer_flag,
float motion_time,
bool hide_tris,
BlenderObjectCulling& culling,
bool *use_portal)
{
- const bool is_instance = b_dupli_iter->is_instance();
- BL::Object b_ob = b_dupli_iter->object();
- BL::Object b_parent = is_instance ? b_dupli_iter->parent()
- : b_dupli_iter->object();
- BL::Object b_ob_instance = is_instance ? b_dupli_iter->instance_object()
+ const bool is_instance = b_instance.is_instance();
+ BL::Object b_ob = b_instance.object();
+ BL::Object b_parent = is_instance ? b_instance.parent()
+ : b_instance.object();
+ BL::Object b_ob_instance = is_instance ? b_instance.instance_object()
: b_ob;
const bool motion = motion_time != 0.0f;
/*const*/ Transform tfm = get_transform(b_ob.matrix_world());
int *persistent_id = NULL;
BL::Array<int, OBJECT_PERSISTENT_ID_SIZE> persistent_id_array;
if(is_instance) {
- persistent_id_array = b_dupli_iter->persistent_id();
+ persistent_id_array = b_instance.persistent_id();
persistent_id = persistent_id_array.data;
}
@@ -310,7 +310,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph& b_depsgraph,
persistent_id,
b_ob,
b_ob_instance,
- is_instance ? b_dupli_iter->random_id() : 0,
+ is_instance ? b_instance.random_id() : 0,
tfm,
use_portal);
}
@@ -448,12 +448,12 @@ Object *BlenderSync::sync_object(BL::Depsgraph& b_depsgraph,
/* dupli texture coordinates and random_id */
if(is_instance) {
- object->dupli_generated = 0.5f*get_float3(b_dupli_iter->orco()) - make_float3(0.5f, 0.5f, 0.5f);
- object->dupli_uv = get_float2(b_dupli_iter->uv());
- object->random_id = b_dupli_iter->random_id();
+ object->dupli_generated = 0.5f*get_float3(b_instance.orco()) - make_float3(0.5f, 0.5f, 0.5f);
+ object->dupli_uv = get_float2(b_instance.uv());
+ object->random_id = b_instance.random_id();
/* Sync possible particle data. */
- sync_dupli_particle(b_ob, *b_dupli_iter, object);
+ sync_dupli_particle(b_ob, b_instance, object);
}
else {
object->dupli_generated = make_float3(0.0f, 0.0f, 0.0f);
@@ -482,7 +482,8 @@ static bool object_render_hide_original(BL::Object::type_enum ob_type,
static bool object_render_hide(BL::Object& b_ob,
bool top_level,
bool parent_hide,
- bool& hide_triangles)
+ bool& hide_triangles,
+ BL::Depsgraph::mode_enum depsgraph_mode)
{
/* check if we should render or hide particle emitter */
BL::Object::particle_systems_iterator b_psys;
@@ -501,11 +502,16 @@ static bool object_render_hide(BL::Object& b_ob,
has_particles = true;
}
+ /* Both mode_PREVIEW and mode_VIEWPORT are treated the same here.*/
+ const bool show_duplicator = depsgraph_mode == BL::Depsgraph::mode_RENDER
+ ? b_ob.show_duplicator_for_render()
+ : b_ob.show_duplicator_for_viewport();
+
if(has_particles) {
- show_emitter = b_ob.show_duplicator_for_render();
+ show_emitter = show_duplicator;
hide_emitter = !show_emitter;
} else if(b_ob.is_duplicator()) {
- if(top_level || b_ob.show_duplicator_for_render()) {
+ if(top_level || show_duplicator) {
hide_as_dupli_parent = true;
}
}
@@ -563,15 +569,15 @@ void BlenderSync::sync_objects(BL::Depsgraph& b_depsgraph, float motion_time)
bool cancel = false;
bool use_portal = false;
- BL::Depsgraph::duplis_iterator b_dupli_iter;
- for(b_depsgraph.duplis.begin(b_dupli_iter);
- b_dupli_iter != b_depsgraph.duplis.end() && !cancel;
- ++b_dupli_iter)
+ BL::Depsgraph::mode_enum depsgraph_mode = b_depsgraph.mode();
+
+ BL::Depsgraph::object_instances_iterator b_instance_iter;
+ for(b_depsgraph.object_instances.begin(b_instance_iter);
+ b_instance_iter != b_depsgraph.object_instances.end() && !cancel;
+ ++b_instance_iter)
{
- BL::Object b_ob = b_dupli_iter->object();
- if(!b_ob.is_visible()) {
- continue;
- }
+ BL::DepsgraphObjectInstance b_instance = *b_instance_iter;
+ BL::Object b_ob = b_instance.object();
progress.set_sync_status("Synchronizing object", b_ob.name());
@@ -581,10 +587,10 @@ void BlenderSync::sync_objects(BL::Depsgraph& b_depsgraph, float motion_time)
/* test if object needs to be hidden */
bool hide_tris;
- if(!object_render_hide(b_ob, true, true, hide_tris)) {
+ if(!object_render_hide(b_ob, true, true, hide_tris, depsgraph_mode)) {
/* object itself */
sync_object(b_depsgraph,
- b_dupli_iter,
+ b_instance,
~(0), /* until we get rid of layers */
motion_time,
hide_tris,
diff --git a/intern/cycles/blender/blender_particles.cpp b/intern/cycles/blender/blender_particles.cpp
index e365061722e..bb8e2e1398e 100644
--- a/intern/cycles/blender/blender_particles.cpp
+++ b/intern/cycles/blender/blender_particles.cpp
@@ -28,11 +28,11 @@ CCL_NAMESPACE_BEGIN
/* Utilities */
bool BlenderSync::sync_dupli_particle(BL::Object& b_ob,
- BL::DepsgraphIter& b_dup,
+ BL::DepsgraphObjectInstance& b_instance,
Object *object)
{
/* test if this dupli was generated from a particle sytem */
- BL::ParticleSystem b_psys = b_dup.particle_system();
+ BL::ParticleSystem b_psys = b_instance.particle_system();
if(!b_psys)
return false;
@@ -43,7 +43,7 @@ bool BlenderSync::sync_dupli_particle(BL::Object& b_ob,
return false;
/* don't handle child particles yet */
- BL::Array<int, OBJECT_PERSISTENT_ID_SIZE> persistent_id = b_dup.persistent_id();
+ BL::Array<int, OBJECT_PERSISTENT_ID_SIZE> persistent_id = b_instance.persistent_id();
if(persistent_id[0] >= b_psys.particles.length())
return false;
@@ -53,7 +53,7 @@ bool BlenderSync::sync_dupli_particle(BL::Object& b_ob,
ParticleSystem *psys;
bool first_use = !particle_system_map.is_used(key);
- bool need_update = particle_system_map.sync(&psys, b_ob, b_dup.object(), key);
+ bool need_update = particle_system_map.sync(&psys, b_ob, b_instance.object(), key);
/* no update needed? */
if(!need_update && !object->mesh->need_update && !scene->object_manager->need_update)
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index bfaa843eb18..eec13d04d7d 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -454,6 +454,7 @@ void BlenderSession::render(BL::Depsgraph& b_depsgraph_)
b_camera_override,
width, height,
&python_thread_state);
+ builtin_images_load();
/* Make sure all views have different noise patterns. - hardcoded value just to make it random */
if(view_index != 0) {
@@ -614,6 +615,7 @@ void BlenderSession::bake(BL::Depsgraph& b_depsgraph_,
b_camera_override,
width, height,
&python_thread_state);
+ builtin_images_load();
}
BakeData *bake_data = NULL;
@@ -773,7 +775,7 @@ void BlenderSession::synchronize(BL::Depsgraph& b_depsgraph_)
/* copy recalc flags, outside of mutex so we can decide to do the real
* synchronization at a later time to not block on running updates */
- sync->sync_recalc();
+ sync->sync_recalc(b_depsgraph_);
/* don't do synchronization if on pause */
if(session_pause) {
@@ -803,6 +805,8 @@ void BlenderSession::synchronize(BL::Depsgraph& b_depsgraph_)
else
sync->sync_camera(b_render, b_camera_override, width, height, "");
+ builtin_images_load();
+
/* unlock */
session->scene->mutex.unlock();
@@ -1327,6 +1331,16 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
return false;
}
+void BlenderSession::builtin_images_load()
+{
+ /* Force builtin images to be loaded along with Blender data sync. This
+ * is needed because we may be reading from depsgraph evaluated data which
+ * can be freed by Blender before Cycles reads it. */
+ ImageManager *manager = session->scene->image_manager;
+ Device *device = session->device;
+ manager->device_load_builtin(device, session->scene, session->progress);
+}
+
void BlenderSession::update_resumable_tile_manager(int num_samples)
{
const int num_resumable_chunks = BlenderSession::num_resumable_chunks,
diff --git a/intern/cycles/blender/blender_session.h b/intern/cycles/blender/blender_session.h
index aecb304c270..1d727e416a0 100644
--- a/intern/cycles/blender/blender_session.h
+++ b/intern/cycles/blender/blender_session.h
@@ -166,6 +166,7 @@ protected:
float *pixels,
const size_t pixels_size,
const bool free_cache);
+ void builtin_images_load();
/* Update tile manager to reflect resumable render settings. */
void update_resumable_tile_manager(int num_samples);
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index 8847d651b02..f9ba8a6e6b7 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -659,7 +659,9 @@ static ShaderNode *add_node(Scene *scene,
image->animated = b_image_node.image_user().use_auto_refresh();
image->use_alpha = b_image.use_alpha();
+ /* TODO: restore */
/* TODO(sergey): Does not work properly when we change builtin type. */
+#if 0
if(b_image.is_updated()) {
scene->image_manager->tag_reload_image(
image->filename.string(),
@@ -668,6 +670,7 @@ static ShaderNode *add_node(Scene *scene,
get_image_extension(b_image_node),
image->use_alpha);
}
+#endif
}
image->color_space = (NodeImageColorSpace)b_image_node.color_space();
image->projection = (NodeImageProjection)b_image_node.projection();
@@ -707,7 +710,9 @@ static ShaderNode *add_node(Scene *scene,
env->animated = b_env_node.image_user().use_auto_refresh();
env->use_alpha = b_image.use_alpha();
+ /* TODO: restore */
/* TODO(sergey): Does not work properly when we change builtin type. */
+#if 0
if(b_image.is_updated()) {
scene->image_manager->tag_reload_image(
env->filename.string(),
@@ -716,6 +721,7 @@ static ShaderNode *add_node(Scene *scene,
EXTENSION_REPEAT,
env->use_alpha);
}
+#endif
}
env->color_space = (NodeImageColorSpace)b_env_node.color_space();
env->interpolation = get_image_interpolation(b_env_node);
@@ -856,9 +862,11 @@ static ShaderNode *add_node(Scene *scene,
point_density->space = (NodeTexVoxelSpace)b_point_density_node.space();
point_density->interpolation = get_image_interpolation(b_point_density_node);
point_density->builtin_data = b_point_density_node.ptr.data;
+ point_density->image_manager = scene->image_manager;
/* TODO(sergey): Use more proper update flag. */
if(true) {
+ point_density->add_image();
b_point_density_node.cache_point_density(b_depsgraph);
scene->image_manager->tag_reload_image(
point_density->filename.string(),
@@ -1238,33 +1246,32 @@ void BlenderSync::sync_materials(BL::Depsgraph& b_depsgraph, bool update_all)
TaskPool pool;
set<Shader*> updated_shaders;
- /* material loop */
- BL::BlendData::materials_iterator b_mat_orig;
- for(b_data.materials.begin(b_mat_orig);
- b_mat_orig != b_data.materials.end();
- ++b_mat_orig)
- {
- /* TODO(sergey): Iterate over evaluated data rather than using mapping. */
- BL::Material b_mat_(b_depsgraph.id_eval_get(*b_mat_orig));
- BL::Material *b_mat = &b_mat_;
+ BL::Depsgraph::ids_iterator b_id;
+ for(b_depsgraph.ids.begin(b_id); b_id != b_depsgraph.ids.end(); ++b_id) {
+ if (!b_id->is_a(&RNA_Material)) {
+ continue;
+ }
+
+ BL::Material b_mat(*b_id);
Shader *shader;
/* test if we need to sync */
- if(shader_map.sync(&shader, *b_mat) || update_all) {
+ if(shader_map.sync(&shader, b_mat) || shader->need_sync_object || update_all) {
ShaderGraph *graph = new ShaderGraph();
- shader->name = b_mat->name().c_str();
- shader->pass_id = b_mat->pass_index();
+ shader->name = b_mat.name().c_str();
+ shader->pass_id = b_mat.pass_index();
+ shader->need_sync_object = false;
/* create nodes */
- if(b_mat->use_nodes() && b_mat->node_tree()) {
- BL::ShaderNodeTree b_ntree(b_mat->node_tree());
+ if(b_mat.use_nodes() && b_mat.node_tree()) {
+ BL::ShaderNodeTree b_ntree(b_mat.node_tree());
add_nodes(scene, b_engine, b_data, b_depsgraph, b_scene, graph, b_ntree);
}
else {
DiffuseBsdfNode *diffuse = new DiffuseBsdfNode();
- diffuse->color = get_float3(b_mat->diffuse_color());
+ diffuse->color = get_float3(b_mat.diffuse_color());
graph->add(diffuse);
ShaderNode *out = graph->output();
@@ -1272,7 +1279,7 @@ void BlenderSync::sync_materials(BL::Depsgraph& b_depsgraph, bool update_all)
}
/* settings */
- PointerRNA cmat = RNA_pointer_get(&b_mat->ptr, "cycles");
+ PointerRNA cmat = RNA_pointer_get(&b_mat.ptr, "cycles");
shader->use_mis = get_boolean(cmat, "sample_as_light");
shader->use_transparent_shadow = get_boolean(cmat, "use_transparent_shadow");
shader->heterogeneous_volume = !get_boolean(cmat, "homogeneous_volume");
@@ -1412,41 +1419,39 @@ void BlenderSync::sync_lamps(BL::Depsgraph& b_depsgraph, bool update_all)
{
shader_map.set_default(scene->default_light);
- /* lamp loop */
- BL::BlendData::lamps_iterator b_lamp_orig;
- for(b_data.lamps.begin(b_lamp_orig);
- b_lamp_orig != b_data.lamps.end();
- ++b_lamp_orig)
- {
- /* TODO(sergey): Iterate over evaluated data rather than using mapping. */
- BL::Lamp b_lamp_(b_depsgraph.id_eval_get(*b_lamp_orig));
- BL::Lamp *b_lamp = &b_lamp_;
+ BL::Depsgraph::ids_iterator b_id;
+ for(b_depsgraph.ids.begin(b_id); b_id != b_depsgraph.ids.end(); ++b_id) {
+ if (!b_id->is_a(&RNA_Lamp)) {
+ continue;
+ }
+
+ BL::Lamp b_lamp(*b_id);
Shader *shader;
/* test if we need to sync */
- if(shader_map.sync(&shader, *b_lamp) || update_all) {
+ if(shader_map.sync(&shader, b_lamp) || update_all) {
ShaderGraph *graph = new ShaderGraph();
/* create nodes */
- if(b_lamp->use_nodes() && b_lamp->node_tree()) {
- shader->name = b_lamp->name().c_str();
+ if(b_lamp.use_nodes() && b_lamp.node_tree()) {
+ shader->name = b_lamp.name().c_str();
- BL::ShaderNodeTree b_ntree(b_lamp->node_tree());
+ BL::ShaderNodeTree b_ntree(b_lamp.node_tree());
add_nodes(scene, b_engine, b_data, b_depsgraph, b_scene, graph, b_ntree);
}
else {
float strength = 1.0f;
- if(b_lamp->type() == BL::Lamp::type_POINT ||
- b_lamp->type() == BL::Lamp::type_SPOT ||
- b_lamp->type() == BL::Lamp::type_AREA)
+ if(b_lamp.type() == BL::Lamp::type_POINT ||
+ b_lamp.type() == BL::Lamp::type_SPOT ||
+ b_lamp.type() == BL::Lamp::type_AREA)
{
strength = 100.0f;
}
EmissionNode *emission = new EmissionNode();
- emission->color = get_float3(b_lamp->color());
+ emission->color = get_float3(b_lamp.color());
emission->strength = strength;
graph->add(emission);
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index c175ed252f7..0c27786f241 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -76,31 +76,12 @@ BlenderSync::~BlenderSync()
/* Sync */
-bool BlenderSync::sync_recalc()
+void BlenderSync::sync_recalc(BL::Depsgraph& b_depsgraph)
{
- /* sync recalc flags from blender to cycles. actual update is done separate,
- * so we can do it later on if doing it immediate is not suitable */
-
- BL::BlendData::materials_iterator b_mat;
- bool has_updated_objects = b_data.objects.is_updated();
- for(b_data.materials.begin(b_mat); b_mat != b_data.materials.end(); ++b_mat) {
- if(b_mat->is_updated() || (b_mat->node_tree() && b_mat->node_tree().is_updated())) {
- shader_map.set_recalc(*b_mat);
- }
- else {
- Shader *shader = shader_map.find(*b_mat);
- if(has_updated_objects && shader != NULL && shader->has_object_dependency) {
- shader_map.set_recalc(*b_mat);
- }
- }
- }
-
- BL::BlendData::lamps_iterator b_lamp;
-
- for(b_data.lamps.begin(b_lamp); b_lamp != b_data.lamps.end(); ++b_lamp)
- if(b_lamp->is_updated() || (b_lamp->node_tree() && b_lamp->node_tree().is_updated()))
- shader_map.set_recalc(*b_lamp);
+ /* Sync recalc flags from blender to cycles. Actual update is done separate,
+ * so we can do it later on if doing it immediate is not suitable. */
+ bool has_updated_objects = b_depsgraph.id_type_updated(BL::DriverTarget::id_type_OBJECT);
bool dicing_prop_changed = false;
if(experimental) {
@@ -122,70 +103,77 @@ bool BlenderSync::sync_recalc()
}
}
- BL::BlendData::objects_iterator b_ob;
+ /* Iterate over all IDs in this depsgraph. */
+ BL::Depsgraph::updates_iterator b_update;
+ for(b_depsgraph.updates.begin(b_update); b_update != b_depsgraph.updates.end(); ++b_update) {
+ BL::ID b_id(b_update->id());
- for(b_data.objects.begin(b_ob); b_ob != b_data.objects.end(); ++b_ob) {
- if(b_ob->is_updated()) {
- object_map.set_recalc(*b_ob);
- light_map.set_recalc(*b_ob);
+ /* Material */
+ if (b_id.is_a(&RNA_Material)) {
+ BL::Material b_mat(b_id);
+ shader_map.set_recalc(b_mat);
+ }
+ /* Lamp */
+ else if (b_id.is_a(&RNA_Lamp)) {
+ BL::Lamp b_lamp(b_id);
+ shader_map.set_recalc(b_lamp);
}
+ /* Object */
+ else if (b_id.is_a(&RNA_Object)) {
+ BL::Object b_ob(b_id);
+ const bool updated_geometry = b_update->updated_geometry();
+
+ if (b_update->updated_transform()) {
+ object_map.set_recalc(b_ob);
+ light_map.set_recalc(b_ob);
+ }
+
+ if(object_is_mesh(b_ob)) {
+ if(updated_geometry ||
+ (dicing_prop_changed && object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE))
+ {
+ BL::ID key = BKE_object_is_modified(b_ob)? b_ob: b_ob.data();
+ mesh_map.set_recalc(key);
+ }
+ }
+ else if(object_is_light(b_ob)) {
+ if(updated_geometry) {
+ light_map.set_recalc(b_ob);
+ }
+ }
- if(object_is_mesh(*b_ob)) {
- if(b_ob->is_updated_data() || b_ob->data().is_updated() ||
- (dicing_prop_changed && object_subdivision_type(*b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE))
- {
- BL::ID key = BKE_object_is_modified(*b_ob)? *b_ob: b_ob->data();
- mesh_map.set_recalc(key);
+ if(updated_geometry) {
+ BL::Object::particle_systems_iterator b_psys;
+ for(b_ob.particle_systems.begin(b_psys); b_psys != b_ob.particle_systems.end(); ++b_psys)
+ particle_system_map.set_recalc(b_ob);
}
}
- else if(object_is_light(*b_ob)) {
- if(b_ob->is_updated_data() || b_ob->data().is_updated())
- light_map.set_recalc(*b_ob);
+ /* Mesh */
+ else if (b_id.is_a(&RNA_Mesh)) {
+ BL::Mesh b_mesh(b_id);
+ mesh_map.set_recalc(b_mesh);
}
-
- if(b_ob->is_updated_data()) {
- BL::Object::particle_systems_iterator b_psys;
- for(b_ob->particle_systems.begin(b_psys); b_psys != b_ob->particle_systems.end(); ++b_psys)
- particle_system_map.set_recalc(*b_ob);
+ /* World */
+ else if (b_id.is_a(&RNA_World)) {
+ BL::World b_world(b_id);
+ if(world_map == b_world.ptr.data) {
+ world_recalc = true;
+ }
}
}
- BL::BlendData::meshes_iterator b_mesh;
-
- for(b_data.meshes.begin(b_mesh); b_mesh != b_data.meshes.end(); ++b_mesh) {
- if(b_mesh->is_updated()) {
- mesh_map.set_recalc(*b_mesh);
+ /* Updates shader with object dependency if objects changed. */
+ if (has_updated_objects) {
+ if(scene->default_background->has_object_dependency) {
+ world_recalc = true;
}
- }
- BL::BlendData::worlds_iterator b_world;
-
- for(b_data.worlds.begin(b_world); b_world != b_data.worlds.end(); ++b_world) {
- if(world_map == b_world->ptr.data) {
- if(b_world->is_updated() ||
- (b_world->node_tree() && b_world->node_tree().is_updated()))
- {
- world_recalc = true;
- }
- else if(b_world->node_tree() && b_world->use_nodes()) {
- Shader *shader = scene->default_background;
- if(has_updated_objects && shader->has_object_dependency) {
- world_recalc = true;
- }
+ foreach(Shader *shader, scene->shaders) {
+ if (shader->has_object_dependency) {
+ shader->need_sync_object = true;
}
}
}
-
- bool recalc =
- shader_map.has_recalc() ||
- object_map.has_recalc() ||
- light_map.has_recalc() ||
- mesh_map.has_recalc() ||
- particle_system_map.has_recalc() ||
- BlendDataObjects_is_updated_get(&b_data.ptr) ||
- world_recalc;
-
- return recalc;
}
void BlenderSync::sync_data(BL::RenderSettings& b_render,
diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h
index 468e287038c..77ee590335c 100644
--- a/intern/cycles/blender/blender_sync.h
+++ b/intern/cycles/blender/blender_sync.h
@@ -59,7 +59,7 @@ public:
~BlenderSync();
/* sync */
- bool sync_recalc();
+ void sync_recalc(BL::Depsgraph& b_depsgraph);
void sync_data(BL::RenderSettings& b_render,
BL::Depsgraph& b_depsgraph,
BL::SpaceView3D& b_v3d,
@@ -126,7 +126,7 @@ private:
bool motion,
int motion_step = 0);
Object *sync_object(BL::Depsgraph& b_depsgraph,
- BL::Depsgraph::duplis_iterator& b_dupli_iter,
+ BL::DepsgraphObjectInstance& b_instance,
uint layer_flag,
float motion_time,
bool hide_tris,
@@ -151,7 +151,7 @@ private:
/* particles */
bool sync_dupli_particle(BL::Object& b_ob,
- BL::DepsgraphIter& b_dup,
+ BL::DepsgraphObjectInstance& b_instance,
Object *object);
/* Images. */
diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h
index 8a874b7063e..e9ede91c295 100644
--- a/intern/cycles/blender/blender_util.h
+++ b/intern/cycles/blender/blender_util.h
@@ -251,7 +251,7 @@ static inline Transform get_transform(const BL::Array<float, 16>& array)
/* We assume both types to be just 16 floats, and transpose because blender
* use column major matrix order while we use row major. */
- memcpy(&projection, &array, sizeof(float)*16);
+ memcpy((void *)&projection, &array, sizeof(float)*16);
projection = projection_transpose(projection);
/* Drop last row, matrix is assumed to be affine transform. */
diff --git a/intern/cycles/bvh/bvh_params.h b/intern/cycles/bvh/bvh_params.h
index 89a379cf356..d8dd7df6ba1 100644
--- a/intern/cycles/bvh/bvh_params.h
+++ b/intern/cycles/bvh/bvh_params.h
@@ -182,7 +182,10 @@ public:
BVHReference& operator=(const BVHReference &arg) {
if(&arg != this) {
- memcpy(this, &arg, sizeof(BVHReference));
+ /* TODO(sergey): Check if it is still faster to memcpy() with
+ * modern compilers.
+ */
+ memcpy((void *)this, &arg, sizeof(BVHReference));
}
return *this;
}
diff --git a/intern/cycles/kernel/closure/alloc.h b/intern/cycles/kernel/closure/alloc.h
index b903aeb8073..acccba9ecec 100644
--- a/intern/cycles/kernel/closure/alloc.h
+++ b/intern/cycles/kernel/closure/alloc.h
@@ -75,7 +75,7 @@ ccl_device_inline ShaderClosure *bsdf_alloc_osl(ShaderData *sd, int size, float3
if(!sc)
return NULL;
- memcpy(sc, data, size);
+ memcpy((void *)sc, data, size);
float sample_weight = fabsf(average(weight));
sc->weight = weight;
diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp
index 32d86b7192a..5f4baf6fda3 100644
--- a/intern/cycles/kernel/osl/osl_services.cpp
+++ b/intern/cycles/kernel/osl/osl_services.cpp
@@ -65,13 +65,13 @@ CCL_NAMESPACE_BEGIN
static void copy_matrix(OSL::Matrix44& m, const Transform& tfm)
{
ProjectionTransform t = projection_transpose(ProjectionTransform(tfm));
- memcpy(&m, &t, sizeof(m));
+ memcpy((void *)&m, &t, sizeof(m));
}
static void copy_matrix(OSL::Matrix44& m, const ProjectionTransform& tfm)
{
ProjectionTransform t = projection_transpose(tfm);
- memcpy(&m, &t, sizeof(m));
+ memcpy((void *)&m, &t, sizeof(m));
}
/* static ustrings */
diff --git a/intern/cycles/kernel/osl/osl_shader.cpp b/intern/cycles/kernel/osl/osl_shader.cpp
index 6b3a996ca12..b7d1c629291 100644
--- a/intern/cycles/kernel/osl/osl_shader.cpp
+++ b/intern/cycles/kernel/osl/osl_shader.cpp
@@ -53,7 +53,7 @@ void OSLShader::thread_init(KernelGlobals *kg, KernelGlobals *kernel_globals, OS
OSL::ShadingSystem *ss = kg->osl->ss;
OSLThreadData *tdata = new OSLThreadData();
- memset(&tdata->globals, 0, sizeof(OSL::ShaderGlobals));
+ memset((void *)&tdata->globals, 0, sizeof(OSL::ShaderGlobals));
tdata->globals.tracedata = &tdata->tracedata;
tdata->globals.flipHandedness = false;
tdata->osl_thread_info = ss->create_thread_info();
diff --git a/intern/cycles/kernel/split/kernel_split_common.h b/intern/cycles/kernel/split/kernel_split_common.h
index b52e7bddc82..abe68104449 100644
--- a/intern/cycles/kernel/split/kernel_split_common.h
+++ b/intern/cycles/kernel/split/kernel_split_common.h
@@ -59,12 +59,15 @@ ccl_device_inline void kernel_split_path_end(KernelGlobals *kg, int ray_index)
ccl_global char *ray_state = kernel_split_state.ray_state;
#ifdef __BRANCHED_PATH__
+# ifdef __SUBSURFACE__
ccl_addr_space SubsurfaceIndirectRays *ss_indirect = &kernel_split_state.ss_rays[ray_index];
if(ss_indirect->num_rays) {
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
}
- else if(IS_FLAG(ray_state, ray_index, RAY_BRANCHED_INDIRECT_SHARED)) {
+ else
+# endif /* __SUBSURFACE__ */
+ if(IS_FLAG(ray_state, ray_index, RAY_BRANCHED_INDIRECT_SHARED)) {
int orig_ray = kernel_split_state.branched_state[ray_index].original_ray;
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
diff --git a/intern/cycles/render/camera.cpp b/intern/cycles/render/camera.cpp
index 38936ffc094..734cdffd5c5 100644
--- a/intern/cycles/render/camera.cpp
+++ b/intern/cycles/render/camera.cpp
@@ -176,7 +176,7 @@ Camera::Camera()
need_flags_update = true;
previous_need_motion = -1;
- memset(&kernel_camera, 0, sizeof(kernel_camera));
+ memset((void *)&kernel_camera, 0, sizeof(kernel_camera));
}
Camera::~Camera()
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index 9c5e32e8219..6867ea95d63 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -943,6 +943,39 @@ void ImageManager::device_update_slot(Device *device,
}
}
+void ImageManager::device_load_builtin(Device *device,
+ Scene *scene,
+ Progress& progress)
+{
+ /* Load only builtin images, Blender needs this to load evaluated
+ * scene data from depsgraph before it is freed. */
+ if(!need_update) {
+ return;
+ }
+
+ TaskPool pool;
+ for(int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
+ for(size_t slot = 0; slot < images[type].size(); slot++) {
+ if(!images[type][slot])
+ continue;
+
+ if(images[type][slot]->need_load) {
+ if(images[type][slot]->builtin_data) {
+ pool.push(function_bind(&ImageManager::device_load_image,
+ this,
+ device,
+ scene,
+ (ImageDataType)type,
+ slot,
+ &progress));
+ }
+ }
+ }
+ }
+
+ pool.wait_work();
+}
+
void ImageManager::device_free_builtin(Device *device)
{
for(int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h
index 5391490d993..66f929aa03a 100644
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@ -80,6 +80,10 @@ public:
int flat_slot,
Progress *progress);
void device_free(Device *device);
+
+ void device_load_builtin(Device *device,
+ Scene *scene,
+ Progress& progress);
void device_free_builtin(Device *device);
void set_osl_texture_system(void *texture_system);
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 3dad4d1a346..3a531f87c10 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -1488,6 +1488,19 @@ void PointDensityTextureNode::attributes(Shader *shader,
ShaderNode::attributes(shader, attributes);
}
+void PointDensityTextureNode::add_image()
+{
+ if(slot == -1) {
+ ImageMetaData metadata;
+ slot = image_manager->add_image(filename.string(), builtin_data,
+ false, 0,
+ interpolation,
+ EXTENSION_CLIP,
+ true,
+ metadata);
+ }
+}
+
void PointDensityTextureNode::compile(SVMCompiler& compiler)
{
ShaderInput *vector_in = input("Vector");
@@ -1500,15 +1513,7 @@ void PointDensityTextureNode::compile(SVMCompiler& compiler)
image_manager = compiler.image_manager;
if(use_density || use_color) {
- if(slot == -1) {
- ImageMetaData metadata;
- slot = image_manager->add_image(filename.string(), builtin_data,
- false, 0,
- interpolation,
- EXTENSION_CLIP,
- true,
- metadata);
- }
+ add_image();
if(slot != -1) {
compiler.stack_assign(vector_in);
@@ -1551,15 +1556,7 @@ void PointDensityTextureNode::compile(OSLCompiler& compiler)
image_manager = compiler.image_manager;
if(use_density || use_color) {
- if(slot == -1) {
- ImageMetaData metadata;
- slot = image_manager->add_image(filename.string(), builtin_data,
- false, 0,
- interpolation,
- EXTENSION_CLIP,
- true,
- metadata);
- }
+ add_image();
if(slot != -1) {
compiler.parameter("filename", string_printf("@i%d", slot).c_str());
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index 35a7df690c3..d1c7c9176e1 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -265,6 +265,8 @@ public:
bool has_spatial_varying() { return true; }
bool has_object_dependency() { return true; }
+ void add_image();
+
ustring filename;
NodeTexVoxelSpace space;
InterpolationType interpolation;
diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp
index b35cdbd3db5..c0f1ae0445e 100644
--- a/intern/cycles/render/scene.cpp
+++ b/intern/cycles/render/scene.cpp
@@ -79,13 +79,13 @@ DeviceScene::DeviceScene(Device *device)
sobol_directions(device, "__sobol_directions", MEM_TEXTURE),
ies_lights(device, "__ies", MEM_TEXTURE)
{
- memset(&data, 0, sizeof(data));
+ memset((void*)&data, 0, sizeof(data));
}
Scene::Scene(const SceneParams& params_, Device *device)
: device(device), dscene(device), params(params_)
{
- memset(&dscene.data, 0, sizeof(dscene.data));
+ memset((void *)&dscene.data, 0, sizeof(dscene.data));
camera = new Camera();
dicing_camera = new Camera();
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index ec52c51e337..c1621cd817b 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -202,6 +202,7 @@ Shader::Shader()
need_update = true;
need_update_mesh = true;
+ need_sync_object = false;
}
Shader::~Shader()
diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h
index abd483caabc..ffaef522124 100644
--- a/intern/cycles/render/shader.h
+++ b/intern/cycles/render/shader.h
@@ -99,6 +99,7 @@ public:
/* synchronization */
bool need_update;
bool need_update_mesh;
+ bool need_sync_object;
/* If the shader has only volume components, the surface is assumed to
* be transparent.
diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp
index eb8a35a271f..626f160786f 100644
--- a/intern/cycles/render/svm.cpp
+++ b/intern/cycles/render/svm.cpp
@@ -735,7 +735,7 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty
}
/* clear all compiler state */
- memset(&active_stack, 0, sizeof(active_stack));
+ memset((void *)&active_stack, 0, sizeof(active_stack));
current_svm_nodes.clear();
foreach(ShaderNode *node_iter, graph->nodes) {
diff --git a/intern/cycles/util/util_vector.h b/intern/cycles/util/util_vector.h
index e98e4e34181..8d91d3936a4 100644
--- a/intern/cycles/util/util_vector.h
+++ b/intern/cycles/util/util_vector.h
@@ -131,7 +131,7 @@ public:
{
if(this != &from) {
resize(from.size());
- memcpy(data_, from.data_, datasize_*sizeof(T));
+ memcpy((void*)data_, from.data_, datasize_*sizeof(T));
}
return *this;
@@ -204,7 +204,9 @@ public:
return NULL;
}
else if(data_ != NULL) {
- memcpy(newdata, data_, ((datasize_ < newsize)? datasize_: newsize)*sizeof(T));
+ memcpy((void *)newdata,
+ data_,
+ ((datasize_ < newsize)? datasize_: newsize)*sizeof(T));
mem_free(data_, capacity_);
}
data_ = newdata;
diff --git a/intern/eigen/CMakeLists.txt b/intern/eigen/CMakeLists.txt
index 5811b71de94..b2639359318 100644
--- a/intern/eigen/CMakeLists.txt
+++ b/intern/eigen/CMakeLists.txt
@@ -36,10 +36,12 @@ set(SRC
intern/eigenvalues.cc
intern/linear_solver.cc
+ intern/matrix.cc
intern/svd.cc
intern/eigenvalues.h
intern/linear_solver.h
+ intern/matrix.h
intern/svd.h
)
diff --git a/intern/eigen/eigen_capi.h b/intern/eigen/eigen_capi.h
index be42e340274..7f3267ff508 100644
--- a/intern/eigen/eigen_capi.h
+++ b/intern/eigen/eigen_capi.h
@@ -29,6 +29,7 @@
#include "intern/eigenvalues.h"
#include "intern/linear_solver.h"
+#include "intern/matrix.h"
#include "intern/svd.h"
#endif /* __EIGEN_C_API_H__ */
diff --git a/intern/eigen/intern/matrix.cc b/intern/eigen/intern/matrix.cc
new file mode 100644
index 00000000000..5e00540f27c
--- /dev/null
+++ b/intern/eigen/intern/matrix.cc
@@ -0,0 +1,55 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2018 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __EIGEN3_MATRIX_C_API_CC__
+#define __EIGEN3_MATRIX_C_API_CC__
+
+/* Eigen gives annoying huge amount of warnings here, silence them! */
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic ignored "-Wlogical-op"
+#endif
+
+#ifdef __EIGEN3_MATRIX_C_API_CC__ /* quiet warning */
+#endif
+
+#include <Eigen/Core>
+#include <Eigen/Dense>
+
+#include "matrix.h"
+
+using Eigen::Map;
+using Eigen::Matrix4f;
+
+bool EIG_invert_m4_m4(float inverse[4][4], const float matrix[4][4])
+{
+ Map<Matrix4f> M = Map<Matrix4f>((float*)matrix);
+ Matrix4f R;
+ bool invertible = true;
+ M.computeInverseWithCheck(R, invertible, 0.0f);
+ memcpy(inverse, R.data(), sizeof(float)*4*4);
+ return invertible;
+}
+
+#endif /* __EIGEN3_MATRIX_C_API_CC__ */
diff --git a/intern/eigen/intern/matrix.h b/intern/eigen/intern/matrix.h
new file mode 100644
index 00000000000..fd0f60fd81c
--- /dev/null
+++ b/intern/eigen/intern/matrix.h
@@ -0,0 +1,40 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2015 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation,
+ * Bastien Montagne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __EIGEN3_MATRIX_C_API_H__
+#define __EIGEN3_MATRIX_C_API_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool EIG_invert_m4_m4(float inverse[4][4], const float matrix[4][4]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __EIGEN3_MATRIX_C_API_H__ */
diff --git a/intern/eigen/intern/svd.cc b/intern/eigen/intern/svd.cc
index 7c331d25aa7..e035f29f5ac 100644
--- a/intern/eigen/intern/svd.cc
+++ b/intern/eigen/intern/svd.cc
@@ -37,6 +37,7 @@
#include <Eigen/Core>
#include <Eigen/SVD>
+#include <Eigen/Dense>
#include "svd.h"
@@ -51,6 +52,8 @@ using Eigen::MatrixXf;
using Eigen::VectorXf;
using Eigen::Map;
+using Eigen::Matrix4f;
+
void EIG_svd_square_matrix(const int size, const float *matrix, float *r_U, float *r_S, float *r_V)
{
/* Since our matrix is squared, we can use thinU/V. */
diff --git a/intern/gawain/gawain/gwn_common.h b/intern/gawain/gawain/gwn_common.h
index dc0a52ca096..f1512bf4466 100644
--- a/intern/gawain/gawain/gwn_common.h
+++ b/intern/gawain/gawain/gwn_common.h
@@ -33,4 +33,4 @@
# define GWN_INLINE static __forceinline
#else
# define GWN_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__))
-#endif \ No newline at end of file
+#endif
diff --git a/intern/gawain/src/gwn_batch.c b/intern/gawain/src/gwn_batch.c
index 2e3a4eff0f0..64d5d146578 100644
--- a/intern/gawain/src/gwn_batch.c
+++ b/intern/gawain/src/gwn_batch.c
@@ -179,7 +179,7 @@ int GWN_batch_vertbuf_add_ex(
return v;
}
}
-
+
// we only make it this far if there is no room for another Gwn_VertBuf
#if TRUST_NO_ONE
assert(false);
diff --git a/intern/gawain/src/gwn_immediate.c b/intern/gawain/src/gwn_immediate.c
index 006af0abe01..b0b587d1b8c 100644
--- a/intern/gawain/src/gwn_immediate.c
+++ b/intern/gawain/src/gwn_immediate.c
@@ -47,7 +47,7 @@ typedef struct {
GLuint vbo_id;
GLuint vao_id;
-
+
GLuint bound_program;
const Gwn_ShaderInterface* shader_interface;
Gwn_AttrBinding attrib_binding;
diff --git a/intern/gawain/src/gwn_vertex_array_id.cpp b/intern/gawain/src/gwn_vertex_array_id.cpp
index ad60dea7542..2ab38a8fe18 100644
--- a/intern/gawain/src/gwn_vertex_array_id.cpp
+++ b/intern/gawain/src/gwn_vertex_array_id.cpp
@@ -18,7 +18,7 @@
#include <mutex>
#include <unordered_set>
-#if TRUST_NO_ONE
+#if 0
extern "C" {
extern int BLI_thread_is_main(void); // Blender-specific function
}
@@ -68,7 +68,8 @@ static void clear_orphans(Gwn_Context* ctx)
Gwn_Context* GWN_context_create(void)
{
#if TRUST_NO_ONE
- assert(thread_is_main());
+ /* We cannot rely on this anymore. */
+ // assert(thread_is_main());
#endif
Gwn_Context* ctx = new Gwn_Context;
glGenVertexArrays(1, &ctx->default_vao);
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index e4b74ae24af..d8330d43c16 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -280,7 +280,7 @@ elseif(WIN32)
if(NOT WITH_GL_EGL)
list(APPEND SRC
intern/GHOST_ContextWGL.cpp
-
+
intern/GHOST_ContextWGL.h
)
endif()
@@ -307,7 +307,7 @@ endif()
if(WITH_GL_EGL AND NOT (WITH_HEADLESS OR WITH_GHOST_SDL))
list(APPEND SRC
intern/GHOST_ContextEGL.cpp
-
+
intern/GHOST_ContextEGL.h
)
endif()
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 071474e57dc..a911c4560e4 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -36,7 +36,7 @@
#include "GHOST_Types.h"
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
/**
@@ -103,7 +103,7 @@ extern GHOST_TUns64 GHOST_GetMilliSeconds(GHOST_SystemHandle systemhandle);
/**
* Installs a timer.
- * Note that, on most operating systems, messages need to be processed in order
+ * Note that, on most operating systems, messages need to be processed in order
* for the timer callbacks to be invoked.
* \param systemhandle The handle to the system
* \param delay The time to wait for the first call to the timerProc (in milliseconds)
@@ -165,7 +165,7 @@ extern void GHOST_GetAllDisplayDimensions(GHOST_SystemHandle systemhandle,
/**
* Create a new window.
- * The new window is added to the list of windows managed.
+ * The new window is added to the list of windows managed.
* Never explicitly delete the window, use disposeWindow() instead.
* \param systemhandle The handle to the system
* \param title The name of the window (displayed in the title bar of the window if the OS supports it).
@@ -218,7 +218,7 @@ extern GHOST_TUserDataPtr GHOST_GetWindowUserData(GHOST_WindowHandle windowhandl
* \param windowhandle The handle to the window
* \param userdata The window user data.
*/
-extern void GHOST_SetWindowUserData(GHOST_WindowHandle windowhandle,
+extern void GHOST_SetWindowUserData(GHOST_WindowHandle windowhandle,
GHOST_TUserDataPtr userdata);
/**
@@ -488,7 +488,7 @@ extern GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle);
extern GHOST_TUns64 GHOST_GetEventTime(GHOST_EventHandle eventhandle);
/**
- * Returns the window this event was generated on,
+ * Returns the window this event was generated on,
* or NULL if it is a 'system' event.
* \param eventhandle The handle to the event
* \return The generating window.
@@ -566,7 +566,7 @@ extern void GHOST_SetTitle(GHOST_WindowHandle windowhandle,
/**
* Returns the title displayed in the title bar. The title
* should be free'd with free().
- *
+ *
* \param windowhandle The handle to the window
* \return The title, free with free().
*/
diff --git a/intern/ghost/GHOST_IEvent.h b/intern/ghost/GHOST_IEvent.h
index ba5d9ee33b9..83273716950 100644
--- a/intern/ghost/GHOST_IEvent.h
+++ b/intern/ghost/GHOST_IEvent.h
@@ -42,8 +42,8 @@ class GHOST_IWindow;
* Interface class for events received from GHOST.
* You should not need to inherit this class. The system will pass these events
* to the GHOST_IEventConsumer::processEvent() method of event consumers.<br>
- * Use the getType() method to retrieve the type of event and the getData()
- * method to get the event data out. Using the event type you can cast the
+ * Use the getType() method to retrieve the type of event and the getData()
+ * method to get the event data out. Using the event type you can cast the
* event data to the correct event dat structure.
* \see GHOST_IEventConsumer#processEvent
* \see GHOST_TEventType
@@ -73,18 +73,18 @@ public:
virtual GHOST_TUns64 getTime() = 0;
/**
- * Returns the window this event was generated on,
+ * Returns the window this event was generated on,
* or NULL if it is a 'system' event.
* \return The generating window.
*/
virtual GHOST_IWindow *getWindow() = 0;
-
+
/**
* Returns the event data.
* \return The event data.
*/
virtual GHOST_TEventDataPtr getData() = 0;
-
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_IEvent")
#endif
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index 25b7fb26e0e..1a6c0f9a1bf 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -315,7 +315,7 @@ public:
* \return The current status.
*/
virtual bool getFullScreen(void) = 0;
-
+
/**
* Native pixel size support (MacBook 'retina').
*/
diff --git a/intern/ghost/GHOST_ISystemPaths.h b/intern/ghost/GHOST_ISystemPaths.h
index 8f81a226f94..14b1183af2c 100644
--- a/intern/ghost/GHOST_ISystemPaths.h
+++ b/intern/ghost/GHOST_ISystemPaths.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/intern/ghost/GHOST_ITimerTask.h b/intern/ghost/GHOST_ITimerTask.h
index 9bea697cbc8..dd3db5623cc 100644
--- a/intern/ghost/GHOST_ITimerTask.h
+++ b/intern/ghost/GHOST_ITimerTask.h
@@ -39,11 +39,11 @@
/**
* Interface for a timer task.
* Timer tasks are created by the system and can be installed by the system.
- * After installation, the timer callback-procedure or "timerProc" will be called
+ * After installation, the timer callback-procedure or "timerProc" will be called
* periodically. You should not need to inherit this class. It is passed to the
* application in the timer-callback.<br>
* <br>
- * Note that GHOST processes timers in the UI thread. You should ask GHOST
+ * Note that GHOST processes timers in the UI thread. You should ask GHOST
* process messages in order for the timer-callbacks to be called.
* \see GHOST_ISystem#installTimer
* \see GHOST_TimerProcPtr
@@ -77,7 +77,7 @@ public:
* \return The timer user data.
*/
virtual GHOST_TUserDataPtr getUserData() const = 0;
-
+
/**
* Changes the time user data.
* \param userData: The timer user data.
diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h
index 4a4d6be5ced..5a3403bcbd3 100644
--- a/intern/ghost/GHOST_IWindow.h
+++ b/intern/ghost/GHOST_IWindow.h
@@ -361,7 +361,7 @@ public:
*/
virtual void endIME() = 0;
#endif /* WITH_INPUT_IME */
-
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_IWindow")
#endif
diff --git a/intern/ghost/GHOST_Path-api.h b/intern/ghost/GHOST_Path-api.h
index 5af3adaa570..9a4d065d2ad 100644
--- a/intern/ghost/GHOST_Path-api.h
+++ b/intern/ghost/GHOST_Path-api.h
@@ -36,7 +36,7 @@
#include "GHOST_Types.h"
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
GHOST_DECLARE_HANDLE(GHOST_SystemPathsHandle);
@@ -79,7 +79,7 @@ extern const GHOST_TUns8 *GHOST_getBinaryDir(void);
extern void GHOST_addToSystemRecentFiles(const char *filename);
#ifdef __cplusplus
-}
+}
#endif
#endif
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index 02b5063e515..b206bb677a7 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -77,7 +77,7 @@ typedef enum {
GHOST_kSuccess
} GHOST_TSuccess;
-/* Xtilt and Ytilt represent how much the pen is tilted away from
+/* Xtilt and Ytilt represent how much the pen is tilted away from
* vertically upright in either the X or Y direction, with X and Y the
* axes of the tablet surface.
* In other words, Xtilt and Ytilt are components of a vector created by projecting
@@ -190,12 +190,12 @@ typedef enum {
GHOST_kEventWindowSize,
GHOST_kEventWindowMove,
GHOST_kEventWindowDPIHintChanged,
-
+
GHOST_kEventDraggingEntered,
GHOST_kEventDraggingUpdated,
GHOST_kEventDraggingExited,
GHOST_kEventDraggingDropDone,
-
+
GHOST_kEventOpenMainFile, // Needed for Cocoa to open double-clicked .blend file at startup
GHOST_kEventNativeResolutionChange, // Needed for Cocoa when window moves to other display
@@ -214,9 +214,9 @@ typedef enum {
GHOST_kStandardCursorDefault = 0,
GHOST_kStandardCursorRightArrow,
GHOST_kStandardCursorLeftArrow,
- GHOST_kStandardCursorInfo,
+ GHOST_kStandardCursorInfo,
GHOST_kStandardCursorDestroy,
- GHOST_kStandardCursorHelp,
+ GHOST_kStandardCursorHelp,
GHOST_kStandardCursorCycle,
GHOST_kStandardCursorSpray,
GHOST_kStandardCursorWait,
@@ -233,7 +233,7 @@ typedef enum {
GHOST_kStandardCursorBottomRightCorner,
GHOST_kStandardCursorBottomLeftCorner,
GHOST_kStandardCursorCopy,
- GHOST_kStandardCursorCustom,
+ GHOST_kStandardCursorCustom,
GHOST_kStandardCursorPencil,
GHOST_kStandardCursorNumCursors
@@ -247,7 +247,7 @@ typedef enum {
GHOST_kKeyLinefeed,
GHOST_kKeyClear,
GHOST_kKeyEnter = 0x0D,
-
+
GHOST_kKeyEsc = 0x1B,
GHOST_kKeySpace = ' ',
GHOST_kKeyQuote = 0x27,
@@ -305,7 +305,7 @@ typedef enum {
GHOST_kKeyBackslash = 0x5C,
GHOST_kKeyAccentGrave = '`',
-
+
GHOST_kKeyLeftShift = 0x100,
GHOST_kKeyRightShift,
GHOST_kKeyLeftControl,
@@ -377,7 +377,7 @@ typedef enum {
GHOST_kKeyF22,
GHOST_kKeyF23,
GHOST_kKeyF24,
-
+
// Multimedia keypad buttons
GHOST_kKeyMediaPlay,
GHOST_kKeyMediaStop,
@@ -418,7 +418,7 @@ typedef enum {
GHOST_kTrackpadEventSwipe, /* Reserved, not used for now */
GHOST_kTrackpadEventMagnify
} GHOST_TTrackpadEventSubTypes;
-
+
typedef struct {
/** The event subtype */
diff --git a/intern/ghost/intern/GHOST_Buttons.h b/intern/ghost/intern/GHOST_Buttons.h
index 0aa93a2fad0..aed9a3cc81f 100644
--- a/intern/ghost/intern/GHOST_Buttons.h
+++ b/intern/ghost/intern/GHOST_Buttons.h
@@ -38,7 +38,7 @@
/**
* This struct stores the state of the mouse buttons.
- * Buttons can be set using button masks.
+ * Buttons can be set using button masks.
* \author Maarten Gribnau
* \date May 15, 2001
*/
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index c89ef49de33..90956cf541a 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -119,7 +119,7 @@ void GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle,
GHOST_TUns32 *height)
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
-
+
system->getMainDisplayDimensions(*width, *height);
}
@@ -182,7 +182,7 @@ GHOST_TSuccess GHOST_DisposeWindow(GHOST_SystemHandle systemhandle,
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
-
+
return system->disposeWindow(window);
}
@@ -193,7 +193,7 @@ int GHOST_ValidWindow(GHOST_SystemHandle systemhandle,
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
-
+
return (int) system->validWindow(window);
}
@@ -211,7 +211,7 @@ GHOST_WindowHandle GHOST_BeginFullScreen(GHOST_SystemHandle systemhandle,
bstereoVisual = true;
else
bstereoVisual = false;
-
+
system->beginFullScreen(*setting, &window, bstereoVisual);
return (GHOST_WindowHandle)window;
@@ -240,7 +240,7 @@ int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle)
int GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, int waitForEvent)
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
-
+
return (int) system->processEvents(waitForEvent ? true : false);
}
@@ -249,7 +249,7 @@ int GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, int waitForEvent)
void GHOST_DispatchEvents(GHOST_SystemHandle systemhandle)
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
-
+
system->dispatchEvents();
}
@@ -257,7 +257,7 @@ void GHOST_DispatchEvents(GHOST_SystemHandle systemhandle)
GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle)
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
-
+
return system->addEventConsumer((GHOST_CallbackEventConsumer *)consumerhandle);
}
@@ -353,7 +353,7 @@ GHOST_TSuccess GHOST_GetCursorPosition(GHOST_SystemHandle systemhandle,
GHOST_TInt32 *y)
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
-
+
return system->getCursorPosition(*x, *y);
}
@@ -364,7 +364,7 @@ GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle,
GHOST_TInt32 y)
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
-
+
return system->setCursorPosition(x, y);
}
@@ -398,7 +398,7 @@ GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
GHOST_TSuccess result;
bool isdown = false;
-
+
result = system->getModifierKeyState(mask, isdown);
*isDown = (int) isdown;
@@ -414,7 +414,7 @@ GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
GHOST_TSuccess result;
bool isdown = false;
-
+
result = system->getButtonState(mask, isdown);
*isDown = (int) isdown;
@@ -441,7 +441,7 @@ void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 c
GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle)
{
GHOST_IEvent *event = (GHOST_IEvent *) eventhandle;
-
+
return event->getType();
}
@@ -466,7 +466,7 @@ GHOST_WindowHandle GHOST_GetEventWindow(GHOST_EventHandle eventhandle)
GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle)
{
GHOST_IEvent *event = (GHOST_IEvent *) eventhandle;
-
+
return event->getData();
}
@@ -475,7 +475,7 @@ GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle)
GHOST_TimerProcPtr GHOST_GetTimerProc(GHOST_TimerTaskHandle timertaskhandle)
{
GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle;
-
+
return timertask->getTimerProc();
}
@@ -485,7 +485,7 @@ void GHOST_SetTimerProc(GHOST_TimerTaskHandle timertaskhandle,
GHOST_TimerProcPtr timerproc)
{
GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle;
-
+
timertask->setTimerProc(timerproc);
}
@@ -504,13 +504,13 @@ void GHOST_SetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle,
GHOST_TUserDataPtr userdata)
{
GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle;
-
+
timertask->setUserData(userdata);
}
-int GHOST_GetValid(GHOST_WindowHandle windowhandle)
+int GHOST_GetValid(GHOST_WindowHandle windowhandle)
{
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
@@ -542,7 +542,7 @@ void GHOST_SetTitle(GHOST_WindowHandle windowhandle,
const char *title)
{
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
-
+
window->setTitle(title);
}
@@ -567,7 +567,7 @@ char *GHOST_GetTitle(GHOST_WindowHandle windowhandle)
-GHOST_RectangleHandle GHOST_GetWindowBounds(GHOST_WindowHandle windowhandle)
+GHOST_RectangleHandle GHOST_GetWindowBounds(GHOST_WindowHandle windowhandle)
{
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
GHOST_Rect *rectangle = NULL;
@@ -580,7 +580,7 @@ GHOST_RectangleHandle GHOST_GetWindowBounds(GHOST_WindowHandle windowhandle)
-GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle)
+GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle)
{
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
GHOST_Rect *rectangle = NULL;
@@ -678,16 +678,16 @@ GHOST_TSuccess GHOST_SetWindowState(GHOST_WindowHandle windowhandle,
GHOST_TSuccess GHOST_SetWindowModifiedState(GHOST_WindowHandle windowhandle, GHOST_TUns8 isUnsavedChanges)
{
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
-
+
return window->setModifiedState(isUnsavedChanges);
-}
+}
GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle,
GHOST_TWindowOrder order)
{
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
-
+
return window->setOrder(order);
}
@@ -725,7 +725,7 @@ GHOST_TUns16 GHOST_GetNumOfAASamples(GHOST_WindowHandle windowhandle)
GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
{
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
-
+
return window->activateDrawingContext();
}
diff --git a/intern/ghost/intern/GHOST_ContextGLX.cpp b/intern/ghost/intern/GHOST_ContextGLX.cpp
index 815189b9098..c94151a1a0e 100644
--- a/intern/ghost/intern/GHOST_ContextGLX.cpp
+++ b/intern/ghost/intern/GHOST_ContextGLX.cpp
@@ -110,6 +110,9 @@ GHOST_TSuccess GHOST_ContextGLX::swapBuffers()
GHOST_TSuccess GHOST_ContextGLX::activateDrawingContext()
{
+ if (m_init == false) {
+ initContext();
+ }
if (m_display) {
return ::glXMakeCurrent(m_display, m_window, m_context) ? GHOST_kSuccess : GHOST_kFailure;
}
@@ -184,7 +187,8 @@ const bool GLXEW_ARB_create_context_robustness =
glxewInit();
#endif /* USE_GLXEW_INIT_WORKAROUND */
-
+ /* Only init the non-offscreen context directly */
+ const bool do_init = (m_window != None);
if (GLXEW_ARB_create_context) {
int profileBitCore = m_contextProfileMask & GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
@@ -301,15 +305,30 @@ const bool GLXEW_ARB_create_context_robustness =
fprintf(stderr, "Warning! GLX_ARB_create_context not available.\n");
}
- GHOST_TSuccess success;
+ GHOST_TSuccess success = GHOST_kSuccess;
if (m_context != NULL) {
- const unsigned char *version;
-
if (!s_sharedContext)
s_sharedContext = m_context;
s_sharedCount++;
+ }
+
+ if (do_init) {
+ success = initContext();
+ }
+
+ GHOST_X11_ERROR_HANDLERS_RESTORE(handler_store);
+
+ return success;
+}
+
+GHOST_TSuccess GHOST_ContextGLX::initContext()
+{
+ GHOST_TSuccess success;
+
+ if (m_context != NULL) {
+ const unsigned char *version;
glXMakeCurrent(m_display, m_window, m_context);
@@ -341,13 +360,12 @@ const bool GLXEW_ARB_create_context_robustness =
success = GHOST_kFailure;
}
-
- GHOST_X11_ERROR_HANDLERS_RESTORE(handler_store);
+ /* We tag as init even if it fails. */
+ m_init = true;
return success;
}
-
GHOST_TSuccess GHOST_ContextGLX::releaseNativeHandles()
{
m_window = 0;
diff --git a/intern/ghost/intern/GHOST_ContextGLX.h b/intern/ghost/intern/GHOST_ContextGLX.h
index ded1b293659..b4d6a841d72 100644
--- a/intern/ghost/intern/GHOST_ContextGLX.h
+++ b/intern/ghost/intern/GHOST_ContextGLX.h
@@ -116,6 +116,7 @@ public:
private:
void initContextGLXEW();
+ GHOST_TSuccess initContext();
Display *m_display;
GLXFBConfig m_fbconfig;
@@ -128,6 +129,7 @@ private:
const int m_contextResetNotificationStrategy;
GLXContext m_context;
+ bool m_init;
/** The first created OpenGL context (for sharing display lists) */
static GLXContext s_sharedContext;
diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp
index 18c7844ad7b..35ebb2c78af 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextWGL.cpp
@@ -145,6 +145,10 @@ GHOST_TSuccess GHOST_ContextWGL::getSwapInterval(int &intervalOut)
GHOST_TSuccess GHOST_ContextWGL::activateDrawingContext()
{
+ if (m_init == false) {
+ initContext();
+ }
+
if (WIN32_CHK(::wglMakeCurrent(m_hDC, m_hGLRC))) {
return GHOST_kSuccess;
}
@@ -958,8 +962,32 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
goto error;
}
+ /* Only init the non-offscreen context directly */
+ if (!create_hDC) {
+ initContext();
+
+ initClearGL();
+ ::SwapBuffers(m_hDC);
+ }
+
+ return GHOST_kSuccess;
+error:
+ if (m_dummyPbuffer) {
+ if (m_hDC != NULL)
+ WIN32_CHK(::wglReleasePbufferDCARB(m_dummyPbuffer, m_hDC));
+
+ WIN32_CHK(::wglDestroyPbufferARB(m_dummyPbuffer));
+ }
+ ::wglMakeCurrent(prevHDC, prevHGLRC);
+ return GHOST_kFailure;
+
+}
+
+
+GHOST_TSuccess GHOST_ContextWGL::initContext()
+{
if (!WIN32_CHK(::wglMakeCurrent(m_hDC, m_hGLRC))) {
- goto error;
+ return GHOST_kFailure;
}
initContextGLEW();
@@ -973,8 +1001,7 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
glEnable(GL_POINT_SPRITE);
}
- initClearGL();
- ::SwapBuffers(m_hDC);
+ m_init = true;
#ifndef NDEBUG
const char *vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
@@ -989,16 +1016,6 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
#endif
return GHOST_kSuccess;
-error:
- if (m_dummyPbuffer) {
- if (m_hDC != NULL)
- WIN32_CHK(::wglReleasePbufferDCARB(m_dummyPbuffer, m_hDC));
-
- WIN32_CHK(::wglDestroyPbufferARB(m_dummyPbuffer));
- }
- ::wglMakeCurrent(prevHDC, prevHGLRC);
- return GHOST_kFailure;
-
}
diff --git a/intern/ghost/intern/GHOST_ContextWGL.h b/intern/ghost/intern/GHOST_ContextWGL.h
index 6f575db73c6..b77a50ae23e 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.h
+++ b/intern/ghost/intern/GHOST_ContextWGL.h
@@ -140,6 +140,7 @@ private:
bool needStencil,
bool sRGB,
int swapMethod);
+ GHOST_TSuccess initContext();
void initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD);
@@ -149,6 +150,7 @@ private:
HWND m_hWnd;
HDC m_hDC;
+ bool m_init;
const int m_contextProfileMask;
const int m_contextMajorVersion;
@@ -158,7 +160,7 @@ private:
const int m_contextResetNotificationStrategy;
HGLRC m_hGLRC;
-
+
#ifndef NDEBUG
const char *m_dummyVendor;
const char *m_dummyRenderer;
diff --git a/intern/ghost/intern/GHOST_Debug.h b/intern/ghost/intern/GHOST_Debug.h
index db49627b378..658c9bf5d2c 100644
--- a/intern/ghost/intern/GHOST_Debug.h
+++ b/intern/ghost/intern/GHOST_Debug.h
@@ -40,9 +40,9 @@
# endif // DEBUG
#endif // _MSC_VER
-#ifdef WITH_GHOST_DEBUG
+#ifdef WITH_GHOST_DEBUG
# define GHOST_DEBUG // spit ghost events to stdout
-#endif // WITH_GHOST_DEBUG
+#endif // WITH_GHOST_DEBUG
#ifdef GHOST_DEBUG
# include <iostream>
diff --git a/intern/ghost/intern/GHOST_DisplayManager.cpp b/intern/ghost/intern/GHOST_DisplayManager.cpp
index 9f0b32148f6..2f8240e826b 100644
--- a/intern/ghost/intern/GHOST_DisplayManager.cpp
+++ b/intern/ghost/intern/GHOST_DisplayManager.cpp
@@ -179,9 +179,9 @@ GHOST_DisplayManager::findMatch(
best = score;
}
}
-
+
match = m_settings[display][found];
-
+
GHOST_PRINT("GHOST_DisplayManager::findMatch(): settings of match:\n");
GHOST_PRINT(" setting.xPixels=" << match.xPixels << "\n");
GHOST_PRINT(" setting.yPixels=" << match.yPixels << "\n");
diff --git a/intern/ghost/intern/GHOST_DisplayManager.h b/intern/ghost/intern/GHOST_DisplayManager.h
index afdb11543e9..02a742a54db 100644
--- a/intern/ghost/intern/GHOST_DisplayManager.h
+++ b/intern/ghost/intern/GHOST_DisplayManager.h
@@ -50,7 +50,7 @@ public:
* Constructor.
*/
GHOST_DisplayManager(void);
-
+
/**
* Destructor.
*/
@@ -79,7 +79,7 @@ public:
GHOST_TInt32& numSettings) const;
/**
- * Returns the current setting for this display device.
+ * Returns the current setting for this display device.
* \param display The index of the display to query with 0 <= display < getNumDisplays().
* \param index The setting index to be returned.
* \param setting The setting of the display device with this index.
@@ -90,7 +90,7 @@ public:
GHOST_DisplaySetting& setting) const;
/**
- * Returns the current setting for this display device.
+ * Returns the current setting for this display device.
* \param display The index of the display to query with 0 <= display < getNumDisplays().
* \param setting The current setting of the display device with this index.
* \return Indication of success.
@@ -128,7 +128,7 @@ protected:
* \return Indication of success.
*/
GHOST_TSuccess initializeSettings(void);
-
+
/** Tells whether the list of display modes has been stored already. */
bool m_settingsInitialized;
/** The list with display settings for the main display. */
diff --git a/intern/ghost/intern/GHOST_DisplayManagerCocoa.h b/intern/ghost/intern/GHOST_DisplayManagerCocoa.h
index f580820d8f6..3ce0b4e2239 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerCocoa.h
+++ b/intern/ghost/intern/GHOST_DisplayManagerCocoa.h
@@ -69,7 +69,7 @@ public:
GHOST_TSuccess getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const;
/**
- * Returns the current setting for this display device.
+ * Returns the current setting for this display device.
* \param display The index of the display to query with 0 <= display < getNumDisplays().
* \param index The setting index to be returned.
* \param setting The setting of the display device with this index.
@@ -78,7 +78,7 @@ public:
GHOST_TSuccess getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const;
/**
- * Returns the current setting for this display device.
+ * Returns the current setting for this display device.
* \param display The index of the display to query with 0 <= display < getNumDisplays().
* \param setting The current setting of the display device with this index.
* \return Indication of success.
@@ -86,14 +86,14 @@ public:
GHOST_TSuccess getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const;
/**
- * Changes the current setting for this display device.
+ * Changes the current setting for this display device.
* \param display The index of the display to query with 0 <= display < getNumDisplays().
* \param setting The current setting of the display device with this index.
* \return Indication of success.
*/
GHOST_TSuccess setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting);
-protected:
+protected:
//Do not cache values as OS X supports screen hot plug
/** Cached number of displays. */
//CGDisplayCount m_numDisplays;
diff --git a/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp b/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp
index 7b9a897fe57..f5f6de330a9 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp
+++ b/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp
@@ -62,11 +62,11 @@ static BOOL get_dd(DWORD d, DISPLAY_DEVICE *dd)
}
/*
- * When you call EnumDisplaySettings with iModeNum set to zero, the operating system
- * initializes and caches information about the display device. When you call
- * EnumDisplaySettings with iModeNum set to a non-zero value, the function returns
+ * When you call EnumDisplaySettings with iModeNum set to zero, the operating system
+ * initializes and caches information about the display device. When you call
+ * EnumDisplaySettings with iModeNum set to a non-zero value, the function returns
* the information that was cached the last time the function was called with iModeNum
- * set to zero.
+ * set to zero.
*/
GHOST_TSuccess GHOST_DisplayManagerWin32::getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const
{
@@ -98,9 +98,9 @@ GHOST_TSuccess GHOST_DisplayManagerWin32::getDisplaySetting(GHOST_TUns8 display,
setting.bpp = dm.dmBitsPerPel;
/* When you call the EnumDisplaySettings function, the dmDisplayFrequency member
* may return with the value 0 or 1. These values represent the display hardware's
- * default refresh rate. This default rate is typically set by switches on a display
- * card or computer motherboard, or by a configuration program that does not use
- * Win32 display functions such as ChangeDisplaySettings.
+ * default refresh rate. This default rate is typically set by switches on a display
+ * card or computer motherboard, or by a configuration program that does not use
+ * Win32 display functions such as ChangeDisplaySettings.
*/
/* First, we tried to explicitly set the frequency to 60 if EnumDisplaySettings
* returned 0 or 1 but this doesn't work since later on an exact match will
diff --git a/intern/ghost/intern/GHOST_DisplayManagerWin32.h b/intern/ghost/intern/GHOST_DisplayManagerWin32.h
index ff8849f03c9..f0d6d62083c 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerWin32.h
+++ b/intern/ghost/intern/GHOST_DisplayManagerWin32.h
@@ -69,7 +69,7 @@ public:
GHOST_TSuccess getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const;
/**
- * Returns the current setting for this display device.
+ * Returns the current setting for this display device.
* \param display The index of the display to query with 0 <= display < getNumDisplays().
* \param index The setting index to be returned.
* \param setting The setting of the display device with this index.
@@ -78,7 +78,7 @@ public:
GHOST_TSuccess getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const;
/**
- * Returns the current setting for this display device.
+ * Returns the current setting for this display device.
* \param display The index of the display to query with 0 <= display < getNumDisplays().
* \param setting The current setting of the display device with this index.
* \return Indication of success.
@@ -86,7 +86,7 @@ public:
GHOST_TSuccess getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const;
/**
- * Changes the current setting for this display device.
+ * Changes the current setting for this display device.
* \param display The index of the display to query with 0 <= display < getNumDisplays().
* \param setting The current setting of the display device with this index.
* \return Indication of success.
diff --git a/intern/ghost/intern/GHOST_DisplayManagerX11.cpp b/intern/ghost/intern/GHOST_DisplayManagerX11.cpp
index b3e6f2e53fa..8a629b2bf18 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerX11.cpp
+++ b/intern/ghost/intern/GHOST_DisplayManagerX11.cpp
@@ -158,7 +158,7 @@ getDisplaySetting(
return GHOST_kSuccess;
}
-
+
GHOST_TSuccess
GHOST_DisplayManagerX11::
getCurrentDisplaySetting(
diff --git a/intern/ghost/intern/GHOST_DisplayManagerX11.h b/intern/ghost/intern/GHOST_DisplayManagerX11.h
index b54c53c67bd..857a8a5fce8 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerX11.h
+++ b/intern/ghost/intern/GHOST_DisplayManagerX11.h
@@ -76,7 +76,7 @@ public:
) const;
/**
- * Returns the current setting for this display device.
+ * Returns the current setting for this display device.
* \param display The index of the display to query with 0 <= display < getNumDisplays().
* \param index The setting index to be returned.
* \param setting The setting of the display device with this index.
@@ -90,7 +90,7 @@ public:
) const;
/**
- * Returns the current setting for this display device.
+ * Returns the current setting for this display device.
* \param display The index of the display to query with 0 <= display < getNumDisplays().
* \param setting The current setting of the display device with this index.
* \return Indication of success.
@@ -102,7 +102,7 @@ public:
) const;
/**
- * Changes the current setting for this display device.
+ * Changes the current setting for this display device.
* \param display The index of the display to query with 0 <= display < getNumDisplays().
* \param setting The current setting of the display device with this index.
* \return Indication of success.
@@ -119,5 +119,5 @@ private:
};
-#endif //
+#endif //
diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.cpp b/intern/ghost/intern/GHOST_DropTargetWin32.cpp
index cbf37bf1b16..79d7a2d48b4 100644
--- a/intern/ghost/intern/GHOST_DropTargetWin32.cpp
+++ b/intern/ghost/intern/GHOST_DropTargetWin32.cpp
@@ -29,7 +29,7 @@
* \ingroup GHOST
*/
-
+
#include "GHOST_Debug.h"
#include "GHOST_DropTargetWin32.h"
#include <shellapi.h>
@@ -59,7 +59,7 @@ GHOST_DropTargetWin32::~GHOST_DropTargetWin32()
}
-/*
+/*
* IUnknown::QueryInterface
*/
HRESULT __stdcall GHOST_DropTargetWin32::QueryInterface(REFIID riid, void **ppvObj)
@@ -81,8 +81,8 @@ HRESULT __stdcall GHOST_DropTargetWin32::QueryInterface(REFIID riid, void **ppvO
}
-/*
- * IUnknown::AddRef
+/*
+ * IUnknown::AddRef
*/
ULONG __stdcall GHOST_DropTargetWin32::AddRef(void)
@@ -90,13 +90,13 @@ ULONG __stdcall GHOST_DropTargetWin32::AddRef(void)
return ::InterlockedIncrement(&m_cRef);
}
-/*
+/*
* IUnknown::Release
*/
ULONG __stdcall GHOST_DropTargetWin32::Release(void)
{
ULONG refs = ::InterlockedDecrement(&m_cRef);
-
+
if (refs == 0) {
delete this;
return 0;
@@ -106,7 +106,7 @@ ULONG __stdcall GHOST_DropTargetWin32::Release(void)
}
}
-/*
+/*
* Implementation of IDropTarget::DragEnter
*/
HRESULT __stdcall GHOST_DropTargetWin32::DragEnter(IDataObject *pDataObject, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
@@ -114,13 +114,13 @@ HRESULT __stdcall GHOST_DropTargetWin32::DragEnter(IDataObject *pDataObject, DWO
// we accept all drop by default
m_window->setAcceptDragOperation(true);
*pdwEffect = DROPEFFECT_NONE;
-
+
m_draggedObjectType = getGhostType(pDataObject);
m_system->pushDragDropEvent(GHOST_kEventDraggingEntered, m_draggedObjectType, m_window, pt.x, pt.y, NULL);
return S_OK;
}
-/*
+/*
* Implementation of IDropTarget::DragOver
*/
HRESULT __stdcall GHOST_DropTargetWin32::DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
@@ -136,7 +136,7 @@ HRESULT __stdcall GHOST_DropTargetWin32::DragOver(DWORD grfKeyState, POINTL pt,
return S_OK;
}
-/*
+/*
* Implementation of IDropTarget::DragLeave
*/
HRESULT __stdcall GHOST_DropTargetWin32::DragLeave(void)
@@ -147,7 +147,7 @@ HRESULT __stdcall GHOST_DropTargetWin32::DragLeave(void)
}
/* Implementation of IDropTarget::Drop
- * This function will not be called if pdwEffect is set to DROPEFFECT_NONE in
+ * This function will not be called if pdwEffect is set to DROPEFFECT_NONE in
* the implementation of IDropTarget::DragOver
*/
HRESULT __stdcall GHOST_DropTargetWin32::Drop(IDataObject *pDataObject, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
@@ -162,15 +162,15 @@ HRESULT __stdcall GHOST_DropTargetWin32::Drop(IDataObject *pDataObject, DWORD gr
}
if (data)
m_system->pushDragDropEvent(GHOST_kEventDraggingDropDone, m_draggedObjectType, m_window, pt.x, pt.y, data);
-
+
m_draggedObjectType = GHOST_kDragnDropTypeUnknown;
return S_OK;
}
-/*
+/*
* Helpers
*/
-
+
DWORD GHOST_DropTargetWin32::allowedDropEffect(DWORD dwAllowed)
{
DWORD dwEffect = DROPEFFECT_NONE;
@@ -264,7 +264,7 @@ void *GHOST_DropTargetWin32::getDropDataAsFilenames(IDataObject *pDataObject)
// Free up memory.
::GlobalUnlock(stgmed.hGlobal);
::ReleaseStgMedium(&stgmed);
-
+
return strArray;
}
}
@@ -301,7 +301,7 @@ void *GHOST_DropTargetWin32::getDropDataAsString(IDataObject *pDataObject)
if (pDataObject->QueryGetData(&fmtetc) == S_OK) {
if (pDataObject->GetData(&fmtetc, &stgmed) == S_OK) {
char *str = (char *)::GlobalLock(stgmed.hGlobal);
-
+
tmp_string = (char *)::malloc(::strlen(str) + 1);
if (!tmp_string) {
::GlobalUnlock(stgmed.hGlobal);
@@ -320,7 +320,7 @@ void *GHOST_DropTargetWin32::getDropDataAsString(IDataObject *pDataObject)
return tmp_string;
}
}
-
+
return NULL;
}
@@ -338,7 +338,7 @@ int GHOST_DropTargetWin32::WideCharToANSI(LPCWSTR in, char * &out)
0,
NULL, NULL
);
-
+
if (!size) {
#ifdef GHOST_DEBUG
::printLastError();
diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.h b/intern/ghost/intern/GHOST_DropTargetWin32.h
index 56bae1fd1b2..3d7be45799f 100644
--- a/intern/ghost/intern/GHOST_DropTargetWin32.h
+++ b/intern/ghost/intern/GHOST_DropTargetWin32.h
@@ -41,11 +41,11 @@ class GHOST_DropTargetWin32 : public IDropTarget
{
public:
/* IUnknownd implementation.
- * Enables clients to get pointers to other interfaces on a given object
+ * Enables clients to get pointers to other interfaces on a given object
* through the QueryInterface method, and manage the existence of the object
- * through the AddRef and Release methods. All other COM interfaces are
- * inherited, directly or indirectly, from IUnknown. Therefore, the three
- * methods in IUnknown are the first entries in the VTable for every interface.
+ * through the AddRef and Release methods. All other COM interfaces are
+ * inherited, directly or indirectly, from IUnknown. Therefore, the three
+ * methods in IUnknown are the first entries in the VTable for every interface.
*/
HRESULT __stdcall QueryInterface(REFIID riid, void **ppvObj);
ULONG __stdcall AddRef(void);
@@ -56,20 +56,20 @@ public:
* provide drag-and-drop operations in your application. It contains methods
* used in any application that can be a target for data during a
* drag-and-drop operation. A drop-target application is responsible for:
- *
+ *
* - Determining the effect of the drop on the target application.
* - Incorporating any valid dropped data when the drop occurs.
* - Communicating target feedback to the source so the source application
* can provide appropriate visual feedback such as setting the cursor.
* - Implementing drag scrolling.
* - Registering and revoking its application windows as drop targets.
- *
- * The IDropTarget interface contains methods that handle all these
- * responsibilities except registering and revoking the application window
- * as a drop target, for which you must call the RegisterDragDrop and the
+ *
+ * The IDropTarget interface contains methods that handle all these
+ * responsibilities except registering and revoking the application window
+ * as a drop target, for which you must call the RegisterDragDrop and the
* RevokeDragDrop functions.
*/
-
+
HRESULT __stdcall DragEnter(IDataObject *pDataObject, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
HRESULT __stdcall DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
HRESULT __stdcall DragLeave(void);
@@ -133,7 +133,7 @@ private:
/**
* Convert Unicode to ANSI, replacing unconvertable chars with '?'.
- * The ANSI codepage is the system default codepage,
+ * The ANSI codepage is the system default codepage,
* and can change from system to system.
* \param in LPCWSTR.
* \param out char *. Is set to NULL on failure.
diff --git a/intern/ghost/intern/GHOST_Event.h b/intern/ghost/intern/GHOST_Event.h
index 6a715498b87..278870738c2 100644
--- a/intern/ghost/intern/GHOST_Event.h
+++ b/intern/ghost/intern/GHOST_Event.h
@@ -60,7 +60,7 @@ public:
* \return The event type.
*/
GHOST_TEventType getType()
- {
+ {
return m_type;
}
@@ -74,7 +74,7 @@ public:
}
/**
- * Returns the window this event was generated on,
+ * Returns the window this event was generated on,
* or NULL if it is a 'system' event.
* \return The generating window.
*/
diff --git a/intern/ghost/intern/GHOST_EventDragnDrop.h b/intern/ghost/intern/GHOST_EventDragnDrop.h
index b7bf37c99d8..c9f4f08b53c 100644
--- a/intern/ghost/intern/GHOST_EventDragnDrop.h
+++ b/intern/ghost/intern/GHOST_EventDragnDrop.h
@@ -41,9 +41,9 @@ extern "C" {
/**
* Drag & drop event
- *
+ *
* The dragging sequence is performed in four phases:
- *
+ *
* <li> Start sequence (GHOST_kEventDraggingEntered) that tells a drag'n'drop operation has started.
* Already gives the object data type, and the entering mouse location
*
@@ -93,13 +93,13 @@ public:
m_dragnDropEventData.data = data;
m_data = &m_dragnDropEventData;
}
-
+
~GHOST_EventDragnDrop()
{
//Free the dropped object data
if (m_dragnDropEventData.data == NULL)
return;
-
+
switch (m_dragnDropEventData.dataType) {
case GHOST_kDragnDropTypeBitmap:
IMB_freeImBuf((ImBuf *)m_dragnDropEventData.data);
@@ -108,10 +108,10 @@ public:
{
GHOST_TStringArray *strArray = (GHOST_TStringArray *)m_dragnDropEventData.data;
int i;
-
+
for (i = 0; i < strArray->count; i++)
free(strArray->strings[i]);
-
+
free(strArray->strings);
free(strArray);
}
@@ -124,8 +124,8 @@ public:
break;
}
}
-
-
+
+
protected:
/** The x,y-coordinates of the cursor position. */
diff --git a/intern/ghost/intern/GHOST_EventKey.h b/intern/ghost/intern/GHOST_EventKey.h
index 54e38c00d05..7e867596503 100644
--- a/intern/ghost/intern/GHOST_EventKey.h
+++ b/intern/ghost/intern/GHOST_EventKey.h
@@ -60,7 +60,7 @@ public:
m_keyEventData.utf8_buf[0] = '\0';
m_data = &m_keyEventData;
}
-
+
/**
* Constructor.
* \param msec The time this event was generated.
@@ -82,7 +82,7 @@ public:
else m_keyEventData.utf8_buf[0] = '\0';
m_data = &m_keyEventData;
}
-
+
protected:
/** The key event data. */
GHOST_TEventKeyData m_keyEventData;
diff --git a/intern/ghost/intern/GHOST_EventManager.cpp b/intern/ghost/intern/GHOST_EventManager.cpp
index 0675ac734ed..bf92fa4517b 100644
--- a/intern/ghost/intern/GHOST_EventManager.cpp
+++ b/intern/ghost/intern/GHOST_EventManager.cpp
@@ -127,7 +127,7 @@ GHOST_TSuccess GHOST_EventManager::addConsumer(GHOST_IEventConsumer *consumer)
{
GHOST_TSuccess success;
GHOST_ASSERT(consumer, "invalid consumer");
-
+
// Check to see whether the consumer is already in our list
TConsumerVector::const_iterator iter = std::find(m_consumers.begin(), m_consumers.end(), consumer);
diff --git a/intern/ghost/intern/GHOST_EventManager.h b/intern/ghost/intern/GHOST_EventManager.h
index ae2971ea1a8..efad19616ad 100644
--- a/intern/ghost/intern/GHOST_EventManager.h
+++ b/intern/ghost/intern/GHOST_EventManager.h
@@ -143,7 +143,7 @@ protected:
/** A stack with events. */
typedef std::deque<GHOST_IEvent *> TEventStack;
-
+
/** The event stack. */
std::deque<GHOST_IEvent *> m_events;
std::deque<GHOST_IEvent *> m_handled_events;
diff --git a/intern/ghost/intern/GHOST_EventNDOF.h b/intern/ghost/intern/GHOST_EventNDOF.h
index 754e1091860..b81f74becee 100644
--- a/intern/ghost/intern/GHOST_EventNDOF.h
+++ b/intern/ghost/intern/GHOST_EventNDOF.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/intern/ghost/intern/GHOST_EventPrinter.cpp b/intern/ghost/intern/GHOST_EventPrinter.cpp
index a6adba12152..221b85b80ba 100644
--- a/intern/ghost/intern/GHOST_EventPrinter.cpp
+++ b/intern/ghost/intern/GHOST_EventPrinter.cpp
@@ -41,7 +41,7 @@
bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event)
{
bool handled = true;
-
+
GHOST_ASSERT(event, "event==0");
if (event->getType() == GHOST_kEventWindowUpdate) return false;
@@ -95,7 +95,7 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event)
std::cout << "GHOST_kEventKeyDown, key: " << str;
}
break;
-
+
case GHOST_kEventDraggingEntered:
{
GHOST_TEventDragnDropData *dragnDropData = (GHOST_TEventDragnDropData *)((GHOST_IEvent *)event)->getData();
@@ -103,7 +103,7 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event)
std::cout << " mouse at x=" << dragnDropData->x << " y=" << dragnDropData->y;
}
break;
-
+
case GHOST_kEventDraggingUpdated:
{
GHOST_TEventDragnDropData *dragnDropData = (GHOST_TEventDragnDropData *)((GHOST_IEvent *)event)->getData();
@@ -118,7 +118,7 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event)
std::cout << "GHOST_kEventDraggingExited, dragged object type : " << dragnDropData->dataType;
}
break;
-
+
case GHOST_kEventDraggingDropDone:
{
GHOST_TEventDragnDropData *dragnDropData = (GHOST_TEventDragnDropData *)((GHOST_IEvent *)event)->getData();
@@ -148,14 +148,14 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event)
case GHOST_kEventOpenMainFile:
{
GHOST_TEventDataPtr eventData = ((GHOST_IEvent *)event)->getData();
-
+
if (eventData)
std::cout << "GHOST_kEventOpenMainFile for path : " << (char *)eventData;
else
std::cout << "GHOST_kEventOpenMainFile with no path specified!!";
}
break;
-
+
case GHOST_kEventQuit:
std::cout << "GHOST_kEventQuit";
break;
diff --git a/intern/ghost/intern/GHOST_ISystemPaths.cpp b/intern/ghost/intern/GHOST_ISystemPaths.cpp
index 93ca0bc3880..8bd7fbe4f9b 100644
--- a/intern/ghost/intern/GHOST_ISystemPaths.cpp
+++ b/intern/ghost/intern/GHOST_ISystemPaths.cpp
@@ -67,7 +67,7 @@ GHOST_TSuccess GHOST_ISystemPaths::create()
# else
m_systemPaths = new GHOST_SystemPathsUnix();
# endif
-#endif
+#endif
success = m_systemPaths != NULL ? GHOST_kSuccess : GHOST_kFailure;
}
else {
diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp
index cab9bf45b80..1f2af73b743 100644
--- a/intern/ghost/intern/GHOST_NDOFManager.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManager.cpp
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/intern/ghost/intern/GHOST_NDOFManager.h b/intern/ghost/intern/GHOST_NDOFManager.h
index 0c0b945d548..78f24e07a6e 100644
--- a/intern/ghost/intern/GHOST_NDOFManager.h
+++ b/intern/ghost/intern/GHOST_NDOFManager.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/intern/ghost/intern/GHOST_NDOFManagerCocoa.h b/intern/ghost/intern/GHOST_NDOFManagerCocoa.h
index 3f1bfcf57fc..6e676faba1e 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerCocoa.h
+++ b/intern/ghost/intern/GHOST_NDOFManagerCocoa.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp b/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp
index fff5aba6f9e..624d39b6347 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/intern/ghost/intern/GHOST_NDOFManagerUnix.h b/intern/ghost/intern/GHOST_NDOFManagerUnix.h
index 3fd171d9e76..8d83ac7b670 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerUnix.h
+++ b/intern/ghost/intern/GHOST_NDOFManagerUnix.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,7 +20,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
#ifndef __GHOST_NDOFMANAGERUNIX_H__
#define __GHOST_NDOFMANAGERUNIX_H__
diff --git a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp
index 0023ee7e1d0..fbdac249eb0 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp
@@ -1,11 +1,11 @@
/*
- *
+ *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/intern/ghost/intern/GHOST_NDOFManagerWin32.h b/intern/ghost/intern/GHOST_NDOFManagerWin32.h
index 2f7bc9ee732..522a79ffc0c 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerWin32.h
+++ b/intern/ghost/intern/GHOST_NDOFManagerWin32.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/intern/ghost/intern/GHOST_Rect.cpp b/intern/ghost/intern/GHOST_Rect.cpp
index 9af4f30ebc1..646dae9f242 100644
--- a/intern/ghost/intern/GHOST_Rect.cpp
+++ b/intern/ghost/intern/GHOST_Rect.cpp
@@ -108,7 +108,7 @@ void GHOST_Rect::setCenter(GHOST_TInt32 cx, GHOST_TInt32 cy)
void GHOST_Rect::setCenter(GHOST_TInt32 cx, GHOST_TInt32 cy, GHOST_TInt32 w, GHOST_TInt32 h)
{
long w_2, h_2;
-
+
w_2 = w >> 1;
h_2 = h >> 1;
m_l = cx - w_2;
diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp
index 4db2f0616d7..f849993ae6d 100644
--- a/intern/ghost/intern/GHOST_System.cpp
+++ b/intern/ghost/intern/GHOST_System.cpp
@@ -113,7 +113,7 @@ GHOST_TSuccess GHOST_System::disposeWindow(GHOST_IWindow *window)
/*
* Remove all pending events for the window.
- */
+ */
if (m_windowManager->getWindowFound(window)) {
m_eventManager->removeWindowEvents(window);
}
@@ -272,7 +272,7 @@ GHOST_TSuccess GHOST_System::pushEvent(GHOST_IEvent *event)
GHOST_TSuccess GHOST_System::getModifierKeyState(GHOST_TModifierKeyMask mask, bool& isDown) const
{
GHOST_ModifierKeys keys;
- // Get the state of all modifier keys
+ // Get the state of all modifier keys
GHOST_TSuccess success = getModifierKeys(keys);
if (success) {
// Isolate the state of the key requested
@@ -306,7 +306,7 @@ GHOST_TSuccess GHOST_System::init()
m_timerManager = new GHOST_TimerManager();
m_windowManager = new GHOST_WindowManager();
m_eventManager = new GHOST_EventManager();
-
+
#ifdef GHOST_DEBUG
if (m_eventManager) {
m_eventPrinter = new GHOST_EventPrinter();
diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index 50c893b1113..6831b3d07d9 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -91,7 +91,7 @@ public:
/**
* Installs a timer.
- * Note that, on most operating systems, messages need to be processed in order
+ * Note that, on most operating systems, messages need to be processed in order
* for the timer callbacks to be invoked.
* \param delay The time to wait for the first call to the timerProc (in milliseconds)
* \param interval The interval between calls to the timerProc
@@ -114,7 +114,7 @@ public:
/***************************************************************************************
* Display/window management functionality
***************************************************************************************/
-
+
/**
* Inherited from GHOST_ISystem but left pure virtual
*
@@ -169,7 +169,7 @@ public:
*/
bool getFullScreen(void);
-
+
/**
* Native pixel size support (MacBook 'retina').
* \return The pixel size in float.
@@ -237,7 +237,7 @@ public:
* \return Indication of success.
*/
GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const;
-
+
#ifdef WITH_INPUT_NDOF
/***************************************************************************************
* Access to 3D mouse.
@@ -305,7 +305,7 @@ public:
*
*/
virtual GHOST_TUns8 *getClipboard(bool selection) const = 0;
-
+
/**
* Put data to the Clipboard
* \param buffer The buffer to copy to the clipboard
@@ -324,7 +324,7 @@ public:
*/
virtual bool supportsNativeDialogs(void);
-
+
protected:
/**
* Initialize the system.
@@ -362,7 +362,7 @@ protected:
/** The N-degree of freedom device manager */
GHOST_NDOFManager *m_ndofManager;
#endif
-
+
/** Prints all the events. */
#ifdef GHOST_DEBUG
GHOST_EventPrinter *m_eventPrinter;
@@ -370,7 +370,7 @@ protected:
/** Settings of the display before the display went fullscreen. */
GHOST_DisplaySetting m_preFullScreenSetting;
-
+
};
inline GHOST_TimerManager *GHOST_System::getTimerManager() const
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h
index 8586c91b615..f0702737b46 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.h
+++ b/intern/ghost/intern/GHOST_SystemCocoa.h
@@ -88,7 +88,7 @@ public:
* \return The dimension of the main display.
*/
void getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const;
-
+
/** Returns the combine dimensions of all monitors.
* \return The dimension of the workspace.
*/
@@ -122,7 +122,7 @@ public:
const bool exclusive = false,
const GHOST_TEmbedderWindowID parentWindow = 0
);
-
+
/**
* Create a new offscreen context.
* Never explicitly delete the context, use disposeContext() instead.
@@ -152,19 +152,19 @@ public:
* \return Indication of the presence of events.
*/
bool processEvents(bool waitForEvent);
-
+
/**
* Handle User request to quit, from Menu bar Quit, and Cmd+Q
* Display alert panel if changes performed since last save
*/
GHOST_TUns8 handleQuitRequest();
-
+
/**
* Handle Cocoa openFile event
* Display confirmation request panel if changes performed since last save
*/
bool handleOpenDocumentRequest(void *filepathStr);
-
+
/**
* Handles a drag'n'drop destination event. Called by GHOST_WindowCocoa window subclass
* \param eventType The type of drag'n'drop event
@@ -176,7 +176,7 @@ public:
*/
GHOST_TSuccess handleDraggingEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType,
GHOST_WindowCocoa *window, int mouseX, int mouseY, void *data);
-
+
/***************************************************************************************
* Cursor management functionality
***************************************************************************************/
@@ -196,7 +196,7 @@ public:
* \return Indication of success.
*/
GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y);
-
+
/***************************************************************************************
* Access to mouse button and keyboard states.
***************************************************************************************/
@@ -221,7 +221,7 @@ public:
* \return Returns the selected buffer
*/
GHOST_TUns8 *getClipboard(bool selection) const;
-
+
/**
* Puts buffer to system clipboard
* \param buffer The buffer to be copied
@@ -236,7 +236,7 @@ public:
* \return Indication whether the event was handled.
*/
GHOST_TSuccess handleWindowEvent(GHOST_TEventType eventType, GHOST_WindowCocoa *window);
-
+
/**
* Handles the Cocoa event telling the application has become active (again)
* \return Indication whether the event was handled.
@@ -254,7 +254,7 @@ public:
int toggleConsole(int action) {
return 0;
}
-
+
/**
* Handles a tablet event.
* \param eventPtr An NSEvent pointer (casted to void* to enable compilation in standard C++)
@@ -279,7 +279,7 @@ public:
* \return Indication whether the event was handled.
*/
GHOST_TSuccess handleKeyEvent(void *eventPtr);
-
+
/**
* Informs if the system provides native dialogs (eg. confirm quit)
*/
@@ -303,19 +303,19 @@ protected:
/** Start time at initialization. */
GHOST_TUns64 m_start_time;
-
+
/** Event has been processed directly by Cocoa (or NDOF manager) and has sent a ghost event to be dispatched */
bool m_outsideLoopEventProcessed;
-
+
/** Raised window is not yet known by the window manager, so delay application become active event handling */
bool m_needDelayedApplicationBecomeActiveEventProcessing;
-
+
/** State of the modifiers. */
GHOST_TUns32 m_modifierMask;
/** Ignores window size messages (when window is dragged). */
bool m_ignoreWindowSizedMessages;
-
+
/** Temporarily ignore momentum scroll events */
bool m_ignoreMomentumScroll;
/** Is the scroll wheel event generated by a multitouch trackpad or mouse? */
diff --git a/intern/ghost/intern/GHOST_SystemPaths.h b/intern/ghost/intern/GHOST_SystemPaths.h
index 22879c71e1e..fbaa8ad8ba5 100644
--- a/intern/ghost/intern/GHOST_SystemPaths.h
+++ b/intern/ghost/intern/GHOST_SystemPaths.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/intern/ghost/intern/GHOST_SystemPathsCocoa.h b/intern/ghost/intern/GHOST_SystemPathsCocoa.h
index 1c76284857c..3a1f3e1aacf 100644
--- a/intern/ghost/intern/GHOST_SystemPathsCocoa.h
+++ b/intern/ghost/intern/GHOST_SystemPathsCocoa.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2010 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Damien Plisson 2010
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/intern/ghost/intern/GHOST_SystemPathsUnix.cpp b/intern/ghost/intern/GHOST_SystemPathsUnix.cpp
index 8738b8dd0fe..b4e1259d824 100644
--- a/intern/ghost/intern/GHOST_SystemPathsUnix.cpp
+++ b/intern/ghost/intern/GHOST_SystemPathsUnix.cpp
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2010 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/intern/ghost/intern/GHOST_SystemPathsUnix.h b/intern/ghost/intern/GHOST_SystemPathsUnix.h
index 1502160c8d6..69c37c00ce0 100644
--- a/intern/ghost/intern/GHOST_SystemPathsUnix.h
+++ b/intern/ghost/intern/GHOST_SystemPathsUnix.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2010 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -44,7 +44,7 @@ public:
* this class should only be instanciated by GHOST_ISystem.
*/
GHOST_SystemPathsUnix();
-
+
/**
* Destructor.
*/
diff --git a/intern/ghost/intern/GHOST_SystemPathsWin32.cpp b/intern/ghost/intern/GHOST_SystemPathsWin32.cpp
index 8056bc76edb..d122d3dd51f 100644
--- a/intern/ghost/intern/GHOST_SystemPathsWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemPathsWin32.cpp
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2011 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation
* Andrea Weikert
*
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index ccc90e363b7..625a34aa142 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -240,7 +240,7 @@ GHOST_TUns64 GHOST_SystemWin32::getMilliSeconds() const
__int64 delta = 1000 * (count - m_start);
GHOST_TUns64 t = (GHOST_TUns64)(delta / m_freq);
- return t;
+ return t;
}
@@ -407,7 +407,7 @@ bool GHOST_SystemWin32::processEvents(bool waitForEvent)
#else
GHOST_TUns64 next = timerMgr->nextFireTime();
GHOST_TInt64 maxSleep = next - getMilliSeconds();
-
+
if (next == GHOST_kFireTimeNever) {
::WaitMessage();
}
@@ -469,17 +469,17 @@ GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys &keys) cons
keys.set(GHOST_kModifierKeyLeftShift, down);
down = HIBYTE(::GetKeyState(VK_RSHIFT)) != 0;
keys.set(GHOST_kModifierKeyRightShift, down);
-
+
down = HIBYTE(::GetKeyState(VK_LMENU)) != 0;
keys.set(GHOST_kModifierKeyLeftAlt, down);
down = HIBYTE(::GetKeyState(VK_RMENU)) != 0;
keys.set(GHOST_kModifierKeyRightAlt, down);
-
+
down = HIBYTE(::GetKeyState(VK_LCONTROL)) != 0;
keys.set(GHOST_kModifierKeyLeftControl, down);
down = HIBYTE(::GetKeyState(VK_RCONTROL)) != 0;
keys.set(GHOST_kModifierKeyRightControl, down);
-
+
bool lwindown = HIBYTE(::GetKeyState(VK_LWIN)) != 0;
bool rwindown = HIBYTE(::GetKeyState(VK_RWIN)) != 0;
if (lwindown || rwindown)
@@ -512,7 +512,7 @@ GHOST_TSuccess GHOST_SystemWin32::getButtons(GHOST_Buttons &buttons) const
GHOST_TSuccess GHOST_SystemWin32::init()
{
GHOST_TSuccess success = GHOST_System::init();
-
+
/* Disable scaling on high DPI displays on Vista */
HMODULE
user32 = ::LoadLibraryA("user32.dll");
@@ -542,12 +542,12 @@ GHOST_TSuccess GHOST_SystemWin32::init()
wc.cbWndExtra = 0;
wc.hInstance = ::GetModuleHandle(0);
wc.hIcon = ::LoadIcon(wc.hInstance, "APPICON");
-
+
if (!wc.hIcon) {
::LoadIcon(NULL, IDI_APPLICATION);
}
wc.hCursor = ::LoadCursor(0, IDC_ARROW);
- wc.hbrBackground =
+ wc.hbrBackground =
#ifdef INW32_COMPISITING
(HBRUSH)CreateSolidBrush
#endif
@@ -560,7 +560,7 @@ GHOST_TSuccess GHOST_SystemWin32::init()
success = GHOST_kFailure;
}
}
-
+
return success;
}
@@ -583,7 +583,7 @@ GHOST_TKey GHOST_SystemWin32::hardKey(RAWINPUT const &raw, int *keyDown, char *v
*keyDown = !(raw.data.keyboard.Flags & RI_KEY_BREAK) && msg != WM_KEYUP && msg != WM_SYSKEYUP;
key = this->convertKey(raw.data.keyboard.VKey, raw.data.keyboard.MakeCode, (raw.data.keyboard.Flags & (RI_KEY_E1 | RI_KEY_E0)));
-
+
// extra handling of modifier keys: don't send repeats out from GHOST
if (key >= GHOST_kKeyLeftShift && key <= GHOST_kKeyRightAlt) {
bool changed = false;
@@ -628,7 +628,7 @@ GHOST_TKey GHOST_SystemWin32::hardKey(RAWINPUT const &raw, int *keyDown, char *v
default:
break;
}
-
+
if (changed) {
modifiers.set(modifier, (bool)*keyDown);
system->storeModifierKeys(modifiers);
@@ -637,7 +637,7 @@ GHOST_TKey GHOST_SystemWin32::hardKey(RAWINPUT const &raw, int *keyDown, char *v
key = GHOST_kKeyUnknown;
}
}
-
+
if (vk) *vk = raw.data.keyboard.VKey;
@@ -682,7 +682,7 @@ GHOST_TKey GHOST_SystemWin32::convertKey(short vKey, short scanCode, short exten
switch (vKey) {
case VK_RETURN:
key = (extend) ? GHOST_kKeyNumpadEnter : GHOST_kKeyEnter; break;
-
+
case VK_BACK: key = GHOST_kKeyBackSpace; break;
case VK_TAB: key = GHOST_kKeyTab; break;
case VK_ESCAPE: key = GHOST_kKeyEsc; break;
@@ -782,7 +782,7 @@ GHOST_TKey GHOST_SystemWin32::convertKey(short vKey, short scanCode, short exten
break;
}
}
-
+
return key;
}
@@ -799,7 +799,7 @@ GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type,
{
GHOST_TInt32 x_screen, y_screen;
GHOST_SystemWin32 *system = (GHOST_SystemWin32 *) getSystem();
-
+
system->getCursorPosition(x_screen, y_screen);
/* TODO: CHECK IF THIS IS A TABLET EVENT */
@@ -856,7 +856,7 @@ void GHOST_SystemWin32::processWheelEvent(GHOST_WindowWin32 *window, WPARAM wPar
int acc = system->m_wheelDeltaAccum;
int delta = GET_WHEEL_DELTA_WPARAM(wParam);
-
+
if (acc * delta < 0) {
// scroll direction reversed.
acc = 0;
@@ -864,7 +864,7 @@ void GHOST_SystemWin32::processWheelEvent(GHOST_WindowWin32 *window, WPARAM wPar
acc += delta;
int direction = (acc >= 0) ? 1 : -1;
acc = abs(acc);
-
+
while (acc >= WHEEL_DELTA) {
system->pushEvent(new GHOST_EventWheel(system->getMilliSeconds(), window, direction));
acc -= WHEEL_DELTA;
@@ -1178,10 +1178,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
*/
case WM_DEADCHAR:
/* The WM_DEADCHAR message is posted to the window with the keyboard focus when a
- * WM_KEYUP message is translated by the TranslateMessage function. WM_DEADCHAR
- * specifies a character code generated by a dead key. A dead key is a key that
- * generates a character, such as the umlaut (double-dot), that is combined with
- * another character to form a composite character. For example, the umlaut-O
+ * WM_KEYUP message is translated by the TranslateMessage function. WM_DEADCHAR
+ * specifies a character code generated by a dead key. A dead key is a key that
+ * generates a character, such as the umlaut (double-dot), that is combined with
+ * another character to form a composite character. For example, the umlaut-O
* character (Ö) is generated by typing the dead key for the umlaut character, and
* then typing the O key.
*/
@@ -1193,16 +1193,16 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
* a dead key that is pressed while holding down the alt key.
*/
case WM_SYSCHAR:
- /* The WM_SYSCHAR message is sent to the window with the keyboard focus when
- * a WM_SYSCHAR message is translated by the TranslateMessage function.
- * WM_SYSCHAR specifies the character code of a dead key - that is,
+ /* The WM_SYSCHAR message is sent to the window with the keyboard focus when
+ * a WM_SYSCHAR message is translated by the TranslateMessage function.
+ * WM_SYSCHAR specifies the character code of a dead key - that is,
* a dead key that is pressed while holding down the alt key.
* To prevent the sound, DefWindowProc must be avoided by return
*/
break;
case WM_SYSCOMMAND:
- /* The WM_SYSCHAR message is sent to the window when system commands such as
- * maximize, minimize or close the window are triggered. Also it is sent when ALT
+ /* The WM_SYSCHAR message is sent to the window when system commands such as
+ * maximize, minimize or close the window are triggered. Also it is sent when ALT
* button is press for menu. To prevent this we must return preventing DefWindowProc.
*/
if (wParam == SC_KEYMENU) {
@@ -1269,11 +1269,11 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
case WM_MOUSEWHEEL:
{
- /* The WM_MOUSEWHEEL message is sent to the focus window
- * when the mouse wheel is rotated. The DefWindowProc
+ /* The WM_MOUSEWHEEL message is sent to the focus window
+ * when the mouse wheel is rotated. The DefWindowProc
* function propagates the message to the window's parent.
- * There should be no internal forwarding of the message,
- * since DefWindowProc propagates it up the parent chain
+ * There should be no internal forwarding of the message,
+ * since DefWindowProc propagates it up the parent chain
* until it finds a window that processes it.
*/
@@ -1281,7 +1281,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
POINT mouse_pos = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
HWND mouse_hwnd = ChildWindowFromPoint(HWND_DESKTOP, mouse_pos);
GHOST_WindowWin32 *mouse_window = (GHOST_WindowWin32 *)::GetWindowLongPtr(mouse_hwnd, GWLP_USERDATA);
-
+
processWheelEvent(mouse_window ? mouse_window : window , wParam, lParam);
eventHandled = true;
#ifdef BROKEN_PEEK_TOUCHPAD
@@ -1293,7 +1293,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
/* The WM_SETCURSOR message is sent to a window if the mouse causes the cursor
* to move within a window and mouse input is not captured.
* This means we have to set the cursor shape every time the mouse moves!
- * The DefWindowProc function uses this message to set the cursor to an
+ * The DefWindowProc function uses this message to set the cursor to an
* arrow if it is not in the client area.
*/
if (LOWORD(lParam) == HTCLIENT) {
@@ -1301,7 +1301,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
window->loadCursor(window->getCursorVisibility(), window->getCursorShape());
// Bypass call to DefWindowProc
return 0;
- }
+ }
else {
// Outside of client area show standard cursor
window->loadCursor(true, GHOST_kStandardCursorDefault);
@@ -1317,10 +1317,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
* that contains the cursor. If a window has captured the mouse, this message is not posted.
*/
case WM_NCHITTEST:
- /* The WM_NCHITTEST message is sent to a window when the cursor moves, or
- * when a mouse button is pressed or released. If the mouse is not captured,
- * the message is sent to the window beneath the cursor. Otherwise, the message
- * is sent to the window that has captured the mouse.
+ /* The WM_NCHITTEST message is sent to a window when the cursor moves, or
+ * when a mouse button is pressed or released. If the mouse is not captured,
+ * the message is sent to the window beneath the cursor. Otherwise, the message
+ * is sent to the window that has captured the mouse.
*/
break;
@@ -1332,11 +1332,11 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
event = processWindowEvent(GHOST_kEventWindowClose, window);
break;
case WM_ACTIVATE:
- /* The WM_ACTIVATE message is sent to both the window being activated and the window being
- * deactivated. If the windows use the same input queue, the message is sent synchronously,
+ /* The WM_ACTIVATE message is sent to both the window being activated and the window being
+ * deactivated. If the windows use the same input queue, the message is sent synchronously,
* first to the window procedure of the top-level window being deactivated, then to the window
* procedure of the top-level window being activated. If the windows use different input queues,
- * the message is sent asynchronously, so the window is activated immediately.
+ * the message is sent asynchronously, so the window is activated immediately.
*/
{
GHOST_ModifierKeys modifiers;
@@ -1353,12 +1353,12 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
}
case WM_ENTERSIZEMOVE:
- /* The WM_ENTERSIZEMOVE message is sent one time to a window after it enters the moving
- * or sizing modal loop. The window enters the moving or sizing modal loop when the user
- * clicks the window's title bar or sizing border, or when the window passes the
- * WM_SYSCOMMAND message to the DefWindowProc function and the wParam parameter of the
- * message specifies the SC_MOVE or SC_SIZE value. The operation is complete when
- * DefWindowProc returns.
+ /* The WM_ENTERSIZEMOVE message is sent one time to a window after it enters the moving
+ * or sizing modal loop. The window enters the moving or sizing modal loop when the user
+ * clicks the window's title bar or sizing border, or when the window passes the
+ * WM_SYSCOMMAND message to the DefWindowProc function and the wParam parameter of the
+ * message specifies the SC_MOVE or SC_SIZE value. The operation is complete when
+ * DefWindowProc returns.
*/
window->m_inLiveResize = 1;
break;
@@ -1366,11 +1366,11 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
window->m_inLiveResize = 0;
break;
case WM_PAINT:
- /* An application sends the WM_PAINT message when the system or another application
+ /* An application sends the WM_PAINT message when the system or another application
* makes a request to paint a portion of an application's window. The message is sent
- * when the UpdateWindow or RedrawWindow function is called, or by the DispatchMessage
- * function when the application obtains a WM_PAINT message by using the GetMessage or
- * PeekMessage function.
+ * when the UpdateWindow or RedrawWindow function is called, or by the DispatchMessage
+ * function when the application obtains a WM_PAINT message by using the GetMessage or
+ * PeekMessage function.
*/
if (!window->m_inLiveResize) {
event = processWindowEvent(GHOST_kEventWindowUpdate, window);
@@ -1381,10 +1381,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
}
break;
case WM_GETMINMAXINFO:
- /* The WM_GETMINMAXINFO message is sent to a window when the size or
- * position of the window is about to change. An application can use
- * this message to override the window's default maximized size and
- * position, or its default minimum or maximum tracking size.
+ /* The WM_GETMINMAXINFO message is sent to a window when the size or
+ * position of the window is about to change. An application can use
+ * this message to override the window's default maximized size and
+ * position, or its default minimum or maximum tracking size.
*/
processMinMaxInfo((MINMAXINFO *) lParam);
/* Let DefWindowProc handle it. */
@@ -1392,9 +1392,9 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
case WM_SIZING:
case WM_SIZE:
/* The WM_SIZE message is sent to a window after its size has changed.
- * The WM_SIZE and WM_MOVE messages are not sent if an application handles the
+ * The WM_SIZE and WM_MOVE messages are not sent if an application handles the
* WM_WINDOWPOSCHANGED message without calling DefWindowProc. It is more efficient
- * to perform any move or size change processing during the WM_WINDOWPOSCHANGED
+ * to perform any move or size change processing during the WM_WINDOWPOSCHANGED
* message without calling DefWindowProc.
*/
/* we get first WM_SIZE before we fully init. So, do not dispatch before we continiously resizng */
@@ -1415,10 +1415,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
* and, if needed, change its size or position.
*/
case WM_MOVE:
- /* The WM_SIZE and WM_MOVE messages are not sent if an application handles the
+ /* The WM_SIZE and WM_MOVE messages are not sent if an application handles the
* WM_WINDOWPOSCHANGED message without calling DefWindowProc. It is more efficient
- * to perform any move or size change processing during the WM_WINDOWPOSCHANGED
- * message without calling DefWindowProc.
+ * to perform any move or size change processing during the WM_WINDOWPOSCHANGED
+ * message without calling DefWindowProc.
*/
/* see WM_SIZE comment*/
if (window->m_inLiveResize) {
@@ -1487,13 +1487,13 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
* that all child windows still exist.
*/
case WM_NCDESTROY:
- /* The WM_NCDESTROY message informs a window that its nonclient area is being destroyed. The
+ /* The WM_NCDESTROY message informs a window that its nonclient area is being destroyed. The
* DestroyWindow function sends the WM_NCDESTROY message to the window following the WM_DESTROY
- * message. WM_DESTROY is used to free the allocated memory object associated with the window.
+ * message. WM_DESTROY is used to free the allocated memory object associated with the window.
*/
break;
case WM_KILLFOCUS:
- /* The WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard focus.
+ /* The WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard focus.
* We want to prevent this if a window is still active and it loses focus to nowhere*/
if (!wParam && hwnd == ::GetActiveWindow())
::SetFocus(hwnd);
@@ -1526,7 +1526,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
* when a timer expires. You can process the message by providing a WM_TIMER
* case in the window procedure. Otherwise, the default window procedure will
* call the TimerProc callback function specified in the call to the SetTimer
- * function used to install the timer.
+ * function used to install the timer.
*
* In GHOST, we let DefWindowProc call the timer callback.
*/
@@ -1565,7 +1565,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
GHOST_TUns8 *GHOST_SystemWin32::getClipboard(bool selection) const
{
char *temp_buff;
-
+
if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL) ) {
wchar_t *buffer;
HANDLE hData = GetClipboardData(CF_UNICODETEXT);
@@ -1578,14 +1578,14 @@ GHOST_TUns8 *GHOST_SystemWin32::getClipboard(bool selection) const
CloseClipboard();
return NULL;
}
-
+
temp_buff = alloc_utf_8_from_16(buffer, 0);
-
+
/* Buffer mustn't be accessed after CloseClipboard
* it would like accessing free-d memory */
GlobalUnlock(hData);
CloseClipboard();
-
+
return (GHOST_TUns8 *)temp_buff;
}
else if (IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(NULL) ) {
@@ -1601,17 +1601,17 @@ GHOST_TUns8 *GHOST_SystemWin32::getClipboard(bool selection) const
CloseClipboard();
return NULL;
}
-
+
len = strlen(buffer);
temp_buff = (char *) malloc(len + 1);
strncpy(temp_buff, buffer, len);
temp_buff[len] = '\0';
-
+
/* Buffer mustn't be accessed after CloseClipboard
* it would like accessing free-d memory */
GlobalUnlock(hData);
CloseClipboard();
-
+
return (GHOST_TUns8 *)temp_buff;
}
else {
@@ -1626,11 +1626,11 @@ void GHOST_SystemWin32::putClipboard(GHOST_TInt8 *buffer, bool selection) const
if (OpenClipboard(NULL)) {
HLOCAL clipbuffer;
wchar_t *data;
-
+
if (buffer) {
size_t len = count_utf_16_from_8(buffer);
EmptyClipboard();
-
+
clipbuffer = LocalAlloc(LMEM_FIXED, sizeof(wchar_t) * len);
data = (wchar_t *)GlobalLock(clipbuffer);
@@ -1686,7 +1686,7 @@ static bool getProcessName(int pid, char *buffer, int max_len)
static bool isStartedFromCommandPrompt()
{
HWND hwnd = GetConsoleWindow();
-
+
if (hwnd) {
DWORD pid = (DWORD)-1;
DWORD ppid = GetParentProcessID();
diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h
index 0f15f9180ae..e1fd82ec239 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.h
+++ b/intern/ghost/intern/GHOST_SystemWin32.h
@@ -110,7 +110,7 @@ public:
/**
* Create a new window.
- * The new window is added to the list of windows managed.
+ * The new window is added to the list of windows managed.
* Never explicitly delete the window, use disposeWindow() instead.
* \param title The name of the window (displayed in the title bar of the window if the OS supports it).
* \param left The coordinate of the left edge of the window.
@@ -157,7 +157,7 @@ public:
* \return Indication of the presence of events.
*/
bool processEvents(bool waitForEvent);
-
+
/***************************************************************************************
** Cursor management functionality
@@ -203,7 +203,7 @@ public:
* \return Returns the Clipboard
*/
GHOST_TUns8 *getClipboard(bool selection) const;
-
+
/**
* Puts buffer to system clipboard
* \param selection Used by X11 only
@@ -212,7 +212,7 @@ public:
void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
/**
- * Creates a drag'n'drop event and pushes it immediately onto the event queue.
+ * Creates a drag'n'drop event and pushes it immediately onto the event queue.
* Called by GHOST_DropTargetWin32 class.
* \param eventType The type of drag'n'drop event
* \param draggedObjectType The type object concerned (currently array of file names, string, ?bitmap)
@@ -222,7 +222,7 @@ public:
* \return Indication whether the event was handled.
*/
static GHOST_TSuccess pushDragDropEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType, GHOST_WindowWin32 *window, int mouseX, int mouseY, void *data);
-
+
/**
* Confirms quitting he program when there is just one window left open
* in the application
@@ -242,7 +242,7 @@ protected:
* \return A success value.
*/
GHOST_TSuccess exit();
-
+
/**
* Converts raw WIN32 key codes from the wndproc to GHOST keys.
* \param vKey The virtual key from hardKey
@@ -303,7 +303,7 @@ protected:
*/
GHOST_TKey processSpecialKey(short vKey, short scanCode) const;
- /**
+ /**
* Creates a window event.
* \param type The type of event to create.
* \param window The window receiving the event (the active window).
@@ -351,7 +351,7 @@ protected:
* param keys The new state of the modifier keys.
*/
inline void storeModifierKeys(const GHOST_ModifierKeys& keys);
-
+
/**
* Check current key layout for AltGr
*/
@@ -373,7 +373,7 @@ protected:
* \return current status (1 -visible, 0 - hidden)
*/
int toggleConsole(int action);
-
+
/** The current state of the modifier keys. */
GHOST_ModifierKeys m_modifierKeys;
/** State variable set at initialization. */
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 69aa3a09977..1efbee0e6aa 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -101,7 +101,12 @@
* See T47228 and D1746 */
#define USE_NON_LATIN_KB_WORKAROUND
-static GHOST_TKey convertXKey(KeySym key);
+static GHOST_TKey ghost_key_from_keysym(
+ const KeySym key);
+static GHOST_TKey ghost_key_from_keycode(
+ const XkbDescPtr xkb_descr, const KeyCode keycode);
+static GHOST_TKey ghost_key_from_keysym_or_keycode(
+ const KeySym key, const XkbDescPtr xkb_descr, const KeyCode keycode);
/* these are for copy and select copy */
static char *txt_cut_buffer = NULL;
@@ -117,11 +122,11 @@ GHOST_SystemX11::
GHOST_SystemX11(
)
: GHOST_System(),
+ m_xkb_descr(NULL),
m_start_time(0)
{
- XInitThreads();
m_display = XOpenDisplay(NULL);
-
+
if (!m_display) {
std::cerr << "Unable to open a display" << std::endl;
abort(); /* was return before, but this would just mean it will crash later */
@@ -179,19 +184,24 @@ GHOST_SystemX11(
if (gettimeofday(&tv, NULL) == -1) {
GHOST_ASSERT(false, "Could not instantiate timer!");
}
-
+
/* Taking care not to overflow the tv.tv_sec * 1000 */
m_start_time = GHOST_TUns64(tv.tv_sec) * 1000 + tv.tv_usec / 1000;
-
-
+
+
/* use detectable autorepeate, mac and windows also do this */
int use_xkb;
int xkb_opcode, xkb_event, xkb_error;
int xkb_major = XkbMajorVersion, xkb_minor = XkbMinorVersion;
-
+
use_xkb = XkbQueryExtension(m_display, &xkb_opcode, &xkb_event, &xkb_error, &xkb_major, &xkb_minor);
if (use_xkb) {
XkbSetDetectableAutoRepeat(m_display, true, NULL);
+
+ m_xkb_descr = XkbGetMap(m_display, 0, XkbUseCoreKbd);
+ if (m_xkb_descr) {
+ XkbGetNames(m_display, XkbKeyNamesMask, m_xkb_descr);
+ }
}
#ifdef WITH_XWAYLAND_HACK
@@ -244,11 +254,15 @@ GHOST_SystemX11::
/* close tablet devices */
if (m_xtablet.StylusDevice)
XCloseDevice(m_display, m_xtablet.StylusDevice);
-
+
if (m_xtablet.EraserDevice)
XCloseDevice(m_display, m_xtablet.EraserDevice);
#endif /* WITH_X11_XINPUT */
+ if (m_xkb_descr) {
+ XkbFreeNames(m_xkb_descr, XkbKeyNamesMask, false);
+ }
+
XCloseDisplay(m_display);
}
@@ -285,7 +299,7 @@ getMilliSeconds() const
/* Taking care not to overflow the tv.tv_sec * 1000 */
return GHOST_TUns64(tv.tv_sec) * 1000 + tv.tv_usec / 1000 - m_start_time;
}
-
+
GHOST_TUns8
GHOST_SystemX11::
getNumDisplays() const
@@ -358,9 +372,9 @@ createWindow(const STR_String& title,
const GHOST_TEmbedderWindowID parentWindow)
{
GHOST_WindowX11 *window = NULL;
-
+
if (!m_display) return 0;
-
+
window = new GHOST_WindowX11(this, m_display, title,
left, top, width, height,
state, parentWindow, type,
@@ -386,7 +400,7 @@ createWindow(const STR_String& title,
return window;
}
-bool GHOST_SystemX11::supportsNativeDialogs(void)
+bool GHOST_SystemX11::supportsNativeDialogs(void)
{
return false;
}
@@ -516,7 +530,7 @@ GHOST_SystemX11::
findGhostWindow(
Window xwind) const
{
-
+
if (xwind == 0) return NULL;
/* It is not entirely safe to do this as the backptr may point
@@ -528,7 +542,7 @@ findGhostWindow(
vector<GHOST_IWindow *>::iterator win_it = win_vec.begin();
vector<GHOST_IWindow *>::const_iterator win_end = win_vec.end();
-
+
for (; win_it != win_end; ++win_it) {
GHOST_WindowX11 *window = static_cast<GHOST_WindowX11 *>(*win_it);
if (window->getXWindow() == xwind) {
@@ -536,14 +550,14 @@ findGhostWindow(
}
}
return NULL;
-
+
}
static void SleepTillEvent(Display *display, GHOST_TInt64 maxSleep)
{
int fd = ConnectionNumber(display);
fd_set fds;
-
+
FD_ZERO(&fds);
FD_SET(fd, &fds);
@@ -555,7 +569,7 @@ static void SleepTillEvent(Display *display, GHOST_TInt64 maxSleep)
tv.tv_sec = maxSleep / 1000;
tv.tv_usec = (maxSleep - tv.tv_sec * 1000) * 1000;
-
+
select(fd + 1, &fds, NULL, NULL, &tv);
}
}
@@ -618,15 +632,15 @@ processEvents(
{
/* Get all the current events -- translate them into
* ghost events and call base class pushEvent() method. */
-
+
bool anyProcessed = false;
-
+
do {
GHOST_TimerManager *timerMgr = getTimerManager();
-
+
if (waitForEvent && m_dirty_windows.empty() && !XPending(m_display)) {
GHOST_TUns64 next = timerMgr->nextFireTime();
-
+
if (next == GHOST_kFireTimeNever) {
SleepTillEvent(m_display, -1);
}
@@ -637,11 +651,11 @@ processEvents(
SleepTillEvent(m_display, next - getMilliSeconds());
}
}
-
+
if (timerMgr->fireTimers(getMilliSeconds())) {
anyProcessed = true;
}
-
+
while (XPending(m_display)) {
XEvent xevent;
XNextEvent(m_display, &xevent);
@@ -669,10 +683,8 @@ processEvents(
}
/* dispatch event to XIM server */
- if ((XFilterEvent(&xevent, (Window)NULL) == True) && (xevent.type != KeyRelease)) {
- /* do nothing now, the event is consumed by XIM.
- * however, KeyRelease event should be processed
- * here, otherwise modifiers remain activated. */
+ if ((XFilterEvent(&xevent, (Window)NULL) == True)) {
+ /* do nothing now, the event is consumed by XIM. */
continue;
}
#endif
@@ -726,7 +738,7 @@ processEvents(
getMilliSeconds(),
GHOST_kEventKeyDown,
window,
- convertXKey(modifiers[i]),
+ ghost_key_from_keysym(modifiers[i]),
'\0',
NULL));
}
@@ -738,7 +750,7 @@ processEvents(
#endif /* USE_UNITY_WORKAROUND */
}
-
+
if (generateWindowExposeEvents()) {
anyProcessed = true;
}
@@ -748,9 +760,9 @@ processEvents(
anyProcessed = true;
}
#endif
-
+
} while (waitForEvent && !anyProcessed);
-
+
return anyProcessed;
}
@@ -956,7 +968,6 @@ GHOST_SystemX11::processEvent(XEvent *xe)
{
XKeyEvent *xke = &(xe->xkey);
KeySym key_sym;
- KeySym key_sym_str;
char ascii;
#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
/* utf8_array[] is initial buffer used for Xutf8LookupString().
@@ -971,7 +982,7 @@ GHOST_SystemX11::processEvent(XEvent *xe)
#else
char *utf8_buf = NULL;
#endif
-
+
GHOST_TEventType type = (xke->type == KeyPress) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp;
GHOST_TKey gkey;
@@ -983,7 +994,7 @@ GHOST_SystemX11::processEvent(XEvent *xe)
* is unmodified (or anyone swapping the keys with xmodmap).
*
* - XLookupKeysym seems to always use first defined keymap (see T47228), which generates
- * keycodes unusable by convertXKey for non-latin-compatible keymaps.
+ * keycodes unusable by ghost_key_from_keysym for non-latin-compatible keymaps.
*
* To address this, we:
*
@@ -1001,6 +1012,7 @@ GHOST_SystemX11::processEvent(XEvent *xe)
*
* [1] http://cgit.freedesktop.org/xorg/lib/libX11/tree/src/KeyBind.c
*/
+ KeySym key_sym_str;
/* Mode_switch 'modifier' is AltGr - when this one or Shift are enabled, we do not want to apply
* that 'forced number' hack. */
const unsigned int mode_switch_mask = XkbKeysymToModifiers(xke->display, XK_Mode_switch);
@@ -1021,7 +1033,7 @@ GHOST_SystemX11::processEvent(XEvent *xe)
/* Only allow a limited set of keys from XLookupKeysym, all others we take from XLookupString,
* unless it gives unknown key... */
- gkey = convertXKey(key_sym);
+ gkey = ghost_key_from_keysym_or_keycode(key_sym, m_xkb_descr, xke->keycode);
switch (gkey) {
case GHOST_kKeyRightAlt:
case GHOST_kKeyLeftAlt:
@@ -1058,10 +1070,12 @@ GHOST_SystemX11::processEvent(XEvent *xe)
case GHOST_kKeyNumpadSlash:
break;
default:
- GHOST_TKey gkey_str = convertXKey(key_sym_str);
+ {
+ GHOST_TKey gkey_str = ghost_key_from_keysym(key_sym_str);
if (gkey_str != GHOST_kKeyUnknown) {
gkey = gkey_str;
}
+ }
}
#else
/* In keyboards like latin ones,
@@ -1083,8 +1097,8 @@ GHOST_SystemX11::processEvent(XEvent *xe)
key_sym = XLookupKeysym(xke, 0);
}
- gkey = convertXKey(key_sym);
-
+ gkey = ghost_key_from_keysym_or_keycode(key_sym, m_xkb_descr, xke->keycode);
+
if (!XLookupString(xke, &ascii, 1, NULL, NULL)) {
ascii = '\0';
}
@@ -1178,7 +1192,7 @@ GHOST_SystemX11::processEvent(XEvent *xe)
if (utf8_buf != utf8_array)
free(utf8_buf);
#endif
-
+
break;
}
@@ -1187,7 +1201,7 @@ GHOST_SystemX11::processEvent(XEvent *xe)
{
XButtonEvent & xbe = xe->xbutton;
GHOST_TButtonMask gbmask = GHOST_kButtonMaskLeft;
- GHOST_TEventType type = (xbe.type == ButtonPress) ?
+ GHOST_TEventType type = (xbe.type == ButtonPress) ?
GHOST_kEventButtonDown : GHOST_kEventButtonUp;
/* process wheel mouse events and break, only pass on press events */
@@ -1201,7 +1215,7 @@ GHOST_SystemX11::processEvent(XEvent *xe)
g_event = new GHOST_EventWheel(getMilliSeconds(), window, -1);
break;
}
-
+
/* process rest of normal mouse buttons */
if (xbe.button == Button1)
gbmask = GHOST_kButtonMaskLeft;
@@ -1233,13 +1247,13 @@ GHOST_SystemX11::processEvent(XEvent *xe)
);
break;
}
-
+
/* change of size, border, layer etc. */
case ConfigureNotify:
{
/* XConfigureEvent & xce = xe->xconfigure; */
- g_event = new
+ g_event = new
GHOST_Event(
getMilliSeconds(),
GHOST_kEventWindowSize,
@@ -1255,10 +1269,10 @@ GHOST_SystemX11::processEvent(XEvent *xe)
/* TODO: make sure this is the correct place for activate/deactivate */
// printf("X: focus %s for window %d\n", xfe.type == FocusIn ? "in" : "out", (int) xfe.window);
-
+
/* May have to look at the type of event and filter some out. */
- GHOST_TEventType gtype = (xfe.type == FocusIn) ?
+ GHOST_TEventType gtype = (xfe.type == FocusIn) ?
GHOST_kEventWindowActivate : GHOST_kEventWindowDeactivate;
#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
@@ -1271,7 +1285,7 @@ GHOST_SystemX11::processEvent(XEvent *xe)
}
#endif
- g_event = new
+ g_event = new
GHOST_Event(
getMilliSeconds(),
gtype,
@@ -1285,7 +1299,7 @@ GHOST_SystemX11::processEvent(XEvent *xe)
XClientMessageEvent & xcme = xe->xclient;
if (((Atom)xcme.data.l[0]) == m_atom.WM_DELETE_WINDOW) {
- g_event = new
+ g_event = new
GHOST_Event(
getMilliSeconds(),
GHOST_kEventWindowClose,
@@ -1329,14 +1343,14 @@ GHOST_SystemX11::processEvent(XEvent *xe)
break;
}
-
+
case DestroyNotify:
::exit(-1);
/* We're not interested in the following things.(yet...) */
case NoExpose:
case GraphicsExpose:
break;
-
+
case EnterNotify:
case LeaveNotify:
{
@@ -1349,7 +1363,7 @@ GHOST_SystemX11::processEvent(XEvent *xe)
*/
XCrossingEvent &xce = xe->xcrossing;
if (xce.mode == NotifyNormal) {
- g_event = new
+ g_event = new
GHOST_EventCursor(
getMilliSeconds(),
GHOST_kEventCursorMove,
@@ -1397,18 +1411,18 @@ GHOST_SystemX11::processEvent(XEvent *xe)
XEvent nxe;
Atom target, utf8_string, string, compound_text, c_string;
XSelectionRequestEvent *xse = &xe->xselectionrequest;
-
+
target = XInternAtom(m_display, "TARGETS", False);
utf8_string = XInternAtom(m_display, "UTF8_STRING", False);
string = XInternAtom(m_display, "STRING", False);
compound_text = XInternAtom(m_display, "COMPOUND_TEXT", False);
c_string = XInternAtom(m_display, "C_STRING", False);
-
+
/* support obsolete clients */
if (xse->property == None) {
xse->property = xse->target;
}
-
+
nxe.xselection.type = SelectionNotify;
nxe.xselection.requestor = xse->requestor;
nxe.xselection.property = xse->property;
@@ -1416,7 +1430,7 @@ GHOST_SystemX11::processEvent(XEvent *xe)
nxe.xselection.selection = xse->selection;
nxe.xselection.target = xse->target;
nxe.xselection.time = xse->time;
-
+
/* Check to see if the requestor is asking for String */
if (xse->target == utf8_string ||
xse->target == string ||
@@ -1447,13 +1461,13 @@ GHOST_SystemX11::processEvent(XEvent *xe)
/* Change property to None because we do not support anything but STRING */
nxe.xselection.property = None;
}
-
+
/* Send the event to the client 0 0 == False, SelectionNotify */
XSendEvent(m_display, xse->requestor, 0, 0, &nxe);
XFlush(m_display);
break;
}
-
+
default:
{
#ifdef WITH_X11_XINPUT
@@ -1584,7 +1598,7 @@ getButtons(
}
else {
return GHOST_kFailure;
- }
+ }
return GHOST_kSuccess;
}
@@ -1688,7 +1702,7 @@ setCursorPosition(
#endif
XSync(m_display, 0); /* Sync to process all requests */
-
+
return GHOST_kSuccess;
}
@@ -1699,7 +1713,7 @@ addDirtyWindow(
GHOST_WindowX11 *bad_wind)
{
GHOST_ASSERT((bad_wind != NULL), "addDirtyWindow() NULL ptr trapped (window)");
-
+
m_dirty_windows.push_back(bad_wind);
}
@@ -1711,7 +1725,7 @@ generateWindowExposeEvents()
vector<GHOST_WindowX11 *>::iterator w_start = m_dirty_windows.begin();
vector<GHOST_WindowX11 *>::const_iterator w_end = m_dirty_windows.end();
bool anyProcessed = false;
-
+
for (; w_start != w_end; ++w_start) {
GHOST_Event *g_event = new
GHOST_Event(
@@ -1721,7 +1735,7 @@ generateWindowExposeEvents()
);
(*w_start)->validate();
-
+
if (g_event) {
pushEvent(g_event);
anyProcessed = true;
@@ -1732,10 +1746,22 @@ generateWindowExposeEvents()
return anyProcessed;
}
+static GHOST_TKey
+ghost_key_from_keysym_or_keycode(const KeySym keysym, XkbDescPtr xkb_descr, const KeyCode keycode)
+{
+ GHOST_TKey type = ghost_key_from_keysym(keysym);
+ if (type == GHOST_kKeyUnknown) {
+ if (xkb_descr) {
+ type = ghost_key_from_keycode(xkb_descr, keycode);
+ }
+ }
+ return type;
+}
+
#define GXMAP(k, x, y) case x: k = y; break
static GHOST_TKey
-convertXKey(KeySym key)
+ghost_key_from_keysym(const KeySym key)
{
GHOST_TKey type;
@@ -1844,6 +1870,9 @@ convertXKey(KeySym key)
#endif
#endif
default:
+#ifdef GHOST_DEBUG
+ printf("%s: unknown key: %lu / 0x%lx\n", __func__, key, key);
+#endif
type = GHOST_kKeyUnknown;
break;
}
@@ -1854,6 +1883,33 @@ convertXKey(KeySym key)
#undef GXMAP
+#define MAKE_ID(a, b, c, d) ((int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a))
+
+static GHOST_TKey
+ghost_key_from_keycode(const XkbDescPtr xkb_descr, const KeyCode keycode)
+{
+ GHOST_ASSERT(XkbKeyNameLength == 4, "Name length is invalid!");
+ if (keycode >= xkb_descr->min_key_code && keycode <= xkb_descr->max_key_code) {
+ const char *id_str = xkb_descr->names->keys[keycode].name;
+ const uint32_t id = MAKE_ID(id_str[0], id_str[1], id_str[2], id_str[3]);
+ switch (id) {
+ case MAKE_ID('T', 'L', 'D', 'E'):
+ return GHOST_kKeyAccentGrave;
+#ifdef GHOST_DEBUG
+ default:
+ printf("%s unhandled keycode: %.*s\n", __func__, XkbKeyNameLength, id_str);
+ break;
+#endif
+ }
+ }
+ else {
+ GHOST_ASSERT(false, "KeyCode out of range!");
+ }
+ return GHOST_kKeyUnknown;
+}
+
+#undef MAKE_ID
+
/* from xclip.c xcout() v0.11 */
#define XCLIB_XCOUT_NONE 0 /* no context */
@@ -2110,12 +2166,12 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const
unsigned char *tmp_data = (unsigned char *) malloc(sel_len + 1);
memcpy((char *)tmp_data, (char *)sel_buf, sel_len);
tmp_data[sel_len] = '\0';
-
+
if (sseln == m_atom.STRING)
XFree(sel_buf);
else
free(sel_buf);
-
+
return tmp_data;
}
return(NULL);
@@ -2156,7 +2212,7 @@ void GHOST_SystemX11::putClipboard(GHOST_TInt8 *buffer, bool selection) const
}
#ifdef WITH_XDND
-GHOST_TSuccess GHOST_SystemX11::pushDragDropEvent(GHOST_TEventType eventType,
+GHOST_TSuccess GHOST_SystemX11::pushDragDropEvent(GHOST_TEventType eventType,
GHOST_TDragnDropTypes draggedObjectType,
GHOST_IWindow *window,
int mouseX, int mouseY,
@@ -2322,7 +2378,7 @@ void GHOST_SystemX11::refreshXInputDevices()
for (int i = 0; i < device_count; ++i) {
char *device_type = device_info[i].type ? XGetAtomName(m_display, device_info[i].type) : NULL;
-
+
// printf("Tablet type:'%s', name:'%s', index:%d\n", device_type, device_info[i].name, i);
@@ -2355,7 +2411,7 @@ void GHOST_SystemX11::refreshXInputDevices()
break;
}
-
+
ici = (XAnyClassPtr)(((char *)ici) + ici->length);
}
}
diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h
index b910589a1ad..d318b894d87 100644
--- a/intern/ghost/intern/GHOST_SystemX11.h
+++ b/intern/ghost/intern/GHOST_SystemX11.h
@@ -34,6 +34,7 @@
#define __GHOST_SYSTEMX11_H__
#include <X11/Xlib.h>
+#include <X11/XKBlib.h> /* allow detectable autorepeate */
#include "GHOST_System.h"
#include "../GHOST_Types.h"
@@ -86,7 +87,7 @@ public:
GHOST_SystemX11(
);
-
+
/**
* Destructor.
*/
@@ -114,7 +115,7 @@ public:
GHOST_TUns64
getMilliSeconds(
) const;
-
+
/**
* Returns the number of displays on this system.
@@ -146,7 +147,7 @@ public:
/**
* Create a new window.
- * The new window is added to the list of windows managed.
+ * The new window is added to the list of windows managed.
* Never explicitly delete the window, use disposeWindow() instead.
* \param title The name of the window (displayed in the title bar of the window if the OS supports it).
* \param left The coordinate of the left edge of the window.
@@ -210,7 +211,7 @@ public:
GHOST_TInt32& x,
GHOST_TInt32& y
) const;
-
+
GHOST_TSuccess
setCursorPosition(
GHOST_TInt32 x,
@@ -239,15 +240,15 @@ public:
/**
* Flag a window as dirty. This will
- * generate a GHOST window update event on a call to processEvents()
+ * generate a GHOST window update event on a call to processEvents()
*/
void
addDirtyWindow(
GHOST_WindowX11 *bad_wind
);
-
-
+
+
/**
* return a pointer to the X11 display structure
*/
@@ -256,7 +257,7 @@ public:
getXDisplay(
) {
return m_display;
- }
+ }
#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
XIM
@@ -277,7 +278,7 @@ public:
* \return Returns the Clipboard indicated by Flag
*/
GHOST_TUns8 *getClipboard(bool selection) const;
-
+
/**
* Puts buffer to system clipboard
* \param buffer The buffer to copy to the clipboard
@@ -287,14 +288,14 @@ public:
#ifdef WITH_XDND
/**
- * Creates a drag'n'drop event and pushes it immediately onto the event queue.
+ * Creates a drag'n'drop event and pushes it immediately onto the event queue.
* Called by GHOST_DropTargetX11 class.
* \param eventType The type of drag'n'drop event
* \param draggedObjectType The type object concerned (currently array of file names, string, ?bitmap)
* \param mouseX x mouse coordinate (in window coordinates)
* \param mouseY y mouse coordinate
* \param window The window on which the event occurred
- * \return Indication whether the event was handled.
+ * \return Indication whether the event was handled.
*/
static GHOST_TSuccess pushDragDropEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType, GHOST_IWindow *window, int mouseX, int mouseY, void *data);
#endif
@@ -373,6 +374,10 @@ public:
private:
Display *m_display;
+
+ /* Use for scancode lookups. */
+ XkbDescRec *m_xkb_descr;
+
#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
XIM m_xim;
#endif
diff --git a/intern/ghost/intern/GHOST_TaskbarWin32.h b/intern/ghost/intern/GHOST_TaskbarWin32.h
index 0ef71754717..f65207af706 100644
--- a/intern/ghost/intern/GHOST_TaskbarWin32.h
+++ b/intern/ghost/intern/GHOST_TaskbarWin32.h
@@ -87,7 +87,7 @@ typedef enum TBPFLAG {
TBPF_PAUSED = 0x8,
} TBPFLAG;
-#define THBN_CLICKED 0x1800
+#define THBN_CLICKED 0x1800
extern "C" {
const GUID IID_ITaskList3 = {0xEA1AFB91, 0x9E28, 0x4B86, {0x90, 0xE9, 0x9E, 0x9F, 0x8A, 0x5E, 0xEF, 0xAF}};
diff --git a/intern/ghost/intern/GHOST_TaskbarX11.cpp b/intern/ghost/intern/GHOST_TaskbarX11.cpp
index b47068df39f..2ef82dc6636 100644
--- a/intern/ghost/intern/GHOST_TaskbarX11.cpp
+++ b/intern/ghost/intern/GHOST_TaskbarX11.cpp
@@ -127,4 +127,4 @@ void GHOST_TaskBarX11::set_progress_enabled(bool enabled)
assert(is_valid());
unity_set_progress_visible(handle, enabled ? 1 : 0);
unity_event_loop(NULL, 0);
-} \ No newline at end of file
+}
diff --git a/intern/ghost/intern/GHOST_TimerManager.cpp b/intern/ghost/intern/GHOST_TimerManager.cpp
index f6ec9d3febe..1918fc26151 100644
--- a/intern/ghost/intern/GHOST_TimerManager.cpp
+++ b/intern/ghost/intern/GHOST_TimerManager.cpp
@@ -102,14 +102,14 @@ GHOST_TUns64 GHOST_TimerManager::nextFireTime()
{
GHOST_TUns64 smallest = GHOST_kFireTimeNever;
TTimerVector::iterator iter;
-
+
for (iter = m_timers.begin(); iter != m_timers.end(); ++iter) {
GHOST_TUns64 next = (*iter)->getNext();
-
+
if (next < smallest)
smallest = next;
}
-
+
return smallest;
}
diff --git a/intern/ghost/intern/GHOST_TimerManager.h b/intern/ghost/intern/GHOST_TimerManager.h
index 6cf4bcf40eb..78026a743eb 100644
--- a/intern/ghost/intern/GHOST_TimerManager.h
+++ b/intern/ghost/intern/GHOST_TimerManager.h
@@ -90,11 +90,11 @@ public:
/**
* Finds the soonest time the next timer would fire.
- * \return The soonest time the next timer would fire,
+ * \return The soonest time the next timer would fire,
* or GHOST_kFireTimeNever if no timers exist.
*/
GHOST_TUns64 nextFireTime();
-
+
/**
* Checks all timer tasks to see if they are expired and fires them if needed.
* \param time The current time.
diff --git a/intern/ghost/intern/GHOST_TimerTask.h b/intern/ghost/intern/GHOST_TimerTask.h
index 45aa66e4630..fa35fd134f5 100644
--- a/intern/ghost/intern/GHOST_TimerTask.h
+++ b/intern/ghost/intern/GHOST_TimerTask.h
@@ -78,7 +78,7 @@ public:
* \param start The timer start time.
*/
void setStart(GHOST_TUns64 start)
- {
+ {
m_start = start;
}
@@ -96,7 +96,7 @@ public:
* \param interval The timer interval.
*/
void setInterval(GHOST_TUns64 interval)
- {
+ {
m_interval = interval;
}
@@ -114,7 +114,7 @@ public:
* \param next The time the timerProc will be called.
*/
void setNext(GHOST_TUns64 next)
- {
+ {
m_next = next;
}
@@ -144,7 +144,7 @@ public:
{
return m_userData;
}
-
+
/**
* Changes the time user data.
* \param userData: The timer user data.
@@ -168,7 +168,7 @@ public:
* \param auxData The auxiliary storage room.
*/
void setAuxData(GHOST_TUns32 auxData)
- {
+ {
m_auxData = auxData;
}
diff --git a/intern/ghost/intern/GHOST_Window.cpp b/intern/ghost/intern/GHOST_Window.cpp
index 71fa260f0f2..6596028d5a1 100644
--- a/intern/ghost/intern/GHOST_Window.cpp
+++ b/intern/ghost/intern/GHOST_Window.cpp
@@ -58,12 +58,12 @@ GHOST_Window::GHOST_Window(
{
m_isUnsavedChanges = false;
m_canAcceptDragOperation = false;
-
+
m_progressBarVisible = false;
-
+
m_cursorGrabAccumPos[0] = 0;
m_cursorGrabAccumPos[1] = 0;
-
+
m_nativePixelSize = 1.0f;
m_fullScreen = state == GHOST_kWindowStateFullScreen;
@@ -208,7 +208,7 @@ GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHO
16, 16, hotX, hotY, 0, 1);
}
-GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
+GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
int sizex, int sizey, int hotX, int hotY,
int fg_color, int bg_color)
{
@@ -234,7 +234,7 @@ bool GHOST_Window::canAcceptDragOperation() const
GHOST_TSuccess GHOST_Window::setModifiedState(bool isUnsavedChanges)
{
m_isUnsavedChanges = isUnsavedChanges;
-
+
return GHOST_kSuccess;
}
diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h
index 2798bdf72f3..413a3315225 100644
--- a/intern/ghost/intern/GHOST_Window.h
+++ b/intern/ghost/intern/GHOST_Window.h
@@ -40,7 +40,7 @@ class GHOST_Context;
/**
* Platform independent implementation of GHOST_IWindow.
- * Dimensions are given in screen coordinates that are relative to the
+ * Dimensions are given in screen coordinates that are relative to the
* upper-left corner of the screen.
* Implements part of the GHOST_IWindow interface and adds some methods to
* be implemented by childs of this class.
@@ -94,7 +94,7 @@ public:
* virtual GHOST_TSuccess activateDrawingContext() = 0;
* virtual GHOST_TSuccess invalidate() = 0;
*/
-
+
/**
* Destructor.
* Closes the window and disposes resources allocated.
@@ -105,7 +105,7 @@ public:
* Returns indication as to whether the window is valid.
* \return The validity of the window.
*/
- virtual bool getValid() const {
+ virtual bool getValid() const {
return m_context != NULL;
}
@@ -114,7 +114,7 @@ public:
* \return The associated OS object/handle
*/
virtual void *getOSWindow() const;
-
+
/**
* Returns the current cursor shape.
* \return The current cursor shape.
@@ -185,14 +185,14 @@ public:
virtual GHOST_TSuccess setProgressBar(float /*progress*/) {
return GHOST_kFailure;
}
-
+
/**
* Hides the progress bar in the icon
*/
virtual GHOST_TSuccess endProgressBar() {
return GHOST_kFailure;
}
-
+
/**
* Sets the swap interval for swapBuffers.
* \param interval The swap interval to use.
@@ -216,26 +216,26 @@ public:
* Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
*/
void setAcceptDragOperation(bool canAccept);
-
+
/**
* Returns acceptance of the dropped object
* Usually called by the "object dropped" event handling function
*/
bool canAcceptDragOperation() const;
-
+
/**
* Sets the window "modified" status, indicating unsaved changes
* \param isUnsavedChanges Unsaved changes or not
* \return Indication of success.
*/
virtual GHOST_TSuccess setModifiedState(bool isUnsavedChanges);
-
+
/**
* Gets the window "modified" status, indicating unsaved changes
* \return True if there are unsaved changes
*/
virtual bool getModifiedState();
-
+
/**
* Returns the type of drawing context used in this window.
* \return The current type of drawing context.
@@ -278,7 +278,7 @@ public:
{
return m_userData;
}
-
+
/**
* Changes the window user data.
* \param userData: The window user data.
@@ -287,7 +287,7 @@ public:
{
m_userData = userData;
}
-
+
float getNativePixelSize(void)
{
if (m_nativePixelSize > 0.0f)
@@ -341,7 +341,7 @@ protected:
virtual GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode /*mode*/) {
return GHOST_kSuccess;
}
-
+
/**
* Sets the cursor shape on the window using
* native window system calls.
@@ -355,15 +355,15 @@ protected:
virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
GHOST_TUns8 mask[16][2],
int hotX, int hotY) = 0;
-
- virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
+
+ virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
int szx, int szy, int hotX, int hotY, int fg, int bg) = 0;
GHOST_TSuccess releaseNativeHandles();
/** The drawing context installed in this window. */
GHOST_TDrawingContextType m_drawingContextType;
-
+
/** The window user data */
GHOST_TUserDataPtr m_userData;
@@ -384,16 +384,16 @@ protected:
/** The current shape of the cursor */
GHOST_TStandardCursor m_cursorShape;
-
+
/** The presence of progress indicator with the application icon */
bool m_progressBarVisible;
-
+
/** The acceptance of the "drop candidate" of the current drag'n'drop operation */
bool m_canAcceptDragOperation;
-
+
/** Modified state : are there unsaved changes */
bool m_isUnsavedChanges;
-
+
/** Stores whether this is a full screen window. */
bool m_fullScreen;
@@ -407,7 +407,7 @@ protected:
GHOST_TUns32 m_fullScreenWidth;
/** Full-screen height */
GHOST_TUns32 m_fullScreenHeight;
-
+
/* OSX only, retina screens */
float m_nativePixelSize;
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.h b/intern/ghost/intern/GHOST_WindowCocoa.h
index 9dbc85d91e2..54ecd2b44c8 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.h
+++ b/intern/ghost/intern/GHOST_WindowCocoa.h
@@ -89,7 +89,7 @@ public:
* \return The validity of the window.
*/
bool getValid() const;
-
+
/**
* Returns the associated NSWindow object
* \return The associated NSWindow object
@@ -110,11 +110,11 @@ public:
/**
* Returns the window rectangle dimensions.
- * The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
+ * The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
* \param bounds The bounding rectangle of the window.
*/
void getWindowBounds(GHOST_Rect& bounds) const;
-
+
/**
* Returns the client rectangle dimensions.
* The left and top members of the rectangle are always zero.
@@ -153,7 +153,7 @@ public:
* \return Indication of success.
*/
GHOST_TSuccess setModifiedState(bool isUnsavedChanges);
-
+
/**
* Converts a point in screen coordinates to client rectangle coordinates
* \param inX The x-coordinate on the screen.
@@ -197,7 +197,7 @@ public:
* \return The NSScreen object
*/
NSScreen *getScreen();
-
+
/**
* Sets the state of the window (normal, minimized, maximized).
* \param state The state of the window.
@@ -213,7 +213,7 @@ public:
GHOST_TSuccess setOrder(GHOST_TWindowOrder order);
void loadCursor(bool visible, GHOST_TStandardCursor cursor) const;
-
+
const GHOST_TabletData *GetTabletData()
{
return &m_tablet;
@@ -223,32 +223,32 @@ public:
{
return m_tablet;
}
-
+
/**
* Sets the progress bar value displayed in the window/application icon
* \param progress The progress % (0.0 to 1.0)
*/
GHOST_TSuccess setProgressBar(float progress);
-
+
/**
* Hides the progress bar icon
*/
GHOST_TSuccess endProgressBar();
-
-
+
+
void setNativePixelSize(void);
GHOST_TSuccess beginFullScreen() const {return GHOST_kFailure;}
GHOST_TSuccess endFullScreen() const {return GHOST_kFailure;}
-
+
/** public function to get the window containing the OpenGL view */
CocoaWindow *getCocoaWindow() const {return m_window;};
/* Internal value to ensure proper redraws during animations */
void setImmediateDraw(bool value) { m_immediateDraw = value; }
bool getImmediateDraw(void) const { return m_immediateDraw; }
-
+
protected:
/**
@@ -268,13 +268,13 @@ protected:
* native window system calls.
*/
GHOST_TSuccess setWindowCursorVisibility(bool visible);
-
+
/**
* Sets the cursor grab on the window using
* native window system calls.
*/
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode);
-
+
/**
* Sets the cursor shape on the window using
* native window system calls.
@@ -287,14 +287,14 @@ protected:
*/
GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color);
-
+
GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY);
/** The window containing the OpenGL view */
CocoaWindow *m_window;
-
+
/** The openGL view */
- CocoaOpenGLView *m_openGLView;
+ CocoaOpenGLView *m_openGLView;
/** The mother SystemCocoa class to send events */
GHOST_SystemCocoa *m_systemCocoa;
diff --git a/intern/ghost/intern/GHOST_WindowManager.cpp b/intern/ghost/intern/GHOST_WindowManager.cpp
index 790c73deca5..31e1b0401f1 100644
--- a/intern/ghost/intern/GHOST_WindowManager.cpp
+++ b/intern/ghost/intern/GHOST_WindowManager.cpp
@@ -42,7 +42,7 @@
#include "GHOST_Window.h"
-GHOST_WindowManager::GHOST_WindowManager() :
+GHOST_WindowManager::GHOST_WindowManager() :
m_fullScreenWindow(0),
m_activeWindow(0),
m_activeWindowBeforeFullScreen(0)
@@ -61,7 +61,7 @@ GHOST_TSuccess GHOST_WindowManager::addWindow(GHOST_IWindow *window)
GHOST_TSuccess success = GHOST_kFailure;
if (window) {
if (!getWindowFound(window)) {
- // Store the pointer to the window
+ // Store the pointer to the window
m_windows.push_back(window);
success = GHOST_kSuccess;
}
@@ -170,7 +170,7 @@ GHOST_TSuccess GHOST_WindowManager::setActiveWindow(GHOST_IWindow *window)
}
return success;
}
-
+
GHOST_IWindow *GHOST_WindowManager::getActiveWindow(void) const
{
@@ -200,7 +200,7 @@ GHOST_IWindow *GHOST_WindowManager::getWindowAssociatedWithOSWindow(void *osWind
if ((*iter)->getOSWindow() == osWindow)
return *iter;
}
-
+
return NULL;
}
@@ -208,7 +208,7 @@ bool GHOST_WindowManager::getAnyModifiedState()
{
bool isAnyModified = false;
std::vector<GHOST_IWindow *>::iterator iter;
-
+
for (iter = m_windows.begin(); iter != m_windows.end(); ++iter) {
if ((*iter)->getModifiedState())
isAnyModified = true;
diff --git a/intern/ghost/intern/GHOST_WindowManager.h b/intern/ghost/intern/GHOST_WindowManager.h
index e868a9b0416..a7dde2af39c 100644
--- a/intern/ghost/intern/GHOST_WindowManager.h
+++ b/intern/ghost/intern/GHOST_WindowManager.h
@@ -110,38 +110,38 @@ public:
* \param window The new active window.
*/
GHOST_TSuccess setActiveWindow(GHOST_IWindow *window);
-
+
/**
* Returns the active window (the window receiving events).
* There can be only one window active which should be in the current window list.
* \return window The active window (or NULL if there is none).
*/
GHOST_IWindow *getActiveWindow(void) const;
-
+
/**
* Set this window to be inactive (not receiving events).
* \param window The window to deactivate.
*/
void setWindowInactive(const GHOST_IWindow *window);
-
+
/**
- * Return a vector of the windows currently managed by this
- * class.
+ * Return a vector of the windows currently managed by this
+ * class.
* \warning It is very dangerous to mess with the contents of
- * this vector. Please do not destroy or add windows use the
+ * this vector. Please do not destroy or add windows use the
* interface above for this,
*/
std::vector<GHOST_IWindow *> & getWindows();
-
+
/**
* Finds the window associated with an OS window object/handle
* \param osWindow The OS window object/handle
* \return The associated window, null if none corresponds
*/
GHOST_IWindow *getWindowAssociatedWithOSWindow(void *osWindow);
-
+
/**
* Return true if any windows has a modified status
* \return True if any window has unsaved changes
@@ -164,7 +164,7 @@ protected:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_WindowManager")
#endif
-
+
};
#endif // __GHOST_WINDOWMANAGER_H__
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index 3c9c7c415bb..676a29f28d4 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -99,7 +99,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
if (state != GHOST_kWindowStateFullScreen) {
RECT rect;
MONITORINFO monitor;
- GHOST_TUns32 tw, th;
+ GHOST_TUns32 tw, th;
#ifndef _MSC_VER
int cxsizeframe = GetSystemMetrics(SM_CXSIZEFRAME);
@@ -158,7 +158,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
width = rect.right - rect.left;
height = rect.bottom - rect.top;
}
-
+
wchar_t *title_16 = alloc_utf16_from_8((char *)(const char *)title, 0);
m_hWnd = ::CreateWindowW(
s_windowClassName, // pointer to registered class name
@@ -225,7 +225,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
::ShowWindow(m_hWnd, nCmdShow);
#ifdef WIN32_COMPOSITING
if (alphaBackground && parentwindowhwnd == 0) {
-
+
HRESULT hr = S_OK;
// Create and populate the Blur Behind structure
@@ -817,7 +817,7 @@ GHOST_TSuccess GHOST_WindowWin32::setWindowCursorGrab(GHOST_TGrabCursorMode mode
m_cursorGrabBounds.m_l = m_cursorGrabBounds.m_r = -1; /* disable */
registerMouseClickEvent(3);
}
-
+
return GHOST_kSuccess;
}
@@ -1041,7 +1041,7 @@ GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(
GHOST_TSuccess GHOST_WindowWin32::setProgressBar(float progress)
-{
+{
/*SetProgressValue sets state to TBPF_NORMAL automaticly*/
if (m_Bar && S_OK == m_Bar->SetProgressValue(m_hWnd, 10000 * progress, 10000))
return GHOST_kSuccess;
diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h
index 75a33951ff4..d998e86c9b1 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.h
+++ b/intern/ghost/intern/GHOST_WindowWin32.h
@@ -132,11 +132,11 @@ public:
/**
* Returns the window rectangle dimensions.
- * The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
+ * The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
* \param bounds The bounding rectangle of the window.
*/
void getWindowBounds(GHOST_Rect& bounds) const;
-
+
/**
* Returns the client rectangle dimensions.
* The left and top members of the rectangle are always zero.
@@ -211,19 +211,19 @@ public:
* \param progress The progress %
*/
GHOST_TSuccess setProgressBar(float progress);
-
+
/**
* Hides the progress bar in the icon
*/
GHOST_TSuccess endProgressBar();
-
+
/**
- * Register a mouse click event (should be called
+ * Register a mouse click event (should be called
* for any real button press, controls mouse
* capturing).
*
- * \param press
+ * \param press
* 0 - mouse pressed
* 1 - mouse released
* 2 - operator grab
@@ -286,14 +286,14 @@ private:
* native window system calls.
*/
GHOST_TSuccess setWindowCursorVisibility(bool visible);
-
+
/**
* Sets the cursor grab on the window using native window system calls.
* Using registerMouseClickEvent.
* \param mode GHOST_TGrabCursorMode.
*/
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode);
-
+
/**
* Sets the cursor shape on the window using
* native window system calls.
@@ -318,7 +318,7 @@ private:
int fg_color,
int bg_color
);
-
+
/** Pointer to system */
GHOST_SystemWin32 *m_system;
/** Pointer to COM IDropTarget implementor */
@@ -330,7 +330,7 @@ private:
/** Flag for if window has captured the mouse */
bool m_hasMouseCaptured;
- /** Flag if an operator grabs the mouse with WM_cursor_grab_enable/ungrab()
+ /** Flag if an operator grabs the mouse with WM_cursor_grab_enable/ungrab()
* Multiple grabs must be released with a single ungrab */
bool m_hasGrabMouse;
/** Count of number of pressed buttons */
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 3c291bd5ec6..ade4799a52d 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -204,7 +204,7 @@ static XVisualInfo *x11_visualinfo_from_glx(
numOfAASamples = 0;
actualSamples = 0;
}
-
+
#ifdef WITH_X11_ALPHA
if ( needAlpha
&& glx_version >= 103
@@ -276,7 +276,7 @@ static XVisualInfo *x11_visualinfo_from_glx(
/* legacy, don't use extension */
for (;;) {
GHOST_X11_GL_GetAttributes(glx_attribs, 64, actualSamples, stereoVisual, needAlpha, false);
-
+
visual = glXChooseVisual(display, DefaultScreen(display), glx_attribs);
/* Any sample level or even zero, which means oversampling disabled, is good
@@ -408,7 +408,7 @@ GHOST_WindowX11(GHOST_SystemX11 *system,
Window root_return;
int x_return, y_return;
unsigned int w_return, h_return, border_w_return, depth_return;
-
+
XGetGeometry(m_display, parentWindow, &root_return, &x_return, &y_return,
&w_return, &h_return, &border_w_return, &depth_return);
@@ -430,8 +430,8 @@ GHOST_WindowX11(GHOST_SystemX11 *system,
&xattributes);
XSelectInput(m_display, parentWindow, SubstructureNotifyMask);
-
- }
+
+ }
#ifdef WITH_XDND
/* initialize drop target for newly created window */
@@ -717,12 +717,12 @@ getTitle(
STR_String& title) const
{
char *name = NULL;
-
+
XFetchName(m_display, m_window, &name);
title = name ? name : "untitled";
XFree(name);
}
-
+
void
GHOST_WindowX11::
getWindowBounds(
@@ -742,12 +742,12 @@ getClientBounds(
int x_return, y_return;
unsigned int w_return, h_return, border_w_return, depth_return;
GHOST_TInt32 screen_x, screen_y;
-
+
XGetGeometry(m_display, m_window, &root_return, &x_return, &y_return,
&w_return, &h_return, &border_w_return, &depth_return);
clientToScreen(0, 0, screen_x, screen_y);
-
+
bounds.m_l = screen_x;
bounds.m_r = bounds.m_l + w_return;
bounds.m_t = screen_y;
@@ -794,7 +794,7 @@ setClientSize(
XConfigureWindow(m_display, m_window, value_mask, &values);
return GHOST_kSuccess;
-}
+}
void
GHOST_WindowX11::
@@ -818,7 +818,7 @@ screenToClient(
outX = ax;
outY = ay;
}
-
+
void
GHOST_WindowX11::
clientToScreen(
@@ -1159,7 +1159,7 @@ setOrder(
GHOST_TWindowOrder order)
{
if (order == GHOST_kWindowOrderTop) {
- XWindowAttributes attr;
+ XWindowAttributes attr;
Atom atom;
/* We use both XRaiseWindow and _NET_ACTIVE_WINDOW, since some
@@ -1209,7 +1209,7 @@ setOrder(
else {
return GHOST_kFailure;
}
-
+
return GHOST_kSuccess;
}
@@ -1233,8 +1233,8 @@ invalidate()
if (m_invalid_window == false) {
m_system->addDirtyWindow(this);
m_invalid_window = true;
- }
-
+ }
+
return GHOST_kSuccess;
}
@@ -1242,15 +1242,15 @@ invalidate()
* called by the X11 system implementation when expose events
* for the window have been pushed onto the GHOST queue
*/
-
+
void
GHOST_WindowX11::
validate()
{
m_invalid_window = false;
-}
-
-
+}
+
+
/**
* Destructor.
* Closes the window and disposes resources allocated.
@@ -1289,7 +1289,7 @@ GHOST_WindowX11::
XSetSelectionOwner(m_display, Clipboard_atom, None, CurrentTime);
}
}
-
+
if (m_visualInfo) {
XFree(m_visualInfo);
}
@@ -1425,13 +1425,13 @@ getStandardCursor(
if (xcursor_id) {
Cursor xcursor = m_standard_cursors[xcursor_id];
-
+
if (!xcursor) {
xcursor = XCreateFontCursor(m_display, xcursor_id);
m_standard_cursors[xcursor_id] = xcursor;
}
-
+
return xcursor;
}
else {
@@ -1447,7 +1447,7 @@ getEmptyCursor(
Pixmap blank;
XColor dummy = {0};
char data[1] = {0};
-
+
/* make a blank cursor */
blank = XCreateBitmapFromData(
m_display,
@@ -1468,7 +1468,7 @@ setWindowCursorVisibility(
bool visible)
{
Cursor xcursor;
-
+
if (visible) {
if (m_visible_cursor)
xcursor = m_visible_cursor;
@@ -1481,7 +1481,7 @@ setWindowCursorVisibility(
XDefineCursor(m_display, m_window, xcursor);
XFlush(m_display);
-
+
return GHOST_kSuccess;
}
@@ -1544,7 +1544,7 @@ setWindowCursorGrab(
}
XFlush(m_display);
-
+
return GHOST_kSuccess;
}
@@ -1556,7 +1556,7 @@ setWindowCursorShape(
Cursor xcursor = getStandardCursor(shape);
m_visible_cursor = xcursor;
-
+
XDefineCursor(m_display, m_window, xcursor);
XFlush(m_display);
@@ -1578,7 +1578,7 @@ setWindowCustomCursorShape(
GHOST_TSuccess
GHOST_WindowX11::
-setWindowCustomCursorShape(
+setWindowCustomCursorShape(
GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask,
int sizex,
@@ -1591,7 +1591,7 @@ setWindowCustomCursorShape(
Colormap colormap = DefaultColormap(m_display, m_visualInfo->screen);
Pixmap bitmap_pix, mask_pix;
XColor fg, bg;
-
+
if (XAllocNamedColor(m_display, colormap, "White", &fg, &fg) == 0) return GHOST_kFailure;
if (XAllocNamedColor(m_display, colormap, "Black", &bg, &bg) == 0) return GHOST_kFailure;
@@ -1601,13 +1601,13 @@ setWindowCustomCursorShape(
bitmap_pix = XCreateBitmapFromData(m_display, m_window, (char *) bitmap, sizex, sizey);
mask_pix = XCreateBitmapFromData(m_display, m_window, (char *) mask, sizex, sizey);
-
+
m_custom_cursor = XCreatePixmapCursor(m_display, bitmap_pix, mask_pix, &fg, &bg, hotX, hotY);
XDefineCursor(m_display, m_window, m_custom_cursor);
XFlush(m_display);
m_visible_cursor = m_custom_cursor;
-
+
XFreePixmap(m_display, bitmap_pix);
XFreePixmap(m_display, mask_pix);
diff --git a/intern/ghost/intern/GHOST_WindowX11.h b/intern/ghost/intern/GHOST_WindowX11.h
index 236fe0b76b0..bf2497ee6d6 100644
--- a/intern/ghost/intern/GHOST_WindowX11.h
+++ b/intern/ghost/intern/GHOST_WindowX11.h
@@ -54,7 +54,7 @@ class GHOST_DropTargetX11;
/**
* X11 implementation of GHOST_IWindow.
- * Dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
+ * Dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
* \author Laurence Bourn
* \date October 26, 2001
*/
@@ -112,7 +112,7 @@ public:
getWindowBounds(
GHOST_Rect& bounds
) const;
-
+
void
getClientBounds(
GHOST_Rect& bounds
@@ -149,7 +149,7 @@ public:
GHOST_TInt32& outX,
GHOST_TInt32& outY
) const;
-
+
GHOST_TWindowState
getState(
) const;
@@ -158,12 +158,12 @@ public:
setState(
GHOST_TWindowState state
);
-
+
GHOST_TSuccess
setOrder(
GHOST_TWindowOrder order
);
-
+
GHOST_TSuccess
invalidate(
);
@@ -191,7 +191,7 @@ public:
validate(
);
- /**
+ /**
* Return a handle to the x11 window type.
*/
Window
@@ -257,7 +257,7 @@ protected:
setWindowCursorVisibility(
bool visible
);
-
+
/**
* Sets the cursor grab on the window using
* native window system calls.
@@ -290,7 +290,7 @@ protected:
int hotX,
int hotY
);
-
+
/**
* Sets the cursor shape on the window using
* native window system calls (Arbitrary size/color).
@@ -310,7 +310,7 @@ protected:
private:
/// Force use of public constructor.
-
+
GHOST_WindowX11(
);
@@ -322,11 +322,11 @@ private:
getStandardCursor(
GHOST_TStandardCursor g_cursor
);
-
+
Cursor
getEmptyCursor(
);
-
+
Window m_window;
Display *m_display;
XVisualInfo *m_visualInfo;
@@ -342,13 +342,13 @@ private:
/** XCursor structure of an empty (blank) cursor */
Cursor m_empty_cursor;
-
+
/** XCursor structure of the custom cursor */
Cursor m_custom_cursor;
/** XCursor to show when cursor is visible */
Cursor m_visible_cursor;
-
+
/** Cache of XC_* ID's to XCursor structures */
std::map<unsigned int, Cursor> m_standard_cursors;
diff --git a/intern/ghost/test/CMakeLists.txt b/intern/ghost/test/CMakeLists.txt
index 0cec217630c..9f714ae4fba 100644
--- a/intern/ghost/test/CMakeLists.txt
+++ b/intern/ghost/test/CMakeLists.txt
@@ -103,7 +103,7 @@ suffix_relpaths(SRC_NEW "${SRC}" "../../guardedalloc/")
include_directories(${INC_NEW})
add_library(guardedalloc_lib ${SRC_NEW})
-# blenfont
+# blenfont
include(${CMAKE_SOURCE_DIR}/../../../source/blender/blenfont/CMakeLists.txt)
suffix_relpaths(INC_NEW "${INC}" "../../../source/blender/blenfont/")
suffix_relpaths(SRC_NEW "${SRC}" "../../../source/blender/blenfont/")
@@ -128,7 +128,7 @@ add_library(glewmx_lib ${SRC_NEW})
include_directories(
"../../../source/blender/blenlib"
)
-add_library(bli_lib
+add_library(bli_lib
"../../../source/blender/blenlib/intern/fileops.c"
"../../../source/blender/blenlib/intern/gsqueue.c"
"../../../source/blender/blenlib/intern/rct.c"
diff --git a/intern/ghost/test/gears/GHOST_C-Test.c b/intern/ghost/test/gears/GHOST_C-Test.c
index c635ab9be5b..abaa6258122 100644
--- a/intern/ghost/test/gears/GHOST_C-Test.c
+++ b/intern/ghost/test/gears/GHOST_C-Test.c
@@ -84,16 +84,16 @@ static void gearGL(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GL
GLfloat angle, da;
GLfloat u, v, len;
const double pi = 3.14159264;
-
+
r0 = inner_radius;
r1 = (float)(outer_radius - tooth_depth / 2.0);
r2 = (float)(outer_radius + tooth_depth / 2.0);
-
+
da = (float)(2.0 * pi / teeth / 4.0);
-
+
glShadeModel(GL_FLAT);
glNormal3f(0.0, 0.0, 1.0);
-
+
/* draw front face */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++) {
@@ -104,7 +104,7 @@ static void gearGL(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GL
glVertex3f((float)(r1 * cos(angle + 3 * da)), (float)(r1 * sin(angle + 3 * da)), (float)(width * 0.5));
}
glEnd();
-
+
/* draw front sides of teeth */
glBegin(GL_QUADS);
da = (float)(2.0 * pi / teeth / 4.0);
@@ -116,9 +116,9 @@ static void gearGL(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GL
glVertex3f((float)(r1 * cos(angle + 3 * da)), (float)(r1 * sin(angle + 3 * da)), (float)(width * 0.5));
}
glEnd();
-
+
glNormal3f(0.0, 0.0, -1.0);
-
+
/* draw back face */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++) {
@@ -129,7 +129,7 @@ static void gearGL(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GL
glVertex3f((float)(r0 * cos(angle)), (float)(r0 * sin(angle)), (float)(-width * 0.5));
}
glEnd();
-
+
/* draw back sides of teeth */
glBegin(GL_QUADS);
da = (float)(2.0 * pi / teeth / 4.0);
@@ -141,7 +141,7 @@ static void gearGL(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GL
glVertex3f((float)(r1 * cos(angle)), (float)(r1 * sin(angle)), (float)(-width * 0.5));
}
glEnd();
-
+
/* draw outward faces of teeth */
glBegin(GL_QUAD_STRIP);
for (i = 0; i < teeth; i++) {
@@ -169,9 +169,9 @@ static void gearGL(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GL
glVertex3f((float)(r1 * cos(0.0)), (float)(r1 * sin(0.0)), (float)(width * 0.5));
glVertex3f((float)(r1 * cos(0.0)), (float)(r1 * sin(0.0)), (float)(-width * 0.5));
glEnd();
-
+
glShadeModel(GL_SMOOTH);
-
+
/* draw inside radius cylinder */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++) {
@@ -191,13 +191,13 @@ static void drawGearGL(int id)
static GLfloat ared[4] = { 0.8f, 0.1f, 0.0f, 1.0f };
static GLfloat agreen[4] = { 0.0f, 0.8f, 0.2f, 1.0f };
static GLfloat ablue[4] = { 0.2f, 0.2f, 1.0f, 1.0f };
-
+
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glEnable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
-
+
switch (id)
{
case 1:
@@ -222,32 +222,32 @@ static void drawGearGL(int id)
static void drawGL(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
+
glPushMatrix();
-
+
glRotatef(view_rotx, 1.0, 0.0, 0.0);
glRotatef(view_roty, 0.0, 1.0, 0.0);
glRotatef(view_rotz, 0.0, 0.0, 1.0);
-
+
glPushMatrix();
glTranslatef(-3.0, -2.0, 0.0);
glRotatef(fAngle, 0.0, 0.0, 1.0);
drawGearGL(1);
glPopMatrix();
-
+
glPushMatrix();
glTranslatef(3.1f, -2.0f, 0.0f);
glRotatef((float)(-2.0 * fAngle - 9.0), 0.0, 0.0, 1.0);
drawGearGL(2);
glPopMatrix();
-
+
glPushMatrix();
glTranslatef(-3.1f, 2.2f, -1.8f);
glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
glRotatef((float)(2.0 * fAngle - 2.0), 0.0, 0.0, 1.0);
drawGearGL(3);
glPopMatrix();
-
+
glPopMatrix();
}
@@ -256,13 +256,13 @@ static void setViewPortGL(GHOST_WindowHandle hWindow)
{
GHOST_RectangleHandle hRect = NULL;
GLfloat w, h;
-
+
GHOST_ActivateWindowDrawingContext(hWindow);
hRect = GHOST_GetClientBounds(hWindow);
-
+
w = (float)GHOST_GetWidthRectangle(hRect) / (float)GHOST_GetHeightRectangle(hRect);
h = 1.0;
-
+
glViewport(0, 0, GHOST_GetWidthRectangle(hRect), GHOST_GetHeightRectangle(hRect));
glMatrixMode(GL_PROJECTION);
@@ -272,7 +272,7 @@ static void setViewPortGL(GHOST_WindowHandle hWindow)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -40.0);
-
+
glClearColor(.2f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
@@ -290,7 +290,7 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
GHOST_TEventWheelData *wheelData = NULL;
GHOST_DisplaySetting setting;
GHOST_WindowHandle window = GHOST_GetEventWindow(hEvent);
-
+
switch (GHOST_GetEventType(hEvent))
{
#if 0
@@ -316,7 +316,7 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
case GHOST_kEventKeyUp:
break;
-
+
case GHOST_kEventKeyDown:
{
keyData = (GHOST_TEventKeyData *)GHOST_GetEventData(hEvent);
@@ -391,7 +391,7 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
sprintf(ntitle, "%s-", title);
GHOST_SetTitle(sMainWindow, ntitle);
-
+
free(ntitle);
free(title);
}
@@ -402,7 +402,7 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
}
}
break;
-
+
case GHOST_kEventWindowClose:
{
GHOST_WindowHandle window2 = GHOST_GetEventWindow(hEvent);
@@ -420,7 +420,7 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
}
}
break;
-
+
case GHOST_kEventWindowActivate:
handled = 0;
break;
@@ -437,7 +437,7 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
GHOST_SwapWindowBuffers(window2);
}
break;
-
+
default:
handled = 0;
break;
@@ -456,7 +456,7 @@ int main(int argc, char **argv)
/* Create the system */
shSystem = GHOST_CreateSystem();
GHOST_AddEventConsumer(shSystem, consumer);
-
+
if (shSystem)
{
/* Create the main window */
@@ -471,7 +471,7 @@ int main(int argc, char **argv)
printf("could not create main window\n");
exit(-1);
}
-
+
/* Create a secondary window */
sSecondaryWindow = GHOST_CreateWindow(
shSystem,
@@ -485,7 +485,7 @@ int main(int argc, char **argv)
printf("could not create secondary window\n");
exit(-1);
}
-
+
/* Install a timer to have the gears running */
sGearsTimer = GHOST_InstallTimer(shSystem,
0,
@@ -496,7 +496,7 @@ int main(int argc, char **argv)
/* Enter main loop */
while (!sExitRequested)
{
- if (!GHOST_ProcessEvents(shSystem, 0))
+ if (!GHOST_ProcessEvents(shSystem, 0))
{
#ifdef WIN32
/* If there were no events, be nice to other applications */
@@ -519,7 +519,7 @@ int main(int argc, char **argv)
/* Dispose the system */
GHOST_DisposeSystem(shSystem);
-
+
return 0;
}
diff --git a/intern/ghost/test/gears/GHOST_Test.cpp b/intern/ghost/test/gears/GHOST_Test.cpp
index f58a220055f..8c4d93fcbc4 100644
--- a/intern/ghost/test/gears/GHOST_Test.cpp
+++ b/intern/ghost/test/gears/GHOST_Test.cpp
@@ -273,7 +273,7 @@ static void View(GHOST_IWindow *window, bool stereo, int eye = 0)
if (stereo)
{
if (nVidiaWindows)
- {
+ {
// handled by nVidia driver so act as normal (explicitly put here since
// it -is- stereo)
glViewport(0, 0, bnds.getWidth(), bnds.getHeight());
@@ -666,7 +666,7 @@ bool Application::processEvent(GHOST_IEvent *event)
window2->swapBuffers();
}
break;
-
+
default:
handled = false;
break;
diff --git a/intern/ghost/test/multitest/Basic.h b/intern/ghost/test/multitest/Basic.h
index c8f61d40c57..86d68ef06cb 100644
--- a/intern/ghost/test/multitest/Basic.h
+++ b/intern/ghost/test/multitest/Basic.h
@@ -28,11 +28,11 @@
int min_i (int a, int b);
int max_i (int a, int b);
-int clamp_i (int val, int min, int max);
+int clamp_i (int val, int min, int max);
-float min_f (float a, float b);
-float max_f (float a, float b);
-float clamp_f (float val, float min, float max);
+float min_f (float a, float b);
+float max_f (float a, float b);
+float clamp_f (float val, float min, float max);
void rect_copy (int dst[2][2], int src[2][2]);
int rect_contains_pt (int rect[2][2], int pt[2]);
diff --git a/intern/ghost/test/multitest/EventToBuf.c b/intern/ghost/test/multitest/EventToBuf.c
index 49255de5e64..7401ab83dbf 100644
--- a/intern/ghost/test/multitest/EventToBuf.c
+++ b/intern/ghost/test/multitest/EventToBuf.c
@@ -47,7 +47,7 @@ char *eventtype_to_string(GHOST_TEventType type)
case GHOST_kEventQuit: return "Quit";
case GHOST_kEventWindowClose: return "WindowClose";
- case GHOST_kEventWindowActivate: return "WindowActivate";
+ case GHOST_kEventWindowActivate: return "WindowActivate";
case GHOST_kEventWindowDeactivate: return "WindowDeactivate";
case GHOST_kEventWindowUpdate: return "WindowUpdate";
case GHOST_kEventWindowSize: return "WindowSize";
@@ -188,7 +188,7 @@ static char *keytype_to_string(GHOST_TKey key)
K(KeyF22);
K(KeyF23);
K(KeyF24);
-
+
default:
return "KeyUnknown";
}
diff --git a/intern/ghost/test/multitest/MultiTest.c b/intern/ghost/test/multitest/MultiTest.c
index 833b5c720a1..8cd31c3137e 100644
--- a/intern/ghost/test/multitest/MultiTest.c
+++ b/intern/ghost/test/multitest/MultiTest.c
@@ -79,7 +79,7 @@ void rect_bevel_side(int rect[2][2], int side, float *lt, float *dk, const float
int ltidx = (side / 2) % 4;
int dkidx = (ltidx + 1 + (side & 1)) % 4;
int i, corner;
-
+
glBegin(GL_LINES);
for (i = 0; i < width; i++) {
float ltf = pow(lt[i], 1.0 / 2.2), dkf = pow(dk[i], 1.0 / 2.2);
@@ -102,7 +102,7 @@ void rect_bevel_side(int rect[2][2], int side, float *lt, float *dk, const float
}
}
glEnd();
-
+
glColor3fv(col);
glRecti(rect[0][0] + width, rect[0][1] + width, rect[1][0] - width, rect[1][1] - width);
}
@@ -113,17 +113,17 @@ void rect_bevel_smooth(int rect[2][2], int width)
float *dk = malloc(sizeof(*dk) * width);
float col[4];
int i;
-
+
for (i = 0; i < width; i++) {
float v = width - 1 ? ((float) i / (width - 1)) : 0;
lt[i] = 1.2 + (1.0 - 1.2) * v;
dk[i] = 0.2 + (1.0 - 0.2) * v;
}
-
+
glGetFloatv(GL_CURRENT_COLOR, col);
-
+
rect_bevel_side(rect, 3, lt, dk, col, width);
-
+
free(lt);
free(dk);
}
@@ -136,11 +136,11 @@ typedef struct {
MultiTestApp *app;
GHOST_WindowHandle win;
-
+
int size[2];
-
+
int lmouse[2], lmbut[3];
-
+
int tmouse[2];
} MainWindow;
@@ -152,18 +152,18 @@ static void mainwindow_log(MainWindow *mw, char *str)
static void mainwindow_do_draw(MainWindow *mw)
{
GHOST_ActivateWindowDrawingContext(mw->win);
-
+
if (mw->lmbut[0]) {
glClearColor(0.5, 0.5, 0.5, 1);
}
else {
glClearColor(1, 1, 1, 1);
- }
+ }
glClear(GL_COLOR_BUFFER_BIT);
-
+
glColor3f(0.5, 0.6, 0.8);
glRecti(mw->tmouse[0] - 5, mw->tmouse[1] - 5, mw->tmouse[0] + 5, mw->tmouse[1] + 5);
-
+
GHOST_SwapWindowBuffers(mw->win);
}
@@ -175,7 +175,7 @@ static void mainwindow_do_reshape(MainWindow *mw)
mw->size[0] = GHOST_GetWidthRectangle(bounds);
mw->size[1] = GHOST_GetHeightRectangle(bounds);
-
+
glViewport(0, 0, mw->size[0], mw->size[1]);
glMatrixMode(GL_PROJECTION);
@@ -234,7 +234,7 @@ static void mainwindow_do_key(MainWindow *mw, GHOST_TKey key, int press)
static void mainwindow_do_move(MainWindow *mw, int x, int y)
{
mw->lmouse[0] = x, mw->lmouse[1] = y;
-
+
if (mw->lmbut[0]) {
mw->tmouse[0] = x, mw->tmouse[1] = y;
GHOST_InvalidateWindow(mw->win);
@@ -261,10 +261,10 @@ static void mainwindow_handle(void *priv, GHOST_EventHandle evt)
MainWindow *mw = priv;
GHOST_TEventType type = GHOST_GetEventType(evt);
char buf[256];
-
+
event_to_buf(evt, buf);
mainwindow_log(mw, buf);
-
+
switch (type) {
case GHOST_kEventCursorMove:
{
@@ -304,7 +304,7 @@ static void mainwindow_timer_proc(GHOST_TimerTaskHandle task, GHOST_TUns64 time)
{
MainWindow *mw = GHOST_GetTimerTaskUserData(task);
char buf[64];
-
+
sprintf(buf, "timer: %6.2f", (double) ((GHOST_TInt64) time) / 1000);
mainwindow_log(mw, buf);
}
@@ -314,23 +314,23 @@ MainWindow *mainwindow_new(MultiTestApp *app)
GHOST_SystemHandle sys = multitestapp_get_system(app);
GHOST_WindowHandle win;
GHOST_GLSettings glSettings = {0};
-
+
win = GHOST_CreateWindow(
sys, "MultiTest:Main",
40, 40, 400, 400,
GHOST_kWindowStateNormal,
GHOST_kDrawingContextTypeOpenGL,
glSettings);
-
+
if (win) {
MainWindow *mw = MEM_callocN(sizeof(*mw), "mainwindow_new");
mw->app = app;
mw->win = win;
-
+
GHOST_SetWindowUserData(mw->win, windowdata_new(mw, mainwindow_handle));
-
+
GHOST_InstallTimer(sys, 1000, 10000, mainwindow_timer_proc, mw);
-
+
return mw;
}
else {
@@ -356,23 +356,23 @@ struct _LoggerWindow {
GHOST_WindowHandle win;
-#ifdef USE_BMF
+#ifdef USE_BMF
BMF_Font *font;
#else
int font;
#endif
int fonttexid;
int fontheight;
-
+
int size[2];
-
+
int ndisplines;
int textarea[2][2];
ScrollBar *scroll;
-
+
char **loglines;
int nloglines, logsize;
-
+
int lmbut[3];
int lmouse[2];
};
@@ -383,7 +383,7 @@ struct _LoggerWindow {
static void loggerwindow_recalc_regions(LoggerWindow *lw)
{
int nscroll[2][2];
-
+
nscroll[0][0] = SCROLLBAR_PAD;
nscroll[0][1] = SCROLLBAR_PAD;
nscroll[1][0] = nscroll[0][0] + SCROLLBAR_WIDTH;
@@ -418,10 +418,10 @@ static void loggerwindow_do_reshape(LoggerWindow *lw)
GHOST_RectangleHandle bounds = GHOST_GetClientBounds(lw->win);
GHOST_ActivateWindowDrawingContext(lw->win);
-
+
lw->size[0] = GHOST_GetWidthRectangle(bounds);
lw->size[1] = GHOST_GetHeightRectangle(bounds);
-
+
loggerwindow_recalc_regions(lw);
loggerwindow_setup_window_gl(lw);
}
@@ -430,21 +430,21 @@ static void loggerwindow_do_draw(LoggerWindow *lw)
{
int i, ndisplines, startline;
int sb_rect[2][2], sb_thumb[2][2];
-
+
GHOST_ActivateWindowDrawingContext(lw->win);
-
+
glClearColor(1, 1, 1, 1);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.8, 0.8, 0.8);
rect_bevel_smooth(lw->textarea, 4);
-
+
scrollbar_get_rect(lw->scroll, sb_rect);
scrollbar_get_thumb(lw->scroll, sb_thumb);
-
+
glColor3f(0.6, 0.6, 0.6);
rect_bevel_smooth(sb_rect, 1);
-
+
if (scrollbar_is_scrolling(lw->scroll)) {
glColor3f(0.6, 0.7, 0.5);
}
@@ -452,16 +452,16 @@ static void loggerwindow_do_draw(LoggerWindow *lw)
glColor3f(0.9, 0.9, 0.92);
}
rect_bevel_smooth(sb_thumb, 1);
-
+
startline = scrollbar_get_thumbpos(lw->scroll) * (lw->nloglines - 1);
ndisplines = min_i(lw->ndisplines, lw->nloglines - startline);
if (lw->fonttexid != -1) {
glBindTexture(GL_TEXTURE_2D, lw->fonttexid);
-
+
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
- glEnable(GL_TEXTURE_2D);
+ glEnable(GL_TEXTURE_2D);
}
glColor3f(0, 0, 0);
for (i = 0; i < ndisplines; i++) {
@@ -470,7 +470,7 @@ static void loggerwindow_do_draw(LoggerWindow *lw)
int x_pos = lw->textarea[0][0] + 4;
int y_pos = lw->textarea[0][1] + 4 + i * lw->fontheight;
-#ifdef USE_BMF
+#ifdef USE_BMF
if (lw->fonttexid == -1) {
glRasterPos2i(x_pos, y_pos);
BMF_DrawString(lw->font, line);
@@ -486,7 +486,7 @@ static void loggerwindow_do_draw(LoggerWindow *lw)
#ifdef USE_BMF
if (lw->fonttexid != -1) {
- glDisable(GL_TEXTURE_2D);
+ glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
}
#endif
@@ -497,7 +497,7 @@ static void loggerwindow_do_draw(LoggerWindow *lw)
static void loggerwindow_do_move(LoggerWindow *lw, int x, int y)
{
lw->lmouse[0] = x, lw->lmouse[1] = y;
-
+
if (scrollbar_is_scrolling(lw->scroll)) {
scrollbar_keep_scrolling(lw->scroll, y);
GHOST_InvalidateWindow(lw->win);
@@ -508,10 +508,10 @@ static void loggerwindow_do_button(LoggerWindow *lw, int which, int press)
{
if (which == GHOST_kButtonMaskLeft) {
lw->lmbut[0] = press;
-
+
if (press) {
if (scrollbar_contains_pt(lw->scroll, lw->lmouse)) {
- scrollbar_start_scrolling(lw->scroll, lw->lmouse[1]);
+ scrollbar_start_scrolling(lw->scroll, lw->lmouse[1]);
GHOST_SetCursorShape(lw->win, GHOST_kStandardCursorUpDown);
GHOST_InvalidateWindow(lw->win);
}
@@ -546,7 +546,7 @@ static void loggerwindow_handle(void *priv, GHOST_EventHandle evt)
{
LoggerWindow *lw = priv;
GHOST_TEventType type = GHOST_GetEventType(evt);
-
+
switch (type) {
case GHOST_kEventCursorMove:
{
@@ -588,7 +588,7 @@ LoggerWindow *loggerwindow_new(MultiTestApp *app)
GHOST_SystemHandle sys = multitestapp_get_system(app);
GHOST_TUns32 screensize[2];
GHOST_WindowHandle win;
-
+
GHOST_GetMainDisplayDimensions(sys, &screensize[0], &screensize[1]);
win = GHOST_CreateWindow(
sys, "MultiTest:Logger",
@@ -596,7 +596,7 @@ LoggerWindow *loggerwindow_new(MultiTestApp *app)
GHOST_kWindowStateNormal,
GHOST_kDrawingContextTypeOpenGL,
glSettings);
-
+
if (win) {
LoggerWindow *lw = MEM_callocN(sizeof(*lw), "loggerwindow_new");
int bbox[2][2];
@@ -614,12 +614,12 @@ LoggerWindow *loggerwindow_new(MultiTestApp *app)
BLF_size(lw->font, 11, 72);
lw->fontheight = BLF_height(lw->font, "A_", 2);
#endif
-
+
lw->nloglines = lw->logsize = 0;
lw->loglines = MEM_mallocN(sizeof(*lw->loglines) * lw->nloglines, "loglines");
-
+
lw->scroll = scrollbar_new(2, 40);
-
+
GHOST_SetWindowUserData(lw->win, windowdata_new(lw, loggerwindow_handle));
loggerwindow_do_reshape(lw);
@@ -636,10 +636,10 @@ void loggerwindow_log(LoggerWindow *lw, char *line)
if (lw->nloglines == lw->logsize) {
lw->loglines = memdbl(lw->loglines, &lw->logsize, sizeof(*lw->loglines));
}
-
+
lw->loglines[lw->nloglines++] = string_dup(line);
scrollbar_set_thumbpct(lw->scroll, (float) lw->ndisplines / lw->nloglines);
-
+
GHOST_InvalidateWindow(lw->win);
}
@@ -652,7 +652,7 @@ void loggerwindow_free(LoggerWindow *lw)
MEM_freeN(lw->loglines[i]);
}
MEM_freeN(lw->loglines);
-
+
windowdata_free(GHOST_GetWindowUserData(lw->win));
GHOST_DisposeWindow(sys, lw->win);
MEM_freeN(lw);
@@ -667,7 +667,7 @@ typedef struct {
MultiTestApp *app;
GHOST_WindowHandle win;
-
+
int size[2];
} ExtraWindow;
@@ -677,10 +677,10 @@ static void extrawindow_do_draw(ExtraWindow *ew)
glClearColor(1, 1, 1, 1);
glClear(GL_COLOR_BUFFER_BIT);
-
+
glColor3f(0.8, 0.8, 0.8);
glRecti(10, 10, ew->size[0] - 10, ew->size[1] - 10);
-
+
GHOST_SwapWindowBuffers(ew->win);
}
@@ -692,7 +692,7 @@ static void extrawindow_do_reshape(ExtraWindow *ew)
ew->size[0] = GHOST_GetWidthRectangle(bounds);
ew->size[1] = GHOST_GetHeightRectangle(bounds);
-
+
glViewport(0, 0, ew->size[0], ew->size[1]);
glMatrixMode(GL_PROJECTION);
@@ -721,15 +721,15 @@ static void extrawindow_spin_cursor(ExtraWindow *ew, GHOST_TUns64 time)
double ftime = (double) ((GHOST_TInt64) time) / 1000;
float angle = fmod(ftime, 1.0) * 3.1415 * 2;
int i;
-
+
memset(&bitmap, 0, sizeof(bitmap));
memset(&mask, 0, sizeof(mask));
-
+
bitmap[0][0] |= mask[0][0] |= 0xF;
bitmap[1][0] |= mask[1][0] |= 0xF;
bitmap[2][0] |= mask[2][0] |= 0xF;
bitmap[3][0] |= mask[3][0] |= 0xF;
-
+
for (i = 0; i < 7; i++) {
int x = 7 + cos(angle) * i;
int y = 7 + sin(angle) * i;
@@ -740,10 +740,10 @@ static void extrawindow_spin_cursor(ExtraWindow *ew, GHOST_TUns64 time)
float v = (i / 63.0) * 3.1415 * 2;
int x = 7 + cos(v) * 7;
int y = 7 + sin(v) * 7;
-
+
mask[y][x / 8] |= (1 << (x % 8));
}
-
+
GHOST_SetCustomCursorShape(ew->win, bitmap, mask, 0, 0);
}
@@ -752,10 +752,10 @@ static void extrawindow_handle(void *priv, GHOST_EventHandle evt)
ExtraWindow *ew = priv;
GHOST_TEventType type = GHOST_GetEventType(evt);
char buf[256];
-
+
event_to_buf(evt, buf);
loggerwindow_log(multitestapp_get_logger(ew->app), buf);
-
+
switch (type) {
case GHOST_kEventKeyDown:
case GHOST_kEventKeyUp:
@@ -790,21 +790,21 @@ ExtraWindow *extrawindow_new(MultiTestApp *app)
GHOST_GLSettings glSettings = {0};
GHOST_SystemHandle sys = multitestapp_get_system(app);
GHOST_WindowHandle win;
-
+
win = GHOST_CreateWindow(
sys, "MultiTest:Extra",
500, 40, 400, 400,
GHOST_kWindowStateNormal,
GHOST_kDrawingContextTypeOpenGL,
glSettings);
-
+
if (win) {
ExtraWindow *ew = MEM_callocN(sizeof(*ew), "mainwindow_new");
ew->app = app;
ew->win = win;
-
+
GHOST_SetWindowUserData(ew->win, windowdata_new(ew, extrawindow_handle));
-
+
return ew;
}
else {
@@ -824,13 +824,13 @@ void extrawindow_free(ExtraWindow *ew)
/*
* MultiTestApp
*/
-
+
struct _MultiTestApp {
GHOST_SystemHandle sys;
MainWindow *main;
LoggerWindow *logger;
ExtraWindow *extra;
-
+
int exit;
};
@@ -838,21 +838,21 @@ static int multitest_event_handler(GHOST_EventHandle evt, GHOST_TUserDataPtr dat
{
MultiTestApp *app = data;
GHOST_WindowHandle win;
-
+
win = GHOST_GetEventWindow(evt);
if (win && !GHOST_ValidWindow(app->sys, win)) {
loggerwindow_log(app->logger, "WARNING: bad event, non-valid window\n");
return 1;
}
-
+
if (win) {
WindowData *wb = GHOST_GetWindowUserData(win);
-
+
windowdata_handle(wb, evt);
}
else {
GHOST_TEventType type = GHOST_GetEventType(evt);
-
+
/* GHOST_kEventQuit are the only 'system' events,
* that is, events without a window.
*/
@@ -866,7 +866,7 @@ static int multitest_event_handler(GHOST_EventHandle evt, GHOST_TUserDataPtr dat
break;
}
}
-
+
return 1;
}
@@ -880,25 +880,25 @@ MultiTestApp *multitestapp_new(void) {
if (!app->sys)
fatal("Unable to create ghost system");
- if (!GHOST_AddEventConsumer(app->sys, consumer))
+ if (!GHOST_AddEventConsumer(app->sys, consumer))
fatal("Unable to add multitest event consumer ");
-
+
app->main = mainwindow_new(app);
- if (!app->main)
+ if (!app->main)
fatal("Unable to create main window");
-
+
app->logger = loggerwindow_new(app);
if (!app->logger)
fatal("Unable to create logger window");
app->extra = NULL;
app->exit = 0;
-
+
return app;
}
LoggerWindow *multitestapp_get_logger(MultiTestApp *app) {
- return app->logger;
+ return app->logger;
}
GHOST_SystemHandle multitestapp_get_system(MultiTestApp *app) {
@@ -943,7 +943,7 @@ void multitestapp_free(MultiTestApp *app)
}
/***/
-
+
int main(int argc, char **argv)
{
MultiTestApp *app;
@@ -953,9 +953,9 @@ int main(int argc, char **argv)
#endif
app = multitestapp_new();
-
+
multitestapp_run(app);
multitestapp_free(app);
-
+
return 0;
}
diff --git a/intern/ghost/test/multitest/ScrollBar.c b/intern/ghost/test/multitest/ScrollBar.c
index 8964d304920..2a363f3ce5d 100644
--- a/intern/ghost/test/multitest/ScrollBar.c
+++ b/intern/ghost/test/multitest/ScrollBar.c
@@ -37,7 +37,7 @@
struct _ScrollBar {
int rect[2][2];
float thumbpos, thumbpct;
-
+
int inset;
int minthumb;
@@ -48,7 +48,7 @@ struct _ScrollBar {
static int scrollbar_get_thumbH(ScrollBar *sb)
{
int scrollable_h = rect_height(sb->rect) - 2 * sb->inset;
-
+
return clamp_i(sb->thumbpct * scrollable_h, sb->minthumb, scrollable_h);
}
@@ -56,7 +56,7 @@ static int scrollbar_get_thumbableH(ScrollBar *sb)
{
int scrollable_h = rect_height(sb->rect) - 2 * sb->inset;
int thumb_h = scrollbar_get_thumbH(sb);
-
+
return scrollable_h - thumb_h;
}
@@ -76,7 +76,7 @@ ScrollBar *scrollbar_new(int inset, int minthumb)
ScrollBar *sb = MEM_callocN(sizeof(*sb), "scrollbar_new");
sb->inset = inset;
sb->minthumb = minthumb;
-
+
return sb;
}
diff --git a/intern/ghost/test/multitest/ScrollBar.h b/intern/ghost/test/multitest/ScrollBar.h
index 8c8d02d197e..dd737539bf2 100644
--- a/intern/ghost/test/multitest/ScrollBar.h
+++ b/intern/ghost/test/multitest/ScrollBar.h
@@ -29,7 +29,7 @@ typedef struct _ScrollBar ScrollBar;
/***/
-
+
ScrollBar* scrollbar_new (int inset, int minthumb);
int scrollbar_is_scrolling (ScrollBar *sb);
diff --git a/intern/ghost/test/multitest/Util.c b/intern/ghost/test/multitest/Util.c
index bacd0a313d4..9ac7ae0263d 100644
--- a/intern/ghost/test/multitest/Util.c
+++ b/intern/ghost/test/multitest/Util.c
@@ -40,10 +40,10 @@ void *memdbl(void *mem, int *size_pr, int item_size)
int cur_size = *size_pr;
int new_size = cur_size ? (cur_size * 2) : 1;
void *nmem = MEM_mallocN(new_size * item_size, "memdbl");
-
+
memcpy(nmem, mem, cur_size * item_size);
MEM_freeN(mem);
-
+
*size_pr = new_size;
return nmem;
}
@@ -54,19 +54,19 @@ char *string_dup(char *str)
char *nstr = MEM_mallocN(len + 1, "string_dup");
memcpy(nstr, str, len + 1);
-
+
return nstr;
}
void fatal(char *fmt, ...)
{
va_list ap;
-
+
fprintf(stderr, "FATAL: ");
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
fprintf(stderr, "\n");
-
+
exit(1);
}
diff --git a/intern/ghost/test/multitest/WindowData.c b/intern/ghost/test/multitest/WindowData.c
index de4992ab2a0..07078cd9238 100644
--- a/intern/ghost/test/multitest/WindowData.c
+++ b/intern/ghost/test/multitest/WindowData.c
@@ -43,7 +43,7 @@ WindowData *windowdata_new(void *data, WindowDataHandler handler)
WindowData *wb = MEM_mallocN(sizeof(*wb), "windowdata_new");
wb->data = data;
wb->handler = handler;
-
+
return wb;
}
diff --git a/intern/ghost/test/multitest/WindowData.h b/intern/ghost/test/multitest/WindowData.h
index f8198101b8d..0e6c7518843 100644
--- a/intern/ghost/test/multitest/WindowData.h
+++ b/intern/ghost/test/multitest/WindowData.h
@@ -27,9 +27,9 @@
typedef void (*WindowDataHandler)(void *priv, GHOST_EventHandle evt);
typedef struct _WindowData WindowData;
-
+
/***/
-
+
WindowData* windowdata_new (void *data, WindowDataHandler handler);
void windowdata_handle (WindowData *wb, GHOST_EventHandle evt);
void windowdata_free (WindowData *wb);
diff --git a/intern/libmv/libmv/base/vector.h b/intern/libmv/libmv/base/vector.h
index 1931fb0b1f9..bdc4392155c 100644
--- a/intern/libmv/libmv/base/vector.h
+++ b/intern/libmv/libmv/base/vector.h
@@ -121,7 +121,7 @@ class vector {
void reserve(unsigned int size) {
if (size > size_) {
T *data = static_cast<T *>(allocate(size));
- memcpy(data, data_, sizeof(*data)*size_);
+ memcpy(static_cast<void *>(data), data_, sizeof(*data)*size_);
allocator_.deallocate(data_, capacity_);
data_ = data;
capacity_ = size;
diff --git a/intern/opencolorio/ocio_impl_glsl.cc b/intern/opencolorio/ocio_impl_glsl.cc
index e20d507b470..090422ff795 100644
--- a/intern/opencolorio/ocio_impl_glsl.cc
+++ b/intern/opencolorio/ocio_impl_glsl.cc
@@ -59,13 +59,19 @@ using namespace OCIO_NAMESPACE;
#include "ocio_impl.h"
static const int LUT3D_EDGE_SIZE = 64;
+static const int SHADER_CACHE_SIZE = 4;
extern "C" char datatoc_gpu_shader_display_transform_glsl[];
extern "C" char datatoc_gpu_shader_display_transform_vertex_glsl[];
/* **** OpenGL drawing routines using GLSL for color space transform ***** */
-typedef struct OCIO_GLSLDrawState {
+typedef struct OCIO_GLSLShader {
+ /* Cache ID */
+ std::string lut3dCacheID;
+ std::string shaderCacheID;
+
+ /* LUT */
bool lut3d_texture_allocated; /* boolean flag indicating whether
* lut texture is allocated
*/
@@ -75,25 +81,29 @@ typedef struct OCIO_GLSLDrawState {
float *lut3d; /* 3D LUT table */
- bool dither_used;
+ /* Dither */
+ bool use_dither;
- bool curve_mapping_used;
+ /* Curve Mapping */
+ bool use_curve_mapping;
bool curve_mapping_texture_allocated;
bool curve_mapping_texture_valid;
GLuint curve_mapping_texture;
size_t curve_mapping_cache_id;
- bool predivide_used;
-
- /* Cache */
- std::string lut3dcacheid;
- std::string shadercacheid;
+ /* Alpha Predivide */
+ bool use_predivide;
/* GLSL stuff */
GLuint ocio_shader;
GLuint vert_shader;
GLuint program;
Gwn_ShaderInterface *shader_interface;
+} GLSLDrawState;
+
+typedef struct OCIO_GLSLDrawState {
+ /* Shader Cache */
+ OCIO_GLSLShader *shader_cache[SHADER_CACHE_SIZE];
/* Previous OpenGL state. */
GLint last_texture, last_texture_unit;
@@ -150,33 +160,24 @@ static GLuint linkShaders(GLuint ocio_shader, GLuint vert_shader)
static OCIO_GLSLDrawState *allocateOpenGLState(void)
{
- OCIO_GLSLDrawState *state;
-
- /* Allocate memory for state. */
- state = (OCIO_GLSLDrawState *) MEM_callocN(sizeof(OCIO_GLSLDrawState),
- "OCIO OpenGL State struct");
-
- /* Call constructors on new memory. */
- new (&state->lut3dcacheid) std::string("");
- new (&state->shadercacheid) std::string("");
-
- return state;
+ return (OCIO_GLSLDrawState *) MEM_callocN(sizeof(OCIO_GLSLDrawState),
+ "OCIO OpenGL State struct");
}
/* Ensure LUT texture and array are allocated */
-static bool ensureLUT3DAllocated(OCIO_GLSLDrawState *state)
+static bool ensureLUT3DAllocated(OCIO_GLSLShader *shader)
{
int num_3d_entries = 3 * LUT3D_EDGE_SIZE * LUT3D_EDGE_SIZE * LUT3D_EDGE_SIZE;
- if (state->lut3d_texture_allocated)
- return state->lut3d_texture_valid;
+ if (shader->lut3d_texture_allocated)
+ return shader->lut3d_texture_valid;
- glGenTextures(1, &state->lut3d_texture);
+ glGenTextures(1, &shader->lut3d_texture);
- state->lut3d = (float *) MEM_callocN(sizeof(float) * num_3d_entries, "OCIO GPU 3D LUT");
+ shader->lut3d = (float *) MEM_callocN(sizeof(float) * num_3d_entries, "OCIO GPU 3D LUT");
glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_3D, state->lut3d_texture);
+ glBindTexture(GL_TEXTURE_3D, shader->lut3d_texture);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -188,27 +189,27 @@ static bool ensureLUT3DAllocated(OCIO_GLSLDrawState *state)
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB16F_ARB,
LUT3D_EDGE_SIZE, LUT3D_EDGE_SIZE, LUT3D_EDGE_SIZE,
- 0, GL_RGB, GL_FLOAT, state->lut3d);
+ 0, GL_RGB, GL_FLOAT, shader->lut3d);
- state->lut3d_texture_allocated = true;
+ shader->lut3d_texture_allocated = true;
/* GL_RGB16F_ARB could be not supported at some drivers
* in this case we could not use GLSL display
*/
- state->lut3d_texture_valid = glGetError() == GL_NO_ERROR;
+ shader->lut3d_texture_valid = glGetError() == GL_NO_ERROR;
- return state->lut3d_texture_valid;
+ return shader->lut3d_texture_valid;
}
-static bool ensureCurveMappingAllocated(OCIO_GLSLDrawState *state, OCIO_CurveMappingSettings *curve_mapping_settings)
+static bool ensureCurveMappingAllocated(OCIO_GLSLShader *shader, OCIO_CurveMappingSettings *curve_mapping_settings)
{
- if (state->curve_mapping_texture_allocated)
- return state->curve_mapping_texture_valid;
+ if (shader->curve_mapping_texture_allocated)
+ return shader->curve_mapping_texture_valid;
- glGenTextures(1, &state->curve_mapping_texture);
+ glGenTextures(1, &shader->curve_mapping_texture);
glActiveTexture(GL_TEXTURE2);
- glBindTexture(GL_TEXTURE_1D, state->curve_mapping_texture);
+ glBindTexture(GL_TEXTURE_1D, shader->curve_mapping_texture);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -221,16 +222,51 @@ static bool ensureCurveMappingAllocated(OCIO_GLSLDrawState *state, OCIO_CurveMap
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA16F, curve_mapping_settings->lut_size,
0, GL_RGBA, GL_FLOAT, curve_mapping_settings->lut);
- state->curve_mapping_texture_allocated = true;
+ shader->curve_mapping_texture_allocated = true;
/* GL_RGB16F_ARB could be not supported at some drivers
* in this case we could not use GLSL display
*/
- state->curve_mapping_texture_valid = glGetError() == GL_NO_ERROR;
+ shader->curve_mapping_texture_valid = glGetError() == GL_NO_ERROR;
- return state->curve_mapping_texture_valid;
+ return shader->curve_mapping_texture_valid;
}
+static void freeGLSLShader(OCIO_GLSLShader *shader)
+{
+ if (shader->curve_mapping_texture_allocated) {
+ glDeleteTextures(1, &shader->curve_mapping_texture);
+ }
+
+ if (shader->lut3d_texture_allocated) {
+ glDeleteTextures(1, &shader->lut3d_texture);
+ }
+
+ if (shader->lut3d) {
+ MEM_freeN(shader->lut3d);
+ }
+
+ if (shader->program) {
+ glDeleteProgram(shader->program);
+ }
+
+ if (shader->shader_interface) {
+ GWN_shaderinterface_discard(shader->shader_interface);
+ }
+
+ if (shader->ocio_shader) {
+ glDeleteShader(shader->ocio_shader);
+ }
+
+ using std::string;
+ shader->lut3dCacheID.~string();
+ shader->shaderCacheID.~string();
+
+ MEM_freeN(shader);
+}
+
+
+
/* Detect if we can support GLSL drawing */
bool OCIOImpl::supportGLSLDraw()
{
@@ -265,135 +301,154 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
glGetIntegerv(GL_TEXTURE_BINDING_2D, &state->last_texture);
glGetIntegerv(GL_ACTIVE_TEXTURE, &state->last_texture_unit);
- if (!ensureLUT3DAllocated(state)) {
- glActiveTexture(state->last_texture_unit);
- glBindTexture(GL_TEXTURE_2D, state->last_texture);
+ /* Compute cache IDs. */
+ GpuShaderDesc shaderDesc;
+ shaderDesc.setLanguage(GPU_LANGUAGE_GLSL_1_3);
+ shaderDesc.setFunctionName("OCIODisplay");
+ shaderDesc.setLut3DEdgeLen(LUT3D_EDGE_SIZE);
- return false;
- }
+ std::string lut3dCacheID = ocio_processor->getGpuLut3DCacheID(shaderDesc);
+ std::string shaderCacheID = ocio_processor->getGpuShaderTextCacheID(shaderDesc);
- if (use_curve_mapping) {
- if (!ensureCurveMappingAllocated(state, curve_mapping_settings)) {
- glActiveTexture(state->last_texture_unit);
- glBindTexture(GL_TEXTURE_2D, state->last_texture);
+ /* Find matching cached shader. */
+ OCIO_GLSLShader *shader = NULL;
+ for (int i = 0; i < SHADER_CACHE_SIZE; i++) {
+ OCIO_GLSLShader *cached_shader = state->shader_cache[i];
+ if (cached_shader == NULL) {
+ continue;
+ }
+
+ if (cached_shader->lut3dCacheID == lut3dCacheID &&
+ cached_shader->shaderCacheID == shaderCacheID &&
+ cached_shader->use_predivide == use_predivide &&
+ cached_shader->use_curve_mapping == use_curve_mapping &&
+ cached_shader->use_dither == use_dither)
+ {
+ /* LRU cache, so move to front. */
+ for (int j = i; j > 0; j--) {
+ state->shader_cache[j] = state->shader_cache[j - 1];
+ }
+ state->shader_cache[0] = cached_shader;
- return false;
+ shader = cached_shader;
+ break;
}
}
- else {
- if (state->curve_mapping_texture_allocated) {
- glDeleteTextures(1, &state->curve_mapping_texture);
- state->curve_mapping_texture_allocated = false;
+
+ if (shader == NULL) {
+ /* LRU cache, shift other items back so we can insert at the front. */
+ OCIO_GLSLShader *last_shader = state->shader_cache[SHADER_CACHE_SIZE - 1];
+ if (last_shader) {
+ freeGLSLShader(last_shader);
+ }
+ for (int j = SHADER_CACHE_SIZE - 1; j > 0; j--) {
+ state->shader_cache[j] = state->shader_cache[j - 1];
}
- }
- /* Step 1: Create a GPU Shader Description */
- GpuShaderDesc shaderDesc;
- shaderDesc.setLanguage(GPU_LANGUAGE_GLSL_1_3);
- shaderDesc.setFunctionName("OCIODisplay");
- shaderDesc.setLut3DEdgeLen(LUT3D_EDGE_SIZE);
+ /* Allocate memory for shader. */
+ shader = (OCIO_GLSLShader *) MEM_callocN(sizeof(OCIO_GLSLShader),
+ "OCIO GLSL Shader");
+ state->shader_cache[0] = shader;
- if (use_curve_mapping) {
- if (state->curve_mapping_cache_id != curve_mapping_settings->cache_id) {
- glActiveTexture(GL_TEXTURE2);
- glBindTexture(GL_TEXTURE_1D, state->curve_mapping_texture);
- glTexSubImage1D(GL_TEXTURE_1D, 0, 0, curve_mapping_settings->lut_size,
- GL_RGBA, GL_FLOAT, curve_mapping_settings->lut);
- }
- }
+ new (&shader->lut3dCacheID) std::string();
+ new (&shader->shaderCacheID) std::string();
- /* Step 2: Compute the 3D LUT */
- std::string lut3dCacheID = ocio_processor->getGpuLut3DCacheID(shaderDesc);
- if (lut3dCacheID != state->lut3dcacheid) {
- state->lut3dcacheid = lut3dCacheID;
- ocio_processor->getGpuLut3D(state->lut3d, shaderDesc);
+ shader->lut3dCacheID = lut3dCacheID;
+ shader->shaderCacheID = shaderCacheID;
+ shader->use_curve_mapping = use_curve_mapping;
+ shader->use_dither = use_dither;
+ shader->use_predivide = use_predivide;
- glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_3D, state->lut3d_texture);
- glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0,
- LUT3D_EDGE_SIZE, LUT3D_EDGE_SIZE, LUT3D_EDGE_SIZE,
- GL_RGB, GL_FLOAT, state->lut3d);
- }
+ bool valid = true;
- /* Step 3: Compute the Shader */
- std::string shaderCacheID = ocio_processor->getGpuShaderTextCacheID(shaderDesc);
- if (state->program == 0 ||
- shaderCacheID != state->shadercacheid ||
- use_predivide != state->predivide_used ||
- use_curve_mapping != state->curve_mapping_used ||
- use_dither != state->dither_used)
- {
- state->shadercacheid = shaderCacheID;
+ /* Compute 3D LUT. */
+ if (valid && ensureLUT3DAllocated(shader)) {
+ ocio_processor->getGpuLut3D(shader->lut3d, shaderDesc);
- if (state->program) {
- glDeleteProgram(state->program);
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_3D, shader->lut3d_texture);
+ glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0,
+ LUT3D_EDGE_SIZE, LUT3D_EDGE_SIZE, LUT3D_EDGE_SIZE,
+ GL_RGB, GL_FLOAT, shader->lut3d);
}
-
- if (state->ocio_shader) {
- glDeleteShader(state->ocio_shader);
+ else {
+ valid = false;
}
- if (state->vert_shader) {
- glDeleteShader(state->vert_shader);
+ /* Allocate curve mapping texture. */
+ if (valid && use_curve_mapping) {
+ if (!ensureCurveMappingAllocated(shader, curve_mapping_settings)) {
+ valid = false;
+ }
}
- /* Vertex shader */
- std::ostringstream osv;
+ if (valid) {
+ /* Vertex shader */
+ std::ostringstream osv;
- osv << "#version 330\n";
- osv << datatoc_gpu_shader_display_transform_vertex_glsl;
+ osv << "#version 330\n";
+ osv << datatoc_gpu_shader_display_transform_vertex_glsl;
- state->vert_shader = compileShaderText(GL_VERTEX_SHADER, osv.str().c_str());
+ shader->vert_shader = compileShaderText(GL_VERTEX_SHADER, osv.str().c_str());
- /* Fragment shader */
- std::ostringstream os;
+ /* Fragment shader */
+ std::ostringstream os;
- os << "#version 330\n";
+ os << "#version 330\n";
- /* Work around OpenColorIO not supporting latest GLSL yet. */
- os << "#define texture2D texture\n";
- os << "#define texture3D texture\n";
+ /* Work around OpenColorIO not supporting latest GLSL yet. */
+ os << "#define texture2D texture\n";
+ os << "#define texture3D texture\n";
- if (use_predivide) {
- os << "#define USE_PREDIVIDE\n";
- }
+ if (use_predivide) {
+ os << "#define USE_PREDIVIDE\n";
+ }
- if (use_dither) {
- os << "#define USE_DITHER\n";
- }
+ if (use_dither) {
+ os << "#define USE_DITHER\n";
+ }
- if (use_curve_mapping) {
- os << "#define USE_CURVE_MAPPING\n";
- }
+ if (use_curve_mapping) {
+ os << "#define USE_CURVE_MAPPING\n";
+ }
- os << ocio_processor->getGpuShaderText(shaderDesc) << "\n";
- os << datatoc_gpu_shader_display_transform_glsl;
+ os << ocio_processor->getGpuShaderText(shaderDesc) << "\n";
+ os << datatoc_gpu_shader_display_transform_glsl;
- state->ocio_shader = compileShaderText(GL_FRAGMENT_SHADER, os.str().c_str());
+ shader->ocio_shader = compileShaderText(GL_FRAGMENT_SHADER, os.str().c_str());
- if (state->ocio_shader && state->vert_shader) {
- state->program = linkShaders(state->ocio_shader, state->vert_shader);
- }
+ /* Program */
+ if (shader->ocio_shader && shader->vert_shader) {
+ shader->program = linkShaders(shader->ocio_shader, shader->vert_shader);
+ }
- if (state->program) {
- if (state->shader_interface) {
- GWN_shaderinterface_discard(state->shader_interface);
+ if (shader->program) {
+ if (shader->shader_interface) {
+ GWN_shaderinterface_discard(shader->shader_interface);
+ }
+ shader->shader_interface = GWN_shaderinterface_create(shader->program);
}
- state->shader_interface = GWN_shaderinterface_create(state->program);
}
+ }
- state->curve_mapping_used = use_curve_mapping;
- state->dither_used = use_dither;
- state->predivide_used = use_predivide;
+ /* Update curve mapping texture. */
+ if (use_curve_mapping && shader->curve_mapping_texture_allocated) {
+ if (shader->curve_mapping_cache_id != curve_mapping_settings->cache_id) {
+ glActiveTexture(GL_TEXTURE2);
+ glBindTexture(GL_TEXTURE_1D, shader->curve_mapping_texture);
+ glTexSubImage1D(GL_TEXTURE_1D, 0, 0, curve_mapping_settings->lut_size,
+ GL_RGBA, GL_FLOAT, curve_mapping_settings->lut);
+ }
}
- if (state->program) {
+ /* Bind Shader. */
+ if (shader->program) {
glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_3D, state->lut3d_texture);
+ glBindTexture(GL_TEXTURE_3D, shader->lut3d_texture);
if (use_curve_mapping) {
glActiveTexture(GL_TEXTURE2);
- glBindTexture(GL_TEXTURE_1D, state->curve_mapping_texture);
+ glBindTexture(GL_TEXTURE_1D, shader->curve_mapping_texture);
}
glActiveTexture(GL_TEXTURE0);
@@ -409,7 +464,7 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
Gwn_VertFormat *format = immVertexFormat();
GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindProgram(state->program, state->shader_interface);
+ immBindProgram(shader->program, shader->shader_interface);
immUniform1i("image_texture", 0);
immUniform1i("lut3d_texture", 1);
@@ -453,27 +508,13 @@ void OCIOImpl::finishGLSLDraw(OCIO_GLSLDrawState *state)
immUnbindProgram();
}
-void OCIOImpl::freeGLState(struct OCIO_GLSLDrawState *state)
+void OCIOImpl::freeGLState(OCIO_GLSLDrawState *state)
{
- using std::string;
-
- if (state->lut3d_texture_allocated)
- glDeleteTextures(1, &state->lut3d_texture);
-
- if (state->lut3d)
- MEM_freeN(state->lut3d);
-
- if (state->program)
- glDeleteProgram(state->program);
-
- if (state->shader_interface)
- GWN_shaderinterface_discard(state->shader_interface);
-
- if (state->ocio_shader)
- glDeleteShader(state->ocio_shader);
-
- state->lut3dcacheid.~string();
- state->shadercacheid.~string();
+ for (int i = 0; i < SHADER_CACHE_SIZE; i++) {
+ if (state->shader_cache[i]) {
+ freeGLSLShader(state->shader_cache[i]);
+ }
+ }
MEM_freeN(state);
}
diff --git a/release/datafiles/studiolights/matcap/license.txt b/release/datafiles/studiolights/matcap/license.txt
new file mode 100644
index 00000000000..358c8dcd832
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/license.txt
@@ -0,0 +1,3 @@
+These matcap images are licensed as GNU GPL 2 or later, like the rest of Blender's code.
+
+Thanks to Kent Trammell, Aidy Burrows, John Herreno , Terry Wallwork and David Silverman for making the pictures.
diff --git a/release/datafiles/studiolights/matcap/mc01.jpg b/release/datafiles/studiolights/matcap/mc01.jpg
new file mode 100644
index 00000000000..8c7aef287ee
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc01.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc02.jpg b/release/datafiles/studiolights/matcap/mc02.jpg
new file mode 100644
index 00000000000..11deddfeaed
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc02.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc03.jpg b/release/datafiles/studiolights/matcap/mc03.jpg
new file mode 100644
index 00000000000..64d992fb61a
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc03.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc04.jpg b/release/datafiles/studiolights/matcap/mc04.jpg
new file mode 100644
index 00000000000..42be580ee93
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc04.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc05.jpg b/release/datafiles/studiolights/matcap/mc05.jpg
new file mode 100644
index 00000000000..586d233ef31
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc05.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc06.jpg b/release/datafiles/studiolights/matcap/mc06.jpg
new file mode 100644
index 00000000000..657883d0866
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc06.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc07.jpg b/release/datafiles/studiolights/matcap/mc07.jpg
new file mode 100644
index 00000000000..372caf7e87c
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc07.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc08.jpg b/release/datafiles/studiolights/matcap/mc08.jpg
new file mode 100644
index 00000000000..50eec402812
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc08.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc09.jpg b/release/datafiles/studiolights/matcap/mc09.jpg
new file mode 100644
index 00000000000..e05d441aaf9
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc09.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc10.jpg b/release/datafiles/studiolights/matcap/mc10.jpg
new file mode 100644
index 00000000000..ab82f17bb93
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc10.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc11.jpg b/release/datafiles/studiolights/matcap/mc11.jpg
new file mode 100644
index 00000000000..053550f082c
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc11.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc12.jpg b/release/datafiles/studiolights/matcap/mc12.jpg
new file mode 100644
index 00000000000..beb16f3742e
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc12.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc13.jpg b/release/datafiles/studiolights/matcap/mc13.jpg
new file mode 100644
index 00000000000..7fb8fa58e8f
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc13.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc14.jpg b/release/datafiles/studiolights/matcap/mc14.jpg
new file mode 100644
index 00000000000..ba868d2f95a
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc14.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc15.jpg b/release/datafiles/studiolights/matcap/mc15.jpg
new file mode 100644
index 00000000000..b10ea326a42
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc15.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc16.jpg b/release/datafiles/studiolights/matcap/mc16.jpg
new file mode 100644
index 00000000000..c6ce02d59df
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc16.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc17.jpg b/release/datafiles/studiolights/matcap/mc17.jpg
new file mode 100644
index 00000000000..14f15f70460
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc17.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc18.jpg b/release/datafiles/studiolights/matcap/mc18.jpg
new file mode 100644
index 00000000000..db572856b07
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc18.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc19.jpg b/release/datafiles/studiolights/matcap/mc19.jpg
new file mode 100644
index 00000000000..56d2efb1734
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc19.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc20.jpg b/release/datafiles/studiolights/matcap/mc20.jpg
new file mode 100644
index 00000000000..002a0910dd9
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc20.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc21.jpg b/release/datafiles/studiolights/matcap/mc21.jpg
new file mode 100644
index 00000000000..cb2fea573b8
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc21.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc22.jpg b/release/datafiles/studiolights/matcap/mc22.jpg
new file mode 100644
index 00000000000..2fc71b98c5a
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc22.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc23.jpg b/release/datafiles/studiolights/matcap/mc23.jpg
new file mode 100644
index 00000000000..3793c0fcaa5
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc23.jpg
Binary files differ
diff --git a/release/datafiles/studiolights/matcap/mc24.jpg b/release/datafiles/studiolights/matcap/mc24.jpg
new file mode 100644
index 00000000000..2a9618d8fe1
--- /dev/null
+++ b/release/datafiles/studiolights/matcap/mc24.jpg
Binary files differ
diff --git a/release/scripts/addons b/release/scripts/addons
-Subproject 27970761a18926abe1b0020aa350305e3109a53
+Subproject ebd058d7a6438d137522063bb3286c8acc325ca
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
-Subproject 6a4f93c9b8f36b19bd02087abf3d7f5983df035
+Subproject 474702157831f1a58bb50f5240ab8b1b02b6ba3
diff --git a/release/scripts/modules/keyingsets_utils.py b/release/scripts/modules/keyingsets_utils.py
index 7ce5f3e029b..48071117bd4 100644
--- a/release/scripts/modules/keyingsets_utils.py
+++ b/release/scripts/modules/keyingsets_utils.py
@@ -153,8 +153,10 @@ def get_transform_generators_base_info(data):
# no path in this case
path = ""
- # data on ID-blocks directly should get grouped by the KeyingSet
- grouping = None
+ # transform data on ID-blocks directly should get grouped under a
+ # hardcoded label ("Object Transforms") so that they get grouped
+ # consistently when keyframed directly
+ grouping = "Object Transforms"
else:
# get the path to the ID-block
path = data.path_from_id()
diff --git a/release/scripts/presets/interface_theme/flatty_dark_blueberry.xml b/release/scripts/presets/interface_theme/flatty_dark_blueberry.xml
index 665259bba00..eb6c8e68511 100644
--- a/release/scripts/presets/interface_theme/flatty_dark_blueberry.xml
+++ b/release/scripts/presets/interface_theme/flatty_dark_blueberry.xml
@@ -160,8 +160,8 @@
</ThemeWidgetColors>
</wcol_menu>
<wcol_pulldown>
- <ThemeWidgetColors outline="#000000"
- inner="#29282eff"
+ <ThemeWidgetColors outline="#29282e"
+ inner="#29282e99"
inner_sel="#505158ff"
item="#ffffffff"
text="#eeeeee"
@@ -936,18 +936,18 @@
</ThemeUserPreferences>
</user_preferences>
<console>
- <ThemeConsole line_output="#6080ff"
+ <ThemeConsole line_output="#b3c2ff"
line_input="#ffffff"
- line_info="#00aa00"
- line_error="#dc6060"
- cursor="#dc6060"
+ line_info="#47b347"
+ line_error="#de6f6f"
+ cursor="#de5959"
select="#ffffff30">
<space>
<ThemeSpaceGeneric back="#2f3035"
title="#ffffff"
text="#ffffff"
text_hi="#ffffff"
- header="#29282eff"
+ header="#2f3035ff"
header_text="#eeeeee"
header_text_hi="#ffffff"
button="#2f303599"
diff --git a/release/scripts/presets/interface_theme/flatty_light.xml b/release/scripts/presets/interface_theme/flatty_light.xml
index c12a41dc8cc..bdcf381f8f9 100644
--- a/release/scripts/presets/interface_theme/flatty_light.xml
+++ b/release/scripts/presets/interface_theme/flatty_light.xml
@@ -161,7 +161,7 @@
</wcol_menu>
<wcol_pulldown>
<ThemeWidgetColors outline="#000000"
- inner="#3f3f3fff"
+ inner="#e6e6e699"
inner_sel="#5680c2ff"
item="#ffffffff"
text="#000000"
@@ -169,7 +169,7 @@
show_shaded="FALSE"
shadetop="25"
shadedown="-20"
- roundness="0.4">
+ roundness="0.3">
</ThemeWidgetColors>
</wcol_pulldown>
<wcol_menu_back>
diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py
index 6a538f0ae33..c2ca271de66 100644
--- a/release/scripts/startup/bl_operators/image.py
+++ b/release/scripts/startup/bl_operators/image.py
@@ -249,4 +249,4 @@ classes = (
ProjectApply,
ProjectEdit,
SaveDirty,
-) \ No newline at end of file
+)
diff --git a/release/scripts/startup/bl_operators/mask.py b/release/scripts/startup/bl_operators/mask.py
index 78a4bd9af27..3ce1abad9b8 100644
--- a/release/scripts/startup/bl_operators/mask.py
+++ b/release/scripts/startup/bl_operators/mask.py
@@ -35,4 +35,4 @@ class MASK_MT_add(Menu):
classes = (
MASK_MT_add,
-) \ No newline at end of file
+)
diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py
index 5fd54eceb25..0959cbec448 100644
--- a/release/scripts/startup/bl_operators/object.py
+++ b/release/scripts/startup/bl_operators/object.py
@@ -865,7 +865,7 @@ class TransformsToDeltasAnim(Operator):
class DupliOffsetFromCursor(Operator):
- """Set offset used for DupliGroup based on cursor position"""
+ """Set offset used for collection instances based on cursor position"""
bl_idname = "object.dupli_offset_from_cursor"
bl_label = "Set Offset From Cursor"
bl_options = {'INTERNAL', 'UNDO'}
@@ -876,9 +876,9 @@ class DupliOffsetFromCursor(Operator):
def execute(self, context):
scene = context.scene
- group = context.group
+ collection = context.collection
- group.dupli_offset = scene.cursor_location
+ collection.dupli_offset = scene.cursor_location
return {'FINISHED'}
diff --git a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py
index f4d6c7065a9..e32c1ac0f81 100644
--- a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py
+++ b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py
@@ -184,4 +184,4 @@ class PlayRenderedAnim(Operator):
classes = (
PlayRenderedAnim,
-) \ No newline at end of file
+)
diff --git a/release/scripts/startup/bl_operators/sequencer.py b/release/scripts/startup/bl_operators/sequencer.py
index 7209b6b478f..337492bc8a7 100644
--- a/release/scripts/startup/bl_operators/sequencer.py
+++ b/release/scripts/startup/bl_operators/sequencer.py
@@ -140,4 +140,4 @@ classes = (
SequencerCrossfadeSounds,
SequencerCutMulticam,
SequencerDeinterlaceSelectedMovies,
-) \ No newline at end of file
+)
diff --git a/release/scripts/startup/bl_operators/uvcalc_lightmap.py b/release/scripts/startup/bl_operators/uvcalc_lightmap.py
index 61ceb3c04c4..ff7bab4102a 100644
--- a/release/scripts/startup/bl_operators/uvcalc_lightmap.py
+++ b/release/scripts/startup/bl_operators/uvcalc_lightmap.py
@@ -559,12 +559,24 @@ def lightmap_uvpack(meshes,
def unwrap(operator, context, **kwargs):
- is_editmode = (context.object.mode == 'EDIT')
+ # only unwrap active object if True
+ PREF_ACT_ONLY = kwargs.pop("PREF_ACT_ONLY")
+
+ # ensure object(s) are selected if necessary and active object is set
+ if context.object is None:
+ if PREF_ACT_ONLY:
+ operator.report({'WARNING'}, "Active object not set")
+ return {'CANCELLED'}
+ elif len(context.selected_objects) == 0:
+ operator.report({'WARNING'}, "No selected objects")
+ return {'CANCELLED'}
+
+ # switch to object mode
+ is_editmode = context.object and context.object.mode == 'EDIT'
if is_editmode:
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
- PREF_ACT_ONLY = kwargs.pop("PREF_ACT_ONLY")
-
+ # define list of meshes
meshes = []
if PREF_ACT_ONLY:
obj = context.scene.objects.active
@@ -579,6 +591,7 @@ def unwrap(operator, context, **kwargs):
lightmap_uvpack(meshes, **kwargs)
+ # switch back to edit mode
if is_editmode:
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index f18464a6614..b0a5e19d269 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -19,13 +19,17 @@
# <pep8 compliant>
import bpy
-from bpy.types import Operator
+from bpy.types import (
+ Operator,
+ OperatorFileListElement
+)
from bpy.props import (
BoolProperty,
EnumProperty,
FloatProperty,
IntProperty,
StringProperty,
+ CollectionProperty,
)
from bpy.app.translations import pgettext_tip as tip_
@@ -55,6 +59,15 @@ rna_relative_prop = BoolProperty(
default=False,
)
+rna_space_type_prop = EnumProperty(
+ name="Type",
+ items=tuple(
+ (e.identifier, e.name, "", e. value)
+ for e in bpy.types.Space.bl_rna.properties["type"].enum_items
+ ),
+ default='EMPTY',
+ )
+
def context_path_validate(context, data_path):
try:
@@ -2335,21 +2348,29 @@ class WM_OT_tool_set_by_name(Operator):
name="Text",
description="Display name of the tool",
)
- space_type = EnumProperty(
- name="Type",
- items=tuple(
- (e.identifier, e.name, "", e. value)
- for e in bpy.types.Space.bl_rna.properties["type"].enum_items
- ),
- default='EMPTY',
+
+ cycle = BoolProperty(
+ name="Cycle",
+ description="Cycle through tools in this group",
+ default=False,
+ options={'SKIP_SAVE'},
)
+ space_type = rna_space_type_prop
+
def execute(self, context):
- from bl_ui.space_toolsystem_common import activate_by_name
- space_type = self.space_type
- if space_type == 'EMPTY':
+ from bl_ui.space_toolsystem_common import (
+ activate_by_name,
+ activate_by_name_or_cycle,
+ )
+
+ if self.properties.is_property_set("space_type"):
+ space_type = self.space_type
+ else:
space_type = context.space_data.type
- if activate_by_name(context, space_type, self.name):
+
+ fn = activate_by_name_or_cycle if self.cycle else activate_by_name
+ if fn(context, space_type, self.name):
return {'FINISHED'}
else:
self.report({'WARNING'}, f"Tool {self.name!r} not found.")
@@ -2369,9 +2390,7 @@ class WM_OT_toolbar(Operator):
cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type)
if cls is None:
- # self.report({'WARNING'}, f"Toolbar not found for {space_type!r}")
- # Passthrough to running search directly.
- bpy.ops.wm.search_menu('INVOKE_DEFAULT')
+ self.report({'WARNING'}, f"Toolbar not found for {space_type!r}")
return {'CANCELLED'}
wm = context.window_manager
@@ -2379,15 +2398,126 @@ class WM_OT_toolbar(Operator):
def draw_menu(popover, context):
layout = popover.layout
- cls.draw_cls(layout, context, detect_layout=False)
-
- layout.operator_context = 'INVOKE_DEFAULT'
- layout.operator("wm.search_menu")
+ cls.draw_cls(layout, context, detect_layout=False, scale_y=1.0)
wm.popover(draw_menu, keymap=keymap)
return {'FINISHED'}
+# Studio Light operations
+class WM_OT_studiolight_install(Operator):
+ """Install a user defined studio light"""
+ bl_idname = "wm.studiolight_install"
+ bl_label = "Install Custom Studio Light"
+
+ files = CollectionProperty(
+ name="File Path",
+ type=OperatorFileListElement,
+ )
+ directory = StringProperty(
+ subtype='DIR_PATH',
+ )
+ filter_folder = BoolProperty(
+ name="Filter folders",
+ default=True,
+ options={'HIDDEN'},
+ )
+ filter_glob = StringProperty(
+ default="*.png;*.jpg;*.hdr;*.exr",
+ options={'HIDDEN'},
+ )
+ orientation = EnumProperty(
+ items=(
+ ("MATCAP", "MatCap", ""),
+ ("WORLD", "World", ""),
+ ("CAMERA", "Camera", ""),
+ )
+ )
+
+ def execute(self, context):
+ import traceback
+ import shutil
+ import pathlib
+ userpref = context.user_preferences
+
+ filepaths = [pathlib.Path(self.directory, e.name) for e in self.files]
+ path_studiolights = bpy.utils.user_resource('DATAFILES')
+
+ if not path_studiolights:
+ self.report({'ERROR'}, "Failed to get Studio Light path")
+ return {'CANCELLED'}
+
+ path_studiolights = pathlib.Path(path_studiolights, "studiolights", self.orientation.lower())
+ if not path_studiolights.exists():
+ try:
+ path_studiolights.mkdir(parents=True, exist_ok=True)
+ except:
+ traceback.print_exc()
+
+ for filepath in filepaths:
+ shutil.copy(str(filepath), str(path_studiolights))
+ userpref.studio_lights_refresh()
+
+ # print message
+ msg = (
+ tip_("StudioLight Installed %r into %r") %
+ (", ".join(str(x.name) for x in self.files), str(path_studiolights))
+ )
+ print(msg)
+ self.report({'INFO'}, msg)
+ return {'FINISHED'}
+
+ def invoke(self, context, event):
+ wm = context.window_manager
+ wm.fileselect_add(self)
+ return {'RUNNING_MODAL'}
+
+
+class WM_OT_studiolight_uninstall(Operator):
+ bl_idname = 'wm.studiolight_uninstall'
+ bl_label = "Uninstall Studio Light"
+ index = bpy.props.IntProperty()
+
+ def execute(self, context):
+ import pathlib
+ userpref = context.user_preferences
+ for studio_light in userpref.studio_lights:
+ if studio_light.index == self.index:
+ path = pathlib.Path(studio_light.path)
+ if path.exists():
+ path.unlink()
+ userpref.studio_lights_refresh()
+ return {'FINISHED'}
+ return {'CANCELLED'}
+
+
+class WM_OT_studiolight_expand(Operator):
+ bl_idname = "wm.studiolight_expand"
+ bl_label = "Expand Studio Light"
+ index = bpy.props.IntProperty()
+
+ def execute(self, context):
+ userpref = context.user_preferences
+ for studio_light in userpref.studio_lights:
+ if studio_light.index == self.index:
+ studio_light.show_expanded = not studio_light.show_expanded
+ break
+
+ return {'FINISHED'}
+
+
+class WM_OT_studiolight_userpref_show(Operator):
+ """Show light user preferences"""
+ bl_idname = "wm.studiolight_userpref_show"
+ bl_label = ""
+ bl_options = {'INTERNAL'}
+
+ def execute(self, context):
+ context.user_preferences.active_section = 'LIGHTS'
+ bpy.ops.screen.userpref_show('INVOKE_DEFAULT')
+ return {'FINISHED'}
+
+
classes = (
BRUSH_OT_active_index_set,
WM_OT_addon_disable,
@@ -2442,6 +2572,10 @@ classes = (
WM_OT_owner_disable,
WM_OT_owner_enable,
WM_OT_url_open,
+ WM_OT_studiolight_expand,
+ WM_OT_studiolight_install,
+ WM_OT_studiolight_uninstall,
+ WM_OT_studiolight_userpref_show,
WM_OT_tool_set_by_name,
WM_OT_toolbar,
)
diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index dd99195f12a..da9054fb681 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -88,7 +88,7 @@ _modules = [
"space_userpref",
"space_view3d",
"space_view3d_toolbar",
- ]
+]
import bpy
@@ -167,6 +167,8 @@ def unregister():
# Define a default UIList, when a list does not need any custom drawing...
# Keep in sync with its #defined name in UI_interface.h
+
+
class UI_UL_list(bpy.types.UIList):
# These are common filtering or ordering operations (same as the default C ones!).
@staticmethod
diff --git a/release/scripts/startup/bl_ui/properties_animviz.py b/release/scripts/startup/bl_ui/properties_animviz.py
index 9782d5a072c..901e15c181a 100644
--- a/release/scripts/startup/bl_ui/properties_animviz.py
+++ b/release/scripts/startup/bl_ui/properties_animviz.py
@@ -37,27 +37,26 @@ class MotionPathButtonsPanel:
mps = avs.motion_path
# Display Range
- layout.row().prop(mps, "type", expand=True)
+ layout.use_property_split = True
+ layout.row().prop(mps, "type")
- split = layout.split()
+ col = layout.column()
- col = split.column()
- col.label(text="Display Range:")
sub = col.column(align=True)
if mps.type == 'CURRENT_FRAME':
- sub.prop(mps, "frame_before", text="Before")
+ sub.prop(mps, "frame_before", text="Frame Range Before")
sub.prop(mps, "frame_after", text="After")
elif mps.type == 'RANGE':
- sub.prop(mps, "frame_start", text="Start")
+ sub.prop(mps, "frame_start", text="Frame Range Start")
sub.prop(mps, "frame_end", text="End")
sub.prop(mps, "frame_step", text="Step")
- col = split.column()
+ col = layout.column(align=True)
if bones:
col.label(text="Cache for Bone:")
else:
- col.label(text="Cache:")
+ col.label(text="Cache")
if mpath:
sub = col.column(align=True)
@@ -81,17 +80,15 @@ class MotionPathButtonsPanel:
sub.operator("object.paths_calculate", text="Calculate...", icon='OBJECT_DATA')
# Display Settings
- split = layout.split()
- col = split.column()
- col.label(text="Show:")
+ layout.label(text="Display")
+
+ col = layout.column()
col.prop(mps, "show_frame_numbers", text="Frame Numbers")
if mpath is not None:
col.prop(mpath, "lines", text="Lines")
col.prop(mpath, "line_thickness", text="Thickness")
- col = split.column()
- col.label("")
col.prop(mps, "show_keyframe_highlight", text="Keyframes")
sub = col.column()
sub.enabled = mps.show_keyframe_highlight
@@ -101,11 +98,11 @@ class MotionPathButtonsPanel:
# Customize path
if mpath is not None:
- row = layout.row(align=True)
- row.prop(mpath, "use_custom_color", text="", toggle=True, icon='COLOR')
- sub = row.row(align=True)
+
+ col.prop(mpath, "use_custom_color", text="Custom Color")
+ sub = col.column()
sub.enabled = mpath.use_custom_color
- sub.prop(mpath, "color", text="")
+ sub.prop(mpath, "color")
# FIXME: this panel still needs to be ported so that it will work correctly with animviz
diff --git a/release/scripts/startup/bl_ui/properties_constraint.py b/release/scripts/startup/bl_ui/properties_constraint.py
index 9b61101778f..b7880e605b3 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -941,6 +941,7 @@ class BONE_PT_constraints(ConstraintButtonsPanel, Panel):
for con in context.pose_bone.constraints:
self.draw_constraint(context, con)
+
classes = (
OBJECT_PT_constraints,
BONE_PT_constraints,
diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py
index 12f862d92a1..e58b4f56ffe 100644
--- a/release/scripts/startup/bl_ui/properties_data_armature.py
+++ b/release/scripts/startup/bl_ui/properties_data_armature.py
@@ -77,15 +77,13 @@ class DATA_PT_display(ArmatureButtonsPanel, Panel):
layout.row().prop(arm, "draw_type", expand=True)
- split = layout.split()
+ layout.use_property_split = True
- col = split.column()
+ col = layout.column()
col.prop(arm, "show_names", text="Names")
col.prop(arm, "show_axes", text="Axes")
col.prop(arm, "show_bone_custom_shapes", text="Shapes")
-
- col = split.column()
- col.prop(arm, "show_group_colors", text="Colors")
+ col.prop(arm, "show_group_colors", text="Group Colors")
if ob:
col.prop(ob, "show_x_ray", text="X-Ray")
col.prop(arm, "use_deform_delay", text="Delay Refresh")
@@ -149,7 +147,8 @@ class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel):
sub = row.row(align=True)
sub.operator("pose.group_assign", text="Assign")
- sub.operator("pose.group_unassign", text="Remove") # row.operator("pose.bone_group_remove_from", text="Remove")
+ # row.operator("pose.bone_group_remove_from", text="Remove")
+ sub.operator("pose.group_unassign", text="Remove")
sub = row.row(align=True)
sub.operator("pose.group_select", text="Select")
@@ -196,7 +195,11 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
if pose_marker_active is not None:
col.operator("poselib.pose_remove", icon='ZOOMOUT', text="")
- col.operator("poselib.apply_pose", icon='ZOOM_SELECTED', text="").pose_index = poselib.pose_markers.active_index
+ col.operator(
+ "poselib.apply_pose",
+ icon='ZOOM_SELECTED',
+ text="",
+ ).pose_index = poselib.pose_markers.active_index
col.operator("poselib.action_sanitize", icon='HELP', text="") # XXX: put in menu?
@@ -216,21 +219,19 @@ class DATA_PT_ghost(ArmatureButtonsPanel, Panel):
layout.row().prop(arm, "ghost_type", expand=True)
- split = layout.split()
+ layout.use_property_split = True
- col = split.column(align=True)
+ col = layout.column(align=True)
if arm.ghost_type == 'RANGE':
- col.prop(arm, "ghost_frame_start", text="Start")
+ col.prop(arm, "ghost_frame_start", text="Frame Start")
col.prop(arm, "ghost_frame_end", text="End")
col.prop(arm, "ghost_size", text="Step")
elif arm.ghost_type == 'CURRENT_FRAME':
- col.prop(arm, "ghost_step", text="Range")
+ col.prop(arm, "ghost_step", text="Frame Range")
col.prop(arm, "ghost_size", text="Step")
- col = split.column()
- col.label(text="Display:")
- col.prop(arm, "show_only_ghost_selected", text="Selected Only")
+ col.prop(arm, "show_only_ghost_selected", text="Display Selected Only")
class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, Panel):
@@ -244,6 +245,7 @@ class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
ob = context.object
itasc = ob.pose.ik_param
@@ -251,34 +253,37 @@ class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, Panel):
layout.prop(ob.pose, "ik_solver")
if itasc:
+ layout.use_property_split = False
layout.row().prop(itasc, "mode", expand=True)
+ layout.use_property_split = True
simulation = (itasc.mode == 'SIMULATION')
if simulation:
- layout.label(text="Reiteration:")
- layout.row().prop(itasc, "reiteration_method", expand=True)
+ layout.prop(itasc, "reiteration_method", expand=False)
- row = layout.row()
- row.active = not simulation or itasc.reiteration_method != 'NEVER'
- row.prop(itasc, "precision")
- row.prop(itasc, "iterations")
+ col = layout.column()
+ col.active = not simulation or itasc.reiteration_method != 'NEVER'
+ col.prop(itasc, "precision")
+ col.prop(itasc, "iterations")
if simulation:
layout.prop(itasc, "use_auto_step")
- row = layout.row()
+ col = layout.column(align=True)
if itasc.use_auto_step:
- row.prop(itasc, "step_min", text="Min")
- row.prop(itasc, "step_max", text="Max")
+ col.prop(itasc, "step_min", text="Steps Min")
+ col.prop(itasc, "step_max", text="Max")
else:
- row.prop(itasc, "step_count")
+ col.prop(itasc, "step_count", text="Steps")
layout.prop(itasc, "solver")
if simulation:
layout.prop(itasc, "feedback")
layout.prop(itasc, "velocity_max")
if itasc.solver == 'DLS':
- row = layout.row()
- row.prop(itasc, "damping_max", text="Damp", slider=True)
- row.prop(itasc, "damping_epsilon", text="Eps", slider=True)
+ col = layout.column()
+ col.separator()
+ col.prop(itasc, "damping_max", text="Damping Max", slider=True)
+ col.prop(itasc, "damping_epsilon", text="Damping Epsilon", slider=True)
+
from .properties_animviz import (
MotionPathButtonsPanel,
diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py b/release/scripts/startup/bl_ui/properties_data_bone.py
index e1763e363ae..079669dbd02 100644
--- a/release/scripts/startup/bl_ui/properties_data_bone.py
+++ b/release/scripts/startup/bl_ui/properties_data_bone.py
@@ -62,88 +62,63 @@ class BONE_PT_transform(BoneButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
ob = context.object
bone = context.bone
+ col = layout.column()
+
if bone and ob:
pchan = ob.pose.bones[bone.name]
-
- row = layout.row()
- col = row.column()
- col.prop(pchan, "location")
col.active = not (bone.parent and bone.use_connect)
- col = row.column()
+ sub = col.row(align=True)
+ sub.prop(pchan, "location")
+ sub.prop(pchan, "lock_location", text="")
+
+ col = layout.column()
if pchan.rotation_mode == 'QUATERNION':
- col.prop(pchan, "rotation_quaternion", text="Rotation")
+ sub = col.row(align=True)
+ sub.prop(pchan, "rotation_quaternion", text="Rotation")
+ subsub = sub.column(align=True)
+ subsub.prop(pchan, "lock_rotation_w", text="")
+ subsub.prop(pchan, "lock_rotation", text="")
elif pchan.rotation_mode == 'AXIS_ANGLE':
- #col.label(text="Rotation")
+ # col.label(text="Rotation")
#col.prop(pchan, "rotation_angle", text="Angle")
#col.prop(pchan, "rotation_axis", text="Axis")
- col.prop(pchan, "rotation_axis_angle", text="Rotation")
+ sub = col.row(align=True)
+ sub.prop(pchan, "rotation_axis_angle", text="Rotation")
+ subsub = sub.column(align=True)
+ subsub.prop(pchan, "lock_rotation_w", text="")
+ subsub.prop(pchan, "lock_rotation", text="")
else:
- col.prop(pchan, "rotation_euler", text="Rotation")
+ sub = col.row(align=True)
+ sub.prop(pchan, "rotation_euler", text="Rotation")
+ sub.prop(pchan, "lock_rotation", text="")
- row.column().prop(pchan, "scale")
+ col = layout.column()
+ sub = col.row(align=True)
+ sub.prop(pchan, "scale")
+ sub.prop(pchan, "lock_scale", text="")
- layout.prop(pchan, "rotation_mode")
+ col = layout.column()
+ col.prop(pchan, "rotation_mode")
elif context.edit_bone:
bone = context.edit_bone
- row = layout.row()
- row.column().prop(bone, "head")
- row.column().prop(bone, "tail")
-
- col = row.column()
- sub = col.column(align=True)
- sub.label(text="Roll:")
- sub.prop(bone, "roll", text="")
- sub.label()
- sub.prop(bone, "lock")
-
-
-class BONE_PT_transform_locks(BoneButtonsPanel, Panel):
- bl_label = "Transform Locks"
- bl_options = {'DEFAULT_CLOSED'}
-
- @classmethod
- def poll(cls, context):
- ob = context.object
- return ob and ob.mode == 'POSE' and context.bone
-
- def draw(self, context):
- layout = self.layout
-
- ob = context.object
- bone = context.bone
- pchan = ob.pose.bones[bone.name]
-
- split = layout.split(percentage=0.1)
-
- col = split.column(align=True)
- col.label(text="")
- col.label(text="X:")
- col.label(text="Y:")
- col.label(text="Z:")
-
- col = split.column()
- col.active = not (bone.parent and bone.use_connect)
- col.prop(pchan, "lock_location", text="Location")
-
- col = split.column()
- col.prop(pchan, "lock_rotation", text="Rotation")
-
- col = split.column()
- col.prop(pchan, "lock_scale", text="Scale")
+ col = layout.column()
+ col.prop(bone, "head")
+ col.prop(bone, "tail")
- if pchan.rotation_mode in {'QUATERNION', 'AXIS_ANGLE'}:
- row = layout.row()
- row.prop(pchan, "lock_rotations_4d", text="Lock Rotation")
+ col = layout.column()
+ col.prop(bone, "roll")
+ col.prop(bone, "lock")
- sub = row.row()
- sub.active = pchan.lock_rotations_4d
- sub.prop(pchan, "lock_rotation_w", text="W")
+ col = layout.column()
+ col.prop(bone, "tail_radius")
+ col.prop(bone, "envelope_distance")
class BONE_PT_curved(BoneButtonsPanel, Panel):
@@ -166,54 +141,52 @@ class BONE_PT_curved(BoneButtonsPanel, Panel):
bbone = bone
layout = self.layout
+ layout.use_property_split = True
+
layout.prop(bone, "bbone_segments", text="Segments")
col = layout.column()
col.active = bone.bbone_segments > 1
- row = col.row()
- sub = row.column(align=True)
- sub.label(text="Curve XY Offsets:")
- sub.prop(bbone, "bbone_curveinx", text="In X")
- sub.prop(bbone, "bbone_curveoutx", text="Out X")
- sub.prop(bbone, "bbone_curveiny", text="In Y")
- sub.prop(bbone, "bbone_curveouty", text="Out Y")
-
- sub = row.column(align=True)
- sub.label("Roll:")
- sub.prop(bbone, "bbone_rollin", text="In")
- sub.prop(bbone, "bbone_rollout", text="Out")
- sub.prop(bone, "use_endroll_as_inroll")
-
- row = col.row()
- sub = row.column(align=True)
- sub.label(text="Scale:")
- sub.prop(bbone, "bbone_scalein", text="In")
- sub.prop(bbone, "bbone_scaleout", text="Out")
-
- sub = row.column(align=True)
- sub.label("Easing:")
- sub.prop(bbone, "bbone_easein", text="In")
- sub.prop(bbone, "bbone_easeout", text="Out")
+ col = layout.column(align=True)
+ col.prop(bbone, "bbone_curveinx", text="Curve In X")
+ col.prop(bbone, "bbone_curveiny", text="In Y")
+
+ col = layout.column(align=True)
+ col.prop(bbone, "bbone_curveoutx", text="Curve Out X")
+ col.prop(bbone, "bbone_curveouty", text="Out Y")
+
+ col = layout.column(align=True)
+ col.prop(bbone, "bbone_rollin", text="Roll In")
+ col.prop(bbone, "bbone_rollout", text="Out")
+ col.prop(bone, "use_endroll_as_inroll")
+
+ col = layout.column(align=True)
+ col.prop(bbone, "bbone_scalein", text="Scale In")
+ col.prop(bbone, "bbone_scaleout", text="Out")
+
+ col = layout.column(align=True)
+ col.prop(bbone, "bbone_easein", text="Ease In")
+ col.prop(bbone, "bbone_easeout", text="Out")
if pchan:
layout.separator()
col = layout.column()
+ col.use_property_split = False
col.prop(pchan, "use_bbone_custom_handles")
- row = col.row()
- row.active = pchan.use_bbone_custom_handles
+ col = layout.column(align=True)
+ col.active = pchan.use_bbone_custom_handles
+ col.use_property_split = True
- sub = row.column(align=True)
- sub.label(text="In:")
- sub.prop_search(pchan, "bbone_custom_handle_start", ob.pose, "bones", text="")
- sub.prop(pchan, "use_bbone_relative_start_handle", text="Relative")
+ sub = col.column()
+ sub.prop_search(pchan, "bbone_custom_handle_start", ob.pose, "bones", text="Custom Handle Start")
+ sub.prop_search(pchan, "bbone_custom_handle_end", ob.pose, "bones", text="End")
- sub = row.column(align=True)
- sub.label(text="Out:")
- sub.prop_search(pchan, "bbone_custom_handle_end", ob.pose, "bones", text="")
- sub.prop(pchan, "use_bbone_relative_end_handle", text="Relative")
+ sub = col.column(align=True)
+ sub.prop(pchan, "use_bbone_relative_start_handle", text="Relative Handle Start")
+ sub.prop(pchan, "use_bbone_relative_end_handle", text="End")
class BONE_PT_relations(BoneButtonsPanel, Panel):
@@ -221,6 +194,7 @@ class BONE_PT_relations(BoneButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
ob = context.object
bone = context.bone
@@ -232,26 +206,22 @@ class BONE_PT_relations(BoneButtonsPanel, Panel):
elif bone is None:
bone = context.edit_bone
- split = layout.split()
-
- col = split.column()
- col.label(text="Layers:")
+ col = layout.column()
+ col.use_property_split = False
col.prop(bone, "layers", text="")
+ col.use_property_split = True
+ col = layout.column()
col.separator()
- if ob and pchan:
- col.label(text="Bone Group:")
- col.prop_search(pchan, "bone_group", ob.pose, "bone_groups", text="")
- col.label(text="Object Children:")
- col.prop(bone, "use_relative_parent")
-
- col = split.column()
- col.label(text="Parent:")
if context.bone:
- col.prop(bone, "parent", text="")
+ col.prop(bone, "parent")
else:
- col.prop_search(bone, "parent", arm, "edit_bones", text="")
+ col.prop_search(bone, "parent", arm, "edit_bones")
+
+ if ob and pchan:
+ col.prop(bone, "use_relative_parent")
+ col.prop_search(pchan, "bone_group", ob.pose, "bone_groups", text="Bone Group")
sub = col.column()
sub.active = (bone.parent is not None)
@@ -274,6 +244,7 @@ class BONE_PT_display(BoneButtonsPanel, Panel):
# note. this works ok in edit-mode but isn't
# all that useful so disabling for now.
layout = self.layout
+ layout.use_property_split = True
ob = context.object
bone = context.bone
@@ -285,23 +256,20 @@ class BONE_PT_display(BoneButtonsPanel, Panel):
bone = context.edit_bone
if bone:
- split = layout.split()
- col = split.column()
+ col = layout.column()
col.prop(bone, "hide", text="Hide")
sub = col.column()
sub.active = bool(pchan and pchan.custom_shape)
sub.prop(bone, "show_wire", text="Wireframe")
if pchan:
- col = split.column()
-
- col.label(text="Custom Shape:")
- col.prop(pchan, "custom_shape", text="")
+ col = layout.column()
+ col.prop(pchan, "custom_shape")
if pchan.custom_shape:
col.prop(pchan, "use_custom_shape_bone_size", text="Bone Size")
col.prop(pchan, "custom_shape_scale", text="Scale")
- col.prop_search(pchan, "custom_shape_transform", ob.pose, "bones", text="At")
+ col.prop_search(pchan, "custom_shape_transform", ob.pose, "bones")
class BONE_PT_inverse_kinematics(BoneButtonsPanel, Panel):
@@ -315,80 +283,82 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
ob = context.object
bone = context.bone
pchan = ob.pose.bones[bone.name]
- row = layout.row()
-
active = pchan.is_in_ik_chain
- split = layout.split(percentage=0.25)
- split.prop(pchan, "lock_ik_x", text="X")
- split.active = active
- row = split.row()
- row.prop(pchan, "ik_stiffness_x", text="Stiffness", slider=True)
- row.active = pchan.lock_ik_x is False and active
+ col = layout.column()
+ col.prop(pchan, "ik_stretch", slider=True)
+ col.active = active
+
+ layout.separator()
+
+ col = layout.column(align=True)
- split = layout.split(percentage=0.25)
- sub = split.row()
+ col.prop(pchan, "lock_ik_x", text="Lock IK X")
+ col.prop(pchan, "lock_ik_y", text="Y")
+ col.prop(pchan, "lock_ik_z", text="Z")
- sub.prop(pchan, "use_ik_limit_x", text="Limit")
+ col = layout.column(align=True)
+
+ sub = col.column(align=True)
sub.active = pchan.lock_ik_x is False and active
- sub = split.row(align=True)
- sub.prop(pchan, "ik_min_x", text="")
- sub.prop(pchan, "ik_max_x", text="")
- sub.active = pchan.lock_ik_x is False and pchan.use_ik_limit_x and active
+ sub.prop(pchan, "ik_stiffness_x", text="Stiffness X", slider=True)
+ sub = col.column(align=True)
+ sub.active = pchan.lock_ik_y is False and active
+ sub.prop(pchan, "ik_stiffness_y", text="Y", slider=True)
+ sub = col.column(align=True)
+ sub.active = pchan.lock_ik_z is False and active
+ sub.prop(pchan, "ik_stiffness_z", text="Z", slider=True)
+
+ col = layout.column(align=True)
- split = layout.split(percentage=0.25)
- split.prop(pchan, "lock_ik_y", text="Y")
- split.active = active
- row = split.row()
- row.prop(pchan, "ik_stiffness_y", text="Stiffness", slider=True)
- row.active = pchan.lock_ik_y is False and active
+ sub = col.column()
+ sub.active = pchan.lock_ik_x is False and active
+ sub.prop(pchan, "use_ik_limit_x", text="Limit X")
- split = layout.split(percentage=0.25)
- sub = split.row()
+ sub = col.column(align=True)
+ sub.active = pchan.lock_ik_x is False and pchan.use_ik_limit_x and active
+ sub.prop(pchan, "ik_min_x", text="Min")
+ sub.prop(pchan, "ik_max_x", text="Max")
+
+ col.separator()
- sub.prop(pchan, "use_ik_limit_y", text="Limit")
+ sub = col.column()
sub.active = pchan.lock_ik_y is False and active
+ sub.prop(pchan, "use_ik_limit_y", text="Limit Y")
- sub = split.row(align=True)
- sub.prop(pchan, "ik_min_y", text="")
- sub.prop(pchan, "ik_max_y", text="")
+ sub = col.column(align=True)
sub.active = pchan.lock_ik_y is False and pchan.use_ik_limit_y and active
+ sub.prop(pchan, "ik_min_y", text="Min")
+ sub.prop(pchan, "ik_max_y", text="Max")
- split = layout.split(percentage=0.25)
- split.prop(pchan, "lock_ik_z", text="Z")
- split.active = active
- sub = split.row()
- sub.prop(pchan, "ik_stiffness_z", text="Stiffness", slider=True)
- sub.active = pchan.lock_ik_z is False and active
-
- split = layout.split(percentage=0.25)
- sub = split.row()
+ col.separator()
- sub.prop(pchan, "use_ik_limit_z", text="Limit")
+ sub = col.column()
sub.active = pchan.lock_ik_z is False and active
- sub = split.row(align=True)
- sub.prop(pchan, "ik_min_z", text="")
- sub.prop(pchan, "ik_max_z", text="")
+ sub.prop(pchan, "use_ik_limit_z", text="Limit Z")
+
+ sub = col.column(align=True)
sub.active = pchan.lock_ik_z is False and pchan.use_ik_limit_z and active
+ sub.prop(pchan, "ik_min_z", text="Min")
+ sub.prop(pchan, "ik_max_z", text="Max")
- split = layout.split(percentage=0.25)
- split.label(text="Stretch:")
- sub = split.row()
- sub.prop(pchan, "ik_stretch", text="", slider=True)
- sub.active = active
+ col.separator()
if ob.pose.ik_solver == 'ITASC':
- split = layout.split()
- col = split.column()
+
+ col = layout.column()
col.prop(pchan, "use_ik_rotation_control", text="Control Rotation")
col.active = active
- col = split.column()
- col.prop(pchan, "ik_rotation_weight", text="Weight", slider=True)
+
+ col = layout.column()
+
+ col.prop(pchan, "ik_rotation_weight", text="IK Rotation Weight", slider=True)
col.active = active
# not supported yet
#row = layout.row()
@@ -410,6 +380,7 @@ class BONE_PT_deform(BoneButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
bone = context.bone
@@ -418,17 +389,15 @@ class BONE_PT_deform(BoneButtonsPanel, Panel):
layout.active = bone.use_deform
- row = layout.row()
+ col = layout.column()
+ col.prop(bone, "envelope_distance", text="Envelope Distance")
+ col.prop(bone, "envelope_weight", text="Envelope Weight")
+ col.prop(bone, "use_envelope_multiply", text="Envelope Multiply")
- col = row.column(align=True)
- col.label(text="Envelope:")
- col.prop(bone, "envelope_distance", text="Distance")
- col.prop(bone, "envelope_weight", text="Weight")
- col.prop(bone, "use_envelope_multiply", text="Multiply")
+ col.separator()
- col = row.column(align=True)
- col.label(text="Envelope Radius:")
- col.prop(bone, "head_radius", text="Head")
+ col = layout.column(align=True)
+ col.prop(bone, "head_radius", text="Radius Head")
col.prop(bone, "tail_radius", text="Tail")
@@ -448,7 +417,6 @@ class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel, Panel):
classes = (
BONE_PT_context_bone,
BONE_PT_transform,
- BONE_PT_transform_locks,
BONE_PT_curved,
BONE_PT_relations,
BONE_PT_display,
diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py
index 58cbcec25ca..e81fc393af8 100644
--- a/release/scripts/startup/bl_ui/properties_data_camera.py
+++ b/release/scripts/startup/bl_ui/properties_data_camera.py
@@ -76,21 +76,22 @@ class DATA_PT_lens(CameraButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
cam = context.camera
- layout.row().prop(cam, "type", expand=True)
+ layout.prop(cam, "type")
- split = layout.split()
+ col = layout.column()
+ col.separator()
- col = split.column()
if cam.type == 'PERSP':
- row = col.row()
+ col = layout.column()
if cam.lens_unit == 'MILLIMETERS':
- row.prop(cam, "lens")
+ col.prop(cam, "lens")
elif cam.lens_unit == 'FOV':
row.prop(cam, "angle")
- row.prop(cam, "lens_unit", text="")
+ col.prop(cam, "lens_unit")
elif cam.type == 'ORTHO':
col.prop(cam, "ortho_scale")
@@ -99,40 +100,37 @@ class DATA_PT_lens(CameraButtonsPanel, Panel):
engine = context.engine
if engine == 'CYCLES':
ccam = cam.cycles
- col.prop(ccam, "panorama_type", text="Type")
+ col.prop(ccam, "panorama_type")
if ccam.panorama_type == 'FISHEYE_EQUIDISTANT':
col.prop(ccam, "fisheye_fov")
elif ccam.panorama_type == 'FISHEYE_EQUISOLID':
- row = layout.row()
- row.prop(ccam, "fisheye_lens", text="Lens")
- row.prop(ccam, "fisheye_fov")
+ col.prop(ccam, "fisheye_lens", text="Lens")
+ col.prop(ccam, "fisheye_fov")
elif ccam.panorama_type == 'EQUIRECTANGULAR':
- row = layout.row()
- sub = row.column(align=True)
- sub.prop(ccam, "latitude_min")
- sub.prop(ccam, "latitude_max")
- sub = row.column(align=True)
- sub.prop(ccam, "longitude_min")
- sub.prop(ccam, "longitude_max")
+ sub = col.column(align=True)
+ sub.prop(ccam, "latitude_min", text="Latitute Min")
+ sub.prop(ccam, "latitude_max", text="Max")
+ sub = col.column(align=True)
+ sub.prop(ccam, "longitude_min", text="Longiture Min")
+ sub.prop(ccam, "longitude_max", text="Max")
elif engine in {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}:
- row = col.row()
if cam.lens_unit == 'MILLIMETERS':
- row.prop(cam, "lens")
+ col.prop(cam, "lens")
elif cam.lens_unit == 'FOV':
- row.prop(cam, "angle")
- row.prop(cam, "lens_unit", text="")
+ col.prop(cam, "angle")
+ col.prop(cam, "lens_unit")
- split = layout.split()
+ col = layout.column()
+ col.separator()
- col = split.column(align=True)
- col.label(text="Shift:")
- col.prop(cam, "shift_x", text="X")
- col.prop(cam, "shift_y", text="Y")
+ sub = col.column(align=True)
+ sub.prop(cam, "shift_x", text="Shift X")
+ sub.prop(cam, "shift_y", text="Y")
- col = split.column(align=True)
- col.label(text="Clipping:")
- col.prop(cam, "clip_start", text="Start")
- col.prop(cam, "clip_end", text="End")
+ col.separator()
+ sub = col.column(align=True)
+ sub.prop(cam, "clip_start", text="Clip Start")
+ sub.prop(cam, "clip_end", text="End")
class DATA_PT_camera_stereoscopy(CameraButtonsPanel, Panel):
@@ -147,6 +145,8 @@ class DATA_PT_camera_stereoscopy(CameraButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+
render = context.scene.render
st = context.camera.stereo
cam = context.camera
@@ -154,9 +154,9 @@ class DATA_PT_camera_stereoscopy(CameraButtonsPanel, Panel):
is_spherical_stereo = cam.type != 'ORTHO' and render.use_spherical_stereo
use_spherical_stereo = is_spherical_stereo and st.use_spherical_stereo
- col = layout.column()
- col.row().prop(st, "convergence_mode", expand=True)
+ layout.prop(st, "convergence_mode")
+ col = layout.column()
sub = col.column()
sub.active = st.convergence_mode != 'PARALLEL'
sub.prop(st, "convergence_distance")
@@ -165,20 +165,20 @@ class DATA_PT_camera_stereoscopy(CameraButtonsPanel, Panel):
if is_spherical_stereo:
col.separator()
- row = col.row()
- row.prop(st, "use_spherical_stereo")
- sub = row.row()
+ col.prop(st, "use_spherical_stereo")
+ sub = col.column()
sub.active = st.use_spherical_stereo
sub.prop(st, "use_pole_merge")
- row = col.row(align=True)
- row.active = st.use_pole_merge
- row.prop(st, "pole_merge_angle_from")
- row.prop(st, "pole_merge_angle_to")
- col.label(text="Pivot:")
- row = col.row()
- row.active = not use_spherical_stereo
- row.prop(st, "pivot", expand=True)
+ sub = col.column(align=True)
+ sub.active = st.use_pole_merge
+ sub.prop(st, "pole_merge_angle_from", text="Pole Merge Angle Start")
+ sub.prop(st, "pole_merge_angle_to", text="End")
+
+ col = layout.column()
+ col.active = not use_spherical_stereo
+ col.separator()
+ col.prop(st, "pivot")
class DATA_PT_camera(CameraButtonsPanel, Panel):
@@ -196,57 +196,68 @@ class DATA_PT_camera(CameraButtonsPanel, Panel):
row.operator("camera.preset_add", text="", icon='ZOOMIN')
row.operator("camera.preset_add", text="", icon='ZOOMOUT').remove_active = True
- layout.label(text="Sensor:")
+ layout.use_property_split = True
- split = layout.split()
+ col = layout.column()
+ col.prop(cam, "sensor_fit")
- col = split.column(align=True)
if cam.sensor_fit == 'AUTO':
- col.prop(cam, "sensor_width", text="Size")
+ col.prop(cam, "sensor_width")
else:
sub = col.column(align=True)
sub.active = cam.sensor_fit == 'HORIZONTAL'
sub.prop(cam, "sensor_width", text="Width")
+
sub = col.column(align=True)
sub.active = cam.sensor_fit == 'VERTICAL'
sub.prop(cam, "sensor_height", text="Height")
- col = split.column(align=True)
- col.prop(cam, "sensor_fit", text="")
-
class DATA_PT_camera_dof(CameraButtonsPanel, Panel):
bl_label = "Depth of Field"
+ bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
cam = context.camera
dof_options = cam.gpu_dof
- split = layout.split()
-
- col = split.column()
- col.label(text="Focus:")
- col.prop(cam, "dof_object", text="")
+ col = layout.column()
+ col.prop(cam, "dof_object", text="Focus on Object")
sub = col.column()
sub.active = (cam.dof_object is None)
- sub.prop(cam, "dof_distance", text="Distance")
+ sub.prop(cam, "dof_distance", text="Focus Distance")
+
+
+class DATA_PT_camera_dof_aperture(CameraButtonsPanel, Panel):
+ bl_label = "Aperture"
+ bl_parent_id = "DATA_PT_camera_dof"
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ cam = context.camera
+ dof_options = cam.gpu_dof
+
+ flow = layout.grid_flow(row_major=True, num_columns=0, even_columns=True, even_rows=False, align=False)
if context.engine == 'BLENDER_EEVEE':
- col = split.column(align=True)
- col.label("Aperture:")
- engine = context.engine
- sub = col.column(align=True)
- sub.prop(dof_options, "fstop")
- sub.prop(dof_options, "blades")
- sub.prop(dof_options, "rotation")
- sub.prop(dof_options, "ratio")
+ col = flow.column()
+ col.prop(dof_options, "fstop")
+ col.prop(dof_options, "blades")
+
+ col = flow.column()
+ col.prop(dof_options, "rotation")
+ col.prop(dof_options, "ratio")
else:
hq_support = dof_options.is_hq_supported
- col = split.column(align=True)
- col.label("Viewport:")
+ col = flow.column()
+ col.label("Viewport")
sub = col.column()
sub.active = hq_support
sub.prop(dof_options, "use_high_quality")
@@ -358,24 +369,21 @@ class DATA_PT_camera_background_image(CameraButtonsPanel, Panel):
class DATA_PT_camera_display(CameraButtonsPanel, Panel):
bl_label = "Display"
+ bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
cam = context.camera
split = layout.split()
+ split.label()
+ split.prop_menu_enum(cam, "show_guide")
- col = split.column()
- col.prop(cam, "show_limits", text="Limits")
- col.prop(cam, "show_mist", text="Mist")
-
- col.prop(cam, "show_sensor", text="Sensor")
- col.prop(cam, "show_name", text="Name")
+ col = layout.column(align=True)
- col = split.column()
- col.prop_menu_enum(cam, "show_guide")
col.separator()
col.prop(cam, "draw_size", text="Size")
col.separator()
@@ -384,6 +392,13 @@ class DATA_PT_camera_display(CameraButtonsPanel, Panel):
sub.active = cam.show_passepartout
sub.prop(cam, "passepartout_alpha", text="Alpha", slider=True)
+ col.separator()
+
+ col.prop(cam, "show_limits", text="Limits")
+ col.prop(cam, "show_mist", text="Mist")
+ col.prop(cam, "show_sensor", text="Sensor")
+ col.prop(cam, "show_name", text="Name")
+
class DATA_PT_camera_safe_areas(CameraButtonsPanel, Panel):
bl_label = "Safe Areas"
@@ -413,27 +428,30 @@ def draw_display_safe_settings(layout, safe_data, settings):
show_safe_areas = settings.show_safe_areas
show_safe_center = settings.show_safe_center
- split = layout.split()
+ layout.use_property_split = True
- col = split.column()
- row = col.row(align=True)
+ row = layout.row(align=True)
row.menu("SAFE_AREAS_MT_presets", text=bpy.types.SAFE_AREAS_MT_presets.bl_label)
row.operator("safe_areas.preset_add", text="", icon='ZOOMIN')
row.operator("safe_areas.preset_add", text="", icon='ZOOMOUT').remove_active = True
- col = split.column()
- col.prop(settings, "show_safe_center", text="Center-Cut Safe Areas")
+ layout.separator()
- split = layout.split()
- col = split.column()
+ col = layout.column()
col.active = show_safe_areas
- col.prop(safe_data, "title", slider=True)
- col.prop(safe_data, "action", slider=True)
- col = split.column()
- col.active = show_safe_areas and show_safe_center
- col.prop(safe_data, "title_center", slider=True)
- col.prop(safe_data, "action_center", slider=True)
+ sub = col.column()
+ sub.prop(safe_data, "title", slider=True)
+ sub.prop(safe_data, "action", slider=True)
+
+ col.separator()
+
+ col.prop(settings, "show_safe_center", text="Center-Cut Safe Areas")
+
+ sub = col.column()
+ sub.active = show_safe_areas and show_safe_center
+ sub.prop(safe_data, "title_center", slider=True)
+ sub.prop(safe_data, "action_center", slider=True)
classes = (
@@ -444,9 +462,10 @@ classes = (
DATA_PT_camera,
DATA_PT_camera_stereoscopy,
DATA_PT_camera_dof,
+ DATA_PT_camera_dof_aperture,
DATA_PT_camera_display,
- DATA_PT_camera_background_image,
DATA_PT_camera_safe_areas,
+ DATA_PT_camera_background_image,
DATA_PT_custom_props_camera,
)
diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py
index 00edc6403f9..47c53d6ffb5 100644
--- a/release/scripts/startup/bl_ui/properties_data_curve.py
+++ b/release/scripts/startup/bl_ui/properties_data_curve.py
@@ -93,43 +93,42 @@ class DATA_PT_shape_curve(CurveButtonsPanel, Panel):
row = layout.row()
row.prop(curve, "dimensions", expand=True)
- split = layout.split()
+ layout.use_property_split = True
+
+ col = layout.column()
+ sub = col.column(align=True)
+ sub.prop(curve, "resolution_u", text="Resolution Preview U")
+ if is_surf:
+ sub.prop(curve, "resolution_v", text="V")
- col = split.column()
- col.label(text="Resolution:")
sub = col.column(align=True)
- sub.prop(curve, "resolution_u", text="Preview U")
sub.prop(curve, "render_resolution_u", text="Render U")
+ if is_surf:
+ sub.prop(curve, "render_resolution_v", text="V")
+ col.separator()
+
if is_curve:
- col.label(text="Twisting:")
- col.prop(curve, "twist_mode", text="")
+ col.prop(curve, "twist_mode")
col.prop(curve, "twist_smooth", text="Smooth")
elif is_text:
- col.label(text="Display:")
col.prop(curve, "use_fast_edit", text="Fast Editing")
- col = split.column()
-
- if is_surf:
- sub = col.column()
- sub.label(text="")
- sub = col.column(align=True)
- sub.prop(curve, "resolution_v", text="Preview V")
- sub.prop(curve, "render_resolution_v", text="Render V")
-
if is_curve or is_text:
- col.label(text="Fill:")
+ col = layout.column()
+ col.separator()
+
sub = col.column()
sub.active = (curve.dimensions == '2D' or (curve.bevel_object is None and curve.dimensions == '3D'))
- sub.prop(curve, "fill_mode", text="")
+ sub.prop(curve, "fill_mode")
col.prop(curve, "use_fill_deform")
if is_curve:
- col.label(text="Path/Curve-Deform:")
+ col = layout.column()
+ col.separator()
+
sub = col.column()
- subsub = sub.row()
- subsub.prop(curve, "use_radius")
- subsub.prop(curve, "use_stretch")
+ sub.prop(curve, "use_radius")
+ sub.prop(curve, "use_stretch")
sub.prop(curve, "use_deform_bounds")
@@ -140,16 +139,17 @@ class DATA_PT_curve_texture_space(CurveButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
curve = context.curve
- row = layout.row()
- row.prop(curve, "use_auto_texspace")
- row.prop(curve, "use_uv_as_generated")
+ col = layout.column()
+ col.prop(curve, "use_uv_as_generated")
+ col.prop(curve, "use_auto_texspace")
- row = layout.row()
- row.column().prop(curve, "texspace_location", text="Location")
- row.column().prop(curve, "texspace_size", text="Size")
+ col = layout.column()
+ col.prop(curve, "texspace_location")
+ col.prop(curve, "texspace_size")
layout.operator("curve.match_texture_space")
@@ -163,49 +163,65 @@ class DATA_PT_geometry_curve(CurveButtonsPanelCurve, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
curve = context.curve
- split = layout.split()
-
- col = split.column()
- col.label(text="Modification:")
+ col = layout.column()
col.prop(curve, "offset")
- col.prop(curve, "extrude")
- col.label(text="Taper Object:")
- col.prop(curve, "taper_object", text="")
- col = split.column()
- col.label(text="Bevel:")
- col.prop(curve, "bevel_depth", text="Depth")
- col.prop(curve, "bevel_resolution", text="Resolution")
- col.label(text="Bevel Object:")
- col.prop(curve, "bevel_object", text="")
+ sub = col.column()
+ sub.active = (curve.bevel_object is None)
+ sub.prop(curve, "extrude")
+
+ col.prop(curve, "taper_object")
+
+ sub = col.column()
+ sub.active = curve.taper_object is not None
+ sub.prop(curve, "use_map_taper")
+
+
+class DATA_PT_geometry_curve_bevel(CurveButtonsPanelCurve, Panel):
+ bl_label = "Bevel"
+ bl_parent_id = "DATA_PT_geometry_curve"
+
+ @classmethod
+ def poll(cls, context):
+ return (type(context.curve) in {Curve, TextCurve})
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ curve = context.curve
+
+ col = layout.column()
+ sub = col.column()
+ sub.active = (curve.bevel_object is None)
+ sub.prop(curve, "bevel_depth", text="Depth")
+ sub.prop(curve, "bevel_resolution", text="Resolution")
+
+ col.prop(curve, "bevel_object", text="Object")
+
+ sub = col.column()
+ sub.active = curve.bevel_object is not None
+ sub.prop(curve, "use_fill_caps")
if type(curve) is not TextCurve:
- col = layout.column(align=True)
- row = col.row()
- row.label(text="Bevel Factor:")
col = layout.column()
col.active = (
- (curve.bevel_depth > 0.0) or
- (curve.extrude > 0.0) or
- (curve.bevel_object is not None))
- row = col.row(align=True)
- row.prop(curve, "bevel_factor_mapping_start", text="")
- row.prop(curve, "bevel_factor_start", text="Start")
- row = col.row(align=True)
- row.prop(curve, "bevel_factor_mapping_end", text="")
- row.prop(curve, "bevel_factor_end", text="End")
+ (curve.bevel_depth > 0.0) or
+ (curve.extrude > 0.0) or
+ (curve.bevel_object is not None)
+ )
+ sub = col.column(align=True)
+ sub.prop(curve, "bevel_factor_start", text="Bevel Start")
+ sub.prop(curve, "bevel_factor_end", text="End")
- row = layout.row()
- sub = row.row()
- sub.active = curve.taper_object is not None
- sub.prop(curve, "use_map_taper")
- sub = row.row()
- sub.active = curve.bevel_object is not None
- sub.prop(curve, "use_fill_caps")
+ sub = col.column(align=True)
+ sub.prop(curve, "bevel_factor_mapping_start", text="Bevel Mapping Start")
+ sub.prop(curve, "bevel_factor_mapping_end", text="End")
class DATA_PT_pathanim(CurveButtonsPanelCurve, Panel):
@@ -218,6 +234,7 @@ class DATA_PT_pathanim(CurveButtonsPanelCurve, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
curve = context.curve
@@ -228,8 +245,9 @@ class DATA_PT_pathanim(CurveButtonsPanelCurve, Panel):
col.prop(curve, "eval_time")
# these are for paths only
- row = layout.row()
- row.prop(curve, "use_path_follow")
+ col.separator()
+
+ col.prop(curve, "use_path_follow")
class DATA_PT_active_spline(CurveButtonsPanelActive, Panel):
@@ -237,65 +255,64 @@ class DATA_PT_active_spline(CurveButtonsPanelActive, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
curve = context.curve
act_spline = curve.splines.active
is_surf = type(curve) is SurfaceCurve
is_poly = (act_spline.type == 'POLY')
- split = layout.split()
+ col = layout.column()
if is_poly:
# These settings are below but its easier to have
# polys set aside since they use so few settings
- row = layout.row()
- row.label(text="Cyclic:")
- row.prop(act_spline, "use_cyclic_u", text="U")
- layout.prop(act_spline, "use_smooth")
+ col.prop(act_spline, "use_cyclic_u")
+ col.prop(act_spline, "use_smooth")
else:
- col = split.column()
- col.label(text="Cyclic:")
- if act_spline.type == 'NURBS':
- col.label(text="Bezier:")
- col.label(text="Endpoint:")
- col.label(text="Order:")
- col.label(text="Resolution:")
-
- col = split.column()
- col.prop(act_spline, "use_cyclic_u", text="U")
+ sub = col.column(align=True)
+ sub.prop(act_spline, "use_cyclic_u")
+ if is_surf:
+ sub.prop(act_spline, "use_cyclic_v", text="V")
if act_spline.type == 'NURBS':
- sub = col.column()
+ sub = col.column(align=True)
# sub.active = (not act_spline.use_cyclic_u)
- sub.prop(act_spline, "use_bezier_u", text="U")
- sub.prop(act_spline, "use_endpoint_u", text="U")
+ sub.prop(act_spline, "use_bezier_u", text="Bezier U")
- sub = col.column()
- sub.prop(act_spline, "order_u", text="U")
- col.prop(act_spline, "resolution_u", text="U")
+ if is_surf:
+ subsub = sub.column()
+ subsub.active = (not act_spline.use_cyclic_v)
+ subsub.prop(act_spline, "use_bezier_v", text="V")
- if is_surf:
- col = split.column()
- col.prop(act_spline, "use_cyclic_v", text="V")
+ sub = col.column(align=True)
+ sub.prop(act_spline, "use_endpoint_u", text="Endpoint U")
- # its a surface, assume its a nurbs
- sub = col.column()
- sub.active = (not act_spline.use_cyclic_v)
- sub.prop(act_spline, "use_bezier_v", text="V")
- sub.prop(act_spline, "use_endpoint_v", text="V")
- sub = col.column()
- sub.prop(act_spline, "order_v", text="V")
+ if is_surf:
+ subsub = sub.column()
+ subsub.active = (not act_spline.use_cyclic_v)
+ subsub.prop(act_spline, "use_endpoint_v", text="V")
+
+ sub = col.column(align=True)
+ sub.prop(act_spline, "order_u", text="Order U")
+
+ if is_surf:
+ sub.prop(act_spline, "order_v", text="V")
+
+ sub = col.column(align=True)
+ sub.prop(act_spline, "resolution_u", text="Resolution U")
+ if is_surf:
sub.prop(act_spline, "resolution_v", text="V")
if act_spline.type == 'BEZIER':
- col = layout.column()
- col.label(text="Interpolation:")
+
+ col.separator()
sub = col.column()
sub.active = (curve.dimensions == '3D')
- sub.prop(act_spline, "tilt_interpolation", text="Tilt")
+ sub.prop(act_spline, "tilt_interpolation", text="Interpolation Tilt")
col.prop(act_spline, "radius_interpolation", text="Radius")
@@ -324,42 +341,46 @@ class DATA_PT_font(CurveButtonsPanelText, Panel):
row.label(text="Bold & Italic")
row.template_ID(text, "font_bold_italic", open="font.open", unlink="font.unlink")
- # layout.prop(text, "font")
+ layout.separator()
- split = layout.split()
+ row = layout.row(align=True)
+ row.prop(char, "use_bold", toggle=True)
+ row.prop(char, "use_italic", toggle=True)
+ row.prop(char, "use_underline", toggle=True)
+ row.prop(char, "use_small_caps", toggle=True)
+
+
+class DATA_PT_font_transform(CurveButtonsPanelText, Panel):
+ bl_label = "Transform"
+ bl_parent_id = "DATA_PT_font"
+
+ def draw(self, context):
+ layout = self.layout
+
+ text = context.curve
+ char = context.curve.edit_format
+
+ layout.use_property_split = True
+
+ col = layout.column()
+
+ col.separator()
- col = split.column()
col.prop(text, "size", text="Size")
- col = split.column()
col.prop(text, "shear")
- split = layout.split()
-
- col = split.column()
- col.label(text="Object Font:")
- col.prop(text, "family", text="")
+ col.separator()
- col = split.column()
- col.label(text="Text on Curve:")
- col.prop(text, "follow_curve", text="")
+ col.prop(text, "family")
+ col.prop(text, "follow_curve")
- split = layout.split()
+ col.separator()
- col = split.column()
sub = col.column(align=True)
- sub.label(text="Underline:")
- sub.prop(text, "underline_position", text="Position")
- sub.prop(text, "underline_height", text="Thickness")
-
- col = split.column()
- col.label(text="Character:")
- col.prop(char, "use_bold")
- col.prop(char, "use_italic")
- col.prop(char, "use_underline")
+ sub.prop(text, "underline_position", text="Underline Position")
+ sub.prop(text, "underline_height", text="Underline Thickness")
- row = layout.row()
- row.prop(text, "small_caps_scale", text="Small Caps")
- row.prop(char, "use_small_caps")
+ col.prop(text, "small_caps_scale", text="Small Caps Scale")
class DATA_PT_paragraph(CurveButtonsPanelText, Panel):
@@ -370,23 +391,40 @@ class DATA_PT_paragraph(CurveButtonsPanelText, Panel):
text = context.curve
- layout.label(text="Horizontal Alignment:")
- layout.row().prop(text, "align_x", expand=True)
- layout.label(text="Vertical Alignment:")
+class DATA_PT_paragraph_alignment(CurveButtonsPanelText, Panel):
+ bl_parent_id = "DATA_PT_paragraph"
+ bl_label = "Alignment"
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = False
+
+ text = context.curve
+
+ layout.row().prop(text, "align_x", expand=True)
layout.row().prop(text, "align_y", expand=True)
- split = layout.split()
- col = split.column(align=True)
- col.label(text="Spacing:")
- col.prop(text, "space_character", text="Letter")
- col.prop(text, "space_word", text="Word")
- col.prop(text, "space_line", text="Line")
+class DATA_PT_paragraph_spacing(CurveButtonsPanelText, Panel):
+ bl_parent_id = "DATA_PT_paragraph"
+ bl_label = "Spacing"
- col = split.column(align=True)
- col.label(text="Offset:")
- col.prop(text, "offset_x", text="X")
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ text = context.curve
+
+ col = layout.column(align=True)
+ col.prop(text, "space_character", text="Character Spacing")
+ col.prop(text, "space_word", text="Word Spacing")
+ col.prop(text, "space_line", text="Line Spacing")
+
+ layout.separator()
+
+ col = layout.column(align=True)
+ col.prop(text, "offset_x", text="Offset X")
col.prop(text, "offset_y", text="Y")
@@ -398,10 +436,7 @@ class DATA_PT_text_boxes(CurveButtonsPanelText, Panel):
text = context.curve
- split = layout.split()
- col = split.column()
- col.operator("font.textbox_add", icon='ZOOMIN')
- col = split.column()
+ layout.operator("font.textbox_add", icon='ZOOMIN')
for i, box in enumerate(text.text_boxes):
@@ -409,19 +444,16 @@ class DATA_PT_text_boxes(CurveButtonsPanelText, Panel):
row = boxy.row()
- split = row.split()
-
- col = split.column(align=True)
-
- col.label(text="Dimensions:")
- col.prop(box, "width", text="Width")
- col.prop(box, "height", text="Height")
+ col = row.column()
+ col.use_property_split = True
- col = split.column(align=True)
+ sub = col.column(align=True)
+ sub.prop(box, "width", text="Size X")
+ sub.prop(box, "height", text="Y")
- col.label(text="Offset:")
- col.prop(box, "x", text="X")
- col.prop(box, "y", text="Y")
+ sub = col.column(align=True)
+ sub.prop(box, "x", text="Offset X")
+ sub.prop(box, "y", text="Y")
row.operator("font.textbox_remove", text="", icon='X', emboss=False).index = i
@@ -437,10 +469,14 @@ classes = (
DATA_PT_shape_curve,
DATA_PT_curve_texture_space,
DATA_PT_geometry_curve,
+ DATA_PT_geometry_curve_bevel,
DATA_PT_pathanim,
DATA_PT_active_spline,
DATA_PT_font,
+ DATA_PT_font_transform,
DATA_PT_paragraph,
+ DATA_PT_paragraph_alignment,
+ DATA_PT_paragraph_spacing,
DATA_PT_text_boxes,
DATA_PT_custom_props_curve,
)
diff --git a/release/scripts/startup/bl_ui/properties_data_empty.py b/release/scripts/startup/bl_ui/properties_data_empty.py
index c66ff87ecbd..1da3d9621aa 100644
--- a/release/scripts/startup/bl_ui/properties_data_empty.py
+++ b/release/scripts/startup/bl_ui/properties_data_empty.py
@@ -36,10 +36,11 @@ class DATA_PT_empty(DataButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
ob = context.object
- layout.prop(ob, "empty_draw_type", text="Display")
+ layout.prop(ob, "empty_draw_type", text="Display As")
if ob.empty_draw_type == 'IMAGE':
layout.template_ID(ob, "data", open="image.open", unlink="object.unlink_data")
@@ -49,9 +50,11 @@ class DATA_PT_empty(DataButtonsPanel, Panel):
row = layout.row(align=True)
layout.prop(ob, "color", text="Transparency", index=3, slider=True)
- row = layout.row(align=True)
- row.prop(ob, "empty_image_offset", text="Offset X", index=0)
- row.prop(ob, "empty_image_offset", text="Offset Y", index=1)
+ col = layout.col(align=True)
+ col.prop(ob, "empty_image_offset", text="Offset X", index=0)
+ col.prop(ob, "empty_image_offset", text="Y", index=1)
+
+ layout.separator()
layout.prop(ob, "empty_draw_size", text="Size")
diff --git a/release/scripts/startup/bl_ui/properties_data_lamp.py b/release/scripts/startup/bl_ui/properties_data_lamp.py
index 2e3dae25197..2727c84e820 100644
--- a/release/scripts/startup/bl_ui/properties_data_lamp.py
+++ b/release/scripts/startup/bl_ui/properties_data_lamp.py
@@ -80,27 +80,27 @@ class DATA_PT_lamp(DataButtonsPanel, Panel):
layout.row().prop(lamp, "type", expand=True)
- split = layout.split()
+ layout.use_property_split = True
- col = split.column()
- sub = col.column()
- sub.prop(lamp, "color", text="")
- sub.prop(lamp, "energy")
+ col = col.column()
+ col.prop(lamp, "color")
+ col.prop(lamp, "energy")
if lamp.type in {'POINT', 'SPOT'}:
- sub.label(text="Falloff:")
- sub.prop(lamp, "falloff_type", text="")
- sub.prop(lamp, "distance")
- sub.prop(lamp, "shadow_soft_size", text="Radius")
+
+ col = col.column()
+ col.label(text="Falloff")
+ col.prop(lamp, "falloff_type")
+ col.prop(lamp, "distance")
+ col.prop(lamp, "shadow_soft_size")
if lamp.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED':
- col.label(text="Attenuation Factors:")
sub = col.column(align=True)
sub.prop(lamp, "linear_attenuation", slider=True, text="Linear")
sub.prop(lamp, "quadratic_attenuation", slider=True, text="Quadratic")
elif lamp.falloff_type == 'INVERSE_COEFFICIENTS':
- col.label(text="Inverse Coefficients:")
+ col.label(text="Inverse Coefficients")
sub = col.column(align=True)
sub.prop(lamp, "constant_coefficient", text="Constant")
sub.prop(lamp, "linear_coefficient", text="Linear")
@@ -119,31 +119,31 @@ class DATA_PT_EEVEE_lamp(DataButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
-
lamp = context.lamp
layout.row().prop(lamp, "type", expand=True)
- split = layout.split()
+ layout.use_property_split = True
- col = split.column()
- sub = col.column()
- sub.prop(lamp, "color", text="")
- sub.prop(lamp, "energy")
+ col = layout.column()
+ col.prop(lamp, "color")
+ col.prop(lamp, "energy")
+ col.prop(lamp, "specular_factor", text="Specular")
+
+ col.separator()
if lamp.type in {'POINT', 'SPOT', 'SUN'}:
- sub.prop(lamp, "shadow_soft_size", text="Radius")
+ col.prop(lamp, "shadow_soft_size", text="Radius")
elif lamp.type == 'AREA':
- sub = sub.column(align=True)
- sub.prop(lamp, "shape", text="")
- if lamp.shape in {'SQUARE', 'DISK'}:
+ col.prop(lamp, "shape")
+
+ sub = col.column(align=True)
+
+ if lamp.shape in {'SQUARE', 'DISK'}:
sub.prop(lamp, "size")
elif lamp.shape in {'RECTANGLE', 'ELLIPSE'}:
sub.prop(lamp, "size", text="Size X")
- sub.prop(lamp, "size_y", text="Size Y")
-
- col = split.column()
- col.prop(lamp, "specular_factor", text="Specular")
+ sub.prop(lamp, "size_y", text="Y")
class DATA_PT_EEVEE_shadow(DataButtonsPanel, Panel):
@@ -162,49 +162,81 @@ class DATA_PT_EEVEE_shadow(DataButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
lamp = context.lamp
- split = layout.split()
- split.active = lamp.use_shadow
+ layout.active = lamp.use_shadow
+
+ col = layout.column()
+ sub = col.column(align=True)
+ sub.prop(lamp, "shadow_buffer_clip_start", text="Clip Start")
+ sub.prop(lamp, "shadow_buffer_clip_end", text="End")
+
+ col.prop(lamp, "shadow_buffer_soft", text="Softness")
- sub = split.column()
- col = sub.column(align=True)
- col.prop(lamp, "shadow_buffer_clip_start", text="Clip Start")
- col.prop(lamp, "shadow_buffer_clip_end", text="Clip End")
- col = sub.column()
- col.prop(lamp, "shadow_buffer_soft", text="Soft")
+ col.separator()
- col = split.column(align=True)
col.prop(lamp, "shadow_buffer_bias", text="Bias")
col.prop(lamp, "shadow_buffer_exp", text="Exponent")
col.prop(lamp, "shadow_buffer_bleed_bias", text="Bleed Bias")
- if lamp.type == 'SUN':
- col = layout.column()
- col.active = lamp.use_shadow
- col.label("Cascaded Shadow Map:")
- split = col.split()
+class DATA_PT_EEVEE_shadow_cascaded_shadow_map(DataButtonsPanel, Panel):
+ bl_label = "Cascaded Shadow Map"
+ bl_parent_id = "DATA_PT_EEVEE_shadow"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
- sub = split.column()
- sub.prop(lamp, "shadow_cascade_count", text="Count")
- sub.prop(lamp, "shadow_cascade_fade", text="Fade")
+ @classmethod
+ def poll(cls, context):
+ lamp = context.lamp
+ engine = context.engine
- sub = split.column()
- sub.prop(lamp, "shadow_cascade_max_distance", text="Max Distance")
- sub.prop(lamp, "shadow_cascade_exponent", text="Distribution")
+ return (lamp and lamp.type == 'SUN') and (engine in cls.COMPAT_ENGINES)
- layout.separator()
+ def draw(self, context):
+ layout = self.layout
+ lamp = context.lamp
+ layout.use_property_split = True
- layout.prop(lamp, "use_contact_shadow")
- split = layout.split()
- split.active = lamp.use_contact_shadow
- col = split.column()
- col.prop(lamp, "contact_shadow_distance", text="Distance")
- col.prop(lamp, "contact_shadow_soft_size", text="Soft")
+ col = layout.column()
- col = split.column()
+ col.prop(lamp, "shadow_cascade_count", text="Count")
+ col.prop(lamp, "shadow_cascade_fade", text="Fade")
+
+ col.prop(lamp, "shadow_cascade_max_distance", text="Max Distance")
+ col.prop(lamp, "shadow_cascade_exponent", text="Distribution")
+
+
+class DATA_PT_EEVEE_shadow_contact(DataButtonsPanel, Panel):
+ bl_label = "Contact Shadows"
+ bl_parent_id = "DATA_PT_EEVEE_shadow"
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ lamp = context.lamp
+ engine = context.engine
+ return (lamp and lamp.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and (engine in cls.COMPAT_ENGINES)
+
+ def draw_header(self, context):
+ lamp = context.lamp
+
+ layout = self.layout
+ layout.active = lamp.use_shadow
+ layout.prop(lamp, "use_contact_shadow", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ lamp = context.lamp
+ layout.use_property_split = True
+
+ col = layout.column()
+ col.active = lamp.use_shadow and lamp.use_contact_shadow
+
+ col.prop(lamp, "contact_shadow_distance", text="Distance")
+ col.prop(lamp, "contact_shadow_soft_size", text="Softness")
col.prop(lamp, "contact_shadow_bias", text="Bias")
col.prop(lamp, "contact_shadow_thickness", text="Thickness")
@@ -272,6 +304,7 @@ class DATA_PT_spot(DataButtonsPanel, Panel):
class DATA_PT_spot(DataButtonsPanel, Panel):
bl_label = "Spot Shape"
+ bl_parent_id = "DATA_PT_EEVEE_lamp"
COMPAT_ENGINES = {'BLENDER_EEVEE'}
@classmethod
@@ -282,16 +315,15 @@ class DATA_PT_spot(DataButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
lamp = context.lamp
- split = layout.split()
+ col = layout.column()
+
+ col.prop(lamp, "spot_size", text="Size")
+ col.prop(lamp, "spot_blend", text="Blend", slider=True)
- col = split.column()
- sub = col.column()
- sub.prop(lamp, "spot_size", text="Size")
- sub.prop(lamp, "spot_blend", text="Blend", slider=True)
- col = split.column()
col.prop(lamp, "show_cone")
@@ -326,6 +358,8 @@ classes = (
DATA_PT_lamp,
DATA_PT_EEVEE_lamp,
DATA_PT_EEVEE_shadow,
+ DATA_PT_EEVEE_shadow_contact,
+ DATA_PT_EEVEE_shadow_cascaded_shadow_map,
DATA_PT_area,
DATA_PT_spot,
DATA_PT_falloff_curve,
diff --git a/release/scripts/startup/bl_ui/properties_data_lattice.py b/release/scripts/startup/bl_ui/properties_data_lattice.py
index c309642e8bc..b584e433cb9 100644
--- a/release/scripts/startup/bl_ui/properties_data_lattice.py
+++ b/release/scripts/startup/bl_ui/properties_data_lattice.py
@@ -57,24 +57,31 @@ class DATA_PT_lattice(DataButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
lat = context.lattice
- row = layout.row()
- row.prop(lat, "points_u")
- row.prop(lat, "interpolation_type_u", text="")
+ col = layout.column()
- row = layout.row()
- row.prop(lat, "points_v")
- row.prop(lat, "interpolation_type_v", text="")
+ sub = col.column(align=True)
+ sub.prop(lat, "points_u", text="Resolution U")
+ sub.prop(lat, "points_v", text="V")
+ sub.prop(lat, "points_w", text="W")
- row = layout.row()
- row.prop(lat, "points_w")
- row.prop(lat, "interpolation_type_w", text="")
+ col.separator()
- row = layout.row()
- row.prop(lat, "use_outside")
- row.prop_search(lat, "vertex_group", context.object, "vertex_groups", text="")
+ sub = col.column(align=True)
+ sub.prop(lat, "interpolation_type_u", text="Interpolation U")
+ sub.prop(lat, "interpolation_type_v", text="V")
+ sub.prop(lat, "interpolation_type_w", text="W")
+
+ col.separator()
+
+ col.prop(lat, "use_outside")
+
+ col.separator()
+
+ col.prop_search(lat, "vertex_group", context.object, "vertex_groups")
class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel, Panel):
diff --git a/release/scripts/startup/bl_ui/properties_data_lightprobe.py b/release/scripts/startup/bl_ui/properties_data_lightprobe.py
index c56d40df906..00c6c205530 100644
--- a/release/scripts/startup/bl_ui/properties_data_lightprobe.py
+++ b/release/scripts/startup/bl_ui/properties_data_lightprobe.py
@@ -56,34 +56,32 @@ class DATA_PT_lightprobe(DataButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
ob = context.object
probe = context.lightprobe
- split = layout.split()
+# layout.prop(probe, "type")
if probe.type == 'GRID':
- col = split.column(align=True)
- col.label("Influence:")
+ col = layout.column()
col.prop(probe, "influence_distance", "Distance")
col.prop(probe, "falloff")
col.prop(probe, "intensity")
col.separator()
- col.label("Resolution:")
- col.prop(probe, "grid_resolution_x", text="X")
+ col.prop(probe, "grid_resolution_x", text="Resolution X")
col.prop(probe, "grid_resolution_y", text="Y")
col.prop(probe, "grid_resolution_z", text="Z")
+
elif probe.type == 'PLANAR':
- col = split.column(align=True)
- col.label("Influence:")
+ col = layout.column()
col.prop(probe, "influence_distance", "Distance")
col.prop(probe, "falloff")
else:
- col = split.column(align=True)
- col.label("Influence:")
- col.prop(probe, "influence_type", text="")
+ col = layout.column()
+ col.prop(probe, "influence_type")
if probe.influence_type == 'ELIPSOID':
col.prop(probe, "influence_distance", "Radius")
@@ -93,27 +91,24 @@ class DATA_PT_lightprobe(DataButtonsPanel, Panel):
col.prop(probe, "falloff")
col.prop(probe, "intensity")
- col = split.column(align=True)
-
- col.label("Clipping:")
- col.prop(probe, "clip_start", text="Start")
+ col = layout.column()
+ sub = col.column()
+ sub.prop(probe, "clip_start", text="Clipping Start")
if probe.type != "PLANAR":
- col.prop(probe, "clip_end", text="End")
+ sub.prop(probe, "clip_end", text="End")
if probe.type == 'GRID':
col.separator()
-
- col.label("Visibility:")
+ col.label("Visibility")
col.prop(probe, "visibility_buffer_bias", "Bias")
col.prop(probe, "visibility_bleed_bias", "Bleed Bias")
col.prop(probe, "visibility_blur", "Blur")
col.separator()
- col.label("Visibility Collection:")
row = col.row(align=True)
- row.prop(probe, "visibility_collection", text="")
+ row.prop(probe, "visibility_collection")
row.prop(probe, "invert_visibility_collection", text="", icon='ARROW_LEFTRIGHT')
@@ -132,14 +127,14 @@ class DATA_PT_lightprobe_parallax(DataButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
probe = context.lightprobe
col = layout.column()
col.active = probe.use_custom_parallax
- row = col.row()
- row.prop(probe, "parallax_type", expand=True)
+ col.prop(probe, "parallax_type")
if probe.parallax_type == 'ELIPSOID':
col.prop(probe, "parallax_distance", "Radius")
@@ -153,31 +148,28 @@ class DATA_PT_lightprobe_display(DataButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
ob = context.object
probe = context.lightprobe
- row = layout.row()
- row.prop(probe, "show_data")
+ col = layout.column()
if probe.type != "PLANAR":
- row.prop(probe, "data_draw_size", text="Size")
+ col.prop(probe, "data_draw_size", text="Size")
else:
- row.prop(ob, "empty_draw_size", text="Arrow Size")
+ col.prop(ob, "empty_draw_size", text="Arrow Size")
- split = layout.split()
+ col.prop(probe, "show_data")
if probe.type in {'GRID', 'CUBEMAP'}:
- col = split.column()
col.prop(probe, "show_influence")
-
- col = split.column()
col.prop(probe, "show_clip")
if probe.type == 'CUBEMAP':
- col = split.column()
- col.active = probe.use_custom_parallax
- col.prop(probe, "show_parallax")
+ sub = col.column()
+ sub.active = probe.use_custom_parallax
+ sub.prop(probe, "show_parallax")
classes = (
diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index a9a47d268d2..76ea85d0fb4 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -158,19 +158,18 @@ class DATA_PT_normals(MeshButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
mesh = context.mesh
- split = layout.split()
+ col = layout.column()
+ col.prop(mesh, "show_double_sided")
- col = split.column()
col.prop(mesh, "use_auto_smooth")
sub = col.column()
sub.active = mesh.use_auto_smooth and not mesh.has_custom_normals
sub.prop(mesh, "auto_smooth_angle", text="Angle")
- split.prop(mesh, "show_double_sided")
-
class DATA_PT_texture_space(MeshButtonsPanel, Panel):
bl_label = "Texture Space"
@@ -179,6 +178,7 @@ class DATA_PT_texture_space(MeshButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
mesh = context.mesh
@@ -187,9 +187,9 @@ class DATA_PT_texture_space(MeshButtonsPanel, Panel):
layout.separator()
layout.prop(mesh, "use_auto_texspace")
- row = layout.row()
- row.column().prop(mesh, "texspace_location", text="Location")
- row.column().prop(mesh, "texspace_size", text="Size")
+
+ layout.prop(mesh, "texspace_location", text="Location")
+ layout.prop(mesh, "texspace_size", text="Size")
class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
@@ -280,6 +280,7 @@ class DATA_PT_face_maps(MeshButtonsPanel, Panel):
sub.operator("object.face_map_select", text="Select")
sub.operator("object.face_map_deselect", text="Deselect")
+
class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
bl_label = "Shape Keys"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
diff --git a/release/scripts/startup/bl_ui/properties_data_metaball.py b/release/scripts/startup/bl_ui/properties_data_metaball.py
index 5095fac40ca..c796c8af141 100644
--- a/release/scripts/startup/bl_ui/properties_data_metaball.py
+++ b/release/scripts/startup/bl_ui/properties_data_metaball.py
@@ -54,23 +54,18 @@ class DATA_PT_metaball(DataButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
mball = context.meta_ball
- split = layout.split()
-
- col = split.column()
+ col = layout.column()
col.label(text="Resolution:")
sub = col.column(align=True)
- sub.prop(mball, "resolution", text="View")
+ sub.prop(mball, "resolution", text="Resolution View")
sub.prop(mball, "render_resolution", text="Render")
- col = split.column()
- col.label(text="Settings:")
col.prop(mball, "threshold", text="Threshold")
-
- layout.label(text="Update:")
- layout.row().prop(mball, "update_method", expand=True)
+ col.prop(mball, "update_method")
class DATA_PT_mball_texture_space(DataButtonsPanel, Panel):
@@ -80,14 +75,15 @@ class DATA_PT_mball_texture_space(DataButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
mball = context.meta_ball
layout.prop(mball, "use_auto_texspace")
- row = layout.row()
- row.column().prop(mball, "texspace_location", text="Location")
- row.column().prop(mball, "texspace_size", text="Size")
+ col = layout.column()
+ col.prop(mball, "texspace_location")
+ col.prop(mball, "texspace_size")
class DATA_PT_metaball_element(DataButtonsPanel, Panel):
@@ -99,35 +95,33 @@ class DATA_PT_metaball_element(DataButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
metaelem = context.meta_ball.elements.active
- layout.prop(metaelem, "type")
+ col = layout.column()
- split = layout.split()
+ col.prop(metaelem, "type")
+
+ col.separator()
- col = split.column(align=True)
- col.label(text="Settings:")
col.prop(metaelem, "stiffness", text="Stiffness")
col.prop(metaelem, "use_negative", text="Negative")
col.prop(metaelem, "hide", text="Hide")
- col = split.column(align=True)
+ sub = col.column(align=True)
if metaelem.type in {'CUBE', 'ELLIPSOID'}:
- col.label(text="Size:")
- col.prop(metaelem, "size_x", text="X")
- col.prop(metaelem, "size_y", text="Y")
- col.prop(metaelem, "size_z", text="Z")
+ sub.prop(metaelem, "size_x", text="Size X")
+ sub.prop(metaelem, "size_y", text="Y")
+ sub.prop(metaelem, "size_z", text="Z")
elif metaelem.type == 'TUBE':
- col.label(text="Size:")
- col.prop(metaelem, "size_x", text="X")
+ sub.prop(metaelem, "size_x", text="Size X")
elif metaelem.type == 'PLANE':
- col.label(text="Size:")
- col.prop(metaelem, "size_x", text="X")
- col.prop(metaelem, "size_y", text="Y")
+ sub.prop(metaelem, "size_x", text="Size X")
+ sub.prop(metaelem, "size_y", text="Y")
class DATA_PT_custom_props_metaball(DataButtonsPanel, PropertyPanel, Panel):
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 45dda12f39b..acd1edc022a 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -170,7 +170,6 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
if bpy.app.debug:
layout.prop(md, "debug_options")
-
def BUILD(self, layout, ob, md):
split = layout.split()
@@ -330,8 +329,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
row.prop(md, "delimit")
layout_info = layout
- layout_info.label(text=iface_("Face Count: {:,}".format(md.face_count)),
- translate=False)
+ layout_info.label(
+ text=iface_("Face Count: {:,}".format(md.face_count)),
+ translate=False,
+ )
def DISPLACE(self, layout, ob, md):
has_texture = (md.texture is not None)
diff --git a/release/scripts/startup/bl_ui/properties_data_speaker.py b/release/scripts/startup/bl_ui/properties_data_speaker.py
index c317f906ba5..e43da31b5e8 100644
--- a/release/scripts/startup/bl_ui/properties_data_speaker.py
+++ b/release/scripts/startup/bl_ui/properties_data_speaker.py
@@ -62,14 +62,16 @@ class DATA_PT_speaker(DataButtonsPanel, Panel):
speaker = context.speaker
- split = layout.split(percentage=0.75)
+ layout.template_ID(speaker, "sound", open="sound.open_mono")
- split.template_ID(speaker, "sound", open="sound.open_mono")
- split.prop(speaker, "muted")
+ layout.use_property_split = True
- row = layout.row()
- row.prop(speaker, "volume")
- row.prop(speaker, "pitch")
+ layout.prop(speaker, "muted")
+
+ col = layout.column()
+ col.active = not speaker.muted
+ col.prop(speaker, "volume", slider=True)
+ col.prop(speaker, "pitch")
class DATA_PT_distance(DataButtonsPanel, Panel):
@@ -79,20 +81,20 @@ class DATA_PT_distance(DataButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
- speaker = context.speaker
+ layout.use_property_split = True
- split = layout.split()
+ speaker = context.speaker
+ layout.active = not speaker.muted
- col = split.column()
- col.label("Volume:")
- col.prop(speaker, "volume_min", text="Minimum")
- col.prop(speaker, "volume_max", text="Maximum")
+ col = layout.column()
+ sub = col.column(align=True)
+ sub.prop(speaker, "volume_min", slider=True, text="Volume Min")
+ sub.prop(speaker, "volume_max", slider=True, text="Max")
col.prop(speaker, "attenuation")
- col = split.column()
- col.label("Distance:")
- col.prop(speaker, "distance_max", text="Maximum")
- col.prop(speaker, "distance_reference", text="Reference")
+ col.separator()
+ col.prop(speaker, "distance_max", text="Max Distance")
+ col.prop(speaker, "distance_reference", text="Distance Reference")
class DATA_PT_cone(DataButtonsPanel, Panel):
@@ -102,18 +104,20 @@ class DATA_PT_cone(DataButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+
speaker = context.speaker
+ layout.active = not speaker.muted
+
+ col = layout.column()
- split = layout.split()
+ sub = col.column(align=True)
+ sub.prop(speaker, "cone_angle_outer", text="Angle Outer")
+ sub.prop(speaker, "cone_angle_inner", text="Inner")
- col = split.column()
- col.label("Angle:")
- col.prop(speaker, "cone_angle_outer", text="Outer")
- col.prop(speaker, "cone_angle_inner", text="Inner")
+ col.separator()
- col = split.column()
- col.label("Volume:")
- col.prop(speaker, "cone_volume_outer", text="Outer")
+ col.prop(speaker, "cone_volume_outer", slider=True)
class DATA_PT_custom_props_speaker(DataButtonsPanel, PropertyPanel, Panel):
diff --git a/release/scripts/startup/bl_ui/properties_data_workspace.py b/release/scripts/startup/bl_ui/properties_data_workspace.py
index 5374aa6b736..3cda3dd0abd 100644
--- a/release/scripts/startup/bl_ui/properties_data_workspace.py
+++ b/release/scripts/startup/bl_ui/properties_data_workspace.py
@@ -19,8 +19,8 @@
# <pep8 compliant>
import bpy
from bpy.types import (
- Panel,
- )
+ Panel,
+)
from rna_prop_ui import PropertyPanel
@@ -51,7 +51,7 @@ class WORKSPACE_PT_owner_ids(WorkSpaceButtonsPanel, Panel):
import addon_utils
addon_map = {mod.__name__: mod for mod in addon_utils.modules()}
- owner_ids = {owner_id.name for owner_id in workspace.owner_ids}
+ owner_ids = {owner_id.name for owner_id in workspace.owner_ids}
for addon in userpref.addons:
module_name = addon.module
@@ -85,7 +85,6 @@ class WORKSPACE_PT_owner_ids(WorkSpaceButtonsPanel, Panel):
row.label(module_name)
-
class WORKSPACE_PT_custom_props(WorkSpaceButtonsPanel, PropertyPanel, Panel):
_context_path = "workspace"
_property_type = bpy.types.WorkSpace
@@ -100,4 +99,3 @@ if __name__ == "__main__": # only for live edit.
from bpy.utils import register_class
for cls in classes:
register_class(cls)
-
diff --git a/release/scripts/startup/bl_ui/properties_freestyle.py b/release/scripts/startup/bl_ui/properties_freestyle.py
index a9c9d512335..12ecbeb3e6b 100644
--- a/release/scripts/startup/bl_ui/properties_freestyle.py
+++ b/release/scripts/startup/bl_ui/properties_freestyle.py
@@ -629,7 +629,7 @@ class VIEWLAYER_PT_freestyle_linestyle(ViewLayerFreestyleEditorButtonsPanel, Pan
row = layout.row(align=True)
row.prop(linestyle, "panel", expand=True)
if linestyle.panel == 'STROKES':
- ## Chaining
+ # Chaining
layout.prop(linestyle, "use_chaining", text="Chaining:")
split = layout.split(align=True)
split.active = linestyle.use_chaining
@@ -643,7 +643,7 @@ class VIEWLAYER_PT_freestyle_linestyle(ViewLayerFreestyleEditorButtonsPanel, Pan
col = split.column()
col.prop(linestyle, "use_same_object")
- ## Splitting
+ # Splitting
layout.label(text="Splitting:")
split = layout.split(align=True)
# First column
@@ -679,7 +679,7 @@ class VIEWLAYER_PT_freestyle_linestyle(ViewLayerFreestyleEditorButtonsPanel, Pan
sub.prop(linestyle, "split_dash3", text="D3")
sub.prop(linestyle, "split_gap3", text="G3")
- ## Sorting
+ # Sorting
layout.prop(linestyle, "use_sorting", text="Sorting:")
col = layout.column()
col.active = linestyle.use_sorting
@@ -693,7 +693,7 @@ class VIEWLAYER_PT_freestyle_linestyle(ViewLayerFreestyleEditorButtonsPanel, Pan
row = col.row(align=True)
row.prop(linestyle, "sort_order", expand=True)
- ## Selection
+ # Selection
layout.label(text="Selection:")
split = layout.split(align=True)
# First column
@@ -716,12 +716,12 @@ class VIEWLAYER_PT_freestyle_linestyle(ViewLayerFreestyleEditorButtonsPanel, Pan
sub.active = linestyle.use_chain_count
sub.prop(linestyle, "chain_count")
- ## Caps
+ # Caps
layout.label(text="Caps:")
row = layout.row(align=True)
row.prop(linestyle, "caps", expand=True)
- ## Dashed lines
+ # Dashed lines
layout.prop(linestyle, "use_dashed_line", text="Dashed Line:")
row = layout.row(align=True)
row.active = linestyle.use_dashed_line
@@ -786,9 +786,10 @@ class VIEWLAYER_PT_freestyle_linestyle(ViewLayerFreestyleEditorButtonsPanel, Pan
row = layout.row()
props = row.operator(
- "wm.properties_context_change",
- text="Go to Linestyle Textures Properties",
- icon='TEXTURE')
+ "wm.properties_context_change",
+ text="Go to Linestyle Textures Properties",
+ icon='TEXTURE',
+ )
props.context = 'TEXTURE'
elif linestyle.panel == 'MISC':
diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index decbbff5d60..a2ccfb4f1b8 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -242,7 +242,6 @@ class GreasePencilStrokeEditPanel:
if is_3d_view:
layout.separator()
-
layout.separator()
col = layout.column(align=True)
col.operator("gpencil.stroke_subdivide", text="Subdivide")
@@ -1100,11 +1099,11 @@ class GreasePencilPaletteColorPanel:
row = layout.row()
sub = row.row(align=True)
- sub.label(text="Isolate:") # based on active color only
+ sub.label(text="Isolate:") # based on active color only
sub.operator("gpencil.palettecolor_isolate", icon='LOCKED', text="").affect_visibility = False
sub.operator("gpencil.palettecolor_isolate", icon='RESTRICT_VIEW_OFF', text="").affect_visibility = True
sub = row.row(align=True)
- sub.label(text="Lock:") # based on other stuff...
+ sub.label(text="Lock:") # based on other stuff...
sub.operator("gpencil.stroke_lock_color", icon='BORDER_RECT', text="")
sub.operator("gpencil.palette_lock_layer", icon='COLOR', text="")
diff --git a/release/scripts/startup/bl_ui/properties_mask_common.py b/release/scripts/startup/bl_ui/properties_mask_common.py
index a7a67130f2f..450ca80bbc2 100644
--- a/release/scripts/startup/bl_ui/properties_mask_common.py
+++ b/release/scripts/startup/bl_ui/properties_mask_common.py
@@ -43,8 +43,8 @@ class MASK_UL_layers(UIList):
class MASK_PT_mask:
# subclasses must define...
- #~ bl_space_type = 'CLIP_EDITOR'
- #~ bl_region_type = 'UI'
+ # ~ bl_space_type = 'CLIP_EDITOR'
+ # ~ bl_region_type = 'UI'
bl_label = "Mask Settings"
bl_options = {'DEFAULT_CLOSED'}
@@ -66,8 +66,8 @@ class MASK_PT_mask:
class MASK_PT_layers:
# subclasses must define...
- #~ bl_space_type = 'CLIP_EDITOR'
- #~ bl_region_type = 'UI'
+ # ~ bl_space_type = 'CLIP_EDITOR'
+ # ~ bl_region_type = 'UI'
bl_label = "Mask Layers"
@classmethod
@@ -114,8 +114,8 @@ class MASK_PT_layers:
class MASK_PT_spline:
# subclasses must define...
- #~ bl_space_type = 'CLIP_EDITOR'
- #~ bl_region_type = 'UI'
+ # ~ bl_space_type = 'CLIP_EDITOR'
+ # ~ bl_region_type = 'UI'
bl_label = "Active Spline"
@classmethod
@@ -148,8 +148,8 @@ class MASK_PT_spline:
class MASK_PT_point:
# subclasses must define...
- #~ bl_space_type = 'CLIP_EDITOR'
- #~ bl_region_type = 'UI'
+ # ~ bl_space_type = 'CLIP_EDITOR'
+ # ~ bl_region_type = 'UI'
bl_label = "Active Point"
@classmethod
@@ -203,8 +203,8 @@ class MASK_PT_point:
class MASK_PT_display:
# subclasses must define...
- #~ bl_space_type = 'CLIP_EDITOR'
- #~ bl_region_type = 'UI'
+ # ~ bl_space_type = 'CLIP_EDITOR'
+ # ~ bl_region_type = 'UI'
bl_label = "Mask Display"
bl_options = {'DEFAULT_CLOSED'}
@@ -229,8 +229,8 @@ class MASK_PT_display:
class MASK_PT_transforms:
# subclasses must define...
- #~ bl_space_type = 'CLIP_EDITOR'
- #~ bl_region_type = 'TOOLS'
+ # ~ bl_space_type = 'CLIP_EDITOR'
+ # ~ bl_region_type = 'TOOLS'
bl_label = "Transforms"
bl_category = "Mask"
bl_options = {'DEFAULT_CLOSED'}
@@ -253,8 +253,8 @@ class MASK_PT_transforms:
class MASK_PT_tools:
# subclasses must define...
- #~ bl_space_type = 'CLIP_EDITOR'
- #~ bl_region_type = 'TOOLS'
+ # ~ bl_space_type = 'CLIP_EDITOR'
+ # ~ bl_region_type = 'TOOLS'
bl_label = "Mask Tools"
bl_category = "Mask"
@@ -291,8 +291,8 @@ class MASK_PT_tools:
class MASK_PT_add:
# subclasses must define...
- #~ bl_space_type = 'CLIP_EDITOR'
- #~ bl_region_type = 'TOOLS'
+ # ~ bl_space_type = 'CLIP_EDITOR'
+ # ~ bl_region_type = 'TOOLS'
bl_label = "Add"
bl_category = "Mask"
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index 9b70c8f22d4..75cdd2d68c6 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -23,6 +23,7 @@ from rna_prop_ui import PropertyPanel
from bpy.app.translations import pgettext_iface as iface_
from bpy_extras.node_utils import find_node_input, find_output_node
+
class MATERIAL_MT_specials(Menu):
bl_label = "Material Specials"
@@ -172,11 +173,11 @@ class EEVEE_MATERIAL_PT_surface(MaterialButtonsPanel, Panel):
if mat.use_nodes:
panel_node_draw(layout, mat.node_tree, ('OUTPUT_EEVEE_MATERIAL', 'OUTPUT_MATERIAL'))
else:
- raym = mat.raytrace_mirror
+ layout.use_property_split = True
layout.prop(mat, "diffuse_color", text="Base Color")
- layout.prop(raym, "reflect_factor", text="Metallic")
+ layout.prop(mat, "metallic")
layout.prop(mat, "specular_intensity", text="Specular")
- layout.prop(raym, "gloss_factor", text="Roughness")
+ layout.prop(mat, "roughness")
class EEVEE_MATERIAL_PT_options(MaterialButtonsPanel, Panel):
@@ -191,6 +192,7 @@ class EEVEE_MATERIAL_PT_options(MaterialButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
mat = context.material
@@ -215,6 +217,27 @@ class EEVEE_MATERIAL_PT_options(MaterialButtonsPanel, Panel):
row.prop(mat, "use_sss_translucency")
+class MATERIAL_PT_viewport(MaterialButtonsPanel, Panel):
+ bl_label = "Viewport Display"
+ bl_context = "material"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ @classmethod
+ def poll(cls, context):
+ return context.material
+
+ def draw(self, context):
+ mat = context.material
+
+ layout = self.layout
+ layout.use_property_split = True
+
+ col = layout.column()
+ col.prop(mat, "diffuse_color")
+ col.prop(mat, "specular_color")
+ col.prop(mat, "roughness")
+
+
classes = (
MATERIAL_MT_specials,
MATERIAL_UL_matslots,
@@ -223,8 +246,10 @@ classes = (
EEVEE_MATERIAL_PT_context_material,
EEVEE_MATERIAL_PT_surface,
EEVEE_MATERIAL_PT_options,
+ MATERIAL_PT_viewport,
)
+
if __name__ == "__main__": # only for live edit.
from bpy.utils import register_class
for cls in classes:
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index f0526fc0271..34515e2a05a 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -48,129 +48,117 @@ class OBJECT_PT_transform(ObjectButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+
+ flow = layout.grid_flow(row_major=True, num_columns=0, even_columns=True, even_rows=False, align=False)
ob = context.object
- row = layout.row()
+ col = flow.column()
+ row = col.row(align=True)
+ row.prop(ob, "location")
+ row.prop(ob, "lock_location", text="")
- row.column().prop(ob, "location")
if ob.rotation_mode == 'QUATERNION':
- row.column().prop(ob, "rotation_quaternion", text="Rotation")
+ col = flow.column()
+ row = col.row(align=True)
+ row.prop(ob, "rotation_quaternion", text="Rotation")
+ sub = row.column(align=True)
+ sub.prop(ob, "lock_rotation_w", text="")
+ sub.prop(ob, "lock_rotation", text="")
elif ob.rotation_mode == 'AXIS_ANGLE':
- #row.column().label(text="Rotation")
+ # row.column().label(text="Rotation")
#row.column().prop(pchan, "rotation_angle", text="Angle")
#row.column().prop(pchan, "rotation_axis", text="Axis")
- row.column().prop(ob, "rotation_axis_angle", text="Rotation")
+ col = flow.column()
+ row = col.row(align=True)
+ row.prop(ob, "rotation_axis_angle", text="Rotation")
+
+ sub = row.column(align=True)
+ sub.prop(ob, "lock_rotation_w", text="")
+ sub.prop(ob, "lock_rotation", text="")
else:
- row.column().prop(ob, "rotation_euler", text="Rotation")
+ col = flow.column()
+ row = col.row(align=True)
+ row.prop(ob, "rotation_euler", text="Rotation")
+ row.prop(ob, "lock_rotation", text="")
- row.column().prop(ob, "scale")
+ col = flow.column()
+ row = col.row(align=True)
+ row.prop(ob, "scale")
+ row.prop(ob, "lock_scale", text="")
layout.prop(ob, "rotation_mode")
class OBJECT_PT_delta_transform(ObjectButtonsPanel, Panel):
bl_label = "Delta Transform"
+ bl_parent_id = "OBJECT_PT_transform"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+ flow = layout.grid_flow(row_major=True, num_columns=0, even_columns=True, even_rows=True, align=False)
ob = context.object
- row = layout.row()
+ col = flow.column()
+ col.prop(ob, "delta_location")
- row.column().prop(ob, "delta_location")
+ col = flow.column()
if ob.rotation_mode == 'QUATERNION':
- row.column().prop(ob, "delta_rotation_quaternion", text="Rotation")
+ col.prop(ob, "delta_rotation_quaternion", text="Rotation")
elif ob.rotation_mode == 'AXIS_ANGLE':
- #row.column().label(text="Rotation")
+ # row.column().label(text="Rotation")
#row.column().prop(pchan, "delta_rotation_angle", text="Angle")
#row.column().prop(pchan, "delta_rotation_axis", text="Axis")
#row.column().prop(ob, "delta_rotation_axis_angle", text="Rotation")
- row.column().label(text="Not for Axis-Angle")
+ col.label(text="Not for Axis-Angle")
else:
- row.column().prop(ob, "delta_rotation_euler", text="Delta Rotation")
-
- row.column().prop(ob, "delta_scale")
-
-
-class OBJECT_PT_transform_locks(ObjectButtonsPanel, Panel):
- bl_label = "Transform Locks"
- bl_options = {'DEFAULT_CLOSED'}
-
- def draw(self, context):
- layout = self.layout
+ col.prop(ob, "delta_rotation_euler", text="Delta Rotation")
- ob = context.object
-
- split = layout.split(percentage=0.1)
-
- col = split.column(align=True)
- col.label(text="")
- col.label(text="X:")
- col.label(text="Y:")
- col.label(text="Z:")
-
- split.column().prop(ob, "lock_location", text="Location")
- split.column().prop(ob, "lock_rotation", text="Rotation")
- split.column().prop(ob, "lock_scale", text="Scale")
-
- if ob.rotation_mode in {'QUATERNION', 'AXIS_ANGLE'}:
- row = layout.row()
- row.prop(ob, "lock_rotations_4d", text="Lock Rotation")
-
- sub = row.row()
- sub.active = ob.lock_rotations_4d
- sub.prop(ob, "lock_rotation_w", text="W")
+ col = flow.column()
+ col.prop(ob, "delta_scale")
class OBJECT_PT_relations(ObjectButtonsPanel, Panel):
bl_label = "Relations"
+ bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+ flow = layout.grid_flow(row_major=True, num_columns=0, even_columns=True, even_rows=False, align=False)
ob = context.object
- split = layout.split()
-
- col = split.column()
- col.prop(ob, "pass_index")
-
- col = split.column()
- col.label(text="Parent:")
- col.prop(ob, "parent", text="")
-
- sub = col.column()
- sub.prop(ob, "parent_type", text="")
+ col = flow.column()
+ col.prop(ob, "parent")
+ sub = col.row(align=True)
+ sub.prop(ob, "parent_type")
parent = ob.parent
if parent and ob.parent_type == 'BONE' and parent.type == 'ARMATURE':
- sub.prop_search(ob, "parent_bone", parent.data, "bones", text="")
+ sub.prop_search(ob, "parent_bone", parent.data, "bones")
sub.active = (parent is not None)
+ col = flow.column()
+ col.active = (ob.parent is not None)
+ col.prop(ob, "use_slow_parent")
+ sub = col.row(align=True)
+ sub.active = (ob.use_slow_parent)
+ sub.prop(ob, "slow_parent_offset", text="Offset")
-class OBJECT_PT_relations_extras(ObjectButtonsPanel, Panel):
- bl_label = "Relations Extras"
- bl_options = {'DEFAULT_CLOSED'}
-
- def draw(self, context):
- layout = self.layout
-
- ob = context.object
-
- split = layout.split()
+ col = flow.column()
+ col.separator()
- col = split.column()
- col.label(text="Tracking Axes:")
- col.prop(ob, "track_axis", text="Axis")
+ col.prop(ob, "track_axis", text="Tracking Axis")
col.prop(ob, "up_axis", text="Up Axis")
- col = split.column()
- col.prop(ob, "use_slow_parent")
- row = col.row()
- row.active = ((ob.parent is not None) and (ob.use_slow_parent))
- row.prop(ob, "slow_parent_offset", text="Offset")
+ col = flow.column()
+ col.separator()
+
+ col.prop(ob, "pass_index")
class COLLECTION_MT_specials(Menu):
@@ -221,10 +209,13 @@ class OBJECT_PT_collections(ObjectButtonsPanel, Panel):
class OBJECT_PT_display(ObjectButtonsPanel, Panel):
- bl_label = "Display"
+ bl_label = "Viewport Display"
+ bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+ flow = layout.grid_flow(row_major=True, num_columns=0, even_columns=True, even_rows=False, align=False)
obj = context.object
obj_type = obj.type
@@ -233,93 +224,93 @@ class OBJECT_PT_display(ObjectButtonsPanel, Panel):
is_empty_image = (obj_type == 'EMPTY' and obj.empty_draw_type == 'IMAGE')
is_dupli = (obj.dupli_type != 'NONE')
- split = layout.split()
-
- col = split.column()
+ col = flow.column(align=True)
col.prop(obj, "show_name", text="Name")
col.prop(obj, "show_axis", text="Axis")
+
# Makes no sense for cameras, armatures, etc.!
# but these settings do apply to dupli instances
+ col = flow.column(align=True)
if is_geometry or is_dupli:
- col.prop(obj, "show_wire", text="Wire")
+ col.prop(obj, "show_wire", text="Wireframe")
if obj_type == 'MESH' or is_dupli:
col.prop(obj, "show_all_edges")
- col = split.column()
- row = col.row()
- row.prop(obj, "show_bounds", text="Bounds")
- sub = row.row()
+ col = flow.column()
+ col.prop(obj, "show_bounds", text="Bounds")
+ sub = col.column()
sub.active = obj.show_bounds
- sub.prop(obj, "draw_bounds_type", text="")
+ sub.prop(obj, "draw_bounds_type")
+ col = flow.column()
if is_geometry:
col.prop(obj, "show_texture_space", text="Texture Space")
- col.prop(obj.display, "show_shadows")
+ col.prop(obj.display, "show_shadows", text="Shadow")
col.prop(obj, "show_x_ray", text="X-Ray")
- if obj_type == 'MESH' or is_empty_image:
- col.prop(obj, "show_transparent", text="Transparency")
+ # if obj_type == 'MESH' or is_empty_image:
+ # col.prop(obj, "show_transparent", text="Transparency")
- split = layout.split()
-
- col = split.column()
+ col = flow.column()
if is_wire:
# wire objects only use the max. draw type for duplis
col.active = is_dupli
- col.label(text="Maximum Dupli Draw Type:")
- else:
- col.label(text="Maximum Draw Type:")
- col.prop(obj, "draw_type", text="")
+ col.prop(
+ obj, "draw_type",
+ text="Maximum Draw Type" if is_wire else "Maximum Draw Type",
+ )
- col = split.column()
if is_geometry or is_empty_image:
# Only useful with object having faces/materials...
- col.label(text="Object Color:")
- col.prop(obj, "color", text="")
-
- col = layout.column()
- col.active = bool(is_dupli or obj.particle_systems)
- col.label(text="Duplicator Visibility:")
- row = col.row(align=True)
- row.prop(obj, "show_duplicator_for_viewport", text="Viewport")
- row.prop(obj, "show_duplicator_for_render", text="Render")
+ col.prop(obj, "color")
class OBJECT_PT_duplication(ObjectButtonsPanel, Panel):
bl_label = "Duplication"
+ bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
ob = context.object
- layout.row().prop(ob, "dupli_type", expand=True)
+ row = layout.row()
+ row.prop(ob, "dupli_type", expand=True)
+
+ layout.use_property_split = True
+ flow = layout.grid_flow(row_major=True, num_columns=0, even_columns=True, even_rows=False, align=False)
if ob.dupli_type == 'FRAMES':
- split = layout.split()
- col = split.column(align=True)
+ col = flow.column(align=True)
col.prop(ob, "dupli_frames_start", text="Start")
col.prop(ob, "dupli_frames_end", text="End")
- col = split.column(align=True)
+ col = flow.column(align=True)
col.prop(ob, "dupli_frames_on", text="On")
col.prop(ob, "dupli_frames_off", text="Off")
- layout.prop(ob, "use_dupli_frames_speed", text="Speed")
+ col = flow.column(align=True)
+ col.prop(ob, "use_dupli_frames_speed", text="Speed")
elif ob.dupli_type == 'VERTS':
layout.prop(ob, "use_dupli_vertices_rotation", text="Rotation")
elif ob.dupli_type == 'FACES':
- row = layout.row()
- row.prop(ob, "use_dupli_faces_scale", text="Scale")
- sub = row.row()
+ col = flow.column()
+ col.prop(ob, "use_dupli_faces_scale", text="Scale")
+ sub = col.column()
sub.active = ob.use_dupli_faces_scale
sub.prop(ob, "dupli_faces_scale", text="Inherit Scale")
elif ob.dupli_type == 'COLLECTION':
- layout.prop(ob, "dupli_group", text="Collection")
+ col = flow.column()
+ col.prop(ob, "dupli_group", text="Collection")
+
+ if ob.dupli_type != 'NONE' or len(ob.particle_systems):
+ col = flow.column(align=True)
+ col.prop(ob, "show_duplicator_for_viewport")
+ col.prop(ob, "show_duplicator_for_render")
from .properties_animviz import (
@@ -370,13 +361,11 @@ classes = (
OBJECT_PT_context_object,
OBJECT_PT_transform,
OBJECT_PT_delta_transform,
- OBJECT_PT_transform_locks,
OBJECT_PT_relations,
- OBJECT_PT_relations_extras,
COLLECTION_MT_specials,
OBJECT_PT_collections,
- OBJECT_PT_display,
OBJECT_PT_duplication,
+ OBJECT_PT_display,
OBJECT_PT_motion_paths,
OBJECT_PT_custom_props,
)
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index bc8bc523e12..f1e5102f061 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -126,7 +126,7 @@ def brush_texpaint_common(panel, context, layout, brush, settings, projpaint=Fal
col.prop(brush, "gradient_stroke_mode", text="Mode")
if brush.gradient_stroke_mode in {'SPACING_REPEAT', 'SPACING_CLAMP'}:
col.prop(brush, "grad_spacing")
- else: # if brush.image_tool == 'FILL':
+ else: # if brush.image_tool == 'FILL':
col.prop(brush, "gradient_fill_mode")
else:
row = col.row(align=True)
diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index b6f7cfe3e84..00eb13dd222 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -255,56 +255,70 @@ class PARTICLE_PT_emission(ParticleButtonsPanel, Panel):
psys = context.particle_system
part = particle_get_settings(context)
+ layout.use_property_split = True
+
layout.enabled = particle_panel_enabled(context, psys) and (psys is None or not psys.has_multiple_caches)
- row = layout.row()
- row.active = part.emit_from == 'VERT' or part.distribution != 'GRID'
- row.prop(part, "count")
+ col = layout.column()
+ col.active = part.emit_from == 'VERT' or part.distribution != 'GRID'
+ col.prop(part, "count")
if part.type == 'HAIR':
- row.prop(part, "hair_length")
+ col.prop(part, "hair_length")
if not part.use_advanced_hair:
row = layout.row()
- row.prop(part, "use_modifier_stack")
+ col.prop(part, "use_modifier_stack")
return
if part.type != 'HAIR':
- split = layout.split()
- col = split.column(align=True)
- col.prop(part, "frame_start")
- col.prop(part, "frame_end")
+ col = layout.column()
+
+ sub = col.column(align=True)
+ sub.prop(part, "frame_start", text="Frame Start")
+ sub.prop(part, "frame_end", text="End")
- col = split.column(align=True)
col.prop(part, "lifetime")
- col.prop(part, "lifetime_random", slider=True)
+ col.prop(part, "lifetime_random", slider=True, text="Lifetime Randomness")
- layout.label(text="Emit From:")
- layout.row().prop(part, "emit_from", expand=True)
- row = layout.row()
+class PARTICLE_PT_emission_source(ParticleButtonsPanel, Panel):
+ bl_label = "Source"
+ bl_parent_id = "PARTICLE_PT_emission"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ def draw(self, context):
+ layout = self.layout
+
+ part = particle_get_settings(context)
+
+ layout.use_property_split = True
+
+ col = layout.column()
+ col.prop(part, "emit_from")
+ col.prop(part, "use_modifier_stack")
+ if part.emit_from == 'FACE' or part.emit_from == 'VOLUME':
+ col.prop(part, "distribution")
+
if part.emit_from == 'VERT':
- row.prop(part, "use_emit_random")
+ col.prop(part, "use_emit_random", text="Random Order")
elif part.distribution == 'GRID':
- row.prop(part, "invert_grid")
- row.prop(part, "hexagonal_grid")
+ col.label(text="Grid")
+ col.prop(part, "invert_grid")
+ col.prop(part, "hexagonal_grid")
else:
- row.prop(part, "use_emit_random")
- row.prop(part, "use_even_distribution")
+ col.prop(part, "use_emit_random")
+ col.prop(part, "use_even_distribution")
if part.emit_from == 'FACE' or part.emit_from == 'VOLUME':
- layout.row().prop(part, "distribution", expand=True)
- row = layout.row()
if part.distribution == 'JIT':
- row.prop(part, "userjit", text="Particles/Face")
- row.prop(part, "jitter_factor", text="Jittering Amount", slider=True)
+ col.prop(part, "userjit", text="Particles/Face")
+ col.prop(part, "jitter_factor", text="Jittering Amount", slider=True)
elif part.distribution == 'GRID':
- row.prop(part, "grid_resolution")
- row.prop(part, "grid_random", text="Random", slider=True)
-
- row = layout.row()
- row.prop(part, "use_modifier_stack")
+ col.prop(part, "grid_resolution")
+ col.prop(part, "grid_random", text="Random", slider=True)
class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
@@ -332,6 +346,7 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
psys = context.particle_system
if not psys.cloth:
+ layout.label(text="Hair dynamics disabled")
return
cloth_md = psys.cloth
@@ -345,44 +360,20 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
row.operator("particle.hair_dynamics_preset_add", text="", icon='ZOOMIN')
row.operator("particle.hair_dynamics_preset_add", text="", icon='ZOOMOUT').remove_active = True
- split = layout.column()
-
- col = split.column()
- col.label(text="Structure")
- col.prop(cloth, "mass")
- sub = col.column(align=True)
- subsub = sub.row(align=True)
- subsub.prop(cloth, "bending_stiffness", text="Stiffness")
- subsub.prop(psys.settings, "bending_random", text="Random")
- sub.prop(cloth, "bending_damping", text="Damping")
- # XXX has no noticeable effect with stiff hair structure springs
- #col.prop(cloth, "spring_damping", text="Damping")
-
- split.separator()
+ layout.use_property_split = True
- col = split.column()
- col.label(text="Volume")
- col.prop(cloth, "air_damping", text="Air Drag")
- col.prop(cloth, "internal_friction", slider=True)
- sub = col.column(align=True)
- sub.prop(cloth, "density_target", text="Density Target")
- sub.prop(cloth, "density_strength", slider=True, text="Strength")
- col.prop(cloth, "voxel_cell_size")
+ layout.separator()
- split.separator()
-
- col = split.column()
- col.label(text="Pinning")
- col.prop(cloth, "pin_stiffness", text="Goal Strength")
+ col = layout.column()
+ col.prop(cloth, "quality", text="Quality Steps", slider=True)
+ col.prop(psys.settings, "show_hair_grid", text="Display Hair Grid")
- split.separator()
+ layout.separator()
- col = split.column()
- col.label(text="Quality:")
- col.prop(cloth, "quality", text="Steps", slider=True)
+ col = layout.column()
+ col.prop(cloth, "pin_stiffness", text="Pin Goal Strength")
- row = col.row()
- row.prop(psys.settings, "show_hair_grid", text="HairGrid")
+ layout.separator()
if result:
box = layout.box()
@@ -405,6 +396,71 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
box.label("Error: %.5f .. %.5f (avg. %.5f)" % (result.min_error, result.max_error, result.avg_error))
+class PARTICLE_PT_hair_dynamics_structure(ParticleButtonsPanel, Panel):
+ bl_label = "Structure"
+ bl_parent_id = "PARTICLE_PT_hair_dynamics"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ return context.particle_system.cloth is not None
+
+ def draw(self, context):
+ layout = self.layout
+
+ psys = context.particle_system
+ cloth_md = psys.cloth
+ cloth = cloth_md.settings
+ result = cloth_md.solver_result
+
+ layout.enabled = psys.use_hair_dynamics and psys.point_cache.is_baked is False
+
+ layout.use_property_split = True
+
+ col = layout.column()
+ col.prop(cloth, "mass")
+ sub = col.column(align=True)
+ sub.prop(cloth, "bending_stiffness", text="Stiffness")
+ sub.prop(psys.settings, "bending_random", text="Random")
+ col.prop(cloth, "bending_damping", text="Damping")
+ # XXX has no noticeable effect with stiff hair structure springs
+ #col.prop(cloth, "spring_damping", text="Damping")
+
+
+class PARTICLE_PT_hair_dynamics_volume(ParticleButtonsPanel, Panel):
+ bl_label = "Volume"
+ bl_parent_id = "PARTICLE_PT_hair_dynamics"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ return context.particle_system.cloth is not None
+
+ def draw(self, context):
+ layout = self.layout
+
+ psys = context.particle_system
+ cloth_md = psys.cloth
+ cloth = cloth_md.settings
+ result = cloth_md.solver_result
+
+ layout.enabled = psys.use_hair_dynamics and psys.point_cache.is_baked is False
+
+ layout.use_property_split = True
+
+ col = layout.column()
+ col.prop(cloth, "air_damping", text="Air Drag")
+ col.prop(cloth, "internal_friction", slider=True)
+ col.prop(cloth, "voxel_cell_size")
+
+ col.separator()
+
+ col.prop(cloth, "density_target", text="Density Target")
+ col.prop(cloth, "density_strength", slider=True, text="Density Strength")
+
+
class PARTICLE_PT_cache(ParticleButtonsPanel, Panel):
bl_label = "Cache"
bl_options = {'DEFAULT_CLOSED'}
@@ -459,31 +515,29 @@ class PARTICLE_PT_velocity(ParticleButtonsPanel, Panel):
part = particle_get_settings(context)
layout.enabled = particle_panel_enabled(context, psys)
+ layout.use_property_split = True
- split = layout.split()
-
- col = split.column()
- col.label(text="Emitter Geometry:")
+ col = layout.column()
col.prop(part, "normal_factor")
sub = col.column(align=True)
- sub.prop(part, "tangent_factor")
- sub.prop(part, "tangent_phase", slider=True)
+ sub.prop(part, "tangent_factor", text="Tangent")
+ sub.prop(part, "tangent_phase", slider=True, text="Tangent Phase")
- col = split.column()
- col.label(text="Emitter Object:")
- col.prop(part, "object_align_factor", text="")
+ col.separator()
+
+ col.prop(part, "object_align_factor")
+
+ col.separator()
- layout.label(text="Other:")
- row = layout.row()
if part.emit_from == 'PARTICLE':
- row.prop(part, "particle_factor")
+ col.prop(part, "particle_factor")
else:
- row.prop(part, "object_factor", slider=True)
- row.prop(part, "factor_random")
+ col.prop(part, "object_factor", slider=True)
+ col.prop(part, "factor_random", text="Randomize")
- #if part.type=='REACTOR':
- # sub.prop(part, "reactor_factor")
- # sub.prop(part, "reaction_shape", slider=True)
+ # if part.type=='REACTOR':
+ # sub.prop(part, "reactor_factor")
+ # sub.prop(part, "reaction_shape", slider=True)
class PARTICLE_PT_rotation(ParticleButtonsPanel, Panel):
@@ -522,32 +576,46 @@ class PARTICLE_PT_rotation(ParticleButtonsPanel, Panel):
part = context.space_data.pin_id
layout.enabled = particle_panel_enabled(context, psys) and part.use_rotations
+ layout.use_property_split = True
- layout.label(text="Initial Orientation:")
+ col = layout.column()
- split = layout.split()
+ col.prop(part, "rotation_mode")
+ col.prop(part, "rotation_factor_random", slider=True, text="Randomize")
- col = split.column(align=True)
- col.prop(part, "rotation_mode", text="")
- col.prop(part, "rotation_factor_random", slider=True, text="Random")
+ col.separator()
- col = split.column(align=True)
col.prop(part, "phase_factor", slider=True)
- col.prop(part, "phase_factor_random", text="Random", slider=True)
+ col.prop(part, "phase_factor_random", text="Randomize Phase ", slider=True)
if part.type != 'HAIR':
- layout.label(text="Angular Velocity:")
+ col.prop(part, "use_dynamic_rotation")
- split = layout.split()
- col = split.column(align=True)
- col.prop(part, "angular_velocity_mode", text="")
- sub = col.column(align=True)
- sub.active = part.angular_velocity_mode != 'NONE'
- sub.prop(part, "angular_velocity_factor", text="")
+class PARTICLE_PT_rotation_angular_velocity(ParticleButtonsPanel, Panel):
+ bl_label = "Angular Velocity"
+ bl_parent_id = "PARTICLE_PT_rotation"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
- col = split.column()
- col.prop(part, "use_dynamic_rotation")
+ def draw(self, context):
+ layout = self.layout
+
+ psys = context.particle_system
+ if psys:
+ part = psys.settings
+ else:
+ part = context.space_data.pin_id
+
+ layout.enabled = particle_panel_enabled(context, psys) and part.use_rotations
+ layout.use_property_split = True
+
+ col = layout.column()
+
+ col.prop(part, "angular_velocity_mode", text="Axis")
+ sub = col.column(align=True)
+ sub.active = part.angular_velocity_mode != 'NONE'
+ sub.prop(part, "angular_velocity_factor", text="Amount")
class PARTICLE_PT_physics(ParticleButtonsPanel, Panel):
@@ -568,127 +636,87 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
psys = context.particle_system
part = particle_get_settings(context)
layout.enabled = particle_panel_enabled(context, psys)
- layout.row().prop(part, "physics_type", expand=True)
+ layout.prop(part, "physics_type")
- row = layout.row()
+ col = layout.column()
if part.physics_type != 'NO':
- col = row.column(align=True)
+ col = col.column()
col.prop(part, "mass")
col.prop(part, "use_multiply_size_mass", text="Multiply mass with size")
- if part.physics_type in {'NEWTON', 'FLUID'}:
- split = layout.split()
+ if part.physics_type == 'FLUID':
+ fluid = part.fluid
- col = split.column()
- col.label(text="Forces:")
- col.prop(part, "brownian_factor")
- col.prop(part, "drag_factor", slider=True)
- col.prop(part, "damping", slider=True)
+ col.label(text="Fluid")
+ col.prop(fluid, "solver")
+ col.prop(fluid, "stiffness", text="Stiffness")
+ col.prop(fluid, "linear_viscosity", text="Viscosity")
+ col.prop(fluid, "buoyancy", text="Buoyancy", slider=True)
- col = split.column()
- col.label(text="Integration:")
- col.prop(part, "integrator", text="")
- col.prop(part, "timestep")
- sub = col.row()
- sub.prop(part, "subframes")
- supports_courant = part.physics_type == 'FLUID'
- subsub = sub.row()
- subsub.enabled = supports_courant
- subsub.prop(part, "use_adaptive_subframes", text="")
- if supports_courant and part.use_adaptive_subframes:
- col.prop(part, "courant_target", text="Threshold")
+ col.label(text="Advanced")
- row = layout.row()
- row.prop(part, "use_size_deflect")
- row.prop(part, "use_die_on_collision")
+ if fluid.solver == 'DDR':
+ sub = col.column()
+ sub.prop(fluid, "repulsion", slider=fluid.factor_repulsion)
+ sub.prop(fluid, "factor_repulsion")
- layout.prop(part, "collision_group")
+ sub.prop(fluid, "stiff_viscosity", slider=fluid.factor_stiff_viscosity)
+ sub.prop(fluid, "factor_stiff_viscosity")
+
+ sub = col.column()
+ sub.prop(fluid, "fluid_radius", slider=fluid.factor_radius)
+ sub.prop(fluid, "factor_radius")
+
+ sub.prop(fluid, "rest_density", slider=fluid.use_factor_density)
+ sub.prop(fluid, "use_factor_density")
- if part.physics_type == 'FLUID':
- fluid = part.fluid
-
- split = layout.split()
- sub = split.row()
- sub.prop(fluid, "solver", expand=True)
-
- split = layout.split()
-
- col = split.column()
- col.label(text="Fluid Properties:")
- col.prop(fluid, "stiffness", text="Stiffness")
- col.prop(fluid, "linear_viscosity", text="Viscosity")
- col.prop(fluid, "buoyancy", text="Buoyancy", slider=True)
-
- col = split.column()
- col.label(text="Advanced:")
-
- if fluid.solver == 'DDR':
- sub = col.row()
- sub.prop(fluid, "repulsion", slider=fluid.factor_repulsion)
- sub.prop(fluid, "factor_repulsion", text="")
-
- sub = col.row()
- sub.prop(fluid, "stiff_viscosity", slider=fluid.factor_stiff_viscosity)
- sub.prop(fluid, "factor_stiff_viscosity", text="")
-
- sub = col.row()
- sub.prop(fluid, "fluid_radius", slider=fluid.factor_radius)
- sub.prop(fluid, "factor_radius", text="")
-
- sub = col.row()
- sub.prop(fluid, "rest_density", slider=fluid.use_factor_density)
- sub.prop(fluid, "use_factor_density", text="")
-
- if fluid.solver == 'CLASSICAL':
- # With the classical solver, it is possible to calculate the
- # spacing between particles when the fluid is at rest. This
- # makes it easier to set stable initial conditions.
- particle_volume = part.mass / fluid.rest_density
- spacing = pow(particle_volume, 1.0 / 3.0)
- sub = col.row()
- sub.label(text="Spacing: %g" % spacing)
-
- elif fluid.solver == 'DDR':
- split = layout.split()
-
- col = split.column()
- col.label(text="Springs:")
- col.prop(fluid, "spring_force", text="Force")
- col.prop(fluid, "use_viscoelastic_springs")
- sub = col.column(align=True)
- sub.active = fluid.use_viscoelastic_springs
- sub.prop(fluid, "yield_ratio", slider=True)
- sub.prop(fluid, "plasticity", slider=True)
-
- col = split.column()
- col.label(text="Advanced:")
- sub = col.row()
- sub.prop(fluid, "rest_length", slider=fluid.factor_rest_length)
- sub.prop(fluid, "factor_rest_length", text="")
- col.label(text="")
- sub = col.column()
- sub.active = fluid.use_viscoelastic_springs
- sub.prop(fluid, "use_initial_rest_length")
- sub.prop(fluid, "spring_frames", text="Frames")
+ if fluid.solver == 'CLASSICAL':
+ # With the classical solver, it is possible to calculate the
+ # spacing between particles when the fluid is at rest. This
+ # makes it easier to set stable initial conditions.
+ particle_volume = part.mass / fluid.rest_density
+ spacing = pow(particle_volume, 1.0 / 3.0)
+
+ sub.label(text="Spacing: %g" % spacing)
+
+ elif fluid.solver == 'DDR':
+
+ col.label(text="Springs")
+ col.prop(fluid, "spring_force", text="Force")
+ col.prop(fluid, "use_viscoelastic_springs")
+
+ sub = col.column()
+ sub.active = fluid.use_viscoelastic_springs
+ sub.prop(fluid, "yield_ratio", slider=True)
+ sub.prop(fluid, "plasticity", slider=True)
+
+ col.label(text="Advanced")
+ sub = col.column()
+ sub.prop(fluid, "rest_length", slider=fluid.factor_rest_length)
+ sub.prop(fluid, "factor_rest_length", text="")
+
+ sub = col.column()
+ sub.active = fluid.use_viscoelastic_springs
+ sub.prop(fluid, "use_initial_rest_length")
+ sub.prop(fluid, "spring_frames", text="Frames")
elif part.physics_type == 'KEYED':
- split = layout.split()
- sub = split.column()
- row = layout.row()
- col = row.column()
- col.active = not psys.use_keyed_timing
- col.prop(part, "keyed_loops", text="Loops")
+ sub = col.column()
+ sub.active = not psys.use_keyed_timing
+ sub.prop(part, "keyed_loops", text="Loops")
if psys:
- row.prop(psys, "use_keyed_timing", text="Use Timing")
+ col.prop(psys, "use_keyed_timing", text="Use Timing")
+
+ col.label(text="Keys")
- layout.label(text="Keys:")
elif part.physics_type == 'BOIDS':
boids = part.boids
@@ -786,6 +814,93 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, Panel):
sub.prop(key, "system", text="System")
+class PARTICLE_PT_physics_deflection(ParticleButtonsPanel, Panel):
+ bl_label = "Deflection"
+ bl_parent_id = "PARTICLE_PT_physics"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.physics_type in {'NEWTON', 'FLUID'}
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ psys = context.particle_system
+ part = particle_get_settings(context)
+
+ layout.enabled = particle_panel_enabled(context, psys)
+
+ col = layout.column()
+ col.prop(part, "use_size_deflect")
+ col.prop(part, "use_die_on_collision")
+
+ col.prop(part, "collision_group")
+
+
+class PARTICLE_PT_physics_forces(ParticleButtonsPanel, Panel):
+ bl_label = "Forces"
+ bl_parent_id = "PARTICLE_PT_physics"
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.physics_type == 'NEWTON'
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ psys = context.particle_system
+ part = particle_get_settings(context)
+
+ layout.enabled = particle_panel_enabled(context, psys)
+
+ col = layout.column()
+
+ col.prop(part, "brownian_factor")
+ col.prop(part, "drag_factor", slider=True)
+ col.prop(part, "damping", slider=True)
+
+
+class PARTICLE_PT_physics_integration(ParticleButtonsPanel, Panel):
+ bl_label = "Integration"
+ bl_options = {'DEFAULT_CLOSED'}
+ bl_parent_id = "PARTICLE_PT_physics"
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.physics_type == 'NEWTON'
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ psys = context.particle_system
+ part = particle_get_settings(context)
+
+ layout.enabled = particle_panel_enabled(context, psys)
+
+ col = layout.column()
+
+ col.prop(part, "integrator")
+ col.prop(part, "timestep")
+ sub = col.row()
+ sub.prop(part, "subframes")
+ supports_courant = part.physics_type == 'FLUID'
+ subsub = sub.row()
+ subsub.enabled = supports_courant
+ subsub.prop(part, "use_adaptive_subframes", text="")
+ if supports_courant and part.use_adaptive_subframes:
+ col.prop(part, "courant_target", text="Threshold")
+
+
class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel):
bl_label = "Boid Brain"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
@@ -811,7 +926,7 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel):
# Currently boids can only use the first state so these are commented out for now.
#row = layout.row()
- #row.template_list("UI_UL_list", "particle_boids", boids, "states",
+ # row.template_list("UI_UL_list", "particle_boids", boids, "states",
# boids, "active_boid_state_index", compact="True")
#col = row.row()
#sub = col.row(align=True)
@@ -904,175 +1019,387 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
psys = context.particle_system
part = particle_get_settings(context)
+ layout.prop(part, "render_type", text="Render As")
+
+ if part.type == 'EMITTER' or \
+ (part.render_type in {'OBJECT', 'COLLECTION'} and part.type == 'HAIR'):
+ if part.render_type not in {'NONE'}:
+
+ col = layout.column(align=True)
+ col.prop(part, "particle_size", text="Scale")
+ col.prop(part, "size_random", slider=True, text="Scale Randomness")
+
if psys:
- row = layout.row()
- if part.render_type in {'OBJECT', 'GROUP'}:
- row.enabled = False
- row.prop(part, "material_slot", text="")
- row.prop(psys, "parent")
+ col = layout.column()
+ if part.render_type not in {'OBJECT', 'COLLECTION', 'NONE'}:
+ # col.enabled = False
+ col.prop(part, "material_slot", text="Material")
+ col.prop(psys, "parent", text="Coordinate System")
- split = layout.split()
- col = split.column()
- col.prop(part, "use_parent_particles")
+class PARTICLE_PT_render_extra(ParticleButtonsPanel, Panel):
+ bl_label = "Extra"
+ bl_parent_id = "PARTICLE_PT_render"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
- col = split.column()
- col.prop(part, "show_unborn")
- col.prop(part, "use_dead")
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.render_type != 'NONE'
- layout.row().prop(part, "render_type", expand=True)
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
- split = layout.split()
+ psys = context.particle_system
+ ob = context.object
+ part = particle_get_settings(context)
- col = split.column()
+ col = layout.column()
- if part.render_type == 'LINE':
- col.prop(part, "line_length_tail")
- col.prop(part, "line_length_head")
+ col = layout.column()
+ col.prop(part, "use_parent_particles", text="Parent Particles")
+ col.prop(part, "show_unborn", text="Unborn")
+ col.prop(part, "use_dead", text="Dead")
- split.prop(part, "use_velocity_length")
- elif part.render_type == 'PATH':
- col.prop(part, "use_strand_primitive")
- sub = col.column()
- sub.active = (part.use_strand_primitive is False)
- sub.prop(part, "use_render_adaptive")
- sub = col.column()
- sub.active = part.use_render_adaptive or part.use_strand_primitive is True
- sub.prop(part, "adaptive_angle")
- sub = col.column()
- sub.active = (part.use_render_adaptive is True and part.use_strand_primitive is False)
- sub.prop(part, "adaptive_pixel")
- col.prop(part, "use_hair_bspline")
- col.prop(part, "render_step", text="Steps")
- col = split.column()
- col.label(text="Timing:")
- col.prop(part, "use_absolute_path_time")
+class PARTICLE_PT_render_line(ParticleButtonsPanel, Panel):
+ bl_label = "Line"
+ bl_parent_id = "PARTICLE_PT_render"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
- if part.type == 'HAIR' or psys.point_cache.is_baked:
- col.prop(part, "path_start", text="Start", slider=not part.use_absolute_path_time)
- else:
- col.prop(part, "trail_count")
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.render_type == 'LINE'
- col.prop(part, "path_end", text="End", slider=not part.use_absolute_path_time)
- col.prop(part, "length_random", text="Random", slider=True)
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
- elif part.render_type == 'OBJECT':
- col.prop(part, "dupli_object")
- sub = col.row()
- sub.prop(part, "use_global_dupli")
- sub.prop(part, "use_rotation_dupli")
- sub.prop(part, "use_scale_dupli")
- elif part.render_type == 'GROUP':
- col.prop(part, "dupli_group")
- split = layout.split()
+ psys = context.particle_system
+ ob = context.object
+ part = particle_get_settings(context)
- col = split.column()
- col.prop(part, "use_whole_group")
- sub = col.column()
- sub.active = (part.use_whole_group is False)
- sub.prop(part, "use_group_pick_random")
- sub.prop(part, "use_group_count")
+ col = layout.column()
- col = split.column()
- sub = col.column()
- sub.active = (part.use_whole_group is False)
- sub.prop(part, "use_global_dupli")
- sub.prop(part, "use_rotation_dupli")
- sub.prop(part, "use_scale_dupli")
+ col.separator()
+ sub = col.column(align=True)
+ sub.prop(part, "line_length_tail", text="Length Tail")
+ sub.prop(part, "line_length_head", text="Head")
+ col.prop(part, "use_velocity_length", text="Velocity Length")
- if part.use_group_count and not part.use_whole_group:
- row = layout.row()
- row.template_list("UI_UL_list", "particle_dupli_weights", part, "dupli_weights",
- part, "active_dupliweight_index")
- col = row.column()
- sub = col.row()
- subsub = sub.column(align=True)
- subsub.operator("particle.dupliob_copy", icon='ZOOMIN', text="")
- subsub.operator("particle.dupliob_remove", icon='ZOOMOUT', text="")
- subsub.operator("particle.dupliob_move_up", icon='TRIA_UP', text="")
- subsub.operator("particle.dupliob_move_down", icon='TRIA_DOWN', text="")
+class PARTICLE_PT_render_path(ParticleButtonsPanel, Panel):
+ bl_label = "Path"
+ bl_parent_id = "PARTICLE_PT_render"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
- weight = part.active_dupliweight
- if weight:
- row = layout.row()
- row.prop(weight, "count")
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.render_type == 'PATH'
- elif part.render_type == 'BILLBOARD':
- ob = context.object
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
- col.label(text="Align:")
+ psys = context.particle_system
+ ob = context.object
+ part = particle_get_settings(context)
- row = layout.row()
- row.prop(part, "billboard_align", expand=True)
- row.prop(part, "lock_billboard", text="Lock")
- row = layout.row()
- row.prop(part, "billboard_object")
+ col = layout.column()
- row = layout.row()
- col = row.column(align=True)
- col.label(text="Tilt:")
- col.prop(part, "billboard_tilt", text="Angle", slider=True)
- col.prop(part, "billboard_tilt_random", text="Random", slider=True)
- col = row.column()
- col.prop(part, "billboard_offset")
+ col.prop(part, "use_strand_primitive")
+ sub = col.column()
+ sub.active = (part.use_strand_primitive is False)
+ sub.prop(part, "use_render_adaptive")
+ sub = col.column()
+ sub.active = part.use_render_adaptive or part.use_strand_primitive is True
+ sub.prop(part, "adaptive_angle")
+ sub = col.column()
+ sub.active = (part.use_render_adaptive is True and part.use_strand_primitive is False)
+ sub.prop(part, "adaptive_pixel")
+ col.prop(part, "use_hair_bspline")
+ col.prop(part, "render_step", text="Steps")
+
+
+class PARTICLE_PT_render_path_timing(ParticleButtonsPanel, Panel):
+ bl_label = "Timing"
+ bl_parent_id = "PARTICLE_PT_render"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
- row = layout.row()
- col = row.column()
- col.prop(part, "billboard_size", text="Scale")
- if part.billboard_align == 'VEL':
- col = row.column(align=True)
- col.label("Velocity Scale:")
- col.prop(part, "billboard_velocity_head", text="Head")
- col.prop(part, "billboard_velocity_tail", text="Tail")
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.render_type == 'PATH'
- if psys:
- col = layout.column()
- col.prop_search(psys, "billboard_normal_uv", ob.data, "uv_layers")
- col.prop_search(psys, "billboard_time_index_uv", ob.data, "uv_layers")
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
- split = layout.split(percentage=0.33)
- split.label(text="Split UVs:")
- split.prop(part, "billboard_uv_split", text="Number of splits")
+ psys = context.particle_system
+ ob = context.object
+ part = particle_get_settings(context)
- if psys:
- col = layout.column()
- col.active = part.billboard_uv_split > 1
- col.prop_search(psys, "billboard_split_uv", ob.data, "uv_layers")
+ col = layout.column()
- row = col.row()
- row.label(text="Animate:")
- row.prop(part, "billboard_animation", text="")
- row.label(text="Offset:")
- row.prop(part, "billboard_offset_split", text="")
+ col.prop(part, "use_absolute_path_time")
- if part.render_type == 'HALO' or part.render_type == 'LINE' or part.render_type == 'BILLBOARD':
- row = layout.row()
- col = row.column()
+ if part.type == 'HAIR' or psys.point_cache.is_baked:
+ col.prop(part, "path_start", text="Start", slider=not part.use_absolute_path_time)
+ else:
col.prop(part, "trail_count")
- if part.trail_count > 1:
- col.prop(part, "use_absolute_path_time", text="Length in Frames")
- col = row.column()
- col.prop(part, "path_end", text="Length", slider=not part.use_absolute_path_time)
- col.prop(part, "length_random", text="Random", slider=True)
- else:
- col = row.column()
- col.label(text="")
- if part.type == 'EMITTER' or \
- (part.render_type in {'OBJECT', 'GROUP'} and part.type == 'HAIR'):
- row = layout.row(align=True)
- row.prop(part, "particle_size")
- row.prop(part, "size_random", slider=True)
+ col.prop(part, "path_end", text="End", slider=not part.use_absolute_path_time)
+ col.prop(part, "length_random", text="Random", slider=True)
+
+
+class PARTICLE_PT_render_object(ParticleButtonsPanel, Panel):
+ bl_label = "Object"
+ bl_parent_id = "PARTICLE_PT_render"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.render_type == 'OBJECT'
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ psys = context.particle_system
+ ob = context.object
+ part = particle_get_settings(context)
+
+ col = layout.column()
+
+ col.prop(part, "dupli_object", text="Instance Object")
+ sub = col.column()
+ sub.prop(part, "use_global_dupli", text="Global Coordinates")
+ sub.prop(part, "use_rotation_dupli", text="Object Rotation")
+ sub.prop(part, "use_scale_dupli", text="Object Scale")
+
+
+class PARTICLE_PT_render_collection(ParticleButtonsPanel, Panel):
+ bl_label = "Collection"
+ bl_parent_id = "PARTICLE_PT_render"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.render_type == 'COLLECTION'
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ psys = context.particle_system
+ ob = context.object
+ part = particle_get_settings(context)
+
+ col = layout.column()
+
+ col.prop(part, "dupli_group")
+
+ col.prop(part, "use_whole_group")
+ sub = col.column()
+ sub.active = (part.use_whole_group is False)
+ sub.prop(part, "use_group_pick_random")
+ sub.prop(part, "use_global_dupli", text="Global Coordinates")
+ sub.prop(part, "use_rotation_dupli", text="Object Rotation")
+ sub.prop(part, "use_scale_dupli", text="Object Scale")
+
+
+class PARTICLE_PT_render_collection_use_count(ParticleButtonsPanel, Panel):
+ bl_label = "Use Count"
+ bl_parent_id = "PARTICLE_PT_render_collection"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.render_type == 'COLLECTION'
+
+ def draw_header(self, context):
+ layout = self.layout
+ part = particle_get_settings(context)
+
+ layout.active = not part.use_whole_group
+
+ layout.prop(part, "use_group_count", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ psys = context.particle_system
+ ob = context.object
+ part = particle_get_settings(context)
+
+ col = layout.column()
+
+ layout.active = part.use_group_count and not part.use_whole_group
+
+ row = layout.row()
+ row.template_list("UI_UL_list", "particle_dupli_weights", part, "dupli_weights",
+ part, "active_dupliweight_index")
+
+ col = row.column()
+ sub = col.row()
+ subsub = sub.column(align=True)
+ subsub.operator("particle.dupliob_copy", icon='ZOOMIN', text="")
+ subsub.operator("particle.dupliob_remove", icon='ZOOMOUT', text="")
+ subsub.operator("particle.dupliob_move_up", icon='TRIA_UP', text="")
+ subsub.operator("particle.dupliob_move_down", icon='TRIA_DOWN', text="")
+
+ weight = part.active_dupliweight
+ if weight:
+ row = layout.row()
+ row.prop(weight, "count")
+
+
+class PARTICLE_PT_render_billboards_alignment(ParticleButtonsPanel, Panel):
+ bl_label = "Billboard Alignment"
+ bl_parent_id = "PARTICLE_PT_render"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.render_type == 'BILLBOARD'
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ psys = context.particle_system
+ ob = context.object
+ part = particle_get_settings(context)
+
+ col = layout.column()
+
+ col.prop(part, "billboard_align", text="Align To")
+ col.prop(part, "lock_billboard", text="Lock Axis")
+ col.prop(part, "billboard_object")
+
+
+class PARTICLE_PT_render_billboards_tilt(ParticleButtonsPanel, Panel):
+ bl_label = "Billboard Tilt"
+ bl_parent_id = "PARTICLE_PT_render"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.render_type == 'BILLBOARD'
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ psys = context.particle_system
+ ob = context.object
+ part = particle_get_settings(context)
+
+ col = layout.column()
+
+ sub = col.column(align=True)
+ sub.prop(part, "billboard_tilt", text="Angle", slider=True)
+ sub.prop(part, "billboard_tilt_random", text="Random", slider=True)
+
+ sub = col.column(align=True)
+ sub.prop(part, "billboard_offset")
+ col.prop(part, "billboard_size", text="Scale")
+ if part.billboard_align == 'VEL':
+ col = col.column(align=True)
+ col.prop(part, "billboard_velocity_head", text="Velocity ScaleHead")
+ col.prop(part, "billboard_velocity_tail", text="Tail")
+
+
+class PARTICLE_PT_render_billboards_uv(ParticleButtonsPanel, Panel):
+ bl_label = "Billboard UVs"
+ bl_parent_id = "PARTICLE_PT_render"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.render_type == 'BILLBOARD'
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ psys = context.particle_system
+ ob = context.object
+ part = particle_get_settings(context)
+
+ col = layout.column()
+
+ if psys:
+ col.prop_search(psys, "billboard_normal_uv", ob.data, "uv_layers")
+ col.prop_search(psys, "billboard_time_index_uv", ob.data, "uv_layers")
+
+ col.prop(part, "billboard_uv_split", text="Split UVs")
+
+ if psys:
+ sub = col.column()
+ sub.active = part.billboard_uv_split > 1
+ sub.prop_search(psys, "billboard_split_uv", ob.data, "uv_layers")
+
+ sub.prop(part, "billboard_animation")
+ sub.prop(part, "billboard_offset_split")
+
+
+class PARTICLE_PT_render_trails(ParticleButtonsPanel, Panel):
+ bl_label = "Trails"
+ bl_parent_id = "PARTICLE_PT_render"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.render_type in {'HALO', 'LINE', 'BILLBOARD'}
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ psys = context.particle_system
+ part = particle_get_settings(context)
+
+ col = layout.column()
+
+ col.prop(part, "trail_count")
+
+ sub = col.column()
+ sub.active = (part.trail_count > 1)
+ sub.prop(part, "use_absolute_path_time", text="Length in Frames")
+ sub.prop(part, "path_end", text="Length", slider=not part.use_absolute_path_time)
+ sub.prop(part, "length_random", text="Random Length", slider=True)
class PARTICLE_PT_draw(ParticleButtonsPanel, Panel):
- bl_label = "Display"
+ bl_label = "Viewport Display"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
@@ -1086,53 +1413,52 @@ class PARTICLE_PT_draw(ParticleButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
psys = context.particle_system
part = particle_get_settings(context)
- row = layout.row()
- row.prop(part, "draw_method", expand=True)
- row.prop(part, "show_guide_hairs")
+ layout.prop(part, "draw_method", text="Display As")
if part.draw_method == 'NONE' or (part.render_type == 'NONE' and part.draw_method == 'RENDER'):
return
path = (part.render_type == 'PATH' and part.draw_method == 'RENDER') or part.draw_method == 'PATH'
- row = layout.row()
- row.prop(part, "draw_percentage", slider=True)
+ layout.separator()
+
+ col = layout.column()
+ col.prop(part, "draw_color", text="Color")
+ if part.draw_color in {'VELOCITY', 'ACCELERATION'}:
+ col.prop(part, "color_maximum", text="Fade Distance")
+
+ col = layout.column()
+
+ if path:
+ col.prop(part, "draw_step", text="Strand Steps")
+ col.prop(part, "draw_percentage", slider=True, text="Amount")
if part.draw_method != 'RENDER' or part.render_type == 'HALO':
- row.prop(part, "draw_size")
- else:
- row.label(text="")
+ col.prop(part, "draw_size", text="Size")
if part.draw_percentage != 100 and psys is not None:
if part.type == 'HAIR':
if psys.use_hair_dynamics and psys.point_cache.is_baked is False:
- layout.row().label(text="Display percentage makes dynamics inaccurate without baking!")
+ layout.row().label(text="Display percentage makes dynamics inaccurate without baking")
else:
phystype = part.physics_type
if phystype != 'NO' and phystype != 'KEYED' and psys.point_cache.is_baked is False:
- layout.row().label(text="Display percentage makes dynamics inaccurate without baking!")
+ layout.row().label(text="Display percentage makes dynamics inaccurate without baking")
+ else:
+ layout.row().label(text="")
- row = layout.row()
- col = row.column()
+ col = layout.column()
+ col.prop(part, "show_guide_hairs", text="Guide Hairs")
col.prop(part, "show_size")
col.prop(part, "show_velocity")
col.prop(part, "show_number")
if part.physics_type == 'BOIDS':
col.prop(part, "show_health")
- col = row.column(align=True)
- col.label(text="Color:")
- col.prop(part, "draw_color", text="")
- sub = col.row(align=True)
- sub.active = (part.draw_color in {'VELOCITY', 'ACCELERATION'})
- sub.prop(part, "color_maximum", text="Max")
-
- if path:
- col.prop(part, "draw_step")
-
class PARTICLE_PT_children(ParticleButtonsPanel, Panel):
bl_label = "Children"
@@ -1151,37 +1477,91 @@ class PARTICLE_PT_children(ParticleButtonsPanel, Panel):
layout.row().prop(part, "child_type", expand=True)
+ layout.use_property_split = True
+
if part.child_type == 'NONE':
return
- row = layout.row()
+ col = layout.column()
- col = row.column(align=True)
- col.prop(part, "child_nbr", text="Display")
- col.prop(part, "rendered_child_count", text="Render")
+ sub = col.column(align=True)
+ sub.prop(part, "child_nbr", text="Display Amount")
+ sub.prop(part, "rendered_child_count", text="Render Amount")
+
+ col.separator()
+
+ col.prop(part, "child_length", slider=True)
+ col.prop(part, "child_length_threshold", slider=True)
+ if psys:
+ col.prop(psys, "child_seed", text="Seed")
+
+ col.separator()
if part.child_type == 'INTERPOLATED':
- col = row.column()
- if psys:
- col.prop(psys, "child_seed", text="Seed")
col.prop(part, "virtual_parents", slider=True)
col.prop(part, "create_long_hair_children")
else:
- col = row.column(align=True)
- col.prop(part, "child_size", text="Size")
- col.prop(part, "child_size_random", text="Random")
+ col.separator()
+ sub = col.column(align=True)
+ sub.prop(part, "child_size", text="Size")
+ sub.prop(part, "child_size_random", text="Randomize Size", slider=True)
- split = layout.split()
+ if part.child_type == 'SIMPLE':
+ col.separator()
+ col.prop(part, "child_radius", text="Radius")
+ col.prop(part, "child_roundness", text="Roundness", slider=True)
+ elif part.virtual_parents > 0.0:
+ sub = col.column(align=True)
+ sub.label(text="Parting not available with virtual parents")
- col = split.column()
- col.label(text="Effects:")
- sub = col.column(align=True)
- if part.child_type == 'SIMPLE':
- sub.prop(part, "twist")
- sub.prop(part, "use_twist_curve")
- if part.use_twist_curve:
- sub.template_curve_mapping(part, "twist_curve")
+class PARTICLE_PT_children_parting(ParticleButtonsPanel, Panel):
+ bl_label = "Parting"
+ bl_parent_id = "PARTICLE_PT_children"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.child_type == 'INTERPOLATED'
+
+ def draw(self, context):
+ layout = self.layout
+
+ psys = context.particle_system
+ part = particle_get_settings(context)
+
+ layout.use_property_split = True
+
+ col = layout.column()
+ col.prop(part, "child_parting_factor", text="Parting", slider=True)
+ col.prop(part, "child_parting_min", text="Min")
+ col.prop(part, "child_parting_max", text="Max")
+
+
+class PARTICLE_PT_children_clumping(ParticleButtonsPanel, Panel):
+ bl_label = "Clumping"
+ bl_parent_id = "PARTICLE_PT_children"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.child_type != 'NONE'
+
+ def draw(self, context):
+ layout = self.layout
+
+ psys = context.particle_system
+ part = particle_get_settings(context)
+
+ layout.use_property_split = True
+
+ col = layout.column()
+
+ sub = col.column()
sub.prop(part, "use_clump_curve")
if part.use_clump_curve:
@@ -1195,28 +1575,33 @@ class PARTICLE_PT_children(ParticleButtonsPanel, Panel):
subsub.enabled = part.use_clump_noise
subsub.prop(part, "clump_noise_size")
- sub = col.column(align=True)
- sub.prop(part, "child_length", slider=True)
- sub.prop(part, "child_length_threshold", slider=True)
-
if part.child_type == 'SIMPLE':
- sub = col.column(align=True)
- sub.prop(part, "child_radius", text="Radius")
- sub.prop(part, "child_roundness", text="Roundness", slider=True)
- if psys:
- sub.prop(psys, "child_seed", text="Seed")
- elif part.virtual_parents > 0.0:
- sub = col.column(align=True)
- sub.label(text="Parting not")
- sub.label(text="available with")
- sub.label(text="virtual parents")
- else:
- sub = col.column(align=True)
- sub.prop(part, "child_parting_factor", text="Parting", slider=True)
- sub.prop(part, "child_parting_min", text="Min")
- sub.prop(part, "child_parting_max", text="Max")
+ sub.prop(part, "twist")
+ sub.prop(part, "use_twist_curve")
+ if part.use_twist_curve:
+ sub.template_curve_mapping(part, "twist_curve")
+
+
+class PARTICLE_PT_children_roughness(ParticleButtonsPanel, Panel):
+ bl_label = "Roughness"
+ bl_parent_id = "PARTICLE_PT_children"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.child_type != 'NONE'
+
+ def draw(self, context):
+ layout = self.layout
+
+ psys = context.particle_system
+ part = particle_get_settings(context)
+
+ layout.use_property_split = True
- col = split.column()
+ col = layout.column()
col.prop(part, "use_roughness_curve")
if part.use_roughness_curve:
@@ -1225,8 +1610,6 @@ class PARTICLE_PT_children(ParticleButtonsPanel, Panel):
sub.prop(part, "roughness_1", text="Roughness")
sub.prop(part, "roughness_1_size", text="Size")
else:
- col.label(text="Roughness:")
-
sub = col.column(align=True)
sub.prop(part, "roughness_1", text="Uniform")
sub.prop(part, "roughness_1_size", text="Size")
@@ -1240,31 +1623,55 @@ class PARTICLE_PT_children(ParticleButtonsPanel, Panel):
sub.prop(part, "roughness_2_size", text="Size")
sub.prop(part, "roughness_2_threshold", slider=True)
- layout.row().label(text="Kink:")
- layout.row().prop(part, "kink", expand=True)
- split = layout.split()
- split.active = part.kink != 'NO'
+class PARTICLE_PT_children_kink(ParticleButtonsPanel, Panel):
+ bl_label = "Kink"
+ bl_parent_id = "PARTICLE_PT_children"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ part = particle_get_settings(context)
+ return part.child_type != 'NONE'
+
+ def draw(self, context):
+ layout = self.layout
+
+ psys = context.particle_system
+ part = particle_get_settings(context)
+
+ layout.use_property_split = True
+
+ col = layout.column()
+
+ col.prop(part, "kink", text="Kink Type")
+ col = layout.column()
+ col.active = part.kink != 'NO'
if part.kink == 'SPIRAL':
- col = split.column()
- sub = col.column(align=True)
- sub.prop(part, "kink_amplitude", text="Radius")
- sub.prop(part, "kink_amplitude_random", text="Random", slider=True)
- sub = col.column(align=True)
+
+ sub = col.column()
+ sub.prop(part, "kink_amplitude", text="Amplitude")
+ sub.prop(part, "kink_amplitude_random", text="Randomize Amplitude", slider=True)
+
+ col.separator()
+
+ sub = col.column()
sub.prop(part, "kink_axis")
- sub.prop(part, "kink_axis_random", text="Random", slider=True)
- col = split.column(align=True)
+ sub.prop(part, "kink_axis_random", text="Randomize Axis", slider=True)
+
+ col.separator()
+
col.prop(part, "kink_frequency", text="Frequency")
col.prop(part, "kink_shape", text="Shape", slider=True)
col.prop(part, "kink_extra_steps", text="Steps")
- else:
- col = split.column()
+
+ elif part.kink in {'CURL', 'RADIAL', 'WAVE', 'BRAID', 'WAVE'}:
sub = col.column(align=True)
sub.prop(part, "kink_amplitude")
sub.prop(part, "kink_amplitude_clump", text="Clump", slider=True)
col.prop(part, "kink_flat", slider=True)
- col = split.column(align=True)
col.prop(part, "kink_frequency")
col.prop(part, "kink_shape", slider=True)
@@ -1337,6 +1744,7 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
ob = context.object
psys = context.particle_system
@@ -1428,6 +1836,35 @@ class PARTICLE_PT_textures(ParticleButtonsPanel, Panel):
layout.template_ID(slot, "texture", new="texture.new")
+class PARTICLE_PT_hair_shape(ParticleButtonsPanel, Panel):
+ bl_label = "Hair Shape"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ if context.particle_system is None:
+ return False
+ return particle_panel_poll(cls, context)
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ psys = context.particle_system
+ part = psys.settings
+
+ layout.prop(part, "shape", text="Strand Shape")
+
+ col = layout.column(align=True)
+ col.prop(part, "root_radius", text="Radius Root")
+ col.prop(part, "tip_radius", text="Tip")
+
+ col = layout.column()
+ col.prop(part, "radius_scale", text="Radius Scaling")
+ col.prop(part, "use_close_tip")
+
+
class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_context_path = "particle_system.settings"
@@ -1440,15 +1877,37 @@ classes = (
PARTICLE_UL_particle_systems,
PARTICLE_PT_context_particles,
PARTICLE_PT_emission,
+ PARTICLE_PT_emission_source,
PARTICLE_PT_hair_dynamics,
+ PARTICLE_PT_hair_dynamics_structure,
+ PARTICLE_PT_hair_dynamics_volume,
PARTICLE_PT_cache,
PARTICLE_PT_velocity,
PARTICLE_PT_rotation,
+ PARTICLE_PT_rotation_angular_velocity,
PARTICLE_PT_physics,
+ PARTICLE_PT_physics_forces,
+ PARTICLE_PT_physics_deflection,
+ PARTICLE_PT_physics_integration,
PARTICLE_PT_boidbrain,
PARTICLE_PT_render,
+ PARTICLE_PT_render_line,
+ PARTICLE_PT_render_path,
+ PARTICLE_PT_render_path_timing,
+ PARTICLE_PT_render_object,
+ PARTICLE_PT_render_collection,
+ PARTICLE_PT_render_collection_use_count,
+ PARTICLE_PT_render_billboards_tilt,
+ PARTICLE_PT_render_billboards_uv,
+ PARTICLE_PT_render_trails,
+ PARTICLE_PT_render_extra,
PARTICLE_PT_draw,
PARTICLE_PT_children,
+ PARTICLE_PT_children_parting,
+ PARTICLE_PT_children_clumping,
+ PARTICLE_PT_children_roughness,
+ PARTICLE_PT_children_kink,
+ PARTICLE_PT_hair_shape,
PARTICLE_PT_field_weights,
PARTICLE_PT_force_fields,
PARTICLE_PT_vertexgroups,
diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index e0d0327324b..f450bc61635 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -257,6 +257,7 @@ class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel):
cloth = context.cloth.settings
effector_weights_ui(self, context, cloth.effector_weights, 'CLOTH')
+
classes = (
CLOTH_MT_presets,
PHYSICS_PT_cloth,
diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py
index 3615f8be48c..05c72bf47ee 100644
--- a/release/scripts/startup/bl_ui/properties_physics_common.py
+++ b/release/scripts/startup/bl_ui/properties_physics_common.py
@@ -274,7 +274,7 @@ def basic_force_field_settings_ui(self, context, field):
elif field.type == 'HARMONIC':
col.prop(field, "use_multiple_springs")
if field.type == 'FORCE':
- col.prop(field, "use_gravity_falloff", text="Gravitation")
+ col.prop(field, "use_gravity_falloff", text="Gravitation")
split = layout.split()
diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
index 817b0ab76ed..3cb9026fd02 100644
--- a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
@@ -117,7 +117,7 @@ class PHYSICS_PT_rigid_body_dynamics(PHYSICS_PT_rigidbody_panel, Panel):
rbo = ob.rigid_body
#col = layout.column(align=1)
- #col.label(text="Activation:")
+ # col.label(text="Activation:")
# XXX: settings such as activate on collison/etc.
split = layout.split()
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index bccde2da2f4..7cb0ce55be3 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -67,12 +67,13 @@ class RENDER_PT_context(Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
scene = context.scene
rd = scene.render
if rd.has_multiple_engines:
- layout.prop(rd, "engine", text="")
+ layout.prop(rd, "engine", text="Render Engine")
class RENDER_PT_dimensions(RenderButtonsPanel, Panel):
@@ -125,6 +126,7 @@ class RENDER_PT_dimensions(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
scene = context.scene
rd = scene.render
@@ -134,41 +136,47 @@ class RENDER_PT_dimensions(RenderButtonsPanel, Panel):
row.operator("render.preset_add", text="", icon='ZOOMIN')
row.operator("render.preset_add", text="", icon='ZOOMOUT').remove_active = True
- split = layout.split()
-
- col = split.column()
- sub = col.column(align=True)
- sub.label(text="Resolution:")
- sub.prop(rd, "resolution_x", text="X")
- sub.prop(rd, "resolution_y", text="Y")
- sub.prop(rd, "resolution_percentage", text="")
+ col = layout.column(align=True)
+ col.prop(rd, "resolution_x", text="Resolution X")
+ col.prop(rd, "resolution_y", text="Y")
+ col.prop(rd, "resolution_percentage", text="%")
- sub.label(text="Aspect Ratio:")
- sub.prop(rd, "pixel_aspect_x", text="X")
- sub.prop(rd, "pixel_aspect_y", text="Y")
+ col = layout.column(align=True)
+ col.prop(rd, "pixel_aspect_x", text="Aspect X")
+ col.prop(rd, "pixel_aspect_y", text="Y")
- row = col.row()
- row.prop(rd, "use_border", text="Border")
- sub = row.row()
+ col = layout.column(align=True)
+ col.prop(rd, "use_border", text="Border")
+ sub = col.column(align=True)
sub.active = rd.use_border
sub.prop(rd, "use_crop_to_border", text="Crop")
- col = split.column()
- sub = col.column(align=True)
- sub.label(text="Frame Range:")
- sub.prop(scene, "frame_start")
- sub.prop(scene, "frame_end")
- sub.prop(scene, "frame_step")
+ col = layout.column(align=True)
+ col.prop(scene, "frame_start", text="Frame Start")
+ col.prop(scene, "frame_end", text="End")
+ col.prop(scene, "frame_step", text="Step")
- sub.label(text="Frame Rate:")
+ col = layout.split(percentage=0.5)
+ col.alignment = 'RIGHT'
+ col.label(text="Frame Rate")
+ self.draw_framerate(col, rd)
- self.draw_framerate(sub, rd)
- subrow = sub.row(align=True)
- subrow.label(text="Time Remapping:")
- subrow = sub.row(align=True)
- subrow.prop(rd, "frame_map_old", text="Old")
- subrow.prop(rd, "frame_map_new", text="New")
+class RENDER_PT_frame_remapping(RenderButtonsPanel, Panel):
+ bl_label = "Time Remapping"
+ bl_parent_id = "RENDER_PT_dimensions"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+
+ rd = context.scene.render
+
+ col = layout.column(align=True)
+ col.prop(rd, "frame_map_old", text="Old")
+ col.prop(rd, "frame_map_new", text="New")
class RENDER_PT_post_processing(RenderButtonsPanel, Panel):
@@ -178,16 +186,15 @@ class RENDER_PT_post_processing(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
rd = context.scene.render
- split = layout.split()
-
- col = split.column()
+ col = layout.column(align=True)
col.prop(rd, "use_compositing")
col.prop(rd, "use_sequencer")
- split.prop(rd, "dither_intensity", text="Dither", slider=True)
+ col.prop(rd, "dither_intensity", text="Dither", slider=True)
class RENDER_PT_stamp(RenderButtonsPanel, Panel):
@@ -197,24 +204,13 @@ class RENDER_PT_stamp(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = False
rd = context.scene.render
- layout.prop(rd, "use_stamp")
- col = layout.column()
- col.active = rd.use_stamp
- row = col.row()
- row.prop(rd, "stamp_font_size", text="Font Size")
- row.prop(rd, "use_stamp_labels", text="Draw Labels")
-
- row = col.row()
- row.column().prop(rd, "stamp_foreground", slider=True)
- row.column().prop(rd, "stamp_background", slider=True)
-
- layout.label("Enabled Metadata")
split = layout.split()
- col = split.column()
+ col = split.column(align=True)
col.prop(rd, "use_stamp_time", text="Time")
col.prop(rd, "use_stamp_date", text="Date")
col.prop(rd, "use_stamp_render_time", text="RenderTime")
@@ -222,7 +218,7 @@ class RENDER_PT_stamp(RenderButtonsPanel, Panel):
col.prop(rd, "use_stamp_scene", text="Scene")
col.prop(rd, "use_stamp_memory", text="Memory")
- col = split.column()
+ col = split.column(align=True)
col.prop(rd, "use_stamp_camera", text="Camera")
col.prop(rd, "use_stamp_lens", text="Lens")
col.prop(rd, "use_stamp_filename", text="Filename")
@@ -230,14 +226,40 @@ class RENDER_PT_stamp(RenderButtonsPanel, Panel):
col.prop(rd, "use_stamp_marker", text="Marker")
col.prop(rd, "use_stamp_sequencer_strip", text="Seq. Strip")
- row = layout.split(percentage=0.2)
+ if rd.use_sequencer:
+ col.prop(rd, "use_stamp_strip_meta", text="Sequence Strip")
+
+ row = layout.split(percentage=0.3)
row.prop(rd, "use_stamp_note", text="Note")
sub = row.row()
sub.active = rd.use_stamp_note
sub.prop(rd, "stamp_note_text", text="")
- if rd.use_sequencer:
- layout.label("Sequencer:")
- layout.prop(rd, "use_stamp_strip_meta")
+
+
+class RENDER_PT_stamp_burn(RenderButtonsPanel, Panel):
+ bl_label = "Burn Into Image"
+ bl_parent_id = "RENDER_PT_stamp"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+
+ def draw_header(self, context):
+ rd = context.scene.render
+
+ self.layout.prop(rd, "use_stamp", text="")
+
+ def draw(self, context):
+ layout = self.layout
+
+ rd = context.scene.render
+
+ layout.use_property_split = True
+
+ col = layout.column()
+ col.active = rd.use_stamp
+ col.prop(rd, "stamp_font_size", text="Font Size")
+ col.prop(rd, "use_stamp_labels", text="Draw Labels")
+ col.column().prop(rd, "stamp_foreground", slider=True)
+ col.column().prop(rd, "stamp_background", slider=True)
class RENDER_PT_output(RenderButtonsPanel, Panel):
@@ -246,6 +268,7 @@ class RENDER_PT_output(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = False
rd = context.scene.render
image_settings = rd.image_settings
@@ -253,17 +276,17 @@ class RENDER_PT_output(RenderButtonsPanel, Panel):
layout.prop(rd, "filepath", text="")
- split = layout.split()
+ layout.use_property_split = True
- col = split.column()
- col.active = not rd.is_movie_format
- col.prop(rd, "use_overwrite")
- col.prop(rd, "use_placeholder")
-
- col = split.column()
+ col = layout.column(align=True)
+ sub = col.column(align=True)
+ sub.active = not rd.is_movie_format
+ sub.prop(rd, "use_overwrite")
+ sub.prop(rd, "use_placeholder")
col.prop(rd, "use_file_extension")
col.prop(rd, "use_render_cache")
+ layout.use_property_split = False
layout.template_image_settings(image_settings, color_management=False)
if rd.use_multiview:
layout.template_image_views(image_settings)
@@ -447,6 +470,7 @@ class RENDER_PT_eevee_ambient_occlusion(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
scene = context.scene
props = scene.eevee
@@ -475,6 +499,7 @@ class RENDER_PT_eevee_motion_blur(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
scene = context.scene
props = scene.eevee
@@ -500,6 +525,7 @@ class RENDER_PT_eevee_depth_of_field(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
scene = context.scene
props = scene.eevee
@@ -525,6 +551,8 @@ class RENDER_PT_eevee_bloom(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+
scene = context.scene
props = scene.eevee
@@ -554,20 +582,32 @@ class RENDER_PT_eevee_volumetric(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+
scene = context.scene
props = scene.eevee
layout.active = props.use_volumetric
col = layout.column()
- col.prop(props, "volumetric_start")
- col.prop(props, "volumetric_end")
+ sub = col.column(align=True)
+ sub.prop(props, "volumetric_start")
+ sub.prop(props, "volumetric_end")
col.prop(props, "volumetric_tile_size")
+ col.separator()
col.prop(props, "volumetric_samples")
- col.prop(props, "volumetric_sample_distribution")
+ sub.prop(props, "volumetric_sample_distribution")
+ col.separator()
col.prop(props, "use_volumetric_lights")
- col.prop(props, "volumetric_light_clamp")
+
+ sub = col.column()
+ sub.active = props.use_volumetric_lights
+ sub.prop(props, "volumetric_light_clamp", text="Light Clamping")
+ col.separator()
col.prop(props, "use_volumetric_shadows")
- col.prop(props, "volumetric_shadow_samples")
+ sub = col.column()
+ sub.active = props.use_volumetric_shadows
+ sub.prop(props, "volumetric_shadow_samples", text="Shadow Samples")
+ col.separator()
col.prop(props, "use_volumetric_colored_transmittance")
@@ -587,9 +627,13 @@ class RENDER_PT_eevee_subsurface_scattering(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+
scene = context.scene
props = scene.eevee
+ layout.active = props.use_sss
+
col = layout.column()
col.prop(props, "sss_samples")
col.prop(props, "sss_jitter_threshold")
@@ -612,12 +656,14 @@ class RENDER_PT_eevee_screen_space_reflections(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+
scene = context.scene
props = scene.eevee
col = layout.column()
col.active = props.use_ssr
- col.prop(props, "use_ssr_refraction")
+ col.prop(props, "use_ssr_refraction", text="Refraction")
col.prop(props, "use_ssr_halfres")
col.prop(props, "ssr_quality")
col.prop(props, "ssr_max_roughness")
@@ -637,6 +683,8 @@ class RENDER_PT_eevee_shadows(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+
scene = context.scene
props = scene.eevee
@@ -658,6 +706,8 @@ class RENDER_PT_eevee_sampling(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+
scene = context.scene
props = scene.eevee
@@ -678,6 +728,8 @@ class RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+
scene = context.scene
props = scene.eevee
@@ -698,30 +750,52 @@ class RENDER_PT_eevee_film(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+
scene = context.scene
rd = scene.render
- split = layout.split()
-
- col = split.column()
+ col = layout.column()
col.prop(rd, "filter_size")
-
- col = split.column()
col.prop(rd, "alpha_mode", text="Alpha")
+class RENDER_PT_hair(RenderButtonsPanel, Panel):
+ bl_label = "Hair"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ return (context.engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+ scene = context.scene
+ rd = scene.render
+
+ row = layout.row()
+ row.prop(rd, "hair_type", expand=True)
+
+ layout.use_property_split = True
+ layout.prop(rd, "hair_subdiv")
+
+
classes = (
RENDER_MT_presets,
RENDER_MT_ffmpeg_presets,
RENDER_MT_framerate_presets,
RENDER_PT_context,
RENDER_PT_dimensions,
+ RENDER_PT_frame_remapping,
RENDER_PT_post_processing,
- RENDER_PT_stamp,
RENDER_PT_output,
RENDER_PT_encoding,
+ RENDER_PT_stamp,
+ RENDER_PT_stamp_burn,
RENDER_UL_renderviews,
RENDER_PT_stereoscopy,
+ RENDER_PT_hair,
RENDER_PT_clay_settings,
RENDER_PT_eevee_sampling,
RENDER_PT_eevee_film,
diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py
index 545d0d696dc..4c5b1a86235 100644
--- a/release/scripts/startup/bl_ui/properties_scene.py
+++ b/release/scripts/startup/bl_ui/properties_scene.py
@@ -19,10 +19,10 @@
# <pep8 compliant>
import bpy
from bpy.types import (
- Menu,
- Panel,
- UIList,
- )
+ Menu,
+ Panel,
+ UIList,
+)
from rna_prop_ui import PropertyPanel
@@ -69,12 +69,12 @@ class SCENE_PT_scene(SceneButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
-
+ layout.use_property_split = True
scene = context.scene
layout.prop(scene, "camera")
- layout.prop(scene, "background_set", text="Background")
- layout.prop(scene, "active_clip", text="Active Clip")
+ layout.prop(scene, "background_set")
+ layout.prop(scene, "active_clip")
class SCENE_PT_unit(SceneButtonsPanel, Panel):
@@ -91,23 +91,18 @@ class SCENE_PT_unit(SceneButtonsPanel, Panel):
row.operator("scene.units_length_preset_add", text="", icon='ZOOMIN')
row.operator("scene.units_length_preset_add", text="", icon='ZOOMOUT').remove_active = True
- layout.separator()
+ layout.use_property_split = True
- split = layout.split(percentage=0.35)
- split.label("Length:")
- split.prop(unit, "system", text="")
- split = layout.split(percentage=0.35)
- split.label("Angle:")
- split.prop(unit, "system_rotation", text="")
+ col = layout.column()
+ col.prop(unit, "system")
+
+ col = layout.column()
+ col.prop(unit, "system_rotation")
col = layout.column()
col.enabled = unit.system != 'NONE'
- split = col.split(percentage=0.35)
- split.label("Unit Scale:")
- split.prop(unit, "scale_length", text="")
- split = col.split(percentage=0.35)
- split.row()
- split.prop(unit, "use_separate")
+ col.prop(unit, "scale_length")
+ col.prop(unit, "use_separate")
class SceneKeyingSetsPanel:
@@ -115,18 +110,19 @@ class SceneKeyingSetsPanel:
@staticmethod
def draw_keyframing_settings(context, layout, ks, ksp):
SceneKeyingSetsPanel._draw_keyframing_setting(
- context, layout, ks, ksp, "Needed",
- "use_insertkey_override_needed", "use_insertkey_needed",
- userpref_fallback="use_keyframe_insert_needed")
-
+ context, layout, ks, ksp, "Needed",
+ "use_insertkey_override_needed", "use_insertkey_needed",
+ userpref_fallback="use_keyframe_insert_needed",
+ )
SceneKeyingSetsPanel._draw_keyframing_setting(
- context, layout, ks, ksp, "Visual",
- "use_insertkey_override_visual", "use_insertkey_visual",
- userpref_fallback="use_visual_keying")
-
+ context, layout, ks, ksp, "Visual",
+ "use_insertkey_override_visual", "use_insertkey_visual",
+ userpref_fallback="use_visual_keying",
+ )
SceneKeyingSetsPanel._draw_keyframing_setting(
- context, layout, ks, ksp, "XYZ to RGB",
- "use_insertkey_override_xyz_to_rgb", "use_insertkey_xyz_to_rgb")
+ context, layout, ks, ksp, "XYZ to RGB",
+ "use_insertkey_override_xyz_to_rgb", "use_insertkey_xyz_to_rgb",
+ )
@staticmethod
def _draw_keyframing_setting(context, layout, ks, ksp, label, toggle_prop, prop, userpref_fallback=None):
@@ -164,6 +160,7 @@ class SceneKeyingSetsPanel:
class SCENE_PT_keying_sets(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
bl_label = "Keying Sets"
+ bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
@@ -197,6 +194,7 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
class SCENE_PT_keying_set_paths(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
bl_label = "Active Keying Set"
+ bl_parent_id = "SCENE_PT_keying_sets"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
@classmethod
@@ -258,22 +256,47 @@ class SCENE_PT_color_management(SceneButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
scene = context.scene
+ view = scene.view_settings
col = layout.column()
- col.label(text="Display:")
col.prop(scene.display_settings, "display_device")
+ col.prop(scene.sequencer_colorspace_settings, "name", text="Sequencer Color Space")
- col = layout.column()
col.separator()
- col.label(text="Render:")
- col.template_colormanaged_view_settings(scene, "view_settings")
col = layout.column()
- col.separator()
- col.label(text="Sequencer:")
- col.prop(scene.sequencer_colorspace_settings, "name")
+ col.prop(view, "view_transform")
+ col.prop(view, "exposure")
+ col.prop(view, "gamma")
+ col.prop(view, "look")
+
+
+class SCENE_PT_color_management_curves(SceneButtonsPanel, Panel):
+ bl_label = "Use Curves"
+ bl_parent_id = "SCENE_PT_color_management"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ def draw_header(self, context):
+
+ scene = context.scene
+ view = scene.view_settings
+
+ self.layout.prop(view, "use_curve_mapping", text="")
+
+ def draw(self, context):
+ layout = self.layout
+
+ scene = context.scene
+ view = scene.view_settings
+
+ layout.use_property_split = False
+ layout.enabled = view.use_curve_mapping
+
+ layout.template_curve_mapping(view, "curve_mapping", levels=True)
class SCENE_PT_audio(SceneButtonsPanel, Panel):
@@ -283,31 +306,34 @@ class SCENE_PT_audio(SceneButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
scene = context.scene
rd = context.scene.render
ffmpeg = rd.ffmpeg
layout.prop(scene, "audio_volume")
- layout.operator("sound.bake_animation")
- split = layout.split()
+ col = layout.column()
+ col.prop(scene, "audio_distance_model")
+
+ col.prop(ffmpeg, "audio_channels")
+ col.prop(ffmpeg, "audio_mixrate", text="Sample Rate")
+
+ layout.separator()
+
+ col = layout.column(align=True)
+ col.prop(scene, "audio_doppler_speed", text="Doppler Speed")
+ col.prop(scene, "audio_doppler_factor", text="Doppler Factor")
- col = split.column()
- col.label("Distance Model:")
- col.prop(scene, "audio_distance_model", text="")
- sub = col.column(align=True)
- sub.prop(scene, "audio_doppler_speed", text="Speed")
- sub.prop(scene, "audio_doppler_factor", text="Doppler")
+ layout.separator()
- col = split.column()
- col.label("Format:")
- col.prop(ffmpeg, "audio_channels", text="")
- col.prop(ffmpeg, "audio_mixrate", text="Rate")
+ layout.operator("sound.bake_animation")
class SCENE_PT_physics(SceneButtonsPanel, Panel):
bl_label = "Gravity"
+ bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw_header(self, context):
@@ -315,16 +341,18 @@ class SCENE_PT_physics(SceneButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
scene = context.scene
layout.active = scene.use_gravity
- layout.prop(scene, "gravity", text="")
+ layout.prop(scene, "gravity")
class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel):
bl_label = "Rigid Body World"
+ bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
@@ -368,7 +396,8 @@ class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel):
class SCENE_PT_rigid_body_cache(SceneButtonsPanel, Panel):
- bl_label = "Rigid Body Cache"
+ bl_label = "Cache"
+ bl_parent_id = "SCENE_PT_rigid_body_world"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@@ -385,7 +414,8 @@ class SCENE_PT_rigid_body_cache(SceneButtonsPanel, Panel):
class SCENE_PT_rigid_body_field_weights(SceneButtonsPanel, Panel):
- bl_label = "Rigid Body Field Weights"
+ bl_label = "Field Weights"
+ bl_parent_id = "SCENE_PT_rigid_body_world"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@@ -403,6 +433,7 @@ class SCENE_PT_rigid_body_field_weights(SceneButtonsPanel, Panel):
class SCENE_PT_simplify(SceneButtonsPanel, Panel):
bl_label = "Simplify"
+ bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw_header(self, context):
@@ -411,22 +442,21 @@ class SCENE_PT_simplify(SceneButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
rd = context.scene.render
layout.active = rd.use_simplify
- split = layout.split()
+ col = layout.column()
+ col.prop(rd, "simplify_subdivision", text="Max Viewport Subdivision")
+ col.prop(rd, "simplify_child_particles", text="Max Child Particles")
- col = split.column()
- col.label(text="Viewport:")
- col.prop(rd, "simplify_subdivision", text="Subdivision")
- col.prop(rd, "simplify_child_particles", text="Child Particles")
+ col.separator()
- col = split.column()
- col.label(text="Render:")
- col.prop(rd, "simplify_subdivision_render", text="Subdivision")
- col.prop(rd, "simplify_child_particles_render", text="Child Particles")
+ col = layout.column()
+ col.prop(rd, "simplify_subdivision_render", text="Max Render Subdivision")
+ col.prop(rd, "simplify_child_particles_render", text="Max Child Particles")
class SCENE_PT_viewport_display(SceneButtonsPanel, Panel):
@@ -439,9 +469,29 @@ class SCENE_PT_viewport_display(SceneButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
+ scene = context.scene
+ col = layout.column()
+ col.prop(scene.display, "light_direction")
+ col.prop(scene.display, "shadow_shift")
+
+
+class SCENE_PT_viewport_display_ssao(SceneButtonsPanel, Panel):
+ bl_label = "Screen Space Ambient Occlusion"
+ bl_parent_id = "SCENE_PT_viewport_display"
+
+ @classmethod
+ def poll(cls, context):
+ return True
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
scene = context.scene
- layout.prop(scene.display, "light_direction", text="")
- layout.prop(scene.display, "shadow_shift")
+ col = layout.column()
+ col.prop(scene.display, "matcap_ssao_samples")
+ col.prop(scene.display, "matcap_ssao_distance")
+ col.prop(scene.display, "matcap_ssao_attenuation")
class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
@@ -458,7 +508,9 @@ classes = (
SCENE_PT_keying_sets,
SCENE_PT_keying_set_paths,
SCENE_PT_color_management,
+ SCENE_PT_color_management_curves,
SCENE_PT_viewport_display,
+ SCENE_PT_viewport_display_ssao,
SCENE_PT_audio,
SCENE_PT_physics,
SCENE_PT_rigid_body_world,
diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py
index aa3227e0b72..e5bf2c910a0 100644
--- a/release/scripts/startup/bl_ui/properties_texture.py
+++ b/release/scripts/startup/bl_ui/properties_texture.py
@@ -59,6 +59,7 @@ class TEXTURE_UL_texslots(UIList):
layout.alignment = 'CENTER'
layout.label(text="", icon_value=icon)
+
def context_tex_datablock(context):
idblock = context.brush
if idblock:
@@ -106,6 +107,7 @@ class TEXTURE_PT_preview(TextureButtonsPanel, Panel):
if isinstance(idblock, Brush):
layout.prop(tex, "use_preview_alpha")
+
class TEXTURE_PT_context(TextureButtonsPanel, Panel):
bl_label = ""
bl_context = "texture"
diff --git a/release/scripts/startup/bl_ui/properties_view_layer.py b/release/scripts/startup/bl_ui/properties_view_layer.py
index 3c8552c3407..013fac3c099 100644
--- a/release/scripts/startup/bl_ui/properties_view_layer.py
+++ b/release/scripts/startup/bl_ui/properties_view_layer.py
@@ -43,7 +43,7 @@ class VIEWLAYER_PT_layer(ViewLayerButtonsPanel, Panel):
rd = scene.render
layer = bpy.context.view_layer
- layout.prop(layer, "use", text="Use for Rendering");
+ layout.prop(layer, "use", text="Use for Rendering")
layout.prop(rd, "use_single_layer", text="Render Single Layer")
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index a3dc401b484..db2a54d6138 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -57,15 +57,17 @@ class CLIP_HT_header(Header):
sc = context.space_data
clip = sc.clip
- CLIP_MT_tracking_editor_menus.draw_collapsible(context, layout)
-
row = layout.row()
row.template_ID(sc, "clip", open="clip.open")
+ CLIP_MT_tracking_editor_menus.draw_collapsible(context, layout)
+
if clip:
tracking = clip.tracking
active_object = tracking.objects.active
+ layout.separator_spacer()
+
if sc.view == 'CLIP':
layout.prop(sc, "pivot_point", text="", icon_only=True)
@@ -122,14 +124,15 @@ class CLIP_HT_header(Header):
row = layout.row()
row.template_ID(sc, "mask", new="mask.new")
+ layout.separator_spacer()
+
layout.prop(sc, "pivot_point", text="", icon_only=True)
row = layout.row(align=True)
- row.prop(toolsettings, "use_proportional_edit_mask",
- text="", icon_only=True)
- if toolsettings.use_proportional_edit_mask:
- row.prop(toolsettings, "proportional_edit_falloff",
- text="", icon_only=True)
+ row.prop(toolsettings, "use_proportional_edit_mask", text="", icon_only=True)
+ sub = row.row(align=True)
+ sub.active = toolsettings.use_proportional_edit_mask
+ sub.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
def draw(self, context):
layout = self.layout
@@ -1018,9 +1021,11 @@ class CLIP_PT_proxy(CLIP_PT_clip_view_panel, Panel):
if clip.use_proxy_custom_directory:
col.prop(clip.proxy, "directory")
- col.operator("clip.rebuild_proxy",
- text="Build Proxy / Timecode" if clip.source == 'MOVIE'
- else "Build Proxy")
+ col.operator(
+ "clip.rebuild_proxy",
+ text="Build Proxy / Timecode" if clip.source == 'MOVIE'
+ else "Build Proxy"
+ )
if clip.source == 'MOVIE':
col2 = col.column()
@@ -1189,6 +1194,7 @@ class CLIP_PT_tools_grease_pencil_brush(GreasePencilBrushPanel, Panel):
class CLIP_PT_tools_grease_pencil_brushcurves(GreasePencilBrushCurvesPanel, Panel):
bl_space_type = 'CLIP_EDITOR'
+
class CLIP_MT_view(Menu):
bl_label = "View"
diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index f3841de3ba4..a238e81d868 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -118,7 +118,7 @@ class DOPESHEET_HT_header(Header):
row = layout.row(align=True)
row.template_header()
-
+
# XXX: perhaps our mode menu can be retired eventually when we get editor submodes in the main menu?
layout.prop(st, "mode", text="")
@@ -179,12 +179,13 @@ class DOPESHEET_HT_editor_buttons(Header):
row.prop(st.dopesheet, "filter_text", text="")
row.prop(st.dopesheet, "use_multi_word_filter", text="")
+ layout.separator_spacer()
+
row = layout.row(align=True)
- row.prop(toolsettings, "use_proportional_action",
- text="", icon_only=True)
- if toolsettings.use_proportional_action:
- row.prop(toolsettings, "proportional_edit_falloff",
- text="", icon_only=True)
+ row.prop(toolsettings, "use_proportional_action", text="", icon_only=True)
+ sub = row.row(align=True)
+ sub.active = toolsettings.use_proportional_action
+ sub.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
# Grease Pencil mode doesn't need snapping, as it's frame-aligned only
if st.mode != 'GPENCIL':
@@ -425,11 +426,11 @@ class DOPESHEET_MT_gpencil_channel(Menu):
layout.operator("anim.channels_editable_toggle")
# XXX: to be enabled when these are ready for use!
- #layout.separator()
- #layout.operator("anim.channels_expand")
- #layout.operator("anim.channels_collapse")
+ # layout.separator()
+ # layout.operator("anim.channels_expand")
+ # layout.operator("anim.channels_collapse")
- #layout.separator()
+ # layout.separator()
#layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
@@ -450,9 +451,9 @@ class DOPESHEET_MT_gpencil_frame(Menu):
layout.separator()
layout.operator("action.keyframe_type")
- #layout.separator()
- #layout.operator("action.copy")
- #layout.operator("action.paste")
+ # layout.separator()
+ # layout.operator("action.copy")
+ # layout.operator("action.paste")
class DOPESHEET_MT_delete(Menu):
@@ -469,6 +470,66 @@ class DOPESHEET_MT_delete(Menu):
layout.operator("action.clean", text="Clean Channels").channels = True
+class DOPESHEET_MT_specials(Menu):
+ bl_label = "Dope Sheet Context Menu"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator("action.copy", text="Copy")
+ layout.operator("action.paste", text="Paste")
+ layout.operator("action.paste", text="Paste Flipped").flipped = True
+
+ layout.separator()
+
+ layout.operator_menu_enum("action.handle_type", "type", text="Handle Type")
+ layout.operator_menu_enum("action.interpolation_type", "type", text="Interpolation Mode")
+ layout.operator_menu_enum("action.easing_type", "type", text="Easing Type")
+
+ layout.separator()
+
+ layout.operator("action.keyframe_insert").type = 'SEL'
+ layout.operator("action.duplicate_move")
+ layout.operator("action.delete")
+
+ layout.separator()
+
+ layout.operator_menu_enum("action.mirror", "type", text="Mirror")
+ layout.operator_menu_enum("action.snap", "type", text="Snap")
+
+
+class DOPESHEET_MT_channel_specials(Menu):
+ bl_label = "Dope Sheet Channel Context Menu"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator("anim.channels_setting_enable", text="Mute Channels").type = 'MUTE'
+ layout.operator("anim.channels_setting_disable", text="Unmute Channels").type = 'MUTE'
+ layout.separator()
+ layout.operator("anim.channels_setting_enable", text="Protect Channels").type = 'PROTECT'
+ layout.operator("anim.channels_setting_disable", text="Unprotect Channels").type = 'PROTECT'
+
+ layout.separator()
+ layout.operator("anim.channels_group")
+ layout.operator("anim.channels_ungroup")
+
+ layout.separator()
+ layout.operator("anim.channels_editable_toggle")
+ layout.operator_menu_enum("action.extrapolation_type", "type", text="Extrapolation Mode")
+
+ layout.separator()
+ layout.operator("anim.channels_expand")
+ layout.operator("anim.channels_collapse")
+
+ layout.separator()
+ layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
+
+ layout.separator()
+
+ layout.operator("anim.channels_delete")
+
+
classes = (
DOPESHEET_HT_header,
DOPESHEET_HT_editor_buttons,
@@ -482,6 +543,8 @@ classes = (
DOPESHEET_MT_gpencil_channel,
DOPESHEET_MT_gpencil_frame,
DOPESHEET_MT_delete,
+ DOPESHEET_MT_specials,
+ DOPESHEET_MT_channel_specials,
)
if __name__ == "__main__": # only for live edit.
diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py
index 7e927bb6385..e655f9d5d15 100644
--- a/release/scripts/startup/bl_ui/space_graph.py
+++ b/release/scripts/startup/bl_ui/space_graph.py
@@ -48,13 +48,13 @@ class GRAPH_HT_header(Header):
sub.active = st.use_normalization
sub.prop(st, "use_auto_normalization", icon='FILE_REFRESH', text="", toggle=True)
- row = layout.row(align=True)
+ layout.separator_spacer()
- row.prop(toolsettings, "use_proportional_fcurve",
- text="", icon_only=True)
- if toolsettings.use_proportional_fcurve:
- row.prop(toolsettings, "proportional_edit_falloff",
- text="", icon_only=True)
+ row = layout.row(align=True)
+ row.prop(toolsettings, "use_proportional_fcurve", text="", icon_only=True)
+ sub = row.row(align=True)
+ sub.active = toolsettings.use_proportional_fcurve
+ sub.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
layout.prop(st, "auto_snap", text="")
layout.prop(st, "pivot_point", icon_only=True)
@@ -299,6 +299,76 @@ class GRAPH_MT_delete(Menu):
layout.operator("graph.clean").channels = False
layout.operator("graph.clean", text="Clean Channels").channels = True
+
+class GRAPH_MT_specials(Menu):
+ bl_label = "F-Curve Context Menu"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator("graph.copy", text="Copy")
+ layout.operator("graph.paste", text="Paste")
+ layout.operator("graph.paste", text="Paste Flipped").flipped = True
+
+ layout.separator()
+
+ layout.operator_menu_enum("graph.handle_type", "type", text="Handle Type")
+ layout.operator_menu_enum("graph.interpolation_type", "type", text="Interpolation Mode")
+ layout.operator_menu_enum("graph.easing_type", "type", text="Easing Type")
+
+ layout.separator()
+
+ layout.operator("graph.keyframe_insert").type = 'SEL'
+ layout.operator("graph.duplicate_move")
+ layout.operator("graph.delete")
+
+ layout.separator()
+
+ layout.operator_menu_enum("graph.mirror", "type", text="Mirror")
+ layout.operator_menu_enum("graph.snap", "type", text="Snap")
+
+
+class GRAPH_MT_channel_specials(Menu):
+ bl_label = "F-Curve Channel Context Menu"
+
+ def draw(self, context):
+ layout = self.layout
+ st = context.space_data
+
+ layout.separator()
+ layout.operator("anim.channels_setting_enable", text="Mute Channels").type = 'MUTE'
+ layout.operator("anim.channels_setting_disable", text="Unmute Channels").type = 'MUTE'
+ layout.separator()
+ layout.operator("anim.channels_setting_enable", text="Protect Channels").type = 'PROTECT'
+ layout.operator("anim.channels_setting_disable", text="Unprotect Channels").type = 'PROTECT'
+
+ layout.separator()
+ layout.operator("anim.channels_group")
+ layout.operator("anim.channels_ungroup")
+
+ layout.separator()
+ layout.operator("anim.channels_editable_toggle")
+ layout.operator_menu_enum("graph.extrapolation_type", "type", text="Extrapolation Mode")
+
+ layout.separator()
+ layout.operator("graph.hide", text="Hide Selected Curves").unselected = False
+ layout.operator("graph.hide", text="Hide Unselected Curves").unselected = True
+ layout.operator("graph.reveal")
+
+ layout.separator()
+ layout.operator("anim.channels_expand")
+ layout.operator("anim.channels_collapse")
+
+ layout.separator()
+ layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
+
+ layout.separator()
+
+ layout.operator("anim.channels_delete")
+ if st.mode == 'DRIVERS':
+ layout.operator("graph.driver_delete_invalid")
+
+
classes = (
GRAPH_HT_header,
GRAPH_MT_editor_menus,
@@ -309,6 +379,8 @@ classes = (
GRAPH_MT_key,
GRAPH_MT_key_transform,
GRAPH_MT_delete,
+ GRAPH_MT_specials,
+ GRAPH_MT_channel_specials,
)
if __name__ == "__main__": # only for live edit.
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index b1ff1618d09..e8c9925ba9e 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -422,6 +422,43 @@ class IMAGE_MT_uvs_select_mode(Menu):
props.data_path = "tool_settings.uv_select_mode"
+class IMAGE_MT_specials(Menu):
+ bl_label = "UV Context Menu"
+
+ def draw(self, context):
+ layout = self.layout
+
+ sima = context.space_data
+
+ # UV Edit Mode
+ if sima.show_uvedit:
+ layout.operator("uv.unwrap")
+ layout.operator("uv.follow_active_quads")
+
+ layout.separator()
+
+ layout.operator("uv.pin").clear = False
+ layout.operator("uv.pin", text="Unpin").clear = True
+
+ layout.separator()
+
+ layout.operator("uv.weld")
+ layout.operator("uv.stitch")
+
+ layout.separator()
+
+ layout.operator_enum("uv.align", "axis") # W, 2/3/4
+
+ layout.separator()
+
+ layout.operator("transform.mirror", text="Mirror X").constraint_axis[0] = True
+ layout.operator("transform.mirror", text="Mirror Y").constraint_axis[1] = True
+
+ layout.separator()
+
+ layout.menu("IMAGE_MT_uvs_snap")
+
+
class IMAGE_HT_header(Header):
bl_space_type = 'IMAGE_EDITOR'
@@ -443,8 +480,6 @@ class IMAGE_HT_header(Header):
layout.prop(sima, "mode", text="")
- MASK_MT_editor_menus.draw_collapsible(context, layout)
-
layout.template_ID(sima, "image", new="image.new", open="image.open")
if not show_render:
layout.prop(sima, "use_image_pin", text="")
@@ -453,8 +488,6 @@ class IMAGE_HT_header(Header):
row = layout.row()
row.template_ID(sima, "mask", new="mask.new")
- layout.prop(sima, "pivot_point", icon_only=True)
-
# uv editing
if show_uvedit:
uvedit = sima.uv_editor
@@ -467,10 +500,25 @@ class IMAGE_HT_header(Header):
layout.prop(toolsettings, "uv_select_mode", text="", expand=True)
layout.prop(uvedit, "sticky_select_mode", icon_only=True)
+ MASK_MT_editor_menus.draw_collapsible(context, layout)
+
+ layout.separator_spacer()
+
+ if show_uvedit or show_maskedit or mode == 'PAINT':
+ layout.prop(sima, "use_realtime_update", icon_only=True, icon='LOCKED')
+
+ if show_uvedit:
+ uvedit = sima.uv_editor
+
+ mesh = context.edit_object.data
+ layout.prop_search(mesh.uv_layers, "active", mesh, "uv_layers", text="")
+
row = layout.row(align=True)
row.prop(toolsettings, "proportional_edit", icon_only=True)
- if toolsettings.proportional_edit != 'DISABLED':
- row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
+ # if toolsettings.proportional_edit != 'DISABLED':
+ sub = row.row(align=True)
+ sub.active = toolsettings.proportional_edit != 'DISABLED'
+ sub.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
row = layout.row(align=True)
row.prop(toolsettings, "use_snap", text="")
@@ -478,8 +526,7 @@ class IMAGE_HT_header(Header):
if toolsettings.snap_uv_element != 'INCREMENT':
row.prop(toolsettings, "snap_target", text="")
- mesh = context.edit_object.data
- layout.prop_search(mesh.uv_layers, "active", mesh, "uv_layers", text="")
+ layout.prop(sima, "pivot_point", icon_only=True)
if ima:
if ima.is_stereo_3d:
@@ -499,9 +546,6 @@ class IMAGE_HT_header(Header):
if ima.type == 'COMPOSITE' and ima.source in {'MOVIE', 'SEQUENCE'}:
row.operator("image.play_composite", icon='PLAY')
- if show_uvedit or show_maskedit or mode == 'PAINT':
- layout.prop(sima, "use_realtime_update", icon_only=True, icon='LOCKED')
-
class MASK_MT_editor_menus(Menu):
bl_idname = "MASK_MT_editor_menus"
@@ -584,6 +628,7 @@ class IMAGE_PT_tools_mask(MASK_PT_tools, Panel):
bl_region_type = 'TOOLS'
bl_category = 'Mask'
+
class IMAGE_PT_tools_mask_add(MASK_PT_add, Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'TOOLS'
@@ -1127,8 +1172,6 @@ class IMAGE_PT_uv_sculpt(Panel, ImagePaintPanel):
col.prop(uvsculpt, "show_brush")
-
-
class IMAGE_PT_options_uvs(Panel, UVToolsPanel):
bl_label = "UV Options"
bl_category = "Options"
@@ -1308,6 +1351,7 @@ classes = (
IMAGE_MT_uvs_mirror,
IMAGE_MT_uvs_weldalign,
IMAGE_MT_uvs_select_mode,
+ IMAGE_MT_specials,
IMAGE_HT_header,
MASK_MT_editor_menus,
IMAGE_PT_mask,
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index 375e101a6a5..1b6baa7d3d9 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -48,9 +48,8 @@ class NODE_HT_header(Header):
row = layout.row(align=True)
row.template_header()
- layout.prop(snode, "tree_type", text="")
-
- NODE_MT_editor_menus.draw_collapsible(context, layout)
+ # Now expanded via the 'ui_type'
+ # layout.prop(snode, "tree_type", text="")
if snode.tree_type == 'ShaderNodeTree':
layout.prop(snode, "shader_type", text="", expand=True)
@@ -69,15 +68,20 @@ class NODE_HT_header(Header):
# No shader nodes for Eevee lamps
if snode_id and not (context.engine == 'BLENDER_EEVEE' and ob.type == 'LAMP'):
- layout.prop(snode_id, "use_nodes")
+ row.prop(snode_id, "use_nodes")
+
+ NODE_MT_editor_menus.draw_collapsible(context, layout)
if snode.shader_type == 'WORLD':
row = layout.row()
row.enabled = not snode.pin
row.template_ID(scene, "world", new="world.new")
+
if snode_id:
row.prop(snode_id, "use_nodes")
+ NODE_MT_editor_menus.draw_collapsible(context, layout)
+
if snode.shader_type == 'LINESTYLE':
view_layer = context.view_layer
lineset = view_layer.freestyle_settings.linesets.active
@@ -85,6 +89,9 @@ class NODE_HT_header(Header):
row = layout.row()
row.enabled = not snode.pin
row.template_ID(lineset, "linestyle", new="scene.freestyle_linestyle_new")
+
+ NODE_MT_editor_menus.draw_collapsible(context, layout)
+
if snode_id:
row.prop(snode_id, "use_nodes")
@@ -96,21 +103,31 @@ class NODE_HT_header(Header):
layout.template_ID(id_from, "texture", new="texture.new")
else:
layout.template_ID(id_from, "active_texture", new="texture.new")
+
if snode_id:
layout.prop(snode_id, "use_nodes")
+ NODE_MT_editor_menus.draw_collapsible(context, layout)
+
elif snode.tree_type == 'CompositorNodeTree':
+
if snode_id:
layout.prop(snode_id, "use_nodes")
+
+ NODE_MT_editor_menus.draw_collapsible(context, layout)
+
+ layout.prop(snode, "use_auto_render")
layout.prop(snode, "show_backdrop")
if snode.show_backdrop:
row = layout.row(align=True)
row.prop(snode, "backdrop_channels", text="", expand=True)
- layout.prop(snode, "use_auto_render")
else:
# Custom node tree is edited as independent ID block
layout.template_ID(snode, "node_tree", new="node.new_node_tree")
+ NODE_MT_editor_menus.draw_collapsible(context, layout)
+
+ layout.separator_spacer()
layout.prop(snode, "pin", text="")
layout.operator("node.tree_path_parent", text="", icon='FILE_PARENT')
@@ -289,6 +306,41 @@ class NODE_MT_node_color_specials(Menu):
layout.operator("node.node_copy_color", icon='COPY_ID')
+class NODE_MT_specials(Menu):
+ bl_label = "Node Context Menu"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator_context = 'INVOKE_DEFAULT'
+ layout.operator("node.duplicate_move")
+ layout.operator("node.delete")
+ layout.operator_context = 'EXEC_DEFAULT'
+
+ layout.operator("node.delete_reconnect")
+
+ layout.separator()
+
+ layout.operator("node.link_make").replace = False
+ layout.operator("node.link_make", text="Make and Replace Links").replace = True
+ layout.operator("node.links_detach")
+
+ layout.separator()
+
+ layout.operator("node.group_make", text="Group")
+ layout.operator("node.group_ungroup", text="Ungroup")
+ layout.operator("node.group_edit").exit = False
+
+ layout.separator()
+
+ layout.operator("node.hide_toggle")
+ layout.operator("node.mute_toggle")
+ layout.operator("node.preview_toggle")
+ layout.operator("node.hide_socket_toggle")
+ layout.operator("node.options_toggle")
+ layout.operator("node.collapse_hide_unused_toggle")
+
+
class NODE_PT_active_node_generic(Panel):
bl_space_type = 'NODE_EDITOR'
bl_region_type = 'UI'
@@ -506,11 +558,15 @@ class NODE_PT_tools_grease_pencil_sculpt(GreasePencilStrokeSculptPanel, Panel):
bl_region_type = 'TOOLS'
# Grease Pencil drawing brushes
+
+
class NODE_PT_tools_grease_pencil_brush(GreasePencilBrushPanel, Panel):
bl_space_type = 'NODE_EDITOR'
bl_region_type = 'TOOLS'
# Grease Pencil drawing curves
+
+
class NODE_PT_tools_grease_pencil_brushcurves(GreasePencilBrushCurvesPanel, Panel):
bl_space_type = 'NODE_EDITOR'
bl_region_type = 'TOOLS'
@@ -521,6 +577,7 @@ class NODE_PT_tools_grease_pencil_brushcurves(GreasePencilBrushCurvesPanel, Pane
def node_draw_tree_view(layout, context):
pass
+
classes = (
NODE_HT_header,
NODE_MT_editor_menus,
@@ -530,6 +587,7 @@ classes = (
NODE_MT_node,
NODE_MT_node_color_presets,
NODE_MT_node_color_specials,
+ NODE_MT_specials,
NODE_PT_active_node_generic,
NODE_PT_active_node_color,
NODE_PT_active_node_properties,
diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py
index 8b8526cf9f2..12cff72b61a 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -179,7 +179,7 @@ class OUTLINER_MT_collection(Menu):
layout.operator("outliner.collection_instance", text="Instance to Scene")
if space.display_mode != 'VIEW_LAYER':
layout.operator("outliner.collection_link", text="Link to Scene")
- layout.operator("outliner.id_operation", text="Unlink").type='UNLINK'
+ layout.operator("outliner.id_operation", text="Unlink").type = 'UNLINK'
if space.display_mode == 'VIEW_LAYER':
layout.separator()
@@ -206,20 +206,20 @@ class OUTLINER_MT_object(Menu):
space = context.space_data
- layout.operator("outliner.object_operation", text="Delete").type='DELETE'
+ layout.operator("outliner.object_operation", text="Delete").type = 'DELETE'
if space.display_mode == 'VIEW_LAYER' and not space.use_filter_collection:
- layout.operator("outliner.object_operation", text="Delete Hierarchy").type='DELETE_HIERARCHY'
+ layout.operator("outliner.object_operation", text="Delete Hierarchy").type = 'DELETE_HIERARCHY'
layout.separator()
- layout.operator("outliner.object_operation", text="Select").type='SELECT'
- layout.operator("outliner.object_operation", text="Select Hierarchy").type='SELECT_HIERARCHY'
- layout.operator("outliner.object_operation", text="Deselect").type='DESELECT'
+ layout.operator("outliner.object_operation", text="Select").type = 'SELECT'
+ layout.operator("outliner.object_operation", text="Select Hierarchy").type = 'SELECT_HIERARCHY'
+ layout.operator("outliner.object_operation", text="Deselect").type = 'DESELECT'
layout.separator()
if not (space.display_mode == 'VIEW_LAYER' and not space.use_filter_collection):
- layout.operator("outliner.id_operation", text="Unlink").type='UNLINK'
+ layout.operator("outliner.id_operation", text="Unlink").type = 'UNLINK'
layout.separator()
layout.operator_menu_enum("outliner.id_operation", 'type', text="ID Data")
diff --git a/release/scripts/startup/bl_ui/space_properties.py b/release/scripts/startup/bl_ui/space_properties.py
index 20cb5719e20..2d1725b2087 100644
--- a/release/scripts/startup/bl_ui/space_properties.py
+++ b/release/scripts/startup/bl_ui/space_properties.py
@@ -31,6 +31,7 @@ class PROPERTIES_HT_header(Header):
row = layout.row()
row.template_header()
+
row.prop(view, "context", expand=True, icon_only=True)
diff --git a/release/scripts/startup/bl_ui/space_statusbar.py b/release/scripts/startup/bl_ui/space_statusbar.py
index 983b474d18b..3a6fc4925d8 100644
--- a/release/scripts/startup/bl_ui/space_statusbar.py
+++ b/release/scripts/startup/bl_ui/space_statusbar.py
@@ -73,7 +73,6 @@ class STATUSBAR_HT_header(Header):
return
-
classes = (
STATUSBAR_HT_header,
)
diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py
index 48ac85f0d0e..358a813fd0f 100644
--- a/release/scripts/startup/bl_ui/space_time.py
+++ b/release/scripts/startup/bl_ui/space_time.py
@@ -36,13 +36,7 @@ class TIME_HT_editor_buttons(Header):
toolsettings = context.tool_settings
screen = context.screen
- layout.separator() # XXX: This should be dynamic (e.g. layout.separator(stretch=1.0))
- layout.separator()
- layout.separator()
- layout.separator()
- layout.separator()
- layout.separator()
- layout.separator()
+ layout.separator_spacer()
row = layout.row(align=True)
row.prop(toolsettings, "use_keyframe_insert_auto", text="", toggle=True)
@@ -67,13 +61,7 @@ class TIME_HT_editor_buttons(Header):
row.operator("screen.keyframe_jump", text="", icon='NEXT_KEYFRAME').next = True
row.operator("screen.frame_jump", text="", icon='FF').end = True
- layout.separator() # XXX: This should be dynamic (e.g. layout.separator(stretch=1.0))
- layout.separator()
- layout.separator()
- layout.separator()
- layout.separator()
- layout.separator()
- layout.separator()
+ layout.separator_spacer()
row = layout.row()
row.scale_x = 0.95
@@ -82,9 +70,6 @@ class TIME_HT_editor_buttons(Header):
else:
row.prop(scene, "frame_current", text="")
- layout.separator()
- layout.separator()
-
row = layout.row(align=True)
row.prop(scene, "use_preview_range", text="", toggle=True)
sub = row.row(align=True)
@@ -106,8 +91,6 @@ class TIME_MT_editor_menus(Menu):
@staticmethod
def draw_menus(layout, context):
- layout.menu("TIME_MT_view")
- layout.menu("TIME_MT_marker")
layout.popover(space_type='DOPESHEET_EDITOR',
region_type='HEADER',
panel_type="TIME_PT_playback",
@@ -116,6 +99,9 @@ class TIME_MT_editor_menus(Menu):
region_type='HEADER',
panel_type="TIME_PT_keyframing_settings",
text="Keying")
+ layout.menu("TIME_MT_view")
+ layout.menu("TIME_MT_marker")
+
class TIME_MT_marker(Menu):
bl_label = "Marker"
@@ -217,6 +203,7 @@ def marker_menu_generic(layout):
###################################
+
class TimelinePanelButtons:
bl_space_type = 'DOPESHEET_EDITOR'
bl_region_type = 'UI'
@@ -292,7 +279,7 @@ class TIME_PT_keyframing_settings(TimelinePanelButtons, Panel):
col = layout.column(align=True)
col.label("New Keyframe Type:")
col.prop(toolsettings, "keyframe_type", text="")
-
+
col = layout.column(align=True)
col.label("Auto Keyframing:")
row = col.row()
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index 8a494369cf5..20db56af416 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -262,8 +262,8 @@ class ToolSelectPanelHelper:
for item, index in ToolSelectPanelHelper._tools_flatten_with_tool_index(cls.tools_from_context(context)):
if item is not None:
if item.text == text:
- return (item, index)
- return None, -1
+ return (cls, item, index)
+ return None, None, -1
@staticmethod
def _tool_active_from_context(context, space_type, mode=None, create=False):
@@ -339,9 +339,7 @@ class ToolSelectPanelHelper:
# - None: Signal to finish (complete any final operations, e.g. add padding).
@staticmethod
- def _layout_generator_single_column(layout):
- scale_y = 2.0
-
+ def _layout_generator_single_column(layout, scale_y):
col = layout.column(align=True)
col.scale_y = scale_y
is_sep = False
@@ -355,9 +353,8 @@ class ToolSelectPanelHelper:
is_sep = yield col
@staticmethod
- def _layout_generator_multi_columns(layout, column_count):
- scale_y = 2.0
- scale_x = 2.2
+ def _layout_generator_multi_columns(layout, column_count, scale_y):
+ scale_x = scale_y * 1.1
column_last = column_count - 1
col = layout.column(align=True)
@@ -394,7 +391,7 @@ class ToolSelectPanelHelper:
column_index += 1
@staticmethod
- def _layout_generator_detect_from_region(layout, region):
+ def _layout_generator_detect_from_region(layout, region, scale_y):
"""
Choose an appropriate layout for the toolbar.
"""
@@ -421,15 +418,14 @@ class ToolSelectPanelHelper:
column_count = 1
if column_count == 1:
- ui_gen = ToolSelectPanelHelper._layout_generator_single_column(layout)
+ ui_gen = ToolSelectPanelHelper._layout_generator_single_column(layout, scale_y=scale_y)
else:
- ui_gen = ToolSelectPanelHelper._layout_generator_multi_columns(layout, column_count=column_count)
+ ui_gen = ToolSelectPanelHelper._layout_generator_multi_columns(layout, column_count=column_count, scale_y=scale_y)
return ui_gen, show_text
-
@classmethod
- def draw_cls(cls, layout, context, detect_layout=True):
+ def draw_cls(cls, layout, context, detect_layout=True, scale_y=1.75):
# Use a classmethod so it can be called outside of a panel context.
# XXX, this UI isn't very nice.
@@ -445,9 +441,9 @@ class ToolSelectPanelHelper:
)
if detect_layout:
- ui_gen, show_text = cls._layout_generator_detect_from_region(layout, context.region)
+ ui_gen, show_text = cls._layout_generator_detect_from_region(layout, context.region, scale_y)
else:
- ui_gen = ToolSelectPanelHelper._layout_generator_single_column(layout)
+ ui_gen = ToolSelectPanelHelper._layout_generator_single_column(layout, scale_y)
show_text = True
# Start iteration
@@ -564,20 +560,60 @@ class WM_MT_toolsystem_submenu(Menu):
).name = item.text
+def _activate_by_item(context, space_type, item, index):
+ tool = ToolSelectPanelHelper._tool_active_from_context(context, space_type, create=True)
+ tool.setup(
+ name=item.text,
+ keymap=item.keymap[0].name if item.keymap is not None else "",
+ cursor=item.cursor or 'DEFAULT',
+ manipulator_group=item.widget or "",
+ data_block=item.data_block or "",
+ index=index,
+ )
+
+
def activate_by_name(context, space_type, text):
- item, index = ToolSelectPanelHelper._tool_get_by_name(context, space_type, text)
- if item is not None:
- tool = ToolSelectPanelHelper._tool_active_from_context(context, space_type, create=True)
- tool.setup(
- name=text,
- keymap=item.keymap[0].name if item.keymap is not None else "",
- cursor=item.cursor or 'DEFAULT',
- manipulator_group=item.widget or "",
- data_block=item.data_block or "",
- index=index,
- )
- return True
- return False
+ cls, item, index = ToolSelectPanelHelper._tool_get_by_name(context, space_type, text)
+ if item is None:
+ return False
+ _activate_by_item(context, space_type, item, index)
+ return True
+
+
+def activate_by_name_or_cycle(context, space_type, text, offset=1):
+
+ # Only cycle when the active tool is activated again.
+ cls, item, index = ToolSelectPanelHelper._tool_get_by_name(context, space_type, text)
+ if item is None:
+ return False
+
+ tool_active = ToolSelectPanelHelper._tool_active_from_context(context, space_type)
+ text_active = getattr(tool_active, "name", None)
+
+ text_current = ""
+ for item_group in cls.tools_from_context(context):
+ if type(item_group) is tuple:
+ index_current = cls._tool_group_active.get(item_group[0].text, 0)
+ ok = False
+ for i, sub_item in enumerate(item_group):
+ if sub_item.text == text:
+ text_current = item_group[index_current].text
+ break
+ if text_current:
+ break
+
+ if text_current == "":
+ return activate_by_name(context, space_type, text)
+ if text_active != text_current:
+ return activate_by_name(context, space_type, text_current)
+
+ index_found = (tool_active.index + offset) % len(item_group)
+
+ cls._tool_group_active[item_group[0].text] = index_found
+
+ item_found = item_group[index_found]
+ _activate_by_item(context, space_type, item_found, index_found)
+ return True
def keymap_from_context(context, space_type):
@@ -594,10 +630,6 @@ def keymap_from_context(context, space_type):
for kmi in keymap.keymap_items:
keymap.keymap_items.remove(kmi)
-
- kmi_search = wm.keyconfigs.find_item_from_operator(idname="wm.toolbar")[1]
- kmi_search_type = None if not kmi_search else kmi_search.type
-
items = []
cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type)
for i, item in enumerate(
@@ -637,17 +669,10 @@ def keymap_from_context(context, space_type):
)
kmi.properties.name = item.text
- # Disallow overlap
- if kmi_search_type == kmi_found_type:
- kmi_search_type = None
-
- # Support double-tap for search.
- if kmi_search_type:
- keymap.keymap_items.new("wm.search_menu", type=kmi_search_type, value='PRESS')
-
wm.keyconfigs.update()
return keymap
+
classes = (
WM_MT_toolsystem_submenu,
)
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 42fac9e03a4..da86c1c03bc 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -91,7 +91,7 @@ class _defs_view3d_generic:
("transform.translate",
dict(release_confirm=True, cursor_transform=True),
dict(type='EVT_TWEAK_A', value='ANY'),
- ),
+ ),
),
)
@@ -292,7 +292,6 @@ class _defs_edit_armature:
class _defs_edit_mesh:
-
@ToolDef.from_fn
def cube_add():
return dict(
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 53acc29dfad..0171d98af0b 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -125,13 +125,13 @@ class TOPBAR_HT_lower_bar(Header):
# Note: general mode options should be added to 'draw_right'.
if mode == 'SCULPT':
- layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".paint_common", category="")
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="")
elif mode == 'PAINT_VERTEX':
- layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".paint_common", category="")
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="")
elif mode == 'PAINT_WEIGHT':
- layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".paint_common", category="")
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="")
elif mode == 'PAINT_TEXTURE':
- layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".paint_common", category="")
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="")
elif mode == 'EDIT_ARMATURE':
pass
elif mode == 'EDIT_CURVE':
@@ -139,9 +139,9 @@ class TOPBAR_HT_lower_bar(Header):
elif mode == 'EDIT_MESH':
pass
elif mode == 'POSE':
- layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".posemode", category="")
+ pass
elif mode == 'PARTICLE':
- layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".paint_common", category="")
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="")
def draw_right(self, context):
layout = self.layout
@@ -151,23 +151,23 @@ class TOPBAR_HT_lower_bar(Header):
mode = context.mode
if mode == 'SCULPT':
- layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".sculpt_mode", category="")
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".sculpt_mode", category="")
elif mode == 'PAINT_VERTEX':
- layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".vertexpaint", category="")
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".vertexpaint", category="")
elif mode == 'PAINT_WEIGHT':
- layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".weightpaint", category="")
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".weightpaint", category="")
elif mode == 'PAINT_TEXTURE':
- layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".imagepaint", category="")
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".imagepaint", category="")
elif mode == 'EDIT_ARMATURE':
- layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".armature_edit", category="")
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".armature_edit", category="")
elif mode == 'EDIT_CURVE':
- layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".curve_edit", category="")
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".curve_edit", category="")
elif mode == 'EDIT_MESH':
- layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".mesh_edit", category="")
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".mesh_edit", category="")
elif mode == 'POSE':
- layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".posemode", category="")
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".posemode", category="")
elif mode == 'PARTICLE':
- layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".particlemode", category="")
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".particlemode", category="")
# 3D View Options, tsk. maybe users aren't always using 3D view?
toolsettings = context.tool_settings
@@ -606,7 +606,16 @@ class INFO_MT_edit(Menu):
layout.separator()
- layout.operator("ed.undo_history")
+ layout.operator("ed.undo_history", text="Undo History...")
+
+ layout.separator()
+
+ layout.operator("screen.repeat_last")
+ layout.operator("screen.repeat_history", text="Repeat History...")
+
+ layout.separator()
+
+ layout.operator("screen.redo_last", text="Adjust Last Operation...")
layout.separator()
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 1c6bf490f7a..a480fa433e1 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -22,6 +22,7 @@ from bpy.types import (
Header,
Menu,
Panel,
+ Operator,
)
from bpy.app.translations import pgettext_iface as iface_
from bpy.app.translations import contexts as i18n_contexts
@@ -52,7 +53,8 @@ class USERPREF_HT_header(Header):
def draw(self, context):
layout = self.layout
- layout.template_header()
+ # No need to show type selector.
+ # layout.template_header()
userpref = context.user_preferences
@@ -70,6 +72,10 @@ class USERPREF_HT_header(Header):
layout.operator("wm.addon_install", icon='FILESEL')
layout.operator("wm.addon_refresh", icon='FILE_REFRESH')
layout.menu("USERPREF_MT_addons_online_resources")
+ elif userpref.active_section == 'LIGHTS':
+ layout.operator('wm.studiolight_install', text="Install MatCap").orientation='MATCAP'
+ layout.operator('wm.studiolight_install', text="Install World HDRI").orientation='WORLD'
+ layout.operator('wm.studiolight_install', text="Install Camera HDRI").orientation='CAMERA'
elif userpref.active_section == 'THEMES':
layout.operator("ui.reset_default_theme")
layout.operator("wm.theme_install")
@@ -140,7 +146,6 @@ class USERPREF_MT_app_templates(Menu):
layout.operator_context = 'INVOKE_DEFAULT'
props = layout.operator("wm.app_template_install")
-
def draw(self, context):
self.draw_ex(context, use_splash=False, use_default=True, use_install=True)
@@ -281,20 +286,21 @@ class USERPREF_PT_interface(Panel):
row.separator()
col = row.column()
- #Toolbox doesn't exist yet
- #col.label(text="Toolbox:")
+ # Toolbox doesn't exist yet
+ # col.label(text="Toolbox:")
#col.prop(view, "show_column_layout")
#col.label(text="Open Toolbox Delay:")
#col.prop(view, "open_left_mouse_delay", text="Hold LMB")
#col.prop(view, "open_right_mouse_delay", text="Hold RMB")
col.prop(view, "show_manipulator")
- col.prop(view, "show_manipulator_navigate")
- ## Currently not working
+ # Currently not working
# col.prop(view, "show_manipulator_shaded")
sub = col.column()
sub.active = view.show_manipulator
sub.prop(view, "manipulator_size", text="Size")
+ col.prop(view, "show_manipulator_navigate")
+
col.separator()
col.separator()
col.separator()
@@ -326,7 +332,6 @@ class USERPREF_PT_interface(Panel):
col.prop(view, "show_view3d_cursor")
-
class USERPREF_PT_edit(Panel):
bl_space_type = 'USER_PREFERENCES'
bl_label = "Edit"
@@ -410,7 +415,7 @@ class USERPREF_PT_edit(Panel):
sub = col.column()
- #~ sub.active = edit.use_keyframe_insert_auto # incorrect, time-line can enable
+ # ~ sub.active = edit.use_keyframe_insert_auto # incorrect, time-line can enable
sub.prop(edit, "use_keyframe_insert_available", text="Only Insert Available")
col.separator()
@@ -1215,7 +1220,7 @@ class USERPREF_PT_input(Panel):
#sub.prop(inputs, "use_mouse_mmb_paste")
- #col.separator()
+ # col.separator()
sub = col.column()
sub.prop(inputs, "invert_zoom_wheel", text="Invert Wheel Zoom Direction")
@@ -1330,7 +1335,7 @@ class USERPREF_PT_addons(Panel):
'OFFICIAL': 'FILE_BLEND',
'COMMUNITY': 'POSE_DATA',
'TESTING': 'MOD_EXPLODE',
- }
+ }
@classmethod
def poll(cls, context):
@@ -1408,7 +1413,6 @@ class USERPREF_PT_addons(Panel):
sub_col.label(" " + addon_file)
sub_col.label(" " + addon_path)
-
if addon_utils.error_encoding:
self.draw_error(
col,
@@ -1433,11 +1437,11 @@ class USERPREF_PT_addons(Panel):
# check if addon should be visible with current filters
if ((filter == "All") or
- (filter == info["category"]) or
- (filter == "Enabled" and is_enabled) or
- (filter == "Disabled" and not is_enabled) or
- (filter == "User" and (mod.__file__.startswith((scripts_addons_folder, userpref_addons_folder))))
- ):
+ (filter == info["category"]) or
+ (filter == "Enabled" and is_enabled) or
+ (filter == "Disabled" and not is_enabled) or
+ (filter == "User" and (mod.__file__.startswith((scripts_addons_folder, userpref_addons_folder))))
+ ):
if search and search not in info["name"].lower():
if info["author"]:
if search not in info["author"].lower():
@@ -1571,6 +1575,60 @@ class USERPREF_PT_addons(Panel):
row.label(text=module_name, translate=False)
+class StudioLightPanelMixin():
+ bl_space_type = 'USER_PREFERENCES'
+ bl_region_type = 'WINDOW'
+
+ @classmethod
+ def poll(cls, context):
+ userpref = context.user_preferences
+ return (userpref.active_section == 'LIGHTS')
+
+ def _get_lights(self, userpref):
+ return [light for light in userpref.studio_lights if light.is_user_defined and light.orientation == self.sl_orientation]
+
+ def draw_header(self, context):
+ layout = self.layout
+ row = layout.row()
+ userpref = context.user_preferences
+ lights = self._get_lights(userpref)
+ row.label("({})".format(len(lights)))
+
+ def draw(self, context):
+ layout = self.layout
+ userpref = context.user_preferences
+ lights = self._get_lights(userpref)
+ if lights:
+ flow = layout.column_flow(4)
+ for studio_light in lights:
+ self.draw_studio_light(flow, studio_light)
+ else:
+ layout.label("No custom {} configured".format(self.bl_label))
+
+ def draw_studio_light(self, layout, studio_light):
+ box = layout.box()
+ row = box.row()
+
+ row.template_icon_view(studio_light, "icon_id")
+ op = row.operator('wm.studiolight_uninstall', text="", icon='ZOOMOUT')
+ op.index = studio_light.index
+
+
+class USERPREF_PT_studiolight_matcaps(Panel, StudioLightPanelMixin):
+ bl_label = "MatCaps"
+ sl_orientation = 'MATCAP'
+
+
+class USERPREF_PT_studiolight_world(Panel, StudioLightPanelMixin):
+ bl_label = "World HDRI"
+ sl_orientation = 'WORLD'
+
+
+class USERPREF_PT_studiolight_camera(Panel, StudioLightPanelMixin):
+ bl_label = "Camera HDRI"
+ sl_orientation = 'CAMERA'
+
+
classes = (
USERPREF_HT_header,
USERPREF_PT_tabs,
@@ -1591,6 +1649,9 @@ classes = (
USERPREF_PT_input,
USERPREF_MT_addons_online_resources,
USERPREF_PT_addons,
+ USERPREF_PT_studiolight_matcaps,
+ USERPREF_PT_studiolight_world,
+ USERPREF_PT_studiolight_camera,
)
if __name__ == "__main__": # only for live edit.
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 213d231c37a..c967fe3ad08 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -58,20 +58,6 @@ class VIEW3D_HT_header(Header):
shading_type = view.shading.type
shading_item = bpy.types.View3DShading.bl_rna.properties['type'].enum_items[shading_type]
- row = layout.row(align=True)
- row.prop(shading, "type", text="", expand=True)
-
- sub = row.row(align=True)
- sub.enabled = shading.type != 'RENDERED'
- sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_shading")
-
- row = layout.row(align=True)
- row.prop(overlay, "show_overlays", icon="WIRE", text="")
-
- sub = row.row(align=True)
- sub.active = overlay.show_overlays
- sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_overlay")
-
if obj:
# Set above:
# mode = obj.mode
@@ -109,6 +95,22 @@ class VIEW3D_HT_header(Header):
VIEW3D_MT_editor_menus.draw_collapsible(context, layout)
+ layout.separator_spacer()
+
+ row = layout.row(align=True)
+ row.prop(shading, "type", text="", expand=True)
+
+ sub = row.row(align=True)
+ sub.enabled = shading.type != 'RENDERED'
+ sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_shading")
+
+ row = layout.row(align=True)
+ row.prop(overlay, "show_overlays", icon="WIRE", text="")
+
+ sub = row.row(align=True)
+ sub.active = overlay.show_overlays
+ sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_overlay")
+
class VIEW3D_MT_editor_menus(Menu):
bl_space_type = 'VIEW3D_MT_editor_menus'
@@ -1328,15 +1330,19 @@ class INFO_MT_add(Menu):
layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_FORCE_FIELD')
layout.separator()
- if len(bpy.data.collections) > 10:
- layout.operator_context = 'INVOKE_REGION_WIN'
- layout.operator(
+ has_collections = bool(bpy.data.collections)
+ col = layout.column()
+ col.enabled = has_collections
+
+ if not has_collections or len(bpy.data.collections) > 10:
+ col.operator_context = 'INVOKE_REGION_WIN'
+ col.operator(
"object.collection_instance_add",
- text="Collection Instance...",
+ text="Collection Instance..." if has_collections else "No Collections to Instance",
icon='OUTLINER_OB_GROUP_INSTANCE',
)
else:
- layout.operator_menu_enum(
+ col.operator_menu_enum(
"object.collection_instance_add",
"collection",
text="Collection Instance",
@@ -1479,7 +1485,7 @@ class VIEW3D_MT_object_clear(Menu):
class VIEW3D_MT_object_specials(Menu):
- bl_label = "Context Menu"
+ bl_label = "Object Context Menu"
@classmethod
def poll(cls, context):
@@ -1782,11 +1788,11 @@ class VIEW3D_MT_make_single_user(Menu):
props = layout.operator("object.make_single_user", text="Object")
props.object = True
- props.obdata = props.material = props.texture = props.animation = False
+ props.obdata = props.material = props.animation = False
props = layout.operator("object.make_single_user", text="Object & Data")
props.object = props.obdata = True
- props.material = props.texture = props.animation = False
+ props.material = props.animation = False
props = layout.operator("object.make_single_user", text="Object & Data & Materials")
props.object = props.obdata = props.material = True
@@ -2109,7 +2115,7 @@ class VIEW3D_MT_particle(Menu):
class VIEW3D_MT_particle_specials(Menu):
- bl_label = "Context Menu"
+ bl_label = "Particle Context Menu"
def draw(self, context):
layout = self.layout
@@ -2359,7 +2365,7 @@ class VIEW3D_MT_pose_apply(Menu):
class VIEW3D_MT_pose_specials(Menu):
- bl_label = "Context Menu"
+ bl_label = "Pose Context Menu"
def draw(self, context):
layout = self.layout
@@ -2492,7 +2498,7 @@ class VIEW3D_MT_edit_mesh(Menu):
class VIEW3D_MT_edit_mesh_specials(Menu):
- bl_label = "Context Menu"
+ bl_label = "Mesh Context Menu"
def draw(self, context):
layout = self.layout
@@ -3050,7 +3056,7 @@ class VIEW3D_MT_edit_curve_clean(Menu):
class VIEW3D_MT_edit_curve_specials(Menu):
- bl_label = "Context Menu"
+ bl_label = "Curve Context Menu"
def draw(self, context):
layout = self.layout
@@ -3264,7 +3270,7 @@ class VIEW3D_MT_edit_armature(Menu):
class VIEW3D_MT_armature_specials(Menu):
- bl_label = "Context Menu"
+ bl_label = "Armature Context Menu"
def draw(self, context):
layout = self.layout
@@ -3414,6 +3420,28 @@ class VIEW3D_MT_edit_gpencil_interpolate(Menu):
layout.operator("gpencil.interpolate_sequence", text="Sequence")
+class VIEW3D_PIE_object_mode(Menu):
+ bl_label = "Mode"
+
+ def draw(self, context):
+ layout = self.layout
+
+ pie = layout.menu_pie()
+ pie.operator_enum("OBJECT_OT_mode_set", "mode")
+
+
+class VIEW3D_PIE_view(Menu):
+ bl_label = "View"
+ bl_idname = "VIEW3D_PIE_view"
+
+ def draw(self, context):
+ layout = self.layout
+
+ pie = layout.menu_pie()
+ pie.operator_enum("VIEW3D_OT_viewnumpad", "type")
+ pie.operator("view3d.view_selected", text="View Selected", icon='ZOOM_SELECTED')
+
+
# ********** Panel **********
@@ -3496,31 +3524,6 @@ class VIEW3D_PT_view3d_cursor(Panel):
layout.column().prop(view, "cursor_location", text="Location")
-class VIEW3D_PT_view3d_name(Panel):
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- bl_label = "Item"
-
- @classmethod
- def poll(cls, context):
- return (context.space_data and context.active_object)
-
- def draw(self, context):
- layout = self.layout
-
- ob = context.active_object
- row = layout.row()
- row.label(text="", icon='OBJECT_DATA')
- row.prop(ob, "name", text="")
-
- if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
- bone = context.active_bone
- if bone:
- row = layout.row()
- row.label(text="", icon='BONE_DATA')
- row.prop(bone, "name", text="")
-
-
class VIEW3D_PT_shading(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
@@ -3537,42 +3540,78 @@ class VIEW3D_PT_shading(Panel):
shading = view.shading
col = layout.column()
+ col.row().label("Lighting")
+ if shading.type in ('SOLID', 'TEXTURED'):
+ col.row().prop(shading, "light", expand=True)
+ if shading.light == 'STUDIO':
+ row = col.row()
+ row.template_icon_view(shading, "studio_light")
+ sub = row.column()
+ sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES')
+ if shading.selected_studio_light.orientation == 'WORLD':
+ col.row().prop(shading, "studiolight_rot_z")
+
+ elif shading.light == 'MATCAP':
+ row = col.row()
+ row.template_icon_view(shading, "studio_light")
+ sub = row.column()
+ sub.operator('VIEW3D_OT_toggle_matcap_flip', emboss=False, text="", icon='ARROW_LEFTRIGHT')
+ sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES')
if shading.type == 'SOLID':
+ col.separator()
+ col.row().label("Color")
col.row().prop(shading, "color_type", expand=True)
if shading.color_type == 'SINGLE':
col.row().prop(shading, "single_color", text="")
if shading.type in ('SOLID', 'TEXTURED'):
- col.row().prop(shading, "light", expand=True)
- if shading.light == 'STUDIO':
- col.row().template_icon_view(shading, "studio_light")
- if shading.studio_light_orientation == 'WORLD':
- col.row().prop(shading, "studiolight_rot_z")
-
col.separator()
- row = col.row()
- row.prop(shading, "show_xray")
-
- row = col.row()
- row.active = not shading.show_xray
- row.prop(shading, "show_shadows")
- sub = row.row()
- sub.active = shading.show_shadows and not shading.show_xray
- sub.prop(shading, "shadow_intensity", text="")
-
- row = col.row()
- row.prop(shading, "show_object_outline")
- sub = row.row()
- sub.active = shading.show_object_outline
- sub.prop(shading, "object_outline_color", text="")
+ if not shading.light == 'MATCAP':
+ row = col.row()
+ row.prop(shading, "show_specular_highlight")
+
+ if shading.type in ('SOLID', 'TEXTURED'):
+ row = col.split(0.4)
+ row.prop(shading, "show_xray")
+ sub = row.row()
+ sub.active = shading.show_xray
+ sub.prop(shading, "xray_alpha", text="")
+
+ row = col.split(0.4)
+ row.active = not shading.show_xray
+ row.prop(shading, "show_shadows")
+ sub = row.row()
+ sub.active = shading.show_shadows and not shading.show_xray
+ sub.prop(shading, "shadow_intensity", text="")
+
+ row = col.split(0.4)
+ row.active = not shading.show_xray
+ row.prop(shading, "show_cavity")
+ sub = row.column(align=True)
+ sub.active = not shading.show_xray and shading.show_cavity
+ sub.prop(shading, "cavity_ridge_factor")
+ sub.prop(shading, "cavity_valley_factor")
+
+ row = col.split(0.4)
+ row.prop(shading, "show_object_outline")
+ sub = row.row()
+ sub.active = shading.show_object_outline
+ sub.prop(shading, "object_outline_color", text="")
+
+ col.prop(view, "show_world")
elif shading.type in ('MATERIAL'):
- col.row().template_icon_view(shading, "studio_light")
- if shading.studio_light_orientation == 'WORLD':
+ row = col.row()
+ row.template_icon_view(shading, "studio_light")
+ sub = row.column()
+ sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES')
+ if shading.selected_studio_light.orientation == 'WORLD':
col.row().prop(shading, "studiolight_rot_z")
+ col.row().prop(shading, "studiolight_background")
+ col.prop(shading, "use_scene_light")
class VIEW3D_PT_overlay(Panel):
@@ -3588,27 +3627,37 @@ class VIEW3D_PT_overlay(Panel):
layout = self.layout
view = context.space_data
+ shading = view.shading
overlay = view.overlay
- scene = context.scene
toolsettings = context.tool_settings
display_all = overlay.show_overlays
col = layout.column()
- col.prop(view, "show_world")
-
- col = layout.column()
col.active = display_all
- col.prop(overlay, "show_cursor", text="3D Cursor")
- col.prop(view, "show_manipulator", text="Manipulators")
+ split = col.split()
- col = layout.column()
- col.active = display_all
- col.prop(overlay, "show_outline_selected")
- col.prop(overlay, "show_all_objects_origin")
- col.prop(overlay, "show_relationship_lines")
- col.prop(overlay, "show_face_orientation")
- col.prop(overlay, "show_backface_culling")
+ sub = split.column()
+ sub.prop(view, "show_manipulator", text="Manipulators")
+ sub.prop(overlay, "show_text", text="Text")
+ sub.prop(overlay, "show_cursor", text="3D Cursor")
+ sub.prop(overlay, "show_outline_selected")
+ sub.prop(overlay, "show_all_objects_origin")
+
+ sub = split.column()
+ sub.prop(overlay, "show_relationship_lines")
+ sub.prop(overlay, "show_motion_paths")
+ #sub.prop(overlay, "show_onion_skins")
+ sub.prop(overlay, "show_face_orientation")
+ sub.prop(overlay, "show_backface_culling")
+ if shading.type == "MATERIAL":
+ sub.prop(overlay, "show_look_dev")
+
+ row = col.row()
+ row.prop(overlay, "show_wireframes")
+ sub = row.row()
+ sub.active = overlay.show_wireframes
+ sub.prop(overlay, "wireframe_threshold", text="")
col = layout.column()
col.active = display_all
@@ -3620,280 +3669,308 @@ class VIEW3D_PT_overlay(Panel):
row.prop(overlay, "show_axis_y", text="Y", toggle=True)
row.prop(overlay, "show_axis_z", text="Z", toggle=True)
- sub = col.column(align=True)
- sub.active = bool(overlay.show_floor or view.region_quadviews or not view.region_3d.is_perspective)
- subsub = sub.column(align=True)
- subsub.active = overlay.show_floor
- subsub.prop(overlay, "grid_lines", text="Lines")
- sub.prop(overlay, "grid_scale", text="Scale")
- subsub = sub.column(align=True)
- subsub.active = scene.unit_settings.system == 'NONE'
- subsub.prop(overlay, "grid_subdivisions", text="Subdivisions")
-
- if context.mode == 'EDIT_MESH':
- col.separator()
- col.label(text="Edit Mode:")
+ if overlay.show_floor:
+ sub = col.column(align=True)
+ sub.active = bool(overlay.show_floor or view.region_quadviews or not view.region_3d.is_perspective)
+ subsub = sub.column(align=True)
+ subsub.active = overlay.show_floor
+ subsub.prop(overlay, "grid_scale", text="Scale")
+ subsub.prop(overlay, "grid_subdivisions", text="Subdivisions")
+
+ col.prop(view, "show_reconstruction", text="Motion Tracking")
+ if view.show_reconstruction:
+ sub = col.column(align=True)
+ sub.active = view.show_reconstruction
+ sub.prop(view, "show_camera_path", text="Camera Path")
+ sub.prop(view, "show_bundle_names", text="3D Marker Names")
+ sub.label(text="Track Type and Size:")
+ row = sub.row(align=True)
+ row.prop(view, "tracks_draw_type", text="")
+ row.prop(view, "tracks_draw_size", text="")
+
+
+class VIEW3D_PT_overlay_edit_mesh(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay'
+ bl_label = "Edit Mesh"
- col.prop(overlay, "show_occlude_wire")
+ @classmethod
+ def poll(cls, context):
+ return context.mode == 'EDIT_MESH'
- col.prop(overlay, "show_weight")
- col.label("Show Zero Weights:")
- col.row().prop(toolsettings, "vertex_group_user", expand=True)
+ def draw(self, context):
+ layout = self.layout
- col.label(text="Normals:")
- row = col.row(align=True)
+ view = context.space_data
+ shading = view.shading
+ overlay = view.overlay
+ toolsettings = context.tool_settings
+ display_all = overlay.show_overlays
+ data = context.active_object.data
+ statvis = context.tool_settings.statvis
+ with_freestyle = bpy.app.build_options.freestyle
- row.prop(overlay, "show_vertex_normals", text="", icon='VERTEXSEL')
- row.prop(overlay, "show_split_normals", text="", icon='LOOPSEL')
- row.prop(overlay, "show_face_normals", text="", icon='FACESEL')
+ col = layout.column()
+ col.active = display_all
- sub = row.row(align=True)
- sub.active = overlay.show_vertex_normals or overlay.show_face_normals or overlay.show_split_normals
- sub.prop(overlay, "normals_length", text="Size")
+ split = col.split()
- elif context.mode == 'POSE':
- col.separator()
- col.label(text="Pose Mode:")
+ sub = split.column()
+ sub.prop(data, "show_faces", text="Faces")
+ sub.prop(data, "show_edges", text="Edges")
+ sub.prop(data, "show_edge_crease", text="Creases")
+ sub.prop(data, "show_edge_sharp", text="Sharp", text_ctxt=i18n_contexts.plural)
+ sub.prop(data, "show_edge_bevel_weight", text="Bevel")
+ if not with_freestyle:
+ sub.prop(data, "show_edge_seams", text="Seams")
- col = layout.column()
- col.active = display_all
- col.prop(overlay, "show_transparent_bones")
- col.prop(overlay, "show_bone_selection")
+ sub = split.column()
+ sub.prop(overlay, "show_occlude_wire")
+ sub.prop(data, "show_extra_edge_length", text="Edge Length")
+ sub.prop(data, "show_extra_edge_angle", text="Edge Angle")
+ sub.prop(data, "show_extra_face_area", text="Face Area")
+ sub.prop(data, "show_extra_face_angle", text="Face Angle")
- elif context.mode == 'EDIT_ARMATURE':
- col.separator()
- col.label(text="Edit Armature:")
+ if bpy.app.debug:
+ sub.prop(data, "show_extra_indices", text="Indices")
- col = layout.column()
- col.active = display_all
- col.prop(overlay, "show_transparent_bones")
+ if with_freestyle:
+ col.label(text="Freestyle:")
+ row = col.row()
+ row.prop(data, "show_freestyle_edge_marks", text="Edge Marks")
+ row.prop(data, "show_freestyle_face_marks", text="Face Marks")
+ row.prop(data, "show_edge_seams", text="Seams")
- elif context.mode in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
- col.separator()
- col.label(text="Paint Mode:")
+ col.label(text="Normals:")
+ row = col.row(align=True)
- if context.mode in {'PAINT_WEIGHT', 'PAINT_VERTEX'}:
- col.prop(overlay, "show_paint_wire")
+ row.prop(overlay, "show_vertex_normals", text="", icon='VERTEXSEL')
+ row.prop(overlay, "show_split_normals", text="", icon='LOOPSEL')
+ row.prop(overlay, "show_face_normals", text="", icon='FACESEL')
- col.prop(view, "show_mode_shade_override")
+ sub = row.row(align=True)
+ sub.active = overlay.show_vertex_normals or overlay.show_face_normals or overlay.show_split_normals
+ sub.prop(overlay, "normals_length", text="Size")
+ col.prop(overlay, "show_weight")
+ if overlay.show_weight:
+ col.label("Show Zero Weights:")
+ col.row().prop(toolsettings, "vertex_group_user", expand=True)
-class VIEW3D_PT_quad_view(Panel):
+ col.prop(data, "show_statvis", text="Mesh Analysis")
+ if data.show_statvis:
+ sub = col.column()
+ sub.active = data.show_statvis
+ sub.prop(statvis, "type")
+ statvis_type = statvis.type
+ if statvis_type == 'OVERHANG':
+ row = sub.row(align=True)
+ row.prop(statvis, "overhang_min", text="")
+ row.prop(statvis, "overhang_max", text="")
+ sub.row().prop(statvis, "overhang_axis", expand=True)
+ elif statvis_type == 'THICKNESS':
+ row = sub.row(align=True)
+ row.prop(statvis, "thickness_min", text="")
+ row.prop(statvis, "thickness_max", text="")
+ sub.prop(statvis, "thickness_samples")
+ elif statvis_type == 'INTERSECT':
+ pass
+ elif statvis_type == 'DISTORT':
+ row = sub.row(align=True)
+ row.prop(statvis, "distort_min", text="")
+ row.prop(statvis, "distort_max", text="")
+ elif statvis_type == 'SHARP':
+ row = sub.row(align=True)
+ row.prop(statvis, "sharp_min", text="")
+ row.prop(statvis, "sharp_max", text="")
+
+
+class VIEW3D_PT_overlay_edit_curve(Panel):
bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- bl_label = "Quad View"
- bl_options = {'DEFAULT_CLOSED'}
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay'
+ bl_label = "Edit Curve"
@classmethod
def poll(cls, context):
- view = context.space_data
- return view.region_quadviews
+ return context.mode == 'EDIT_CURVE'
def draw(self, context):
layout = self.layout
-
view = context.space_data
+ data = context.active_object.data
+ overlay = view.overlay
+ display_all = overlay.show_overlays
- region = view.region_quadviews[2]
col = layout.column()
- col.prop(region, "lock_rotation")
- row = col.row()
- row.enabled = region.lock_rotation
- row.prop(region, "show_sync_view")
+ col.active = display_all
+
row = col.row()
- row.enabled = region.lock_rotation and region.show_sync_view
- row.prop(region, "use_box_clip")
+ row.prop(data, "show_handles", text="Handles")
+ row.prop(data, "show_normal_face", text="Normals")
-class VIEW3D_PT_view3d_stereo(Panel):
+class VIEW3D_PT_overlay_sculpt(Panel):
bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- bl_label = "Stereoscopy"
- bl_options = {'DEFAULT_CLOSED'}
+ bl_context = ".sculpt_mode"
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay'
+ bl_label = "Sculpt"
@classmethod
def poll(cls, context):
- scene = context.scene
-
- multiview = scene.render.use_multiview
- return context.space_data and multiview
+ return (
+ context.mode == 'SCULPT' and
+ (context.sculpt_object and context.tool_settings.sculpt)
+ )
def draw(self, context):
layout = self.layout
- view = context.space_data
-
- basic_stereo = context.scene.render.views_format == 'STEREO_3D'
-
- col = layout.column()
- col.row().prop(view, "stereo_3d_camera", expand=True)
+ toolsettings = context.tool_settings
+ sculpt = toolsettings.sculpt
- col.label(text="Display:")
- row = col.row()
- row.active = basic_stereo
- row.prop(view, "show_stereo_3d_cameras")
- row = col.row()
- row.active = basic_stereo
- split = row.split()
- split.prop(view, "show_stereo_3d_convergence_plane")
- split = row.split()
- split.prop(view, "stereo_3d_convergence_plane_alpha", text="Alpha")
- split.active = view.show_stereo_3d_convergence_plane
- row = col.row()
- split = row.split()
- split.prop(view, "show_stereo_3d_volume")
- split = row.split()
- split.prop(view, "stereo_3d_volume_alpha", text="Alpha")
+ layout.prop(sculpt, "show_diffuse_color")
+ layout.prop(sculpt, "show_mask")
-class VIEW3D_PT_view3d_motion_tracking(Panel):
+class VIEW3D_PT_overlay_pose(Panel):
bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- bl_label = "Motion Tracking"
- bl_options = {'DEFAULT_CLOSED'}
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay'
+ bl_label = "Pose Mode"
@classmethod
def poll(cls, context):
- view = context.space_data
- return (view)
-
- def draw_header(self, context):
- view = context.space_data
-
- self.layout.prop(view, "show_reconstruction", text="")
+ return context.mode == 'POSE'
def draw(self, context):
layout = self.layout
-
view = context.space_data
+ overlay = view.overlay
+ display_all = overlay.show_overlays
col = layout.column()
- col.active = view.show_reconstruction
- col.prop(view, "show_camera_path", text="Camera Path")
- col.prop(view, "show_bundle_names", text="3D Marker Names")
- col.label(text="Track Type and Size:")
- row = col.row(align=True)
- row.prop(view, "tracks_draw_type", text="")
- row.prop(view, "tracks_draw_size", text="")
+ col.active = display_all
+ col.prop(overlay, "show_transparent_bones")
+ row = col.split(0.65)
+ row.prop(overlay, "show_bone_selection")
+ sub = row.column()
+ sub.active = display_all and overlay.show_bone_selection
+ sub.prop(overlay, "bone_selection_alpha", text="")
-class VIEW3D_PT_view3d_meshdisplay(Panel):
+class VIEW3D_PT_overlay_edit_armature(Panel):
bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- bl_label = "Mesh Display"
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay'
+ bl_label = "Edit Armature"
@classmethod
def poll(cls, context):
- # The active object check is needed because of local-mode
- return (context.active_object and (context.mode == 'EDIT_MESH'))
+ return context.mode == 'EDIT_ARMATURE'
def draw(self, context):
layout = self.layout
- with_freestyle = bpy.app.build_options.freestyle
+ view = context.space_data
+ overlay = view.overlay
+ display_all = overlay.show_overlays
- mesh = context.active_object.data
- scene = context.scene
+ col = layout.column()
+ col.active = display_all
+ col.prop(overlay, "show_transparent_bones")
- split = layout.split()
- col = split.column()
- col.label(text="Overlays:")
- col.prop(mesh, "show_faces", text="Faces")
- col.prop(mesh, "show_edges", text="Edges")
- col.prop(mesh, "show_edge_crease", text="Creases")
- if with_freestyle:
- col.prop(mesh, "show_edge_seams", text="Seams")
+class VIEW3D_PT_overlay_paint(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_parent_id = 'VIEW3D_PT_overlay'
+ bl_label = "Paint"
- col = split.column()
- col.label()
- if not with_freestyle:
- col.prop(mesh, "show_edge_seams", text="Seams")
- col.prop(mesh, "show_edge_sharp", text="Sharp", text_ctxt=i18n_contexts.plural)
- col.prop(mesh, "show_edge_bevel_weight", text="Bevel")
- if with_freestyle:
- col.prop(mesh, "show_freestyle_edge_marks", text="Edge Marks")
- col.prop(mesh, "show_freestyle_face_marks", text="Face Marks")
+ @classmethod
+ def poll(cls, context):
+ return context.mode in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}
+
+ def draw(self, context):
+ layout = self.layout
+ view = context.space_data
+ overlay = view.overlay
+ display_all = overlay.show_overlays
col = layout.column()
+ col.active = display_all
- col.separator()
- split = layout.split()
- col = split.column()
- col.label(text="Edge Info:")
- col.prop(mesh, "show_extra_edge_length", text="Length")
- col.prop(mesh, "show_extra_edge_angle", text="Angle")
- col = split.column()
- col.label(text="Face Info:")
- col.prop(mesh, "show_extra_face_area", text="Area")
- col.prop(mesh, "show_extra_face_angle", text="Angle")
- if bpy.app.debug:
- layout.prop(mesh, "show_extra_indices")
+ if context.mode in {'PAINT_WEIGHT', 'PAINT_VERTEX'}:
+ col.prop(overlay, "show_paint_wire")
+ col.prop(view, "show_mode_shade_override")
-class VIEW3D_PT_view3d_meshstatvis(Panel):
+
+class VIEW3D_PT_quad_view(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
- bl_label = "Mesh Analysis"
+ bl_label = "Quad View"
+ bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
- # The active object check is needed because of local-mode
- return (context.active_object and (context.mode == 'EDIT_MESH'))
-
- def draw_header(self, context):
- mesh = context.active_object.data
-
- self.layout.prop(mesh, "show_statvis", text="")
+ view = context.space_data
+ return view.region_quadviews
def draw(self, context):
layout = self.layout
- mesh = context.active_object.data
- statvis = context.tool_settings.statvis
- layout.active = mesh.show_statvis
+ view = context.space_data
- layout.prop(statvis, "type")
- statvis_type = statvis.type
- if statvis_type == 'OVERHANG':
- row = layout.row(align=True)
- row.prop(statvis, "overhang_min", text="")
- row.prop(statvis, "overhang_max", text="")
- layout.row().prop(statvis, "overhang_axis", expand=True)
- elif statvis_type == 'THICKNESS':
- row = layout.row(align=True)
- row.prop(statvis, "thickness_min", text="")
- row.prop(statvis, "thickness_max", text="")
- layout.prop(statvis, "thickness_samples")
- elif statvis_type == 'INTERSECT':
- pass
- elif statvis_type == 'DISTORT':
- row = layout.row(align=True)
- row.prop(statvis, "distort_min", text="")
- row.prop(statvis, "distort_max", text="")
- elif statvis_type == 'SHARP':
- row = layout.row(align=True)
- row.prop(statvis, "sharp_min", text="")
- row.prop(statvis, "sharp_max", text="")
+ region = view.region_quadviews[2]
+ col = layout.column()
+ col.prop(region, "lock_rotation")
+ row = col.row()
+ row.enabled = region.lock_rotation
+ row.prop(region, "show_sync_view")
+ row = col.row()
+ row.enabled = region.lock_rotation and region.show_sync_view
+ row.prop(region, "use_box_clip")
-class VIEW3D_PT_view3d_curvedisplay(Panel):
+class VIEW3D_PT_view3d_stereo(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
- bl_label = "Curve Display"
+ bl_label = "Stereoscopy"
+ bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
- editmesh = context.mode == 'EDIT_CURVE'
- return (editmesh)
+ scene = context.scene
+
+ multiview = scene.render.use_multiview
+ return context.space_data and multiview
def draw(self, context):
layout = self.layout
+ view = context.space_data
- curve = context.active_object.data
+ basic_stereo = context.scene.render.views_format == 'STEREO_3D'
col = layout.column()
+ col.row().prop(view, "stereo_3d_camera", expand=True)
+
+ col.label(text="Display:")
+ row = col.row()
+ row.active = basic_stereo
+ row.prop(view, "show_stereo_3d_cameras")
+ row = col.row()
+ row.active = basic_stereo
+ split = row.split()
+ split.prop(view, "show_stereo_3d_convergence_plane")
+ split = row.split()
+ split.prop(view, "stereo_3d_convergence_plane_alpha", text="Alpha")
+ split.active = view.show_stereo_3d_convergence_plane
row = col.row()
- row.prop(curve, "show_handles", text="Handles")
- row.prop(curve, "show_normal_face", text="Normals")
+ split = row.split()
+ split.prop(view, "show_stereo_3d_volume")
+ split = row.split()
+ split.prop(view, "stereo_3d_volume_alpha", text="Alpha")
class VIEW3D_PT_transform_orientations(Panel):
@@ -4090,19 +4167,22 @@ classes = (
VIEW3D_MT_edit_armature_delete,
VIEW3D_MT_edit_gpencil_transform,
VIEW3D_MT_edit_gpencil_interpolate,
+ VIEW3D_PIE_object_mode,
+ VIEW3D_PIE_view,
VIEW3D_PT_grease_pencil,
VIEW3D_PT_grease_pencil_palettecolor,
VIEW3D_PT_view3d_properties,
VIEW3D_PT_view3d_cursor,
- VIEW3D_PT_view3d_name,
VIEW3D_PT_quad_view,
VIEW3D_PT_view3d_stereo,
- VIEW3D_PT_view3d_motion_tracking,
- VIEW3D_PT_view3d_meshdisplay,
- VIEW3D_PT_view3d_meshstatvis,
- VIEW3D_PT_view3d_curvedisplay,
VIEW3D_PT_shading,
VIEW3D_PT_overlay,
+ VIEW3D_PT_overlay_edit_mesh,
+ VIEW3D_PT_overlay_edit_curve,
+ VIEW3D_PT_overlay_edit_armature,
+ VIEW3D_PT_overlay_pose,
+ VIEW3D_PT_overlay_paint,
+ VIEW3D_PT_overlay_sculpt,
VIEW3D_PT_transform_orientations,
VIEW3D_PT_context_properties,
)
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 1b1e0f73dd1..a7469104b17 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -36,8 +36,8 @@ from .properties_paint_common import (
class View3DPanel:
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'TOOLS'
+ bl_space_type = 'PROPERTIES'
+ bl_region_type = 'WINDOW'
# **************** standard tool clusters ******************
@@ -53,15 +53,21 @@ def draw_keyframing_tools(context, layout):
# Used by vertex & weight paint
def draw_vpaint_symmetry(layout, vpaint):
- col = layout.column(align=True)
- col.label(text="Mirror:")
- row = col.row(align=True)
+ split = layout.split()
+
+ col = split.column()
+ col.alignment = 'RIGHT'
+ col.label(text="Mirror")
+
+ col = split.column()
+ row = col.row(align=True)
row.prop(vpaint, "use_symmetry_x", text="X", toggle=True)
row.prop(vpaint, "use_symmetry_y", text="Y", toggle=True)
row.prop(vpaint, "use_symmetry_z", text="Z", toggle=True)
col = layout.column()
+ col.use_property_split = True
col.prop(vpaint, "radial_symmetry", text="Radial")
@@ -69,8 +75,8 @@ def draw_vpaint_symmetry(layout, vpaint):
class VIEW3D_PT_tools_meshedit_options(View3DPanel, Panel):
- bl_category = ""
- bl_context = ".mesh_edit" # dot on purpose (access from topbar)
+ bl_category = "Options"
+ bl_context = ".mesh_edit" # dot on purpose (access from topbar)
bl_label = "Mesh Options"
@classmethod
@@ -101,9 +107,10 @@ class VIEW3D_PT_tools_meshedit_options(View3DPanel, Panel):
# ********** default tools for editmode_curve ****************
+
class VIEW3D_PT_tools_curveedit_options_stroke(View3DPanel, Panel):
bl_category = "Options"
- bl_context = ".curve_edit" # dot on purpose (access from topbar)
+ bl_context = ".curve_edit" # dot on purpose (access from topbar)
bl_label = "Curve Stroke"
def draw(self, context):
@@ -155,8 +162,6 @@ class VIEW3D_PT_tools_curveedit_options_stroke(View3DPanel, Panel):
colsub.prop(cps, "surface_plane", expand=True)
-
-
# ********** default tools for editmode_armature ****************
@@ -175,7 +180,7 @@ class VIEW3D_PT_tools_armatureedit_options(View3DPanel, Panel):
class VIEW3D_PT_tools_posemode_options(View3DPanel, Panel):
bl_category = "Options"
- bl_context = ".posemode" # dot on purpose (access from topbar)
+ bl_context = ".posemode" # dot on purpose (access from topbar)
bl_label = "Pose Options"
def draw(self, context):
@@ -188,13 +193,13 @@ class VIEW3D_PT_tools_posemode_options(View3DPanel, Panel):
class View3DPaintPanel(UnifiedPaintPanel):
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'TOOLS'
+ bl_space_type = 'PROPERTIES'
+ bl_region_type = 'WINDOW'
class VIEW3D_PT_imapaint_tools_missing(Panel, View3DPaintPanel):
bl_category = "Tools"
- bl_context = ".imagepaint" # dot on purpose (access from topbar)
+ bl_context = ".imagepaint" # dot on purpose (access from topbar)
bl_label = "Missing Data"
@classmethod
@@ -254,8 +259,8 @@ class VIEW3D_PT_imapaint_tools_missing(Panel, View3DPaintPanel):
col.operator("image.new", text="New").gen_context = 'PAINT_STENCIL'
+# TODO, move to space_view3d.py
class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
- bl_category = "Tools"
bl_context = ".paint_common" # dot on purpose (access from topbar)
bl_label = "Brush"
@@ -527,10 +532,10 @@ class VIEW3D_MT_tools_projectpaint_uvlayer(Menu):
props.value = i
+# TODO, move to space_view3d.py
class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
- bl_context = ".imagepaint" # dot on purpose (access from topbar)
+ bl_context = ".imagepaint" # dot on purpose (access from topbar)
bl_label = "Slots"
- bl_category = "Slots"
@classmethod
def poll(cls, context):
@@ -588,10 +593,10 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
col.operator("image.save_dirty", text="Save All Images")
+# TODO, move to space_view3d.py
class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
- bl_context = ".imagepaint" # dot on purpose (access from topbar)
+ bl_context = ".imagepaint" # dot on purpose (access from topbar)
bl_label = "Mask"
- bl_category = "Slots"
@classmethod
def poll(cls, context):
@@ -605,6 +610,7 @@ class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
toolsettings = context.tool_settings
ipaint = toolsettings.image_paint
@@ -615,22 +621,28 @@ class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
col.active = ipaint.use_stencil_layer
stencil_text = mesh.uv_layer_stencil.name if mesh.uv_layer_stencil else ""
- col.label("UV Map")
- col.menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text, translate=False)
+ split = col.split(0.5)
+ colsub = split.column()
+ colsub.alignment = 'RIGHT'
+ colsub.label("UV Layer")
+ split.column().menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text, translate=False)
- col.label("Stencil Image:")
# todo this should be combinded into a single row
- col.template_ID(ipaint, "stencil_image", open="image.open")
- col.operator("image.new", text="New").gen_context = 'PAINT_STENCIL'
+ split = col.split(0.5)
+ colsub = split.column()
+ colsub.alignment = 'RIGHT'
+ colsub.label("Stencil Image")
+ colsub = split.column()
+ colsub.template_ID(ipaint, "stencil_image", open="image.open")
+ colsub.operator("image.new", text="New").gen_context = 'PAINT_STENCIL'
- col.label("Visualization:")
row = col.row(align=True)
- row.prop(ipaint, "stencil_color", text="")
+ row.prop(ipaint, "stencil_color", text="Display Color")
row.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
+# TODO, move to space_view3d.py
class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
- bl_category = "Options"
bl_context = ".paint_common" # dot on purpose (access from topbar)
bl_label = "Overlay"
@@ -696,8 +708,8 @@ class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
sub.prop(brush, "use_secondary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
+# TODO, move to space_view3d.py
class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
- bl_category = "Tools"
bl_context = ".paint_common" # dot on purpose (access from topbar)
bl_label = "Texture"
bl_options = {'DEFAULT_CLOSED'}
@@ -721,9 +733,9 @@ class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
brush_texture_settings(col, brush, context.sculpt_object)
+# TODO, move to space_view3d.py
class VIEW3D_PT_tools_mask_texture(Panel, View3DPaintPanel):
- bl_category = "Tools"
- bl_context = ".imagepaint" # dot on purpose (access from topbar)
+ bl_context = ".imagepaint" # dot on purpose (access from topbar)
bl_label = "Texture Mask"
bl_options = {'DEFAULT_CLOSED'}
@@ -744,8 +756,8 @@ class VIEW3D_PT_tools_mask_texture(Panel, View3DPaintPanel):
brush_mask_texture_settings(col, brush)
+# TODO, move to space_view3d.py
class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
- bl_category = "Tools"
bl_context = ".paint_common" # dot on purpose (access from topbar)
bl_label = "Stroke"
bl_options = {'DEFAULT_CLOSED'}
@@ -765,12 +777,11 @@ class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
settings = self.paint_settings(context)
brush = settings.brush
+ layout.use_property_split = True
col = layout.column()
- col.label(text="Stroke Method:")
-
- col.prop(brush, "stroke_method", text="")
+ col.prop(brush, "stroke_method")
if brush.use_anchor:
col.separator()
@@ -800,12 +811,16 @@ class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
if brush.sculpt_capabilities.has_jitter:
col.separator()
- row = col.row(align=True)
+ colsub = col.split(0.5)
+ row = colsub.row(align=True)
+ row.alignment = 'RIGHT'
+ row.label("Jitter")
+ row = colsub.row(align=True)
row.prop(brush, "use_relative_jitter", icon_only=True)
if brush.use_relative_jitter:
- row.prop(brush, "jitter", slider=True)
+ row.prop(brush, "jitter", slider=True, text="")
else:
- row.prop(brush, "jitter_absolute")
+ row.prop(brush, "jitter_absolute", text="")
row.prop(brush, "use_pressure_jitter", toggle=True, text="")
if brush.sculpt_capabilities.has_smooth_stroke:
@@ -843,8 +858,8 @@ class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
layout.prop(settings, "input_samples")
+# TODO, move to space_view3d.py
class VIEW3D_PT_tools_brush_curve(Panel, View3DPaintPanel):
- bl_category = "Tools"
bl_context = ".paint_common" # dot on purpose (access from topbar)
bl_label = "Curve"
bl_options = {'DEFAULT_CLOSED'}
@@ -873,8 +888,8 @@ class VIEW3D_PT_tools_brush_curve(Panel, View3DPaintPanel):
row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
+# TODO, move to space_view3d.py
class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
- bl_category = "Tools"
bl_context = ".sculpt_mode" # dot on purpose (access from topbar)
bl_label = "Dyntopo"
bl_options = {'DEFAULT_CLOSED'}
@@ -884,16 +899,18 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
return (context.sculpt_object and context.tool_settings.sculpt)
def draw_header(self, context):
+ is_popover = self.is_popover
layout = self.layout
layout.operator(
- "sculpt.dynamic_topology_toggle",
- icon='CHECKBOX_HLT' if context.sculpt_object.use_dynamic_topology_sculpting else 'CHECKBOX_DEHLT',
- text="",
- emboss=False,
- )
+ "sculpt.dynamic_topology_toggle",
+ icon='CHECKBOX_HLT' if context.sculpt_object.use_dynamic_topology_sculpting else 'CHECKBOX_DEHLT',
+ text="",
+ emboss=is_popover,
+ )
def draw(self, context):
layout = self.layout
+ layout.use_property_split = True
toolsettings = context.tool_settings
sculpt = toolsettings.sculpt
@@ -902,7 +919,8 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
col = layout.column()
col.active = context.sculpt_object.use_dynamic_topology_sculpting
- sub = col.column(align=True)
+
+ sub = col.column()
sub.active = (brush and brush.sculpt_tool != 'MASK')
if (sculpt.detail_type_method == 'CONSTANT'):
row = sub.row(align=True)
@@ -912,20 +930,22 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
sub.prop(sculpt, "detail_percent")
else:
sub.prop(sculpt, "detail_size")
- sub.prop(sculpt, "detail_refine_method", text="")
- sub.prop(sculpt, "detail_type_method", text="")
- col.separator()
+ sub.prop(sculpt, "detail_refine_method", text="Refine Method")
+ sub.prop(sculpt, "detail_type_method", text="Detailing")
+
col.prop(sculpt, "use_smooth_shading")
- col.operator("sculpt.optimize")
- if (sculpt.detail_type_method == 'CONSTANT'):
- col.operator("sculpt.detail_flood_fill")
+
col.separator()
+
col.prop(sculpt, "symmetrize_direction")
col.operator("sculpt.symmetrize")
+ col.operator("sculpt.optimize")
+ if (sculpt.detail_type_method == 'CONSTANT'):
+ col.operator("sculpt.detail_flood_fill")
+# TODO, move to space_view3d.py
class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
- bl_category = "Options"
bl_context = ".sculpt_mode" # dot on purpose (access from topbar)
bl_label = "Options"
bl_options = {'DEFAULT_CLOSED'}
@@ -958,8 +978,8 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
self.unified_paint_settings(layout, context)
+# TODO, move to space_view3d.py
class VIEW3D_PT_sculpt_symmetry(Panel, View3DPaintPanel):
- bl_category = "Tools"
bl_context = ".sculpt_mode" # dot on purpose (access from topbar)
bl_label = "Symmetry/Lock"
bl_options = {'DEFAULT_CLOSED'}
@@ -973,35 +993,55 @@ class VIEW3D_PT_sculpt_symmetry(Panel, View3DPaintPanel):
sculpt = context.tool_settings.sculpt
- col = layout.column(align=True)
- col.label(text="Mirror:")
+ split = layout.split()
+
+ col = split.column()
+ col.alignment = 'RIGHT'
+ col.label(text="Mirror")
+
+ col = split.column()
+
row = col.row(align=True)
row.prop(sculpt, "use_symmetry_x", text="X", toggle=True)
row.prop(sculpt, "use_symmetry_y", text="Y", toggle=True)
row.prop(sculpt, "use_symmetry_z", text="Z", toggle=True)
- layout.column().prop(sculpt, "radial_symmetry", text="Radial")
- layout.prop(sculpt, "use_symmetry_feather", text="Feather")
+ split = layout.split()
- layout.label(text="Lock:")
+ col = split.column()
+ col.alignment = 'RIGHT'
+ col.label(text="Lock")
- row = layout.row(align=True)
+ col = split.column()
+
+ row = col.row(align=True)
row.prop(sculpt, "lock_x", text="X", toggle=True)
row.prop(sculpt, "lock_y", text="Y", toggle=True)
row.prop(sculpt, "lock_z", text="Z", toggle=True)
- layout.label(text="Tiling:")
- row = layout.row(align=True)
+ split = layout.split()
+
+ col = split.column()
+ col.alignment = 'RIGHT'
+ col.label(text="Tiling")
+
+ col = split.column()
+
+ row = col.row(align=True)
row.prop(sculpt, "tile_x", text="X", toggle=True)
row.prop(sculpt, "tile_y", text="Y", toggle=True)
row.prop(sculpt, "tile_z", text="Z", toggle=True)
+ layout.use_property_split = True
+
+ layout.prop(sculpt, "use_symmetry_feather", text="Feather")
+ layout.column().prop(sculpt, "radial_symmetry", text="Radial")
layout.column().prop(sculpt, "tile_offset", text="Tile Offset")
+# TODO, move to space_view3d.py
class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
- bl_category = "Options"
bl_context = ".paint_common" # dot on purpose (access from topbar)
bl_label = "Appearance"
@@ -1046,8 +1086,8 @@ class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
# ********** default tools for weight-paint ****************
+# TODO, move to space_view3d.py
class VIEW3D_PT_tools_weightpaint_symmetry(Panel, View3DPaintPanel):
- bl_category = "Tools"
bl_context = ".weightpaint"
bl_options = {'DEFAULT_CLOSED'}
bl_label = "Symmetry"
@@ -1059,8 +1099,8 @@ class VIEW3D_PT_tools_weightpaint_symmetry(Panel, View3DPaintPanel):
draw_vpaint_symmetry(layout, wpaint)
+# TODO, move to space_view3d.py
class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
- bl_category = "Options"
bl_context = ".weightpaint"
bl_label = "Options"
@@ -1090,8 +1130,8 @@ class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
# ********** default tools for vertex-paint ****************
+# TODO, move to space_view3d.py
class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
- bl_category = "Options"
bl_context = ".vertexpaint" # dot on purpose (access from topbar)
bl_label = "Options"
@@ -1106,8 +1146,8 @@ class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
self.unified_paint_settings(col, context)
+# TODO, move to space_view3d.py
class VIEW3D_PT_tools_vertexpaint_symmetry(Panel, View3DPaintPanel):
- bl_category = "Tools"
bl_context = ".vertexpaint" # dot on purpose (access from topbar)
bl_options = {'DEFAULT_CLOSED'}
bl_label = "Symmetry"
@@ -1122,9 +1162,9 @@ class VIEW3D_PT_tools_vertexpaint_symmetry(Panel, View3DPaintPanel):
# ********** default tools for texture-paint ****************
+# TODO, move to space_view3d.py
class VIEW3D_PT_tools_imagepaint_external(Panel, View3DPaintPanel):
- bl_category = "Tools"
- bl_context = ".imagepaint" # dot on purpose (access from topbar)
+ bl_context = ".imagepaint" # dot on purpose (access from topbar)
bl_label = "External"
bl_options = {'DEFAULT_CLOSED'}
@@ -1144,9 +1184,9 @@ class VIEW3D_PT_tools_imagepaint_external(Panel, View3DPaintPanel):
col.operator("paint.project_image", text="Apply Camera Image")
+# TODO, move to space_view3d.py
class VIEW3D_PT_tools_imagepaint_symmetry(Panel, View3DPaintPanel):
- bl_category = "Tools"
- bl_context = ".imagepaint" # dot on purpose (access from topbar)
+ bl_context = ".imagepaint" # dot on purpose (access from topbar)
bl_label = "Symmetry"
bl_options = {'DEFAULT_CLOSED'}
@@ -1156,16 +1196,23 @@ class VIEW3D_PT_tools_imagepaint_symmetry(Panel, View3DPaintPanel):
toolsettings = context.tool_settings
ipaint = toolsettings.image_paint
- col = layout.column(align=True)
+ split = layout.split()
+
+ col = split.column()
+ col.alignment = 'RIGHT'
+ col.label(text="Mirror")
+
+ col = split.column()
+
row = col.row(align=True)
row.prop(ipaint, "use_symmetry_x", text="X", toggle=True)
row.prop(ipaint, "use_symmetry_y", text="Y", toggle=True)
row.prop(ipaint, "use_symmetry_z", text="Z", toggle=True)
+# TODO, move to space_view3d.py
class VIEW3D_PT_tools_projectpaint(View3DPaintPanel, Panel):
- bl_category = "Options"
- bl_context = ".imagepaint" # dot on purpose (access from topbar)
+ bl_context = ".imagepaint" # dot on purpose (access from topbar)
bl_label = "Project Paint"
@classmethod
@@ -1200,8 +1247,8 @@ class VIEW3D_PT_tools_projectpaint(View3DPaintPanel, Panel):
self.unified_paint_settings(layout, context)
+# TODO, move to space_view3d.py
class VIEW3D_PT_imagepaint_options(View3DPaintPanel):
- bl_category = "Options"
bl_label = "Options"
@classmethod
@@ -1226,11 +1273,11 @@ class VIEW3D_MT_tools_projectpaint_stencil(Menu):
props.value = i
+# TODO, move to space_view3d.py
class VIEW3D_PT_tools_particlemode(View3DPanel, Panel):
"""Default tools for particle mode"""
bl_context = ".particlemode"
bl_label = "Options"
- bl_category = "Tools"
def draw(self, context):
layout = self.layout
@@ -1343,6 +1390,8 @@ class VIEW3D_PT_tools_grease_pencil_brush(GreasePencilBrushPanel, Panel):
bl_space_type = 'VIEW_3D'
# Grease Pencil drawingcurves
+
+
class VIEW3D_PT_tools_grease_pencil_brushcurves(GreasePencilBrushCurvesPanel, Panel):
bl_space_type = 'VIEW_3D'
diff --git a/source/blender/alembic/ABC_alembic.h b/source/blender/alembic/ABC_alembic.h
index 70250310213..08136fc2f49 100644
--- a/source/blender/alembic/ABC_alembic.h
+++ b/source/blender/alembic/ABC_alembic.h
@@ -29,8 +29,8 @@ extern "C" {
struct bContext;
struct CacheReader;
-struct DerivedMesh;
struct ListBase;
+struct Mesh;
struct Object;
struct Scene;
@@ -114,12 +114,13 @@ void ABC_get_transform(struct CacheReader *reader,
float time,
float scale);
-struct DerivedMesh *ABC_read_mesh(struct CacheReader *reader,
- struct Object *ob,
- struct DerivedMesh *dm,
- const float time,
- const char **err_str,
- int flags);
+/* Either modifies current_mesh in-place or constructs a new mesh. */
+struct Mesh *ABC_read_mesh(struct CacheReader *reader,
+ struct Object *ob,
+ struct Mesh *current_mesh,
+ const float time,
+ const char **err_str,
+ int flags);
void CacheReader_incref(struct CacheReader *reader);
void CacheReader_free(struct CacheReader *reader);
diff --git a/source/blender/alembic/intern/abc_camera.cc b/source/blender/alembic/intern/abc_camera.cc
index 4c91b9a6252..457bbd2b3af 100644
--- a/source/blender/alembic/intern/abc_camera.cc
+++ b/source/blender/alembic/intern/abc_camera.cc
@@ -49,13 +49,11 @@ using Alembic::AbcGeom::kWrapExisting;
/* ************************************************************************** */
-AbcCameraWriter::AbcCameraWriter(Depsgraph *depsgraph,
- Scene *scene,
- Object *ob,
+AbcCameraWriter::AbcCameraWriter(Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(ob, time_sampling, settings, parent)
{
OCamera camera(parent->alembicXform(), m_name, m_time_sampling);
m_camera_schema = camera.getSchema();
diff --git a/source/blender/alembic/intern/abc_camera.h b/source/blender/alembic/intern/abc_camera.h
index a839ca947ca..dd5dc28d598 100644
--- a/source/blender/alembic/intern/abc_camera.h
+++ b/source/blender/alembic/intern/abc_camera.h
@@ -35,9 +35,7 @@ class AbcCameraWriter : public AbcObjectWriter {
Alembic::AbcGeom::OFloatProperty m_eye_separation;
public:
- AbcCameraWriter(Depsgraph *depsgraph,
- Scene *scene,
- Object *ob,
+ AbcCameraWriter(Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings);
diff --git a/source/blender/alembic/intern/abc_curves.cc b/source/blender/alembic/intern/abc_curves.cc
index 41c1dacabc0..e27403305da 100644
--- a/source/blender/alembic/intern/abc_curves.cc
+++ b/source/blender/alembic/intern/abc_curves.cc
@@ -37,8 +37,8 @@ extern "C" {
#include "BLI_listbase.h"
-#include "BKE_cdderivedmesh.h"
#include "BKE_curve.h"
+#include "BKE_mesh.h"
#include "BKE_object.h"
#include "ED_curve.h"
@@ -71,13 +71,11 @@ using Alembic::AbcGeom::OV2fGeomParam;
/* ************************************************************************** */
-AbcCurveWriter::AbcCurveWriter(Depsgraph *depsgraph,
- Scene *scene,
- Object *ob,
+AbcCurveWriter::AbcCurveWriter(Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(ob, time_sampling, settings, parent)
{
OCurves curves(parent->alembicXform(), m_name, m_time_sampling);
m_schema = curves.getSchema();
@@ -258,9 +256,21 @@ void AbcCurveReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSele
/* ************************************************************************** */
-void read_curve_sample(Curve *cu, const ICurvesSchema &schema, const ISampleSelector &sample_sel)
+void AbcCurveReader::read_curve_sample(Curve *cu, const ICurvesSchema &schema, const ISampleSelector &sample_sel)
{
- ICurvesSchema::Sample smp = schema.getValue(sample_sel);
+ ICurvesSchema::Sample smp;
+ try {
+ smp = schema.getValue(sample_sel);
+ }
+ catch(Alembic::Util::Exception &ex) {
+ printf("Alembic: error reading curve sample for '%s/%s' at time %f: %s\n",
+ m_iobject.getFullName().c_str(),
+ schema.getName().c_str(),
+ sample_sel.getRequestedTime(),
+ ex.what());
+ return;
+ }
+
const Int32ArraySamplePtr num_vertices = smp.getCurvesNumVertices();
const P3fArraySamplePtr positions = smp.getPositions();
const FloatArraySamplePtr weights = smp.getPositionWeights();
@@ -400,18 +410,31 @@ void read_curve_sample(Curve *cu, const ICurvesSchema &schema, const ISampleSele
}
}
-/* NOTE: Alembic only stores data about control points, but the DerivedMesh
+/* NOTE: Alembic only stores data about control points, but the Mesh
* passed from the cache modifier contains the displist, which has more data
* than the control points, so to avoid corrupting the displist we modify the
- * object directly and create a new DerivedMesh from that. Also we might need to
+ * object directly and create a new Mesh from that. Also we might need to
* create new or delete existing NURBS in the curve.
*/
-DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh * /*dm*/,
- const ISampleSelector &sample_sel,
- int /*read_flag*/,
- const char ** /*err_str*/)
+Mesh *AbcCurveReader::read_mesh(Mesh *existing_mesh,
+ const ISampleSelector &sample_sel,
+ int /*read_flag*/,
+ const char **err_str)
{
- const ICurvesSchema::Sample sample = m_curves_schema.getValue(sample_sel);
+ ICurvesSchema::Sample sample;
+
+ try {
+ sample = m_curves_schema.getValue(sample_sel);
+ }
+ catch(Alembic::Util::Exception &ex) {
+ *err_str = "Error reading curve sample; more detail on the console";
+ printf("Alembic: error reading curve sample for '%s/%s' at time %f: %s\n",
+ m_iobject.getFullName().c_str(),
+ m_curves_schema.getName().c_str(),
+ sample_sel.getRequestedTime(),
+ ex.what());
+ return existing_mesh;
+ }
const P3fArraySamplePtr &positions = sample.getPositions();
const Int32ArraySamplePtr num_vertices = sample.getCurvesNumVertices();
@@ -450,5 +473,5 @@ DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh * /*dm*/,
}
}
- return CDDM_from_curve(m_object);
+ return BKE_mesh_new_nomain_from_curve(m_object);
}
diff --git a/source/blender/alembic/intern/abc_curves.h b/source/blender/alembic/intern/abc_curves.h
index 1e7180bbb1f..eb80553620d 100644
--- a/source/blender/alembic/intern/abc_curves.h
+++ b/source/blender/alembic/intern/abc_curves.h
@@ -36,9 +36,7 @@ class AbcCurveWriter : public AbcObjectWriter {
Alembic::AbcGeom::OCurvesSchema::Sample m_sample;
public:
- AbcCurveWriter(Depsgraph *depsgraph,
- Scene *scene,
- Object *ob,
+ AbcCurveWriter(Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings);
@@ -60,16 +58,17 @@ public:
const char **err_str) const;
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
- DerivedMesh *read_derivedmesh(DerivedMesh *dm,
- const Alembic::Abc::ISampleSelector &sample_sel,
- int read_flag,
- const char **err_str);
+ struct Mesh *read_mesh(struct Mesh *existing_mesh,
+ const Alembic::Abc::ISampleSelector &sample_sel,
+ int read_flag,
+ const char **err_str);
+
+ void read_curve_sample(Curve *cu,
+ const Alembic::AbcGeom::ICurvesSchema &schema,
+ const Alembic::Abc::ISampleSelector &sample_selector);
+
};
/* ************************************************************************** */
-void read_curve_sample(Curve *cu,
- const Alembic::AbcGeom::ICurvesSchema &schema,
- const Alembic::Abc::ISampleSelector &sample_selector);
-
#endif /* __ABC_CURVES_H__ */
diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc
index 093c4de085e..c766720d6cd 100644
--- a/source/blender/alembic/intern/abc_exporter.cc
+++ b/source/blender/alembic/intern/abc_exporter.cc
@@ -60,6 +60,8 @@ extern "C" {
#include "BKE_modifier.h"
#include "BKE_particle.h"
#include "BKE_scene.h"
+
+#include "DEG_depsgraph_query.h"
}
using Alembic::Abc::TimeSamplingPtr;
@@ -69,6 +71,8 @@ using Alembic::Abc::OBox3dProperty;
ExportSettings::ExportSettings()
: scene(NULL)
+ , view_layer(NULL)
+ , depsgraph(NULL)
, logger()
, selected_only(false)
, visible_layers_only(false)
@@ -168,16 +172,12 @@ static bool export_object(const ExportSettings * const settings, const Base * co
/* ************************************************************************** */
-AbcExporter::AbcExporter(Main *bmain, Scene *scene,
- Depsgraph *depsgraph,
- const char *filename, ExportSettings &settings)
+AbcExporter::AbcExporter(Main *bmain, const char *filename, ExportSettings &settings)
: m_bmain(bmain)
, m_settings(settings)
, m_filename(filename)
, m_trans_sampling_index(0)
, m_shape_sampling_index(0)
- , m_scene(scene)
- , m_depsgraph(depsgraph)
, m_writer(NULL)
{}
@@ -201,7 +201,7 @@ void AbcExporter::getShutterSamples(unsigned int nr_of_samples,
bool time_relative,
std::vector<double> &samples)
{
- Scene *scene = m_scene; /* for use in the FPS macro */
+ Scene *scene = m_settings.scene; /* for use in the FPS macro */
samples.clear();
unsigned int frame_offset = time_relative ? m_settings.frame_start : 0;
@@ -231,7 +231,7 @@ Alembic::Abc::TimeSamplingPtr AbcExporter::createTimeSampling(double step)
Alembic::Abc::TimeSamplingType ts(
static_cast<uint32_t>(samples.size()),
- 1.0 / m_scene->r.frs_sec);
+ 1.0 / m_settings.scene->r.frs_sec); /* TODO(Sybren): shouldn't we use the FPS macro here? */
return TimeSamplingPtr(new Alembic::Abc::TimeSampling(ts, samples));
}
@@ -265,7 +265,7 @@ void AbcExporter::operator()(float &progress, bool &was_canceled)
scene_name = "untitled";
}
- Scene *scene = m_scene;
+ Scene *scene = m_settings.scene;
const double fps = FPS;
char buf[16];
snprintf(buf, 15, "%f", fps);
@@ -297,8 +297,8 @@ void AbcExporter::operator()(float &progress, bool &was_canceled)
OBox3dProperty archive_bounds_prop = Alembic::AbcGeom::CreateOArchiveBounds(m_writer->archive(), m_trans_sampling_index);
- createTransformWritersHierarchy(m_depsgraph);
- createShapeWriters(m_depsgraph);
+ createTransformWritersHierarchy();
+ createShapeWriters();
/* Make a list of frames to export. */
@@ -360,7 +360,7 @@ void AbcExporter::operator()(float &progress, bool &was_canceled)
}
}
-void AbcExporter::createTransformWritersHierarchy(Depsgraph *depsgraph)
+void AbcExporter::createTransformWritersHierarchy()
{
for (Base *base = static_cast<Base *>(m_settings.view_layer->object_bases.first); base; base = base->next) {
Object *ob = base->object;
@@ -373,27 +373,26 @@ void AbcExporter::createTransformWritersHierarchy(Depsgraph *depsgraph)
/* We do not export transforms for objects of these classes. */
break;
default:
- exploreTransform(depsgraph, base, ob->parent, NULL);
+ exploreTransform(base, ob->parent, NULL);
}
}
}
}
-void AbcExporter::exploreTransform(Depsgraph *depsgraph, Base *ob_base, Object *parent, Object *dupliObParent)
+void AbcExporter::exploreTransform(Base *ob_base, Object *parent, Object *dupliObParent)
{
- Object *ob = ob_base->object;
-
/* If an object isn't exported itself, its duplilist shouldn't be
* exported either. */
if (!export_object(&m_settings, ob_base, dupliObParent != NULL)) {
return;
}
- if (object_type_is_exportable(m_scene, ob)) {
- createTransformWriter(depsgraph, ob, parent, dupliObParent);
+ Object *ob = DEG_get_evaluated_object(m_settings.depsgraph, ob_base->object);
+ if (object_type_is_exportable(m_settings.scene, ob)) {
+ createTransformWriter(ob, parent, dupliObParent);
}
- ListBase *lb = object_duplilist(depsgraph, m_scene, ob);
+ ListBase *lb = object_duplilist(m_settings.depsgraph, m_settings.scene, ob);
if (lb) {
Base fake_base = *ob_base; // copy flags (like selection state) from the real object.
@@ -414,15 +413,15 @@ void AbcExporter::exploreTransform(Depsgraph *depsgraph, Base *ob_base, Object *
dupli_parent = (dupli_ob->parent) ? dupli_ob->parent : ob;
fake_base.object = dupli_ob;
- exploreTransform(depsgraph, &fake_base, dupli_parent, ob);
+ exploreTransform(&fake_base, dupli_parent, ob);
}
}
- }
- free_object_duplilist(lb);
+ free_object_duplilist(lb);
+ }
}
-AbcTransformWriter * AbcExporter::createTransformWriter(Depsgraph *depsgraph, Object *ob, Object *parent, Object *dupliObParent)
+AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *parent, Object *dupliObParent)
{
/* An object should not be its own parent, or we'll get infinite loops. */
BLI_assert(ob != parent);
@@ -457,29 +456,29 @@ AbcTransformWriter * AbcExporter::createTransformWriter(Depsgraph *depsgraph, Ob
* return the parent's AbcTransformWriter pointer. */
if (parent->parent) {
if (parent == dupliObParent) {
- parent_writer = createTransformWriter(depsgraph, parent, parent->parent, NULL);
+ parent_writer = createTransformWriter(parent, parent->parent, NULL);
}
else {
- parent_writer = createTransformWriter(depsgraph, parent, parent->parent, dupliObParent);
+ parent_writer = createTransformWriter(parent, parent->parent, dupliObParent);
}
}
else if (parent == dupliObParent) {
if (dupliObParent->parent == NULL) {
- parent_writer = createTransformWriter(depsgraph, parent, NULL, NULL);
+ parent_writer = createTransformWriter(parent, NULL, NULL);
}
else {
- parent_writer = createTransformWriter(depsgraph, parent, dupliObParent->parent, dupliObParent->parent);
+ parent_writer = createTransformWriter(parent, dupliObParent->parent, dupliObParent->parent);
}
}
else {
- parent_writer = createTransformWriter(depsgraph, parent, dupliObParent, dupliObParent);
+ parent_writer = createTransformWriter(parent, dupliObParent, dupliObParent);
}
BLI_assert(parent_writer);
alembic_parent = parent_writer->alembicXform();
}
- my_writer = new AbcTransformWriter(depsgraph, ob, alembic_parent, parent_writer,
+ my_writer = new AbcTransformWriter(ob, alembic_parent, parent_writer,
m_trans_sampling_index, m_settings);
/* When flattening, the matrix of the dupliobject has to be added. */
@@ -491,14 +490,14 @@ AbcTransformWriter * AbcExporter::createTransformWriter(Depsgraph *depsgraph, Ob
return my_writer;
}
-void AbcExporter::createShapeWriters(Depsgraph *depsgraph)
+void AbcExporter::createShapeWriters()
{
for (Base *base = static_cast<Base *>(m_settings.view_layer->object_bases.first); base; base = base->next) {
- exploreObject(depsgraph, base, NULL);
+ exploreObject(base, NULL);
}
}
-void AbcExporter::exploreObject(Depsgraph *depsgraph, Base *ob_base, Object *dupliObParent)
+void AbcExporter::exploreObject(Base *ob_base, Object *dupliObParent)
{
/* If an object isn't exported itself, its duplilist shouldn't be
* exported either. */
@@ -506,10 +505,10 @@ void AbcExporter::exploreObject(Depsgraph *depsgraph, Base *ob_base, Object *dup
return;
}
- createShapeWriter(ob_base, dupliObParent);
-
- Object *ob = ob_base->object;
- ListBase *lb = object_duplilist(depsgraph, m_scene, ob);
+ Object *ob = DEG_get_evaluated_object(m_settings.depsgraph, ob_base->object);
+ createShapeWriter(ob, dupliObParent);
+
+ ListBase *lb = object_duplilist(m_settings.depsgraph, m_settings.scene, ob);
if (lb) {
Base fake_base = *ob_base; // copy flags (like selection state) from the real object.
@@ -524,12 +523,12 @@ void AbcExporter::exploreObject(Depsgraph *depsgraph, Base *ob_base, Object *dup
}
if (link->type == OB_DUPLICOLLECTION) {
fake_base.object = link->ob;
- exploreObject(depsgraph, &fake_base, ob);
+ exploreObject(&fake_base, ob);
}
}
- }
- free_object_duplilist(lb);
+ free_object_duplilist(lb);
+ }
}
void AbcExporter::createParticleSystemsWriters(Object *ob, AbcTransformWriter *xform)
@@ -547,19 +546,17 @@ void AbcExporter::createParticleSystemsWriters(Object *ob, AbcTransformWriter *x
if (m_settings.export_hair && psys->part->type == PART_HAIR) {
m_settings.export_child_hairs = true;
- m_shapes.push_back(new AbcHairWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
+ m_shapes.push_back(new AbcHairWriter(ob, xform, m_shape_sampling_index, m_settings, psys));
}
else if (m_settings.export_particles && psys->part->type == PART_EMITTER) {
- m_shapes.push_back(new AbcPointsWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
+ m_shapes.push_back(new AbcPointsWriter(ob, xform, m_shape_sampling_index, m_settings, psys));
}
}
}
-void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
+void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent)
{
- Object *ob = ob_base->object;
-
- if (!object_type_is_exportable(m_scene, ob)) {
+ if (!object_type_is_exportable(m_settings.scene, ob)) {
return;
}
@@ -590,7 +587,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
return;
}
- m_shapes.push_back(new AbcMeshWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcMeshWriter(ob, xform, m_shape_sampling_index, m_settings));
break;
}
case OB_SURF:
@@ -601,7 +598,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
return;
}
- m_shapes.push_back(new AbcNurbsWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcNurbsWriter(ob, xform, m_shape_sampling_index, m_settings));
break;
}
case OB_CURVE:
@@ -612,7 +609,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
return;
}
- m_shapes.push_back(new AbcCurveWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcCurveWriter(ob, xform, m_shape_sampling_index, m_settings));
break;
}
case OB_CAMERA:
@@ -620,7 +617,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
Camera *cam = static_cast<Camera *>(ob->data);
if (cam->type == CAM_PERSP) {
- m_shapes.push_back(new AbcCameraWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcCameraWriter(ob, xform, m_shape_sampling_index, m_settings));
}
break;
@@ -633,7 +630,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
}
m_shapes.push_back(new AbcMBallWriter(
- m_bmain, m_depsgraph, m_scene, ob, xform,
+ m_bmain, ob, xform,
m_shape_sampling_index, m_settings));
break;
}
@@ -653,7 +650,7 @@ AbcTransformWriter *AbcExporter::getXForm(const std::string &name)
void AbcExporter::setCurrentFrame(Main *bmain, double t)
{
- m_scene->r.cfra = static_cast<int>(t);
- m_scene->r.subframe = static_cast<float>(t) - m_scene->r.cfra;
- BKE_scene_graph_update_for_newframe(m_depsgraph, bmain);
+ m_settings.scene->r.cfra = static_cast<int>(t);
+ m_settings.scene->r.subframe = static_cast<float>(t) - m_settings.scene->r.cfra;
+ BKE_scene_graph_update_for_newframe(m_settings.depsgraph, bmain);
}
diff --git a/source/blender/alembic/intern/abc_exporter.h b/source/blender/alembic/intern/abc_exporter.h
index c891824a114..a92e426292c 100644
--- a/source/blender/alembic/intern/abc_exporter.h
+++ b/source/blender/alembic/intern/abc_exporter.h
@@ -92,9 +92,6 @@ class AbcExporter {
unsigned int m_trans_sampling_index, m_shape_sampling_index;
- Scene *m_scene;
- Depsgraph *m_depsgraph;
-
ArchiveWriter *m_writer;
/* mapping from name to transform writer */
@@ -104,8 +101,7 @@ class AbcExporter {
std::vector<AbcObjectWriter *> m_shapes;
public:
- AbcExporter(Main *bmain, Scene *scene, Depsgraph *depsgraph,
- const char *filename, ExportSettings &settings);
+ AbcExporter(Main *bmain, const char *filename, ExportSettings &settings);
~AbcExporter();
void operator()(float &progress, bool &was_canceled);
@@ -119,12 +115,12 @@ protected:
private:
Alembic::Abc::TimeSamplingPtr createTimeSampling(double step);
- void createTransformWritersHierarchy(Depsgraph *depsgraph);
- AbcTransformWriter * createTransformWriter(Depsgraph *depsgraph, Object *ob, Object *parent, Object *dupliObParent);
- void exploreTransform(Depsgraph *depsgraph, Base *ob_base, Object *parent, Object *dupliObParent);
- void exploreObject(Depsgraph *depsgraph, Base *ob_base, Object *dupliObParent);
- void createShapeWriters(Depsgraph *depsgraph);
- void createShapeWriter(Base *ob_base, Object *dupliObParent);
+ void createTransformWritersHierarchy();
+ AbcTransformWriter * createTransformWriter(Object *ob, Object *parent, Object *dupliObParent);
+ void exploreTransform(Base *ob_base, Object *parent, Object *dupliObParent);
+ void exploreObject(Base *ob_base, Object *dupliObParent);
+ void createShapeWriters();
+ void createShapeWriter(Object *ob, Object *dupliObParent);
void createParticleSystemsWriters(Object *ob, AbcTransformWriter *xform);
AbcTransformWriter *getXForm(const std::string &name);
diff --git a/source/blender/alembic/intern/abc_hair.cc b/source/blender/alembic/intern/abc_hair.cc
index e7cc474e2e8..83a46a330fd 100644
--- a/source/blender/alembic/intern/abc_hair.cc
+++ b/source/blender/alembic/intern/abc_hair.cc
@@ -30,12 +30,16 @@
extern "C" {
#include "MEM_guardedalloc.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "BLI_listbase.h"
#include "BLI_math_geom.h"
-#include "BKE_DerivedMesh.h"
+#include "BKE_library.h"
+#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_object.h"
#include "BKE_particle.h"
}
@@ -49,14 +53,12 @@ using Alembic::AbcGeom::OV2fGeomParam;
/* ************************************************************************** */
-AbcHairWriter::AbcHairWriter(Depsgraph *depsgraph,
- Scene *scene,
- Object *ob,
+AbcHairWriter::AbcHairWriter(Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings,
ParticleSystem *psys)
- : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(ob, time_sampling, settings, parent)
, m_uv_warning_shown(false)
{
m_psys = psys;
@@ -70,15 +72,8 @@ void AbcHairWriter::do_write()
if (!m_psys) {
return;
}
-
- ParticleSystemModifierData *psmd = psys_get_modifier(m_object, m_psys);
-
- if (!psmd->mesh_final) {
- return;
- }
-
- DerivedMesh *dm = mesh_create_derived_render(m_depsgraph, m_scene, m_object, CD_MASK_MESH);
- DM_ensure_tessface(dm);
+ Mesh *mesh = mesh_get_eval_final(m_settings.depsgraph, m_settings.scene, m_object, CD_MASK_MESH);
+ BKE_mesh_tessface_ensure(mesh);
std::vector<Imath::V3f> verts;
std::vector<int32_t> hvertices;
@@ -88,15 +83,13 @@ void AbcHairWriter::do_write()
if (m_psys->pathcache) {
ParticleSettings *part = m_psys->part;
- write_hair_sample(dm, part, verts, norm_values, uv_values, hvertices);
+ write_hair_sample(mesh, part, verts, norm_values, uv_values, hvertices);
if (m_settings.export_child_hairs && m_psys->childcache) {
- write_hair_child_sample(dm, part, verts, norm_values, uv_values, hvertices);
+ write_hair_child_sample(mesh, part, verts, norm_values, uv_values, hvertices);
}
}
- dm->release(dm);
-
Alembic::Abc::P3fArraySample iPos(verts);
m_sample = OCurvesSchema::Sample(iPos, hvertices);
m_sample.setBasis(Alembic::AbcGeom::kNoBasis);
@@ -119,7 +112,7 @@ void AbcHairWriter::do_write()
m_schema.set(m_sample);
}
-void AbcHairWriter::write_hair_sample(DerivedMesh *dm,
+void AbcHairWriter::write_hair_sample(Mesh *mesh,
ParticleSettings *part,
std::vector<Imath::V3f> &verts,
std::vector<Imath::V3f> &norm_values,
@@ -130,9 +123,9 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm,
float inv_mat[4][4];
invert_m4_m4_safe(inv_mat, m_object->obmat);
- MTFace *mtface = static_cast<MTFace *>(CustomData_get_layer(&dm->faceData, CD_MTFACE));
- MFace *mface = dm->getTessFaceArray(dm);
- MVert *mverts = dm->getVertArray(dm);
+ MTFace *mtface = mesh->mtface;
+ MFace *mface = mesh->mface;
+ MVert *mverts = mesh->mvert;
if ((!mtface || !mface) && !m_uv_warning_shown) {
std::fprintf(stderr, "Warning, no UV set found for underlying geometry of %s.\n",
@@ -152,11 +145,13 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm,
/* underlying info for faces-only emission */
path = cache[p];
+ /* Write UV and normal vectors */
if (part->from == PART_FROM_FACE && mtface) {
const int num = pa->num_dmcache >= 0 ? pa->num_dmcache : pa->num;
- if (num < dm->getNumTessFaces(dm)) {
- MFace *face = static_cast<MFace *>(dm->getTessFaceData(dm, num, CD_MFACE));
+ if (num < mesh->totface) {
+ /* TODO(Sybren): check whether the NULL check here and if(mface) are actually required */
+ MFace *face = mface == NULL ? NULL : &mface[num];
MTFace *tface = mtface + num;
if (mface) {
@@ -172,7 +167,7 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm,
}
}
else {
- std::fprintf(stderr, "Particle to faces overflow (%d/%d)\n", num, dm->getNumTessFaces(dm));
+ std::fprintf(stderr, "Particle to faces overflow (%d/%d)\n", num, mesh->totface);
}
}
else if (part->from == PART_FROM_VERT && mtface) {
@@ -180,8 +175,8 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm,
const int num = (pa->num_dmcache >= 0) ? pa->num_dmcache : pa->num;
/* iterate over all faces to find a corresponding underlying UV */
- for (int n = 0; n < dm->getNumTessFaces(dm); ++n) {
- MFace *face = static_cast<MFace *>(dm->getTessFaceData(dm, n, CD_MFACE));
+ for (int n = 0; n < mesh->totface; ++n) {
+ MFace *face = &mface[n];
MTFace *tface = mtface + n;
unsigned int vtx[4];
vtx[0] = face->v1;
@@ -217,7 +212,7 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm,
int steps = path->segments + 1;
hvertices.push_back(steps);
- for (k = 0; k < steps; ++k) {
+ for (k = 0; k < steps; ++k, ++path) {
float vert[3];
copy_v3_v3(vert, path->co);
mul_m4_v3(inv_mat, vert);
@@ -225,12 +220,11 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm,
/* Convert Z-up to Y-up. */
verts.push_back(Imath::V3f(vert[0], vert[2], -vert[1]));
- ++path;
}
}
}
-void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm,
+void AbcHairWriter::write_hair_child_sample(Mesh *mesh,
ParticleSettings *part,
std::vector<Imath::V3f> &verts,
std::vector<Imath::V3f> &norm_values,
@@ -241,8 +235,8 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm,
float inv_mat[4][4];
invert_m4_m4_safe(inv_mat, m_object->obmat);
- MTFace *mtface = static_cast<MTFace *>(CustomData_get_layer(&dm->faceData, CD_MTFACE));
- MVert *mverts = dm->getVertArray(dm);
+ MTFace *mtface = mesh->mtface;
+ MVert *mverts = mesh->mvert;
ParticleCacheKey **cache = m_psys->childcache;
ParticleCacheKey *path;
@@ -265,7 +259,7 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm,
continue;
}
- MFace *face = static_cast<MFace *>(dm->getTessFaceData(dm, num, CD_MFACE));
+ MFace *face = &mesh->mface[num];
MTFace *tface = mtface + num;
float r_uv[2], tmpnor[3], mapfw[4], vec[3];
diff --git a/source/blender/alembic/intern/abc_hair.h b/source/blender/alembic/intern/abc_hair.h
index 5627f7726e6..e2dffd4edaf 100644
--- a/source/blender/alembic/intern/abc_hair.h
+++ b/source/blender/alembic/intern/abc_hair.h
@@ -25,7 +25,6 @@
#include "abc_object.h"
-struct DerivedMesh;
struct ParticleSettings;
struct ParticleSystem;
@@ -40,9 +39,7 @@ class AbcHairWriter : public AbcObjectWriter {
bool m_uv_warning_shown;
public:
- AbcHairWriter(Depsgraph *depsgraph,
- Scene *scene,
- Object *ob,
+ AbcHairWriter(Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings,
@@ -51,14 +48,14 @@ public:
private:
virtual void do_write();
- void write_hair_sample(DerivedMesh *dm,
+ void write_hair_sample(struct Mesh *mesh,
ParticleSettings *part,
std::vector<Imath::V3f> &verts,
std::vector<Imath::V3f> &norm_values,
std::vector<Imath::V2f> &uv_values,
std::vector<int32_t> &hvertices);
- void write_hair_child_sample(DerivedMesh *dm,
+ void write_hair_child_sample(struct Mesh *mesh,
ParticleSettings *part,
std::vector<Imath::V3f> &verts,
std::vector<Imath::V3f> &norm_values,
diff --git a/source/blender/alembic/intern/abc_mball.cc b/source/blender/alembic/intern/abc_mball.cc
index 1df55712abe..d6e54407922 100644
--- a/source/blender/alembic/intern/abc_mball.cc
+++ b/source/blender/alembic/intern/abc_mball.cc
@@ -42,13 +42,11 @@ extern "C" {
AbcMBallWriter::AbcMBallWriter(
Main *bmain,
- Depsgraph *depsgraph,
- Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(ob, time_sampling, settings, parent)
, m_bmain(bmain)
{
m_is_animated = isAnimated();
@@ -58,8 +56,7 @@ AbcMBallWriter::AbcMBallWriter(
sizeof(CurveCache),
"CurveCache for AbcMBallWriter");
- m_mesh_writer = new AbcMeshWriter(depsgraph, scene, m_mesh_ob, parent,
- time_sampling, settings);
+ m_mesh_writer = new AbcMeshWriter(m_mesh_ob, parent, time_sampling, settings);
m_mesh_writer->setIsAnimated(m_is_animated);
}
@@ -101,7 +98,7 @@ void AbcMBallWriter::do_write()
* only contains for_render flag. As soon as CoW is
* implemented, this is to be rethinked.
*/
- BKE_displist_make_mball_forRender(m_depsgraph, m_scene, m_object, &disp);
+ BKE_displist_make_mball_forRender(m_settings.depsgraph, m_settings.scene, m_object, &disp);
BKE_mesh_from_metaball(&disp, tmpmesh);
BKE_displist_free(&disp);
diff --git a/source/blender/alembic/intern/abc_mball.h b/source/blender/alembic/intern/abc_mball.h
index 19bf7dc054d..07cb1908e95 100644
--- a/source/blender/alembic/intern/abc_mball.h
+++ b/source/blender/alembic/intern/abc_mball.h
@@ -26,6 +26,7 @@
#include "abc_object.h"
class AbcMeshWriter;
+struct EvaluationContext;
struct Main;
struct MetaBall;
struct Object;
@@ -42,8 +43,6 @@ class AbcMBallWriter : public AbcObjectWriter {
public:
AbcMBallWriter(
Main *bmain,
- Depsgraph *depsgraph,
- Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index 56fa0a93532..2b739837239 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -30,6 +30,7 @@
extern "C" {
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_fluidsim_types.h"
#include "DNA_object_types.h"
@@ -37,10 +38,10 @@ extern "C" {
#include "BLI_math_geom.h"
#include "BLI_string.h"
-#include "BKE_cdderivedmesh.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
@@ -51,6 +52,8 @@ extern "C" {
#include "bmesh.h"
#include "bmesh_tools.h"
+
+#include "DEG_depsgraph_query.h"
}
using Alembic::Abc::FloatArraySample;
@@ -103,27 +106,27 @@ using Alembic::AbcGeom::IN3fGeomParam;
/* NOTE: Alembic's polygon winding order is clockwise, to match with Renderman. */
-static void get_vertices(DerivedMesh *dm, std::vector<Imath::V3f> &points)
+static void get_vertices(struct Mesh *mesh, std::vector<Imath::V3f> &points)
{
points.clear();
- points.resize(dm->getNumVerts(dm));
+ points.resize(mesh->totvert);
- MVert *verts = dm->getVertArray(dm);
+ MVert *verts = mesh->mvert;
- for (int i = 0, e = dm->getNumVerts(dm); i < e; ++i) {
+ for (int i = 0, e = mesh->totvert; i < e; ++i) {
copy_yup_from_zup(points[i].getValue(), verts[i].co);
}
}
-static void get_topology(DerivedMesh *dm,
+static void get_topology(struct Mesh *mesh,
std::vector<int32_t> &poly_verts,
std::vector<int32_t> &loop_counts,
bool &smooth_normal)
{
- const int num_poly = dm->getNumPolys(dm);
- const int num_loops = dm->getNumLoops(dm);
- MLoop *mloop = dm->getLoopArray(dm);
- MPoly *mpoly = dm->getPolyArray(dm);
+ const int num_poly = mesh->totpoly;
+ const int num_loops = mesh->totloop;
+ MLoop *mloop = mesh->mloop;
+ MPoly *mpoly = mesh->mpoly;
poly_verts.clear();
loop_counts.clear();
@@ -145,7 +148,7 @@ static void get_topology(DerivedMesh *dm,
}
}
-static void get_creases(DerivedMesh *dm,
+static void get_creases(struct Mesh *mesh,
std::vector<int32_t> &indices,
std::vector<int32_t> &lengths,
std::vector<float> &sharpnesses)
@@ -156,9 +159,9 @@ static void get_creases(DerivedMesh *dm,
lengths.clear();
sharpnesses.clear();
- MEdge *edge = dm->getEdgeArray(dm);
+ MEdge *edge = mesh->medge;
- for (int i = 0, e = dm->getNumEdges(dm); i < e; ++i) {
+ for (int i = 0, e = mesh->totedge; i < e; ++i) {
const float sharpness = static_cast<float>(edge[i].crease) * factor;
if (sharpness != 0.0f) {
@@ -171,41 +174,40 @@ static void get_creases(DerivedMesh *dm,
lengths.resize(sharpnesses.size(), 2);
}
-static void get_vertex_normals(DerivedMesh *dm, std::vector<Imath::V3f> &normals)
+static void get_vertex_normals(struct Mesh *mesh, std::vector<Imath::V3f> &normals)
{
normals.clear();
- normals.resize(dm->getNumVerts(dm));
+ normals.resize(mesh->totvert);
- MVert *verts = dm->getVertArray(dm);
+ MVert *verts = mesh->mvert;
float no[3];
- for (int i = 0, e = dm->getNumVerts(dm); i < e; ++i) {
+ for (int i = 0, e = mesh->totvert; i < e; ++i) {
normal_short_to_float_v3(no, verts[i].no);
copy_yup_from_zup(normals[i].getValue(), no);
}
}
-static void get_loop_normals(DerivedMesh *dm, std::vector<Imath::V3f> &normals)
+static void get_loop_normals(struct Mesh *mesh, std::vector<Imath::V3f> &normals)
{
- MPoly *mpoly = dm->getPolyArray(dm);
- MPoly *mp = mpoly;
+ MPoly *mp = mesh->mpoly;
- MLoop *mloop = dm->getLoopArray(dm);
+ MLoop *mloop = mesh->mloop;
MLoop *ml = mloop;
- MVert *verts = dm->getVertArray(dm);
+ MVert *verts = mesh->mvert;
- const float (*lnors)[3] = static_cast<float(*)[3]>(dm->getLoopDataArray(dm, CD_NORMAL));
+ const float (*lnors)[3] = static_cast<float(*)[3]>(CustomData_get_layer(&mesh->ldata, CD_NORMAL));
normals.clear();
- normals.resize(dm->getNumLoops(dm));
+ normals.resize(mesh->totloop);
unsigned loop_index = 0;
/* NOTE: data needs to be written in the reverse order. */
if (lnors) {
- for (int i = 0, e = dm->getNumPolys(dm); i < e; ++i, ++mp) {
+ for (int i = 0, e = mesh->totpoly; i < e; ++i, ++mp) {
ml = mloop + mp->loopstart + (mp->totloop - 1);
for (int j = 0; j < mp->totloop; --ml, ++j, ++loop_index) {
@@ -217,7 +219,7 @@ static void get_loop_normals(DerivedMesh *dm, std::vector<Imath::V3f> &normals)
else {
float no[3];
- for (int i = 0, e = dm->getNumPolys(dm); i < e; ++i, ++mp) {
+ for (int i = 0, e = mesh->totpoly; i < e; ++i, ++mp) {
ml = mloop + mp->loopstart + (mp->totloop - 1);
/* Flat shaded, use common normal for all verts. */
@@ -286,13 +288,11 @@ static ModifierData *get_liquid_sim_modifier(Scene *scene, Object *ob)
/* ************************************************************************** */
-AbcMeshWriter::AbcMeshWriter(Depsgraph *depsgraph,
- Scene *scene,
- Object *ob,
+AbcMeshWriter::AbcMeshWriter(Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(ob, time_sampling, settings, parent)
{
m_is_animated = isAnimated();
m_subsurf_mod = NULL;
@@ -304,11 +304,11 @@ AbcMeshWriter::AbcMeshWriter(Depsgraph *depsgraph,
}
if (!m_settings.apply_subdiv) {
- m_subsurf_mod = get_subsurf_modifier(m_scene, m_object);
+ m_subsurf_mod = get_subsurf_modifier(m_settings.scene, m_object);
m_is_subd = (m_subsurf_mod != NULL);
}
- m_is_liquid = (get_liquid_sim_modifier(m_scene, m_object) != NULL);
+ m_is_liquid = (get_liquid_sim_modifier(m_settings.scene, m_object) != NULL);
while (parent->alembicXform().getChildHeader(m_name)) {
m_name.append("_");
@@ -369,36 +369,37 @@ void AbcMeshWriter::do_write()
if (!m_first_frame && !m_is_animated)
return;
- DerivedMesh *dm = getFinalMesh();
+ bool needsfree;
+ struct Mesh *mesh = getFinalMesh(needsfree);
try {
if (m_settings.use_subdiv_schema && m_subdiv_schema.valid()) {
- writeSubD(dm);
+ writeSubD(mesh);
}
else {
- writeMesh(dm);
+ writeMesh(mesh);
}
- freeMesh(dm);
+ if (needsfree) BKE_id_free(NULL, mesh);
}
catch (...) {
- freeMesh(dm);
+ if (needsfree) BKE_id_free(NULL, mesh);
throw;
}
}
-void AbcMeshWriter::writeMesh(DerivedMesh *dm)
+void AbcMeshWriter::writeMesh(struct Mesh *mesh)
{
std::vector<Imath::V3f> points, normals;
std::vector<int32_t> poly_verts, loop_counts;
bool smooth_normal = false;
- get_vertices(dm, points);
- get_topology(dm, poly_verts, loop_counts, smooth_normal);
+ get_vertices(mesh, points);
+ get_topology(mesh, poly_verts, loop_counts, smooth_normal);
if (m_first_frame && m_settings.export_face_sets) {
- writeFaceSets(dm, m_mesh_schema);
+ writeFaceSets(mesh, m_mesh_schema);
}
m_mesh_sample = OPolyMeshSchema::Sample(V3fArraySample(points),
@@ -407,7 +408,7 @@ void AbcMeshWriter::writeMesh(DerivedMesh *dm)
UVSample sample;
if (m_first_frame && m_settings.export_uvs) {
- const char *name = get_uv_sample(sample, m_custom_data_config, &dm->loopData);
+ const char *name = get_uv_sample(sample, m_custom_data_config, &mesh->ldata);
if (!sample.indices.empty() && !sample.uvs.empty()) {
OV2fGeomParam::Sample uv_sample;
@@ -419,15 +420,15 @@ void AbcMeshWriter::writeMesh(DerivedMesh *dm)
m_mesh_sample.setUVs(uv_sample);
}
- write_custom_data(m_mesh_schema.getArbGeomParams(), m_custom_data_config, &dm->loopData, CD_MLOOPUV);
+ write_custom_data(m_mesh_schema.getArbGeomParams(), m_custom_data_config, &mesh->ldata, CD_MLOOPUV);
}
if (m_settings.export_normals) {
if (smooth_normal) {
- get_loop_normals(dm, normals);
+ get_loop_normals(mesh, normals);
}
else {
- get_vertex_normals(dm, normals);
+ get_vertex_normals(mesh, normals);
}
ON3fGeomParam::Sample normals_sample;
@@ -441,7 +442,7 @@ void AbcMeshWriter::writeMesh(DerivedMesh *dm)
if (m_is_liquid) {
std::vector<Imath::V3f> velocities;
- getVelocities(dm, velocities);
+ getVelocities(mesh, velocities);
m_mesh_sample.setVelocities(V3fArraySample(velocities));
}
@@ -450,10 +451,10 @@ void AbcMeshWriter::writeMesh(DerivedMesh *dm)
m_mesh_schema.set(m_mesh_sample);
- writeArbGeoParams(dm);
+ writeArbGeoParams(mesh);
}
-void AbcMeshWriter::writeSubD(DerivedMesh *dm)
+void AbcMeshWriter::writeSubD(struct Mesh *mesh)
{
std::vector<float> crease_sharpness;
std::vector<Imath::V3f> points;
@@ -462,12 +463,12 @@ void AbcMeshWriter::writeSubD(DerivedMesh *dm)
bool smooth_normal = false;
- get_vertices(dm, points);
- get_topology(dm, poly_verts, loop_counts, smooth_normal);
- get_creases(dm, crease_indices, crease_lengths, crease_sharpness);
+ get_vertices(mesh, points);
+ get_topology(mesh, poly_verts, loop_counts, smooth_normal);
+ get_creases(mesh, crease_indices, crease_lengths, crease_sharpness);
if (m_first_frame && m_settings.export_face_sets) {
- writeFaceSets(dm, m_subdiv_schema);
+ writeFaceSets(mesh, m_subdiv_schema);
}
m_subdiv_sample = OSubDSchema::Sample(V3fArraySample(points),
@@ -476,7 +477,7 @@ void AbcMeshWriter::writeSubD(DerivedMesh *dm)
UVSample sample;
if (m_first_frame && m_settings.export_uvs) {
- const char *name = get_uv_sample(sample, m_custom_data_config, &dm->loopData);
+ const char *name = get_uv_sample(sample, m_custom_data_config, &mesh->ldata);
if (!sample.indices.empty() && !sample.uvs.empty()) {
OV2fGeomParam::Sample uv_sample;
@@ -488,7 +489,7 @@ void AbcMeshWriter::writeSubD(DerivedMesh *dm)
m_subdiv_sample.setUVs(uv_sample);
}
- write_custom_data(m_subdiv_schema.getArbGeomParams(), m_custom_data_config, &dm->loopData, CD_MLOOPUV);
+ write_custom_data(m_subdiv_schema.getArbGeomParams(), m_custom_data_config, &mesh->ldata, CD_MLOOPUV);
}
if (!crease_indices.empty()) {
@@ -500,11 +501,11 @@ void AbcMeshWriter::writeSubD(DerivedMesh *dm)
m_subdiv_sample.setSelfBounds(bounds());
m_subdiv_schema.set(m_subdiv_sample);
- writeArbGeoParams(dm);
+ writeArbGeoParams(mesh);
}
template <typename Schema>
-void AbcMeshWriter::writeFaceSets(DerivedMesh *dm, Schema &schema)
+void AbcMeshWriter::writeFaceSets(struct Mesh *dm, Schema &schema)
{
std::map< std::string, std::vector<int32_t> > geo_groups;
getGeoGroups(dm, geo_groups);
@@ -518,14 +519,17 @@ void AbcMeshWriter::writeFaceSets(DerivedMesh *dm, Schema &schema)
}
}
-DerivedMesh *AbcMeshWriter::getFinalMesh()
+Mesh *AbcMeshWriter::getFinalMesh(bool &r_needsfree)
{
/* We don't want subdivided mesh data */
if (m_subsurf_mod) {
m_subsurf_mod->mode |= eModifierMode_DisableTemporary;
}
- DerivedMesh *dm = mesh_create_derived_render(m_depsgraph, m_scene, m_object, CD_MASK_MESH);
+ Scene *scene = DEG_get_evaluated_scene(m_settings.depsgraph);
+ Object *ob_eval = DEG_get_evaluated_object(m_settings.depsgraph, m_object);
+ struct Mesh *mesh = mesh_get_eval_final(m_settings.depsgraph, scene, ob_eval, CD_MASK_MESH);
+ r_needsfree = false;
if (m_subsurf_mod) {
m_subsurf_mod->mode &= ~eModifierMode_DisableTemporary;
@@ -536,34 +540,31 @@ DerivedMesh *AbcMeshWriter::getFinalMesh()
const int quad_method = m_settings.quad_method;
const int ngon_method = m_settings.ngon_method;
- BMesh *bm = DM_to_bmesh(dm, true);
+ struct BMeshCreateParams bmcp = {false};
+ struct BMeshFromMeshParams bmfmp = {true, false, false, 0};
+ BMesh *bm = BKE_mesh_to_bmesh_ex(mesh, &bmcp, &bmfmp);
BM_mesh_triangulate(bm, quad_method, ngon_method, tag_only, NULL, NULL, NULL);
- DerivedMesh *result = CDDM_from_bmesh(bm, false);
+ struct BMeshToMeshParams bmmp = {0};
+ Mesh *result = BKE_bmesh_to_mesh_nomain(bm, &bmmp);
BM_mesh_free(bm);
- freeMesh(dm);
-
- dm = result;
+ mesh = result;
+ r_needsfree = true;
}
m_custom_data_config.pack_uvs = m_settings.pack_uv;
- m_custom_data_config.mpoly = dm->getPolyArray(dm);
- m_custom_data_config.mloop = dm->getLoopArray(dm);
- m_custom_data_config.totpoly = dm->getNumPolys(dm);
- m_custom_data_config.totloop = dm->getNumLoops(dm);
- m_custom_data_config.totvert = dm->getNumVerts(dm);
+ m_custom_data_config.mpoly = mesh->mpoly;
+ m_custom_data_config.mloop = mesh->mloop;
+ m_custom_data_config.totpoly = mesh->totpoly;
+ m_custom_data_config.totloop = mesh->totloop;
+ m_custom_data_config.totvert = mesh->totvert;
- return dm;
-}
-
-void AbcMeshWriter::freeMesh(DerivedMesh *dm)
-{
- dm->release(dm);
+ return mesh;
}
-void AbcMeshWriter::writeArbGeoParams(DerivedMesh *dm)
+void AbcMeshWriter::writeArbGeoParams(struct Mesh *dm)
{
if (m_is_liquid) {
/* We don't need anything more for liquid meshes. */
@@ -572,22 +573,22 @@ void AbcMeshWriter::writeArbGeoParams(DerivedMesh *dm)
if (m_first_frame && m_settings.export_vcols) {
if (m_subdiv_schema.valid()) {
- write_custom_data(m_subdiv_schema.getArbGeomParams(), m_custom_data_config, &dm->loopData, CD_MLOOPCOL);
+ write_custom_data(m_subdiv_schema.getArbGeomParams(), m_custom_data_config, &dm->ldata, CD_MLOOPCOL);
}
else {
- write_custom_data(m_mesh_schema.getArbGeomParams(), m_custom_data_config, &dm->loopData, CD_MLOOPCOL);
+ write_custom_data(m_mesh_schema.getArbGeomParams(), m_custom_data_config, &dm->ldata, CD_MLOOPCOL);
}
}
}
-void AbcMeshWriter::getVelocities(DerivedMesh *dm, std::vector<Imath::V3f> &vels)
+void AbcMeshWriter::getVelocities(struct Mesh *mesh, std::vector<Imath::V3f> &vels)
{
- const int totverts = dm->getNumVerts(dm);
+ const int totverts = mesh->totvert;
vels.clear();
vels.resize(totverts);
- ModifierData *md = get_liquid_sim_modifier(m_scene, m_object);
+ ModifierData *md = get_liquid_sim_modifier(m_settings.scene, m_object);
FluidsimModifierData *fmd = reinterpret_cast<FluidsimModifierData *>(md);
FluidsimSettings *fss = fmd->fss;
@@ -605,11 +606,11 @@ void AbcMeshWriter::getVelocities(DerivedMesh *dm, std::vector<Imath::V3f> &vels
}
void AbcMeshWriter::getGeoGroups(
- DerivedMesh *dm,
+ struct Mesh *mesh,
std::map<std::string, std::vector<int32_t> > &geo_groups)
{
- const int num_poly = dm->getNumPolys(dm);
- MPoly *polygons = dm->getPolyArray(dm);
+ const int num_poly = mesh->totpoly;
+ MPoly *polygons = mesh->mpoly;
for (int i = 0; i < num_poly; ++i) {
MPoly &current_poly = polygons[i];
@@ -638,7 +639,7 @@ void AbcMeshWriter::getGeoGroups(
std::vector<int32_t> faceArray;
- for (int i = 0, e = dm->getNumTessFaces(dm); i < e; ++i) {
+ for (int i = 0, e = mesh->totface; i < e; ++i) {
faceArray.push_back(i);
}
@@ -667,7 +668,7 @@ static void assign_materials(Main *bmain, Object *ob, const std::map<std::string
int matcount = 0;
for (; it != mat_index_map.end(); ++it, ++matcount) {
- if (!BKE_object_material_slot_add(ob)) {
+ if (!BKE_object_material_slot_add(bmain, ob)) {
can_assign = false;
break;
}
@@ -696,7 +697,7 @@ static void assign_materials(Main *bmain, Object *ob, const std::map<std::string
assigned_mat = mat_iter->second;
}
- assign_material(ob, assigned_mat, it->second, BKE_MAT_ASSIGN_OBDATA);
+ assign_material(bmain, ob, assigned_mat, it->second, BKE_MAT_ASSIGN_OBDATA);
}
}
}
@@ -873,11 +874,11 @@ ABC_INLINE void read_normals_params(AbcMeshData &abc_data,
}
}
-static bool check_smooth_poly_flag(DerivedMesh *dm)
+static bool check_smooth_poly_flag(Mesh *mesh)
{
- MPoly *mpolys = dm->getPolyArray(dm);
+ MPoly *mpolys = mesh->mpoly;
- for (int i = 0, e = dm->getNumPolys(dm); i < e; ++i) {
+ for (int i = 0, e = mesh->totpoly; i < e; ++i) {
MPoly &poly = mpolys[i];
if ((poly.flag & ME_SMOOTH) != 0) {
@@ -888,11 +889,11 @@ static bool check_smooth_poly_flag(DerivedMesh *dm)
return false;
}
-static void set_smooth_poly_flag(DerivedMesh *dm)
+static void set_smooth_poly_flag(Mesh *mesh)
{
- MPoly *mpolys = dm->getPolyArray(dm);
+ MPoly *mpolys = mesh->mpoly;
- for (int i = 0, e = dm->getNumPolys(dm); i < e; ++i) {
+ for (int i = 0, e = mesh->totpoly; i < e; ++i) {
MPoly &poly = mpolys[i];
poly.flag |= ME_SMOOTH;
}
@@ -900,7 +901,7 @@ static void set_smooth_poly_flag(DerivedMesh *dm)
static void *add_customdata_cb(void *user_data, const char *name, int data_type)
{
- DerivedMesh *dm = static_cast<DerivedMesh *>(user_data);
+ Mesh *mesh = static_cast<Mesh *>(user_data);
CustomDataType cd_data_type = static_cast<CustomDataType>(data_type);
void *cd_ptr;
CustomData *loopdata;
@@ -911,7 +912,7 @@ static void *add_customdata_cb(void *user_data, const char *name, int data_type)
return NULL;
}
- loopdata = dm->getLoopDataLayout(dm);
+ loopdata = &mesh->ldata;
cd_ptr = CustomData_get_layer_named(loopdata, cd_data_type, name);
if (cd_ptr != NULL) {
/* layer already exists, so just return it. */
@@ -920,7 +921,7 @@ static void *add_customdata_cb(void *user_data, const char *name, int data_type)
/* create a new layer, taking care to construct the hopefully-soon-to-be-removed
* CD_MTEXPOLY layer too, with the same name. */
- numloops = dm->getNumLoops(dm);
+ numloops = mesh->totloop;
cd_ptr = CustomData_add_layer_named(loopdata, cd_data_type, CD_DEFAULT,
NULL, numloops, name);
return cd_ptr;
@@ -986,17 +987,19 @@ static void read_mesh_sample(const std::string & iobject_full_name,
}
}
-CDStreamConfig get_config(DerivedMesh *dm)
+CDStreamConfig get_config(Mesh *mesh)
{
CDStreamConfig config;
- config.user_data = dm;
- config.mvert = dm->getVertArray(dm);
- config.mloop = dm->getLoopArray(dm);
- config.mpoly = dm->getPolyArray(dm);
- config.totloop = dm->getNumLoops(dm);
- config.totpoly = dm->getNumPolys(dm);
- config.loopdata = dm->getLoopDataLayout(dm);
+ BLI_assert(mesh->mvert);
+
+ config.user_data = mesh;
+ config.mvert = mesh->mvert;
+ config.mloop = mesh->mloop;
+ config.mpoly = mesh->mpoly;
+ config.totloop = mesh->totloop;
+ config.totpoly = mesh->totpoly;
+ config.loopdata = &mesh->ldata;
config.add_customdata_cb = add_customdata_cb;
return config;
@@ -1027,14 +1030,8 @@ void AbcMeshReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
m_object = BKE_object_add_only_object(bmain, OB_MESH, m_object_name.c_str());
m_object->data = mesh;
- DerivedMesh *dm = CDDM_from_mesh(mesh);
- DerivedMesh *ndm = this->read_derivedmesh(dm, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
-
- if (ndm != dm) {
- dm->release(dm);
- }
-
- DM_to_mesh(ndm, mesh, m_object, CD_MASK_MESH, true);
+ Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
+ BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, CD_MASK_MESH, true);
if (m_settings->validate_meshes) {
BKE_mesh_validate(mesh, false, false);
@@ -1064,33 +1061,45 @@ bool AbcMeshReader::accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHe
return true;
}
-DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
- const ISampleSelector &sample_sel,
- int read_flag,
- const char **err_str)
+Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
+ const ISampleSelector &sample_sel,
+ int read_flag,
+ const char **err_str)
{
- const IPolyMeshSchema::Sample sample = m_schema.getValue(sample_sel);
+ IPolyMeshSchema::Sample sample;
+ try {
+ sample = m_schema.getValue(sample_sel);
+ }
+ catch(Alembic::Util::Exception &ex) {
+ *err_str = "Error reading mesh sample; more detail on the console";
+ printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
+ m_iobject.getFullName().c_str(),
+ m_schema.getName().c_str(),
+ sample_sel.getRequestedTime(),
+ ex.what());
+ return existing_mesh;
+ }
const P3fArraySamplePtr &positions = sample.getPositions();
const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices();
const Alembic::Abc::Int32ArraySamplePtr &face_counts = sample.getFaceCounts();
- DerivedMesh *new_dm = NULL;
+ Mesh *new_mesh = NULL;
/* Only read point data when streaming meshes, unless we need to create new ones. */
ImportSettings settings;
settings.read_flag |= read_flag;
- bool topology_changed = positions->size() != dm->getNumVerts(dm) ||
- face_counts->size() != dm->getNumPolys(dm) ||
- face_indices->size() != dm->getNumLoops(dm);
+ bool topology_changed = positions->size() != existing_mesh->totvert ||
+ face_counts->size() != existing_mesh->totpoly ||
+ face_indices->size() != existing_mesh->totloop;
if (topology_changed) {
- new_dm = CDDM_from_template(dm,
- positions->size(),
- 0,
- 0,
- face_indices->size(),
- face_counts->size());
+ new_mesh = BKE_mesh_new_nomain_from_template(existing_mesh,
+ positions->size(),
+ 0,
+ 0,
+ face_indices->size(),
+ face_counts->size());
settings.read_flag |= MOD_MESHSEQ_READ_ALL;
}
@@ -1098,8 +1107,8 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
/* If the face count changed (e.g. by triangulation), only read points.
* This prevents crash from T49813.
* TODO(kevin): perhaps find a better way to do this? */
- if (face_counts->size() != dm->getNumPolys(dm) ||
- face_indices->size() != dm->getNumLoops(dm))
+ if (face_counts->size() != existing_mesh->totpoly ||
+ face_indices->size() != existing_mesh->totloop)
{
settings.read_flag = MOD_MESHSEQ_READ_VERT;
@@ -1110,40 +1119,39 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
}
}
- CDStreamConfig config = get_config(new_dm ? new_dm : dm);
+ CDStreamConfig config = get_config(new_mesh ? new_mesh : existing_mesh);
config.time = sample_sel.getRequestedTime();
bool do_normals = false;
read_mesh_sample(m_iobject.getFullName(),
&settings, m_schema, sample_sel, config, do_normals);
- if (new_dm) {
+ if (new_mesh) {
/* Check if we had ME_SMOOTH flag set to restore it. */
- if (!do_normals && check_smooth_poly_flag(dm)) {
- set_smooth_poly_flag(new_dm);
+ if (!do_normals && check_smooth_poly_flag(existing_mesh)) {
+ set_smooth_poly_flag(new_mesh);
}
- CDDM_calc_normals(new_dm);
- CDDM_calc_edges(new_dm);
+ BKE_mesh_calc_normals(new_mesh);
+ BKE_mesh_calc_edges(new_mesh, false, false);
/* Here we assume that the number of materials doesn't change, i.e. that
* the material slots that were created when the object was loaded from
* Alembic are still valid now. */
- size_t num_polys = new_dm->getNumPolys(new_dm);
+ size_t num_polys = new_mesh->totpoly;
if (num_polys > 0) {
- MPoly *dmpolies = new_dm->getPolyArray(new_dm);
std::map<std::string, int> mat_map;
- assign_facesets_to_mpoly(sample_sel, 0, dmpolies, num_polys, mat_map);
+ assign_facesets_to_mpoly(sample_sel, 0, new_mesh->mpoly, num_polys, mat_map);
}
- return new_dm;
+ return new_mesh;
}
if (do_normals) {
- CDDM_calc_normals(dm);
+ BKE_mesh_calc_normals(existing_mesh);
}
- return dm;
+ return existing_mesh;
}
void AbcMeshReader::assign_facesets_to_mpoly(
@@ -1305,16 +1313,22 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
m_object = BKE_object_add_only_object(bmain, OB_MESH, m_object_name.c_str());
m_object->data = mesh;
- DerivedMesh *dm = CDDM_from_mesh(mesh);
- DerivedMesh *ndm = this->read_derivedmesh(dm, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
+ Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
+ BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, CD_MASK_MESH, true);
- if (ndm != dm) {
- dm->release(dm);
+ ISubDSchema::Sample sample;
+ try {
+ sample = m_schema.getValue(sample_sel);
+ }
+ catch(Alembic::Util::Exception &ex) {
+ printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
+ m_iobject.getFullName().c_str(),
+ m_schema.getName().c_str(),
+ sample_sel.getRequestedTime(),
+ ex.what());
+ return;
}
- DM_to_mesh(ndm, mesh, m_object, CD_MASK_MESH, true);
-
- const ISubDSchema::Sample sample = m_schema.getValue(sample_sel);
Int32ArraySamplePtr indices = sample.getCreaseIndices();
Alembic::Abc::FloatArraySamplePtr sharpnesses = sample.getCreaseSharpnesses();
@@ -1344,29 +1358,41 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
}
}
-DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm,
- const ISampleSelector &sample_sel,
- int read_flag,
- const char **err_str)
+Mesh *AbcSubDReader::read_mesh(Mesh *existing_mesh,
+ const ISampleSelector &sample_sel,
+ int read_flag,
+ const char **err_str)
{
- const ISubDSchema::Sample sample = m_schema.getValue(sample_sel);
+ ISubDSchema::Sample sample;
+ try {
+ sample = m_schema.getValue(sample_sel);
+ }
+ catch(Alembic::Util::Exception &ex) {
+ *err_str = "Error reading mesh sample; more detail on the console";
+ printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
+ m_iobject.getFullName().c_str(),
+ m_schema.getName().c_str(),
+ sample_sel.getRequestedTime(),
+ ex.what());
+ return existing_mesh;
+ }
const P3fArraySamplePtr &positions = sample.getPositions();
const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices();
const Alembic::Abc::Int32ArraySamplePtr &face_counts = sample.getFaceCounts();
- DerivedMesh *new_dm = NULL;
+ Mesh *new_mesh = NULL;
ImportSettings settings;
settings.read_flag |= read_flag;
- if (dm->getNumVerts(dm) != positions->size()) {
- new_dm = CDDM_from_template(dm,
- positions->size(),
- 0,
- 0,
- face_indices->size(),
- face_counts->size());
+ if (existing_mesh->totvert != positions->size()) {
+ new_mesh = BKE_mesh_new_nomain_from_template(existing_mesh,
+ positions->size(),
+ 0,
+ 0,
+ face_indices->size(),
+ face_counts->size());
settings.read_flag |= MOD_MESHSEQ_READ_ALL;
}
@@ -1374,8 +1400,8 @@ DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm,
/* If the face count changed (e.g. by triangulation), only read points.
* This prevents crash from T49813.
* TODO(kevin): perhaps find a better way to do this? */
- if (face_counts->size() != dm->getNumPolys(dm) ||
- face_indices->size() != dm->getNumLoops(dm))
+ if (face_counts->size() != existing_mesh->totpoly ||
+ face_indices->size() != existing_mesh->totpoly)
{
settings.read_flag = MOD_MESHSEQ_READ_VERT;
@@ -1387,22 +1413,22 @@ DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm,
}
/* Only read point data when streaming meshes, unless we need to create new ones. */
- CDStreamConfig config = get_config(new_dm ? new_dm : dm);
+ CDStreamConfig config = get_config(new_mesh ? new_mesh : existing_mesh);
config.time = sample_sel.getRequestedTime();
read_subd_sample(m_iobject.getFullName(),
&settings, m_schema, sample_sel, config);
- if (new_dm) {
+ if (new_mesh) {
/* Check if we had ME_SMOOTH flag set to restore it. */
- if (check_smooth_poly_flag(dm)) {
- set_smooth_poly_flag(new_dm);
+ if (check_smooth_poly_flag(existing_mesh)) {
+ set_smooth_poly_flag(new_mesh);
}
- CDDM_calc_normals(new_dm);
- CDDM_calc_edges(new_dm);
+ BKE_mesh_calc_normals(new_mesh);
+ BKE_mesh_calc_edges(new_mesh, false, false);
- return new_dm;
+ return new_mesh;
}
- return dm;
+ return existing_mesh;
}
diff --git a/source/blender/alembic/intern/abc_mesh.h b/source/blender/alembic/intern/abc_mesh.h
index c57123cda4c..e1507bedd01 100644
--- a/source/blender/alembic/intern/abc_mesh.h
+++ b/source/blender/alembic/intern/abc_mesh.h
@@ -26,7 +26,6 @@
#include "abc_customdata.h"
#include "abc_object.h"
-struct DerivedMesh;
struct Mesh;
struct ModifierData;
@@ -50,9 +49,7 @@ class AbcMeshWriter : public AbcObjectWriter {
bool m_is_subd;
public:
- AbcMeshWriter(Depsgraph *depsgraph,
- Scene *scene,
- Object *ob,
+ AbcMeshWriter(Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings);
@@ -65,29 +62,28 @@ private:
bool isAnimated() const;
- void writeMesh(DerivedMesh *dm);
- void writeSubD(DerivedMesh *dm);
+ void writeMesh(struct Mesh *mesh);
+ void writeSubD(struct Mesh *mesh);
- void getMeshInfo(DerivedMesh *dm, std::vector<float> &points,
+ void getMeshInfo(struct Mesh *mesh, std::vector<float> &points,
std::vector<int32_t> &facePoints,
std::vector<int32_t> &faceCounts,
std::vector<int32_t> &creaseIndices,
std::vector<int32_t> &creaseLengths,
std::vector<float> &creaseSharpness);
- DerivedMesh *getFinalMesh();
- void freeMesh(DerivedMesh *dm);
+ struct Mesh *getFinalMesh(bool &r_needsfree);
- void getMaterialIndices(DerivedMesh *dm, std::vector<int32_t> &indices);
+ void getMaterialIndices(struct Mesh *mesh, std::vector<int32_t> &indices);
- void writeArbGeoParams(DerivedMesh *dm);
- void getGeoGroups(DerivedMesh *dm, std::map<std::string, std::vector<int32_t> > &geoGroups);
+ void writeArbGeoParams(struct Mesh *mesh);
+ void getGeoGroups(struct Mesh *mesh, std::map<std::string, std::vector<int32_t> > &geoGroups);
/* fluid surfaces support */
- void getVelocities(DerivedMesh *dm, std::vector<Imath::V3f> &vels);
+ void getVelocities(struct Mesh *mesh, std::vector<Imath::V3f> &vels);
template <typename Schema>
- void writeFaceSets(DerivedMesh *dm, Schema &schema);
+ void writeFaceSets(struct Mesh *mesh, Schema &schema);
};
/* ************************************************************************** */
@@ -106,10 +102,10 @@ public:
const char **err_str) const;
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
- DerivedMesh *read_derivedmesh(DerivedMesh *dm,
- const Alembic::Abc::ISampleSelector &sample_sel,
- int read_flag,
- const char **err_str);
+ struct Mesh *read_mesh(struct Mesh *existing_mesh,
+ const Alembic::Abc::ISampleSelector &sample_sel,
+ int read_flag,
+ const char **err_str);
private:
void readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start,
@@ -136,10 +132,10 @@ public:
const Object *const ob,
const char **err_str) const;
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
- DerivedMesh *read_derivedmesh(DerivedMesh *dm,
- const Alembic::Abc::ISampleSelector &sample_sel,
- int read_flag,
- const char **err_str);
+ struct Mesh *read_mesh(struct Mesh *existing_mesh,
+ const Alembic::Abc::ISampleSelector &sample_sel,
+ int read_flag,
+ const char **err_str);
};
/* ************************************************************************** */
@@ -148,6 +144,6 @@ void read_mverts(MVert *mverts,
const Alembic::AbcGeom::P3fArraySamplePtr &positions,
const Alembic::AbcGeom::N3fArraySamplePtr &normals);
-CDStreamConfig get_config(DerivedMesh *dm);
+CDStreamConfig get_config(struct Mesh *mesh);
#endif /* __ABC_MESH_H__ */
diff --git a/source/blender/alembic/intern/abc_nurbs.cc b/source/blender/alembic/intern/abc_nurbs.cc
index 1f042d0bafc..95d06fc5efe 100644
--- a/source/blender/alembic/intern/abc_nurbs.cc
+++ b/source/blender/alembic/intern/abc_nurbs.cc
@@ -60,13 +60,11 @@ using Alembic::AbcGeom::ONuPatchSchema;
/* ************************************************************************** */
-AbcNurbsWriter::AbcNurbsWriter(Depsgraph *depsgraph,
- Scene *scene,
- Object *ob,
+AbcNurbsWriter::AbcNurbsWriter(Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(ob, time_sampling, settings, parent)
{
m_is_animated = isAnimated();
@@ -255,7 +253,19 @@ void AbcNurbsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSele
nu->resolv = cu->resolv;
const INuPatchSchema &schema = it->first;
- const INuPatchSchema::Sample smp = schema.getValue(sample_sel);
+ INuPatchSchema::Sample smp;
+ try {
+ smp = schema.getValue(sample_sel);
+ }
+ catch(Alembic::Util::Exception &ex) {
+ printf("Alembic: error reading nurbs sample for '%s/%s' at time %f: %s\n",
+ m_iobject.getFullName().c_str(),
+ schema.getName().c_str(),
+ sample_sel.getRequestedTime(),
+ ex.what());
+ return;
+ }
+
nu->orderu = smp.getUOrder() - 1;
nu->orderv = smp.getVOrder() - 1;
diff --git a/source/blender/alembic/intern/abc_nurbs.h b/source/blender/alembic/intern/abc_nurbs.h
index d2422345c3f..827aa4b365f 100644
--- a/source/blender/alembic/intern/abc_nurbs.h
+++ b/source/blender/alembic/intern/abc_nurbs.h
@@ -32,9 +32,7 @@ class AbcNurbsWriter : public AbcObjectWriter {
bool m_is_animated;
public:
- AbcNurbsWriter(Depsgraph *depsgraph,
- Scene *scene,
- Object *ob,
+ AbcNurbsWriter(Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings);
diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc
index 85bda9aa8eb..7e0b1ccfbd4 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -58,16 +58,12 @@ using Alembic::AbcGeom::OStringProperty;
/* ************************************************************************** */
-AbcObjectWriter::AbcObjectWriter(Depsgraph *depsgraph,
- Scene *scene,
- Object *ob,
+AbcObjectWriter::AbcObjectWriter(Object *ob,
uint32_t time_sampling,
ExportSettings &settings,
AbcObjectWriter *parent)
: m_object(ob)
, m_settings(settings)
- , m_depsgraph(depsgraph)
- , m_scene(scene)
, m_time_sampling(time_sampling)
, m_first_frame(true)
{
@@ -248,12 +244,12 @@ Imath::M44d get_matrix(const IXformSchema &schema, const float time)
return s0.getMatrix();
}
-DerivedMesh *AbcObjectReader::read_derivedmesh(DerivedMesh *dm,
- const Alembic::Abc::ISampleSelector &UNUSED(sample_sel),
- int UNUSED(read_flag),
- const char **UNUSED(err_str))
+struct Mesh *AbcObjectReader::read_mesh(struct Mesh *existing_mesh,
+ const Alembic::Abc::ISampleSelector &UNUSED(sample_sel),
+ int UNUSED(read_flag),
+ const char **UNUSED(err_str))
{
- return dm;
+ return existing_mesh;
}
void AbcObjectReader::setupObjectTransform(const float time)
diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h
index d41088bdcad..8794cb61708 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -44,8 +44,6 @@ protected:
Object *m_object;
ExportSettings &m_settings;
- Depsgraph *m_depsgraph;
- Scene *m_scene;
uint32_t m_time_sampling;
Imath::Box3d m_bounds;
@@ -57,9 +55,7 @@ protected:
std::string m_name;
public:
- AbcObjectWriter(Depsgraph *depsgraph,
- Scene *scene,
- Object *ob,
+ AbcObjectWriter(Object *ob,
uint32_t time_sampling,
ExportSettings &settings,
AbcObjectWriter *parent = NULL);
@@ -124,7 +120,7 @@ static bool has_animations(Schema &schema, ImportSettings *settings)
/* ************************************************************************** */
-struct DerivedMesh;
+struct Mesh;
using Alembic::AbcCoreAbstract::chrono_t;
@@ -180,10 +176,10 @@ public:
virtual void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) = 0;
- virtual DerivedMesh *read_derivedmesh(DerivedMesh *dm,
- const Alembic::Abc::ISampleSelector &sample_sel,
- int read_flag,
- const char **err_str);
+ virtual struct Mesh *read_mesh(struct Mesh *mesh,
+ const Alembic::Abc::ISampleSelector &sample_sel,
+ int read_flag,
+ const char **err_str);
/** Reads the object matrix and sets up an object transform if animated. */
void setupObjectTransform(const float time);
diff --git a/source/blender/alembic/intern/abc_points.cc b/source/blender/alembic/intern/abc_points.cc
index 6f52ccec4a7..9ff995ffcbf 100644
--- a/source/blender/alembic/intern/abc_points.cc
+++ b/source/blender/alembic/intern/abc_points.cc
@@ -40,6 +40,8 @@ extern "C" {
#include "BKE_scene.h"
#include "BLI_math.h"
+
+#include "DEG_depsgraph_query.h"
}
using Alembic::AbcGeom::kVertexScope;
@@ -58,14 +60,12 @@ using Alembic::AbcGeom::OPointsSchema;
/* ************************************************************************** */
-AbcPointsWriter::AbcPointsWriter(Depsgraph *depsgraph,
- Scene *scene,
- Object *ob,
+AbcPointsWriter::AbcPointsWriter(Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings,
ParticleSystem *psys)
- : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(ob, time_sampling, settings, parent)
{
m_psys = psys;
@@ -87,8 +87,8 @@ void AbcPointsWriter::do_write()
ParticleKey state;
ParticleSimulationData sim;
- sim.depsgraph = m_depsgraph;
- sim.scene = m_scene;
+ sim.depsgraph = m_settings.depsgraph;
+ sim.scene = m_settings.scene;
sim.ob = m_object;
sim.psys = m_psys;
@@ -102,7 +102,7 @@ void AbcPointsWriter::do_write()
continue;
}
- state.time = BKE_scene_frame_get(m_scene);
+ state.time = DEG_get_ctime(m_settings.depsgraph);
if (psys_get_particle_state(&sim, p, &state, 0) == 0) {
continue;
@@ -173,15 +173,9 @@ bool AbcPointsReader::accepts_object_type(const Alembic::AbcCoreAbstract::Object
void AbcPointsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel)
{
Mesh *mesh = BKE_mesh_add(bmain, m_data_name.c_str());
+ Mesh *read_mesh = this->read_mesh(mesh, sample_sel, 0, NULL);
- DerivedMesh *dm = CDDM_from_mesh(mesh);
- DerivedMesh *ndm = this->read_derivedmesh(dm, sample_sel, 0, NULL);
-
- if (ndm != dm) {
- dm->release(dm);
- }
-
- DM_to_mesh(ndm, mesh, m_object, CD_MASK_MESH, true);
+ BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, CD_MASK_MESH, true);
if (m_settings->validate_meshes) {
BKE_mesh_validate(mesh, false, false);
@@ -218,23 +212,35 @@ void read_points_sample(const IPointsSchema &schema,
read_mverts(config.mvert, positions, vnormals);
}
-DerivedMesh *AbcPointsReader::read_derivedmesh(DerivedMesh *dm,
- const ISampleSelector &sample_sel,
- int /*read_flag*/,
- const char ** /*err_str*/)
+struct Mesh *AbcPointsReader::read_mesh(struct Mesh *existing_mesh,
+ const ISampleSelector &sample_sel,
+ int /*read_flag*/,
+ const char **err_str)
{
- const IPointsSchema::Sample sample = m_schema.getValue(sample_sel);
+ IPointsSchema::Sample sample;
+ try {
+ sample = m_schema.getValue(sample_sel);
+ }
+ catch(Alembic::Util::Exception &ex) {
+ *err_str = "Error reading points sample; more detail on the console";
+ printf("Alembic: error reading points sample for '%s/%s' at time %f: %s\n",
+ m_iobject.getFullName().c_str(),
+ m_schema.getName().c_str(),
+ sample_sel.getRequestedTime(),
+ ex.what());
+ return existing_mesh;
+ }
const P3fArraySamplePtr &positions = sample.getPositions();
- DerivedMesh *new_dm = NULL;
+ Mesh *new_mesh = NULL;
- if (dm->getNumVerts(dm) != positions->size()) {
- new_dm = CDDM_new(positions->size(), 0, 0, 0, 0);
+ if (existing_mesh->totvert != positions->size()) {
+ new_mesh = BKE_mesh_new_nomain(positions->size(), 0, 0, 0, 0);
}
- CDStreamConfig config = get_config(new_dm ? new_dm : dm);
+ CDStreamConfig config = get_config(new_mesh ? new_mesh : existing_mesh);
read_points_sample(m_schema, sample_sel, config);
- return new_dm ? new_dm : dm;
+ return new_mesh ? new_mesh : existing_mesh;
}
diff --git a/source/blender/alembic/intern/abc_points.h b/source/blender/alembic/intern/abc_points.h
index 1ac8792ede1..e986f9448f4 100644
--- a/source/blender/alembic/intern/abc_points.h
+++ b/source/blender/alembic/intern/abc_points.h
@@ -38,9 +38,7 @@ class AbcPointsWriter : public AbcObjectWriter {
ParticleSystem *m_psys;
public:
- AbcPointsWriter(Depsgraph *depsgraph,
- Scene *scene,
- Object *ob,
+ AbcPointsWriter(Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings,
@@ -65,10 +63,10 @@ public:
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
- DerivedMesh *read_derivedmesh(DerivedMesh *dm,
- const Alembic::Abc::ISampleSelector &sample_sel,
- int read_flag,
- const char **err_str);
+ struct Mesh *read_mesh(struct Mesh *existing_mesh,
+ const Alembic::Abc::ISampleSelector &sample_sel,
+ int read_flag,
+ const char **err_str);
};
void read_points_sample(const Alembic::AbcGeom::IPointsSchema &schema,
diff --git a/source/blender/alembic/intern/abc_transform.cc b/source/blender/alembic/intern/abc_transform.cc
index e5da367b9a9..81ebfef3e11 100644
--- a/source/blender/alembic/intern/abc_transform.cc
+++ b/source/blender/alembic/intern/abc_transform.cc
@@ -32,6 +32,8 @@ extern "C" {
#include "BLI_math.h"
#include "BKE_object.h"
+
+#include "DEG_depsgraph_query.h"
}
using Alembic::AbcGeom::OObject;
@@ -57,13 +59,12 @@ static bool has_parent_camera(Object *ob)
/* ************************************************************************** */
-AbcTransformWriter::AbcTransformWriter(Depsgraph *depsgraph,
- Object *ob,
+AbcTransformWriter::AbcTransformWriter(Object *ob,
const OObject &abc_parent,
AbcTransformWriter *parent,
unsigned int time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(depsgraph, NULL, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(ob, time_sampling, settings, parent)
, m_proxy_from(NULL)
{
m_is_animated = hasAnimation(m_object);
@@ -81,29 +82,31 @@ AbcTransformWriter::AbcTransformWriter(Depsgraph *depsgraph,
void AbcTransformWriter::do_write()
{
+ Object *ob_eval = DEG_get_evaluated_object(m_settings.depsgraph, m_object);
+
if (m_first_frame) {
m_visibility = Alembic::AbcGeom::CreateVisibilityProperty(m_xform, m_xform.getSchema().getTimeSampling());
}
- m_visibility.set(!(m_object->restrictflag & OB_RESTRICT_VIEW));
+ m_visibility.set(!(ob_eval->restrictflag & OB_RESTRICT_VIEW));
if (!m_first_frame && !m_is_animated) {
return;
}
float yup_mat[4][4];
- create_transform_matrix(m_object, yup_mat,
+ create_transform_matrix(ob_eval, yup_mat,
m_inherits_xform ? ABC_MATRIX_LOCAL : ABC_MATRIX_WORLD,
m_proxy_from);
/* Only apply rotation to root camera, parenting will propagate it. */
- if (m_object->type == OB_CAMERA && (!m_inherits_xform || !has_parent_camera(m_object))) {
+ if (ob_eval->type == OB_CAMERA && (!m_inherits_xform || !has_parent_camera(ob_eval))) {
float rot_mat[4][4];
axis_angle_to_mat4_single(rot_mat, 'X', -M_PI_2);
mul_m4_m4m4(yup_mat, yup_mat, rot_mat);
}
- if (!m_object->parent || !m_inherits_xform) {
+ if (!ob_eval->parent || !m_inherits_xform) {
/* Only apply scaling to root objects, parenting will propagate it. */
float scale_mat[4][4];
scale_m4_fl(scale_mat, m_settings.global_scale);
diff --git a/source/blender/alembic/intern/abc_transform.h b/source/blender/alembic/intern/abc_transform.h
index 91420b28f93..12bf9d38007 100644
--- a/source/blender/alembic/intern/abc_transform.h
+++ b/source/blender/alembic/intern/abc_transform.h
@@ -43,8 +43,7 @@ public:
Object *m_proxy_from;
public:
- AbcTransformWriter(Depsgraph *depsgraph,
- Object *ob,
+ AbcTransformWriter(Object *ob,
const Alembic::AbcGeom::OObject &abc_parent,
AbcTransformWriter *parent,
unsigned int time_sampling,
diff --git a/source/blender/alembic/intern/abc_util.cc b/source/blender/alembic/intern/abc_util.cc
index 6787d118fa1..53860ab149d 100644
--- a/source/blender/alembic/intern/abc_util.cc
+++ b/source/blender/alembic/intern/abc_util.cc
@@ -181,11 +181,11 @@ void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], AbcAxisSwapMod
unit_m3(dst_rot);
unit_m4(dst_scale_mat);
- /* We assume there is no sheer component and no homogeneous scaling component. */
- BLI_assert(fabs(src_mat[0][3]) < 2 * FLT_EPSILON);
- BLI_assert(fabs(src_mat[1][3]) < 2 * FLT_EPSILON);
- BLI_assert(fabs(src_mat[2][3]) < 2 * FLT_EPSILON);
- BLI_assert(fabs(src_mat[3][3] - 1.0f) < 2 * FLT_EPSILON);
+ /* TODO(Sybren): This code assumes there is no sheer component and no
+ * homogeneous scaling component, which is not always true when writing
+ * non-hierarchical (e.g. flat) objects (e.g. when parent has non-uniform
+ * scale and the child rotates). This is currently not taken into account
+ * when axis-swapping. */
/* Extract translation, rotation, and scale form matrix. */
mat4_to_loc_rot_size(src_trans, src_rot, src_scale, src_mat);
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 1a6990a1de8..cc9923189c7 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -230,9 +230,7 @@ static void find_iobject(const IObject &object, IObject &ret,
}
struct ExportJobData {
- Scene *scene;
ViewLayer *view_layer;
- Depsgraph *depsgraph;
Main *bmain;
char filename[1024];
@@ -262,10 +260,16 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo
G.is_break = false;
+ DEG_graph_build_from_view_layer(data->settings.depsgraph,
+ data->bmain,
+ data->settings.scene,
+ data->view_layer);
+ BKE_scene_graph_update_tagged(data->settings.depsgraph, data->bmain);
+
try {
- Scene *scene = data->scene;
- AbcExporter exporter(data->bmain, scene, data->depsgraph, data->filename, data->settings);
+ AbcExporter exporter(data->bmain, data->filename, data->settings);
+ Scene *scene = data->settings.scene; /* for the CFRA macro */
const int orig_frame = CFRA;
data->was_canceled = false;
@@ -274,7 +278,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo
if (CFRA != orig_frame) {
CFRA = orig_frame;
- BKE_scene_graph_update_for_newframe(data->depsgraph, data->bmain);
+ BKE_scene_graph_update_for_newframe(data->settings.depsgraph, data->bmain);
}
data->export_ok = !data->was_canceled;
@@ -313,9 +317,7 @@ bool ABC_export(
{
ExportJobData *job = static_cast<ExportJobData *>(MEM_mallocN(sizeof(ExportJobData), "ExportJobData"));
- job->scene = scene;
job->view_layer = CTX_data_view_layer(C);
- job->depsgraph = CTX_data_depsgraph(C);
job->bmain = CTX_data_main(C);
job->export_ok = false;
BLI_strncpy(job->filename, filepath, 1024);
@@ -336,14 +338,14 @@ bool ABC_export(
* do bigger refactor and maybe there is a better way which does not involve
* hardcore refactoring. */
new (&job->settings) ExportSettings();
- job->settings.scene = job->scene;
- job->settings.depsgraph = job->depsgraph;
+ job->settings.scene = scene;
+ job->settings.depsgraph = DEG_graph_new(scene, job->view_layer, DAG_EVAL_RENDER);
/* Sybren: for now we only export the active scene layer.
* Later in the 2.8 development process this may be replaced by using
* a specific collection for Alembic I/O, which can then be toggled
* between "real" objects and cached Alembic files. */
- job->settings.view_layer = CTX_data_view_layer(C);
+ job->settings.view_layer = job->view_layer;
job->settings.frame_start = params->frame_start;
job->settings.frame_end = params->frame_end;
@@ -387,7 +389,7 @@ bool ABC_export(
if (as_background_job) {
wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
CTX_wm_window(C),
- job->scene,
+ job->settings.scene,
"Alembic Export",
WM_JOB_PROGRESS,
WM_JOB_TYPE_ALEMBIC);
@@ -960,12 +962,12 @@ void ABC_get_transform(CacheReader *reader, float r_mat[4][4], float time, float
/* ************************************************************************** */
-DerivedMesh *ABC_read_mesh(CacheReader *reader,
- Object *ob,
- DerivedMesh *dm,
- const float time,
- const char **err_str,
- int read_flag)
+Mesh *ABC_read_mesh(CacheReader *reader,
+ Object *ob,
+ Mesh *existing_mesh,
+ const float time,
+ const char **err_str,
+ int read_flag)
{
AbcObjectReader *abc_reader = reinterpret_cast<AbcObjectReader *>(reader);
IObject iobject = abc_reader->iobject();
@@ -984,7 +986,7 @@ DerivedMesh *ABC_read_mesh(CacheReader *reader,
/* kFloorIndex is used to be compatible with non-interpolating
* properties; they use the floor. */
ISampleSelector sample_sel(time, ISampleSelector::kFloorIndex);
- return abc_reader->read_derivedmesh(dm, sample_sel, read_flag, err_str);
+ return abc_reader->read_mesh(existing_mesh, sample_sel, read_flag, err_str);
}
/* ************************************************************************** */
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index 668588435b4..90c0016d0ed 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -124,7 +124,7 @@ void BLF_boundbox_ex(int fontid, const char *str, size_t len, struct rctf *box,
void BLF_boundbox(int fontid, const char *str, size_t len, struct rctf *box) ATTR_NONNULL();
/* The next both function return the width and height
- * of the string, using the current font and both value
+ * of the string, using the current font and both value
* are multiplied by the aspect of the font.
*/
float BLF_width_ex(int fontid, const char *str, size_t len, struct ResultBLF *r_info) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2);
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index fafee125264..5dd692d3855 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -172,7 +172,7 @@ static int blf_search_available(void)
for (i = 0; i < BLF_MAX_FONT; i++)
if (!global_font[i])
return i;
-
+
return -1;
}
diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c
index f493aa9af74..ff5c1151a82 100644
--- a/source/blender/blenfont/intern/blf_dir.c
+++ b/source/blender/blenfont/intern/blf_dir.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation.
*
* ***** END GPL LICENSE BLOCK *****
@@ -61,7 +61,7 @@ static ListBase global_font_dir = { NULL, NULL };
static DirBLF *blf_dir_find(const char *path)
{
DirBLF *p;
-
+
p = global_font_dir.first;
while (p) {
if (BLI_path_cmp(p->path, path) == 0)
@@ -74,11 +74,11 @@ static DirBLF *blf_dir_find(const char *path)
void BLF_dir_add(const char *path)
{
DirBLF *dir;
-
+
dir = blf_dir_find(path);
if (dir) /* already in the list ? just return. */
return;
-
+
dir = (DirBLF *)MEM_callocN(sizeof(DirBLF), "BLF_dir_add");
dir->path = BLI_strdup(path);
BLI_addhead(&global_font_dir, dir);
@@ -87,7 +87,7 @@ void BLF_dir_add(const char *path)
void BLF_dir_rem(const char *path)
{
DirBLF *dir;
-
+
dir = blf_dir_find(path);
if (dir) {
BLI_remlink(&global_font_dir, dir);
@@ -102,11 +102,11 @@ char **BLF_dir_get(int *ndir)
char **dirs;
char *path;
int i, count;
-
+
count = BLI_listbase_count(&global_font_dir);
if (!count)
return NULL;
-
+
dirs = (char **)MEM_callocN(sizeof(char *) * count, "BLF_dir_get");
p = global_font_dir.first;
i = 0;
@@ -123,7 +123,7 @@ void BLF_dir_free(char **dirs, int count)
{
char *path;
int i;
-
+
for (i = 0; i < count; i++) {
path = dirs[i];
MEM_freeN(path);
@@ -159,7 +159,7 @@ int blf_dir_split(const char *str, char *file, int *size)
{
int i, len;
char *s;
-
+
/* Window, Linux or Mac, this is always / */
s = strrchr(str, '/');
if (s) {
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index c12303dcfc0..1289dc6c5a6 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -553,7 +553,7 @@ static void blf_font_draw_buffer_ex(
width_clip -= chx + width_clip - buf_info->w;
if (height_clip + pen_y > buf_info->h)
height_clip -= pen_y + height_clip - buf_info->h;
-
+
/* drawing below the image? */
if (pen_y < 0) {
yb_start += (g->pitch < 0) ? -pen_y : pen_y;
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 9baa586eef5..5a87c726566 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -292,11 +292,11 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c)
if (font->flags & BLF_HINTING)
flags &= ~FT_LOAD_NO_HINTING;
-
+
if (is_sharp)
err = FT_Load_Glyph(font->face, (FT_UInt)index, FT_LOAD_TARGET_MONO);
else
- err = FT_Load_Glyph(font->face, (FT_UInt)index, flags);
+ err = FT_Load_Glyph(font->face, (FT_UInt)index, flags);
if (err) {
BLI_spin_unlock(font->ft_lib_mutex);
diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h
index b48bd2fbae7..624f3ae884c 100644
--- a/source/blender/blenfont/intern/blf_internal.h
+++ b/source/blender/blenfont/intern/blf_internal.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation.
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h
index c80b5422061..d7b526735d1 100644
--- a/source/blender/blenfont/intern/blf_internal_types.h
+++ b/source/blender/blenfont/intern/blf_internal_types.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation.
*
* ***** END GPL LICENSE BLOCK *****
@@ -204,7 +204,7 @@ typedef struct FontBLF {
/* angle in radians. */
float angle;
-
+
#if 0 /* BLF_BLUR_ENABLE */
/* blur: 3 or 5 large kernel */
int blur;
diff --git a/source/blender/blenfont/intern/blf_util.c b/source/blender/blenfont/intern/blf_util.c
index cdd81e33b0a..681553efbbe 100644
--- a/source/blender/blenfont/intern/blf_util.c
+++ b/source/blender/blenfont/intern/blf_util.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 74416bcd18f..79b0e5eb95f 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -38,18 +38,18 @@
* There are three main mesh data structures in Blender:
* #Mesh, #CDDerivedMesh and #BMesh.
*
- * These, and a few others, all implement DerivedMesh interfaces,
- * which contains unified drawing interfaces, a few utility interfaces,
- * and a bunch of read-only interfaces intended mostly for conversion from
+ * These, and a few others, all implement DerivedMesh interfaces,
+ * which contains unified drawing interfaces, a few utility interfaces,
+ * and a bunch of read-only interfaces intended mostly for conversion from
* one format to another.
*
* All Mesh structures in blender make use of CustomData, which is used to store
* per-element attributes and interpolate them (e.g. uvs, vcols, vgroups, etc).
- *
+ *
* Mesh is the "serialized" structure, used for storing object-mode mesh data
* and also for saving stuff to disk. It's interfaces are also what DerivedMesh
* uses to communicate with.
- *
+ *
* CDDM is a little mesh library, that uses Mesh data structures in the backend.
* It's mostly used for modifiers, and has the advantages of not taking much
* resources.
@@ -398,19 +398,19 @@ void DM_set_only_copy(DerivedMesh *dm, CustomDataMask mask);
* freed, see BKE_customdata.h for the different options
*/
void DM_add_vert_layer(
- struct DerivedMesh *dm, int type, int alloctype,
+ struct DerivedMesh *dm, int type, eCDAllocType alloctype,
void *layer);
void DM_add_edge_layer(
- struct DerivedMesh *dm, int type, int alloctype,
+ struct DerivedMesh *dm, int type, eCDAllocType alloctype,
void *layer);
void DM_add_tessface_layer(
- struct DerivedMesh *dm, int type, int alloctype,
+ struct DerivedMesh *dm, int type, eCDAllocType alloctype,
void *layer);
void DM_add_loop_layer(
- DerivedMesh *dm, int type, int alloctype,
+ DerivedMesh *dm, int type, eCDAllocType alloctype,
void *layer);
void DM_add_poly_layer(
- struct DerivedMesh *dm, int type, int alloctype,
+ struct DerivedMesh *dm, int type, eCDAllocType alloctype,
void *layer);
/* custom data access functions
@@ -531,12 +531,6 @@ DMCoNo *mesh_get_mapped_verts_nors(struct Scene *scene, struct Object *ob);
void mesh_get_mapped_verts_coords(DerivedMesh *dm, float (*r_cos)[3], const int totcos);
/* */
-DerivedMesh *mesh_get_derived_final(
- struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, CustomDataMask dataMask);
-DerivedMesh *mesh_get_derived_deform(
- struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, CustomDataMask dataMask);
DerivedMesh *mesh_create_derived_for_modifier(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h
index 0fb83162459..2f7d0eaba03 100644
--- a/source/blender/blenkernel/BKE_anim.h
+++ b/source/blender/blenkernel/BKE_anim.h
@@ -32,22 +32,25 @@
* \author nzc
* \since March 2001
*/
-struct Depsgraph;
-struct Path;
-struct Object;
-struct Scene;
-struct ListBase;
struct bAnimVizSettings;
struct bMotionPath;
struct bPoseChannel;
-struct ReportList;
+struct Depsgraph;
+struct ListBase;
struct Main;
+struct Object;
+struct ParticleSystem;
+struct Path;
+struct ReportList;
+struct Scene;
/* ---------------------------------------------------- */
/* Animation Visualization */
void animviz_settings_init(struct bAnimVizSettings *avs);
+struct bMotionPath *animviz_copy_motionpath(const struct bMotionPath *mpath_src);
+
void animviz_free_motionpath_cache(struct bMotionPath *mpath);
void animviz_free_motionpath(struct bMotionPath *mpath);
@@ -66,7 +69,6 @@ int where_on_path(struct Object *ob, float ctime, float vec[4], float dir[3], fl
/* ---------------------------------------------------- */
/* Dupli-Geometry */
-struct ListBase *object_duplilist_ex(struct Depsgraph *depsgraph, struct Scene *sce, struct Object *ob, bool update);
struct ListBase *object_duplilist(struct Depsgraph *depsgraph, struct Scene *sce, struct Object *ob);
void free_object_duplilist(struct ListBase *lb);
int count_duplilist(struct Object *ob);
@@ -81,6 +83,26 @@ typedef struct DupliApplyData {
DupliExtraData *extra;
} DupliApplyData;
+typedef struct DupliObject {
+ struct DupliObject *next, *prev;
+ struct Object *ob;
+ float mat[4][4];
+ float orco[3], uv[2];
+
+ short type; /* from Object.transflag */
+ char no_draw;
+
+ /* Persistent identifier for a dupli object, for inter-frame matching of
+ * objects with motion blur, or inter-update matching for syncing. */
+ int persistent_id[16]; /* 2*MAX_DUPLI_RECUR */
+
+ /* Particle this dupli was generated from. */
+ struct ParticleSystem *particle_system;
+
+ /* Random ID for shading */
+ unsigned int random_id;
+} DupliObject;
+
DupliApplyData *duplilist_apply(struct Depsgraph *depsgraph, struct Object *ob, struct Scene *scene, struct ListBase *duplilist);
void duplilist_restore(struct ListBase *duplilist, DupliApplyData *apply_data);
void duplilist_free_apply_data(DupliApplyData *apply_data);
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index 8b71d97c0e5..326c25e8899 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -33,6 +33,8 @@
struct AnimData;
struct AnimMapper;
+struct ChannelDriver;
+struct Depsgraph;
struct FCurve;
struct ID;
struct KS_Path;
@@ -173,24 +175,24 @@ void BKE_fcurves_main_cb(struct Main *bmain, ID_FCurve_Edit_Callback func, void
/* In general, these ones should be called to do all animation evaluation */
/* Evaluation loop for evaluating animation data */
-void BKE_animsys_evaluate_animdata(struct Scene *scene, struct ID *id, struct AnimData *adt, float ctime, short recalc);
+void BKE_animsys_evaluate_animdata(struct Depsgraph *depsgraph, struct Scene *scene, struct ID *id, struct AnimData *adt, float ctime, short recalc);
/* Evaluation of all ID-blocks with Animation Data blocks - Animation Data Only */
-void BKE_animsys_evaluate_all_animation(struct Main *main, struct Scene *scene, float ctime);
+void BKE_animsys_evaluate_all_animation(struct Main *main, struct Depsgraph *depsgraph, struct Scene *scene, float ctime);
/* TODO(sergey): This is mainly a temp public function. */
bool BKE_animsys_execute_fcurve(struct PointerRNA *ptr, struct AnimMapper *remap, struct FCurve *fcu, float curval);
/* ------------ Specialized API --------------- */
/* There are a few special tools which require these following functions. They are NOT to be used
- * for standard animation evaluation UNDER ANY CIRCUMSTANCES!
+ * for standard animation evaluation UNDER ANY CIRCUMSTANCES!
*
- * i.e. Pose Library (PoseLib) uses some of these for selectively applying poses, but
+ * i.e. Pose Library (PoseLib) uses some of these for selectively applying poses, but
* Particles/Sequencer performing funky time manipulation is not ok.
*/
/* Evaluate Action (F-Curve Bag) */
-void animsys_evaluate_action(struct PointerRNA *ptr, struct bAction *act, struct AnimMapper *remap, float ctime);
+void animsys_evaluate_action(struct Depsgraph *depsgraph, struct PointerRNA *ptr, struct bAction *act, struct AnimMapper *remap, float ctime);
/* Evaluate Action Group */
void animsys_evaluate_action_group(struct PointerRNA *ptr, struct bAction *act, struct bActionGroup *agrp, struct AnimMapper *remap, float ctime);
@@ -202,7 +204,9 @@ void animsys_evaluate_action_group(struct PointerRNA *ptr, struct bAction *act,
struct Depsgraph;
void BKE_animsys_eval_animdata(struct Depsgraph *depsgraph, struct ID *id);
-void BKE_animsys_eval_driver(struct Depsgraph *depsgraph, struct ID *id, struct FCurve *fcurve);
+void BKE_animsys_eval_driver(struct Depsgraph *depsgraph, struct ID *id, int driver_index, struct ChannelDriver *driver_orig);
+
+void BKE_animsys_update_driver_array(struct ID *id);
/* ************************************* */
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 3712e556b63..a1212322983 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -28,7 +28,7 @@
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 280
-#define BLENDER_SUBVERSION 15
+#define BLENDER_SUBVERSION 17
/* Several breakages with 270, e.g. constraint deg vs rad */
#define BLENDER_MINVERSION 270
#define BLENDER_MINSUBVERSION 6
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index f2601f2ca32..9f326d97937 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -57,12 +57,6 @@ void BKE_brush_sculpt_reset(struct Brush *brush);
/* image icon function */
struct ImBuf *get_brush_icon(struct Brush *brush);
-/* brush library operations used by different paint panels */
-int BKE_brush_texture_set_nr(struct Brush *brush, int nr);
-int BKE_brush_texture_delete(struct Brush *brush);
-int BKE_brush_clone_image_set_nr(struct Brush *brush, int nr);
-int BKE_brush_clone_image_delete(struct Brush *brush);
-
/* jitter */
void BKE_brush_jitter_pos(
const struct Scene *scene, struct Brush *brush,
diff --git a/source/blender/blenkernel/BKE_cachefile.h b/source/blender/blenkernel/BKE_cachefile.h
index e0419d0e749..43768b67f8f 100644
--- a/source/blender/blenkernel/BKE_cachefile.h
+++ b/source/blender/blenkernel/BKE_cachefile.h
@@ -35,6 +35,7 @@ extern "C" {
#endif
struct CacheFile;
+struct Depsgraph;
struct Main;
struct Scene;
@@ -57,7 +58,7 @@ void BKE_cachefile_reload(const struct Main *bmain, struct CacheFile *cache_file
void BKE_cachefile_ensure_handle(const struct Main *bmain, struct CacheFile *cache_file);
-void BKE_cachefile_update_frame(struct Main *bmain, struct Scene *scene, const float ctime, const float fps);
+void BKE_cachefile_update_frame(struct Main *bmain, struct Depsgraph *depsgraph, struct Scene *scene, const float ctime, const float fps);
bool BKE_cachefile_filepath_get(
const struct Main *bmain, const struct CacheFile *cache_file, float frame,
diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h
index 8277fa0439d..74a90cd20f7 100644
--- a/source/blender/blenkernel/BKE_cdderivedmesh.h
+++ b/source/blender/blenkernel/BKE_cdderivedmesh.h
@@ -55,7 +55,7 @@ struct DerivedMesh *CDDM_new(int numVerts, int numEdges, int numFaces,
struct DerivedMesh *CDDM_from_mesh(struct Mesh *mesh);
/* creates a CDDerivedMesh from the given Mesh with custom allocation type. */
-struct DerivedMesh *CDDM_from_mesh_ex(struct Mesh *mesh, int alloctype, CustomDataMask mask);
+struct DerivedMesh *CDDM_from_mesh_ex(struct Mesh *mesh, eCDAllocType alloctype, CustomDataMask mask);
struct DerivedMesh *CDDM_from_bmesh(struct BMesh *bm, const bool use_mdisps);
diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h
index edc24d9649e..fc5b19ccb4f 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -91,7 +91,6 @@ bool BKE_collection_is_in_scene(struct Collection *collection);
void BKE_collections_after_lib_link(struct Main *bmain);
bool BKE_collection_object_cyclic_check(struct Main *bmain, struct Object *object, struct Collection *collection);
bool BKE_collection_is_animated(struct Collection *collection, struct Object *parent);
-void BKE_collection_handle_recalc_and_update(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *parent, struct Collection *collection);
/* Object list cache. */
diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h
index f68c4a2757b..5332b3acd72 100644
--- a/source/blender/blenkernel/BKE_colortools.h
+++ b/source/blender/blenkernel/BKE_colortools.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 51cd4da183a..85c894864d5 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -67,12 +67,14 @@ extern const CustomDataMask CD_MASK_EVERYTHING;
* CD_NUMTYPES elements, that indicate if a layer can be copied. */
/* add/copy/merge allocation types */
-#define CD_ASSIGN 0 /* use the data pointer */
-#define CD_CALLOC 1 /* allocate blank memory */
-#define CD_DEFAULT 2 /* allocate and set to default */
-#define CD_REFERENCE 3 /* use data pointers, set layer flag NOFREE */
-#define CD_DUPLICATE 4 /* do a full copy of all layers, only allowed if source
- * has same number of elements */
+typedef enum eCDAllocType {
+ CD_ASSIGN = 0, /* use the data pointer */
+ CD_CALLOC = 1, /* allocate blank memory */
+ CD_DEFAULT = 2, /* allocate and set to default */
+ CD_REFERENCE = 3, /* use data pointers, set layer flag NOFREE */
+ CD_DUPLICATE = 4, /* do a full copy of all layers, only allowed if source
+ * has same number of elements */
+} eCDAllocType;
#define CD_TYPE_AS_MASK(_type) (CustomDataMask)((CustomDataMask)1 << (CustomDataMask)(_type))
@@ -120,16 +122,18 @@ void CustomData_data_add(int type, void *data1, const void *data2);
/* initializes a CustomData object with the same layer setup as source.
* mask is a bitfield where (mask & (1 << (layer type))) indicates
* if a layer should be copied or not. alloctype must be one of the above. */
-void CustomData_copy(const struct CustomData *source, struct CustomData *dest,
- CustomDataMask mask, int alloctype, int totelem);
+void CustomData_copy(
+ const struct CustomData *source, struct CustomData *dest,
+ CustomDataMask mask, eCDAllocType alloctype, int totelem);
/* BMESH_TODO, not really a public function but readfile.c needs it */
void CustomData_update_typemap(struct CustomData *data);
/* same as the above, except that this will preserve existing layers, and only
* add the layers that were not there yet */
-bool CustomData_merge(const struct CustomData *source, struct CustomData *dest,
- CustomDataMask mask, int alloctype, int totelem);
+bool CustomData_merge(
+ const struct CustomData *source, struct CustomData *dest,
+ CustomDataMask mask, eCDAllocType alloctype, int totelem);
/* Reallocate custom data to a new element count.
* Only affects on data layers which are owned by the CustomData itself,
@@ -144,7 +148,7 @@ void CustomData_realloc(struct CustomData *data, int totelem);
* consistent with the new layout.*/
bool CustomData_bmesh_merge(
const struct CustomData *source, struct CustomData *dest,
- CustomDataMask mask, int alloctype, struct BMesh *bm, const char htype);
+ CustomDataMask mask, eCDAllocType alloctype, struct BMesh *bm, const char htype);
/** NULL's all members and resets the typemap. */
void CustomData_reset(struct CustomData *data);
@@ -164,11 +168,13 @@ void CustomData_free_temporary(struct CustomData *data, int totelem);
* backed by an external data array. the different allocation types are
* defined above. returns the data of the layer.
*/
-void *CustomData_add_layer(struct CustomData *data, int type, int alloctype,
- void *layer, int totelem);
+void *CustomData_add_layer(
+ struct CustomData *data, int type, eCDAllocType alloctype,
+ void *layer, int totelem);
/*same as above but accepts a name */
-void *CustomData_add_layer_named(struct CustomData *data, int type, int alloctype,
- void *layer, int totelem, const char *name);
+void *CustomData_add_layer_named(
+ struct CustomData *data, int type, eCDAllocType alloctype,
+ void *layer, int totelem, const char *name);
/* frees the active or first data layer with the give type.
* returns 1 on success, 0 if no layer with the given type is found
diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h
index 09e9b667369..6dd40b7a651 100644
--- a/source/blender/blenkernel/BKE_displist.h
+++ b/source/blender/blenkernel/BKE_displist.h
@@ -57,11 +57,12 @@ enum {
/* prototypes */
-struct Scene;
-struct Object;
-struct ListBase;
struct Depsgraph;
struct DerivedMesh;
+struct ListBase;
+struct Main;
+struct Object;
+struct Scene;
/* used for curves, nurbs, mball, importing */
typedef struct DispList {
diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h
index a0814fc9183..0a759629930 100644
--- a/source/blender/blenkernel/BKE_dynamicpaint.h
+++ b/source/blender/blenkernel/BKE_dynamicpaint.h
@@ -28,6 +28,7 @@
*/
struct Depsgraph;
+struct Main;
struct Scene;
struct ViewLayer;
@@ -86,7 +87,9 @@ struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings
/* image sequence baking */
int dynamicPaint_createUVSurface(struct Scene *scene, struct DynamicPaintSurface *surface, float *progress, short *do_update);
-int dynamicPaint_calculateFrame(struct DynamicPaintSurface *surface, struct Depsgraph *depsgraph, struct Scene *scene, struct Object *cObject, int frame);
+int dynamicPaint_calculateFrame(
+ struct DynamicPaintSurface *surface, struct Depsgraph *depsgraph,
+ struct Scene *scene, struct Object *cObject, int frame);
void dynamicPaint_outputSurfaceImage(struct DynamicPaintSurface *surface, char *filename, short output_layer);
/* PaintPoint state */
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index e184fd3796b..c5ad91c81fd 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -54,7 +54,7 @@ typedef struct Global {
/* strings: lastsaved */
char ima[1024], lib[1024]; /* 1024 = FILE_MAX */
- /* when set: G.main->name contains valid relative base path */
+ /* when set: G_MAIN->name contains valid relative base path */
bool relbase_valid;
bool file_loaded;
bool save_over;
@@ -210,6 +210,11 @@ enum {
/* Memory is allocated where? blender.c */
extern Global G;
+/**
+ * Stupid macro to hide the few *valid* usages of G.main (from startup/exit code e.g.), helps with cleanup task.
+ */
+#define G_MAIN (G).main
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 1af123759e6..fc018dbfe81 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -190,25 +190,25 @@ void BKE_image_alpha_mode_from_extension(struct Image *image);
/* returns a new image or NULL if it can't load */
struct Image *BKE_image_load(struct Main *bmain, const char *filepath);
/* returns existing Image when filename/type is same (frame optional) */
-struct Image *BKE_image_load_exists_ex(const char *filepath, bool *r_exists);
-struct Image *BKE_image_load_exists(const char *filepath);
+struct Image *BKE_image_load_exists_ex(struct Main *bmain, const char *filepath, bool *r_exists);
+struct Image *BKE_image_load_exists(struct Main *bmain, const char *filepath);
/* adds image, adds ibuf, generates color or pattern */
struct Image *BKE_image_add_generated(
struct Main *bmain, unsigned int width, unsigned int height, const char *name,
int depth, int floatbuf, short gen_type, const float color[4], const bool stereo3d);
/* adds image from imbuf, owns imbuf */
-struct Image *BKE_image_add_from_imbuf(struct ImBuf *ibuf, const char *name);
+struct Image *BKE_image_add_from_imbuf(struct Main *bmain, struct ImBuf *ibuf, const char *name);
/* for reload, refresh, pack */
void BKE_image_init_imageuser(struct Image *ima, struct ImageUser *iuser);
-void BKE_image_signal(struct Image *ima, struct ImageUser *iuser, int signal);
+void BKE_image_signal(struct Main *bmain, struct Image *ima, struct ImageUser *iuser, int signal);
void BKE_image_walk_all_users(const struct Main *mainp, void *customdata,
void callback(struct Image *ima, struct ImageUser *iuser, void *customdata));
/* ensures an Image exists for viewing nodes or render */
-struct Image *BKE_image_verify_viewer(int type, const char *name);
+struct Image *BKE_image_verify_viewer(struct Main *bmain, int type, const char *name);
/* ensures the view node cache is compatible with the scene views */
void BKE_image_verify_viewer_views(const struct RenderData *rd, struct Image *ima, struct ImageUser *iuser);
@@ -242,27 +242,27 @@ void BKE_image_backup_render(struct Scene *scene, struct Image *ima, bool free_c
bool BKE_image_save_openexr_multiview(struct Image *ima, struct ImBuf *ibuf, const char *filepath, const int flags);
/* goes over all textures that use images */
-void BKE_image_free_all_textures(void);
+void BKE_image_free_all_textures(struct Main *bmain);
/* does one image! */
void BKE_image_free_anim_ibufs(struct Image *ima, int except_frame);
/* does all images with type MOVIE or SEQUENCE */
-void BKE_image_all_free_anim_ibufs(int except_frame);
+void BKE_image_all_free_anim_ibufs(struct Main *bmain, int except_frame);
void BKE_image_memorypack(struct Image *ima);
void BKE_image_packfiles(struct ReportList *reports, struct Image *ima, const char *basepath);
void BKE_image_packfiles_from_mem(struct ReportList *reports, struct Image *ima, char *data, const size_t data_len);
/* prints memory statistics for images */
-void BKE_image_print_memlist(void);
+void BKE_image_print_memlist(struct Main *bmain);
/* empty image block, of similar type and filename */
void BKE_image_copy_data(struct Main *bmain, struct Image *ima_dst, const struct Image *ima_src, const int flag);
struct Image *BKE_image_copy(struct Main *bmain, const struct Image *ima);
/* merge source into dest, and free source */
-void BKE_image_merge(struct Image *dest, struct Image *source);
+void BKE_image_merge(struct Main *bmain, struct Image *dest, struct Image *source);
/* scale the image */
bool BKE_image_scale(struct Image *image, int width, int height);
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 57b509da3a4..28bc254f25a 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -84,6 +84,7 @@ enum {
LIB_ID_COPY_KEEP_LIB = 1 << 20, /* Keep the library pointer when copying datablock outside of bmain. */
LIB_ID_COPY_NO_ANIMDATA = 1 << 21, /* Don't copy id->adt, used by ID datablock localization routines. */
LIB_ID_COPY_SHAPEKEY = 1 << 22, /* EXCEPTION! Deep-copy shapekeys used by copied obdata ID. */
+ LIB_ID_COPY_CD_REFERENCE = 1 << 23,
};
void BKE_libblock_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, const int flag);
@@ -94,8 +95,7 @@ void *BKE_libblock_copy_nolib(const struct ID *id, const bool do_action) ATTR_NO
void BKE_libblock_rename(struct Main *bmain, struct ID *id, const char *name) ATTR_NONNULL();
void BLI_libblock_ensure_unique_name(struct Main *bmain, const char *name) ATTR_NONNULL();
-struct ID *BKE_libblock_find_name_ex(struct Main *bmain, const short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
-struct ID *BKE_libblock_find_name(const short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+struct ID *BKE_libblock_find_name(struct Main *bmain, const short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
/* library_remap.c (keep here since they're general functions) */
/**
@@ -139,7 +139,7 @@ void BKE_libblock_free_data(struct ID *id, const bool do_id_user) ATTR_NONNULL(
void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id);
void id_lib_extern(struct ID *id);
-void BKE_library_filepath_set(struct Library *lib, const char *filepath);
+void BKE_library_filepath_set(struct Main *bmain, struct Library *lib, const char *filepath);
void id_us_ensure_real(struct ID *id);
void id_us_clear_real(struct ID *id);
void id_us_plus_no_lib(struct ID *id);
@@ -182,6 +182,9 @@ struct BlendThumbnail *BKE_main_thumbnail_from_imbuf(struct Main *bmain, struct
struct ImBuf *BKE_main_thumbnail_to_imbuf(struct Main *bmain, struct BlendThumbnail *data);
void BKE_main_thumbnail_create(struct Main *bmain);
+const char *BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL();
+const char *BKE_main_blendfile_path_from_global(void);
+
void BKE_main_id_tag_idcode(struct Main *mainvar, const short type, const int tag, const bool value);
void BKE_main_id_tag_listbase(struct ListBase *lb, const int tag, const bool value);
void BKE_main_id_tag_all(struct Main *mainvar, const int tag, const bool value);
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index efcff9a9382..0913cf208eb 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -128,8 +128,6 @@ typedef struct Main {
ListBase cachefiles;
ListBase workspaces;
- char id_tag_update[MAX_LIBARRAY];
-
/* Must be generated, used and freed by same code - never assume this is valid data unless you know
* when, who and how it was created.
* Used by code doing a lot of remapping etc. at once to speed things up. */
diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h
index 43f36618c19..c85017a2216 100644
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@ -47,7 +47,7 @@ struct Scene;
void init_def_material(void);
void BKE_material_free(struct Material *ma);
void BKE_material_free_ex(struct Material *ma, bool do_id_user);
-void test_object_materials(struct Object *ob, struct ID *id);
+void test_object_materials(struct Main *bmain, struct Object *ob, struct ID *id);
void test_all_objects_materials(struct Main *bmain, struct ID *id);
void BKE_material_resize_object(struct Main *bmain, struct Object *ob, const short totcol, bool do_id_user);
void BKE_material_init(struct Material *ma);
@@ -79,13 +79,13 @@ enum {
};
struct Material *give_current_material(struct Object *ob, short act);
-void assign_material_id(struct ID *id, struct Material *ma, short act);
-void assign_material(struct Object *ob, struct Material *ma, short act, int assign_type);
-void assign_matarar(struct Object *ob, struct Material ***matar, short totcol);
+void assign_material_id(struct Main *bmain, struct ID *id, struct Material *ma, short act);
+void assign_material(struct Main *bmain, struct Object *ob, struct Material *ma, short act, int assign_type);
+void assign_matarar(struct Main *bmain, struct Object *ob, struct Material ***matar, short totcol);
short BKE_object_material_slot_find_index(struct Object *ob, struct Material *ma);
-bool BKE_object_material_slot_add(struct Object *ob);
-bool BKE_object_material_slot_remove(struct Object *ob);
+bool BKE_object_material_slot_add(struct Main *bmain, struct Object *ob);
+bool BKE_object_material_slot_remove(struct Main *bmain, struct Object *ob);
void BKE_texpaint_slot_refresh_cache(struct Scene *scene, struct Material *ma);
void BKE_texpaint_slots_refresh_object(struct Scene *scene, struct Object *ob);
@@ -102,8 +102,8 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3]);
/* copy/paste */
void clear_matcopybuf(void);
void free_matcopybuf(void);
-void copy_matcopybuf(struct Material *ma);
-void paste_matcopybuf(struct Material *ma);
+void copy_matcopybuf(struct Main *bmain, struct Material *ma);
+void paste_matcopybuf(struct Main *bmain, struct Material *ma);
/* Evaluation. */
diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h
index 41f04c09e69..74ef9d9dbc0 100644
--- a/source/blender/blenkernel/BKE_mball.h
+++ b/source/blender/blenkernel/BKE_mball.h
@@ -76,8 +76,6 @@ void BKE_mball_select_swap(struct MetaBall *mb);
struct Depsgraph;
-void BKE_mball_eval_geometry(struct Depsgraph *depsgraph,
- struct MetaBall *mball);
/* Draw Cache */
enum {
diff --git a/source/blender/blenkernel/BKE_mball_tessellate.h b/source/blender/blenkernel/BKE_mball_tessellate.h
index df652df177d..363bfe09c75 100644
--- a/source/blender/blenkernel/BKE_mball_tessellate.h
+++ b/source/blender/blenkernel/BKE_mball_tessellate.h
@@ -24,6 +24,7 @@
* \ingroup bke
*/
struct Depsgraph;
+struct Main;
struct Object;
struct Scene;
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 6e0514fd009..3d70ef75a7c 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -34,6 +34,9 @@
/* defines BLI_INLINE */
#include "BLI_utildefines.h"
+/* defines CustomDataMask */
+#include "BKE_customdata.h"
+
struct ID;
struct BMeshCreateParams;
struct BMeshFromMeshParams;
@@ -46,9 +49,11 @@ struct LinkNode;
struct BLI_Stack;
struct MemArena;
struct BMesh;
+struct KeyBlock;
struct MLoopTri;
struct Main;
struct Mesh;
+struct ModifierData;
struct MPoly;
struct MLoop;
struct MFace;
@@ -127,7 +132,7 @@ float (*BKE_mesh_orco_verts_get(struct Object *ob))[3];
void BKE_mesh_orco_verts_transform(struct Mesh *me, float (*orco)[3], int totvert, int invert);
int test_index_face(struct MFace *mface, struct CustomData *mfdata, int mfindex, int nr);
struct Mesh *BKE_mesh_from_object(struct Object *ob);
-void BKE_mesh_assign_object(struct Object *ob, struct Mesh *me);
+void BKE_mesh_assign_object(struct Main *bmain, struct Object *ob, struct Mesh *me);
void BKE_mesh_from_metaball(struct ListBase *lb, struct Mesh *me);
int BKE_mesh_nurbs_to_mdata(
struct Object *ob, struct MVert **r_allvert, int *r_totvert,
@@ -140,10 +145,10 @@ int BKE_mesh_nurbs_displist_to_mdata(
struct MLoop **r_allloop, struct MPoly **r_allpoly,
struct MLoopUV **r_alluv, int *r_totloop, int *r_totpoly);
void BKE_mesh_from_nurbs_displist(
- struct Object *ob, struct ListBase *dispbase, const bool use_orco_uv, const char *obdata_name);
-void BKE_mesh_from_nurbs(struct Object *ob);
-void BKE_mesh_to_curve_nurblist(struct DerivedMesh *dm, struct ListBase *nurblist, const int edge_users_test);
-void BKE_mesh_to_curve(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
+ struct Main *bmain, struct Object *ob, struct ListBase *dispbase, const bool use_orco_uv, const char *obdata_name, bool temporary);
+void BKE_mesh_from_nurbs(struct Main *bmain, struct Object *ob);
+void BKE_mesh_to_curve_nurblist(const struct Mesh *me, struct ListBase *nurblist, const int edge_users_test);
+void BKE_mesh_to_curve(struct Main *bmain, struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
void BKE_mesh_material_index_remove(struct Mesh *me, short index);
void BKE_mesh_material_index_clear(struct Mesh *me);
void BKE_mesh_material_remap(struct Mesh *me, const unsigned int *remap, unsigned int remap_len);
@@ -168,6 +173,15 @@ void BKE_mesh_split_faces(struct Mesh *mesh, bool free_loop_normals);
struct Mesh *BKE_mesh_new_from_object(
struct Depsgraph *depsgraph, struct Main *bmain, struct Scene *sce, struct Object *ob,
const bool apply_modifiers, const bool calc_tessface, const bool calc_undeformed);
+struct Mesh *BKE_mesh_create_derived_for_modifier(
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
+ struct ModifierData *md, int build_shapekey_layers);
+
+/* Copies a nomain-Mesh into an existing Mesh. */
+void BKE_mesh_nomain_to_mesh(struct Mesh *mesh_src, struct Mesh *mesh_dst, struct Object *ob,
+ CustomDataMask mask, bool take_ownership);
+void BKE_mesh_nomain_to_meshkey(struct Mesh *mesh_src, struct Mesh *mesh_dst, struct KeyBlock *kb);
+
/* vertex level transformations & checks (no derived mesh) */
@@ -192,23 +206,10 @@ void BKE_mesh_mselect_active_set(struct Mesh *me, int index, int type);
void BKE_mesh_apply_vert_coords(struct Mesh *mesh, float (*vertCoords)[3]);
-/* *** mesh_runtime.c *** */
-void BKE_mesh_runtime_reset(struct Mesh *mesh);
-int BKE_mesh_runtime_looptri_len(const struct Mesh *mesh);
-void BKE_mesh_runtime_looptri_recalc(struct Mesh *mesh);
-const struct MLoopTri *BKE_mesh_runtime_looptri_ensure(struct Mesh *mesh);
-bool BKE_mesh_runtime_ensure_edit_data(struct Mesh *mesh);
-bool BKE_mesh_runtime_clear_edit_data(struct Mesh *mesh);
-void BKE_mesh_runtime_clear_geometry(struct Mesh *mesh);
-void BKE_mesh_runtime_clear_cache(struct Mesh *mesh);
-
-void BKE_mesh_runtime_verttri_from_looptri(
- struct MVertTri *r_verttri,
- const struct MLoop *mloop, const struct MLoopTri *looptri, int looptri_num);
-
/* *** mesh_evaluate.c *** */
+void BKE_mesh_calc_normals_mapping_simple(struct Mesh *me);
void BKE_mesh_calc_normals_mapping(
struct MVert *mverts, int numVerts,
const struct MLoop *mloop, const struct MPoly *mpolys, int numLoops, int numPolys, float (*r_polyNors)[3],
diff --git a/source/blender/blenkernel/BKE_mesh_runtime.h b/source/blender/blenkernel/BKE_mesh_runtime.h
new file mode 100644
index 00000000000..6904ad529de
--- /dev/null
+++ b/source/blender/blenkernel/BKE_mesh_runtime.h
@@ -0,0 +1,85 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef __BKE_MESH_RUNTIME_H__
+#define __BKE_MESH_RUNTIME_H__
+
+/** \file BKE_mesh_runtime.h
+ * \ingroup bke
+ *
+ * This file contains access functions for the Mesh.runtime struct.
+ */
+
+#include "BKE_customdata.h" /* for CustomDataMask */
+
+struct Depsgraph;
+struct Mesh;
+struct MLoop;
+struct MLoopTri;
+struct MVertTri;
+struct Object;
+struct Scene;
+
+/* Undefine to hide DerivedMesh-based function declarations */
+#define USE_DERIVEDMESH
+
+#ifdef USE_DERIVEDMESH
+struct DerivedMesh;
+#endif
+
+void BKE_mesh_runtime_reset(struct Mesh *mesh);
+int BKE_mesh_runtime_looptri_len(const struct Mesh *mesh);
+void BKE_mesh_runtime_looptri_recalc(struct Mesh *mesh);
+const struct MLoopTri *BKE_mesh_runtime_looptri_ensure(struct Mesh *mesh);
+bool BKE_mesh_runtime_ensure_edit_data(struct Mesh *mesh);
+bool BKE_mesh_runtime_clear_edit_data(struct Mesh *mesh);
+void BKE_mesh_runtime_clear_geometry(struct Mesh *mesh);
+void BKE_mesh_runtime_clear_cache(struct Mesh *mesh);
+
+void BKE_mesh_runtime_verttri_from_looptri(
+ struct MVertTri *r_verttri,
+ const struct MLoop *mloop, const struct MLoopTri *looptri, int looptri_num);
+
+/* NOTE: the functions below are defined in DerivedMesh.c, and are intended to be moved
+ * to a more suitable location when that file is removed. */
+#ifdef USE_DERIVEDMESH
+struct DerivedMesh *mesh_get_derived_final(
+ struct Depsgraph *depsgraph, struct Scene *scene,
+ struct Object *ob, CustomDataMask dataMask);
+#endif
+struct Mesh *mesh_get_eval_final(
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, CustomDataMask dataMask);
+
+#ifdef USE_DERIVEDMESH
+struct DerivedMesh *mesh_get_derived_deform(
+ struct Depsgraph *depsgraph, struct Scene *scene,
+ struct Object *ob, CustomDataMask dataMask);
+#endif
+struct Mesh *mesh_get_eval_deform(
+ struct Depsgraph *depsgraph, struct Scene *scene,
+ struct Object *ob, CustomDataMask dataMask);
+
+#endif /* __BKE_MESH_RUNTIME_H__ */
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index c8d50793e76..b40d32203f6 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -467,8 +467,8 @@ void test_object_modifiers(struct Object *ob);
void modifier_mdef_compact_influences(struct ModifierData *md);
void modifier_path_init(char *path, int path_maxlen, const char *name);
-const char *modifier_path_relbase(struct Object *ob);
-
+const char *modifier_path_relbase(struct Main *bmain, struct Object *ob);
+const char *modifier_path_relbase_from_global(struct Object *ob);
/* wrappers for modifier callbacks that ensure valid normals */
@@ -557,9 +557,8 @@ struct DerivedMesh *modifier_applyModifierEM_DM_deprecated(
struct ModifierData *md, const struct ModifierEvalContext *ctx,
struct BMEditMesh *editData, struct DerivedMesh *dm);
-struct Mesh *BKE_modifier_get_evaluated_mesh_from_object(
- const struct ModifierEvalContext *ctx,
- struct Object *ob);
+struct Mesh *BKE_modifier_get_evaluated_mesh_from_evaluated_object(
+ struct Object *ob_eval, bool *r_free_mesh);
#endif
diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h
index 5b5ebbf035c..014ea2b9159 100644
--- a/source/blender/blenkernel/BKE_movieclip.h
+++ b/source/blender/blenkernel/BKE_movieclip.h
@@ -49,7 +49,7 @@ void BKE_movieclip_make_local(struct Main *bmain, struct MovieClip *clip, const
struct MovieClip *BKE_movieclip_file_add(struct Main *bmain, const char *name);
struct MovieClip *BKE_movieclip_file_add_exists_ex(struct Main *bmain, const char *name, bool *r_exists);
struct MovieClip *BKE_movieclip_file_add_exists(struct Main *bmain, const char *name);
-void BKE_movieclip_reload(struct MovieClip *clip);
+void BKE_movieclip_reload(struct Main *bmain, struct MovieClip *clip);
void BKE_movieclip_clear_cache(struct MovieClip *clip);
void BKE_movieclip_clear_proxy_cache(struct MovieClip *clip);
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h
index 10bc367e909..851f2360f51 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -23,7 +23,7 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- */
+ */
#ifndef __BKE_MULTIRES_H__
#define __BKE_MULTIRES_H__
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index c654dd51e2a..d271252ceef 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -87,7 +87,7 @@ struct bNodeInstanceHash;
/** Compact definition of a node socket.
* Can be used to quickly define a list of static sockets for a node,
- * which are added to each new node of that type.
+ * which are added to each new node of that type.
*
* \deprecated This struct is used by C nodes to define templates as simple
* static struct lists. These are converted to the new template collections
@@ -293,7 +293,7 @@ typedef struct bNodeTreeType {
/* calls allowing threaded composite */
void (*localize)(struct bNodeTree *localtree, struct bNodeTree *ntree);
void (*local_sync)(struct bNodeTree *localtree, struct bNodeTree *ntree);
- void (*local_merge)(struct bNodeTree *localtree, struct bNodeTree *ntree);
+ void (*local_merge)(struct Main *bmain, struct bNodeTree *localtree, struct bNodeTree *ntree);
/* Tree update. Overrides nodetype->updatetreefunc! */
void (*update)(struct bNodeTree *ntree);
@@ -345,7 +345,7 @@ void ntreeUserIncrefID(struct bNodeTree *ntree);
void ntreeUserDecrefID(struct bNodeTree *ntree);
-struct bNodeTree *ntreeFromID(struct ID *id);
+struct bNodeTree *ntreeFromID(const struct ID *id);
void ntreeMakeLocal(struct Main *bmain, struct bNodeTree *ntree, bool id_in_mainlist, const bool lib_local);
struct bNode *ntreeFindType(const struct bNodeTree *ntree, int type);
@@ -371,7 +371,7 @@ int ntreeOutputExists(struct bNode *node, struct bNodeSocket *testso
void ntreeNodeFlagSet(const bNodeTree *ntree, const int flag, const bool enable);
struct bNodeTree *ntreeLocalize(struct bNodeTree *ntree);
void ntreeLocalSync(struct bNodeTree *localtree, struct bNodeTree *ntree);
-void ntreeLocalMerge(struct bNodeTree *localtree, struct bNodeTree *ntree);
+void ntreeLocalMerge(struct Main *bmain, struct bNodeTree *localtree, struct bNodeTree *ntree);
/** \} */
@@ -1056,9 +1056,6 @@ void free_nodesystem(void);
struct Depsgraph;
-void BKE_nodetree_copy_default_values(struct bNodeTree *ntree_dst,
- const struct bNodeTree *ntree_src);
-
void BKE_nodetree_shading_params_eval(struct Depsgraph *depsgraph,
struct bNodeTree *ntree_dst,
const struct bNodeTree *ntree_src);
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index db6c7aa9c4f..482d39b5e68 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -66,6 +66,7 @@ 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);
@@ -78,12 +79,14 @@ void BKE_object_free_modifiers(struct Object *ob, const int flag);
void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob);
void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target);
-bool BKE_object_exists_check(const struct Object *obtest);
+bool BKE_object_exists_check(struct Main *bmain, const struct Object *obtest);
bool BKE_object_is_in_editmode(const struct Object *ob);
bool BKE_object_is_in_editmode_vgroup(const struct Object *ob);
-bool BKE_object_is_in_editmode_and_selected(const struct Object *ob);
bool BKE_object_is_in_wpaint_select_vert(const struct Object *ob);
bool BKE_object_has_mode_data(const struct Object *ob, eObjectMode object_mode);
+bool BKE_object_is_mode_compat(const struct Object *ob, eObjectMode object_mode);
+
+bool BKE_object_data_is_in_editmode(const struct ID *id);
typedef enum eObjectVisibilityCheck {
OB_VISIBILITY_CHECK_FOR_VIEWPORT,
@@ -142,7 +145,7 @@ struct Base **BKE_object_pose_base_array_get_unique(struct ViewLayer *view_layer
struct Base **BKE_object_pose_base_array_get(struct ViewLayer *view_layer, unsigned int *r_bases_len);
void BKE_object_get_parent_matrix(
- struct Scene *scene, struct Object *ob,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
struct Object *par, float parentmat[4][4]);
void BKE_object_where_is_calc(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
@@ -154,7 +157,8 @@ void BKE_object_where_is_calc_time(
void BKE_object_where_is_calc_time_ex(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime,
struct RigidBodyWorld *rbw, float r_originmat[3][3]);
-void BKE_object_where_is_calc_mat4(struct Scene *scene, struct Object *ob, float obmat[4][4]);
+void BKE_object_where_is_calc_mat4(
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float obmat[4][4]);
/* possibly belong in own moduke? */
struct BoundBox *BKE_boundbox_alloc_unit(void);
@@ -254,12 +258,10 @@ void BKE_object_eval_flush_base_flags(
struct Object *object, int base_index,
const bool is_from_set);
-void BKE_object_handle_data_update(
- struct Depsgraph *depsgraph,
+void BKE_object_handle_data_update(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob);
-void BKE_object_handle_update(
- struct Depsgraph *depsgraph,
+void BKE_object_handle_update(struct Depsgraph *depsgraph,
struct Scene *scene, struct Object *ob);
void BKE_object_handle_update_ex(
struct Depsgraph *depsgraph,
@@ -271,6 +273,9 @@ void BKE_object_sculpt_modifiers_changed(struct Object *ob);
int BKE_object_obdata_texspace_get(struct Object *ob, short **r_texflag, float **r_loc, float **r_size, float **r_rot);
struct Mesh *BKE_object_get_evaluated_mesh(const struct Depsgraph *depsgraph, struct Object *ob);
+struct Mesh *BKE_object_get_final_mesh(struct Object *object);
+struct Mesh *BKE_object_get_pre_modified_mesh(struct Object *object);
+struct Mesh *BKE_object_get_original_mesh(struct Object *object);
int BKE_object_insert_ptcache(struct Object *ob);
void BKE_object_delete_ptcache(struct Object *ob, int index);
@@ -292,6 +297,8 @@ void BKE_object_data_relink(struct Object *ob);
struct MovieClip *BKE_object_movieclip_get(struct Scene *scene, struct Object *ob, bool use_default);
+void BKE_object_runtime_reset(struct Object *object);
+
/* this function returns a superset of the scenes selection based on relationships */
typedef enum eObRelationTypes {
diff --git a/source/blender/blenkernel/BKE_packedFile.h b/source/blender/blenkernel/BKE_packedFile.h
index a2397922061..ed6d66906d1 100644
--- a/source/blender/blenkernel/BKE_packedFile.h
+++ b/source/blender/blenkernel/BKE_packedFile.h
@@ -52,21 +52,25 @@ void packAll(struct Main *bmain, struct ReportList *reports, bool verbose);
void packLibraries(struct Main *bmain, struct ReportList *reports);
/* unpack */
-char *unpackFile(struct ReportList *reports, const char *abs_name, const char *local_name, struct PackedFile *pf, int how);
-int unpackVFont(struct ReportList *reports, struct VFont *vfont, int how);
+char *unpackFile(
+ struct ReportList *reports, const char *ref_file_name,
+ const char *abs_name, const char *local_name, struct PackedFile *pf, int how);
+int unpackVFont(struct Main *bmain, struct ReportList *reports, struct VFont *vfont, int how);
int unpackSound(struct Main *bmain, struct ReportList *reports, struct bSound *sound, int how);
-int unpackImage(struct ReportList *reports, struct Image *ima, int how);
+int unpackImage(struct Main *bmain, struct ReportList *reports, struct Image *ima, int how);
void unpackAll(struct Main *bmain, struct ReportList *reports, int how);
int unpackLibraries(struct Main *bmain, struct ReportList *reports);
-int writePackedFile(struct ReportList *reports, const char *filename, struct PackedFile *pf, int guimode);
+int writePackedFile(
+ struct ReportList *reports, const char *ref_file_name,
+ const char *filename, struct PackedFile *pf, const bool guimode);
/* free */
void freePackedFile(struct PackedFile *pf);
/* info */
int countPackedFiles(struct Main *bmain);
-int checkPackedFile(const char *filename, struct PackedFile *pf);
+int checkPackedFile(const char *ref_file_name, const char *filename, struct PackedFile *pf);
/* read */
int seekPackedFile(struct PackedFile *pf, int offset, int whence);
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 717f4c4f6e8..2ba6446c18f 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -23,7 +23,7 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- */
+ */
#ifndef __BKE_PAINT_H__
#define __BKE_PAINT_H__
@@ -40,6 +40,7 @@ struct CurveMapping;
struct MeshElemMap;
struct GridPaintMask;
struct Main;
+struct Mesh;
struct MLoop;
struct MLoopTri;
struct MFace;
@@ -120,7 +121,7 @@ void BKE_paint_curve_copy_data(
struct PaintCurve *BKE_paint_curve_copy(struct Main *bmain, const struct PaintCurve *pc);
void BKE_paint_curve_make_local(struct Main *bmain, struct PaintCurve *pc, const bool lib_local);
-void BKE_paint_init(struct Scene *sce, ePaintMode mode, const char col[3]);
+void BKE_paint_init(struct Main *bmain, struct Scene *sce, ePaintMode mode, const char col[3]);
void BKE_paint_free(struct Paint *p);
void BKE_paint_copy(struct Paint *src, struct Paint *tar, const int flag);
@@ -185,7 +186,8 @@ typedef struct SculptSession {
float *vmask;
/* Mesh connectivity */
- const struct MeshElemMap *pmap;
+ struct MeshElemMap *pmap;
+ int *pmap_mem;
/* BMesh for dynamic topology sculpting */
struct BMesh *bm;
@@ -258,6 +260,8 @@ int BKE_sculpt_mask_layers_ensure(struct Object *ob,
struct MultiresModifierData *mmd);
void BKE_sculpt_toolsettings_data_ensure(struct Scene *scene);
+struct PBVH *BKE_sculpt_object_pbvh_ensure(struct Object *ob, struct Mesh *me_eval_deform);
+
enum {
SCULPT_MASK_LAYER_CALC_VERT = (1 << 0),
SCULPT_MASK_LAYER_CALC_LOOP = (1 << 1)
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 4820f0173bf..d87d63454f0 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -303,15 +303,13 @@ void psys_set_current_num(Object *ob, int index);
struct LatticeDeformData *psys_create_lattice_deform_data(struct ParticleSimulationData *sim);
struct ParticleSystem *psys_orig_get(struct ParticleSystem *psys);
-struct ParticleSystem *psys_eval_get(struct Depsgraph *depsgraph,
- struct Object *object,
- struct ParticleSystem *psys);
bool psys_in_edit_mode(struct Depsgraph *depsgraph, struct ParticleSystem *psys);
bool psys_check_enabled(struct Object *ob, struct ParticleSystem *psys, const bool use_render_params);
bool psys_check_edited(struct ParticleSystem *psys);
void psys_check_group_weights(struct ParticleSettings *part);
int psys_uses_gravity(struct ParticleSimulationData *sim);
+void BKE_particlesettings_fluid_default_settings(struct ParticleSettings *part);
/* free */
void BKE_particlesettings_free(struct ParticleSettings *part);
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index c18288de1bc..78c766f6115 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -240,7 +240,7 @@ void BKE_pbvh_node_layer_disp_free(PBVHNode *node);
/* vertex deformer */
float (*BKE_pbvh_get_vertCos(struct PBVH *pbvh))[3];
-void BKE_pbvh_apply_vertCos(struct PBVH *pbvh, float (*vertCos)[3]);
+void BKE_pbvh_apply_vertCos(struct PBVH *pbvh, float (*vertCos)[3], const int totvert);
bool BKE_pbvh_isDeformed(struct PBVH *pbvh);
/* Vertex Iterator */
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 36708cb11a4..0b95152ad8e 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -64,7 +64,7 @@ struct ScrAreaMap;
#include "RNA_types.h"
-/* spacetype has everything stored to get an editor working, it gets initialized via
+/* spacetype has everything stored to get an editor working, it gets initialized via
* ED_spacetypes_init() in editors/space_api/spacetypes.c */
/* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */
@@ -72,36 +72,36 @@ struct ScrAreaMap;
typedef struct SpaceType {
struct SpaceType *next, *prev;
-
+
char name[BKE_ST_MAXNAME]; /* for menus */
int spaceid; /* unique space identifier */
int iconid; /* icon lookup for menus */
-
+
/* Initial allocation, after this WM will call init() too. Some editors need
* area and scene data (e.g. frame range) to set their initial scrolling. */
- struct SpaceLink *(*new)(const struct ScrArea *, const struct Scene *);
+ struct SpaceLink *(*new)(const struct ScrArea *sa, const struct Scene *scene);
/* not free spacelink itself */
- void (*free)(struct SpaceLink *);
-
+ void (*free)(struct SpaceLink *sl);
+
/* init is to cope with file load, screen (size) changes, check handlers */
- void (*init)(struct wmWindowManager *, struct ScrArea *);
+ void (*init)(struct wmWindowManager *wm, struct ScrArea *sa);
/* exit is called when the area is hidden or removed */
- void (*exit)(struct wmWindowManager *, struct ScrArea *);
+ void (*exit)(struct wmWindowManager *wm, struct ScrArea *sa);
/* Listeners can react to bContext changes */
- void (*listener)(struct bScreen *sc, struct ScrArea *,
- struct wmNotifier *, struct Scene *scene,
+ void (*listener)(struct bScreen *sc, struct ScrArea *sa,
+ struct wmNotifier *wmn, struct Scene *scene,
struct WorkSpace *workspace);
-
+
/* refresh context, called after filereads, ED_area_tag_refresh() */
- void (*refresh)(const struct bContext *, struct ScrArea *);
-
+ void (*refresh)(const struct bContext *C, struct ScrArea *sa);
+
/* after a spacedata copy, an init should result in exact same situation */
- struct SpaceLink *(*duplicate)(struct SpaceLink *);
+ struct SpaceLink *(*duplicate)(struct SpaceLink *sl);
/* register operator types on startup */
void (*operatortypes)(void);
/* add default items to WM keymap */
- void (*keymap)(struct wmKeyConfig *);
+ void (*keymap)(struct wmKeyConfig *keyconf);
/* on startup, define dropboxes for spacetype+regions */
void (*dropboxes)(void);
@@ -109,44 +109,48 @@ typedef struct SpaceType {
void (*manipulators)(void);
/* return context data */
- int (*context)(const struct bContext *, const char *, struct bContextDataResult *);
+ int (*context)(const struct bContext *C, const char *member, struct bContextDataResult *result);
/* Used when we want to replace an ID by another (or NULL). */
- void (*id_remap)(struct ScrArea *, struct SpaceLink *, struct ID *, struct ID *);
+ void (*id_remap)(struct ScrArea *sa, struct SpaceLink *sl, struct ID *old_id, struct ID *new_id);
+
+ int (*space_subtype_get)(struct ScrArea *sa);
+ void (*space_subtype_set)(struct ScrArea *sa, int value);
+ void (*space_subtype_item_extend)(struct bContext *C, EnumPropertyItem **item, int *totitem);
/* region type definitions */
ListBase regiontypes;
-
+
/* tool shelf definitions */
ListBase toolshelf;
-
+
/* read and write... */
-
+
/* default keymaps to add */
int keymapflag;
-
+
} SpaceType;
/* region types are also defined using spacetypes_init, via a callback */
typedef struct ARegionType {
struct ARegionType *next, *prev;
-
+
int regionid; /* unique identifier within this space, defines RGN_TYPE_xxxx */
-
+
/* add handlers, stuff you only do once or on area/region type/size changes */
- void (*init)(struct wmWindowManager *, struct ARegion *);
+ void (*init)(struct wmWindowManager *wm, struct ARegion *ar);
/* exit is called when the region is hidden or removed */
- void (*exit)(struct wmWindowManager *, struct ARegion *);
+ void (*exit)(struct wmWindowManager *wm, struct ARegion *ar);
/* draw entirely, view changes should be handled here */
- void (*draw)(const struct bContext *, struct ARegion *);
+ void (*draw)(const struct bContext *C, struct ARegion *ar);
/* optional, compute button layout before drawing for dynamic size */
- void (*layout)(const struct bContext *, struct ARegion *);
+ void (*layout)(const struct bContext *C, struct ARegion *ar);
/* snap the size of the region (can be NULL for no snapping). */
int (*snap_size)(const struct ARegion *ar, int size, int axis);
/* contextual changes should be handled here */
- void (*listener)(struct bScreen *, struct ScrArea *, struct ARegion *,
- struct wmNotifier *, const struct Scene *scene);
+ void (*listener)(struct bScreen *sc, struct ScrArea *sa, struct ARegion *ar,
+ struct wmNotifier *wmn, const struct Scene *scene);
/* Optional callback to generate subscriptions. */
void (*message_subscribe)(
const struct bContext *C,
@@ -157,18 +161,18 @@ typedef struct ARegionType {
void (*free)(struct ARegion *);
/* split region, copy data optionally */
- void *(*duplicate)(void *);
+ void *(*duplicate)(void *poin);
+
-
/* register operator types on startup */
void (*operatortypes)(void);
/* add own items to keymap */
- void (*keymap)(struct wmKeyConfig *);
+ void (*keymap)(struct wmKeyConfig *keyconf);
/* allows default cursor per region */
- void (*cursor)(struct wmWindow *, struct ScrArea *, struct ARegion *ar);
+ void (*cursor)(struct wmWindow *win, struct ScrArea *sa, struct ARegion *ar);
/* return context data */
- int (*context)(const struct bContext *, const char *, struct bContextDataResult *);
+ int (*context)(const struct bContext *C, const char *member, struct bContextDataResult *result);
/* custom drawing callbacks */
ListBase drawcalls;
@@ -178,7 +182,7 @@ typedef struct ARegionType {
/* header type definitions */
ListBase headertypes;
-
+
/* hardcoded constraints, smaller than these values region is not visible */
int minsizex, minsizey;
/* when new region opens (region prefsizex/y are zero then */
@@ -195,24 +199,29 @@ typedef struct ARegionType {
typedef struct PanelType {
struct PanelType *next, *prev;
-
+
char idname[BKE_ST_MAXNAME]; /* unique name */
char label[BKE_ST_MAXNAME]; /* for panel header */
char translation_context[BKE_ST_MAXNAME];
char context[BKE_ST_MAXNAME]; /* for buttons window */
char category[BKE_ST_MAXNAME]; /* for category tabs */
- char owner_id[BKE_ST_MAXNAME]; /* for work-spaces to selectively show. */
+ char owner_id[BKE_ST_MAXNAME]; /* for work-spaces to selectively show. */
+ char parent_id[BKE_ST_MAXNAME]; /* parent idname for subpanels */
int space_type;
int region_type;
int flag;
/* verify if the panel should draw or not */
- int (*poll)(const struct bContext *, struct PanelType *);
+ int (*poll)(const struct bContext *C, struct PanelType *pt);
/* draw header (optional) */
- void (*draw_header)(const struct bContext *, struct Panel *);
+ void (*draw_header)(const struct bContext *C, struct Panel *pa);
/* draw entirely, view changes should be handled here */
- void (*draw)(const struct bContext *, struct Panel *);
+ void (*draw)(const struct bContext *C, struct Panel *pa);
+
+ /* sub panels */
+ struct PanelType *parent;
+ ListBase children;
/* RNA integration */
ExtensionRNA ext;
@@ -221,14 +230,18 @@ typedef struct PanelType {
/* uilist types */
/* Draw an item in the uiList */
-typedef void (*uiListDrawItemFunc)(struct uiList *, struct bContext *, struct uiLayout *, struct PointerRNA *,
- struct PointerRNA *, int, struct PointerRNA *, const char *, int, int);
+typedef void (*uiListDrawItemFunc)(
+ struct uiList *ui_list, struct bContext *C, struct uiLayout *layout, struct PointerRNA *dataptr,
+ struct PointerRNA *itemptr, int icon, struct PointerRNA *active_dataptr, const char *active_propname,
+ int index, int flt_flag);
/* Draw the filtering part of an uiList */
-typedef void (*uiListDrawFilterFunc)(struct uiList *, struct bContext *, struct uiLayout *);
+typedef void (*uiListDrawFilterFunc)(
+ struct uiList *ui_list, struct bContext *C, struct uiLayout *layout);
/* Filter items of an uiList */
-typedef void (*uiListFilterItemsFunc)(struct uiList *, struct bContext *, struct PointerRNA *, const char *);
+typedef void (*uiListFilterItemsFunc)(
+ struct uiList *ui_list, struct bContext *C, struct PointerRNA *, const char *propname);
typedef struct uiListType {
struct uiListType *next, *prev;
@@ -253,7 +266,7 @@ typedef struct HeaderType {
int region_type;
/* draw entirely, view changes should be handled here */
- void (*draw)(const struct bContext *, struct Header *);
+ void (*draw)(const struct bContext *C, struct Header *header);
/* RNA integration */
ExtensionRNA ext;
@@ -277,9 +290,9 @@ typedef struct MenuType {
const char *description;
/* verify if the menu should draw or not */
- int (*poll)(const struct bContext *, struct MenuType *);
+ int (*poll)(const struct bContext *C, struct MenuType *mt);
/* draw entirely, view changes should be handled here */
- void (*draw)(const struct bContext *, struct Menu *);
+ void (*draw)(const struct bContext *C, struct Menu *menu);
/* RNA integration */
ExtensionRNA ext;
@@ -303,7 +316,8 @@ void BKE_spacedata_freelist(ListBase *lb);
void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2);
void BKE_spacedata_draw_locks(int set);
-void BKE_spacedata_callback_id_remap_set(void (*func)(struct ScrArea *, struct SpaceLink *, struct ID *, struct ID *));
+void BKE_spacedata_callback_id_remap_set(
+ void (*func)(struct ScrArea *sa, struct SpaceLink *sl, struct ID *old_id, struct ID *new_id));
void BKE_spacedata_id_unref(struct ScrArea *sa, struct SpaceLink *sl, struct ID *id);
/* area/regions */
@@ -340,7 +354,7 @@ float BKE_screen_view3d_zoom_to_fac(float camzoom);
float BKE_screen_view3d_zoom_from_fac(float zoomfac);
/* screen */
-void BKE_screen_free(struct bScreen *sc);
+void BKE_screen_free(struct bScreen *sc);
void BKE_screen_area_map_free(struct ScrAreaMap *area_map) ATTR_NONNULL();
unsigned int BKE_screen_visible_layers(struct bScreen *screen, struct Scene *scene);
@@ -352,4 +366,3 @@ void BKE_screen_remove_unused_scredges(struct bScreen *sc);
void BKE_screen_remove_unused_scrverts(struct bScreen *sc);
#endif
-
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index cbe7c0b7743..63c91ef9635 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -94,6 +94,7 @@ void BKE_sequence_iterator_end(SeqIterator *iter);
typedef struct SeqRenderData {
struct Main *bmain;
+ struct Depsgraph *depsgraph;
struct Scene *scene;
int rectx;
int recty;
@@ -113,7 +114,7 @@ typedef struct SeqRenderData {
} SeqRenderData;
void BKE_sequencer_new_render_data(
- struct Main *bmain, struct Scene *scene,
+ struct Main *bmain, struct Depsgraph *depsgraph, struct Scene *scene,
int rectx, int recty, int preview_render_size,
int for_render,
SeqRenderData *r_context);
@@ -251,7 +252,7 @@ struct StripElem *BKE_sequencer_give_stripelem(struct Sequence *seq, int cfra);
void BKE_sequencer_update_changed_seq_and_deps(struct Scene *scene, struct Sequence *changed_seq, int len_change, int ibuf_change);
bool BKE_sequencer_input_have_to_preprocess(const SeqRenderData *context, struct Sequence *seq, float cfra);
-void BKE_sequencer_proxy_rebuild_context(struct Main *bmain, struct Scene *scene, struct Sequence *seq, struct GSet *file_list, ListBase *queue);
+void BKE_sequencer_proxy_rebuild_context(struct Main *bmain, struct Depsgraph *depsgraph, struct Scene *scene, struct Sequence *seq, struct GSet *file_list, ListBase *queue);
void BKE_sequencer_proxy_rebuild(struct SeqIndexBuildContext *context, short *stop, short *do_update, float *progress);
void BKE_sequencer_proxy_rebuild_finish(struct SeqIndexBuildContext *context, bool stop);
diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h
index 36caad86cf7..8a809b606f1 100644
--- a/source/blender/blenkernel/BKE_shrinkwrap.h
+++ b/source/blender/blenkernel/BKE_shrinkwrap.h
@@ -78,7 +78,7 @@ typedef struct ShrinkwrapCalcData {
} ShrinkwrapCalcData;
void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd, struct Object *ob, struct Mesh *mesh,
- float (*vertexCos)[3], int numVerts, const struct ModifierEvalContext *ctx);
+ float (*vertexCos)[3], int numVerts);
/*
* This function casts a ray in the given BVHTree.. but it takes into consideration the space_transform, that is:
diff --git a/source/blender/blenkernel/BKE_studiolight.h b/source/blender/blenkernel/BKE_studiolight.h
index 213de712abd..5e386fde528 100644
--- a/source/blender/blenkernel/BKE_studiolight.h
+++ b/source/blender/blenkernel/BKE_studiolight.h
@@ -57,15 +57,25 @@
struct GPUTexture;
enum StudioLightFlag {
- STUDIOLIGHT_DIFFUSE_LIGHT_CALCULATED = (1 << 0),
- STUDIOLIGHT_LIGHT_DIRECTION_CALCULATED = (1 << 1),
- STUDIOLIGHT_EXTERNAL_FILE = (1 << 2),
- STUDIOLIGHT_ORIENTATION_CAMERA = (1 << 3),
- STUDIOLIGHT_ORIENTATION_WORLD = (1 << 4),
- STUDIOLIGHT_EQUIRECTANGULAR_IMAGE_LOADED = (1 << 5),
- STUDIOLIGHT_EQUIRECTANGULAR_GPUTEXTURE = (1 << 6),
- STUDIOLIGHT_RADIANCE_BUFFERS_CALCULATED = (1 << 7),
+ STUDIOLIGHT_DIFFUSE_LIGHT_CALCULATED = (1 << 0),
+ STUDIOLIGHT_LIGHT_DIRECTION_CALCULATED = (1 << 1),
+ STUDIOLIGHT_INTERNAL = (1 << 2),
+ STUDIOLIGHT_EXTERNAL_FILE = (1 << 3),
+ STUDIOLIGHT_USER_DEFINED = (1 << 12),
+ STUDIOLIGHT_ORIENTATION_CAMERA = (1 << 4),
+ STUDIOLIGHT_ORIENTATION_WORLD = (1 << 5),
+ STUDIOLIGHT_ORIENTATION_VIEWNORMAL = (1 << 6),
+ STUDIOLIGHT_EXTERNAL_IMAGE_LOADED = (1 << 7),
+ STUDIOLIGHT_EQUIRECTANGULAR_IRRADIANCE_IMAGE_CALCULATED = (1 << 8),
+ STUDIOLIGHT_EQUIRECTANGULAR_RADIANCE_GPUTEXTURE = (1 << 9),
+ STUDIOLIGHT_EQUIRECTANGULAR_IRRADIANCE_GPUTEXTURE = (1 << 10),
+ STUDIOLIGHT_RADIANCE_BUFFERS_CALCULATED = (1 << 11),
+ STUDIOLIGHT_UI_EXPANDED = (1 << 13),
} StudioLightFlag;
+#define STUDIOLIGHT_FLAG_ALL (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_EXTERNAL_FILE)
+#define STUDIOLIGHT_FLAG_ORIENTATIONS (STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_ORIENTATION_VIEWNORMAL)
+#define STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_ORIENTATION_WORLD)
+#define STUDIOLIGHT_ORIENTATIONS_SOLID (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD)
typedef struct StudioLight {
struct StudioLight *next, *prev;
@@ -77,17 +87,21 @@ typedef struct StudioLight {
int index;
float diffuse_light[6][3];
float light_direction[3];
- ImBuf *equirectangular_buffer;
- ImBuf *radiance_buffers[6];
- struct GPUTexture *equirectangular_gputexture;
+ ImBuf *equirectangular_radiance_buffer;
+ ImBuf *equirectangular_irradiance_buffer;
+ ImBuf *radiance_cubemap_buffers[6];
+ struct GPUTexture *equirectangular_radiance_gputexture;
+ struct GPUTexture *equirectangular_irradiance_gputexture;
} StudioLight;
void BKE_studiolight_init(void);
void BKE_studiolight_free(void);
struct StudioLight *BKE_studiolight_find(const char *name, int flag);
-struct StudioLight *BKE_studiolight_findindex(int index);
+struct StudioLight *BKE_studiolight_findindex(int index, int flag);
+struct StudioLight *BKE_studiolight_find_first(int flag);
unsigned int *BKE_studiolight_preview(StudioLight *sl, int icon_size, int icon_id_type);
-const struct ListBase *BKE_studiolight_listbase(void);
+struct ListBase *BKE_studiolight_listbase(void);
void BKE_studiolight_ensure_flag(StudioLight *sl, int flag);
+void BKE_studiolight_refresh(void);
#endif /* __BKE_STUDIOLIGHT_H__ */
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index 13302caa09d..0c3b118d947 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -32,6 +32,7 @@
* \author Sergey Sharybin
*/
+struct Depsgraph;
struct bGPDlayer;
struct ImBuf;
struct ListBase;
@@ -61,7 +62,8 @@ struct ListBase *BKE_tracking_get_active_plane_tracks(struct MovieTracking *trac
struct MovieTrackingReconstruction *BKE_tracking_get_active_reconstruction(struct MovieTracking *tracking);
/* matrices for constraints and drawing */
-void BKE_tracking_get_camera_object_matrix(struct Scene *scene, struct Object *ob, float mat[4][4]);
+void BKE_tracking_get_camera_object_matrix(
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float mat[4][4]);
void BKE_tracking_get_projection_matrix(struct MovieTracking *tracking, struct MovieTrackingObject *object,
int framenr, int winx, int winy, float mat[4][4]);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 8bf7ac3f6a2..c081bb0799f 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -61,6 +61,7 @@
#include "BKE_modifier.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_mesh_tangent.h"
#include "BKE_object.h"
#include "BKE_object_deform.h"
@@ -94,7 +95,6 @@
static ThreadRWMutex loops_cache_lock = PTHREAD_RWLOCK_INITIALIZER;
-static void add_shapekey_layers(DerivedMesh *dm, Mesh *me, Object *ob);
static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape_uid);
static void mesh_init_origspace(Mesh *mesh);
@@ -716,7 +716,7 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask, bool
Mesh tmp = *me;
int totvert, totedge /*, totface */ /* UNUSED */, totloop, totpoly;
int did_shapekeys = 0;
- int alloctype = CD_DUPLICATE;
+ eCDAllocType alloctype = CD_DUPLICATE;
if (take_ownership && dm->type == DM_TYPE_CDDM && dm->needsFree) {
bool has_any_referenced_layers =
@@ -911,27 +911,27 @@ static void mesh_set_only_copy(Mesh *mesh, CustomDataMask mask)
#endif
}
-void DM_add_vert_layer(DerivedMesh *dm, int type, int alloctype, void *layer)
+void DM_add_vert_layer(DerivedMesh *dm, int type, eCDAllocType alloctype, void *layer)
{
CustomData_add_layer(&dm->vertData, type, alloctype, layer, dm->numVertData);
}
-void DM_add_edge_layer(DerivedMesh *dm, int type, int alloctype, void *layer)
+void DM_add_edge_layer(DerivedMesh *dm, int type, eCDAllocType alloctype, void *layer)
{
CustomData_add_layer(&dm->edgeData, type, alloctype, layer, dm->numEdgeData);
}
-void DM_add_tessface_layer(DerivedMesh *dm, int type, int alloctype, void *layer)
+void DM_add_tessface_layer(DerivedMesh *dm, int type, eCDAllocType alloctype, void *layer)
{
CustomData_add_layer(&dm->faceData, type, alloctype, layer, dm->numTessFaceData);
}
-void DM_add_loop_layer(DerivedMesh *dm, int type, int alloctype, void *layer)
+void DM_add_loop_layer(DerivedMesh *dm, int type, eCDAllocType alloctype, void *layer)
{
CustomData_add_layer(&dm->loopData, type, alloctype, layer, dm->numLoopData);
}
-void DM_add_poly_layer(DerivedMesh *dm, int type, int alloctype, void *layer)
+void DM_add_poly_layer(DerivedMesh *dm, int type, eCDAllocType alloctype, void *layer)
{
CustomData_add_layer(&dm->polyData, type, alloctype, layer, dm->numPolyData);
}
@@ -1157,6 +1157,8 @@ DerivedMesh *mesh_create_derived(Mesh *me, float (*vertCos)[3])
return dm;
}
+/* XXX2.8(Sybren): can be removed once DerivedMesh port is done */
+#ifdef WITH_DERIVEDMESH_DEPRECATED_FUNCS
DerivedMesh *mesh_create_derived_for_modifier(
struct Depsgraph *depsgraph, Scene *scene, Object *ob,
ModifierData *md, int build_shapekey_layers)
@@ -1207,6 +1209,7 @@ DerivedMesh *mesh_create_derived_for_modifier(
return dm;
}
+#endif
static float (*get_editbmesh_orco_verts(BMEditMesh *em))[3]
{
@@ -1294,7 +1297,11 @@ static Mesh *create_orco_mesh(Object *ob, Mesh *me, BMEditMesh *em, int layer)
else {
BKE_id_copy_ex(
NULL, &me->id, (ID **)&mesh,
- LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_DEG_TAG, false);
+ (LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG |
+ LIB_ID_COPY_CD_REFERENCE),
+ false);
}
orco = get_orco_coords_dm(ob, em, layer, &free);
@@ -1916,7 +1923,7 @@ static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape
}
}
-static void add_shapekey_layers(DerivedMesh *dm, Mesh *me, Object *UNUSED(ob))
+static void UNUSED_FUNCTION(add_shapekey_layers)(DerivedMesh *dm, Mesh *me, Object *UNUSED(ob))
{
KeyBlock *kb;
Key *key = me->key;
@@ -2125,7 +2132,11 @@ static void mesh_calc_modifiers(
if (r_deform_mesh) {
BKE_id_copy_ex(
NULL, &me->id, (ID **)r_deform_mesh,
- LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_DEG_TAG, false);
+ (LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG |
+ LIB_ID_COPY_CD_REFERENCE),
+ false);
/* XXX: Is build_shapekey_layers ever even true? This should have crashed long ago... */
BLI_assert(!build_shapekey_layers);
@@ -2268,7 +2279,11 @@ static void mesh_calc_modifiers(
else {
BKE_id_copy_ex(
NULL, &me->id, (ID **)&mesh,
- LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_DEG_TAG, false);
+ (LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG |
+ LIB_ID_COPY_CD_REFERENCE),
+ false);
ASSERT_IS_VALID_MESH(mesh);
// XXX: port to Mesh if build_shapekey_layers can ever be true
@@ -2439,7 +2454,11 @@ static void mesh_calc_modifiers(
else {
BKE_id_copy_ex(
NULL, &me->id, (ID **)&final_mesh,
- LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_DEG_TAG, false);
+ (LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG |
+ LIB_ID_COPY_CD_REFERENCE),
+ false);
//if (build_shapekey_layers) {
// add_shapekey_layers(final_mesh, me, ob);
@@ -2774,7 +2793,7 @@ static void editbmesh_calc_modifiers(
}
else {
struct Mesh *mesh = ob->data;
- if (mesh->id.tag & LIB_TAG_COPY_ON_WRITE) {
+ if (mesh->id.tag & LIB_TAG_COPIED_ON_WRITE) {
BKE_mesh_runtime_ensure_edit_data(mesh);
mesh->runtime.edit_data->vertexCos = MEM_dupallocN(deformedVerts);
}
@@ -2816,7 +2835,7 @@ static void editbmesh_calc_modifiers(
else {
/* this is just a copy of the editmesh, no need to calc normals */
struct Mesh *mesh = ob->data;
- if (mesh->id.tag & LIB_TAG_COPY_ON_WRITE) {
+ if (mesh->id.tag & LIB_TAG_COPIED_ON_WRITE) {
BKE_mesh_runtime_ensure_edit_data(mesh);
if (mesh->runtime.edit_data->vertexCos != NULL)
MEM_freeN((void *)mesh->runtime.edit_data->vertexCos);
@@ -2916,6 +2935,48 @@ static bool calc_modifiers_skip_orco(Depsgraph *depsgraph,
}
#endif
+static void mesh_finalize_eval(Object *object)
+{
+ Mesh *mesh = (Mesh *)object->data;
+ Mesh *mesh_eval = object->runtime.mesh_eval;
+ /* Special Tweaks for cases when evaluated mesh came from
+ * BKE_mesh_new_nomain_from_template().
+ */
+ BLI_strncpy(mesh_eval->id.name, mesh->id.name, sizeof(mesh_eval->id.name));
+ if (mesh_eval->mat != NULL) {
+ MEM_freeN(mesh_eval->mat);
+ }
+ /* Set flag which makes it easier to see what's going on in a debugger. */
+ mesh_eval->id.tag |= LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT;
+ mesh_eval->mat = MEM_dupallocN(mesh->mat);
+ mesh_eval->totcol = mesh->totcol;
+ /* Make evaluated mesh to share same edit mesh pointer as original
+ * and copied meshes.
+ */
+ mesh_eval->edit_btmesh = mesh->edit_btmesh;
+ /* Copy autosmooth settings from original mesh.
+ * This is not done by BKE_mesh_new_nomain_from_template(), so need to take
+ * extra care here.
+ */
+ mesh_eval->flag |= (mesh->flag & ME_AUTOSMOOTH);
+ mesh_eval->smoothresh = mesh->smoothresh;
+ /* Replace evaluated object's data with fully evaluated mesh. */
+ /* TODO(sergey): There was statement done by Sybren and Mai that this
+ * caused modifiers to be applied twice. which is weirtd and shouldn't
+ * really happen. But since there is no reference to the report, can not
+ * do much about this.
+ */
+
+ /* Object is sometimes not evaluated!
+ * TODO(sergey): BAD TEMPORARY HACK FOR UNTIL WE ARE SMARTER */
+ if (object->id.tag & LIB_TAG_COPIED_ON_WRITE) {
+ object->data = mesh_eval;
+ }
+ else {
+ /* evaluated will be available via: 'object->runtime.mesh_eval' */
+ }
+}
+
static void mesh_build_data(
struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask,
const bool build_shapekey_layers, const bool need_mapping)
@@ -2931,12 +2992,21 @@ static void mesh_build_data(
}
#endif
- mesh_calc_modifiers_dm(
+ mesh_calc_modifiers(
depsgraph, scene, ob, NULL, 1, need_mapping, dataMask, -1, true, build_shapekey_layers,
true,
- &ob->derivedDeform, &ob->derivedFinal);
+ &ob->runtime.mesh_deform_eval, &ob->runtime.mesh_eval);
+
+ mesh_finalize_eval(ob);
+
+ ob->derivedDeform = CDDM_from_mesh_ex(ob->runtime.mesh_deform_eval, CD_REFERENCE, CD_MASK_MESH);
+ ob->derivedFinal = CDDM_from_mesh_ex(ob->runtime.mesh_eval, CD_REFERENCE, CD_MASK_MESH);
DM_set_object_boundbox(ob, ob->derivedFinal);
+ /* TODO(sergey): Convert bounding box calculation to use mesh, then
+ * we can skip this copy.
+ */
+ BKE_mesh_texspace_copy_from_object(ob->runtime.mesh_eval, ob);
ob->derivedFinal->needsFree = 0;
ob->derivedDeform->needsFree = 0;
@@ -3037,6 +3107,8 @@ void makeDerivedMesh(
/***/
+#ifdef USE_DERIVEDMESH
+/* Deprecated DM, use: 'mesh_get_eval_final'. */
DerivedMesh *mesh_get_derived_final(
struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
{
@@ -3056,7 +3128,29 @@ DerivedMesh *mesh_get_derived_final(
if (ob->derivedFinal) { BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS)); }
return ob->derivedFinal;
}
+#endif
+Mesh *mesh_get_eval_final(
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
+{
+ /* if there's no evaluated mesh or the last data mask used doesn't include
+ * the data we need, rebuild the derived mesh
+ */
+ bool need_mapping;
+ dataMask |= object_get_datamask(depsgraph, ob, &need_mapping);
+ if (!ob->runtime.mesh_eval ||
+ ((dataMask & ob->lastDataMask) != dataMask) ||
+ (need_mapping != ob->lastNeedMapping))
+ {
+ mesh_build_data(depsgraph, scene, ob, dataMask, false, need_mapping);
+ }
+
+ if (ob->runtime.mesh_eval) { BLI_assert(!(ob->runtime.mesh_eval->runtime.cd_dirty_vert & CD_MASK_NORMAL)); }
+ return ob->runtime.mesh_eval;
+}
+
+#ifdef USE_DERIVEDMESH
+/* Deprecated DM, use: 'mesh_get_eval_deform' instead. */
DerivedMesh *mesh_get_derived_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
{
/* if there's no derived mesh or the last data mask used doesn't include
@@ -3075,6 +3169,26 @@ DerivedMesh *mesh_get_derived_deform(struct Depsgraph *depsgraph, Scene *scene,
return ob->derivedDeform;
}
+#endif
+Mesh *mesh_get_eval_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
+{
+ /* if there's no derived mesh or the last data mask used doesn't include
+ * the data we need, rebuild the derived mesh
+ */
+ bool need_mapping;
+
+ dataMask |= object_get_datamask(depsgraph, ob, &need_mapping);
+
+ if (!ob->runtime.mesh_deform_eval ||
+ ((dataMask & ob->lastDataMask) != dataMask) ||
+ (need_mapping != ob->lastNeedMapping))
+ {
+ mesh_build_data(depsgraph, scene, ob, dataMask, false, need_mapping);
+ }
+
+ return ob->runtime.mesh_deform_eval;
+}
+
DerivedMesh *mesh_create_derived_render(struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
{
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index dd3e8c0afdb..01f6eab261f 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -265,7 +265,7 @@ bActionGroup *action_groups_add_new(bAction *act, const char name[])
/* Add given channel into (active) group
* - assumes that channel is not linked to anything anymore
- * - always adds at the end of the group
+ * - always adds at the end of the group
*/
void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
{
@@ -582,7 +582,9 @@ void BKE_pose_copy_data_ex(bPose **dst, const bPose *src, const int flag, const
if (copy_constraints) {
BKE_constraints_copy_ex(&listb, &pchan->constraints, flag, true); // BKE_constraints_copy NULLs listb
pchan->constraints = listb;
- pchan->mpath = NULL; /* motion paths should not get copied yet... */
+
+ /* XXX: This is needed for motionpath drawing to work. Dunno why it was setting to null before... */
+ pchan->mpath = animviz_copy_motionpath(pchan->mpath);
}
if (pchan->prop) {
@@ -912,7 +914,7 @@ void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_f
/* checks for IK constraint, Spline IK, and also for Follow-Path constraint.
- * can do more constraints flags later
+ * can do more constraints flags later
*/
/* pose should be entirely OK */
void BKE_pose_update_constraint_flags(bPose *pose)
@@ -1386,7 +1388,7 @@ void BKE_pose_tag_recalc(Main *bmain, bPose *pose)
}
/* For the calculation of the effects of an Action at the given frame on an object
- * This is currently only used for the Action Constraint
+ * This is currently only used for the Action Constraint
*/
void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe)
{
@@ -1452,7 +1454,7 @@ void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, c
adt.action = act;
/* execute effects of Action on to workob (or it's PoseChannels) */
- BKE_animsys_evaluate_animdata(NULL, &workob->id, &adt, cframe, ADT_RECALC_ANIM);
+ BKE_animsys_evaluate_animdata(NULL, NULL, &workob->id, &adt, cframe, ADT_RECALC_ANIM);
}
}
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index cff9fd4a7c8..c7730d8877b 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -35,6 +35,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
+#include "BLI_dlrbTree.h"
#include "BLT_translation.h"
@@ -44,6 +45,7 @@
#include "DNA_scene_types.h"
#include "BKE_anim.h"
+#include "BKE_animsys.h"
#include "BKE_action.h"
#include "BKE_context.h"
#include "BKE_curve.h"
@@ -59,7 +61,12 @@
#include "DEG_depsgraph_query.h"
#include "DEG_depsgraph_build.h"
+#include "GPU_batch.h"
+
// XXX bad level call...
+extern short compare_ak_cfraPtr(void *node, void *data);
+extern void agroup_to_keylist(struct AnimData *adt, struct bActionGroup *agrp, struct DLRBT_Tree *keys, struct DLRBT_Tree *blocks);
+extern void action_to_keylist(struct AnimData *adt, struct bAction *act, struct DLRBT_Tree *keys, struct DLRBT_Tree *blocks);
/* --------------------- */
/* forward declarations */
@@ -106,6 +113,10 @@ void animviz_free_motionpath_cache(bMotionPath *mpath)
/* free the path if necessary */
if (mpath->points)
MEM_freeN(mpath->points);
+
+ GWN_VERTBUF_DISCARD_SAFE(mpath->points_vbo);
+ GWN_BATCH_DISCARD_SAFE(mpath->batch_line);
+ GWN_BATCH_DISCARD_SAFE(mpath->batch_points);
/* reset the relevant parameters */
mpath->points = NULL;
@@ -130,6 +141,27 @@ void animviz_free_motionpath(bMotionPath *mpath)
/* ------------------- */
+/* Make a copy of motionpath data, so that viewing with copy on write works */
+bMotionPath *animviz_copy_motionpath(const bMotionPath *mpath_src)
+{
+ bMotionPath *mpath_dst;
+
+ if (mpath_src == NULL)
+ return NULL;
+
+ mpath_dst = MEM_dupallocN(mpath_src);
+ mpath_dst->points = MEM_dupallocN(mpath_src->points);
+
+ /* should get recreated on draw... */
+ mpath_dst->points_vbo = NULL;
+ mpath_dst->batch_line = NULL;
+ mpath_dst->batch_points = NULL;
+
+ return mpath_dst;
+}
+
+/* ------------------- */
+
/**
* Setup motion paths for the given data.
* \note Only used when explicitly calculating paths on bones which may/may not be consider already
@@ -212,7 +244,7 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec
mpath->color[1] = 0.0;
mpath->color[2] = 0.0;
- mpath->line_thickness = 1;
+ mpath->line_thickness = 2;
mpath->flag |= MOTIONPATH_FLAG_LINES; /* draw lines by default */
/* allocate a cache */
@@ -232,6 +264,8 @@ typedef struct MPathTarget {
struct MPathTarget *next, *prev;
bMotionPath *mpath; /* motion path in question */
+
+ DLRBT_Tree keys; /* temp, to know where the keyframes are */
/* Original (Source Objects) */
Object *ob; /* source object */
@@ -344,6 +378,13 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
/* worldspace object location */
copy_v3_v3(mpv->co, ob_eval->obmat[3]);
}
+
+ float mframe = (float)(CFRA);
+
+ /* Tag if it's a keyframe */
+ if (BLI_dlrbTree_search_exact(&mpt->keys, compare_ak_cfraPtr, &mframe)) {
+ mpv->flag |= MOTIONPATH_VERT_KEY;
+ }
}
}
@@ -387,13 +428,44 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
if (mpt->pchan) {
mpt->pchan_eval = BKE_pose_channel_find_name(mpt->ob_eval->pose, mpt->pchan->name);
}
+
+ AnimData *adt = BKE_animdata_from_id(&mpt->ob_eval->id);
+
+ /* build list of all keyframes in active action for object or pchan */
+ BLI_dlrbTree_init(&mpt->keys);
+
+ if (adt) {
+ bAnimVizSettings *avs;
+
+ /* get pointer to animviz settings for each target */
+ if (mpt->pchan)
+ avs = &mpt->ob->pose->avs;
+ else
+ avs = &mpt->ob->avs;
+
+ /* it is assumed that keyframes for bones are all grouped in a single group
+ * unless an option is set to always use the whole action
+ */
+ if ((mpt->pchan) && (avs->path_viewflag & MOTIONPATH_VIEW_KFACT) == 0) {
+ bActionGroup *agrp = BKE_action_group_find_name(adt->action, mpt->pchan->name);
+
+ if (agrp) {
+ agroup_to_keylist(adt, agrp, &mpt->keys, NULL);
+ BLI_dlrbTree_linkedlist_sync(&mpt->keys);
+ }
+ }
+ else {
+ action_to_keylist(adt, adt->action, &mpt->keys, NULL);
+ BLI_dlrbTree_linkedlist_sync(&mpt->keys);
+ }
+ }
}
-
+
/* calculate path over requested range */
for (CFRA = sfra; CFRA <= efra; CFRA++) {
/* update relevant data for new frame */
motionpaths_calc_update_scene(bmain, depsgraph);
-
+
/* perform baking for targets */
motionpaths_calc_bake_targets(scene, targets);
}
@@ -406,6 +478,7 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
/* clear recalc flags from targets */
for (mpt = targets->first; mpt; mpt = mpt->next) {
bAnimVizSettings *avs;
+ bMotionPath *mpath = mpt->mpath;
/* get pointer to animviz settings for each target */
if (mpt->pchan)
@@ -415,6 +488,14 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
/* clear the flag requesting recalculation of targets */
avs->recalc &= ~ANIMVIZ_RECALC_PATHS;
+
+ /* Clean temp data */
+ BLI_dlrbTree_free(&mpt->keys);
+
+ /* Free previous batches to force update. */
+ GWN_VERTBUF_DISCARD_SAFE(mpath->points_vbo);
+ GWN_BATCH_DISCARD_SAFE(mpath->batch_line);
+ GWN_BATCH_DISCARD_SAFE(mpath->batch_points);
}
}
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index a14231fd427..e5a68fa7476 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -141,7 +141,7 @@ AnimData *BKE_animdata_from_id(ID *id)
/* Add AnimData to the given ID-block. In order for this to work, we assume that
* the AnimData pointer is stored immediately after the given ID-block in the struct,
- * as per IdAdtTemplate. Also note that
+ * as per IdAdtTemplate. Also note that
*/
AnimData *BKE_animdata_add_id(ID *id)
{
@@ -250,6 +250,9 @@ void BKE_animdata_free(ID *id, const bool do_id_user)
/* free drivers - stored as a list of F-Curves */
free_fcurves(&adt->drivers);
+
+ /* free driver array cache */
+ MEM_SAFE_FREE(adt->driver_array);
/* free overrides */
/* TODO... */
@@ -289,6 +292,7 @@ AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const bool do_action, co
/* duplicate drivers (F-Curves) */
copy_fcurves(&dadt->drivers, &adt->drivers);
+ dadt->driver_array = NULL;
/* don't copy overrides */
BLI_listbase_clear(&dadt->overrides);
@@ -419,8 +423,8 @@ static bool animpath_matches_basepath(const char path[], const char basepath[])
}
/* Move F-Curves in src action to dst action, setting up all the necessary groups
- * for this to happen, but only if the F-Curves being moved have the appropriate
- * "base path".
+ * for this to happen, but only if the F-Curves being moved have the appropriate
+ * "base path".
* - This is used when data moves from one datablock to another, causing the
* F-Curves to need to be moved over too
*/
@@ -1698,60 +1702,46 @@ bool BKE_animsys_execute_fcurve(PointerRNA *ptr, AnimMapper *remap, FCurve *fcu,
return ok;
}
-/* Evaluate all the F-Curves in the given list
- * This performs a set of standard checks. If extra checks are required, separate code should be used
- */
-static void animsys_evaluate_fcurves(PointerRNA *ptr, ListBase *list, AnimMapper *remap, float ctime, short recalc)
+static void animsys_write_orig_anim_rna(
+ PointerRNA *ptr,
+ AnimMapper *remap,
+ FCurve *fcu,
+ float value)
{
- FCurve *fcu;
-
/* Pointer is expected to be an ID pointer, if it's not -- we are doomed. */
PointerRNA orig_ptr = *ptr;
orig_ptr.id.data = ((ID *)orig_ptr.id.data)->orig_id;
orig_ptr.data = orig_ptr.id.data;
+ PathResolvedRNA orig_anim_rna;
+ /* TODO(sergey): Is there a faster way to get anim_rna of original ID? */
+ if (animsys_store_rna_setting(&orig_ptr, remap, fcu->rna_path, fcu->array_index, &orig_anim_rna)) {
+ animsys_write_rna_setting(&orig_anim_rna, value);
+ }
+}
- const bool copy_on_write = orig_ptr.id.data != NULL;
-
- /* calculate then execute each curve */
- for (fcu = list->first; fcu; fcu = fcu->next) {
- /* check if this F-Curve doesn't belong to a muted group */
- if ((fcu->grp == NULL) || (fcu->grp->flag & AGRP_MUTED) == 0) {
- /* check if this curve should be skipped */
- if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) {
- PathResolvedRNA anim_rna;
- /* Read current value from original datablock. */
- float dna_val;
-
- if (copy_on_write) {
- if (animsys_store_rna_setting(&orig_ptr, remap, fcu->rna_path, fcu->array_index, &anim_rna)) {
- if (!animsys_read_rna_setting(&anim_rna, &dna_val)) {
- continue;
- }
- }
- else {
- continue;
- }
- }
-
- if (animsys_store_rna_setting(ptr, remap, fcu->rna_path, fcu->array_index, &anim_rna)) {
- if (copy_on_write) {
- const bool check_orig_dna = ((recalc & ADT_RECALC_CHECK_ORIG_DNA) != 0);
- /* If we are tweaking DNA without changing frame, we don't write f-curves,
- * since otherwise we will not be able to change properties which has animation.
- */
- if (check_orig_dna && fcu->orig_dna_val != dna_val) {
- continue;
- }
- }
-
- const float curval = calculate_fcurve(&anim_rna, fcu, ctime);
- animsys_write_rna_setting(&anim_rna, curval);
-
- if (copy_on_write) {
- /* Store original DNA value f-curve was written for. */
- fcu->orig_dna_val = dna_val;
- }
- }
+/* Evaluate all the F-Curves in the given list
+ * This performs a set of standard checks. If extra checks are required, separate code should be used
+ */
+static void animsys_evaluate_fcurves(
+ Depsgraph *depsgraph, PointerRNA *ptr, ListBase *list, AnimMapper *remap, float ctime)
+{
+ const bool is_active_depsgraph = DEG_is_active(depsgraph);
+ /* Calculate then execute each curve. */
+ for (FCurve *fcu = list->first; fcu; fcu = fcu->next) {
+ /* Check if this F-Curve doesn't belong to a muted group. */
+ if ((fcu->grp != NULL) && (fcu->grp->flag & AGRP_MUTED)) {
+ continue;
+ }
+ /* Check if this curve should be skipped. */
+ if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED))) {
+ continue;
+ }
+ PathResolvedRNA anim_rna;
+ if (animsys_store_rna_setting(ptr, remap, fcu->rna_path, fcu->array_index, &anim_rna)) {
+ const float curval = calculate_fcurve(&anim_rna, fcu, ctime);
+ animsys_write_rna_setting(&anim_rna, curval);
+ if (is_active_depsgraph) {
+ animsys_write_orig_anim_rna(ptr, remap, fcu, curval);
}
}
}
@@ -1863,7 +1853,8 @@ void animsys_evaluate_action_group(PointerRNA *ptr, bAction *act, bActionGroup *
}
/* Evaluate Action (F-Curve Bag) */
-static void animsys_evaluate_action_ex(PointerRNA *ptr, bAction *act, AnimMapper *remap, float ctime, short recalc)
+static void animsys_evaluate_action_ex(
+ Depsgraph *depsgraph, PointerRNA *ptr, bAction *act, AnimMapper *remap, float ctime)
{
/* check if mapper is appropriate for use here (we set to NULL if it's inappropriate) */
if (act == NULL) return;
@@ -1872,12 +1863,12 @@ static void animsys_evaluate_action_ex(PointerRNA *ptr, bAction *act, AnimMapper
action_idcode_patch_check(ptr->id.data, act);
/* calculate then execute each curve */
- animsys_evaluate_fcurves(ptr, &act->curves, remap, ctime, recalc);
+ animsys_evaluate_fcurves(depsgraph, ptr, &act->curves, remap, ctime);
}
-void animsys_evaluate_action(PointerRNA *ptr, bAction *act, AnimMapper *remap, float ctime)
+void animsys_evaluate_action(Depsgraph *depsgraph, PointerRNA *ptr, bAction *act, AnimMapper *remap, float ctime)
{
- animsys_evaluate_action_ex(ptr, act, remap, ctime, 0);
+ animsys_evaluate_action_ex(depsgraph, ptr, act, remap, ctime);
}
/* ***************************************** */
@@ -1906,7 +1897,7 @@ static float nlastrip_get_influence(NlaStrip *strip, float cframe)
}
/* evaluate the evaluation time and influence for the strip, storing the results in the strip */
-static void nlastrip_evaluate_controls(NlaStrip *strip, float ctime)
+static void nlastrip_evaluate_controls(Depsgraph *depsgraph, NlaStrip *strip, float ctime)
{
/* now strip's evaluate F-Curves for these settings (if applicable) */
if (strip->fcurves.first) {
@@ -1916,7 +1907,7 @@ static void nlastrip_evaluate_controls(NlaStrip *strip, float ctime)
RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr);
/* execute these settings as per normal */
- animsys_evaluate_fcurves(&strip_ptr, &strip->fcurves, NULL, ctime, 0);
+ animsys_evaluate_fcurves(depsgraph, &strip_ptr, &strip->fcurves, NULL, ctime);
}
/* analytically generate values for influence and time (if applicable)
@@ -1938,7 +1929,7 @@ static void nlastrip_evaluate_controls(NlaStrip *strip, float ctime)
}
/* gets the strip active at the current time for a list of strips for evaluation purposes */
-NlaEvalStrip *nlastrips_ctime_get_strip(ListBase *list, ListBase *strips, short index, float ctime)
+NlaEvalStrip *nlastrips_ctime_get_strip(Depsgraph *depsgraph, ListBase *list, ListBase *strips, short index, float ctime)
{
NlaStrip *strip, *estrip = NULL;
NlaEvalStrip *nes;
@@ -2015,7 +2006,7 @@ NlaEvalStrip *nlastrips_ctime_get_strip(ListBase *list, ListBase *strips, short
* - negative influence is not supported yet... how would that be defined?
*/
/* TODO: this sounds a bit hacky having a few isolated F-Curves stuck on some data it operates on... */
- nlastrip_evaluate_controls(estrip, ctime);
+ nlastrip_evaluate_controls(depsgraph, estrip, ctime);
if (estrip->influence <= 0.0f)
return NULL;
@@ -2034,8 +2025,8 @@ NlaEvalStrip *nlastrips_ctime_get_strip(ListBase *list, ListBase *strips, short
return NULL;
/* evaluate controls for the relevant extents of the bordering strips... */
- nlastrip_evaluate_controls(estrip->prev, estrip->start);
- nlastrip_evaluate_controls(estrip->next, estrip->end);
+ nlastrip_evaluate_controls(depsgraph, estrip->prev, estrip->start);
+ nlastrip_evaluate_controls(depsgraph, estrip->next, estrip->end);
break;
}
@@ -2381,7 +2372,8 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr, ListBase *channels, Li
}
/* evaluate transition strip */
-static void nlastrip_evaluate_transition(PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
+static void nlastrip_evaluate_transition(
+ Depsgraph *depsgraph, PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
{
ListBase tmp_channels = {NULL, NULL};
ListBase tmp_modifiers = {NULL, NULL};
@@ -2421,12 +2413,12 @@ static void nlastrip_evaluate_transition(PointerRNA *ptr, ListBase *channels, Li
/* first strip */
tmp_nes.strip_mode = NES_TIME_TRANSITION_START;
tmp_nes.strip = s1;
- nlastrip_evaluate(ptr, &tmp_channels, &tmp_modifiers, &tmp_nes);
+ nlastrip_evaluate(depsgraph, ptr, &tmp_channels, &tmp_modifiers, &tmp_nes);
/* second strip */
tmp_nes.strip_mode = NES_TIME_TRANSITION_END;
tmp_nes.strip = s2;
- nlastrip_evaluate(ptr, &tmp_channels, &tmp_modifiers, &tmp_nes);
+ nlastrip_evaluate(depsgraph, ptr, &tmp_channels, &tmp_modifiers, &tmp_nes);
/* accumulate temp-buffer and full-buffer, using the 'real' strip */
@@ -2437,7 +2429,8 @@ static void nlastrip_evaluate_transition(PointerRNA *ptr, ListBase *channels, Li
}
/* evaluate meta-strip */
-static void nlastrip_evaluate_meta(PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
+static void nlastrip_evaluate_meta(
+ Depsgraph *depsgraph, PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
{
ListBase tmp_modifiers = {NULL, NULL};
NlaStrip *strip = nes->strip;
@@ -2457,13 +2450,13 @@ static void nlastrip_evaluate_meta(PointerRNA *ptr, ListBase *channels, ListBase
/* find the child-strip to evaluate */
evaltime = (nes->strip_time * (strip->end - strip->start)) + strip->start;
- tmp_nes = nlastrips_ctime_get_strip(NULL, &strip->strips, -1, evaltime);
+ tmp_nes = nlastrips_ctime_get_strip(depsgraph, NULL, &strip->strips, -1, evaltime);
/* directly evaluate child strip into accumulation buffer...
* - there's no need to use a temporary buffer (as it causes issues [T40082])
*/
if (tmp_nes) {
- nlastrip_evaluate(ptr, channels, &tmp_modifiers, tmp_nes);
+ nlastrip_evaluate(depsgraph, ptr, channels, &tmp_modifiers, tmp_nes);
/* free temp eval-strip */
MEM_freeN(tmp_nes);
@@ -2474,7 +2467,7 @@ static void nlastrip_evaluate_meta(PointerRNA *ptr, ListBase *channels, ListBase
}
/* evaluates the given evaluation strip */
-void nlastrip_evaluate(PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
+void nlastrip_evaluate(Depsgraph *depsgraph, PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
{
NlaStrip *strip = nes->strip;
@@ -2492,10 +2485,10 @@ void nlastrip_evaluate(PointerRNA *ptr, ListBase *channels, ListBase *modifiers,
nlastrip_evaluate_actionclip(ptr, channels, modifiers, nes);
break;
case NLASTRIP_TYPE_TRANSITION: /* transition */
- nlastrip_evaluate_transition(ptr, channels, modifiers, nes);
+ nlastrip_evaluate_transition(depsgraph, ptr, channels, modifiers, nes);
break;
case NLASTRIP_TYPE_META: /* meta */
- nlastrip_evaluate_meta(ptr, channels, modifiers, nes);
+ nlastrip_evaluate_meta(depsgraph, ptr, channels, modifiers, nes);
break;
default: /* do nothing */
@@ -2561,7 +2554,7 @@ void nladata_flush_channels(ListBase *channels)
*
* \param[out] echannels Evaluation channels with calculated values
*/
-static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData *adt, float ctime)
+static void animsys_evaluate_nla(Depsgraph *depsgraph, ListBase *echannels, PointerRNA *ptr, AnimData *adt, float ctime)
{
NlaTrack *nlt;
short track_index = 0;
@@ -2599,7 +2592,7 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData
has_strips = true;
/* otherwise, get strip to evaluate for this channel */
- nes = nlastrips_ctime_get_strip(&estrips, &nlt->strips, track_index, ctime);
+ nes = nlastrips_ctime_get_strip(depsgraph, &estrips, &nlt->strips, track_index, ctime);
if (nes) nes->track = nlt;
}
@@ -2640,14 +2633,14 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData
}
/* add this to our list of evaluation strips */
- nlastrips_ctime_get_strip(&estrips, &dummy_trackslist, -1, ctime);
+ nlastrips_ctime_get_strip(depsgraph, &estrips, &dummy_trackslist, -1, ctime);
}
else {
/* special case - evaluate as if there isn't any NLA data */
/* TODO: this is really just a stop-gap measure... */
if (G.debug & G_DEBUG) printf("NLA Eval: Stopgap for active action on NLA Stack - no strips case\n");
- animsys_evaluate_action(ptr, adt->action, adt->remap, ctime);
+ animsys_evaluate_action(depsgraph, ptr, adt->action, adt->remap, ctime);
BLI_freelistN(&estrips);
return;
}
@@ -2660,17 +2653,17 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData
/* 2. for each strip, evaluate then accumulate on top of existing channels, but don't set values yet */
for (nes = estrips.first; nes; nes = nes->next)
- nlastrip_evaluate(ptr, echannels, NULL, nes);
+ nlastrip_evaluate(depsgraph, ptr, echannels, NULL, nes);
/* 3. free temporary evaluation data that's not used elsewhere */
BLI_freelistN(&estrips);
}
/* NLA Evaluation function (mostly for use through do_animdata)
- * - All channels that will be affected are not cleared anymore. Instead, we just evaluate into
+ * - All channels that will be affected are not cleared anymore. Instead, we just evaluate into
* some temp channels, where values can be accumulated in one go.
*/
-static void animsys_calculate_nla(PointerRNA *ptr, AnimData *adt, float ctime)
+static void animsys_calculate_nla(Depsgraph *depsgraph, PointerRNA *ptr, AnimData *adt, float ctime)
{
ListBase echannels = {NULL, NULL};
@@ -2678,7 +2671,7 @@ static void animsys_calculate_nla(PointerRNA *ptr, AnimData *adt, float ctime)
* and also when the user jumps between different times instead of moving sequentially... */
/* evaluate the NLA stack, obtaining a set of values to flush */
- animsys_evaluate_nla(&echannels, ptr, adt, ctime);
+ animsys_evaluate_nla(depsgraph, &echannels, ptr, adt, ctime);
/* flush effects of accumulating channels in NLA to the actual data they affect */
nladata_flush_channels(&echannels);
@@ -2721,7 +2714,7 @@ static void animsys_evaluate_overrides(PointerRNA *ptr, AnimData *adt)
/* Evaluation System - Public API */
/* Overview of how this system works:
- * 1) Depsgraph sorts data as necessary, so that data is in an order that means
+ * 1) Depsgraph sorts data as necessary, so that data is in an order that means
* that all dependencies are resolved before dependents.
* 2) All normal animation is evaluated, so that drivers have some basis values to
* work with
@@ -2729,35 +2722,35 @@ static void animsys_evaluate_overrides(PointerRNA *ptr, AnimData *adt)
* which modify the effects of the NLA-stacks
* b. Active Action is evaluated as per normal, on top of the results of the NLA tracks
*
- * --------------< often in a separate phase... >------------------
+ * --------------< often in a separate phase... >------------------
*
* 3) Drivers/expressions are evaluated on top of this, in an order where dependencies are
- * resolved nicely.
+ * resolved nicely.
* Note: it may be necessary to have some tools to handle the cases where some higher-level
* drivers are added and cause some problematic dependencies that didn't exist in the local levels...
*
- * --------------< always executed >------------------
+ * --------------< always executed >------------------
*
* Maintenance of editability of settings (XXX):
* In order to ensure that settings that are animated can still be manipulated in the UI without requiring
- * that keyframes are added to prevent these values from being overwritten, we use 'overrides'.
+ * that keyframes are added to prevent these values from being overwritten, we use 'overrides'.
*
* Unresolved things:
* - Handling of multi-user settings (i.e. time-offset, group-instancing) -> big cache grids or nodal system? but stored where?
- * - Multiple-block dependencies (i.e. drivers for settings are in both local and higher levels) -> split into separate lists?
+ * - Multiple-block dependencies (i.e. drivers for settings are in both local and higher levels) -> split into separate lists?
*
* Current Status:
- * - Currently (as of September 2009), overrides we haven't needed to (fully) implement overrides.
+ * - Currently (as of September 2009), overrides we haven't needed to (fully) implement overrides.
* However, the code for this is relatively harmless, so is left in the code for now.
*/
/* Evaluation loop for evaluation animation data
*
* This assumes that the animation-data provided belongs to the ID block in question,
- * and that the flags for which parts of the anim-data settings need to be recalculated
- * have been set already by the depsgraph. Now, we use the recalc
+ * and that the flags for which parts of the anim-data settings need to be recalculated
+ * have been set already by the depsgraph. Now, we use the recalc
*/
-void BKE_animsys_evaluate_animdata(Scene *scene, ID *id, AnimData *adt, float ctime, short recalc)
+void BKE_animsys_evaluate_animdata(Depsgraph *depsgraph, Scene *scene, ID *id, AnimData *adt, float ctime, short recalc)
{
PointerRNA id_ptr;
@@ -2779,11 +2772,11 @@ void BKE_animsys_evaluate_animdata(Scene *scene, ID *id, AnimData *adt, float ct
/* evaluate NLA-stack
* - active action is evaluated as part of the NLA stack as the last item
*/
- animsys_calculate_nla(&id_ptr, adt, ctime);
+ animsys_calculate_nla(depsgraph, &id_ptr, adt, ctime);
}
/* evaluate Active Action only */
else if (adt->action)
- animsys_evaluate_action_ex(&id_ptr, adt->action, adt->remap, ctime, recalc);
+ animsys_evaluate_action_ex(depsgraph, &id_ptr, adt->action, adt->remap, ctime);
/* reset tag */
adt->recalc &= ~ADT_RECALC_ANIM;
@@ -2827,7 +2820,7 @@ void BKE_animsys_evaluate_animdata(Scene *scene, ID *id, AnimData *adt, float ct
* 'local' (i.e. belonging in the nearest ID-block that setting is related to, not a
* standard 'root') block are overridden by a larger 'user'
*/
-void BKE_animsys_evaluate_all_animation(Main *main, Scene *scene, float ctime)
+void BKE_animsys_evaluate_all_animation(Main *main, Depsgraph *depsgraph, Scene *scene, float ctime)
{
ID *id;
@@ -2843,7 +2836,7 @@ void BKE_animsys_evaluate_all_animation(Main *main, Scene *scene, float ctime)
for (id = first; id; id = id->next) { \
if (ID_REAL_USERS(id) > 0) { \
AnimData *adt = BKE_animdata_from_id(id); \
- BKE_animsys_evaluate_animdata(scene, id, adt, ctime, aflag); \
+ BKE_animsys_evaluate_animdata(depsgraph, scene, id, adt, ctime, aflag); \
} \
} (void)0
@@ -2860,9 +2853,9 @@ void BKE_animsys_evaluate_all_animation(Main *main, Scene *scene, float ctime)
NtId_Type *ntp = (NtId_Type *)id; \
if (ntp->nodetree) { \
AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \
- BKE_animsys_evaluate_animdata(scene, (ID *)ntp->nodetree, adt2, ctime, ADT_RECALC_ANIM); \
+ BKE_animsys_evaluate_animdata(depsgraph, scene, (ID *)ntp->nodetree, adt2, ctime, ADT_RECALC_ANIM); \
} \
- BKE_animsys_evaluate_animdata(scene, id, adt, ctime, aflag); \
+ BKE_animsys_evaluate_animdata(depsgraph, scene, id, adt, ctime, aflag); \
} \
} (void)0
@@ -2963,44 +2956,48 @@ void BKE_animsys_eval_animdata(Depsgraph *depsgraph, ID *id)
*/
DEG_debug_print_eval_time(depsgraph, __func__, id->name, id, ctime);
short recalc = ADT_RECALC_ANIM;
- const Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
- /* If animation component is directly tagged for update, we always apply f-curves. */
- if (((scene_eval->id.recalc & ID_RECALC_TIME) == 0) &&
- (id->recalc & ID_RECALC_TIME) == 0)
- {
- recalc |= ADT_RECALC_CHECK_ORIG_DNA;
- }
- BKE_animsys_evaluate_animdata(scene, id, adt, ctime, recalc);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, id, adt, ctime, recalc);
}
-/* TODO(sergey): This is slow lookup of driver from CoW datablock.
- * Keep this for until we've got something smarter for depsgraph
- * building.\
- */
-static FCurve *find_driver_from_evaluated_id(ID *id, FCurve *fcu)
+void BKE_animsys_update_driver_array(ID *id)
{
- /* We've got non-CoW datablock, can use f-curve as-is. */
- if (id->orig_id == NULL) {
- return fcu;
+ AnimData *adt = BKE_animdata_from_id(id);
+
+ /* Runtime driver map to avoid O(n^2) lookups in BKE_animsys_eval_driver.
+ * Ideally the depsgraph could pass a pointer to the COW driver directly,
+ * but this is difficult in the current design. */
+ if (adt && adt->drivers.first) {
+ BLI_assert(!adt->driver_array);
+
+ int num_drivers = BLI_listbase_count(&adt->drivers);
+ adt->driver_array = MEM_mallocN(sizeof(FCurve *) * num_drivers, "adt->driver_array");
+
+ int driver_index = 0;
+ for (FCurve *fcu = adt->drivers.first; fcu; fcu = fcu->next) {
+ adt->driver_array[driver_index++] = fcu;
+ }
}
- /*const*/ ID *id_orig = id->orig_id;
- const AnimData *adt_orig = BKE_animdata_from_id(id_orig);
- const AnimData *adt_cow = BKE_animdata_from_id(id);
- const int fcu_index = BLI_findindex(&adt_orig->drivers, fcu);
- BLI_assert(fcu_index != -1);
- return BLI_findlink(&adt_cow->drivers, fcu_index);
}
void BKE_animsys_eval_driver(Depsgraph *depsgraph,
ID *id,
- FCurve *fcu)
+ int driver_index,
+ ChannelDriver *driver_orig)
{
/* TODO(sergey): De-duplicate with BKE animsys. */
- ChannelDriver *driver = fcu->driver;
PointerRNA id_ptr;
bool ok = false;
- fcu = find_driver_from_evaluated_id(id, fcu);
+ /* Lookup driver, accelerated with driver array map. */
+ const AnimData *adt = BKE_animdata_from_id(id);
+ FCurve *fcu;
+
+ if (adt->driver_array) {
+ fcu = adt->driver_array[driver_index];
+ }
+ else {
+ fcu = BLI_findlink(&adt->drivers, driver_index);
+ }
DEG_debug_print_eval_subdata_index(
depsgraph, __func__, id->name, id, "fcu", fcu->rna_path, fcu, fcu->array_index);
@@ -3011,7 +3008,7 @@ void BKE_animsys_eval_driver(Depsgraph *depsgraph,
if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) {
/* check if driver itself is tagged for recalculation */
/* XXX driver recalc flag is not set yet by depsgraph! */
- if ((driver) && !(driver->flag & DRIVER_FLAG_INVALID) /*&& (driver->flag & DRIVER_FLAG_RECALC)*/) {
+ if ((driver_orig) && !(driver_orig->flag & DRIVER_FLAG_INVALID) /*&& (driver_orig->flag & DRIVER_FLAG_RECALC)*/) {
/* evaluate this using values set already in other places
* 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 */
@@ -3022,17 +3019,20 @@ void BKE_animsys_eval_driver(Depsgraph *depsgraph,
const float ctime = DEG_get_ctime(depsgraph);
const float curval = calculate_fcurve(&anim_rna, fcu, ctime);
ok = animsys_write_rna_setting(&anim_rna, curval);
+ if (ok && DEG_is_active(depsgraph)) {
+ animsys_write_orig_anim_rna(&id_ptr, NULL, fcu, curval);
+ }
}
//printf("\tnew val = %f\n", fcu->curval);
/* clear recalc flag */
- driver->flag &= ~DRIVER_FLAG_RECALC;
+ driver_orig->flag &= ~DRIVER_FLAG_RECALC;
/* set error-flag if evaluation failed */
if (ok == 0) {
printf("invalid driver - %s[%d]\n", fcu->rna_path, fcu->array_index);
- driver->flag |= DRIVER_FLAG_INVALID;
+ driver_orig->flag |= DRIVER_FLAG_INVALID;
}
}
}
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index 2054442250e..3b2534eae73 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -718,13 +718,13 @@ bool BKE_appdir_app_template_id_search(const char *app_template, char *path, siz
/**
* Gets the temp directory when blender first runs.
* If the default path is not found, use try $TEMP
- *
+ *
* Also make sure the temp dir has a trailing slash
*
* \param fullname The full path to the temporary temp directory
* \param basename The full path to the persistent temp directory (may be NULL)
* \param maxlen The size of the fullname buffer
- * \param userdir Directory specified in user preferences
+ * \param userdir Directory specified in user preferences
*/
static void where_is_temp(char *fullname, char *basename, const size_t maxlen, char *userdir)
{
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index bf21019a948..ce99da87c74 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -688,6 +688,13 @@ void BKE_pose_bone_done(struct Depsgraph *depsgraph,
invert_m4_m4(imat, pchan->bone->arm_mat);
mul_m4_m4m4(pchan->chan_mat, pchan->pose_mat, imat);
}
+ if (DEG_is_active(depsgraph)) {
+ bPoseChannel *pchan_orig = pchan->orig_pchan;
+ copy_m4_m4(pchan_orig->pose_mat, pchan->pose_mat);
+ copy_m4_m4(pchan_orig->chan_mat, pchan->chan_mat);
+ copy_v3_v3(pchan_orig->pose_head, pchan->pose_mat[3]);
+ BKE_pose_where_is_bone_tail(pchan_orig);
+ }
}
void BKE_pose_iktree_evaluate(struct Depsgraph *depsgraph,
diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c
index 98482bcc8b1..857fc72672c 100644
--- a/source/blender/blenkernel/intern/blender_undo.c
+++ b/source/blender/blenkernel/intern/blender_undo.c
@@ -67,10 +67,11 @@
bool BKE_memfile_undo_decode(MemFileUndoData *mfu, bContext *C)
{
- char mainstr[sizeof(G.main->name)];
+ Main *bmain = CTX_data_main(C);
+ char mainstr[sizeof(bmain->name)];
int success = 0, fileflags;
- BLI_strncpy(mainstr, G.main->name, sizeof(mainstr)); /* temporal store */
+ BLI_strncpy(mainstr, BKE_main_blendfile_path(bmain), sizeof(mainstr)); /* temporal store */
fileflags = G.fileflags;
G.fileflags |= G_FILE_NO_UI;
@@ -82,13 +83,14 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, bContext *C)
success = BKE_blendfile_read_from_memfile(C, &mfu->memfile, NULL, 0);
}
- /* restore */
- BLI_strncpy(G.main->name, mainstr, sizeof(G.main->name)); /* restore */
+ /* Restore, bmain has been re-allocated. */
+ bmain = CTX_data_main(C);
+ BLI_strncpy(bmain->name, mainstr, sizeof(bmain->name));
G.fileflags = fileflags;
if (success) {
/* important not to update time here, else non keyed tranforms are lost */
- DEG_on_visible_update(G.main, false);
+ DEG_on_visible_update(bmain, false);
}
return success;
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 34079d778f7..597c69408b5 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -116,6 +116,7 @@ static void setup_app_data(
bContext *C, BlendFileData *bfd,
const char *filepath, ReportList *reports)
{
+ Main *bmain = G.main; /* Valid usage */
Scene *curscene = NULL;
const bool is_startup = (bfd->filename[0] == '\0');
const bool recover = (G.fileflags & G_FILE_RECOVER) != 0;
@@ -172,9 +173,9 @@ static void setup_app_data(
bool track_undo_scene;
/* comes from readfile.c */
- SWAP(ListBase, G.main->wm, bfd->main->wm);
- SWAP(ListBase, G.main->workspaces, bfd->main->workspaces);
- SWAP(ListBase, G.main->screen, bfd->main->screen);
+ SWAP(ListBase, bmain->wm, bfd->main->wm);
+ SWAP(ListBase, bmain->workspaces, bfd->main->workspaces);
+ SWAP(ListBase, bmain->screen, bfd->main->screen);
/* we re-use current window and screen */
win = CTX_wm_window(C);
@@ -236,9 +237,9 @@ static void setup_app_data(
/* clear old property update cache, in case some old references are left dangling */
RNA_property_update_cache_free();
- G.main = bfd->main;
+ bmain = G.main = bfd->main;
- CTX_data_main_set(C, G.main);
+ CTX_data_main_set(C, bmain);
if (bfd->user) {
@@ -266,7 +267,7 @@ static void setup_app_data(
/* Keep state from preferences. */
const int fileflags_skip = G_FILE_FLAGS_RUNTIME;
G.fileflags = (G.fileflags & fileflags_skip) | (bfd->fileflags & ~fileflags_skip);
- CTX_wm_manager_set(C, G.main->wm.first);
+ CTX_wm_manager_set(C, bmain->wm.first);
CTX_wm_screen_set(C, bfd->curscreen);
CTX_data_scene_set(C, bfd->curscene);
CTX_wm_area_set(C, NULL);
@@ -280,10 +281,10 @@ static void setup_app_data(
wmWindow *win = CTX_wm_window(C);
/* in case we don't even have a local scene, add one */
- if (!G.main->scene.first)
- BKE_scene_add(G.main, "Empty");
+ if (!bmain->scene.first)
+ BKE_scene_add(bmain, "Empty");
- CTX_data_scene_set(C, G.main->scene.first);
+ CTX_data_scene_set(C, bmain->scene.first);
win->scene = CTX_data_scene(C);
curscene = CTX_data_scene(C);
}
@@ -307,35 +308,35 @@ static void setup_app_data(
/* FIXME: this version patching should really be part of the file-reading code,
* but we still get too many unrelated data-corruption crashes otherwise... */
- if (G.main->versionfile < 250)
- do_versions_ipos_to_animato(G.main);
+ if (bmain->versionfile < 250)
+ do_versions_ipos_to_animato(bmain);
- G.main->recovered = 0;
+ bmain->recovered = 0;
/* startup.blend or recovered startup */
if (bfd->filename[0] == 0) {
- G.main->name[0] = 0;
+ bmain->name[0] = '\0';
}
else if (recover && G.relbase_valid) {
/* in case of autosave or quit.blend, use original filename instead
* use relbase_valid to make sure the file is saved, else we get <memory2> in the filename */
filepath = bfd->filename;
- G.main->recovered = 1;
+ bmain->recovered = 1;
/* these are the same at times, should never copy to the same location */
- if (G.main->name != filepath)
- BLI_strncpy(G.main->name, filepath, FILE_MAX);
+ if (bmain->name != filepath)
+ BLI_strncpy(bmain->name, filepath, FILE_MAX);
}
/* baseflags, groups, make depsgraph, etc */
/* first handle case if other windows have different scenes visible */
if (mode == LOAD_UI) {
- wmWindowManager *wm = G.main->wm.first;
+ wmWindowManager *wm = bmain->wm.first;
if (wm) {
for (wmWindow *win = wm->windows.first; win; win = win->next) {
if (win->scene && win->scene != curscene) {
- BKE_scene_set_background(G.main, win->scene);
+ BKE_scene_set_background(bmain, win->scene);
}
}
}
@@ -346,10 +347,10 @@ static void setup_app_data(
* constructing dependency graph.
*/
if (mode != LOAD_UNDO) {
- IMB_colormanagement_check_file_config(G.main);
+ IMB_colormanagement_check_file_config(bmain);
}
- BKE_scene_set_background(G.main, curscene);
+ BKE_scene_set_background(bmain, curscene);
if (mode != LOAD_UNDO) {
/* TODO(sergey): Can this be also move above? */
@@ -431,9 +432,10 @@ bool BKE_blendfile_read_from_memfile(
bContext *C, struct MemFile *memfile,
ReportList *reports, int skip_flags)
{
+ Main *bmain = CTX_data_main(C);
BlendFileData *bfd;
- bfd = BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports, skip_flags);
+ bfd = BLO_read_from_memfile(bmain, BKE_main_blendfile_path(bmain), memfile, reports, skip_flags);
if (bfd) {
/* remove the unused screens and wm */
while (bfd->main->wm.first)
diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index dbaf3f2ee9e..7c9e57b039e 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -325,7 +325,7 @@ void BKE_bpath_missing_files_find(Main *bmain, const char *searchpath, ReportLis
struct BPathFind_Data data = {NULL};
const int flag = BKE_BPATH_TRAVERSE_ABS | BKE_BPATH_TRAVERSE_RELOAD_EDITED;
- data.basedir = bmain->name;
+ data.basedir = BKE_main_blendfile_path(bmain);
data.reports = reports;
data.searchdir = searchpath;
data.find_all = find_all;
@@ -442,7 +442,7 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
/* image may have been painted onto (and not saved, T44543) */
!BKE_image_is_dirty(ima))
{
- BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
+ BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_RELOAD);
BKE_image_walk_all_users(bmain, ima, bpath_traverse_image_user_cb);
}
}
@@ -643,7 +643,7 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
/* keep packedfile paths always relative to the blend */
if (lib->packedfile == NULL) {
if (rewrite_path_fixed(lib->name, visit_cb, absbase, bpath_user_data)) {
- BKE_library_filepath_set(lib, lib->name);
+ BKE_library_filepath_set(bmain, lib, lib->name);
}
}
break;
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index d82c1ca56fe..7f50e521e63 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -457,68 +457,6 @@ void BKE_brush_curve_preset(Brush *b, eCurveMappingPreset preset)
curvemapping_changed(b->curve, false);
}
-/* XXX Unused function. */
-int BKE_brush_texture_set_nr(Brush *brush, int nr)
-{
- ID *idtest, *id = NULL;
-
- id = (ID *)brush->mtex.tex;
-
- idtest = (ID *)BLI_findlink(&G.main->tex, nr - 1);
- if (idtest == NULL) { /* new tex */
- if (id) idtest = (ID *)BKE_texture_copy(G.main, (Tex *)id);
- else idtest = (ID *)BKE_texture_add(G.main, "Tex");
- id_us_min(idtest);
- }
- if (idtest != id) {
- BKE_brush_texture_delete(brush);
-
- brush->mtex.tex = (Tex *)idtest;
- id_us_plus(idtest);
-
- return 1;
- }
-
- return 0;
-}
-
-int BKE_brush_texture_delete(Brush *brush)
-{
- if (brush->mtex.tex)
- id_us_min(&brush->mtex.tex->id);
-
- return 1;
-}
-
-int BKE_brush_clone_image_set_nr(Brush *brush, int nr)
-{
- if (brush && nr > 0) {
- Image *ima = (Image *)BLI_findlink(&G.main->image, nr - 1);
-
- if (ima) {
- BKE_brush_clone_image_delete(brush);
- brush->clone.image = ima;
- id_us_plus(&ima->id);
- brush->clone.offset[0] = brush->clone.offset[1] = 0.0f;
-
- return 1;
- }
- }
-
- return 0;
-}
-
-int BKE_brush_clone_image_delete(Brush *brush)
-{
- if (brush && brush->clone.image) {
- id_us_min(&brush->clone.image->id);
- brush->clone.image = NULL;
- return 1;
- }
-
- return 0;
-}
-
/* Generic texture sampler for 3D painting systems. point has to be either in
* region space mouse coordinates, or 3d world coordinates for 3D mapping.
*
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index b3ea3de6ea9..e8328139d64 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -45,6 +45,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_editmesh.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "MEM_guardedalloc.h"
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index 8f156e8f267..74c0dca6279 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -89,13 +89,22 @@ void BKE_cachefile_free(CacheFile *cache_file)
{
BKE_animdata_free((ID *)cache_file, false);
+ if (cache_file->id.tag & LIB_TAG_NO_MAIN) {
+ /* CoW/no-main copies reuse the existing ArchiveReader and mutex */
+ return;
+ }
+
+ if (cache_file->handle) {
#ifdef WITH_ALEMBIC
- ABC_free_handle(cache_file->handle);
+ ABC_free_handle(cache_file->handle);
#endif
-
+ cache_file->handle = NULL;
+ }
if (cache_file->handle_mutex) {
BLI_mutex_free(cache_file->handle_mutex);
+ cache_file->handle_mutex = NULL;
}
+
BLI_freelistN(&cache_file->object_paths);
}
@@ -110,8 +119,14 @@ void BKE_cachefile_free(CacheFile *cache_file)
void BKE_cachefile_copy_data(
Main *UNUSED(bmain), CacheFile *cache_file_dst, const CacheFile *UNUSED(cache_file_src), const int UNUSED(flag))
{
+ if (cache_file_dst->id.tag & LIB_TAG_NO_MAIN) {
+ /* CoW/no-main copies reuse the existing ArchiveReader and mutex */
+ return;
+ }
+
cache_file_dst->handle = NULL;
- BLI_listbase_clear(&cache_file_dst->object_paths);
+ cache_file_dst->handle_mutex = NULL;
+ BLI_duplicatelist(&cache_file_dst->object_paths, &cache_file_dst->object_paths);
}
CacheFile *BKE_cachefile_copy(Main *bmain, const CacheFile *cache_file)
@@ -153,20 +168,24 @@ void BKE_cachefile_ensure_handle(const Main *bmain, CacheFile *cache_file)
BLI_mutex_lock(cache_file->handle_mutex);
if (cache_file->handle == NULL) {
+ /* Assigning to a CoW copy is a bad idea; assign to the original instead. */
+ BLI_assert((cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0);
BKE_cachefile_reload(bmain, cache_file);
}
BLI_mutex_unlock(cache_file->handle_mutex);
}
-void BKE_cachefile_update_frame(Main *bmain, Scene *scene, const float ctime, const float fps)
+void BKE_cachefile_update_frame(
+ Main *bmain, struct Depsgraph *depsgraph, Scene *scene,
+ const float ctime, const float fps)
{
CacheFile *cache_file;
char filename[FILE_MAX];
for (cache_file = bmain->cachefiles.first; cache_file; cache_file = cache_file->id.next) {
/* Execute drivers only, as animation has already been done. */
- BKE_animsys_evaluate_animdata(scene, &cache_file->id, cache_file->adt, ctime, ADT_RECALC_DRIVERS);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &cache_file->id, cache_file->adt, ctime, ADT_RECALC_DRIVERS);
if (!cache_file->is_sequence) {
continue;
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 19d1d1e0ede..7bcc05b0e37 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -46,6 +46,7 @@
#include "BKE_global.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
+#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_editmesh.h"
#include "BKE_curve.h"
@@ -289,7 +290,7 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
* this derivedmesh is just original mesh. it's the multires subsurf dm
* that this is actually for, to support a pbvh on a modified mesh */
if (!cddm->pbvh && ob->type == OB_MESH) {
- Mesh *me = ob->data;
+ Mesh *me = BKE_object_get_original_mesh(ob);
const int looptris_num = poly_to_tri_count(me->totpoly, me->totloop);
MLoopTri *looptri;
bool deformed;
@@ -324,7 +325,7 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
totvert = deformdm->getNumVerts(deformdm);
vertCos = MEM_malloc_arrayN(totvert, sizeof(float[3]), "cdDM_getPBVH vertCos");
deformdm->getVertCos(deformdm, vertCos);
- BKE_pbvh_apply_vertCos(cddm->pbvh, vertCos);
+ BKE_pbvh_apply_vertCos(cddm->pbvh, vertCos, totvert);
MEM_freeN(vertCos);
}
}
@@ -597,7 +598,7 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh)
return CDDM_from_mesh_ex(mesh, CD_REFERENCE, CD_MASK_MESH);
}
-DerivedMesh *CDDM_from_mesh_ex(Mesh *mesh, int alloctype, CustomDataMask mask)
+DerivedMesh *CDDM_from_mesh_ex(Mesh *mesh, eCDAllocType alloctype, CustomDataMask mask)
{
CDDerivedMesh *cddm = cdDM_create(__func__);
DerivedMesh *dm = &cddm->dm;
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index a39de284064..cc1c7260cbc 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -48,7 +48,7 @@
#include "BKE_cloth.h"
#include "BKE_effect.h"
#include "BKE_global.h"
-#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_pointcache.h"
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index c4709a32f78..ab0ec8b0491 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -59,7 +59,7 @@
static bool collection_child_add(Collection *parent, Collection *collection, int flag, const bool add_us);
static bool collection_child_remove(Collection *parent, Collection *collection);
-static bool collection_object_add(Collection *collection, Object *ob, int flag, const bool add_us);
+static bool collection_object_add(Main *bmain, Collection *collection, Object *ob, int flag, const bool add_us);
static bool collection_object_remove(Main *bmain, Collection *collection, Object *ob, const bool free_us);
static CollectionChild *collection_find_child(Collection *parent, Collection *collection);
@@ -163,7 +163,7 @@ bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy)
/* Link child object into parent collections. */
for (CollectionParent *cparent = collection->parents.first; cparent; cparent = cparent->next) {
Collection *parent = cparent->collection;
- collection_object_add(parent, cob->ob, 0, true);
+ collection_object_add(bmain, parent, cob->ob, 0, true);
}
/* Remove child object. */
@@ -190,7 +190,7 @@ bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy)
* \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
*/
void BKE_collection_copy_data(
- Main *UNUSED(bmain), Collection *collection_dst, const Collection *collection_src, const int flag)
+ Main *bmain, Collection *collection_dst, const Collection *collection_src, const int flag)
{
/* Do not copy collection's preview (same behavior as for objects). */
if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0 && false) { /* XXX TODO temp hack */
@@ -211,7 +211,7 @@ void BKE_collection_copy_data(
collection_child_add(collection_dst, child->collection, flag, false);
}
for (CollectionObject *cob = collection_src->gobject.first; cob; cob = cob->next) {
- collection_object_add(collection_dst, cob->ob, flag, false);
+ collection_object_add(bmain, collection_dst, cob->ob, flag, false);
}
}
@@ -311,23 +311,6 @@ bool BKE_collection_is_animated(Collection *collection, Object *UNUSED(parent))
return false;
}
-/* puts all collection members in local timing system, after this call
- * you can draw everything, leaves tags in objects to signal it needs further updating */
-
-/* note: does not work for derivedmesh and render... it recreates all again in convertblender.c */
-void BKE_collection_handle_recalc_and_update(
- struct Depsgraph *depsgraph, Scene *scene, Object *UNUSED(parent), Collection *collection)
-{
- /* only do existing tags, as set by regular depsgraph */
- FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(collection, object)
- {
- if (object->id.recalc & ID_RECALC_ALL) {
- BKE_object_handle_update(depsgraph, scene, object);
- }
- }
- FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
-}
-
/* **************** Object List Cache *******************/
static void collection_object_cache_fill(ListBase *lb, Collection *collection, int parent_restrict)
@@ -367,12 +350,12 @@ ListBase BKE_collection_object_cache_get(Collection *collection)
if (!(collection->flag & COLLECTION_HAS_OBJECT_CACHE)) {
static ThreadMutex cache_lock = BLI_MUTEX_INITIALIZER;
+ BLI_mutex_lock(&cache_lock);
if (!(collection->flag & COLLECTION_HAS_OBJECT_CACHE)) {
- BLI_mutex_lock(&cache_lock);
collection_object_cache_fill(&collection->object_cache, collection, 0);
collection->flag |= COLLECTION_HAS_OBJECT_CACHE;
- BLI_mutex_unlock(&cache_lock);
}
+ BLI_mutex_unlock(&cache_lock);
}
return collection->object_cache;
@@ -522,7 +505,7 @@ Collection *BKE_collection_object_find(Main *bmain, Collection *collection, Obje
/********************** Collection Objects *********************/
-static bool collection_object_add(Collection *collection, Object *ob, int flag, const bool add_us)
+static bool collection_object_add(Main *bmain, Collection *collection, Object *ob, int flag, const bool add_us)
{
if (ob->dup_group) {
/* Cyclic dependency check. */
@@ -545,6 +528,10 @@ static bool collection_object_add(Collection *collection, Object *ob, int flag,
id_us_plus(&ob->id);
}
+ if ((flag & LIB_ID_CREATE_NO_MAIN) == 0) {
+ DEG_id_tag_update_ex(bmain, &collection->id, DEG_TAG_COPY_ON_WRITE);
+ }
+
return true;
}
@@ -565,6 +552,8 @@ static bool collection_object_remove(Main *bmain, Collection *collection, Object
id_us_min(&ob->id);
}
+ DEG_id_tag_update_ex(bmain, &collection->id, DEG_TAG_COPY_ON_WRITE);
+
return true;
}
@@ -577,7 +566,7 @@ bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob)
return false;
}
- if (!collection_object_add(collection, ob, 0, true)) {
+ if (!collection_object_add(bmain, collection, ob, 0, true)) {
return false;
}
@@ -597,7 +586,7 @@ void BKE_collection_object_add_from(Main *bmain, Scene *scene, Object *ob_src, O
FOREACH_SCENE_COLLECTION_BEGIN(scene, collection)
{
if (BKE_collection_has_object(collection, ob_src)) {
- collection_object_add(collection, ob_dst, 0, true);
+ collection_object_add(bmain, collection, ob_dst, 0, true);
}
}
FOREACH_SCENE_COLLECTION_END;
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 337d1a1a149..6c97380b9ca 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 28c6fe852c2..fe60d53a9a2 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -103,7 +103,7 @@
/* ************************ Constraints - General Utilities *************************** */
/* These functions here don't act on any specific constraints, and are therefore should/will
- * not require any of the special function-pointers afforded by the relevant constraint
+ * not require any of the special function-pointers afforded by the relevant constraint
* type-info structs.
*/
@@ -654,7 +654,7 @@ static void constraint_target_to_mat4(Object *ob, const char *substring, float m
/* ************************* Specific Constraints ***************************** */
/* Each constraint defines a set of functions, which will be called at the appropriate
* times. In addition to this, each constraint should have a type-info struct, where
- * its functions are attached for use.
+ * its functions are attached for use.
*/
/* Template for type-info data:
@@ -663,7 +663,7 @@ static void constraint_target_to_mat4(Object *ob, const char *substring, float m
* - although the naming of functions doesn't matter, it would help for code
* readability, to follow the same naming convention as is presented here
* - any functions that a constraint doesn't need to define, don't define
- * for such cases, just use NULL
+ * for such cases, just use NULL
* - these should be defined after all the functions have been defined, so that
* forward-definitions/prototypes don't need to be used!
* - keep this copy #if-def'd so that future constraints can get based off this
@@ -3963,7 +3963,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
}
else {
- BKE_tracking_get_camera_object_matrix(cob->scene, camob_eval, mat);
+ BKE_tracking_get_camera_object_matrix(depsgraph, cob->scene, camob_eval, mat);
mul_m4_m4m4(cob->matrix, obmat, mat);
translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
@@ -3975,7 +3975,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
float aspect = (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp);
float len, d;
- BKE_object_where_is_calc_mat4(scene, camob_eval, mat);
+ BKE_object_where_is_calc_mat4(depsgraph, scene, camob_eval, mat);
/* camera axis */
vec[0] = 0.0f;
@@ -4238,7 +4238,7 @@ static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
float ctime = DEG_get_ctime(depsgraph);
float framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, ctime);
- BKE_object_where_is_calc_mat4(scene, camob, cammat);
+ BKE_object_where_is_calc_mat4(depsgraph, scene, camob, cammat);
BKE_tracking_camera_get_reconstructed_interpolate(tracking, object, framenr, mat);
@@ -4456,7 +4456,7 @@ static void con_unlink_refs_cb(bConstraint *UNUSED(con), ID **idpoin, bool is_re
/* Free data of a specific constraint if it has any info.
* be sure to run BIK_clear_data() when freeing an IK constraint,
- * unless DAG_relations_tag_update is called.
+ * unless DAG_relations_tag_update is called.
*/
void BKE_constraint_free_data_ex(bConstraint *con, bool do_id_user)
{
@@ -4805,7 +4805,7 @@ bool BKE_constraints_proxylocked_owner(Object *ob, bPoseChannel *pchan)
/* This function is a relic from the prior implementations of the constraints system, when all
* constraints either had one or no targets. It used to be called during the main constraint solving
- * loop, but is now only used for the remaining cases for a few constraints.
+ * loop, but is now only used for the remaining cases for a few constraints.
*
* None of the actual calculations of the matrices should be done here! Also, this function is
* not to be used by any new constraints, particularly any that have multiple targets.
@@ -4910,7 +4910,7 @@ void BKE_constraint_targets_for_solving_get(struct Depsgraph *depsgraph, bConstr
/* This function is called whenever constraints need to be evaluated. Currently, all
* constraints that can be evaluated are every time this gets run.
*
- * BKE_constraints_make_evalob and BKE_constraints_clear_evalob should be called before and
+ * BKE_constraints_make_evalob and BKE_constraints_clear_evalob should be called before and
* after running this function, to sort out cob
*/
void BKE_constraints_solve(struct Depsgraph *depsgraph, ListBase *conlist, bConstraintOb *cob, float ctime)
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 9c0ace2f654..aa67eafaa98 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -1397,8 +1397,9 @@ void customData_mask_layers__print(CustomDataMask mask)
/********************* CustomData functions *********************/
static void customData_update_offsets(CustomData *data);
-static CustomDataLayer *customData_add_layer__internal(CustomData *data, int type, int alloctype, void *layerdata,
- int totelem, const char *name);
+static CustomDataLayer *customData_add_layer__internal(
+ CustomData *data, int type, eCDAllocType alloctype, void *layerdata,
+ int totelem, const char *name);
void CustomData_update_typemap(CustomData *data)
{
@@ -1427,8 +1428,9 @@ static bool customdata_typemap_is_valid(const CustomData *data)
}
#endif
-bool CustomData_merge(const struct CustomData *source, struct CustomData *dest,
- CustomDataMask mask, int alloctype, int totelem)
+bool CustomData_merge(
+ const struct CustomData *source, struct CustomData *dest,
+ CustomDataMask mask, eCDAllocType alloctype, int totelem)
{
/*const LayerTypeInfo *typeInfo;*/
CustomDataLayer *layer, *newlayer;
@@ -1510,8 +1512,9 @@ void CustomData_realloc(CustomData *data, int totelem)
}
}
-void CustomData_copy(const struct CustomData *source, struct CustomData *dest,
- CustomDataMask mask, int alloctype, int totelem)
+void CustomData_copy(
+ const struct CustomData *source, struct CustomData *dest,
+ CustomDataMask mask, eCDAllocType alloctype, int totelem)
{
CustomData_reset(dest);
@@ -1810,8 +1813,9 @@ static int customData_resize(CustomData *data, int amount)
return 1;
}
-static CustomDataLayer *customData_add_layer__internal(CustomData *data, int type, int alloctype, void *layerdata,
- int totelem, const char *name)
+static CustomDataLayer *customData_add_layer__internal(
+ CustomData *data, int type, eCDAllocType alloctype, void *layerdata,
+ int totelem, const char *name)
{
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
int flag = 0, index = data->totlayer;
@@ -1898,8 +1902,9 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, int typ
return &data->layers[index];
}
-void *CustomData_add_layer(CustomData *data, int type, int alloctype,
- void *layerdata, int totelem)
+void *CustomData_add_layer(
+ CustomData *data, int type, eCDAllocType alloctype,
+ void *layerdata, int totelem)
{
CustomDataLayer *layer;
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
@@ -1915,8 +1920,9 @@ void *CustomData_add_layer(CustomData *data, int type, int alloctype,
}
/*same as above but accepts a name*/
-void *CustomData_add_layer_named(CustomData *data, int type, int alloctype,
- void *layerdata, int totelem, const char *name)
+void *CustomData_add_layer_named(
+ CustomData *data, int type, eCDAllocType alloctype,
+ void *layerdata, int totelem, const char *name)
{
CustomDataLayer *layer;
@@ -2673,7 +2679,7 @@ void CustomData_bmesh_init_pool(CustomData *data, int totelem, const char htype)
bool CustomData_bmesh_merge(
const CustomData *source, CustomData *dest,
- CustomDataMask mask, int alloctype, BMesh *bm, const char htype)
+ CustomDataMask mask, eCDAllocType alloctype, BMesh *bm, const char htype)
{
BMHeader *h;
BMIter iter;
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index 0451031c5b8..3639649eab5 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -50,6 +50,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_mesh_remap.h"
#include "BKE_object.h"
#include "BKE_object_deform.h"
diff --git a/source/blender/blenkernel/intern/data_transfer_intern.h b/source/blender/blenkernel/intern/data_transfer_intern.h
index 352eedc6ec2..1a543a1deb5 100644
--- a/source/blender/blenkernel/intern/data_transfer_intern.h
+++ b/source/blender/blenkernel/intern/data_transfer_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2014 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Bastien Montagne
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index fa996b8f73e..5e812d4e5d0 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -37,6 +37,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_curve_types.h"
+#include "DNA_mesh_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_vfont_types.h"
@@ -51,8 +52,11 @@
#include "BKE_displist.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_object.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
#include "BKE_mball.h"
#include "BKE_mball_tessellate.h"
+#include "BKE_mesh.h"
#include "BKE_curve.h"
#include "BKE_key.h"
#include "BKE_anim.h"
@@ -925,7 +929,7 @@ static void curve_calc_modifiers_post(
Curve *cu = ob->data;
int required_mode = 0, totvert = 0;
const bool editmode = (!for_render && (cu->editnurb || cu->editfont));
- DerivedMesh *dm = NULL, *ndm;
+ Mesh *modified = NULL, *mesh_applied;
float (*vertCos)[3] = NULL;
int useCache = !for_render;
ModifierApplyFlag app_flag = 0;
@@ -963,23 +967,21 @@ static void curve_calc_modifiers_post(
continue;
if (mti->type == eModifierTypeType_OnlyDeform ||
- (mti->type == eModifierTypeType_DeformOrConstruct && !dm))
+ (mti->type == eModifierTypeType_DeformOrConstruct && !modified))
{
- if (dm) {
+ if (modified) {
if (!vertCos) {
- totvert = dm->getNumVerts(dm);
- vertCos = MEM_mallocN(sizeof(*vertCos) * totvert, "dfmv");
- dm->getVertCos(dm, vertCos);
+ vertCos = BKE_mesh_vertexCos_get(modified, &totvert);
}
- modifier_deformVerts_DM_deprecated(md, &mectx_deform, dm, vertCos, totvert);
+ modifier_deformVerts(md, &mectx_deform, modified, vertCos, totvert);
}
else {
if (!vertCos) {
vertCos = displist_get_allverts(dispbase, &totvert);
}
- modifier_deformVerts_DM_deprecated(md, &mectx_deform, NULL, vertCos, totvert);
+ modifier_deformVerts(md, &mectx_deform, NULL, vertCos, totvert);
}
}
else {
@@ -991,13 +993,17 @@ static void curve_calc_modifiers_post(
break;
}
- if (dm) {
+ if (modified) {
if (vertCos) {
- DerivedMesh *tdm = CDDM_copy(dm);
- dm->release(dm);
- dm = tdm;
-
- CDDM_apply_vert_coords(dm, vertCos);
+ Mesh *temp_mesh;
+ BKE_id_copy_ex(NULL, &modified->id, (ID **)&temp_mesh,
+ LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW,
+ false);
+ BKE_id_free(NULL, modified);
+ modified = temp_mesh;
+
+ BKE_mesh_apply_vert_coords(modified, vertCos);
}
}
else {
@@ -1009,7 +1015,7 @@ static void curve_calc_modifiers_post(
curve_to_filledpoly(cu, nurb, dispbase);
}
- dm = CDDM_from_curve_displist(ob, dispbase);
+ modified = BKE_mesh_new_nomain_from_curve_displist(ob, dispbase);
}
if (vertCos) {
@@ -1018,26 +1024,31 @@ static void curve_calc_modifiers_post(
vertCos = NULL;
}
- ndm = modwrap_applyModifier(md, &mectx_apply, dm);
+ mesh_applied = modifier_applyModifier(md, &mectx_apply, modified);
- if (ndm) {
+ if (mesh_applied) {
/* Modifier returned a new derived mesh */
- if (dm && dm != ndm) /* Modifier */
- dm->release(dm);
- dm = ndm;
+ if (modified && modified != mesh_applied) /* Modifier */
+ BKE_id_free(NULL, modified);
+ modified = mesh_applied;
}
}
}
if (vertCos) {
- if (dm) {
- DerivedMesh *tdm = CDDM_copy(dm);
- dm->release(dm);
- dm = tdm;
+ if (modified) {
+ Mesh *temp_mesh;
+ BKE_id_copy_ex(NULL, &modified->id, (ID **)&temp_mesh,
+ LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW,
+ false);
+ BKE_id_free(NULL, modified);
+ modified = temp_mesh;
+
+ BKE_mesh_apply_vert_coords(modified, vertCos);
+ BKE_mesh_calc_normals_mapping_simple(modified);
- CDDM_apply_vert_coords(dm, vertCos);
- CDDM_calc_normals_mapping(dm);
MEM_freeN(vertCos);
}
else {
@@ -1048,22 +1059,27 @@ static void curve_calc_modifiers_post(
}
if (r_dm_final) {
- if (dm) {
+ if (modified) {
/* see: mesh_calc_modifiers */
- if (dm->getNumTessFaces(dm) == 0) {
- dm->recalcTessellation(dm);
+ if (modified->totface == 0) {
+ BKE_mesh_tessface_calc(modified);
}
/* Even if tessellation is not needed, some modifiers might have modified CD layers
* (like mloopcol or mloopuv), hence we have to update those. */
- else if (dm->dirty & DM_DIRTY_TESS_CDLAYERS) {
- DM_update_tessface_data(dm);
+ else if (modified->runtime.cd_dirty_vert & CD_MASK_TESSLOOPNORMAL) {
+ BKE_mesh_tessface_calc(modified);
}
- if (dm->type == DM_TYPE_CDDM) {
- CDDM_calc_normals_mapping_ex(dm, (dm->dirty & DM_DIRTY_NORMALS) ? false : true);
- }
+ /* XXX2.8(Sybren): make sure the face normals are recalculated as well */
+ BKE_mesh_ensure_normals(modified);
+
+ (*r_dm_final) = CDDM_from_mesh_ex(modified, CD_DUPLICATE, CD_MASK_MESH);
+ BKE_id_free(NULL, modified);
+ }
+ else {
+ (*r_dm_final) = NULL;
}
- (*r_dm_final) = dm;
+
}
}
@@ -1095,6 +1111,8 @@ static void displist_surf_indices(DispList *dl)
}
}
+/* XXX2.8(Sybren): unused function; impossible to test after porting to Mesh */
+#ifdef WITH_DERIVEDMESH_DEPRECATED_FUNCS
static DerivedMesh *create_orco_dm(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
DerivedMesh *dm;
@@ -1138,7 +1156,10 @@ static void add_orco_dm(Object *ob, DerivedMesh *dm, DerivedMesh *orcodm)
else
DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, orco);
}
+#endif
+/* XXX2.8(Sybren): unused function; impossible to test after porting to Mesh */
+#ifdef WITH_DERIVEDMESH_DEPRECATED_FUNCS
static void curve_calc_orcodm(
Depsgraph *depsgraph, Scene *scene, Object *ob, DerivedMesh *dm_final,
const bool for_render, const bool use_render_resolution)
@@ -1208,6 +1229,7 @@ static void curve_calc_orcodm(
orcodm->release(orcodm);
}
+#endif
void BKE_displist_make_surf(
Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase,
@@ -1816,6 +1838,8 @@ void BKE_displist_make_curveTypes_forOrco(
}
/* add Orco layer to the displist object which has got derived mesh and return orco */
+/* XXX2.8(Sybren): can be removed once DerivedMesh port is done */
+#ifdef WITH_DERIVEDMESH_DEPRECATED_FUNCS
float *BKE_displist_make_orco(
Depsgraph *depsgraph, Scene *scene, Object *ob, DerivedMesh *dm_final,
const bool for_render,
@@ -1838,6 +1862,7 @@ float *BKE_displist_make_orco(
return orco;
}
+#endif
void BKE_displist_minmax(ListBase *dispbase, float min[3], float max[3])
{
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index ee2ece48325..0b2c65a7b8d 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -3216,7 +3216,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam
BKE_image_path_ensure_ext_from_imtype(output_file, format);
/* Validate output file path */
- BLI_path_abs(output_file, G.main->name);
+ BLI_path_abs(output_file, BKE_main_blendfile_path_from_global());
BLI_make_existing_file(output_file);
/* Init image buffer */
@@ -3645,7 +3645,7 @@ static void dynamic_paint_brush_velocity_compute_cb(
}
static void dynamicPaint_brushMeshCalculateVelocity(
- struct Depsgraph *depsgraph, Scene *scene,
+ Depsgraph *depsgraph, Scene *scene,
Object *ob, DynamicPaintBrushSettings *brush, Vec3f **brushVel, float timescale)
{
float prev_obmat[4][4];
@@ -3710,7 +3710,8 @@ static void dynamicPaint_brushMeshCalculateVelocity(
}
/* calculate velocity for object center point */
-static void dynamicPaint_brushObjectCalculateVelocity(struct Depsgraph *depsgraph, Scene *scene, Object *ob, Vec3f *brushVel, float timescale)
+static void dynamicPaint_brushObjectCalculateVelocity(
+ Depsgraph *depsgraph, Scene *scene, Object *ob, Vec3f *brushVel, float timescale)
{
float prev_obmat[4][4];
float cur_loc[3] = {0.0f}, prev_loc[3] = {0.0f};
@@ -4096,7 +4097,7 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(
}
}
-static int dynamicPaint_paintMesh(struct Depsgraph *depsgraph, DynamicPaintSurface *surface,
+static int dynamicPaint_paintMesh(Depsgraph *depsgraph, DynamicPaintSurface *surface,
DynamicPaintBrushSettings *brush,
Object *brushOb,
Scene *scene,
@@ -4584,7 +4585,7 @@ static void dynamic_paint_paint_single_point_cb_ex(
}
static int dynamicPaint_paintSinglePoint(
- struct Depsgraph *depsgraph, DynamicPaintSurface *surface, float *pointCoord, DynamicPaintBrushSettings *brush,
+ Depsgraph *depsgraph, DynamicPaintSurface *surface, float *pointCoord, DynamicPaintBrushSettings *brush,
Object *brushOb, Scene *scene, float timescale)
{
PaintSurfaceData *sData = surface->data;
@@ -5882,7 +5883,9 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const Vie
/*
* Do Dynamic Paint step. Paints scene brush objects of current state/frame to the surface.
*/
-static int dynamicPaint_doStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, DynamicPaintSurface *surface, float timescale, float subframe)
+static int dynamicPaint_doStep(
+ Depsgraph *depsgraph, Scene *scene,
+ Object *ob, DynamicPaintSurface *surface, float timescale, float subframe)
{
PaintSurfaceData *sData = surface->data;
PaintBakeData *bData = sData->bData;
@@ -5961,7 +5964,7 @@ static int dynamicPaint_doStep(struct Depsgraph *depsgraph, Scene *scene, Object
psys_check_enabled(brushObj, brush->psys, G.is_rendering))
{
/* Paint a particle system */
- BKE_animsys_evaluate_animdata(scene, &brush->psys->part->id, brush->psys->part->adt,
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &brush->psys->part->id, brush->psys->part->adt,
BKE_scene_frame_get(scene), ADT_RECALC_ANIM);
dynamicPaint_paintParticles(surface, brush->psys, brush, timescale);
}
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 905f103250a..0de04e31be9 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -270,7 +270,7 @@ FCurve *iter_step_fcurve(FCurve *fcu_iter, const char rna_path[])
/* Get list of LinkData's containing pointers to the F-Curves which control the types of data indicated
* Lists...
- * - dst: list of LinkData's matching the criteria returned.
+ * - dst: list of LinkData's matching the criteria returned.
* List must be freed after use, and is assumed to be empty when passed.
* - src: list of F-Curves to search through
* Filters...
@@ -879,7 +879,7 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample
/* ***************************** F-Curve Sanity ********************************* */
/* The functions here are used in various parts of Blender, usually after some editing
* of keyframe data has occurred. They ensure that keyframe data is properly ordered and
- * that the handles are correctly
+ * that the handles are correctly
*/
/* Checks if the F-Curve has a Cycles modifier with simple settings that warrant transition smoothing */
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index f1834bdf8a6..f3d0a5fe085 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -58,14 +58,14 @@ void *fmodifiers_storage_get(FModifierStackStorage *storage, FModifier *fcm);
/* Info ------------------------------- */
/* F-Modifiers are modifiers which operate on F-Curves. However, they can also be defined
- * on NLA-Strips to affect all of the F-Curves referenced by the NLA-Strip.
+ * on NLA-Strips to affect all of the F-Curves referenced by the NLA-Strip.
*/
/* Template --------------------------- */
/* Each modifier defines a set of functions, which will be called at the appropriate
* times. In addition to this, each modifier should have a type-info struct, where
- * its functions are attached for use.
+ * its functions are attached for use.
*/
/* Template for type-info data:
@@ -74,7 +74,7 @@ void *fmodifiers_storage_get(FModifierStackStorage *storage, FModifier *fcm);
* - although the naming of functions doesn't matter, it would help for code
* readability, to follow the same naming convention as is presented here
* - any functions that a constraint doesn't need to define, don't define
- * for such cases, just use NULL
+ * for such cases, just use NULL
* - these should be defined after all the functions have been defined, so that
* forward-definitions/prototypes don't need to be used!
* - keep this copy #if-def'd so that future constraints can get based off this
@@ -260,7 +260,7 @@ static FModifierTypeInfo FMI_GENERATOR = {
* x is the evaluation 'time', and 'y' is the resultant value
*
* Functions available are
- * sin, cos, tan, sinc (normalized sin), natural log, square root
+ * sin, cos, tan, sinc (normalized sin), natural log, square root
*/
static void fcm_fn_generator_new_data(void *mdata)
@@ -1397,7 +1397,7 @@ static float eval_fmodifier_influence(FModifier *fcm, float evaltime)
}
/* evaluate time modifications imposed by some F-Curve Modifiers
- * - this step acts as an optimization to prevent the F-Curve stack being evaluated
+ * - this step acts as an optimization to prevent the F-Curve stack being evaluated
* several times by modifiers requesting the time be modified, as the final result
* would have required using the modified time
* - modifiers only ever receive the unmodified time, as subsequent modifiers should be
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 34b185417e3..f7ab5415d1c 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -255,8 +255,8 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath)
}
else {
BLI_split_file_part(filepath, filename, sizeof(filename));
- pf = newPackedFile(NULL, filepath, bmain->name);
- temp_pf = newPackedFile(NULL, filepath, bmain->name);
+ pf = newPackedFile(NULL, filepath, BKE_main_blendfile_path(bmain));
+ temp_pf = newPackedFile(NULL, filepath, BKE_main_blendfile_path(bmain));
is_builtin = false;
}
@@ -301,7 +301,7 @@ VFont *BKE_vfont_load_exists_ex(struct Main *bmain, const char *filepath, bool *
char str[FILE_MAX], strtest[FILE_MAX];
BLI_strncpy(str, filepath, sizeof(str));
- BLI_path_abs(str, bmain->name);
+ BLI_path_abs(str, BKE_main_blendfile_path(bmain));
/* first search an identical filepath */
for (vfont = bmain->vfont.first; vfont; vfont = vfont->id.next) {
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index e5c192b3e1e..c1ecabcfb5a 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -498,7 +498,7 @@ void BKE_image_make_local(Main *bmain, Image *ima, const bool lib_local)
BKE_id_make_local_generic(bmain, &ima->id, true, lib_local);
}
-void BKE_image_merge(Image *dest, Image *source)
+void BKE_image_merge(Main *bmain, Image *dest, Image *source)
{
/* sanity check */
if (dest && source && dest != source) {
@@ -516,7 +516,7 @@ void BKE_image_merge(Image *dest, Image *source)
}
BLI_spin_unlock(&image_spin);
- BKE_libblock_free(G.main, source);
+ BKE_libblock_free(bmain, source);
}
}
@@ -592,7 +592,7 @@ Image *BKE_image_load(Main *bmain, const char *filepath)
char str[FILE_MAX];
STRNCPY(str, filepath);
- BLI_path_abs(str, bmain->name);
+ BLI_path_abs(str, BKE_main_blendfile_path(bmain));
/* exists? */
file = BLI_open(str, O_BINARY | O_RDONLY, 0);
@@ -615,19 +615,19 @@ Image *BKE_image_load(Main *bmain, const char *filepath)
/* otherwise creates new. */
/* does not load ibuf itself */
/* pass on optional frame for #name images */
-Image *BKE_image_load_exists_ex(const char *filepath, bool *r_exists)
+Image *BKE_image_load_exists_ex(Main *bmain, const char *filepath, bool *r_exists)
{
Image *ima;
char str[FILE_MAX], strtest[FILE_MAX];
STRNCPY(str, filepath);
- BLI_path_abs(str, G.main->name);
+ BLI_path_abs(str, BKE_main_blendfile_path_from_global());
/* first search an identical filepath */
- for (ima = G.main->image.first; ima; ima = ima->id.next) {
+ for (ima = bmain->image.first; ima; ima = ima->id.next) {
if (ima->source != IMA_SRC_VIEWER && ima->source != IMA_SRC_GENERATED) {
STRNCPY(strtest, ima->name);
- BLI_path_abs(strtest, ID_BLEND_PATH(G.main, &ima->id));
+ BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &ima->id));
if (BLI_path_cmp(strtest, str) == 0) {
if ((BKE_image_has_anim(ima) == false) ||
@@ -646,12 +646,12 @@ Image *BKE_image_load_exists_ex(const char *filepath, bool *r_exists)
if (r_exists)
*r_exists = false;
- return BKE_image_load(G.main, filepath);
+ return BKE_image_load(bmain, filepath);
}
-Image *BKE_image_load_exists(const char *filepath)
+Image *BKE_image_load_exists(Main *bmain, const char *filepath)
{
- return BKE_image_load_exists_ex(filepath, NULL);
+ return BKE_image_load_exists_ex(bmain, filepath, NULL);
}
static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type,
@@ -753,7 +753,7 @@ Image *BKE_image_add_generated(
/* Create an image image from ibuf. The refcount of ibuf is increased,
* caller should take care to drop its reference by calling
* IMB_freeImBuf if needed. */
-Image *BKE_image_add_from_imbuf(ImBuf *ibuf, const char *name)
+Image *BKE_image_add_from_imbuf(Main *bmain, ImBuf *ibuf, const char *name)
{
/* on save, type is changed to FILE in editsima.c */
Image *ima;
@@ -762,7 +762,7 @@ Image *BKE_image_add_from_imbuf(ImBuf *ibuf, const char *name)
name = BLI_path_basename(ibuf->name);
}
- ima = image_alloc(G.main, name, IMA_SRC_FILE, IMA_TYPE_IMAGE);
+ ima = image_alloc(bmain, name, IMA_SRC_FILE, IMA_TYPE_IMAGE);
if (ima) {
STRNCPY(ima->name, ibuf->name);
@@ -931,12 +931,12 @@ void BKE_image_tag_time(Image *ima)
}
#if 0
-static void tag_all_images_time()
+static void tag_all_images_time(Main *bmain)
{
Image *ima;
int ctime = PIL_check_seconds_timer_i();
- ima = G.main->image.first;
+ ima = bmain->image.first;
while (ima) {
if (ima->bindcode || ima->repbind || ima->ibufs.first) {
ima->lastused = ctime;
@@ -990,17 +990,17 @@ static uintptr_t image_mem_size(Image *image)
return size;
}
-void BKE_image_print_memlist(void)
+void BKE_image_print_memlist(Main *bmain)
{
Image *ima;
uintptr_t size, totsize = 0;
- for (ima = G.main->image.first; ima; ima = ima->id.next)
+ for (ima = bmain->image.first; ima; ima = ima->id.next)
totsize += image_mem_size(ima);
printf("\ntotal image memory len: %.3f MB\n", (double)totsize / (double)(1024 * 1024));
- for (ima = G.main->image.first; ima; ima = ima->id.next) {
+ for (ima = bmain->image.first; ima; ima = ima->id.next) {
size = image_mem_size(ima);
if (size)
@@ -1013,7 +1013,7 @@ static bool imagecache_check_dirty(ImBuf *ibuf, void *UNUSED(userkey), void *UNU
return (ibuf->userflags & IB_BITMAPDIRTY) == 0;
}
-void BKE_image_free_all_textures(void)
+void BKE_image_free_all_textures(Main *bmain)
{
#undef CHECK_FREED_SIZE
@@ -1023,14 +1023,14 @@ void BKE_image_free_all_textures(void)
uintptr_t tot_freed_size = 0;
#endif
- for (ima = G.main->image.first; ima; ima = ima->id.next)
+ for (ima = bmain->image.first; ima; ima = ima->id.next)
ima->id.tag &= ~LIB_TAG_DOIT;
- for (tex = G.main->tex.first; tex; tex = tex->id.next)
+ for (tex = bmain->tex.first; tex; tex = tex->id.next)
if (tex->ima)
tex->ima->id.tag |= LIB_TAG_DOIT;
- for (ima = G.main->image.first; ima; ima = ima->id.next) {
+ for (ima = bmain->image.first; ima; ima = ima->id.next) {
if (ima->cache && (ima->id.tag & LIB_TAG_DOIT)) {
#ifdef CHECK_FREED_SIZE
uintptr_t old_size = image_mem_size(ima);
@@ -1066,11 +1066,11 @@ void BKE_image_free_anim_ibufs(Image *ima, int except_frame)
BLI_spin_unlock(&image_spin);
}
-void BKE_image_all_free_anim_ibufs(int cfra)
+void BKE_image_all_free_anim_ibufs(Main *bmain, int cfra)
{
Image *ima;
- for (ima = G.main->image.first; ima; ima = ima->id.next)
+ for (ima = bmain->image.first; ima; ima = ima->id.next)
if (BKE_image_is_animated(ima))
BKE_image_free_anim_ibufs(ima, cfra);
}
@@ -1648,7 +1648,8 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
time_t t;
if (scene->r.stamp & R_STAMP_FILENAME) {
- SNPRINTF(stamp_data->file, do_prefix ? "File %s" : "%s", G.relbase_valid ? G.main->name : "<untitled>");
+ SNPRINTF(stamp_data->file, do_prefix ? "File %s" : "%s",
+ G.relbase_valid ? BKE_main_blendfile_path_from_global() : "<untitled>");
}
else {
stamp_data->file[0] = '\0';
@@ -2547,17 +2548,17 @@ struct anim *openanim(const char *name, int flags, int streamindex, char colorsp
/* forces existence of 1 Image for renderout or nodes, returns Image */
/* name is only for default, when making new one */
-Image *BKE_image_verify_viewer(int type, const char *name)
+Image *BKE_image_verify_viewer(Main *bmain, int type, const char *name)
{
Image *ima;
- for (ima = G.main->image.first; ima; ima = ima->id.next)
+ for (ima = bmain->image.first; ima; ima = ima->id.next)
if (ima->source == IMA_SRC_VIEWER)
if (ima->type == type)
break;
if (ima == NULL)
- ima = image_alloc(G.main, name, IMA_SRC_VIEWER, type);
+ ima = image_alloc(bmain, name, IMA_SRC_VIEWER, type);
/* happens on reload, imagewindow cannot be image user when hidden*/
if (ima->id.us == 0)
@@ -2708,7 +2709,7 @@ void BKE_image_init_imageuser(Image *ima, ImageUser *iuser)
image_init_imageuser(ima, iuser);
}
-void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
+void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
{
if (ima == NULL)
return;
@@ -2770,7 +2771,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
if (iuser)
iuser->ok = 1;
- BKE_image_walk_all_users(G.main, ima, image_tag_frame_recalc);
+ BKE_image_walk_all_users(bmain, ima, image_tag_frame_recalc);
break;
@@ -2782,13 +2783,13 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
if (totfiles != BLI_listbase_count_at_most(&ima->packedfiles, totfiles + 1)) {
/* in case there are new available files to be loaded */
image_free_packedfiles(ima);
- BKE_image_packfiles(NULL, ima, ID_BLEND_PATH(G.main, &ima->id));
+ BKE_image_packfiles(NULL, ima, ID_BLEND_PATH(bmain, &ima->id));
}
else {
ImagePackedFile *imapf;
for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
PackedFile *pf;
- pf = newPackedFile(NULL, imapf->filepath, ID_BLEND_PATH(G.main, &ima->id));
+ pf = newPackedFile(NULL, imapf->filepath, ID_BLEND_PATH(bmain, &ima->id));
if (pf) {
freePackedFile(imapf->packedfile);
imapf->packedfile = pf;
@@ -2840,7 +2841,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
* this also makes sure all scenes are accounted for. */
{
Scene *scene;
- for (scene = G.main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
if (scene->nodetree) {
nodeUpdateID(scene->nodetree, &ima->id);
}
@@ -3532,7 +3533,7 @@ static ImBuf *load_image_single(
BLI_addtail(&ima->packedfiles, imapf);
STRNCPY(imapf->filepath, filepath);
- imapf->packedfile = newPackedFile(NULL, filepath, ID_BLEND_PATH(G.main, &ima->id));
+ imapf->packedfile = newPackedFile(NULL, filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id));
}
}
}
@@ -4370,7 +4371,7 @@ void BKE_image_user_file_path(ImageUser *iuser, Image *ima, char *filepath)
BLI_stringenc(filepath, head, tail, numlen, frame);
}
- BLI_path_abs(filepath, ID_BLEND_PATH(G.main, &ima->id));
+ BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id));
}
bool BKE_image_has_alpha(struct Image *image)
@@ -4698,7 +4699,7 @@ static void image_update_views_format(Image *ima, ImageUser *iuser)
char str[FILE_MAX];
STRNCPY(str, iv->filepath);
- BLI_path_abs(str, G.main->name);
+ BLI_path_abs(str, BKE_main_blendfile_path_from_global());
/* exists? */
file = BLI_open(str, O_BINARY | O_RDONLY, 0);
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 941c7eb2a87..82178096b46 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -251,7 +251,7 @@ static const char *ob_adrcodes_to_paths(int adrcode, int *array_index)
}
/* PoseChannel types
- * NOTE: pchan name comes from 'actname' added earlier...
+ * NOTE: pchan name comes from 'actname' added earlier...
*/
static const char *pchan_adrcodes_to_paths(int adrcode, int *array_index)
{
@@ -314,7 +314,7 @@ static const char *constraint_adrcodes_to_paths(int adrcode, int *array_index)
}
/* ShapeKey types
- * NOTE: as we don't have access to the keyblock where the data comes from (for now),
+ * NOTE: as we don't have access to the keyblock where the data comes from (for now),
* we'll just use numerical indices for now...
*/
static char *shapekey_adrcodes_to_paths(ID *id, int adrcode, int *UNUSED(array_index))
@@ -1672,10 +1672,10 @@ static void nlastrips_to_animdata(ID *id, ListBase *strips)
/* Called from do_versions() in readfile.c to convert the old 'IPO/adrcode' system
* to the new 'Animato/RNA' system.
*
- * The basic method used here, is to loop over datablocks which have IPO-data, and
- * add those IPO's to new AnimData blocks as Actions.
+ * The basic method used here, is to loop over datablocks which have IPO-data, and
+ * add those IPO's to new AnimData blocks as Actions.
* Action/NLA data only works well for Objects, so these only need to be checked for there.
- *
+ *
* Data that has been converted should be freed immediately, which means that it is immediately
* clear which datablocks have yet to be converted, and also prevent freeing errors when we exit.
*/
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 2a60bd94d10..b5b62de57ec 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -211,8 +211,10 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
/* works best if we force to linear type (endpoints match) */
lt->typeu = lt->typev = lt->typew = KEY_LINEAR;
- /* prevent using deformed locations */
- BKE_displist_free(&ltOb->curve_cache->disp);
+ if (ltOb->curve_cache) {
+ /* prevent using deformed locations */
+ BKE_displist_free(&ltOb->curve_cache->disp);
+ }
copy_m4_m4(mat, ltOb->obmat);
unit_m4(ltOb->obmat);
@@ -418,10 +420,11 @@ void calc_latt_deform(LatticeDeformData *lattice_deform_data, float co[3], float
int defgrp_index = -1;
float co_prev[3], weight_blend = 0.0f;
MDeformVert *dvert = BKE_lattice_deform_verts_get(ob);
+ float *__restrict latticedata = lattice_deform_data->latticedata;
if (lt->editlatt) lt = lt->editlatt->latt;
- if (lattice_deform_data->latticedata == NULL) return;
+ if (latticedata == NULL) return;
if (lt->vgroup[0] && dvert) {
defgrp_index = defgroup_name_index(ob, lt->vgroup);
@@ -502,7 +505,7 @@ void calc_latt_deform(LatticeDeformData *lattice_deform_data, float co[3], float
idx_u = idx_v;
}
- madd_v3_v3fl(co, &lattice_deform_data->latticedata[idx_u * 3], u);
+ madd_v3_v3fl(co, &latticedata[idx_u * 3], u);
if (defgrp_index != -1)
weight_blend += (u * defvert_find_weight(dvert + idx_u, defgrp_index));
@@ -1054,7 +1057,7 @@ void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Objec
modifier_deformVerts_DM_deprecated(md, &mectx, NULL, vertexCos, numVerts);
}
- if (ob->id.tag & LIB_TAG_COPY_ON_WRITE) {
+ if (ob->id.tag & LIB_TAG_COPIED_ON_WRITE) {
if (vertexCos) {
BKE_lattice_vertexcos_apply(ob, vertexCos);
MEM_freeN(vertexCos);
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 3a6d599ccd3..c7bb24cdcee 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -1206,8 +1206,7 @@ void BKE_view_layer_bases_in_mode_iterator_next(BLI_Iterator *iter)
}
while (base) {
- if ((base->flag & BASE_SELECTED) != 0 &&
- (base->object->type == data->base_active->object->type) &&
+ if ((base->object->type == data->base_active->object->type) &&
(base != data->base_active) &&
(base->object->mode & data->object_mode))
{
@@ -1265,6 +1264,16 @@ void BKE_layer_eval_view_layer(
/* Store base in the array. */
view_layer->object_bases_array[base_index++] = base;
}
+ if (view_layer == DEG_get_evaluated_view_layer(depsgraph)) {
+ ViewLayer *view_layer_orig = DEG_get_input_view_layer(depsgraph);
+ Base *base_orig = view_layer_orig->object_bases.first;
+ const Base *base_eval = view_layer->object_bases.first;
+ while (base_orig != NULL) {
+ base_orig->flag = base_eval->flag;
+ base_orig = base_orig->next;
+ base_eval = base_eval->next;
+ }
+ }
}
void BKE_layer_eval_view_layer_indexed(
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 3926d2055f0..a885f22b739 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -155,7 +155,7 @@
* also note that the id _must_ have a library - campbell */
void BKE_id_lib_local_paths(Main *bmain, Library *lib, ID *id)
{
- const char *bpath_user_data[2] = {bmain->name, lib->filepath};
+ const char *bpath_user_data[2] = {BKE_main_blendfile_path(bmain), lib->filepath};
BKE_bpath_traverse_id(bmain, id,
BKE_bpath_relocate_visitor,
@@ -1737,18 +1737,31 @@ void BKE_main_thumbnail_create(struct Main *bmain)
bmain->blen_thumb->height = BLEN_THUMB_SIZE;
}
+/**
+ * Return filepath of given \a main.
+ */
+const char *BKE_main_blendfile_path(const Main *bmain)
+{
+ return bmain->name;
+}
+
+/**
+ * Return filepath of global main (G_MAIN).
+ *
+ * \warning Usage is not recommended, you should always try to get a valid Main pointer from context...
+ */
+const char *BKE_main_blendfile_path_from_global(void)
+{
+ return BKE_main_blendfile_path(G_MAIN);
+}
+
/* ***************** ID ************************ */
-ID *BKE_libblock_find_name_ex(struct Main *bmain, const short type, const char *name)
+ID *BKE_libblock_find_name(struct Main *bmain, const short type, const char *name)
{
ListBase *lb = which_libbase(bmain, type);
BLI_assert(lb != NULL);
return BLI_findstring(lb, name, offsetof(ID, name) + 2);
}
-ID *BKE_libblock_find_name(const short type, const char *name)
-{
- return BKE_libblock_find_name_ex(G.main, type, name);
-}
-
void id_sort_by_name(ListBase *lb, ID *id)
{
@@ -2078,7 +2091,7 @@ static void library_make_local_copying_check(ID *id, GSet *loop_tags, MainIDRela
/** Make linked datablocks local.
*
- * \param bmain Almost certainly G.main.
+ * \param bmain Almost certainly global main.
* \param lib If not NULL, only make local datablocks from this library.
* \param untagged_only If true, only make local datablocks not tagged with LIB_TAG_PRE_EXISTING.
* \param set_fake If true, set fake user on all localized datablocks (except group and objects ones).
@@ -2510,7 +2523,7 @@ void BKE_id_ui_prefix(char name[MAX_ID_NAME + 1], const ID *id)
strcpy(name + 3, id->name + 2);
}
-void BKE_library_filepath_set(Library *lib, const char *filepath)
+void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
{
/* in some cases this is used to update the absolute path from the
* relative */
@@ -2529,8 +2542,8 @@ void BKE_library_filepath_set(Library *lib, const char *filepath)
* since making local could cause this to be directly linked - campbell
*/
/* Never make paths relative to parent lib - reading code (blenloader) always set *all* lib->name relative to
- * current G.main, not to their parent for indirectly linked ones. */
- const char *basepath = G.main->name;
+ * current main, not to their parent for indirectly linked ones. */
+ const char *basepath = BKE_main_blendfile_path(bmain);
BLI_path_abs(lib->filepath, basepath);
}
}
diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index cf2a001daaa..e3c10175feb 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -395,8 +395,7 @@ static void libblock_remap_data_postprocess_collection_update(Main *bmain, Colle
}
}
-
-static void libblock_remap_data_postprocess_obdata_relink(Main *UNUSED(bmain), Object *ob, ID *new_id)
+static void libblock_remap_data_postprocess_obdata_relink(Main *bmain, Object *ob, ID *new_id)
{
if (ob->data == new_id) {
switch (GS(new_id->name)) {
@@ -410,7 +409,7 @@ static void libblock_remap_data_postprocess_obdata_relink(Main *UNUSED(bmain), O
break;
}
test_object_modifiers(ob);
- test_object_materials(ob, new_id);
+ test_object_materials(bmain, ob, new_id);
}
}
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 131d79c249f..1ea2f170922 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -113,10 +113,10 @@ void BKE_material_init(Material *ma)
ma->r = ma->g = ma->b = 0.8;
ma->specr = ma->specg = ma->specb = 1.0;
- ma->alpha = 1.0;
+ // ma->alpha = 1.0; /* DEPRECATED */
ma->spec = 0.5;
- ma->gloss_mir = 1.0;
+ ma->roughness = 0.25f;
ma->pr_lamp = 3; /* two lamps, is bits */
ma->pr_type = MA_SPHERE;
@@ -402,7 +402,7 @@ Material *BKE_material_pop_id(Main *bmain, ID *id, int index_i, bool update_data
(*totcol)--;
*matar = MEM_reallocN(*matar, sizeof(void *) * (*totcol));
- test_all_objects_materials(G.main, id);
+ test_all_objects_materials(bmain, id);
}
if (update_data) {
@@ -535,7 +535,7 @@ void BKE_material_resize_object(Main *bmain, Object *ob, const short totcol, boo
DEG_relations_tag_update(bmain);
}
-void test_object_materials(Object *ob, ID *id)
+void test_object_materials(Main *bmain, Object *ob, ID *id)
{
/* make the ob mat-array same size as 'ob->data' mat-array */
const short *totcol;
@@ -544,7 +544,7 @@ void test_object_materials(Object *ob, ID *id)
return;
}
- BKE_material_resize_object(G.main, ob, *totcol, false);
+ BKE_material_resize_object(bmain, ob, *totcol, false);
}
void test_all_objects_materials(Main *bmain, ID *id)
@@ -566,7 +566,7 @@ void test_all_objects_materials(Main *bmain, ID *id)
BKE_main_unlock(bmain);
}
-void assign_material_id(ID *id, Material *ma, short act)
+void assign_material_id(Main *bmain, ID *id, Material *ma, short act)
{
Material *mao, **matar, ***matarar;
short *totcolp;
@@ -610,10 +610,10 @@ void assign_material_id(ID *id, Material *ma, short act)
if (ma)
id_us_plus(&ma->id);
- test_all_objects_materials(G.main, id);
+ test_all_objects_materials(bmain, id);
}
-void assign_material(Object *ob, Material *ma, short act, int assign_type)
+void assign_material(Main *bmain, Object *ob, Material *ma, short act, int assign_type)
{
Material *mao, **matar, ***matarar;
short *totcolp;
@@ -685,14 +685,14 @@ void assign_material(Object *ob, Material *ma, short act, int assign_type)
if (mao)
id_us_min(&mao->id);
ob->mat[act - 1] = ma;
- test_object_materials(ob, ob->data);
+ test_object_materials(bmain, ob, ob->data);
}
else { /* in data */
mao = (*matarar)[act - 1];
if (mao)
id_us_min(&mao->id);
(*matarar)[act - 1] = ma;
- test_all_objects_materials(G.main, ob->data); /* Data may be used by several objects... */
+ test_all_objects_materials(bmain, ob->data); /* Data may be used by several objects... */
}
if (ma)
@@ -785,20 +785,20 @@ void BKE_material_remap_object_calc(
/* XXX - this calls many more update calls per object then are needed, could be optimized */
-void assign_matarar(struct Object *ob, struct Material ***matar, short totcol)
+void assign_matarar(Main *bmain, struct Object *ob, struct Material ***matar, short totcol)
{
int actcol_orig = ob->actcol;
short i;
while ((ob->totcol > totcol) &&
- BKE_object_material_slot_remove(ob))
+ BKE_object_material_slot_remove(bmain, ob))
{
/* pass */
}
/* now we have the right number of slots */
for (i = 0; i < totcol; i++)
- assign_material(ob, (*matar)[i], i + 1, BKE_MAT_ASSIGN_USERPREF);
+ assign_material(bmain, ob, (*matar)[i], i + 1, BKE_MAT_ASSIGN_USERPREF);
if (actcol_orig > ob->totcol)
actcol_orig = ob->totcol;
@@ -827,19 +827,19 @@ short BKE_object_material_slot_find_index(Object *ob, Material *ma)
return 0;
}
-bool BKE_object_material_slot_add(Object *ob)
+bool BKE_object_material_slot_add(Main *bmain, Object *ob)
{
if (ob == NULL) return false;
if (ob->totcol >= MAXMAT) return false;
- assign_material(ob, NULL, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF);
+ assign_material(bmain, ob, NULL, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF);
ob->actcol = ob->totcol;
return true;
}
/* ****************** */
-bool BKE_object_material_slot_remove(Object *ob)
+bool BKE_object_material_slot_remove(Main *bmain, Object *ob)
{
Material *mao, ***matarar;
short *totcolp;
@@ -890,7 +890,7 @@ bool BKE_object_material_slot_remove(Object *ob)
actcol = ob->actcol;
- for (Object *obt = G.main->object.first; obt; obt = obt->id.next) {
+ for (Object *obt = bmain->object.first; obt; obt = obt->id.next) {
if (obt->data == ob->data) {
/* Can happen when object material lists are used, see: T52953 */
if (actcol > obt->totcol) {
@@ -1276,21 +1276,21 @@ void free_matcopybuf(void)
matcopied = 0;
}
-void copy_matcopybuf(Material *ma)
+void copy_matcopybuf(Main *bmain, Material *ma)
{
if (matcopied)
free_matcopybuf();
memcpy(&matcopybuf, ma, sizeof(Material));
- matcopybuf.nodetree = ntreeCopyTree_ex(ma->nodetree, G.main, false);
+ matcopybuf.nodetree = ntreeCopyTree_ex(ma->nodetree, bmain, false);
matcopybuf.preview = NULL;
BLI_listbase_clear(&matcopybuf.gpumaterial);
/* TODO Duplicate Engine Settings and set runtime to NULL */
matcopied = 1;
}
-void paste_matcopybuf(Material *ma)
+void paste_matcopybuf(Main *bmain, Material *ma)
{
ID id;
@@ -1309,13 +1309,11 @@ void paste_matcopybuf(Material *ma)
memcpy(ma, &matcopybuf, sizeof(Material));
(ma->id) = id;
- ma->nodetree = ntreeCopyTree_ex(matcopybuf.nodetree, G.main, false);
+ ma->nodetree = ntreeCopyTree_ex(matcopybuf.nodetree, bmain, false);
}
void BKE_material_eval(struct Depsgraph *depsgraph, Material *material)
{
DEG_debug_print_eval(depsgraph, __func__, material->id.name, material);
- if ((BLI_listbase_is_empty(&material->gpumaterial) == false)) {
- GPU_material_uniform_buffer_tag_dirty(&material->gpumaterial);
- }
+ GPU_material_free(&material->gpumaterial);
}
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 2f85bfedcf2..3afaf2d569e 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -277,7 +277,7 @@ float *BKE_mball_make_orco(Object *ob, ListBase *dispbase)
* This really needs a rewrite/refactor its totally broken in anything other then basic cases
* Multiple Scenes + Set Scenes & mixing mball basis SHOULD work but fails to update the depsgraph on rename
* and linking into scenes or removal of basis mball. so take care when changing this code.
- *
+ *
* Main idiot thing here is that the system returns find_basis_mball() objects which fail a is_basis_mball() test.
*
* Not only that but the depsgraph and their areas depend on this behavior!, so making small fixes here isn't worth it.
@@ -563,11 +563,6 @@ void BKE_mball_select_swap(struct MetaBall *mb)
/* **** Depsgraph evaluation **** */
-void BKE_mball_eval_geometry(struct Depsgraph *UNUSED(depsgraph),
- MetaBall *UNUSED(mball))
-{
-}
-
/* Draw Engine */
void (*BKE_mball_batch_cache_dirty_cb)(MetaBall *mb, int mode) = NULL;
diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c
index 0f13618c76a..7e26a0f7713 100644
--- a/source/blender/blenkernel/intern/mball_tessellate.c
+++ b/source/blender/blenkernel/intern/mball_tessellate.c
@@ -48,9 +48,10 @@
#include "BKE_global.h"
-#include "BKE_scene.h"
#include "BKE_displist.h"
+#include "BKE_main.h"
#include "BKE_mball_tessellate.h" /* own include */
+#include "BKE_scene.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index f99818f39b9..b325d8d02d9 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -46,6 +46,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_library.h"
#include "BKE_material.h"
#include "BKE_modifier.h"
@@ -543,12 +544,13 @@ void BKE_mesh_copy_data(Main *bmain, Mesh *me_dst, const Mesh *me_src, const int
me_dst->mat = MEM_dupallocN(me_src->mat);
- CustomData_copy(&me_src->vdata, &me_dst->vdata, mask, CD_DUPLICATE, me_dst->totvert);
- CustomData_copy(&me_src->edata, &me_dst->edata, mask, CD_DUPLICATE, me_dst->totedge);
- CustomData_copy(&me_src->ldata, &me_dst->ldata, mask, CD_DUPLICATE, me_dst->totloop);
- CustomData_copy(&me_src->pdata, &me_dst->pdata, mask, CD_DUPLICATE, me_dst->totpoly);
+ const eCDAllocType alloc_type = (flag & LIB_ID_COPY_CD_REFERENCE) ? CD_REFERENCE : CD_DUPLICATE;
+ CustomData_copy(&me_src->vdata, &me_dst->vdata, mask, alloc_type, me_dst->totvert);
+ CustomData_copy(&me_src->edata, &me_dst->edata, mask, alloc_type, me_dst->totedge);
+ CustomData_copy(&me_src->ldata, &me_dst->ldata, mask, alloc_type, me_dst->totloop);
+ CustomData_copy(&me_src->pdata, &me_dst->pdata, mask, alloc_type, me_dst->totpoly);
if (do_tessface) {
- CustomData_copy(&me_src->fdata, &me_dst->fdata, mask, CD_DUPLICATE, me_dst->totface);
+ CustomData_copy(&me_src->fdata, &me_dst->fdata, mask, alloc_type, me_dst->totface);
}
else {
mesh_tessface_clear_intern(me_dst, false);
@@ -580,6 +582,34 @@ void BKE_mesh_copy_data(Main *bmain, Mesh *me_dst, const Mesh *me_src, const int
}
}
+/* Custom data layer functions; those assume that totXXX are set correctly. */
+static void mesh_ensure_cdlayers_primary(Mesh *mesh, bool do_tessface)
+{
+ if (!CustomData_get_layer(&mesh->vdata, CD_MVERT))
+ CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CALLOC, NULL, mesh->totvert);
+ if (!CustomData_get_layer(&mesh->edata, CD_MEDGE))
+ CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_CALLOC, NULL, mesh->totedge);
+ if (!CustomData_get_layer(&mesh->ldata, CD_MLOOP))
+ CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CALLOC, NULL, mesh->totloop);
+ if (!CustomData_get_layer(&mesh->pdata, CD_MPOLY))
+ CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CALLOC, NULL, mesh->totpoly);
+
+ if (do_tessface && !CustomData_get_layer(&mesh->fdata, CD_MFACE))
+ CustomData_add_layer(&mesh->fdata, CD_MFACE, CD_CALLOC, NULL, mesh->totface);
+}
+static void mesh_ensure_cdlayers_origindex(Mesh *mesh, bool do_tessface)
+{
+ if (!CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX))
+ CustomData_add_layer(&mesh->vdata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totvert);
+ if (!CustomData_get_layer(&mesh->edata, CD_ORIGINDEX))
+ CustomData_add_layer(&mesh->edata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totedge);
+ if (!CustomData_get_layer(&mesh->pdata, CD_ORIGINDEX))
+ CustomData_add_layer(&mesh->pdata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totpoly);
+
+ if (do_tessface && !CustomData_get_layer(&mesh->fdata, CD_ORIGINDEX))
+ CustomData_add_layer(&mesh->fdata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totface);
+}
+
Mesh *BKE_mesh_new_nomain(int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len)
{
Mesh *mesh = BKE_libblock_alloc(
@@ -597,28 +627,16 @@ Mesh *BKE_mesh_new_nomain(int verts_len, int edges_len, int tessface_len, int lo
copy_vn_i(mesh->ldata.typemap, CD_NUMTYPES, -1);
copy_vn_i(mesh->pdata.typemap, CD_NUMTYPES, -1);
- CustomData_add_layer(&mesh->vdata, CD_ORIGINDEX, CD_CALLOC, NULL, verts_len);
- CustomData_add_layer(&mesh->edata, CD_ORIGINDEX, CD_CALLOC, NULL, edges_len);
- CustomData_add_layer(&mesh->fdata, CD_ORIGINDEX, CD_CALLOC, NULL, tessface_len);
- CustomData_add_layer(&mesh->pdata, CD_ORIGINDEX, CD_CALLOC, NULL, polys_len);
-
- CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CALLOC, NULL, verts_len);
- CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_CALLOC, NULL, edges_len);
- CustomData_add_layer(&mesh->fdata, CD_MFACE, CD_CALLOC, NULL, tessface_len);
- CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CALLOC, NULL, loops_len);
- CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CALLOC, NULL, polys_len);
-
- mesh->mvert = CustomData_get_layer(&mesh->vdata, CD_MVERT);
- mesh->medge = CustomData_get_layer(&mesh->edata, CD_MEDGE);
- mesh->mface = CustomData_get_layer(&mesh->fdata, CD_MFACE);
- mesh->mloop = CustomData_get_layer(&mesh->ldata, CD_MLOOP);
- mesh->mpoly = CustomData_get_layer(&mesh->pdata, CD_MPOLY);
-
mesh->totvert = verts_len;
mesh->totedge = edges_len;
+ mesh->totface = tessface_len;
mesh->totloop = loops_len;
mesh->totpoly = polys_len;
+ mesh_ensure_cdlayers_primary(mesh, true);
+ mesh_ensure_cdlayers_origindex(mesh, true);
+ BKE_mesh_update_customdata_pointers(mesh, false);
+
return mesh;
}
@@ -637,6 +655,7 @@ static Mesh *mesh_new_nomain_from_template_ex(
me_dst->totvert = verts_len;
me_dst->totedge = edges_len;
+ me_dst->totface = tessface_len;
me_dst->totloop = loops_len;
me_dst->totpoly = polys_len;
@@ -651,15 +670,12 @@ static Mesh *mesh_new_nomain_from_template_ex(
mesh_tessface_clear_intern(me_dst, false);
}
+ /* The destination mesh should at least have valid primary CD layers,
+ * even in cases where the source mesh does not. */
+ mesh_ensure_cdlayers_primary(me_dst, do_tessface);
+ mesh_ensure_cdlayers_origindex(me_dst, false);
BKE_mesh_update_customdata_pointers(me_dst, false);
- if (!CustomData_get_layer(&me_dst->vdata, CD_ORIGINDEX))
- CustomData_add_layer(&me_dst->vdata, CD_ORIGINDEX, CD_CALLOC, NULL, verts_len);
- if (!CustomData_get_layer(&me_dst->edata, CD_ORIGINDEX))
- CustomData_add_layer(&me_dst->edata, CD_ORIGINDEX, CD_CALLOC, NULL, edges_len);
- if (!CustomData_get_layer(&me_dst->pdata, CD_ORIGINDEX))
- CustomData_add_layer(&me_dst->pdata, CD_ORIGINDEX, CD_CALLOC, NULL, polys_len);
-
return me_dst;
}
@@ -1026,7 +1042,7 @@ Mesh *BKE_mesh_from_object(Object *ob)
else return NULL;
}
-void BKE_mesh_assign_object(Object *ob, Mesh *me)
+void BKE_mesh_assign_object(Main *bmain, Object *ob, Mesh *me)
{
Mesh *old = NULL;
@@ -1042,7 +1058,7 @@ void BKE_mesh_assign_object(Object *ob, Mesh *me)
id_us_plus((ID *)me);
}
- test_object_materials(ob, (ID *)me);
+ test_object_materials(bmain, ob, (ID *)me);
test_object_modifiers(ob);
}
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index a48a74f2d67..33b38d60183 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -26,6 +26,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_scene_types.h"
+#include "DNA_key_types.h"
#include "DNA_material_types.h"
#include "DNA_meta_types.h"
#include "DNA_object_types.h"
@@ -40,7 +41,10 @@
#include "BKE_main.h"
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
+#include "BKE_key.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
+#include "BKE_modifier.h"
#include "BKE_displist.h"
#include "BKE_library.h"
#include "BKE_material.h"
@@ -58,6 +62,12 @@
*/
// #undef VALIDATE_MESH
+#ifdef VALIDATE_MESH
+# define ASSERT_IS_VALID_MESH(mesh) (BLI_assert((mesh == NULL) || (BKE_mesh_is_valid(mesh) == true)))
+#else
+# define ASSERT_IS_VALID_MESH(mesh)
+#endif
+
void BKE_mesh_from_metaball(ListBase *lb, Mesh *me)
{
DispList *dl;
@@ -534,9 +544,9 @@ Mesh *BKE_mesh_new_nomain_from_curve(Object *ob)
}
/* this may fail replacing ob->data, be sure to check ob->type */
-void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const bool use_orco_uv, const char *obdata_name)
+void BKE_mesh_from_nurbs_displist(
+ Main *bmain, Object *ob, ListBase *dispbase, const bool use_orco_uv, const char *obdata_name, bool temporary)
{
- Main *bmain = G.main;
Object *ob1;
DerivedMesh *dm = ob->derivedFinal;
Mesh *me;
@@ -620,10 +630,19 @@ void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const bool use
ob1 = ob1->id.next;
}
- BKE_libblock_free_us(bmain, cu);
+ if (temporary) {
+ /* For temporary objects in BKE_mesh_new_from_object don't remap
+ * the entire scene with associated depsgraph updates, which are
+ * problematic for renderers exporting data. */
+ id_us_min(&cu->id);
+ BKE_libblock_free(bmain, cu);
+ }
+ else {
+ BKE_libblock_free_us(bmain, cu);
+ }
}
-void BKE_mesh_from_nurbs(Object *ob)
+void BKE_mesh_from_nurbs(Main *bmain, Object *ob)
{
Curve *cu = (Curve *) ob->data;
bool use_orco_uv = (cu->flag & CU_UV_ORCO) != 0;
@@ -633,7 +652,7 @@ void BKE_mesh_from_nurbs(Object *ob)
disp = ob->curve_cache->disp;
}
- BKE_mesh_from_nurbs_displist(ob, &disp, use_orco_uv, cu->id.name);
+ BKE_mesh_from_nurbs_displist(bmain, ob, &disp, use_orco_uv, cu->id.name, false);
}
typedef struct EdgeLink {
@@ -660,15 +679,15 @@ static void appendPolyLineVert(ListBase *lb, unsigned int index)
BLI_addtail(lb, vl);
}
-void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int edge_users_test)
+void BKE_mesh_to_curve_nurblist(const Mesh *me, ListBase *nurblist, const int edge_users_test)
{
- MVert *mvert = dm->getVertArray(dm);
- MEdge *med, *medge = dm->getEdgeArray(dm);
- MPoly *mp, *mpoly = dm->getPolyArray(dm);
- MLoop *mloop = dm->getLoopArray(dm);
+ MVert *mvert = me->mvert;
+ MEdge *med, *medge = me->medge;
+ MPoly *mp, *mpoly = me->mpoly;
+ MLoop *mloop = me->mloop;
- int dm_totedge = dm->getNumEdges(dm);
- int dm_totpoly = dm->getNumPolys(dm);
+ int medge_len = me->totedge;
+ int mpoly_len = me->totpoly;
int totedges = 0;
int i;
@@ -678,8 +697,8 @@ void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int e
ListBase edges = {NULL, NULL};
/* get boundary edges */
- edge_users = MEM_calloc_arrayN(dm_totedge, sizeof(int), __func__);
- for (i = 0, mp = mpoly; i < dm_totpoly; i++, mp++) {
+ edge_users = MEM_calloc_arrayN(medge_len, sizeof(int), __func__);
+ for (i = 0, mp = mpoly; i < mpoly_len; i++, mp++) {
MLoop *ml = &mloop[mp->loopstart];
int j;
for (j = 0; j < mp->totloop; j++, ml++) {
@@ -689,7 +708,7 @@ void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int e
/* create edges from all faces (so as to find edges not in any faces) */
med = medge;
- for (i = 0; i < dm_totedge; i++, med++) {
+ for (i = 0; i < medge_len; i++, med++) {
if (edge_users[i] == edge_users_test) {
EdgeLink *edl = MEM_callocN(sizeof(EdgeLink), "EdgeLink");
edl->edge = med;
@@ -793,18 +812,18 @@ void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int e
}
}
-void BKE_mesh_to_curve(Depsgraph *depsgraph, Scene *scene, Object *ob)
+void BKE_mesh_to_curve(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob)
{
/* make new mesh data from the original copy */
- DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_MESH);
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_MESH);
ListBase nurblist = {NULL, NULL};
bool needsFree = false;
- BKE_mesh_to_curve_nurblist(dm, &nurblist, 0);
- BKE_mesh_to_curve_nurblist(dm, &nurblist, 1);
+ BKE_mesh_to_curve_nurblist(me_eval, &nurblist, 0);
+ BKE_mesh_to_curve_nurblist(me_eval, &nurblist, 1);
if (nurblist.first) {
- Curve *cu = BKE_curve_add(G.main, ob->id.name + 2, OB_CURVE);
+ Curve *cu = BKE_curve_add(bmain, ob->id.name + 2, OB_CURVE);
cu->flag |= CU_3D;
cu->nurb = nurblist;
@@ -817,11 +836,20 @@ void BKE_mesh_to_curve(Depsgraph *depsgraph, Scene *scene, Object *ob)
needsFree = true;
}
- dm->needsFree = needsFree;
- dm->release(dm);
+ /* Just to avoid dangling pointer, dm will be removed. */
+ {
+ DerivedMesh *dm = ob->derivedFinal;
+ if (dm != NULL) {
+ dm->needsFree = needsFree;
+ dm->release(dm);
+ }
+ }
if (needsFree) {
+ BKE_mesh_free(me_eval);
+
ob->derivedFinal = NULL;
+ ob->runtime.mesh_eval = NULL;
/* curve object could have got bounding box only in special cases */
if (ob->bb) {
@@ -856,9 +884,8 @@ Mesh *BKE_mesh_new_from_object(
/* copies object and modifiers (but not the data) */
Object *tmpobj;
/* TODO: make it temp copy outside bmain! */
- BKE_id_copy_ex(bmain, &ob->id, (ID **)&tmpobj, LIB_ID_COPY_CACHES, false);
+ BKE_id_copy_ex(bmain, &ob->id, (ID **)&tmpobj, LIB_ID_COPY_CACHES | LIB_ID_CREATE_NO_DEG_TAG, false);
tmpcu = (Curve *)tmpobj->data;
- id_us_min(&tmpcu->id);
/* Copy cached display list, it might be needed by the stack evaluation.
* Ideally stack should be able to use render-time display list, but doing
@@ -878,7 +905,8 @@ Mesh *BKE_mesh_new_from_object(
BKE_object_free_modifiers(tmpobj, 0);
/* copies the data */
- copycu = tmpobj->data = BKE_curve_copy(bmain, (Curve *) ob->data);
+ BKE_id_copy_ex(bmain, ob->data, (ID **)&copycu, LIB_ID_CREATE_NO_DEG_TAG, false);
+ tmpobj->data = copycu;
/* make sure texture space is calculated for a copy of curve,
* it will be used for the final result.
@@ -901,7 +929,7 @@ Mesh *BKE_mesh_new_from_object(
/* convert object type to mesh */
uv_from_orco = (tmpcu->flag & CU_UV_ORCO) != 0;
- BKE_mesh_from_nurbs_displist(tmpobj, &dispbase, uv_from_orco, tmpcu->id.name + 2);
+ BKE_mesh_from_nurbs_displist(bmain, tmpobj, &dispbase, uv_from_orco, tmpcu->id.name + 2, true);
tmpmesh = tmpobj->data;
@@ -911,11 +939,11 @@ Mesh *BKE_mesh_new_from_object(
* if it didn't the curve did not have any segments or otherwise
* would have generated an empty mesh */
if (tmpobj->type != OB_MESH) {
- BKE_libblock_free_us(bmain, tmpobj);
+ BKE_libblock_free(bmain, tmpobj);
return NULL;
}
- BKE_libblock_free_us(bmain, tmpobj);
+ BKE_libblock_free(bmain, tmpobj);
/* XXX The curve to mesh conversion is convoluted... But essentially, BKE_mesh_from_nurbs_displist()
* already transfers the ownership of materials from the temp copy of the Curve ID to the new
@@ -1070,3 +1098,341 @@ Mesh *BKE_mesh_new_from_object(
return tmpmesh;
}
+
+
+static void add_shapekey_layers(Mesh *mesh_dest, Mesh *mesh_src)
+{
+ KeyBlock *kb;
+ Key *key = mesh_src->key;
+ int i;
+
+ if (!mesh_src->key)
+ return;
+
+ /* ensure we can use mesh vertex count for derived mesh custom data */
+ if (mesh_src->totvert != mesh_dest->totvert) {
+ fprintf(stderr,
+ "%s: vertex size mismatch (mesh/dm) '%s' (%d != %d)\n",
+ __func__, mesh_src->id.name + 2, mesh_src->totvert, mesh_dest->totvert);
+ return;
+ }
+
+ for (i = 0, kb = key->block.first; kb; kb = kb->next, i++) {
+ int ci;
+ float *array;
+
+ if (mesh_src->totvert != kb->totelem) {
+ fprintf(stderr,
+ "%s: vertex size mismatch (Mesh '%s':%d != KeyBlock '%s':%d)\n",
+ __func__, mesh_src->id.name + 2, mesh_src->totvert, kb->name, kb->totelem);
+ array = MEM_calloc_arrayN((size_t)mesh_src->totvert, 3 * sizeof(float), __func__);
+ }
+ else {
+ array = MEM_malloc_arrayN((size_t)mesh_src->totvert, 3 * sizeof(float), __func__);
+ memcpy(array, kb->data, (size_t)mesh_src->totvert * 3 * sizeof(float));
+ }
+
+ CustomData_add_layer_named(&mesh_dest->vdata, CD_SHAPEKEY, CD_ASSIGN, array, mesh_dest->totvert, kb->name);
+ ci = CustomData_get_layer_index_n(&mesh_dest->vdata, CD_SHAPEKEY, i);
+
+ mesh_dest->vdata.layers[ci].uid = kb->uid;
+ }
+}
+
+
+Mesh *BKE_mesh_create_derived_for_modifier(
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob,
+ ModifierData *md, int build_shapekey_layers)
+{
+ Mesh *me = ob->data;
+ const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ Mesh *result;
+ KeyBlock *kb;
+ ModifierEvalContext mectx = {depsgraph, ob, 0};
+
+ md->scene = scene;
+
+ if (!(md->mode & eModifierMode_Realtime)) {
+ return NULL;
+ }
+
+ if (mti->isDisabled && mti->isDisabled(md, 0)) {
+ return NULL;
+ }
+
+ if (build_shapekey_layers && me->key && (kb = BLI_findlink(&me->key->block, ob->shapenr - 1))) {
+ BKE_keyblock_convert_to_mesh(kb, me);
+ }
+
+ if (mti->type == eModifierTypeType_OnlyDeform) {
+ int numVerts;
+ float (*deformedVerts)[3] = BKE_mesh_vertexCos_get(me, &numVerts);
+
+ modifier_deformVerts(md, &mectx, NULL, deformedVerts, numVerts);
+ BKE_id_copy_ex(NULL, &me->id, (ID **)&result,
+ LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG |
+ LIB_ID_COPY_NO_PREVIEW,
+ false);
+ BKE_mesh_apply_vert_coords(result, deformedVerts);
+
+ if (build_shapekey_layers)
+ add_shapekey_layers(result, me);
+
+ MEM_freeN(deformedVerts);
+ }
+ else {
+ Mesh *mesh_temp;
+ BKE_id_copy_ex(NULL, &me->id, (ID **)&mesh_temp,
+ LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG |
+ LIB_ID_COPY_NO_PREVIEW,
+ false);
+
+ if (build_shapekey_layers)
+ add_shapekey_layers(mesh_temp, me);
+
+ result = modifier_applyModifier(md, &mectx, mesh_temp);
+ ASSERT_IS_VALID_MESH(result);
+
+ if (mesh_temp != result) {
+ BKE_id_free(NULL, mesh_temp);
+ }
+ }
+
+ return result;
+}
+
+/* This is a Mesh-based copy of the same function in DerivedMesh.c */
+static void shapekey_layers_to_keyblocks(Mesh *mesh_src, Mesh *mesh_dst, int actshape_uid)
+{
+ KeyBlock *kb;
+ int i, j, tot;
+
+ if (!mesh_dst->key)
+ return;
+
+ tot = CustomData_number_of_layers(&mesh_src->vdata, CD_SHAPEKEY);
+ for (i = 0; i < tot; i++) {
+ CustomDataLayer *layer = &mesh_src->vdata.layers[CustomData_get_layer_index_n(&mesh_src->vdata, CD_SHAPEKEY, i)];
+ float (*cos)[3], (*kbcos)[3];
+
+ for (kb = mesh_dst->key->block.first; kb; kb = kb->next) {
+ if (kb->uid == layer->uid)
+ break;
+ }
+
+ if (!kb) {
+ kb = BKE_keyblock_add(mesh_dst->key, layer->name);
+ kb->uid = layer->uid;
+ }
+
+ if (kb->data)
+ MEM_freeN(kb->data);
+
+ cos = CustomData_get_layer_n(&mesh_src->vdata, CD_SHAPEKEY, i);
+ kb->totelem = mesh_src->totvert;
+
+ kb->data = kbcos = MEM_malloc_arrayN(kb->totelem, 3 * sizeof(float), "kbcos DerivedMesh.c");
+ if (kb->uid == actshape_uid) {
+ MVert *mvert = mesh_src->mvert;
+
+ for (j = 0; j < mesh_src->totvert; j++, kbcos++, mvert++) {
+ copy_v3_v3(*kbcos, mvert->co);
+ }
+ }
+ else {
+ for (j = 0; j < kb->totelem; j++, cos++, kbcos++) {
+ copy_v3_v3(*kbcos, *cos);
+ }
+ }
+ }
+
+ for (kb = mesh_dst->key->block.first; kb; kb = kb->next) {
+ if (kb->totelem != mesh_src->totvert) {
+ if (kb->data)
+ MEM_freeN(kb->data);
+
+ kb->totelem = mesh_src->totvert;
+ kb->data = MEM_calloc_arrayN(kb->totelem, 3 * sizeof(float), "kb->data derivedmesh.c");
+ fprintf(stderr, "%s: lost a shapekey layer: '%s'! (bmesh internal error)\n", __func__, kb->name);
+ }
+ }
+}
+
+
+/* This is a Mesh-based copy of DM_to_mesh() */
+void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, CustomDataMask mask, bool take_ownership)
+{
+ /* mesh_src might depend on mesh_dst, so we need to do everything with a local copy */
+ /* TODO(Sybren): the above claim came from DM_to_mesh(); check whether it is still true with Mesh */
+ Mesh tmp = *mesh_dst;
+ int totvert, totedge /*, totface */ /* UNUSED */, totloop, totpoly;
+ int did_shapekeys = 0;
+ eCDAllocType alloctype = CD_DUPLICATE;
+
+ if (take_ownership /* && dm->type == DM_TYPE_CDDM && dm->needsFree */) {
+ bool has_any_referenced_layers =
+ CustomData_has_referenced(&mesh_src->vdata) ||
+ CustomData_has_referenced(&mesh_src->edata) ||
+ CustomData_has_referenced(&mesh_src->ldata) ||
+ CustomData_has_referenced(&mesh_src->fdata) ||
+ CustomData_has_referenced(&mesh_src->pdata);
+ if (!has_any_referenced_layers) {
+ alloctype = CD_ASSIGN;
+ }
+ }
+ CustomData_reset(&tmp.vdata);
+ CustomData_reset(&tmp.edata);
+ CustomData_reset(&tmp.fdata);
+ CustomData_reset(&tmp.ldata);
+ CustomData_reset(&tmp.pdata);
+
+ BKE_mesh_ensure_normals(mesh_src);
+
+ totvert = tmp.totvert = mesh_src->totvert;
+ totedge = tmp.totedge = mesh_src->totedge;
+ totloop = tmp.totloop = mesh_src->totloop;
+ totpoly = tmp.totpoly = mesh_src->totpoly;
+ tmp.totface = 0;
+
+ CustomData_copy(&mesh_src->vdata, &tmp.vdata, mask, alloctype, totvert);
+ CustomData_copy(&mesh_src->edata, &tmp.edata, mask, alloctype, totedge);
+ CustomData_copy(&mesh_src->ldata, &tmp.ldata, mask, alloctype, totloop);
+ CustomData_copy(&mesh_src->pdata, &tmp.pdata, mask, alloctype, totpoly);
+ tmp.cd_flag = mesh_src->cd_flag;
+ tmp.runtime.deformed_only = mesh_src->runtime.deformed_only;
+
+ if (CustomData_has_layer(&mesh_src->vdata, CD_SHAPEKEY)) {
+ KeyBlock *kb;
+ int uid;
+
+ if (ob) {
+ kb = BLI_findlink(&mesh_dst->key->block, ob->shapenr - 1);
+ if (kb) {
+ uid = kb->uid;
+ }
+ else {
+ printf("%s: error - could not find active shapekey %d!\n",
+ __func__, ob->shapenr - 1);
+
+ uid = INT_MAX;
+ }
+ }
+ else {
+ /* if no object, set to INT_MAX so we don't mess up any shapekey layers */
+ uid = INT_MAX;
+ }
+
+ shapekey_layers_to_keyblocks(mesh_src, mesh_dst, uid);
+ did_shapekeys = 1;
+ }
+
+ /* copy texture space */
+ if (ob) {
+ BKE_mesh_texspace_copy_from_object(&tmp, ob);
+ }
+
+ /* not all DerivedMeshes store their verts/edges/faces in CustomData, so
+ * we set them here in case they are missing */
+ /* TODO(Sybren): we could probably replace CD_ASSIGN with alloctype and always directly pass mesh_src->mxxx,
+ * instead of using a ternary operator. */
+ if (!CustomData_has_layer(&tmp.vdata, CD_MVERT)) {
+ CustomData_add_layer(&tmp.vdata, CD_MVERT, CD_ASSIGN,
+ (alloctype == CD_ASSIGN) ? mesh_src->mvert : MEM_dupallocN(mesh_src->mvert),
+ totvert);
+ }
+ if (!CustomData_has_layer(&tmp.edata, CD_MEDGE)) {
+ CustomData_add_layer(&tmp.edata, CD_MEDGE, CD_ASSIGN,
+ (alloctype == CD_ASSIGN) ? mesh_src->medge : MEM_dupallocN(mesh_src->medge),
+ totedge);
+ }
+ if (!CustomData_has_layer(&tmp.pdata, CD_MPOLY)) {
+ /* TODO(Sybren): assigment to tmp.mxxx is probably not necessary due to the
+ * BKE_mesh_update_customdata_pointers() call below. */
+ tmp.mloop = (alloctype == CD_ASSIGN) ? mesh_src->mloop : MEM_dupallocN(mesh_src->mloop);
+ tmp.mpoly = (alloctype == CD_ASSIGN) ? mesh_src->mpoly : MEM_dupallocN(mesh_src->mpoly);
+
+ CustomData_add_layer(&tmp.ldata, CD_MLOOP, CD_ASSIGN, tmp.mloop, tmp.totloop);
+ CustomData_add_layer(&tmp.pdata, CD_MPOLY, CD_ASSIGN, tmp.mpoly, tmp.totpoly);
+ }
+
+ /* object had got displacement layer, should copy this layer to save sculpted data */
+ /* NOTE: maybe some other layers should be copied? nazgul */
+ if (CustomData_has_layer(&mesh_dst->ldata, CD_MDISPS)) {
+ if (totloop == mesh_dst->totloop) {
+ MDisps *mdisps = CustomData_get_layer(&mesh_dst->ldata, CD_MDISPS);
+ CustomData_add_layer(&tmp.ldata, CD_MDISPS, alloctype, mdisps, totloop);
+ }
+ }
+
+ /* yes, must be before _and_ after tessellate */
+ BKE_mesh_update_customdata_pointers(&tmp, false);
+
+ /* since 2.65 caller must do! */
+ // BKE_mesh_tessface_calc(&tmp);
+
+ CustomData_free(&mesh_dst->vdata, mesh_dst->totvert);
+ CustomData_free(&mesh_dst->edata, mesh_dst->totedge);
+ CustomData_free(&mesh_dst->fdata, mesh_dst->totface);
+ CustomData_free(&mesh_dst->ldata, mesh_dst->totloop);
+ CustomData_free(&mesh_dst->pdata, mesh_dst->totpoly);
+
+ /* ok, this should now use new CD shapekey data,
+ * which should be fed through the modifier
+ * stack */
+ if (tmp.totvert != mesh_dst->totvert && !did_shapekeys && mesh_dst->key) {
+ printf("%s: YEEK! this should be recoded! Shape key loss!: ID '%s'\n", __func__, tmp.id.name);
+ if (tmp.key && !(tmp.id.tag & LIB_TAG_NO_MAIN)) {
+ id_us_min(&tmp.key->id);
+ }
+ tmp.key = NULL;
+ }
+
+ /* Clear selection history */
+ MEM_SAFE_FREE(tmp.mselect);
+ tmp.totselect = 0;
+ BLI_assert(ELEM(tmp.bb, NULL, mesh_dst->bb));
+ if (mesh_dst->bb) {
+ MEM_freeN(mesh_dst->bb);
+ tmp.bb = NULL;
+ }
+
+ /* skip the listbase */
+ MEMCPY_STRUCT_OFS(mesh_dst, &tmp, id.prev);
+
+ if (take_ownership) {
+ if (alloctype == CD_ASSIGN) {
+ CustomData_free_typemask(&mesh_src->vdata, mesh_src->totvert, ~mask);
+ CustomData_free_typemask(&mesh_src->edata, mesh_src->totedge, ~mask);
+ CustomData_free_typemask(&mesh_src->ldata, mesh_src->totloop, ~mask);
+ CustomData_free_typemask(&mesh_src->pdata, mesh_src->totpoly, ~mask);
+ }
+ BKE_id_free(NULL, mesh_src);
+ }
+}
+
+/* This is a Mesh-based copy of DM_to_meshkey() */
+void BKE_mesh_nomain_to_meshkey(Mesh *mesh_src, Mesh *mesh_dst, KeyBlock *kb)
+{
+ int a, totvert = mesh_src->totvert;
+ float *fp;
+ MVert *mvert;
+
+ if (totvert == 0 || mesh_dst->totvert == 0 || mesh_dst->totvert != totvert) {
+ return;
+ }
+
+ if (kb->data) MEM_freeN(kb->data);
+ kb->data = MEM_malloc_arrayN(mesh_dst->key->elemsize, mesh_dst->totvert, "kb->data");
+ kb->totelem = totvert;
+
+ fp = kb->data;
+ mvert = mesh_src->mvert;
+
+ for (a = 0; a < kb->totelem; a++, fp += 3, mvert++) {
+ copy_v3_v3(fp, mvert->co);
+ }
+}
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 997201fc4d0..4e1297043d0 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -88,6 +88,20 @@ static void mesh_calc_normals_vert_fallback(MVert *mverts, int numVerts)
}
}
+/* TODO(Sybren): we can probably rename this to BKE_mesh_calc_normals_mapping(),
+ * and remove the function of the same name below, as that one doesn't seem to be
+ * called anywhere. */
+void BKE_mesh_calc_normals_mapping_simple(struct Mesh *mesh)
+{
+ const bool only_face_normals = CustomData_is_referenced_layer(&mesh->vdata, CD_MVERT);
+
+ BKE_mesh_calc_normals_mapping_ex(
+ mesh->mvert, mesh->totvert,
+ mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, NULL,
+ mesh->mface, mesh->totface, NULL, NULL,
+ only_face_normals);
+}
+
/* Calculate vertex and face normals, face normals are returned in *r_faceNors if non-NULL
* and vertex normals are stored in actual mverts.
*/
diff --git a/source/blender/blenkernel/intern/mesh_runtime.c b/source/blender/blenkernel/intern/mesh_runtime.c
index c8416811694..cd9db408d19 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.c
+++ b/source/blender/blenkernel/intern/mesh_runtime.c
@@ -35,13 +35,22 @@
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
#include "BLI_math_geom.h"
#include "BLI_threads.h"
#include "BKE_bvhutils.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
+#ifdef USE_DERIVEDMESH
+#include "BKE_DerivedMesh.h"
+#endif
+
+/* -------------------------------------------------------------------- */
+/** \name Mesh Runtime Struct Utils
+ * \{ */
static ThreadRWMutex loops_cache_lock = PTHREAD_RWLOCK_INITIALIZER;
@@ -145,8 +154,9 @@ const MLoopTri *BKE_mesh_runtime_looptri_ensure(Mesh *mesh)
}
/* This is a copy of DM_verttri_from_looptri(). */
-void BKE_mesh_runtime_verttri_from_looptri(MVertTri *r_verttri, const MLoop *mloop,
- const MLoopTri *looptri, int looptri_num)
+void BKE_mesh_runtime_verttri_from_looptri(
+ MVertTri *r_verttri, const MLoop *mloop,
+ const MLoopTri *looptri, int looptri_num)
{
int i;
for (i = 0; i < looptri_num; i++) {
@@ -192,6 +202,12 @@ void BKE_mesh_runtime_clear_geometry(Mesh *mesh)
MEM_SAFE_FREE(mesh->runtime.looptris.array);
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Mesh Batch Cache Callbacks
+ * \{ */
+
/* Draw Engine */
void (*BKE_mesh_batch_cache_dirty_cb)(Mesh *me, int mode) = NULL;
void (*BKE_mesh_batch_cache_free_cb)(Mesh *me) = NULL;
@@ -208,3 +224,5 @@ void BKE_mesh_batch_cache_free(Mesh *me)
BKE_mesh_batch_cache_free_cb(me);
}
}
+
+/** \} */
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 111968ba018..0b904caf375 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -60,6 +60,8 @@
#include "BKE_appdir.h"
#include "BKE_cdderivedmesh.h"
+#include "BKE_editmesh.h"
+#include "BKE_global.h"
#include "BKE_idcode.h"
#include "BKE_key.h"
#include "BKE_library.h"
@@ -70,7 +72,6 @@
#include "BKE_DerivedMesh.h"
/* may move these, only for modifier_path_relbase */
-#include "BKE_global.h" /* ugh, G.main->name only */
#include "BKE_main.h"
/* end */
@@ -399,9 +400,9 @@ void modifier_setError(ModifierData *md, const char *_format, ...)
/* used for buttons, to find out if the 'draw deformed in editmode' option is
* there
- *
+ *
* also used in transform_conversion.c, to detect CrazySpace [tm] (2nd arg
- * then is NULL)
+ * then is NULL)
* also used for some mesh tools to give warnings
*/
int modifiers_getCageIndex(struct Scene *scene, Object *ob, int *r_lastPossibleCageIndex, bool is_virtual)
@@ -796,10 +797,22 @@ void test_object_modifiers(Object *ob)
* - else if the file has been saved return the blend file path.
* - else if the file isn't saved and the ID isn't from a library, return the temp dir.
*/
-const char *modifier_path_relbase(Object *ob)
+const char *modifier_path_relbase(Main *bmain, Object *ob)
+{
+ if (G.relbase_valid || ID_IS_LINKED(ob)) {
+ return ID_BLEND_PATH(bmain, &ob->id);
+ }
+ else {
+ /* last resort, better then using "" which resolves to the current
+ * working directory */
+ return BKE_tempdir_session();
+ }
+}
+
+const char *modifier_path_relbase_from_global(Object *ob)
{
if (G.relbase_valid || ID_IS_LINKED(ob)) {
- return ID_BLEND_PATH(G.main, &ob->id);
+ return ID_BLEND_PATH_FROM_GLOBAL(&ob->id);
}
else {
/* last resort, better then using "" which resolves to the current
@@ -1212,13 +1225,26 @@ struct DerivedMesh *modifier_applyModifierEM_DM_deprecated(struct ModifierData *
}
}
-/** Get evaluated mesh for other object, which is used as an operand for the modifier,
- * i.e. second operand for boolean modifier.
+/**
+ * Get evaluated mesh for other evaluated object, which is used as an operand for the modifier,
+ * e.g. second operand for boolean modifier.
+ * Note thqt modifiers in stack always get fully evaluated COW ID pointers, never original ones. Makes things simpler.
*/
-Mesh *BKE_modifier_get_evaluated_mesh_from_object(const ModifierEvalContext *ctx, Object *ob)
+Mesh *BKE_modifier_get_evaluated_mesh_from_evaluated_object(Object *ob_eval, bool *r_free_mesh)
{
- /* Note: we do not care about RENDER setting here, since we get data from despgraph
- * (and render depsgraph shall be different from realtime one)
- */
- return BKE_object_get_evaluated_mesh(ctx->depsgraph, ob);
+ Mesh *me;
+
+ if ((ob_eval->type == OB_MESH) && (ob_eval->mode & OB_MODE_EDIT)) {
+ /* Note: currently we have no equivalent to derived cagemesh or even final dm in BMEditMesh...
+ * This is TODO in core depsgraph/modifier stack code still. */
+ BMEditMesh *em = BKE_editmesh_from_object(ob_eval);
+ me = BKE_bmesh_to_mesh_nomain(em->bm, &(struct BMeshToMeshParams){0});
+ *r_free_mesh = true;
+ }
+ else {
+ me = ob_eval->runtime.mesh_eval;
+ *r_free_mesh = false;
+ }
+
+ return me;
}
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index d742bcea69d..fc236cc2ad0 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -199,7 +199,7 @@ static void get_proxy_fname(const MovieClip *clip,
else
BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d/%08d", dir, clipfile, size, proxynr);
- BLI_path_abs(name, G.main->name);
+ BLI_path_abs(name, BKE_main_blendfile_path_from_global());
BLI_path_frame(name, 1, 0);
strcat(name, ".jpg");
@@ -270,7 +270,7 @@ static void movieclip_open_anim_file(MovieClip *clip)
if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) {
char dir[FILE_MAX];
BLI_strncpy(dir, clip->proxy.dir, sizeof(dir));
- BLI_path_abs(dir, G.main->name);
+ BLI_path_abs(dir, BKE_main_blendfile_path_from_global());
IMB_anim_set_index_dir(clip->anim, dir);
}
}
@@ -627,13 +627,13 @@ static void movieclip_load_get_size(MovieClip *clip)
}
}
-static void detect_clip_source(MovieClip *clip)
+static void detect_clip_source(Main *bmain, MovieClip *clip)
{
ImBuf *ibuf;
char name[FILE_MAX];
BLI_strncpy(name, clip->name, sizeof(name));
- BLI_path_abs(name, G.main->name);
+ BLI_path_abs(name, BKE_main_blendfile_path(bmain));
ibuf = IMB_testiffname(name, IB_rect | IB_multilayer);
if (ibuf) {
@@ -656,7 +656,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name)
char str[FILE_MAX];
BLI_strncpy(str, name, sizeof(str));
- BLI_path_abs(str, bmain->name);
+ BLI_path_abs(str, BKE_main_blendfile_path(bmain));
/* exists? */
file = BLI_open(str, O_BINARY | O_RDONLY, 0);
@@ -670,7 +670,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name)
clip = movieclip_alloc(bmain, BLI_path_basename(name));
BLI_strncpy(clip->name, name, sizeof(clip->name));
- detect_clip_source(clip);
+ detect_clip_source(bmain, clip);
movieclip_load_get_size(clip);
if (clip->lastsize[0]) {
@@ -690,7 +690,7 @@ MovieClip *BKE_movieclip_file_add_exists_ex(Main *bmain, const char *filepath, b
char str[FILE_MAX], strtest[FILE_MAX];
BLI_strncpy(str, filepath, sizeof(str));
- BLI_path_abs(str, bmain->name);
+ BLI_path_abs(str, BKE_main_blendfile_path(bmain));
/* first search an identical filepath */
for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
@@ -1282,13 +1282,13 @@ void BKE_movieclip_clear_proxy_cache(MovieClip *clip)
}
}
-void BKE_movieclip_reload(MovieClip *clip)
+void BKE_movieclip_reload(Main *bmain, MovieClip *clip)
{
/* clear cache */
free_buffers(clip);
/* update clip source */
- detect_clip_source(clip);
+ detect_clip_source(bmain, clip);
clip->lastsize[0] = clip->lastsize[1] = 0;
movieclip_load_get_size(clip);
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index ee32c2398b2..39a472241bc 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -51,6 +51,7 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_multires.h"
#include "BKE_paint.h"
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 777c2a580fd..b91887e6815 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -73,7 +73,7 @@
/* Freeing ------------------------------------------- */
/* Remove the given NLA strip from the NLA track it occupies, free the strip's data,
- * and the strip itself.
+ * and the strip itself.
*/
void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip)
{
@@ -400,7 +400,7 @@ NlaStrip *BKE_nla_add_soundstrip(Scene *scene, Speaker *speaker)
/* Strip Mapping ------------------------------------- */
/* non clipped mapping for strip-time <-> global time (for Action-Clips)
- * invert = convert action-strip time to global time
+ * invert = convert action-strip time to global time
*/
static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short mode)
{
@@ -470,7 +470,7 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short
}
/* non clipped mapping for strip-time <-> global time (for Transitions)
- * invert = convert action-strip time to global time
+ * invert = convert action-strip time to global time
*/
static float nlastrip_get_frame_transition(NlaStrip *strip, float cframe, short mode)
{
@@ -597,7 +597,7 @@ bool BKE_nlastrips_has_space(ListBase *strips, float start, float end)
}
/* Rearrange the strips in the track so that they are always in order
- * (usually only needed after a strip has been moved)
+ * (usually only needed after a strip has been moved)
*/
void BKE_nlastrips_sort_strips(ListBase *strips)
{
@@ -1037,7 +1037,7 @@ bool BKE_nlatrack_has_space(NlaTrack *nlt, float start, float end)
}
/* Rearrange the strips in the track so that they are always in order
- * (usually only needed after a strip has been moved)
+ * (usually only needed after a strip has been moved)
*/
void BKE_nlatrack_sort_strips(NlaTrack *nlt)
{
@@ -1050,7 +1050,7 @@ void BKE_nlatrack_sort_strips(NlaTrack *nlt)
}
/* Add the given NLA-Strip to the given NLA-Track, assuming that it
- * isn't currently attached to another one
+ * isn't currently attached to another one
*/
bool BKE_nlatrack_add_strip(NlaTrack *nlt, NlaStrip *strip)
{
@@ -1757,7 +1757,7 @@ bool BKE_nla_action_stash(AnimData *adt)
/* Core Tools ------------------------------------------- */
/* For the given AnimData block, add the active action to the NLA
- * stack (i.e. 'push-down' action). The UI should only allow this
+ * stack (i.e. 'push-down' action). The UI should only allow this
* for normal editing only (i.e. not in editmode for some strip's action),
* so no checks for this are performed.
*/
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index a25b21a995a..2031bb4e9d4 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -836,7 +836,7 @@ bool nodeIsChildOf(const bNode *parent, const bNode *child)
/**
* Iterate over a chain of nodes, starting with \a node_start, executing
* \a callback for each node (which can return false to end iterator).
- *
+ *
* \param reversed for backwards iteration
* \note Recursive
*/
@@ -868,7 +868,7 @@ void nodeChainIter(
/**
* Iterate over all parents of \a node, executing \a callback for each parent (which can return false to end iterator)
- *
+ *
* \note Recursive
*/
void nodeParentsIter(bNode *node, bool (*callback)(bNode *, void *), void *userdata)
@@ -1684,7 +1684,7 @@ static void node_free_node_ex(bNodeTree *ntree, bNode *node, bool remove_animdat
remove_animdata &= ntree && !(ntree->flag & NTREE_IS_LOCALIZED);
/* extra free callback */
- if (use_api_free_cb && node->typeinfo->freefunc_api) {
+ if (use_api_free_cb && node->typeinfo != NULL && node->typeinfo->freefunc_api) {
PointerRNA ptr;
RNA_pointer_create((ID *)ntree, &RNA_Node, node, &ptr);
@@ -1711,7 +1711,7 @@ static void node_free_node_ex(bNodeTree *ntree, bNode *node, bool remove_animdat
BKE_animdata_fix_paths_remove((ID *)ntree, prefix);
}
- if (ntree->typeinfo->free_node_cache)
+ if (node->typeinfo != NULL && ntree->typeinfo->free_node_cache)
ntree->typeinfo->free_node_cache(ntree, node);
/* texture node has bad habit of keeping exec data around */
@@ -1721,7 +1721,7 @@ static void node_free_node_ex(bNodeTree *ntree, bNode *node, bool remove_animdat
}
}
- if (node->typeinfo->freefunc) {
+ if (node->typeinfo != NULL && node->typeinfo->freefunc) {
node->typeinfo->freefunc(node);
}
@@ -1933,15 +1933,15 @@ void ntreeSetOutput(bNodeTree *ntree)
* might be different for editor or for "real" use... */
}
-bNodeTree *ntreeFromID(ID *id)
+bNodeTree *ntreeFromID(const ID *id)
{
switch (GS(id->name)) {
- case ID_MA: return ((Material *)id)->nodetree;
- case ID_LA: return ((Lamp *)id)->nodetree;
- case ID_WO: return ((World *)id)->nodetree;
- case ID_TE: return ((Tex *)id)->nodetree;
- case ID_SCE: return ((Scene *)id)->nodetree;
- case ID_LS: return ((FreestyleLineStyle *)id)->nodetree;
+ case ID_MA: return ((const Material *)id)->nodetree;
+ case ID_LA: return ((const Lamp *)id)->nodetree;
+ case ID_WO: return ((const World *)id)->nodetree;
+ case ID_TE: return ((const Tex *)id)->nodetree;
+ case ID_SCE: return ((const Scene *)id)->nodetree;
+ case ID_LS: return ((const FreestyleLineStyle *)id)->nodetree;
default: return NULL;
}
}
@@ -2050,11 +2050,11 @@ void ntreeLocalSync(bNodeTree *localtree, bNodeTree *ntree)
/* merge local tree results back, and free local tree */
/* we have to assume the editor already changed completely */
-void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree)
+void ntreeLocalMerge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree)
{
if (ntree && localtree) {
if (ntree->typeinfo->local_merge)
- ntree->typeinfo->local_merge(localtree, ntree);
+ ntree->typeinfo->local_merge(bmain, localtree, ntree);
ntreeFreeTree(localtree);
MEM_freeN(localtree);
@@ -3739,43 +3739,9 @@ void BKE_nodetree_remove_layer_n(bNodeTree *ntree, Scene *scene, const int layer
}
}
-static void node_copy_default_values_list(ListBase *sockets_dst,
- const ListBase *sockets_src)
-{
- bNodeSocket *sock_dst = sockets_dst->first;
- const bNodeSocket *sock_src = sockets_src->first;
- while (sock_dst != NULL) {
- node_socket_copy_default_value(sock_dst, sock_src);
- sock_dst = sock_dst->next;
- sock_src = sock_src->next;
- }
-}
-
-static void node_copy_default_values(bNode *node_dst, const bNode *node_src)
-{
- node_copy_default_values_list(&node_dst->inputs, &node_src->inputs);
- node_copy_default_values_list(&node_dst->outputs, &node_src->outputs);
-}
-
-void BKE_nodetree_copy_default_values(bNodeTree *ntree_dst,
- const bNodeTree *ntree_src)
-{
- if (ntree_dst == ntree_src) {
- return;
- }
- bNode *node_dst = ntree_dst->nodes.first;
- const bNode *node_src = ntree_src->nodes.first;
- while (node_dst != NULL) {
- node_copy_default_values(node_dst, node_src);
- node_dst = node_dst->next;
- node_src = node_src->next;
- }
-}
-
void BKE_nodetree_shading_params_eval(struct Depsgraph *depsgraph,
bNodeTree *ntree_dst,
const bNodeTree *ntree_src)
{
DEG_debug_print_eval(depsgraph, __func__, ntree_src->id.name, ntree_dst);
- BKE_nodetree_copy_default_values(ntree_dst, ntree_src);
}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index ab3300c4ff7..f55925f64f5 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -330,6 +330,34 @@ void BKE_object_free_derived_caches(Object *ob)
ob->bb = NULL;
}
+ BKE_object_free_derived_mesh_caches(ob);
+
+ if (ob->runtime.mesh_eval != NULL) {
+ Mesh *mesh_eval = ob->runtime.mesh_eval;
+ /* Restore initial pointer. */
+ if (ob->data == mesh_eval) {
+ ob->data = ob->runtime.mesh_orig;
+ }
+ /* Evaluated mesh points to edit mesh, but does not own it. */
+ mesh_eval->edit_btmesh = NULL;
+ BKE_mesh_free(mesh_eval);
+ BKE_libblock_free_data(&mesh_eval->id, false);
+ MEM_freeN(mesh_eval);
+ ob->runtime.mesh_eval = NULL;
+ }
+ if (ob->runtime.mesh_deform_eval != NULL) {
+ Mesh *mesh_deform_eval = ob->runtime.mesh_deform_eval;
+ BKE_mesh_free(mesh_deform_eval);
+ BKE_libblock_free_data(&mesh_deform_eval->id, false);
+ MEM_freeN(mesh_deform_eval);
+ ob->runtime.mesh_deform_eval = NULL;
+ }
+
+ BKE_object_free_curve_cache(ob);
+}
+
+void BKE_object_free_derived_mesh_caches(struct Object *ob)
+{
if (ob->derivedFinal) {
ob->derivedFinal->needsFree = 1;
ob->derivedFinal->release(ob->derivedFinal);
@@ -340,19 +368,6 @@ void BKE_object_free_derived_caches(Object *ob)
ob->derivedDeform->release(ob->derivedDeform);
ob->derivedDeform = NULL;
}
-
- if (ob->mesh_evaluated != NULL) {
- /* Restore initial pointer. */
- ob->data = ob->mesh_evaluated->id.orig_id;
- /* Evaluated mesh points to edit mesh, but does not own it. */
- ob->mesh_evaluated->edit_btmesh = NULL;
- BKE_mesh_free(ob->mesh_evaluated);
- BKE_libblock_free_data(&ob->mesh_evaluated->id, false);
- MEM_freeN(ob->mesh_evaluated);
- ob->mesh_evaluated = NULL;
- }
-
- BKE_object_free_curve_cache(ob);
}
void BKE_object_free_caches(Object *object)
@@ -502,21 +517,36 @@ bool BKE_object_is_in_editmode(const Object *ob)
return false;
}
-bool BKE_object_is_in_editmode_and_selected(const Object *ob)
-{
- if ((ob->base_flag & BASE_SELECTED) && (BKE_object_is_in_editmode(ob))) {
- return true;
- }
- return false;
-}
-
-
bool BKE_object_is_in_editmode_vgroup(const Object *ob)
{
return (OB_TYPE_SUPPORT_VGROUP(ob->type) &&
BKE_object_is_in_editmode(ob));
}
+bool BKE_object_data_is_in_editmode(const ID *id)
+{
+ const short type = GS(id->name);
+ BLI_assert(OB_DATA_SUPPORT_EDITMODE(type));
+ switch (type) {
+ case ID_ME:
+ return ((const Mesh *)id)->edit_btmesh != NULL;
+ case ID_CU:
+ return (
+ (((const Curve *)id)->editnurb != NULL) ||
+ (((const Curve *)id)->editfont != NULL)
+ );
+ case ID_MB:
+ return ((const MetaBall *)id)->editelems != NULL;
+ case ID_LT:
+ return ((const Lattice *)id)->editlatt != NULL;
+ case ID_AR:
+ return ((const bArmature *)id)->edbo != NULL;
+ default:
+ BLI_assert(0);
+ return false;
+ }
+}
+
bool BKE_object_is_in_wpaint_select_vert(const Object *ob)
{
if (ob->type == OB_MESH) {
@@ -559,6 +589,12 @@ bool BKE_object_has_mode_data(const struct Object *ob, eObjectMode object_mode)
return false;
}
+bool BKE_object_is_mode_compat(const struct Object *ob, eObjectMode object_mode)
+{
+ return ((ob->mode == object_mode) ||
+ (ob->mode & object_mode) != 0);
+}
+
/**
* Return if the object is visible, as evaluated by depsgraph
*/
@@ -589,13 +625,13 @@ bool BKE_object_is_visible(Object *ob, const eObjectVisibilityCheck mode)
}
}
-bool BKE_object_exists_check(const Object *obtest)
+bool BKE_object_exists_check(Main *bmain, const Object *obtest)
{
Object *ob;
if (obtest == NULL) return false;
- ob = G.main->object.first;
+ ob = bmain->object.first;
while (ob) {
if (ob == obtest) return true;
ob = ob->id.next;
@@ -1199,7 +1235,8 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_
BLI_listbase_clear(&ob_dst->drawdata);
BLI_listbase_clear(&ob_dst->pc_ids);
- ob_dst->mpath = NULL;
+ ob_dst->avs = ob_src->avs;
+ ob_dst->mpath = animviz_copy_motionpath(ob_src->mpath);
copy_object_lod(ob_dst, ob_src, flag_subdata);
@@ -1684,7 +1721,7 @@ void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4])
if (ob->parent) {
float par_imat[4][4];
- BKE_object_get_parent_matrix(NULL, ob, ob->parent, par_imat);
+ BKE_object_get_parent_matrix(NULL, NULL, ob, ob->parent, par_imat);
invert_m4(par_imat);
mul_m4_m4m4(mat, par_imat, ob->obmat);
}
@@ -1697,10 +1734,10 @@ void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4])
int enable_cu_speed = 1;
/**
- * \param scene: Used when curve cache needs to be calculated, or for dupli-frame time.
+ * \param depsgraph: Used for dupli-frame time.
* \return success if \a mat is set.
*/
-static bool ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
+static bool ob_parcurve(Depsgraph *depsgraph, Scene *UNUSED(scene), Object *ob, Object *par, float mat[4][4])
{
Curve *cu = par->data;
float vec[4], dir[3], quat[4], radius, ctime;
@@ -1739,11 +1776,11 @@ static bool ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
}
else {
/* For dupli-frames only */
- if (scene == NULL) {
+ if (depsgraph == NULL) {
return false;
}
- ctime = BKE_scene_frame_get(scene);
+ ctime = DEG_get_ctime(depsgraph);
if (cu->pathlen) {
ctime /= cu->pathlen;
}
@@ -1994,7 +2031,7 @@ static void ob_parvert3(Object *ob, Object *par, float mat[4][4])
}
-void BKE_object_get_parent_matrix(Scene *scene, Object *ob, Object *par, float parentmat[4][4])
+void BKE_object_get_parent_matrix(Depsgraph *depsgraph, Scene *scene, Object *ob, Object *par, float parentmat[4][4])
{
float tmat[4][4];
float vec[3];
@@ -2005,7 +2042,7 @@ void BKE_object_get_parent_matrix(Scene *scene, Object *ob, Object *par, float p
ok = 0;
if (par->type == OB_CURVE) {
if ((((Curve *)par->data)->flag & CU_PATH) &&
- (ob_parcurve(scene, ob, par, tmat)))
+ (ob_parcurve(depsgraph, scene, ob, par, tmat)))
{
ok = 1;
}
@@ -2041,7 +2078,8 @@ void BKE_object_get_parent_matrix(Scene *scene, Object *ob, Object *par, float p
/**
* \param r_originmat Optional matrix that stores the space the object is in (without its own matrix applied)
*/
-static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4][4], float slowmat[4][4],
+static void solve_parenting(Depsgraph *depsgraph,
+ Scene *scene, Object *ob, Object *par, float obmat[4][4], float slowmat[4][4],
float r_originmat[3][3], const bool set_origin)
{
float totmat[4][4];
@@ -2052,7 +2090,7 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4
if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat);
- BKE_object_get_parent_matrix(scene, ob, par, totmat);
+ BKE_object_get_parent_matrix(depsgraph, scene, ob, par, totmat);
/* total */
mul_m4_m4m4(tmat, totmat, ob->parentinv);
@@ -2102,14 +2140,14 @@ void BKE_object_where_is_calc_time_ex(
if (ob == NULL) return;
/* execute drivers only, as animation has already been done */
- BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_DRIVERS);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, ctime, ADT_RECALC_DRIVERS);
if (ob->parent) {
Object *par = ob->parent;
float slowmat[4][4];
/* calculate parent matrix */
- solve_parenting(scene, ob, par, ob->obmat, slowmat, r_originmat, true);
+ solve_parenting(depsgraph, scene, ob, par, ob->obmat, slowmat, r_originmat, true);
/* "slow parent" is definitely not threadsafe, and may also give bad results jumping around
* An old-fashioned hack which probably doesn't really cut it anymore
@@ -2150,7 +2188,7 @@ void BKE_object_where_is_calc_time(Depsgraph *depsgraph, Scene *scene, Object *o
* constraints -- assume dependencies are already solved by depsgraph.
* no changes to object and it's parent would be done.
* used for bundles orientation in 3d space relative to parented blender camera */
-void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
+void BKE_object_where_is_calc_mat4(Depsgraph *depsgraph, Scene *scene, Object *ob, float obmat[4][4])
{
if (ob->parent) {
@@ -2158,7 +2196,7 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
Object *par = ob->parent;
- solve_parenting(scene, ob, par, obmat, slowmat, NULL, false);
+ solve_parenting(depsgraph, scene, ob, par, obmat, slowmat, NULL, false);
if (ob->partype & PARSLOW)
where_is_object_parslow(ob, obmat, slowmat);
@@ -2170,35 +2208,44 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
void BKE_object_where_is_calc_ex(Depsgraph *depsgraph, Scene *scene, RigidBodyWorld *rbw, Object *ob, float r_originmat[3][3])
{
- BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, BKE_scene_frame_get(scene), rbw, r_originmat);
+ BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, DEG_get_ctime(depsgraph), rbw, r_originmat);
}
void BKE_object_where_is_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
- BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, BKE_scene_frame_get(scene), NULL, NULL);
+ BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, DEG_get_ctime(depsgraph), NULL, NULL);
}
-/* for calculation of the inverse parent transform, only used for editor */
+/**
+ * For calculation of the inverse parent transform, only used for editor.
+ *
+ * It assumes the object parent is already in the depsgraph.
+ * Otherwise, after changing ob->parent you need to call:
+ * DEG_relations_tag_update(bmain);
+ * BKE_scene_graph_update_tagged(depsgraph, bmain);
+ */
void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *ob, Object *workob)
{
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
BKE_object_workob_clear(workob);
unit_m4(workob->obmat);
unit_m4(workob->parentinv);
unit_m4(workob->constinv);
- workob->parent = ob->parent;
- workob->trackflag = ob->trackflag;
- workob->upflag = ob->upflag;
+ /* Since this is used while calculating parenting, at this moment ob_eval->parent is still NULL. */
+ workob->parent = DEG_get_evaluated_object(depsgraph, ob->parent);
+
+ workob->trackflag = ob_eval->trackflag;
+ workob->upflag = ob_eval->upflag;
- workob->partype = ob->partype;
- workob->par1 = ob->par1;
- workob->par2 = ob->par2;
- workob->par3 = ob->par3;
+ workob->partype = ob_eval->partype;
+ workob->par1 = ob_eval->par1;
+ workob->par2 = ob_eval->par2;
+ workob->par3 = ob_eval->par3;
- workob->constraints.first = ob->constraints.first;
- workob->constraints.last = ob->constraints.last;
+ workob->constraints = ob_eval->constraints;
- BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
+ BLI_strncpy(workob->parsubstr, ob_eval->parsubstr, sizeof(workob->parsubstr));
BKE_object_where_is_calc(depsgraph, scene, workob);
}
@@ -2219,7 +2266,7 @@ void BKE_object_apply_mat4_ex(Object *ob, float mat[4][4], Object *parent, float
if (parent != NULL) {
float rmat[4][4], diff_mat[4][4], imat[4][4], parent_mat[4][4];
- BKE_object_get_parent_matrix(NULL, ob, parent, parent_mat);
+ BKE_object_get_parent_matrix(NULL, NULL, ob, parent, parent_mat);
mul_m4_m4m4(diff_mat, parent_mat, parentinv);
invert_m4_m4(imat, diff_mat);
@@ -2806,10 +2853,63 @@ int BKE_object_obdata_texspace_get(Object *ob, short **r_texflag, float **r_loc,
Mesh *BKE_object_get_evaluated_mesh(const Depsgraph *depsgraph, Object *ob)
{
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+ return ob_eval->runtime.mesh_eval;
+}
- return ob_eval->mesh_evaluated;
+/* Get object's mesh with all modifiers applied. */
+Mesh *BKE_object_get_final_mesh(Object *object)
+{
+ if (object->runtime.mesh_eval != NULL) {
+ BLI_assert((object->id.tag & LIB_TAG_COPIED_ON_WRITE) != 0);
+ BLI_assert(object->runtime.mesh_eval == object->data);
+ BLI_assert((object->runtime.mesh_eval->id.tag & LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT) != 0);
+ return object->runtime.mesh_eval;
+ }
+ /* Wasn't evaluated yet. */
+ return object->data;
}
+/* Get mesh which is not affected by modifiers:
+ * - For original objects it will be same as object->data, and it is a mesh
+ * which is in the corresponding bmain.
+ * - For copied-on-write objects it will give pointer to a copied-on-write
+ * mesh which corresponds to original object's mesh.
+ */
+Mesh *BKE_object_get_pre_modified_mesh(Object *object)
+{
+ if (object->runtime.mesh_orig != NULL) {
+ BLI_assert(object->id.tag & LIB_TAG_COPIED_ON_WRITE);
+ BLI_assert(object->id.orig_id != NULL);
+ BLI_assert(object->runtime.mesh_orig->id.orig_id == ((Object *)object->id.orig_id)->data);
+ Mesh *result = object->runtime.mesh_orig;
+ BLI_assert((result->id.tag & LIB_TAG_COPIED_ON_WRITE) != 0);
+ BLI_assert((result->id.tag & LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT) == 0);
+ return result;
+ }
+ BLI_assert((object->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0);
+ return object->data;
+}
+
+/* Get a mesh which corresponds to very very original mesh from bmain.
+ * - For original objects it will be object->data.
+ * - For evaluated objects it will be same mesh as corresponding original
+ * object uses as data.
+ */
+Mesh *BKE_object_get_original_mesh(Object *object)
+{
+ Mesh *result = NULL;
+ if (object->id.orig_id == NULL) {
+ BLI_assert((object->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0);
+ result = object->data;
+ }
+ else {
+ BLI_assert((object->id.tag & LIB_TAG_COPIED_ON_WRITE) != 0);
+ result = ((Object *)object->id.orig_id)->data;
+ }
+ BLI_assert(result != NULL);
+ BLI_assert((result->id.tag & (LIB_TAG_COPIED_ON_WRITE | LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT)) == 0);
+ return result;
+}
static int pc_cmp(const void *a, const void *b)
{
@@ -3313,6 +3413,10 @@ MovieClip *BKE_object_movieclip_get(Scene *scene, Object *ob, bool use_default)
return clip;
}
+void BKE_object_runtime_reset(Object *object)
+{
+ memset(&object->runtime, 0, sizeof(object->runtime));
+}
/*
* Find an associated Armature object
@@ -3351,7 +3455,7 @@ static void obrel_list_add(LinkNode **links, Object *ob)
* Iterates over all objects of the given scene layer.
* Depending on the eObjectSet flag:
* collect either OB_SET_ALL, OB_SET_VISIBLE or OB_SET_SELECTED objects.
- * If OB_SET_VISIBLE or OB_SET_SELECTED are collected,
+ * If OB_SET_VISIBLE or OB_SET_SELECTED are collected,
* then also add related objects according to the given includeFilters.
*/
LinkNode *BKE_object_relational_superset(struct ViewLayer *view_layer, eObjectSet objectSet, eObRelationTypes includeFilter)
@@ -3708,7 +3812,7 @@ bool BKE_object_modifier_update_subframe(
/* was originally OB_RECALC_ALL - TODO - which flags are really needed??? */
/* TODO(sergey): What about animation? */
ob->id.recalc |= ID_RECALC_ALL;
- BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, frame, ADT_RECALC_ANIM);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, frame, ADT_RECALC_ANIM);
if (update_mesh) {
/* ignore cache clear during subframe updates
* to not mess up cache validity */
@@ -3722,12 +3826,12 @@ bool BKE_object_modifier_update_subframe(
/* for curve following objects, parented curve has to be updated too */
if (ob->type == OB_CURVE) {
Curve *cu = ob->data;
- BKE_animsys_evaluate_animdata(scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM);
}
/* and armatures... */
if (ob->type == OB_ARMATURE) {
bArmature *arm = ob->data;
- BKE_animsys_evaluate_animdata(scene, &arm->id, arm->adt, frame, ADT_RECALC_ANIM);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &arm->id, arm->adt, frame, ADT_RECALC_ANIM);
BKE_pose_where_is(depsgraph, scene, ob);
}
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 5e42cdb6b14..e9b1e79dc67 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -56,6 +56,7 @@
#include "BKE_lattice.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_scene.h"
@@ -72,8 +73,6 @@
typedef struct DupliContext {
Depsgraph *depsgraph;
- bool do_update;
- bool animated;
Collection *collection; /* XXX child objects are selected from this group if set, could be nicer */
Object *obedit; /* Only to check if the object is in edit-mode. */
@@ -99,14 +98,13 @@ typedef struct DupliGenerator {
static const DupliGenerator *get_dupli_generator(const DupliContext *ctx);
/* create initial context for root object */
-static void init_context(DupliContext *r_ctx, Depsgraph *depsgraph, Scene *scene, Object *ob, float space_mat[4][4], bool update)
+static void init_context(
+ DupliContext *r_ctx, Depsgraph *depsgraph,
+ Scene *scene, Object *ob, float space_mat[4][4])
{
r_ctx->depsgraph = depsgraph;
r_ctx->scene = scene;
r_ctx->view_layer = DEG_get_evaluated_view_layer(depsgraph);
- /* don't allow BKE_object_handle_update for viewport during render, can crash */
- r_ctx->do_update = update && !(G.is_rendering && DEG_get_mode(depsgraph) != DAG_EVAL_RENDER);
- r_ctx->animated = false;
r_ctx->collection = NULL;
r_ctx->object = ob;
@@ -123,12 +121,10 @@ static void init_context(DupliContext *r_ctx, Depsgraph *depsgraph, Scene *scene
}
/* create sub-context for recursive duplis */
-static void copy_dupli_context(DupliContext *r_ctx, const DupliContext *ctx, Object *ob, float mat[4][4], int index, bool animated)
+static void copy_dupli_context(DupliContext *r_ctx, const DupliContext *ctx, Object *ob, float mat[4][4], int index)
{
*r_ctx = *ctx;
- r_ctx->animated |= animated; /* object animation makes all children animated */
-
/* XXX annoying, previously was done by passing an ID* argument, this at least is more explicit */
if (ctx->gen->type == OB_DUPLICOLLECTION)
r_ctx->collection = ctx->object->dup_group;
@@ -146,8 +142,7 @@ static void copy_dupli_context(DupliContext *r_ctx, const DupliContext *ctx, Obj
* mat is transform of the object relative to current context (including object obmat)
*/
static DupliObject *make_dupli(const DupliContext *ctx,
- Object *ob, float mat[4][4], int index,
- bool animated, bool hide)
+ Object *ob, float mat[4][4], int index)
{
DupliObject *dob;
int i;
@@ -164,7 +159,6 @@ static DupliObject *make_dupli(const DupliContext *ctx,
dob->ob = ob;
mul_m4_m4m4(dob->mat, (float (*)[4])ctx->space_mat, mat);
dob->type = ctx->gen->type;
- dob->animated = animated || ctx->animated; /* object itself or some parent is animated */
/* set persistent id, which is an array with a persistent index for each level
* (particle number, vertex number, ..). by comparing this we can find the same
@@ -177,8 +171,6 @@ static DupliObject *make_dupli(const DupliContext *ctx,
for (; i < MAX_DUPLI_RECUR; i++)
dob->persistent_id[i] = INT_MAX;
- if (hide)
- dob->no_draw = true;
/* metaballs never draw in duplis, they are instead merged into one by the basis
* mball outside of the group. this does mean that if that mball is not in the
* scene, they will not show up at all, limitation that should be solved once. */
@@ -208,12 +200,12 @@ static DupliObject *make_dupli(const DupliContext *ctx,
/* recursive dupli objects
* space_mat is the local dupli space (excluding dupli object obmat!)
*/
-static void make_recursive_duplis(const DupliContext *ctx, Object *ob, float space_mat[4][4], int index, bool animated)
+static void make_recursive_duplis(const DupliContext *ctx, Object *ob, float space_mat[4][4], int index)
{
/* simple preventing of too deep nested collections with MAX_DUPLI_RECUR */
if (ctx->level < MAX_DUPLI_RECUR) {
DupliContext rctx;
- copy_dupli_context(&rctx, ctx, ob, space_mat, index, animated);
+ copy_dupli_context(&rctx, ctx, ob, space_mat, index);
if (rctx.gen) {
rctx.gen->make_duplis(&rctx);
}
@@ -247,7 +239,7 @@ static void make_child_duplis(const DupliContext *ctx, void *userdata, MakeChild
Object *ob = base->object;
if ((base->flag & BASE_VISIBLED) && ob != ctx->obedit && is_child(ob, parent)) {
DupliContext pctx;
- copy_dupli_context(&pctx, ctx, ctx->object, NULL, collectionid, false);
+ copy_dupli_context(&pctx, ctx, ctx->object, NULL, collectionid);
/* mballs have a different dupli handling */
if (ob->type != OB_MBALL) {
@@ -266,7 +258,7 @@ static void make_child_duplis(const DupliContext *ctx, void *userdata, MakeChild
Object *ob = base->object;
if ((ob != ctx->obedit) && is_child(ob, parent)) {
DupliContext pctx;
- copy_dupli_context(&pctx, ctx, ctx->object, NULL, baseid, false);
+ copy_dupli_context(&pctx, ctx, ctx->object, NULL, baseid);
/* mballs have a different dupli handling */
if (ob->type != OB_MBALL)
@@ -289,7 +281,6 @@ static void make_duplis_collection(const DupliContext *ctx)
Base *base;
float collection_mat[4][4];
int id;
- bool animated;
if (ob->dup_group == NULL) return;
collection = ob->dup_group;
@@ -300,17 +291,6 @@ static void make_duplis_collection(const DupliContext *ctx)
mul_m4_m4m4(collection_mat, ob->obmat, collection_mat);
/* don't access 'ob->obmat' from now on. */
- /* handles animated collections */
-
- /* we need to check update for objects that are not in scene... */
- if (ctx->do_update) {
- /* note: update is optional because we don't always need object
- * transformations to be correct. Also fixes bug [#29616]. */
- BKE_collection_handle_recalc_and_update(ctx->depsgraph, ctx->scene, ob, collection);
- }
-
- animated = BKE_collection_is_animated(collection, ob);
-
const ListBase dup_collection_objects = BKE_collection_object_cache_get(collection);
for (base = dup_collection_objects.first, id = 0; base; base = base->next, id++) {
if (base->object != ob && (base->flag & BASE_VISIBLED)) {
@@ -319,10 +299,10 @@ static void make_duplis_collection(const DupliContext *ctx)
/* collection dupli offset, should apply after everything else */
mul_m4_m4m4(mat, collection_mat, base->object->obmat);
- make_dupli(ctx, base->object, mat, id, animated, false);
+ make_dupli(ctx, base->object, mat, id);
/* recursion */
- make_recursive_duplis(ctx, base->object, collection_mat, id, animated);
+ make_recursive_duplis(ctx, base->object, collection_mat, id);
}
}
}
@@ -335,6 +315,7 @@ static const DupliGenerator gen_dupli_collection = {
/* OB_DUPLIFRAMES */
static void make_duplis_frames(const DupliContext *ctx)
{
+ Depsgraph *depsgraph = ctx->depsgraph;
Scene *scene = ctx->scene;
Object *ob = ctx->object;
extern int enable_cu_speed; /* object.c */
@@ -378,10 +359,11 @@ static void make_duplis_frames(const DupliContext *ctx)
* and/or other objects which may affect this object's transforms are not updated either.
* However, this has always been the way that this worked (i.e. pre 2.5), so I guess that it'll be fine!
*/
- BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
- BKE_object_where_is_calc_time(ctx->depsgraph, scene, ob, (float)scene->r.cfra);
+ /* ob-eval will do drivers, so we don't need to do them */
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM);
+ BKE_object_where_is_calc_time(depsgraph, scene, ob, (float)scene->r.cfra);
- make_dupli(ctx, ob, ob->obmat, scene->r.cfra, false, false);
+ make_dupli(ctx, ob, ob->obmat, scene->r.cfra);
}
}
@@ -392,8 +374,9 @@ static void make_duplis_frames(const DupliContext *ctx)
*/
scene->r.cfra = cfrao;
- BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
- BKE_object_where_is_calc_time(ctx->depsgraph, scene, ob, (float)scene->r.cfra);
+ /* ob-eval will do drivers, so we don't need to do them */
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM);
+ BKE_object_where_is_calc_time(depsgraph, scene, ob, (float)scene->r.cfra);
/* but, to make sure unkeyed object transforms are still sane,
* let's copy object's original data back over
@@ -466,13 +449,13 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3],
*/
mul_m4_m4m4(space_mat, obmat, inst_ob->imat);
- dob = make_dupli(vdd->ctx, vdd->inst_ob, obmat, index, false, false);
+ dob = make_dupli(vdd->ctx, vdd->inst_ob, obmat, index);
if (vdd->orco)
copy_v3_v3(dob->orco, vdd->orco[index]);
/* recursion */
- make_recursive_duplis(vdd->ctx, vdd->inst_ob, space_mat, index, false);
+ make_recursive_duplis(vdd->ctx, vdd->inst_ob, space_mat, index);
}
static void make_child_duplis_verts(const DupliContext *ctx, void *userdata, Object *child)
@@ -515,7 +498,7 @@ static void make_duplis_verts(const DupliContext *ctx)
{
Scene *scene = ctx->scene;
Object *parent = ctx->object;
- bool use_texcoords = ELEM(DEG_get_mode(ctx->depsgraph), DAG_EVAL_RENDER, DAG_EVAL_PREVIEW);
+ bool use_texcoords = (DEG_get_mode(ctx->depsgraph) == DAG_EVAL_RENDER);
VertexDupliData vdd;
vdd.ctx = ctx;
@@ -651,7 +634,7 @@ static void make_duplis_font(const DupliContext *ctx)
copy_v3_v3(obmat[3], vec);
- make_dupli(ctx, ob, obmat, a, false, false);
+ make_dupli(ctx, ob, obmat, a);
}
}
@@ -719,7 +702,7 @@ static void make_child_duplis_faces(const DupliContext *ctx, void *userdata, Obj
float (*orco)[3] = fdd->orco;
MLoopUV *mloopuv = fdd->mloopuv;
int a, totface = fdd->totface;
- bool use_texcoords = ELEM(DEG_get_mode(ctx->depsgraph), DAG_EVAL_RENDER, DAG_EVAL_PREVIEW);
+ bool use_texcoords = (DEG_get_mode(ctx->depsgraph) == DAG_EVAL_RENDER);
float child_imat[4][4];
DupliObject *dob;
@@ -757,7 +740,7 @@ static void make_child_duplis_faces(const DupliContext *ctx, void *userdata, Obj
*/
mul_m4_m4m4(space_mat, obmat, inst_ob->imat);
- dob = make_dupli(ctx, inst_ob, obmat, a, false, false);
+ dob = make_dupli(ctx, inst_ob, obmat, a);
if (use_texcoords) {
float w = 1.0f / (float)mp->totloop;
@@ -777,7 +760,7 @@ static void make_child_duplis_faces(const DupliContext *ctx, void *userdata, Obj
}
/* recursion */
- make_recursive_duplis(ctx, inst_ob, space_mat, a, false);
+ make_recursive_duplis(ctx, inst_ob, space_mat, a);
}
}
@@ -785,7 +768,7 @@ static void make_duplis_faces(const DupliContext *ctx)
{
Scene *scene = ctx->scene;
Object *parent = ctx->object;
- bool use_texcoords = ELEM(DEG_get_mode(ctx->depsgraph), DAG_EVAL_RENDER, DAG_EVAL_PREVIEW);
+ bool use_texcoords = (DEG_get_mode(ctx->depsgraph) == DAG_EVAL_RENDER);
FaceDupliData fdd;
fdd.use_scale = ((parent->transflag & OB_DUPLIFACES_SCALE) != 0);
@@ -838,7 +821,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
Scene *scene = ctx->scene;
Object *par = ctx->object;
bool for_render = DEG_get_mode(ctx->depsgraph) == DAG_EVAL_RENDER;
- bool use_texcoords = ELEM(DEG_get_mode(ctx->depsgraph), DAG_EVAL_RENDER, DAG_EVAL_PREVIEW);
+ bool use_texcoords = for_render;
Object *ob = NULL, **oblist = NULL, obcopy, *obcopylist = NULL;
DupliObject *dob;
@@ -922,10 +905,6 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
/* gather list of objects or single object */
if (part->ren_as == PART_DRAW_GR) {
- if (ctx->do_update) {
- BKE_collection_handle_recalc_and_update(ctx->depsgraph, scene, par, part->dup_group);
- }
-
if (part->draw & PART_DRAW_COUNT_GR) {
for (dw = part->dupliweights.first; dw; dw = dw->next)
totcollection += dw->count;
@@ -1072,7 +1051,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
/* individual particle transform */
mul_m4_m4m4(mat, pamat, tmat);
- dob = make_dupli(ctx, object, mat, a, false, false);
+ dob = make_dupli(ctx, object, mat, a);
dob->particle_system = psys;
if (use_texcoords) {
@@ -1126,7 +1105,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
if (part->draw & PART_DRAW_GLOBAL_OB)
add_v3_v3v3(mat[3], mat[3], vec);
- dob = make_dupli(ctx, ob, mat, a, false, false);
+ dob = make_dupli(ctx, ob, mat, a);
dob->particle_system = psys;
if (use_texcoords)
psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
@@ -1163,7 +1142,7 @@ static void make_duplis_particles(const DupliContext *ctx)
for (psys = ctx->object->particlesystem.first, psysid = 0; psys; psys = psys->next, psysid++) {
/* particles create one more level for persistent psys index */
DupliContext pctx;
- copy_dupli_context(&pctx, ctx, ctx->object, NULL, psysid, false);
+ copy_dupli_context(&pctx, ctx, ctx->object, NULL, psysid);
make_duplis_particle_system(&pctx, psys);
}
}
@@ -1217,11 +1196,11 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx)
/* ---- ListBase dupli container implementation ---- */
/* Returns a list of DupliObject */
-ListBase *object_duplilist_ex(Depsgraph *depsgraph, Scene *scene, Object *ob, bool update)
+ListBase *object_duplilist(Depsgraph *depsgraph, Scene *sce, Object *ob)
{
ListBase *duplilist = MEM_callocN(sizeof(ListBase), "duplilist");
DupliContext ctx;
- init_context(&ctx, depsgraph, scene, ob, NULL, update);
+ init_context(&ctx, depsgraph, sce, ob, NULL);
if (ctx.gen) {
ctx.duplilist = duplilist;
ctx.gen->make_duplis(&ctx);
@@ -1230,13 +1209,6 @@ ListBase *object_duplilist_ex(Depsgraph *depsgraph, Scene *scene, Object *ob, bo
return duplilist;
}
-/* note: previously updating was always done, this is why it defaults to be on
- * but there are likely places it can be called without updating */
-ListBase *object_duplilist(Depsgraph *depsgraph, Scene *sce, Object *ob)
-{
- return object_duplilist_ex(depsgraph, sce, ob, true);
-}
-
void free_object_duplilist(ListBase *lb)
{
BLI_freelistN(lb);
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index d21a1326392..f0f31eebfbd 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -39,28 +39,29 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
-#include "BKE_global.h"
+#include "BKE_animsys.h"
#include "BKE_armature.h"
#include "BKE_action.h"
#include "BKE_constraint.h"
#include "BKE_curve.h"
#include "BKE_DerivedMesh.h"
-#include "BKE_animsys.h"
#include "BKE_displist.h"
+#include "BKE_editmesh.h"
#include "BKE_effect.h"
+#include "BKE_global.h"
+#include "BKE_image.h"
#include "BKE_key.h"
#include "BKE_lamp.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
-#include "BKE_editmesh.h"
+#include "BKE_main.h"
+#include "BKE_material.h"
+#include "BKE_mball.h"
+#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_scene.h"
-#include "BKE_material.h"
-#include "BKE_mball.h"
-#include "BKE_mesh.h"
-#include "BKE_image.h"
#include "MEM_guardedalloc.h"
@@ -95,7 +96,7 @@ void BKE_object_eval_parent(Depsgraph *depsgraph,
copy_m4_m4(locmat, ob->obmat);
/* get parent effect matrix */
- BKE_object_get_parent_matrix(scene, ob, par, totmat);
+ BKE_object_get_parent_matrix(depsgraph, scene, ob, par, totmat);
/* total */
mul_m4_m4m4(tmat, totmat, ob->parentinv);
@@ -140,6 +141,13 @@ void BKE_object_eval_done(Depsgraph *depsgraph, Object *ob)
/* Set negative scale flag in object. */
if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE;
else ob->transflag &= ~OB_NEG_SCALE;
+
+ if (DEG_is_active(depsgraph)) {
+ Object *ob_orig = DEG_get_original_object(ob);
+ copy_m4_m4(ob_orig->obmat, ob->obmat);
+ ob_orig->transflag = ob->transflag;
+ ob_orig->flag = ob->flag;
+ }
}
void BKE_object_handle_data_update(
@@ -159,14 +167,14 @@ void BKE_object_handle_data_update(
if (adt) {
/* evaluate drivers - datalevel */
/* XXX: for mesh types, should we push this to derivedmesh instead? */
- BKE_animsys_evaluate_animdata(scene, data_id, adt, ctime, ADT_RECALC_DRIVERS);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, data_id, adt, ctime, ADT_RECALC_DRIVERS);
}
/* TODO(sergey): Only used by legacy depsgraph. */
key = BKE_key_from_object(ob);
if (key && key->block.first) {
if (!(ob->shapeflag & OB_SHAPE_LOCK))
- BKE_animsys_evaluate_animdata(scene, &key->id, key->adt, ctime, ADT_RECALC_DRIVERS);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &key->id, key->adt, ctime, ADT_RECALC_DRIVERS);
}
/* includes all keys and modifiers */
@@ -330,62 +338,6 @@ void BKE_object_eval_uber_data(Depsgraph *depsgraph,
BKE_mball_batch_cache_dirty(ob->data, BKE_MBALL_BATCH_DIRTY_ALL);
break;
}
-
- if (DEG_depsgraph_use_copy_on_write()) {
- if (ob->type == OB_MESH) {
- /* Quick hack to convert evaluated derivedMesh to Mesh. */
- DerivedMesh *dm = ob->derivedFinal;
- if (dm != NULL) {
- Mesh *mesh = (Mesh *)ob->data;
- Mesh *new_mesh = BKE_libblock_alloc_notest(ID_ME);
- BKE_mesh_init(new_mesh);
- /* Copy ID name so GS(new_mesh->id) works correct later on. */
- BLI_strncpy(new_mesh->id.name, mesh->id.name, sizeof(new_mesh->id.name));
- /* Copy materials so render engines can access them. */
- new_mesh->mat = MEM_dupallocN(mesh->mat);
- new_mesh->totcol = mesh->totcol;
- DM_to_mesh(dm, new_mesh, ob, CD_MASK_MESH, true);
- new_mesh->edit_btmesh = mesh->edit_btmesh;
- /* Store result mesh as derived_mesh of object. This way we have
- * explicit way to query final object evaluated data and know for sure
- * who owns the newly created mesh datablock.
- */
- ob->mesh_evaluated = new_mesh;
- /* TODO(sergey): This is kind of compatibility thing, so all render
- * engines can use object->data for mesh data for display. This is
- * something what we might want to change in the future.
- * XXX: This can sometimes cause modifiers to be applied twice!
- */
- ob->data = new_mesh;
- /* Special flags to help debugging. */
- new_mesh->id.tag |= LIB_TAG_COPY_ON_WRITE_EVAL;
- /* Save some memory by throwing DerivedMesh away. */
- /* NOTE: Watch out, some tools might need it!
- * So keep around for now..
- */
- /* Store original ID as a pointer in evaluated ID.
- * This way we can restore original object data when we are freeing
- * evaluated mesh.
- */
- new_mesh->id.orig_id = &mesh->id;
- /* Copy autosmooth settings from original mesh. */
- new_mesh->flag |= (mesh->flag & ME_AUTOSMOOTH);
- new_mesh->smoothresh = mesh->smoothresh;
- }
-#if 0
- if (ob->derivedFinal != NULL) {
- ob->derivedFinal->needsFree = 1;
- ob->derivedFinal->release(ob->derivedFinal);
- ob->derivedFinal = NULL;
- }
- if (ob->derivedDeform != NULL) {
- ob->derivedDeform->needsFree = 1;
- ob->derivedDeform->release(ob->derivedDeform);
- ob->derivedDeform = NULL;
- }
-#endif
- }
- }
}
void BKE_object_eval_cloth(Depsgraph *depsgraph,
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index f17c10765b8..07cd28da556 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -246,14 +246,14 @@ void packAll(Main *bmain, ReportList *reports, bool verbose)
for (vfont = bmain->vfont.first; vfont; vfont = vfont->id.next) {
if (vfont->packedfile == NULL && !ID_IS_LINKED(vfont) && BKE_vfont_is_builtin(vfont) == false) {
- vfont->packedfile = newPackedFile(reports, vfont->name, bmain->name);
+ vfont->packedfile = newPackedFile(reports, vfont->name, BKE_main_blendfile_path(bmain));
tot ++;
}
}
for (sound = bmain->sound.first; sound; sound = sound->id.next) {
if (sound->packedfile == NULL && !ID_IS_LINKED(sound)) {
- sound->packedfile = newPackedFile(reports, sound->name, bmain->name);
+ sound->packedfile = newPackedFile(reports, sound->name, BKE_main_blendfile_path(bmain));
tot++;
}
}
@@ -291,7 +291,8 @@ static char *find_new_name(char *name)
}
#endif
-int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, int guimode)
+int writePackedFile(
+ ReportList *reports, const char *ref_file_name, const char *filename, PackedFile *pf, const bool guimode)
{
int file, number;
int ret_value = RET_OK;
@@ -303,7 +304,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
if (guimode) {} //XXX waitcursor(1);
BLI_strncpy(name, filename, sizeof(name));
- BLI_path_abs(name, G.main->name);
+ BLI_path_abs(name, ref_file_name);
if (BLI_exists(name)) {
for (number = 1; number <= 999; number++) {
@@ -363,7 +364,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
* - PF_DIFFERENT: the packed file and original file differ
* - PF_NOFILE: the original file doens't exist
*/
-int checkPackedFile(const char *filename, PackedFile *pf)
+int checkPackedFile(const char *ref_file_name, const char *filename, PackedFile *pf)
{
BLI_stat_t st;
int ret_val, i, len, file;
@@ -371,7 +372,7 @@ int checkPackedFile(const char *filename, PackedFile *pf)
char name[FILE_MAX];
BLI_strncpy(name, filename, sizeof(name));
- BLI_path_abs(name, G.main->name);
+ BLI_path_abs(name, ref_file_name);
if (BLI_stat(name, &st) == -1) {
ret_val = PF_NOFILE;
@@ -423,7 +424,9 @@ int checkPackedFile(const char *filename, PackedFile *pf)
*
* \warning 'abs_name' may be relative still! (use a "//" prefix) be sure to run #BLI_path_abs on it first.
*/
-char *unpackFile(ReportList *reports, const char *abs_name, const char *local_name, PackedFile *pf, int how)
+char *unpackFile(
+ ReportList *reports, const char *ref_file_name,
+ const char *abs_name, const char *local_name, PackedFile *pf, int how)
{
char *newname = NULL;
const char *temp = NULL;
@@ -441,7 +444,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
char temp_abs[FILE_MAX];
BLI_strncpy(temp_abs, local_name, sizeof(temp_abs));
- BLI_path_abs(temp_abs, G.main->name);
+ BLI_path_abs(temp_abs, ref_file_name);
/* if file exists use it */
if (BLI_exists(temp_abs)) {
@@ -452,7 +455,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
ATTR_FALLTHROUGH;
}
case PF_WRITE_LOCAL:
- if (writePackedFile(reports, local_name, pf, 1) == RET_OK) {
+ if (writePackedFile(reports, ref_file_name, local_name, pf, 1) == RET_OK) {
temp = local_name;
}
break;
@@ -461,7 +464,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
char temp_abs[FILE_MAX];
BLI_strncpy(temp_abs, abs_name, sizeof(temp_abs));
- BLI_path_abs(temp_abs, G.main->name);
+ BLI_path_abs(temp_abs, ref_file_name);
/* if file exists use it */
if (BLI_exists(temp_abs)) {
@@ -473,7 +476,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
ATTR_FALLTHROUGH;
}
case PF_WRITE_ORIGINAL:
- if (writePackedFile(reports, abs_name, pf, 1) == RET_OK) {
+ if (writePackedFile(reports, ref_file_name, abs_name, pf, 1) == RET_OK) {
temp = abs_name;
}
break;
@@ -531,7 +534,7 @@ static void unpack_generate_paths(
}
}
-int unpackVFont(ReportList *reports, VFont *vfont, int how)
+int unpackVFont(Main *bmain, ReportList *reports, VFont *vfont, int how)
{
char localname[FILE_MAX], absname[FILE_MAX];
char *newname;
@@ -539,7 +542,7 @@ int unpackVFont(ReportList *reports, VFont *vfont, int how)
if (vfont != NULL) {
unpack_generate_paths(vfont->name, (ID *)vfont, absname, localname, sizeof(absname), sizeof(localname));
- newname = unpackFile(reports, absname, localname, vfont->packedfile, how);
+ newname = unpackFile(reports, BKE_main_blendfile_path(bmain), absname, localname, vfont->packedfile, how);
if (newname != NULL) {
ret_value = RET_OK;
freePackedFile(vfont->packedfile);
@@ -560,7 +563,7 @@ int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how)
if (sound != NULL) {
unpack_generate_paths(sound->name, (ID *)sound, absname, localname, sizeof(absname), sizeof(localname));
- newname = unpackFile(reports, absname, localname, sound->packedfile, how);
+ newname = unpackFile(reports, BKE_main_blendfile_path(bmain), absname, localname, sound->packedfile, how);
if (newname != NULL) {
BLI_strncpy(sound->name, newname, sizeof(sound->name));
MEM_freeN(newname);
@@ -577,7 +580,7 @@ int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how)
return(ret_value);
}
-int unpackImage(ReportList *reports, Image *ima, int how)
+int unpackImage(Main *bmain, ReportList *reports, Image *ima, int how)
{
int ret_value = RET_ERROR;
@@ -588,7 +591,7 @@ int unpackImage(ReportList *reports, Image *ima, int how)
ImagePackedFile *imapf = ima->packedfiles.last;
unpack_generate_paths(imapf->filepath, (ID *)ima, absname, localname, sizeof(absname), sizeof(localname));
- newname = unpackFile(reports, absname, localname, imapf->packedfile, how);
+ newname = unpackFile(reports, BKE_main_blendfile_path(bmain), absname, localname, imapf->packedfile, how);
if (newname != NULL) {
ImageView *iv;
@@ -619,7 +622,7 @@ int unpackImage(ReportList *reports, Image *ima, int how)
}
if (ret_value == RET_OK) {
- BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
+ BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_RELOAD);
}
return(ret_value);
@@ -634,7 +637,7 @@ int unpackLibraries(Main *bmain, ReportList *reports)
for (lib = bmain->library.first; lib; lib = lib->id.next) {
if (lib->packedfile && lib->name[0]) {
- newname = unpackFile(reports, lib->filepath, lib->filepath, lib->packedfile, PF_WRITE_ORIGINAL);
+ newname = unpackFile(reports, BKE_main_blendfile_path(bmain), lib->filepath, lib->filepath, lib->packedfile, PF_WRITE_ORIGINAL);
if (newname != NULL) {
ret_value = RET_OK;
@@ -667,7 +670,7 @@ void packLibraries(Main *bmain, ReportList *reports)
for (lib = bmain->library.first; lib; lib = lib->id.next)
if (lib->packedfile == NULL)
- lib->packedfile = newPackedFile(reports, lib->name, bmain->name);
+ lib->packedfile = newPackedFile(reports, lib->name, BKE_main_blendfile_path(bmain));
}
void unpackAll(Main *bmain, ReportList *reports, int how)
@@ -678,11 +681,11 @@ void unpackAll(Main *bmain, ReportList *reports, int how)
for (ima = bmain->image.first; ima; ima = ima->id.next)
if (BKE_image_has_packedfile(ima))
- unpackImage(reports, ima, how);
+ unpackImage(bmain, reports, ima, how);
for (vf = bmain->vfont.first; vf; vf = vf->id.next)
if (vf->packedfile)
- unpackVFont(reports, vf, how);
+ unpackVFont(bmain, reports, vf, how);
for (sound = bmain->sound.first; sound; sound = sound->id.next)
if (sound->packedfile)
@@ -727,7 +730,7 @@ void BKE_unpack_id(Main *bmain, ID *id, ReportList *reports, int how)
{
Image *ima = (Image *)id;
if (BKE_image_has_packedfile(ima)) {
- unpackImage(reports, ima, how);
+ unpackImage(bmain, reports, ima, how);
}
break;
}
@@ -735,7 +738,7 @@ void BKE_unpack_id(Main *bmain, ID *id, ReportList *reports, int how)
{
VFont *vf = (VFont *)id;
if (vf->packedfile) {
- unpackVFont(reports, vf, how);
+ unpackVFont(bmain, reports, vf, how);
}
break;
}
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index f961510984a..20d68ee2a58 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -59,6 +59,8 @@
#include "BKE_key.h"
#include "BKE_library.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_mapping.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_paint.h"
@@ -502,7 +504,7 @@ eObjectMode BKE_paint_object_mode_from_paint_mode(ePaintMode mode)
}
}
-void BKE_paint_init(Scene *sce, ePaintMode mode, const char col[3])
+void BKE_paint_init(Main *bmain, Scene *sce, ePaintMode mode, const char col[3])
{
UnifiedPaintSettings *ups = &sce->toolsettings->unified_paint_settings;
Brush *brush;
@@ -512,10 +514,10 @@ void BKE_paint_init(Scene *sce, ePaintMode mode, const char col[3])
brush = BKE_paint_brush(paint);
if (brush == NULL) {
eObjectMode ob_mode = BKE_paint_object_mode_from_paint_mode(mode);
- brush = BKE_brush_first_search(G.main, ob_mode);
+ brush = BKE_brush_first_search(bmain, ob_mode);
if (!brush) {
- brush = BKE_brush_add(G.main, "Brush", ob_mode);
+ brush = BKE_brush_add(bmain, "Brush", ob_mode);
id_us_min(&brush->id); /* fake user only */
}
BKE_paint_brush_set(paint, brush);
@@ -753,7 +755,6 @@ void BKE_sculptsession_free(Object *ob)
{
if (ob && ob->sculpt) {
SculptSession *ss = ob->sculpt;
- DerivedMesh *dm = ob->derivedFinal;
if (ss->bm) {
BKE_sculptsession_bm_to_me(ob, true);
@@ -762,12 +763,11 @@ void BKE_sculptsession_free(Object *ob)
if (ss->pbvh)
BKE_pbvh_free(ss->pbvh);
+ MEM_SAFE_FREE(ss->pmap);
+ MEM_SAFE_FREE(ss->pmap_mem);
if (ss->bm_log)
BM_log_free(ss->bm_log);
- if (dm && dm->getPBVH)
- dm->getPBVH(NULL, dm); /* signal to clear */
-
if (ss->texcache)
MEM_freeN(ss->texcache);
@@ -872,9 +872,8 @@ void BKE_sculpt_update_mesh_elements(
return;
}
- DerivedMesh *dm;
SculptSession *ss = ob->sculpt;
- Mesh *me = ob->data;
+ Mesh *me = BKE_object_get_original_mesh(ob);
MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob);
ss->modifiers_active = sculpt_modifiers_active(scene, sd, ob);
@@ -909,13 +908,14 @@ void BKE_sculpt_update_mesh_elements(
ss->kb = (mmd == NULL) ? BKE_keyblock_from_object(ob) : NULL;
- dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
+ Mesh *me_eval_deform = mesh_get_eval_deform(depsgraph, scene, ob, CD_MASK_BAREMESH);
/* VWPaint require mesh info for loop lookup, so require sculpt mode here */
if (mmd && ob->mode & OB_MODE_SCULPT) {
ss->multires = mmd;
- ss->totvert = dm->getNumVerts(dm);
- ss->totpoly = dm->getNumPolys(dm);
+ ss->totvert = me_eval->totvert;
+ ss->totpoly = me_eval->totpoly;
ss->mvert = NULL;
ss->mpoly = NULL;
ss->mloop = NULL;
@@ -930,8 +930,17 @@ void BKE_sculpt_update_mesh_elements(
ss->vmask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK);
}
- ss->pbvh = dm->getPBVH(ob, dm);
- ss->pmap = (need_pmap && dm->getPolyMap) ? dm->getPolyMap(ob, dm) : NULL;
+ PBVH *pbvh = BKE_sculpt_object_pbvh_ensure(ob, me_eval_deform);
+ BLI_assert(pbvh == ss->pbvh);
+ UNUSED_VARS_NDEBUG(pbvh);
+ MEM_SAFE_FREE(ss->pmap);
+ MEM_SAFE_FREE(ss->pmap_mem);
+ if (need_pmap && ob->type == OB_MESH) {
+ BKE_mesh_vert_poly_map_create(
+ &ss->pmap, &ss->pmap_mem,
+ me->mpoly, me->mloop,
+ me->totvert, me->totpoly, me->totloop);
+ }
pbvh_show_diffuse_color_set(ss->pbvh, ss->show_diffuse_color);
pbvh_show_mask_set(ss->pbvh, ss->show_mask);
@@ -945,7 +954,7 @@ void BKE_sculpt_update_mesh_elements(
ss->orig_cos = (ss->kb) ? BKE_keyblock_convert_to_vertcos(ob, ss->kb) : BKE_mesh_vertexCos_get(me, NULL);
BKE_crazyspace_build_sculpt(depsgraph, scene, ob, &ss->deform_imats, &ss->deform_cos);
- BKE_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos);
+ BKE_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos, me->totvert);
for (a = 0; a < me->totvert; ++a) {
invert_m3(ss->deform_imats[a]);
@@ -962,14 +971,14 @@ void BKE_sculpt_update_mesh_elements(
/* if pbvh is deformed, key block is already applied to it */
if (ss->kb) {
- bool pbvh_deformd = BKE_pbvh_isDeformed(ss->pbvh);
- if (!pbvh_deformd || ss->deform_cos == NULL) {
+ bool pbvh_deformed = BKE_pbvh_isDeformed(ss->pbvh);
+ if (!pbvh_deformed || ss->deform_cos == NULL) {
float (*vertCos)[3] = BKE_keyblock_convert_to_vertcos(ob, ss->kb);
if (vertCos) {
- if (!pbvh_deformd) {
+ if (!pbvh_deformed) {
/* apply shape keys coordinates to PBVH */
- BKE_pbvh_apply_vertCos(ss->pbvh, vertCos);
+ BKE_pbvh_apply_vertCos(ss->pbvh, vertCos, me->totvert);
}
if (ss->deform_cos == NULL) {
ss->deform_cos = vertCos;
@@ -1091,3 +1100,96 @@ void BKE_sculpt_toolsettings_data_ensure(struct Scene *scene)
sd->paint.tile_offset[2] = 1.0f;
}
}
+
+static bool check_sculpt_object_deformed(Object *object, const bool for_construction)
+{
+ bool deformed = false;
+
+ /* Active modifiers means extra deformation, which can't be handled correct
+ * on birth of PBVH and sculpt "layer" levels, so use PBVH only for internal brush
+ * stuff and show final DerivedMesh so user would see actual object shape.
+ */
+ deformed |= object->sculpt->modifiers_active;
+
+ if (for_construction) {
+ deformed |= object->sculpt->kb != NULL;
+ }
+ else {
+ /* As in case with modifiers, we can't synchronize deformation made against
+ * PBVH and non-locked keyblock, so also use PBVH only for brushes and
+ * final DM to give final result to user.
+ */
+ deformed |= object->sculpt->kb && (object->shapeflag & OB_SHAPE_LOCK) == 0;
+ }
+
+ return deformed;
+}
+
+PBVH *BKE_sculpt_object_pbvh_ensure(Object *ob, Mesh *me_eval_deform)
+{
+ if (!ob) {
+ return NULL;
+ }
+
+ if (!ob->sculpt) {
+ return NULL;
+ }
+
+ PBVH *pbvh = ob->sculpt->pbvh;
+
+ /* Sculpting on a BMesh (dynamic-topology) gets a special PBVH */
+ if (!pbvh && ob->sculpt->bm) {
+ pbvh = BKE_pbvh_new();
+
+ BKE_pbvh_build_bmesh(pbvh, ob->sculpt->bm,
+ ob->sculpt->bm_smooth_shading,
+ ob->sculpt->bm_log, ob->sculpt->cd_vert_node_offset,
+ ob->sculpt->cd_face_node_offset);
+
+ pbvh_show_diffuse_color_set(pbvh, ob->sculpt->show_diffuse_color);
+ pbvh_show_mask_set(pbvh, ob->sculpt->show_mask);
+ }
+
+ /* always build pbvh from original mesh, and only use it for drawing if
+ * this derivedmesh is just original mesh. it's the multires subsurf dm
+ * that this is actually for, to support a pbvh on a modified mesh */
+ if (!pbvh && ob->type == OB_MESH) {
+ Mesh *me = BKE_object_get_original_mesh(ob);
+ const int looptris_num = poly_to_tri_count(me->totpoly, me->totloop);
+ MLoopTri *looptri;
+ bool deformed;
+
+ pbvh = BKE_pbvh_new();
+
+ looptri = MEM_malloc_arrayN(looptris_num, sizeof(*looptri), __func__);
+
+ BKE_mesh_recalc_looptri(
+ me->mloop, me->mpoly,
+ me->mvert,
+ me->totloop, me->totpoly,
+ looptri);
+
+ BKE_pbvh_build_mesh(
+ pbvh,
+ me->mpoly, me->mloop,
+ me->mvert, me->totvert, &me->vdata,
+ looptri, looptris_num);
+
+ pbvh_show_diffuse_color_set(pbvh, ob->sculpt->show_diffuse_color);
+ pbvh_show_mask_set(pbvh, ob->sculpt->show_mask);
+
+ deformed = check_sculpt_object_deformed(ob, true);
+
+ if (deformed && me_eval_deform) {
+ int totvert;
+ float (*v_cos)[3];
+
+ v_cos = BKE_mesh_vertexCos_get(me_eval_deform, &totvert);
+ BKE_pbvh_apply_vertCos(pbvh, v_cos, totvert);
+ MEM_freeN(v_cos);
+ }
+ }
+
+ ob->sculpt->pbvh = pbvh;
+ return pbvh;
+}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index a42826a1f89..8c322f0c853 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -298,24 +298,6 @@ ParticleSystem *psys_orig_get(ParticleSystem *psys)
return psys->orig_psys;
}
-struct ParticleSystem *psys_eval_get(Depsgraph *depsgraph,
- Object *object,
- ParticleSystem *psys)
-{
- Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
- if (object_eval == object) {
- return psys;
- }
- ParticleSystem *psys_eval = object_eval->particlesystem.first;
- while (psys_eval != NULL) {
- if (psys_eval->orig_psys == psys) {
- return psys_eval;
- }
- psys_eval = psys_eval->next;
- }
- return psys_eval;
-}
-
static PTCacheEdit *psys_orig_edit_get(ParticleSystem *psys)
{
if (psys->orig_psys == NULL) {
@@ -2618,7 +2600,6 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
}
void psys_cache_edit_paths(Depsgraph *depsgraph, Scene *scene, Object *ob, PTCacheEdit *edit, float cfra, const bool use_render_params)
{
- Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
ParticleCacheKey *ca, **cache = edit->pathcache;
ParticleEditSettings *pset = &scene->toolsettings->particle;
@@ -2626,16 +2607,9 @@ void psys_cache_edit_paths(Depsgraph *depsgraph, Scene *scene, Object *ob, PTCac
PTCacheEditKey *ekey = NULL;
ParticleSystem *psys = edit->psys;
- ParticleSystem *psys_eval = NULL;
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
- ParticleSystemModifierData *psmd_eval = NULL;
-
- if (psmd != NULL) {
- psmd_eval = (ParticleSystemModifierData *)modifiers_findByName(ob_eval, psmd->modifier.name);
- psys_eval = psmd_eval->psys;
- }
- ParticleData *pa = psys_eval ? psys_eval->particles : NULL;
+ ParticleData *pa = psys ? psys->particles : NULL;
ParticleInterpolationData pind;
ParticleKey result;
@@ -2664,7 +2638,7 @@ void psys_cache_edit_paths(Depsgraph *depsgraph, Scene *scene, Object *ob, PTCac
/* frs_sec = (psys || edit->pid.flag & PTCACHE_VEL_PER_SEC) ? 25.0f : 1.0f; */ /* UNUSED */
- const bool use_weight = (pset->brushtype == PE_BRUSH_WEIGHT) && (psys_eval != NULL) && (psys_eval->particles != NULL);
+ const bool use_weight = (pset->brushtype == PE_BRUSH_WEIGHT) && (psys != NULL) && (psys->particles != NULL);
if (use_weight) {
; /* use weight painting colors now... */
@@ -2709,10 +2683,10 @@ void psys_cache_edit_paths(Depsgraph *depsgraph, Scene *scene, Object *ob, PTCac
cache[i]->segments = segments;
/*--get the first data points--*/
- init_particle_interpolation(ob_eval, psys_eval, pa, &pind);
+ init_particle_interpolation(ob, psys, pa, &pind);
- if (psys_eval) {
- psys_mat_hair_to_global(ob_eval, psmd_eval->mesh_final, psys->part->from, pa, hairmat);
+ if (psys) {
+ psys_mat_hair_to_global(ob, psmd->mesh_final, psys->part->from, pa, hairmat);
copy_v3_v3(rotmat[0], hairmat[2]);
copy_v3_v3(rotmat[1], hairmat[1]);
copy_v3_v3(rotmat[2], hairmat[0]);
@@ -2731,7 +2705,7 @@ void psys_cache_edit_paths(Depsgraph *depsgraph, Scene *scene, Object *ob, PTCac
time = (float)k / (float)segments;
t = birthtime + time * (dietime - birthtime);
result.time = -t;
- do_particle_interpolation(psys_eval, i, pa, t, &pind, &result);
+ do_particle_interpolation(psys, i, pa, t, &pind, &result);
copy_v3_v3(ca->co, result.co);
/* non-hair points are already in global space */
@@ -2828,9 +2802,9 @@ void psys_cache_edit_paths(Depsgraph *depsgraph, Scene *scene, Object *ob, PTCac
ParticleSimulationData sim = {0};
sim.depsgraph = depsgraph;
sim.scene = scene;
- sim.ob = ob_eval;
- sim.psys = psys_eval;
- sim.psmd = psys_get_modifier(ob_eval, psys_eval);
+ sim.ob = ob;
+ sim.psys = psys;
+ sim.psmd = psys_get_modifier(ob, psys);
psys_cache_child_paths(&sim, cfra, true, use_render_params);
}
@@ -3089,6 +3063,9 @@ void object_remove_particle_system(Scene *UNUSED(scene), Object *ob)
DEG_relations_tag_update(G.main);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+
+ /* Flush object mode. */
+ DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
}
static void default_particle_settings(ParticleSettings *part)
@@ -3169,6 +3146,12 @@ static void default_particle_settings(ParticleSettings *part)
part->omat = 1;
part->use_modifier_stack = false;
part->draw_size = 0.1f;
+
+ part->shape_flag = PART_SHAPE_CLOSE_TIP;
+ part->shape = 0.0f;
+ part->rad_root = 1.0f;
+ part->rad_tip = 0.0f;
+ part->rad_scale = 0.01f;
}
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index cba0721ab3f..8d6991ff9f4 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -74,8 +74,10 @@
#include "BKE_collision.h"
#include "BKE_colortools.h"
#include "BKE_effect.h"
+#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_library_query.h"
+#include "BKE_main.h"
#include "BKE_particle.h"
#include "BKE_collection.h"
@@ -995,7 +997,7 @@ static void evaluate_emitter_anim(struct Depsgraph *depsgraph, Scene *scene, Obj
evaluate_emitter_anim(depsgraph, scene, ob->parent, cfra);
/* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
- BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, cfra, ADT_RECALC_ANIM);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, cfra, ADT_RECALC_ANIM);
BKE_object_where_is_calc_time(depsgraph, scene, ob, cfra);
}
@@ -1447,7 +1449,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d
}
/*********************************************************************************************************
- * SPH fluid physics
+ * SPH fluid physics
*
* In theory, there could be unlimited implementation of SPH simulators
*
@@ -3043,6 +3045,7 @@ static void hair_create_input_mesh(ParticleSimulationData *sim, int totpoint, in
if (!mesh) {
*r_mesh = mesh = BKE_mesh_new_nomain(totpoint, totedge, 0, 0, 0);
CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, mesh->totvert);
+ BKE_mesh_update_customdata_pointers(mesh, false);
}
mvert = mesh->mvert;
medge = mesh->medge;
@@ -3804,8 +3807,9 @@ static void cached_step(ParticleSimulationData *sim, float cfra, const bool use_
}
}
-static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra), const bool use_render_params)
-{
+static void particles_fluid_step(
+ Main *bmain, ParticleSimulationData *sim, int UNUSED(cfra), const bool use_render_params)
+{
ParticleSystem *psys = sim->psys;
if (psys->particles) {
MEM_freeN(psys->particles);
@@ -3835,7 +3839,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra),
// ok, start loading
BLI_join_dirfile(filename, sizeof(filename), fss->surfdataPath, OB_FLUIDSIM_SURF_PARTICLES_FNAME);
- BLI_path_abs(filename, modifier_path_relbase(sim->ob));
+ BLI_path_abs(filename, modifier_path_relbase(bmain, sim->ob));
BLI_path_frame(filename, curFrame, 0); // fixed #frame-no
@@ -3909,7 +3913,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra),
} // fluid sim particles done
}
#else
- UNUSED_VARS(use_render_params);
+ UNUSED_VARS(bmain, use_render_params);
#endif // WITH_MOD_FLUID
}
@@ -4146,7 +4150,7 @@ void psys_check_boid_data(ParticleSystem *psys)
}
}
-static void fluid_default_settings(ParticleSettings *part)
+void BKE_particlesettings_fluid_default_settings(ParticleSettings *part)
{
SPHFluidSettings *fluid = part->fluid;
@@ -4178,24 +4182,12 @@ static void psys_prepare_physics(ParticleSimulationData *sim)
sim->psys->flag &= ~PSYS_KEYED;
}
- if (part->phystype == PART_PHYS_BOIDS && part->boids == NULL) {
- BoidState *state;
-
- part->boids = MEM_callocN(sizeof(BoidSettings), "Boid Settings");
- boid_default_settings(part->boids);
-
- state = boid_new_state(part->boids);
- BLI_addtail(&state->rules, boid_new_rule(eBoidRuleType_Separate));
- BLI_addtail(&state->rules, boid_new_rule(eBoidRuleType_Flock));
-
- ((BoidRule*)state->rules.first)->flag |= BOIDRULE_CURRENT;
-
- state->flag |= BOIDSTATE_CURRENT;
- BLI_addtail(&part->boids->states, state);
+ /* RNA Update must ensure this is true. */
+ if (part->phystype == PART_PHYS_BOIDS) {
+ BLI_assert(part->boids != NULL);
}
- else if (part->phystype == PART_PHYS_FLUID && part->fluid == NULL) {
- part->fluid = MEM_callocN(sizeof(SPHFluidSettings), "SPH Fluid Settings");
- fluid_default_settings(part);
+ else if (part->phystype == PART_PHYS_FLUID) {
+ BLI_assert(part->fluid != NULL);
}
psys_check_boid_data(sim->psys);
@@ -4225,6 +4217,18 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o
if (!psys_check_enabled(ob, psys, use_render_params))
return;
+ if (DEG_is_active(depsgraph)) {
+ if (psys->orig_psys != NULL && psys->orig_psys->edit != NULL) {
+ psys_cache_edit_paths(
+ depsgraph,
+ (Scene *)DEG_get_original_id(&scene->id),
+ DEG_get_original_object(ob),
+ psys->orig_psys->edit,
+ DEG_get_ctime(depsgraph),
+ DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
+ }
+ }
+
cfra = DEG_get_ctime(depsgraph);
sim.depsgraph = depsgraph;
@@ -4249,7 +4253,7 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o
}
/* execute drivers only, as animation has already been done */
- BKE_animsys_evaluate_animdata(scene, &part->id, part->adt, cfra, ADT_RECALC_DRIVERS);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &part->id, part->adt, cfra, ADT_RECALC_DRIVERS);
/* to verify if we need to restore object afterwards */
psys->flag &= ~PSYS_OB_ANIM_RESTORE;
@@ -4288,7 +4292,7 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o
for (i=0; i<=part->hair_step; i++) {
hcfra=100.0f*(float)i/(float)psys->part->hair_step;
if ((part->flag & PART_HAIR_REGROW)==0)
- BKE_animsys_evaluate_animdata(scene, &part->id, part->adt, hcfra, ADT_RECALC_ANIM);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &part->id, part->adt, hcfra, ADT_RECALC_ANIM);
system_step(&sim, hcfra, use_render_params);
psys->cfra = hcfra;
psys->recalc = 0;
@@ -4307,7 +4311,7 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o
}
case PART_FLUID:
{
- particles_fluid_step(&sim, (int)cfra, use_render_params);
+ particles_fluid_step(G.main /* Yuck :/ */, &sim, (int)cfra, use_render_params);
break;
}
default:
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 7b53c5f8811..8cc8a8510f2 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -2189,8 +2189,13 @@ float (*BKE_pbvh_get_vertCos(PBVH *pbvh))[3]
return vertCos;
}
-void BKE_pbvh_apply_vertCos(PBVH *pbvh, float (*vertCos)[3])
+void BKE_pbvh_apply_vertCos(PBVH *pbvh, float (*vertCos)[3], const int totvert)
{
+ if (totvert != pbvh->totvert) {
+ BLI_assert(!"PBVH: Given deforming vcos number does not natch PBVH vertex number!");
+ return;
+ }
+
if (!pbvh->deformed) {
if (pbvh->verts) {
/* if pbvh is not already deformed, verts/faces points to the */
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index a99057ac0ad..af13909bf89 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -1802,7 +1802,7 @@ static int ptcache_frame_from_filename(const char *filename, const char *ext)
static int ptcache_path(PTCacheID *pid, char *filename)
{
Library *lib = (pid->ob) ? pid->ob->id.lib : NULL;
- const char *blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: G.main->name;
+ const char *blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: BKE_main_blendfile_path_from_global();
size_t i;
if (pid->cache->flag & PTCACHE_EXTERNAL) {
@@ -2959,7 +2959,7 @@ int BKE_ptcache_write(PTCacheID *pid, unsigned int cfra)
return !error;
}
/* youll need to close yourself after!
- * mode - PTCACHE_CLEAR_ALL,
+ * mode - PTCACHE_CLEAR_ALL,
*/
/* Clears & resets */
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 75018bbe5bd..f7628d081a6 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -58,6 +58,7 @@
#include "BKE_collection.h"
#include "BKE_effect.h"
#include "BKE_global.h"
+#include "BKE_layer.h"
#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_mesh.h"
@@ -705,7 +706,8 @@ static void rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool
/* --------------------- */
-static void rigidbody_constraint_set_limits(RigidBodyCon *rbc, void (*set_limits)(rbConstraint*,int,float,float))
+static void rigidbody_constraint_set_limits(
+ RigidBodyCon *rbc, void (*set_limits)(rbConstraint *, int, float, float))
{
if (rbc->flag & RBC_FLAG_USE_LIMIT_LIN_X)
set_limits(rbc->physics_constraint, RB_LIMIT_LIN_X, rbc->limit_lin_x_lower, rbc->limit_lin_x_upper);
@@ -1435,14 +1437,14 @@ static void rigidbody_update_simulation(struct Depsgraph *depsgraph, Scene *scen
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
-static void rigidbody_update_simulation_post_step(RigidBodyWorld *rbw)
+static void rigidbody_update_simulation_post_step(ViewLayer *view_layer, RigidBodyWorld *rbw)
{
- FOREACH_COLLECTION_BASE_RECURSIVE_BEGIN(rbw->group, base)
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(rbw->group, ob)
{
- Object *ob = base->object;
+ Base *base = BKE_view_layer_base_find(view_layer, ob);
RigidBodyOb *rbo = ob->rigidbody_object;
/* Reset kinematic state for transformed objects. */
- if (rbo && (base->flag & BASE_SELECTED) && (G.moving & G_TRANSFORM_OBJ)) {
+ if (rbo && base && (base->flag & BASE_SELECTED) && (G.moving & G_TRANSFORM_OBJ)) {
RB_body_set_kinematic_state(rbo->physics_object, rbo->flag & RBO_FLAG_KINEMATIC || rbo->flag & RBO_FLAG_DISABLED);
RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo));
/* Deactivate passive objects so they don't interfere with deactivation of active objects. */
@@ -1450,7 +1452,7 @@ static void rigidbody_update_simulation_post_step(RigidBodyWorld *rbw)
RB_body_deactivate(rbo->physics_object);
}
}
- FOREACH_COLLECTION_BASE_RECURSIVE_END
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
bool BKE_rigidbody_check_sim_running(RigidBodyWorld *rbw, float ctime)
@@ -1646,7 +1648,8 @@ void BKE_rigidbody_do_simulation(struct Depsgraph *depsgraph, Scene *scene, floa
/* step simulation by the requested timestep, steps per second are adjusted to take time scale into account */
RB_dworld_step_simulation(rbw->physics_world, timestep, INT_MAX, 1.0f / (float)rbw->steps_per_second * min_ff(rbw->time_scale, 1.0f));
- rigidbody_update_simulation_post_step(rbw);
+ ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
+ rigidbody_update_simulation_post_step(view_layer, rbw);
/* write cache for current frame */
BKE_ptcache_validate(cache, (int)ctime);
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 1a9a2d5b36d..63d7942c623 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -942,20 +942,19 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
/* called from creator_args.c */
Scene *BKE_scene_set_name(Main *bmain, const char *name)
{
- Scene *sce = (Scene *)BKE_libblock_find_name_ex(bmain, ID_SCE, name);
+ Scene *sce = (Scene *)BKE_libblock_find_name(bmain, ID_SCE, name);
if (sce) {
BKE_scene_set_background(bmain, sce);
- printf("Scene switch for render: '%s' in file: '%s'\n", name, bmain->name);
+ printf("Scene switch for render: '%s' in file: '%s'\n", name, BKE_main_blendfile_path(bmain));
return sce;
}
- printf("Can't find scene: '%s' in file: '%s'\n", name, bmain->name);
+ printf("Can't find scene: '%s' in file: '%s'\n", name, BKE_main_blendfile_path(bmain));
return NULL;
}
/* Used by metaballs, return *all* objects (including duplis) existing in the scene (including scene's sets) */
-int BKE_scene_base_iter_next(
- Depsgraph *depsgraph, SceneBaseIter *iter,
+int BKE_scene_base_iter_next(Depsgraph *depsgraph, SceneBaseIter *iter,
Scene **scene, int val, Base **base, Object **ob)
{
bool run_again = true;
@@ -1029,7 +1028,7 @@ int BKE_scene_base_iter_next(
* this enters eternal loop because of
* makeDispListMBall getting called inside of collection_duplilist */
if ((*base)->object->dup_group == NULL) {
- iter->duplilist = object_duplilist_ex(depsgraph, (*scene), (*base)->object, false);
+ iter->duplilist = object_duplilist(depsgraph, (*scene), (*base)->object);
iter->dupob = iter->duplilist->first;
@@ -1229,7 +1228,7 @@ bool BKE_scene_validate_setscene(Main *bmain, Scene *sce)
}
/* This function is needed to cope with fractional frames - including two Blender rendering features
- * mblur (motion blur that renders 'subframes' and blurs them together), and fields rendering.
+ * mblur (motion blur that renders 'subframes' and blurs them together), and fields rendering.
*/
float BKE_scene_frame_get(const Scene *scene)
{
@@ -1268,10 +1267,10 @@ void BKE_scene_frame_set(struct Scene *scene, double cfra)
#define POSE_ANIMATION_WORKAROUND
#ifdef POSE_ANIMATION_WORKAROUND
-static void scene_armature_depsgraph_workaround(Main *bmain)
+static void scene_armature_depsgraph_workaround(Main *bmain, Depsgraph *depsgraph)
{
Object *ob;
- if (BLI_listbase_is_empty(&bmain->armature) || !DEG_id_type_tagged(bmain, ID_OB)) {
+ if (BLI_listbase_is_empty(&bmain->armature) || !DEG_id_type_updated(depsgraph, ID_OB)) {
return;
}
for (ob = bmain->object.first; ob; ob = ob->id.next) {
@@ -1293,7 +1292,7 @@ static bool check_rendered_viewport_visible(Main *bmain)
Scene *scene = window->scene;
RenderEngineType *type = RE_engines_find(scene->r.engine);
- if (type->draw_engine || !type->render_to_view) {
+ if (type->draw_engine || !type->render) {
continue;
}
@@ -1373,7 +1372,7 @@ void BKE_scene_graph_update_tagged(Depsgraph *depsgraph,
/* Inform editors about possible changes. */
DEG_ids_check_recalc(bmain, depsgraph, scene, view_layer, false);
/* Clear recalc flags. */
- DEG_ids_clear_recalc(bmain);
+ DEG_ids_clear_recalc(bmain, depsgraph);
}
/* applies changes right away, does all sets too */
@@ -1399,10 +1398,10 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph,
*
* TODO(sergey): Make this a depsgraph node?
*/
- BKE_cachefile_update_frame(bmain, scene, ctime,
+ BKE_cachefile_update_frame(bmain, depsgraph, scene, ctime,
(((double)scene->r.frs_sec) / (double)scene->r.frs_sec_base));
#ifdef POSE_ANIMATION_WORKAROUND
- scene_armature_depsgraph_workaround(bmain);
+ scene_armature_depsgraph_workaround(bmain, depsgraph);
#endif
/* Update all objects: drivers, matrices, displists, etc. flags set
* by depgraph or manual, no layer check here, gets correct flushed.
@@ -1415,7 +1414,7 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph,
/* Inform editors about possible changes. */
DEG_ids_check_recalc(bmain, depsgraph, scene, view_layer, true);
/* clear recalc flags */
- DEG_ids_clear_recalc(bmain);
+ DEG_ids_clear_recalc(bmain, depsgraph);
}
/* return default view */
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index ece68884f5c..8cff10902ef 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -69,13 +69,19 @@ static void spacetype_free(SpaceType *st)
for (art = st->regiontypes.first; art; art = art->next) {
BLI_freelistN(&art->drawcalls);
- for (pt = art->paneltypes.first; pt; pt = pt->next)
- if (pt->ext.free)
+ for (pt = art->paneltypes.first; pt; pt = pt->next) {
+ if (pt->ext.free) {
pt->ext.free(pt->ext.data);
+ }
+
+ BLI_freelistN(&pt->children);
+ }
- for (ht = art->headertypes.first; ht; ht = ht->next)
- if (ht->ext.free)
+ for (ht = art->headertypes.first; ht; ht = ht->next) {
+ if (ht->ext.free) {
ht->ext.free(ht->ext.data);
+ }
+ }
BLI_freelistN(&art->paneltypes);
BLI_freelistN(&art->headertypes);
@@ -169,10 +175,35 @@ void BKE_spacedata_freelist(ListBase *lb)
BLI_freelistN(lb);
}
+static void panel_list_copy(ListBase *newlb, const ListBase *lb)
+{
+ BLI_listbase_clear(newlb);
+ BLI_duplicatelist(newlb, lb);
+
+ /* copy panel pointers */
+ Panel *newpa = newlb->first;
+ Panel *pa = lb->first;
+ for (; newpa; newpa = newpa->next, pa = pa->next) {
+ newpa->activedata = NULL;
+
+ Panel *newpatab = newlb->first;
+ Panel *patab = lb->first;
+ while (newpatab) {
+ if (newpa->paneltab == patab) {
+ newpa->paneltab = newpatab;
+ break;
+ }
+ newpatab = newpatab->next;
+ patab = patab->next;
+ }
+
+ panel_list_copy(&newpa->children, &pa->children);
+ }
+}
+
ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
{
ARegion *newar = MEM_dupallocN(ar);
- Panel *pa, *newpa, *patab;
newar->prev = newar->next = NULL;
BLI_listbase_clear(&newar->handlers);
@@ -199,25 +230,10 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
if (ar->v2d.tab_offset)
newar->v2d.tab_offset = MEM_dupallocN(ar->v2d.tab_offset);
- BLI_listbase_clear(&newar->panels);
- BLI_duplicatelist(&newar->panels, &ar->panels);
+ panel_list_copy(&newar->panels, &ar->panels);
BLI_listbase_clear(&newar->ui_previews);
BLI_duplicatelist(&newar->ui_previews, &ar->ui_previews);
-
- /* copy panel pointers */
- for (newpa = newar->panels.first; newpa; newpa = newpa->next) {
- patab = newar->panels.first;
- pa = ar->panels.first;
- while (patab) {
- if (newpa->paneltab == pa) {
- newpa->paneltab = patab;
- break;
- }
- patab = patab->next;
- pa = pa->next;
- }
- }
return newar;
}
@@ -329,6 +345,19 @@ void BKE_region_callback_free_manipulatormap_set(void (*callback)(struct wmManip
region_free_manipulatormap_callback = callback;
}
+static void panel_list_free(ListBase *lb)
+{
+ Panel *pa, *pa_next;
+ for (pa = lb->first; pa; pa = pa_next) {
+ pa_next = pa->next;
+ if (pa->activedata) {
+ MEM_freeN(pa->activedata);
+ }
+ panel_list_free(&pa->children);
+ MEM_freeN(pa);
+ }
+}
+
/* not region itself */
void BKE_area_region_free(SpaceType *st, ARegion *ar)
{
@@ -351,16 +380,7 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar)
ar->v2d.tab_offset = NULL;
}
- if (!BLI_listbase_is_empty(&ar->panels)) {
- Panel *pa, *pa_next;
- for (pa = ar->panels.first; pa; pa = pa_next) {
- pa_next = pa->next;
- if (pa->activedata) {
- MEM_freeN(pa->activedata);
- }
- MEM_freeN(pa);
- }
- }
+ panel_list_free(&ar->panels);
for (uilst = ar->ui_lists.first; uilst; uilst = uilst->next) {
if (uilst->dyn_data) {
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 176d1224979..00af9721f07 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
- * Contributor(s):
+ * Contributor(s):
* - Blender Foundation, 2003-2009
* - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
*
@@ -1767,13 +1767,13 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
if (output != output) output = 1;
if (wipe->forward) output = 1 - output;
break;
- /* BOX WIPE IS NOT WORKING YET */
+ /* BOX WIPE IS NOT WORKING YET */
/* case DO_CROSS_WIPE: */
/* BOX WIPE IS NOT WORKING YET */
#if 0
- case DO_BOX_WIPE:
- if (!wipe->forward)
- facf0 = 1.0f - facf0; /* Go the other direction */
+ case DO_BOX_WIPE:
+ if (!wipe->forward)
+ facf0 = 1.0f - facf0; /* Go the other direction */
width = (int)(wipe->edgeWidth * ((xo + yo) / 2.0));
hwidth = (float)width / 2.0;
@@ -1806,8 +1806,9 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
output = in_band(hwidth, hyp2, 1, 1) * in_band(hwidth, hyp, 1, 1);
}
- if (!wipe->forward)
- facf0 = 1.0f - facf0; /* Go the other direction */
+ if (!wipe->forward) {
+ facf0 = 1.0f - facf0; /* Go the other direction */
+ }
angle = -1 / angle;
b1 = posy / 2 - (-angle) * posx / 2;
b3 = (yo - posy / 2) - (-angle) * (xo - posx / 2);
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index fb619f6c567..ecd0335fc4e 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
- * Contributor(s):
+ * Contributor(s):
* - Blender Foundation, 2003-2009
* - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
*
@@ -593,11 +593,12 @@ void BKE_sequencer_pixel_from_sequencer_space_v4(struct Scene *scene, float pixe
/*********************** sequencer pipeline functions *************************/
void BKE_sequencer_new_render_data(
- Main *bmain, Scene *scene, int rectx, int recty,
+ Main *bmain, struct Depsgraph *depsgraph, Scene *scene, int rectx, int recty,
int preview_render_size, int for_render,
SeqRenderData *r_context)
{
r_context->bmain = bmain;
+ r_context->depsgraph = depsgraph;
r_context->scene = scene;
r_context->rectx = rectx;
r_context->recty = recty;
@@ -897,7 +898,7 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, const bool lock_r
BLI_join_dirfile(path, sizeof(path), seq->strip->dir,
seq->strip->stripdata->name);
- BLI_path_abs(path, G.main->name);
+ BLI_path_abs(path, BKE_main_blendfile_path_from_global());
BKE_sequence_free_anim(seq);
@@ -1462,6 +1463,7 @@ typedef struct SeqIndexBuildContext {
int view_id;
Main *bmain;
+ Depsgraph *depsgraph;
Scene *scene;
Sequence *seq, *orig_seq;
} SeqIndexBuildContext;
@@ -1544,7 +1546,7 @@ static void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile)
BLI_join_dirfile(name, sizeof(name),
seq->strip->dir, seq->strip->stripdata->name);
- BLI_path_abs(name, G.main->name);
+ BLI_path_abs(name, BKE_main_blendfile_path_from_global());
proxy = seq->strip->proxy;
@@ -1561,7 +1563,7 @@ static void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile)
else {
BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir));
}
- BLI_path_abs(dir, G.main->name);
+ BLI_path_abs(dir, BKE_main_blendfile_path_from_global());
}
if (is_multiview && seq->views_format == R_IMF_VIEWS_INDIVIDUAL) {
@@ -1689,7 +1691,7 @@ static bool seq_proxy_get_fname(Editing *ed, Sequence *seq, int cfra, int render
return false;
}
BLI_path_append(dir, sizeof(dir), fname);
- BLI_path_abs(name, G.main->name);
+ BLI_path_abs(name, BKE_main_blendfile_path_from_global());
}
else if ((proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_DIR) && (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE)) {
BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir));
@@ -1721,7 +1723,7 @@ static bool seq_proxy_get_fname(Editing *ed, Sequence *seq, int cfra, int render
{
char fname[FILE_MAXFILE];
BLI_join_dirfile(fname, PROXY_MAXFILE, dir, proxy->file);
- BLI_path_abs(fname, G.main->name);
+ BLI_path_abs(fname, BKE_main_blendfile_path_from_global());
if (suffix[0] != '\0') {
/* TODO(sergey): This will actually append suffix after extension
* which is weird but how was originally coded in multiview branch.
@@ -1747,7 +1749,7 @@ static bool seq_proxy_get_fname(Editing *ed, Sequence *seq, int cfra, int render
BLI_snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####%s", dir, render_size, suffix);
}
- BLI_path_abs(name, G.main->name);
+ BLI_path_abs(name, BKE_main_blendfile_path_from_global());
BLI_path_frame(name, frameno, 0);
strcat(name, ".jpg");
@@ -1892,7 +1894,7 @@ static bool seq_proxy_multiview_context_invalid(Sequence *seq, Scene *scene, con
char path[FILE_MAX];
BLI_join_dirfile(path, sizeof(path), seq->strip->dir,
seq->strip->stripdata->name);
- BLI_path_abs(path, G.main->name);
+ BLI_path_abs(path, BKE_main_blendfile_path_from_global());
BKE_scene_multiview_view_prefix_get(scene, path, prefix, &ext);
}
else {
@@ -1950,7 +1952,9 @@ static int seq_proxy_context_count(Sequence *seq, Scene *scene)
return num_views;
}
-void BKE_sequencer_proxy_rebuild_context(Main *bmain, Scene *scene, Sequence *seq, struct GSet *file_list, ListBase *queue)
+void BKE_sequencer_proxy_rebuild_context(
+ Main *bmain, Depsgraph *depsgraph, Scene *scene,
+ Sequence *seq, struct GSet *file_list, ListBase *queue)
{
SeqIndexBuildContext *context;
Sequence *nseq;
@@ -1982,6 +1986,7 @@ void BKE_sequencer_proxy_rebuild_context(Main *bmain, Scene *scene, Sequence *se
context->overwrite = (nseq->strip->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) == 0;
context->bmain = bmain;
+ context->depsgraph = depsgraph;
context->scene = scene;
context->orig_seq = seq;
context->seq = nseq;
@@ -2035,7 +2040,7 @@ void BKE_sequencer_proxy_rebuild(SeqIndexBuildContext *context, short *stop, sho
/* fail safe code */
BKE_sequencer_new_render_data(
- bmain, context->scene,
+ bmain, context->depsgraph, context->scene,
(scene->r.size * (float) scene->r.xsch) / 100.0f + 0.5f,
(scene->r.size * (float) scene->r.ysch) / 100.0f + 0.5f, 100,
false,
@@ -2841,7 +2846,7 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context, Sequence *seq
if (s_elem) {
BLI_join_dirfile(name, sizeof(name), seq->strip->dir, s_elem->name);
- BLI_path_abs(name, G.main->name);
+ BLI_path_abs(name, BKE_main_blendfile_path_from_global());
}
flag = IB_rect | IB_metadata;
@@ -3131,7 +3136,7 @@ static ImBuf *seq_render_mask(const SeqRenderData *context, Mask *mask, float nr
/* anim-data */
adt = BKE_animdata_from_id(&mask->id);
- BKE_animsys_evaluate_animdata(context->scene, &mask_temp->id, adt, nr, ADT_RECALC_ANIM);
+ BKE_animsys_evaluate_animdata(context->depsgraph, context->scene, &mask_temp->id, adt, nr, ADT_RECALC_ANIM);
maskbuf = MEM_mallocN(sizeof(float) * context->rectx * context->recty, __func__);
@@ -3511,7 +3516,7 @@ static ImBuf *do_render_strip_uncached(
ibuf = seq_render_scene_strip(context, seq, nr, cfra);
/* Scene strips update all animation, so we need to restore original state.*/
- BKE_animsys_evaluate_all_animation(context->bmain, context->scene, cfra);
+ BKE_animsys_evaluate_all_animation(context->bmain, context->depsgraph, context->scene, cfra);
copy_to_ibuf_still(context, seq, nr, ibuf);
}
@@ -5146,7 +5151,7 @@ void BKE_sequence_init_colorspace(Sequence *seq)
ImBuf *ibuf;
BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name);
- BLI_path_abs(name, G.main->name);
+ BLI_path_abs(name, BKE_main_blendfile_path_from_global());
/* initialize input color space */
if (seq->type == SEQ_TYPE_IMAGE) {
@@ -5314,6 +5319,7 @@ static void seq_anim_add_suffix(Scene *scene, struct anim *anim, const int view_
Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C); /* only for sound */
char path[sizeof(seq_load->path)];
@@ -5328,7 +5334,7 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
int i;
BLI_strncpy(path, seq_load->path, sizeof(path));
- BLI_path_abs(path, G.main->name);
+ BLI_path_abs(path, BKE_main_blendfile_path(bmain));
anim_arr = MEM_callocN(sizeof(struct anim *) * totfiles, "Video files");
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 3d3130486cb..a7b233bc042 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -50,6 +50,7 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_DerivedMesh.h"
#include "BKE_lattice.h"
+#include "BKE_library.h"
#include "BKE_modifier.h"
#include "BKE_deform.h"
@@ -367,7 +368,7 @@ static void shrinkwrap_calc_normal_projection_cb_ex(
}
}
-static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, const ModifierEvalContext *ctx)
+static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
{
/* Options about projection direction */
float proj_axis[3] = {0.0f, 0.0f, 0.0f};
@@ -382,6 +383,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, const Mo
/* auxiliary target */
Mesh *auxMesh = NULL;
+ bool auxMesh_free;
void *auxData = NULL;
SpaceTransform local2aux;
@@ -414,7 +416,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, const Mo
}
if (calc->smd->auxTarget) {
- auxMesh = BKE_modifier_get_evaluated_mesh_from_object(ctx, calc->smd->auxTarget);
+ auxMesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(calc->smd->auxTarget, &auxMesh_free);
if (!auxMesh)
return;
BLI_SPACE_TRANSFORM_SETUP(&local2aux, calc->ob, calc->smd->auxTarget);
@@ -482,6 +484,9 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, const Mo
free_bvhtree_from_mesh(auxData);
}
}
+ if (auxMesh != NULL && auxMesh_free) {
+ BKE_id_free(NULL, auxMesh);
+ }
}
/*
@@ -596,11 +601,12 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
/* Main shrinkwrap function */
void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, Mesh *mesh,
- float (*vertexCos)[3], int numVerts, const ModifierEvalContext *ctx)
+ float (*vertexCos)[3], int numVerts)
{
DerivedMesh *ss_mesh = NULL;
ShrinkwrapCalcData calc = NULL_ShrinkwrapCalcData;
+ bool target_free;
/* remove loop dependencies on derived meshes (TODO should this be done elsewhere?) */
if (smd->target == ob) smd->target = NULL;
@@ -625,7 +631,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, Mesh *me
if (smd->target) {
- calc.target = BKE_modifier_get_evaluated_mesh_from_object(ctx, smd->target);
+ calc.target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(smd->target, &target_free);
/* TODO there might be several "bugs" on non-uniform scales matrixs
* because it will no longer be nearest surface, not sphere projection
@@ -681,7 +687,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, Mesh *me
break;
case MOD_SHRINKWRAP_PROJECT:
- TIMEIT_BENCH(shrinkwrap_calc_normal_projection(&calc, ctx), deform_project);
+ TIMEIT_BENCH(shrinkwrap_calc_normal_projection(&calc), deform_project);
break;
case MOD_SHRINKWRAP_NEAREST_VERTEX:
@@ -693,4 +699,8 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, Mesh *me
/* free memory */
if (ss_mesh)
ss_mesh->release(ss_mesh);
+
+ if (target_free && calc.target) {
+ BKE_id_free(NULL, calc.target);
+ }
}
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 272af8341de..738be9ded54 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -73,6 +73,7 @@
#include "BKE_deform.h"
#include "BKE_DerivedMesh.h"
#include "BKE_effect.h"
+#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
@@ -2107,7 +2108,8 @@ BLI_INLINE void apply_inflow_fields(SmokeFlowSettings *sfs, float emission_value
}
}
-static void update_flowsfluids(struct Depsgraph *depsgraph, Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt)
+static void update_flowsfluids(
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt)
{
Object **flowobjs = NULL;
EmissionMap *emaps = NULL;
@@ -2561,7 +2563,9 @@ static void update_effectors(struct Depsgraph *depsgraph, Scene *scene, Object *
pdEndEffectors(&effectors);
}
-static void step(struct Depsgraph *depsgraph, Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *domain_dm, float fps)
+static void step(
+ Depsgraph *depsgraph,
+ Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *domain_dm, float fps)
{
SmokeDomainSettings *sds = smd->domain;
/* stability values copied from wturbulence.cpp */
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 747ffdafe8b..a7f3fc1df9e 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -77,7 +77,7 @@ bSound *BKE_sound_new_file(struct Main *bmain, const char *filepath)
BLI_strncpy(str, filepath, sizeof(str));
- path = /*bmain ? bmain->name :*/ G.main->name;
+ path = BKE_main_blendfile_path(bmain);
BLI_path_abs(str, path);
@@ -96,7 +96,7 @@ bSound *BKE_sound_new_file_exists_ex(struct Main *bmain, const char *filepath, b
char str[FILE_MAX], strtest[FILE_MAX];
BLI_strncpy(str, filepath, sizeof(str));
- BLI_path_abs(str, bmain->name);
+ BLI_path_abs(str, BKE_main_blendfile_path(bmain));
/* first search an identical filepath */
for (sound = bmain->sound.first; sound; sound = sound->id.next) {
diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c
index f139ea5fbe6..e4b49656907 100644
--- a/source/blender/blenkernel/intern/studiolight.c
+++ b/source/blender/blenkernel/intern/studiolight.c
@@ -55,29 +55,41 @@
/* Statics */
static ListBase studiolights;
-#define STUDIOLIGHT_EXTENSIONS ".jpg", ".hdr"
-#define STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE 32
+#define STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE 8
+#define STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT 32
+#define STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH (STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT * 2)
static const char *STUDIOLIGHT_CAMERA_FOLDER = "studiolights/camera/";
static const char *STUDIOLIGHT_WORLD_FOLDER = "studiolights/world/";
+static const char *STUDIOLIGHT_MATCAP_FOLDER = "studiolights/matcap/";
/* FUNCTIONS */
static void studiolight_free(struct StudioLight *sl)
{
for (int index = 0 ; index < 6 ; index ++) {
- if (sl->radiance_buffers[index] != NULL) {
- IMB_freeImBuf(sl->radiance_buffers[index]);
- sl->radiance_buffers[index] = NULL;
+ if (sl->radiance_cubemap_buffers[index] != NULL) {
+ IMB_freeImBuf(sl->radiance_cubemap_buffers[index]);
+ sl->radiance_cubemap_buffers[index] = NULL;
}
- if (sl->equirectangular_gputexture) {
- GPU_texture_free(sl->equirectangular_gputexture);
- sl->equirectangular_gputexture = NULL;
+ if (sl->equirectangular_radiance_gputexture) {
+ GPU_texture_free(sl->equirectangular_radiance_gputexture);
+ sl->equirectangular_radiance_gputexture = NULL;
}
- if (sl->equirectangular_buffer) {
- IMB_freeImBuf(sl->equirectangular_buffer);
- sl->equirectangular_buffer = NULL;
+ if (sl->equirectangular_irradiance_gputexture) {
+ GPU_texture_free(sl->equirectangular_irradiance_gputexture);
+ sl->equirectangular_irradiance_gputexture = NULL;
+ }
+
+ if (sl->equirectangular_radiance_buffer) {
+ IMB_freeImBuf(sl->equirectangular_radiance_buffer);
+ sl->equirectangular_radiance_buffer = NULL;
+ }
+
+ if (sl->equirectangular_irradiance_buffer) {
+ IMB_freeImBuf(sl->equirectangular_irradiance_buffer);
+ sl->equirectangular_irradiance_buffer = NULL;
}
}
MEM_freeN(sl);
@@ -94,7 +106,7 @@ static struct StudioLight *studiolight_create(void)
sl->irradiance_icon_id = BKE_icon_ensure_studio_light(sl, STUDIOLIGHT_ICON_ID_TYPE_IRRADIANCE);
for (int index = 0 ; index < 6 ; index ++) {
- sl->radiance_buffers[index] = NULL;
+ sl->radiance_cubemap_buffers[index] = NULL;
}
return sl;
}
@@ -153,30 +165,49 @@ static void studiolight_load_equierectangular_image(StudioLight *sl)
ibuf = IMB_loadiffname(sl->path, 0, NULL);
if (ibuf) {
IMB_float_from_rect(ibuf);
- sl->equirectangular_buffer = ibuf;
+ sl->equirectangular_radiance_buffer = ibuf;
}
}
- sl->flag |= STUDIOLIGHT_EQUIRECTANGULAR_IMAGE_LOADED;
+ sl->flag |= STUDIOLIGHT_EXTERNAL_IMAGE_LOADED;
}
-static void studiolight_create_equierectangular_gputexture(StudioLight *sl)
+static void studiolight_create_equierectangular_radiance_gputexture(StudioLight *sl)
{
if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) {
char error[256];
- BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECTANGULAR_IMAGE_LOADED);
- ImBuf *ibuf = sl->equirectangular_buffer;
- sl->equirectangular_gputexture = GPU_texture_create_2D(ibuf->x, ibuf->y, GPU_RGBA16F, ibuf->rect_float, error);
- }
- sl->flag |= STUDIOLIGHT_EQUIRECTANGULAR_GPUTEXTURE;
+ BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EXTERNAL_IMAGE_LOADED);
+ ImBuf *ibuf = sl->equirectangular_radiance_buffer;
+ sl->equirectangular_radiance_gputexture = GPU_texture_create_2D(ibuf->x, ibuf->y, GPU_RGBA8, ibuf->rect_float, error);
+ GPUTexture *tex = sl->equirectangular_radiance_gputexture;
+ GPU_texture_bind(tex, 0);
+ GPU_texture_filter_mode(tex, true);
+ GPU_texture_wrap_mode(tex, true);
+ GPU_texture_unbind(tex);
+ }
+ sl->flag |= STUDIOLIGHT_EQUIRECTANGULAR_RADIANCE_GPUTEXTURE;
}
+static void studiolight_create_equierectangular_irradiance_gputexture(StudioLight *sl)
+{
+ if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) {
+ char error[256];
+ BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECTANGULAR_IRRADIANCE_IMAGE_CALCULATED);
+ ImBuf *ibuf = sl->equirectangular_irradiance_buffer;
+ sl->equirectangular_irradiance_gputexture = GPU_texture_create_2D(ibuf->x, ibuf->y, GPU_RGBA16F, ibuf->rect_float, error);
+ GPUTexture *tex = sl->equirectangular_irradiance_gputexture;
+ GPU_texture_bind(tex, 0);
+ GPU_texture_filter_mode(tex, true);
+ GPU_texture_wrap_mode(tex, true);
+ GPU_texture_unbind(tex);
+ }
+ sl->flag |= STUDIOLIGHT_EQUIRECTANGULAR_IRRADIANCE_GPUTEXTURE;
+}
-
-static void studiolight_calculate_radiance_buffers(StudioLight *sl)
+static void studiolight_calculate_radiance_cubemap_buffers(StudioLight *sl)
{
if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) {
- BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECTANGULAR_IMAGE_LOADED);
- ImBuf* ibuf = sl->equirectangular_buffer;
+ BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EXTERNAL_IMAGE_LOADED);
+ ImBuf *ibuf = sl->equirectangular_radiance_buffer;
if (ibuf) {
float *colbuf = MEM_mallocN(SQUARE(STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) * sizeof(float[4]), __func__);
const float add = 1.0f / (STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE + 1);
@@ -184,41 +215,41 @@ static void studiolight_calculate_radiance_buffers(StudioLight *sl)
/* front */
studiolight_calculate_radiance_buffer(ibuf, colbuf, start, add, start, add, 0.5f, 0, 2, 1);
- sl->radiance_buffers[STUDIOLIGHT_Y_POS] = IMB_allocFromBuffer(
+ sl->radiance_cubemap_buffers[STUDIOLIGHT_Y_POS] = IMB_allocFromBuffer(
NULL, colbuf, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE);
/* back */
studiolight_calculate_radiance_buffer(ibuf, colbuf, -start, -add, start, add, -0.5f, 0, 2, 1);
- sl->radiance_buffers[STUDIOLIGHT_Y_NEG] = IMB_allocFromBuffer(
+ sl->radiance_cubemap_buffers[STUDIOLIGHT_Y_NEG] = IMB_allocFromBuffer(
NULL, colbuf, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE);
/* left */
studiolight_calculate_radiance_buffer(ibuf, colbuf, -start, -add, start, add, 0.5f, 1, 2, 0);
- sl->radiance_buffers[STUDIOLIGHT_X_POS] = IMB_allocFromBuffer(
+ sl->radiance_cubemap_buffers[STUDIOLIGHT_X_POS] = IMB_allocFromBuffer(
NULL, colbuf, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE);
/* right */
studiolight_calculate_radiance_buffer(ibuf, colbuf, start, add, start, add, -0.5f, 1, 2, 0);
- sl->radiance_buffers[STUDIOLIGHT_X_NEG] = IMB_allocFromBuffer(
+ sl->radiance_cubemap_buffers[STUDIOLIGHT_X_NEG] = IMB_allocFromBuffer(
NULL, colbuf, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE);
/* top */
studiolight_calculate_radiance_buffer(ibuf, colbuf, start, add, start, add, -0.5f, 0, 1, 2);
- sl->radiance_buffers[STUDIOLIGHT_Z_NEG] = IMB_allocFromBuffer(
+ sl->radiance_cubemap_buffers[STUDIOLIGHT_Z_NEG] = IMB_allocFromBuffer(
NULL, colbuf, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE);
/* bottom */
studiolight_calculate_radiance_buffer(ibuf, colbuf, start, add, -start, -add, 0.5f, 0, 1, 2);
- sl->radiance_buffers[STUDIOLIGHT_Z_POS] = IMB_allocFromBuffer(
+ sl->radiance_cubemap_buffers[STUDIOLIGHT_Z_POS] = IMB_allocFromBuffer(
NULL, colbuf, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE);
#if 0
- IMB_saveiff(sl->radiance_buffers[STUDIOLIGHT_X_POS], "/tmp/studiolight_radiance_left.png", IB_rectfloat);
- IMB_saveiff(sl->radiance_buffers[STUDIOLIGHT_X_NEG], "/tmp/studiolight_radiance_right.png", IB_rectfloat);
- IMB_saveiff(sl->radiance_buffers[STUDIOLIGHT_Y_POS], "/tmp/studiolight_radiance_front.png", IB_rectfloat);
- IMB_saveiff(sl->radiance_buffers[STUDIOLIGHT_Y_NEG], "/tmp/studiolight_radiance_back.png", IB_rectfloat);
- IMB_saveiff(sl->radiance_buffers[STUDIOLIGHT_Z_POS], "/tmp/studiolight_radiance_bottom.png", IB_rectfloat);
- IMB_saveiff(sl->radiance_buffers[STUDIOLIGHT_Z_NEG], "/tmp/studiolight_radiance_top.png", IB_rectfloat);
+ IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_X_POS], "/tmp/studiolight_radiance_left.png", IB_rectfloat);
+ IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_X_NEG], "/tmp/studiolight_radiance_right.png", IB_rectfloat);
+ IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_Y_POS], "/tmp/studiolight_radiance_front.png", IB_rectfloat);
+ IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_Y_NEG], "/tmp/studiolight_radiance_back.png", IB_rectfloat);
+ IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_Z_POS], "/tmp/studiolight_radiance_bottom.png", IB_rectfloat);
+ IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_Z_NEG], "/tmp/studiolight_radiance_top.png", IB_rectfloat);
#endif
MEM_freeN(colbuf);
}
@@ -226,147 +257,61 @@ static void studiolight_calculate_radiance_buffers(StudioLight *sl)
sl->flag |= STUDIOLIGHT_RADIANCE_BUFFERS_CALCULATED;
}
-static void studiolight_calculate_irradiance(StudioLight *sl, float color[3], const float normal[3])
+BLI_INLINE void studiolight_evaluate_radiance_buffer(
+ ImBuf *radiance_buffer, const float normal[3], float color[3], int *hits,
+ int xoffset, int yoffset, int zoffset, float zvalue)
{
- float direction[3];
- ImBuf *radiance_buffer;
- float *radiance_color;
- float angle;
-
- /* back */
- radiance_buffer = sl->radiance_buffers[STUDIOLIGHT_Y_POS];
if (radiance_buffer == NULL) {
- goto fail;
+ return;
}
- radiance_color = radiance_buffer->rect_float;
+ float angle;
+ float *radiance_color = radiance_buffer->rect_float;
+ float direction[3];
for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) {
for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) {
// calculate light direction;
- direction[1] = 0.5;
- direction[0] = (x / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
- direction[2] = (y / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
+ direction[zoffset] = zvalue;
+ direction[xoffset] = (x / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
+ direction[yoffset] = (y / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
normalize_v3(direction);
- angle = dot_v3v3(direction, normal);
- if (angle > 0.0f) {
- madd_v3_v3fl(color, radiance_color, angle);
- }
+ angle = fmax(0.0f, dot_v3v3(direction, normal));
+ madd_v3_v3fl(color, radiance_color, angle);
+ (*hits) ++;
radiance_color += 4;
}
}
+}
+
+static void studiolight_calculate_irradiance(StudioLight *sl, float color[3], const float normal[3])
+{
+ int hits = 0;
+ copy_v3_fl(color, 0.0f);
+
+ /* back */
+ studiolight_evaluate_radiance_buffer(sl->radiance_cubemap_buffers[STUDIOLIGHT_Y_POS], normal, color, &hits, 0, 2, 1, 0.5);
/* front */
- radiance_buffer = sl->radiance_buffers[STUDIOLIGHT_Y_NEG];
- if (radiance_buffer == NULL) {
- goto fail;
- }
- radiance_color = radiance_buffer->rect_float;
- for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) {
- for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) {
- // calculate light direction;
- direction[1] = -0.5;
- direction[0] = (x / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
- direction[2] = (y / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
- normalize_v3(direction);
- angle = dot_v3v3(direction, normal);
- if (angle > 0.0f) {
- madd_v3_v3fl(color, radiance_color, angle);
- }
- radiance_color += 4;
- }
- }
+ studiolight_evaluate_radiance_buffer(sl->radiance_cubemap_buffers[STUDIOLIGHT_Y_NEG], normal, color, &hits, 0, 2, 1, -0.5);
/* left */
- radiance_buffer = sl->radiance_buffers[STUDIOLIGHT_X_POS];
- if (radiance_buffer == NULL) {
- goto fail;
- }
- radiance_color = radiance_buffer->rect_float;
- for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) {
- for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) {
- // calculate light direction;
- direction[0] = 0.5;
- direction[1] = (x / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
- direction[2] = (y / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
- normalize_v3(direction);
- angle = dot_v3v3(direction, normal);
- if (angle > 0.0f) {
- madd_v3_v3fl(color, radiance_color, angle);
- }
- radiance_color += 4;
- }
- }
-
+ studiolight_evaluate_radiance_buffer(sl->radiance_cubemap_buffers[STUDIOLIGHT_X_POS], normal, color, &hits, 1, 2, 0, 0.5);
/* right */
- radiance_buffer = sl->radiance_buffers[STUDIOLIGHT_X_NEG];
- if (radiance_buffer == NULL) {
- goto fail;
- }
- radiance_color = radiance_buffer->rect_float;
- for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) {
- for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) {
- // calculate light direction;
- direction[0] = -0.5;
- direction[1] = (x / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
- direction[2] = (y / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
- normalize_v3(direction);
- angle = dot_v3v3(direction, normal);
- if (angle > 0.0f) {
- madd_v3_v3fl(color, radiance_color, angle);
- }
- radiance_color += 4;
- }
- }
+ studiolight_evaluate_radiance_buffer(sl->radiance_cubemap_buffers[STUDIOLIGHT_X_NEG], normal, color, &hits, 1, 2, 0, -0.5);
/* top */
- radiance_buffer = sl->radiance_buffers[STUDIOLIGHT_Z_POS];
- if (radiance_buffer == NULL) {
- goto fail;
- }
- radiance_color = radiance_buffer->rect_float;
- for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) {
- for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) {
- // calculate light direction;
- direction[2] = 0.5;
- direction[0] = (x / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
- direction[1] = (y / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
- normalize_v3(direction);
- angle = dot_v3v3(direction, normal);
- if (angle > 0.0f) {
- madd_v3_v3fl(color, radiance_color, angle);
- }
- radiance_color += 4;
- }
- }
-
+ studiolight_evaluate_radiance_buffer(sl->radiance_cubemap_buffers[STUDIOLIGHT_Z_POS], normal, color, &hits, 0, 1, 2, 0.5);
/* bottom */
- radiance_buffer = sl->radiance_buffers[STUDIOLIGHT_Z_NEG];
- if (radiance_buffer == NULL) {
- goto fail;
+ studiolight_evaluate_radiance_buffer(sl->radiance_cubemap_buffers[STUDIOLIGHT_Z_NEG], normal, color, &hits, 0, 1, 2, -0.5);
+
+ if (hits) {
+ mul_v3_fl(color, 3.0 / hits);
}
- radiance_color = radiance_buffer->rect_float;
- for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) {
- for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) {
- // calculate light direction;
- direction[2] = -0.5;
- direction[0] = (x / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
- direction[1] = (y / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
- normalize_v3(direction);
- angle = dot_v3v3(direction, normal);
- if (angle > 0.0f) {
- madd_v3_v3fl(color, radiance_color, angle);
- }
- radiance_color += 4;
- }
+ else {
+ copy_v3_fl3(color, 1.0, 0.0, 1.0);
}
-
- mul_v3_fl(color, 1.25 / (STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE * STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE));
- return;
-
-fail:
- /* Pink color of failure. */
- ARRAY_SET_ITEMS(color, 1.0f, 0.0f, 1.0f);
}
+
static void studiolight_calculate_diffuse_light(StudioLight *sl)
{
/* init light to black */
@@ -397,6 +342,99 @@ static void studiolight_calculate_diffuse_light(StudioLight *sl)
sl->flag |= STUDIOLIGHT_DIFFUSE_LIGHT_CALCULATED;
}
+BLI_INLINE void studiolight_evaluate_specular_radiance_buffer(
+ ImBuf *radiance_buffer, const float specular, const float normal[3], float color[3], int *hits,
+ int xoffset, int yoffset, int zoffset, float zvalue)
+{
+ if (radiance_buffer == NULL) {
+ return;
+ }
+ float angle;
+ float *radiance_color = radiance_buffer->rect_float;
+ float direction[3];
+ for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) {
+ for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) {
+ // calculate light direction;
+ direction[zoffset] = zvalue;
+ direction[xoffset] = (x / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
+ direction[yoffset] = (y / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f;
+ normalize_v3(direction);
+ angle = pow(fmax(0.0f, dot_v3v3(direction, normal)), specular);
+ madd_v3_v3fl(color, radiance_color, angle);
+ (*hits) ++;
+ radiance_color += 4;
+ }
+ }
+
+}
+
+static void studiolight_calculate_specular_irradiance(StudioLight *sl, float color[3], const float normal[3])
+{
+ const float specular = 4.0f;
+ int hits = 0;
+ copy_v3_fl(color, 0.0f);
+
+ /* back */
+ studiolight_evaluate_specular_radiance_buffer(
+ sl->radiance_cubemap_buffers[STUDIOLIGHT_Y_POS], specular, normal, color, &hits, 0, 2, 1, 0.5);
+ /* front */
+ studiolight_evaluate_specular_radiance_buffer(
+ sl->radiance_cubemap_buffers[STUDIOLIGHT_Y_NEG], specular, normal, color, &hits, 0, 2, 1, -0.5);
+
+ /* left */
+ studiolight_evaluate_specular_radiance_buffer(
+ sl->radiance_cubemap_buffers[STUDIOLIGHT_X_POS], specular, normal, color, &hits, 1, 2, 0, 0.5);
+ /* right */
+ studiolight_evaluate_specular_radiance_buffer(
+ sl->radiance_cubemap_buffers[STUDIOLIGHT_X_NEG], specular, normal, color, &hits, 1, 2, 0, -0.5);
+
+ /* top */
+ studiolight_evaluate_specular_radiance_buffer(
+ sl->radiance_cubemap_buffers[STUDIOLIGHT_Z_POS], specular, normal, color, &hits, 0, 1, 2, 0.5);
+ /* bottom */
+ studiolight_evaluate_specular_radiance_buffer(
+ sl->radiance_cubemap_buffers[STUDIOLIGHT_Z_NEG], specular, normal, color, &hits, 0, 1, 2, -0.5);
+
+ if (hits) {
+ mul_v3_fl(color, specular / hits);
+ }
+ else {
+ copy_v3_fl3(color, 1.0, 0.0, 1.0);
+ }
+}
+
+static void studiolight_calculate_irradiance_equirectangular_image(StudioLight *sl)
+{
+ if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) {
+ BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_RADIANCE_BUFFERS_CALCULATED);
+
+ float *colbuf = MEM_mallocN(STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH * STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT * sizeof(float[4]), __func__);
+ float *color = colbuf;
+ for (int y = 0; y < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT ; y ++) {
+ float yf = y / (float)STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT;
+
+ for (int x = 0; x < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH ; x ++) {
+ float xf = x / (float)STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH;
+ float dir[3];
+ equirectangular_to_direction(dir, xf, yf);
+ studiolight_calculate_specular_irradiance(sl, color, dir);
+ color[3] = 1.0f;
+ color += 4;
+ }
+ }
+ sl->equirectangular_irradiance_buffer = IMB_allocFromBuffer(
+ NULL, colbuf,
+ STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH,
+ STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT);
+ MEM_freeN(colbuf);
+#if 0
+ IMB_saveiff(sl->equirectangular_irradiance_buffer, "/tmp/studiolight_specular_irradiance.png", IB_rectfloat);
+#endif
+
+ }
+ sl->flag |= STUDIOLIGHT_EQUIRECTANGULAR_IRRADIANCE_IMAGE_CALCULATED;
+}
+
static void studiolight_calculate_light_direction(StudioLight *sl)
{
float best_light = 0.0;
@@ -405,30 +443,27 @@ static void studiolight_calculate_light_direction(StudioLight *sl)
sl->light_direction[2] = -1.0f;
if ((sl->flag & STUDIOLIGHT_EXTERNAL_FILE) && (sl->flag & STUDIOLIGHT_ORIENTATION_WORLD)) {
- ImBuf *ibuf = NULL;
- ibuf = IMB_loadiffname(sl->path, 0, NULL);
+ BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECTANGULAR_IRRADIANCE_IMAGE_CALCULATED);
+ ImBuf *ibuf = sl->equirectangular_irradiance_buffer;
if (ibuf) {
- IMB_float_from_rect(ibuf);
/* go over every pixel, determine light, if higher calc direction off the light */
- float col[4];
- float direction[3];
float new_light;
- for (int y = 0; y < ibuf->y; y ++) {
- for (int x = 0; x < ibuf->x; x ++) {
- nearest_interpolation_color_wrap(ibuf, NULL, col, x, y);
- new_light = col[0] + col[1] + col[2];
+ float *color = ibuf->rect_float;
+ for (int y = 0; y < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT; y ++) {
+ for (int x = 0; x < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH; x ++) {
+ new_light = color[0] + color[1] + color[2];
if (new_light > best_light) {
- float u = x / (float)ibuf->x;
- float v = y / (float)ibuf->y;
- equirectangular_to_direction(direction, u, v);
- sl->light_direction[0] = direction[1];
- sl->light_direction[1] = direction[0];
- sl->light_direction[2] = direction[2];
+ float u = x / (float)STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH;
+ float v = y / (float)STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT;
+ equirectangular_to_direction(sl->light_direction, u, v);
+ SWAP(float, sl->light_direction[0], sl->light_direction[1]);
+ normalize_v3(sl->light_direction);
+ negate_v3(sl->light_direction);
best_light = new_light;
}
+ color += 4;
}
}
- IMB_freeImBuf(ibuf);
}
}
sl->flag |= STUDIOLIGHT_LIGHT_DIRECTION_CALCULATED;
@@ -440,13 +475,13 @@ static void studiolight_add_files_from_datafolder(const int folder_id, const cha
struct direntry *dir;
const char *folder = BKE_appdir_folder_id(folder_id, subfolder);
if (folder) {
- unsigned int totfile = BLI_filelist_dir_contents(folder, &dir);
+ uint totfile = BLI_filelist_dir_contents(folder, &dir);
int i;
for (i = 0; i < totfile; i++) {
if ((dir[i].type & S_IFREG)) {
const char *filename = dir[i].relname;
const char *path = dir[i].path;
- if (BLI_testextensie_n(filename, STUDIOLIGHT_EXTENSIONS, NULL)) {
+ if (BLI_testextensie_array(filename, imb_ext_image)) {
sl = studiolight_create();
sl->flag = STUDIOLIGHT_EXTERNAL_FILE | flag;
BLI_strncpy(sl->name, filename, FILE_MAXFILE);
@@ -490,9 +525,9 @@ static int studiolight_cmp(const void *a, const void *b)
}
/* icons */
-static unsigned int* studiolight_radiance_preview(StudioLight *sl, int icon_size)
+static uint *studiolight_radiance_preview(StudioLight *sl, int icon_size)
{
- BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECTANGULAR_IMAGE_LOADED);
+ BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EXTERNAL_IMAGE_LOADED);
uint *rect = MEM_mallocN(icon_size * icon_size * sizeof(uint), __func__);
int icon_center = icon_size / 2;
@@ -531,7 +566,7 @@ static unsigned int* studiolight_radiance_preview(StudioLight *sl, int icon_size
reflect_v3_v3v3(direction, incoming, normal);
float color[4];
- studiolight_calculate_radiance(sl->equirectangular_buffer, color, direction);
+ studiolight_calculate_radiance(sl->equirectangular_radiance_buffer, color, direction);
pixelresult = rgb_to_cpack(
linearrgb_to_srgb(color[0]),
@@ -544,56 +579,134 @@ static unsigned int* studiolight_radiance_preview(StudioLight *sl, int icon_size
return rect;
}
-static unsigned int* studiolight_irradiance_preview(StudioLight *sl, int icon_size)
+static uint *studiolight_matcap_preview(StudioLight *sl, int icon_size)
{
- BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_DIFFUSE_LIGHT_CALCULATED);
+ BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EXTERNAL_IMAGE_LOADED);
uint *rect = MEM_mallocN(icon_size * icon_size * sizeof(uint), __func__);
- int icon_center = icon_size / 2;
- float sphere_radius = icon_center * 0.9;
-
+ const uint alphamask = 0xff000000;
+ float color[4];
+ float fx, fy;
int offset = 0;
+ ImBuf *ibuf = sl->equirectangular_radiance_buffer;
for (int y = 0; y < icon_size; y++) {
- float dy = y - icon_center;
for (int x = 0; x < icon_size; x++) {
- float dx = x - icon_center;
- /* calculate aliasing */
- float alias = 0;
- const float alias_step = 0.333;
- for (float ay = dy - 0.5; ay < dy + 0.5; ay += alias_step) {
- for (float ax = dx - 0.5; ax < dx + 0.5; ax += alias_step) {
- if (sqrt(ay * ay + ax * ax) < sphere_radius) {
- alias += alias_step * alias_step;
+ fx = x * ibuf->x / icon_size;
+ fy = y * ibuf->y / icon_size;
+ nearest_interpolation_color(ibuf, NULL, color, fx, fy);
+ rect[offset++] = rgb_to_cpack(linearrgb_to_srgb(color[0]),
+ linearrgb_to_srgb(color[1]),
+ linearrgb_to_srgb(color[2])) | alphamask;
+ }
+ }
+ return rect;
+}
+
+static uint *studiolight_irradiance_preview(StudioLight *sl, int icon_size)
+{
+ if (/*!(sl->flag & STUDIOLIGHT_EXTERNAL_FILE)*/ 1) {
+
+ BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_DIFFUSE_LIGHT_CALCULATED);
+
+ uint *rect = MEM_mallocN(icon_size * icon_size * sizeof(uint), __func__);
+ int icon_center = icon_size / 2;
+ float sphere_radius = icon_center * 0.9;
+
+ int offset = 0;
+ for (int y = 0; y < icon_size; y++) {
+ float dy = y - icon_center;
+ for (int x = 0; x < icon_size; x++) {
+ float dx = x - icon_center;
+ /* calculate aliasing */
+ float alias = 0;
+ const float alias_step = 0.333;
+ for (float ay = dy - 0.5; ay < dy + 0.5; ay += alias_step) {
+ for (float ax = dx - 0.5; ax < dx + 0.5; ax += alias_step) {
+ if (sqrt(ay * ay + ax * ax) < sphere_radius) {
+ alias += alias_step * alias_step;
+ }
}
}
+ uint pixelresult = 0x0;
+ uint alias_i = clamp_i(alias * 256, 0, 255);
+ if (alias_i != 0) {
+ /* calculate normal */
+ uint alias_mask = alias_i << 24;
+ float normal[3];
+ normal[0] = dx / sphere_radius;
+ normal[1] = dy / sphere_radius;
+ normal[2] = sqrt(-(normal[0] * normal[0]) - (normal[1] * normal[1]) + 1);
+ normalize_v3(normal);
+
+ float color[3];
+ mul_v3_v3fl(color, sl->diffuse_light[STUDIOLIGHT_X_POS], clamp_f(normal[0], 0.0, 1.0));
+ interp_v3_v3v3(color, color, sl->diffuse_light[STUDIOLIGHT_X_NEG], clamp_f(-normal[0], 0.0, 1.0));
+ interp_v3_v3v3(color, color, sl->diffuse_light[STUDIOLIGHT_Z_POS], clamp_f(normal[1], 0.0, 1.0));
+ interp_v3_v3v3(color, color, sl->diffuse_light[STUDIOLIGHT_Z_NEG], clamp_f(-normal[1], 0.0, 1.0));
+ interp_v3_v3v3(color, color, sl->diffuse_light[STUDIOLIGHT_Y_POS], clamp_f(normal[2], 0.0, 1.0));
+
+ pixelresult = rgb_to_cpack(
+ linearrgb_to_srgb(color[0]),
+ linearrgb_to_srgb(color[1]),
+ linearrgb_to_srgb(color[2])) | alias_mask;
+ }
+ rect[offset++] = pixelresult;
}
- uint pixelresult = 0x0;
- uint alias_i = clamp_i(alias * 256, 0, 255);
- if (alias_i != 0) {
- /* calculate normal */
- uint alias_mask = alias_i << 24;
- float normal[3];
- normal[0] = dx / sphere_radius;
- normal[1] = dy / sphere_radius;
- normal[2] = sqrt(-(normal[0] * normal[0]) - (normal[1] * normal[1]) + 1);
- normalize_v3(normal);
-
- float color[3];
- mul_v3_v3fl(color, sl->diffuse_light[STUDIOLIGHT_X_POS], clamp_f(normal[0], 0.0, 1.0));
- interp_v3_v3v3(color, color, sl->diffuse_light[STUDIOLIGHT_X_NEG], clamp_f(-normal[0], 0.0, 1.0));
- interp_v3_v3v3(color, color, sl->diffuse_light[STUDIOLIGHT_Z_POS], clamp_f(normal[1], 0.0, 1.0));
- interp_v3_v3v3(color, color, sl->diffuse_light[STUDIOLIGHT_Z_NEG], clamp_f(-normal[1], 0.0, 1.0));
- interp_v3_v3v3(color, color, sl->diffuse_light[STUDIOLIGHT_Y_POS], clamp_f(normal[2], 0.0, 1.0));
-
- pixelresult = rgb_to_cpack(
- linearrgb_to_srgb(color[0]),
- linearrgb_to_srgb(color[1]),
- linearrgb_to_srgb(color[2])) | alias_mask;
+ }
+ return rect;
+ }
+ else {
+ BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECTANGULAR_IRRADIANCE_IMAGE_CALCULATED);
+
+ uint *rect = MEM_mallocN(icon_size * icon_size * sizeof(uint), __func__);
+ int icon_center = icon_size / 2;
+ float sphere_radius = icon_center * 0.9;
+
+ int offset = 0;
+ for (int y = 0; y < icon_size; y++) {
+ float dy = y - icon_center;
+ for (int x = 0; x < icon_size; x++) {
+ float dx = x - icon_center;
+ /* calculate aliasing */
+ float alias = 0;
+ const float alias_step = 0.333;
+ for (float ay = dy - 0.5; ay < dy + 0.5; ay += alias_step) {
+ for (float ax = dx - 0.5; ax < dx + 0.5; ax += alias_step) {
+ if (sqrt(ay * ay + ax * ax) < sphere_radius) {
+ alias += alias_step * alias_step;
+ }
+ }
+ }
+ uint pixelresult = 0x0;
+ uint alias_i = clamp_i(alias * 256, 0, 255);
+ if (alias_i != 0) {
+ /* calculate normal */
+ uint alias_mask = alias_i << 24;
+ float incoming[3];
+ copy_v3_fl3(incoming, 0.0, 1.0, 0.0);
+
+ float normal[3];
+ normal[0] = dx / sphere_radius;
+ normal[2] = dy / sphere_radius;
+ normal[1] = -sqrt(-(normal[0] * normal[0]) - (normal[2] * normal[2]) + 1);
+ normalize_v3(normal);
+
+ float direction[3];
+ reflect_v3_v3v3(direction, incoming, normal);
+
+ float color[4];
+ studiolight_calculate_radiance(sl->equirectangular_irradiance_buffer, color, direction);
+
+ pixelresult = rgb_to_cpack(
+ linearrgb_to_srgb(color[0]),
+ linearrgb_to_srgb(color[1]),
+ linearrgb_to_srgb(color[2])) | alias_mask;
+ }
+ rect[offset++] = pixelresult;
}
- rect[offset++] = pixelresult;
}
+ return rect;
}
- return rect;
}
/* API */
@@ -606,19 +719,21 @@ void BKE_studiolight_init(void)
/* Add default studio light */
sl = studiolight_create();
BLI_strncpy(sl->name, "INTERNAL_01", FILE_MAXFILE);
- sl->flag = STUDIOLIGHT_DIFFUSE_LIGHT_CALCULATED | STUDIOLIGHT_ORIENTATION_CAMERA;
+ sl->flag = STUDIOLIGHT_INTERNAL | STUDIOLIGHT_DIFFUSE_LIGHT_CALCULATED | STUDIOLIGHT_ORIENTATION_CAMERA;
copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_X_POS], 0.0f);
copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_X_NEG], 0.0f);
- copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Y_POS], 1.0f);
- copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Y_NEG], 0.0f);
- copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Z_POS], 0.0f);
- copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Z_NEG], 0.0f);
+ copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Y_POS], 0.8f);
+ copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Y_NEG], 0.05f);
+ copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Z_POS], 0.2f);
+ copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Z_NEG], 0.1f);
BLI_addtail(&studiolights, sl);
studiolight_add_files_from_datafolder(BLENDER_SYSTEM_DATAFILES, STUDIOLIGHT_CAMERA_FOLDER, STUDIOLIGHT_ORIENTATION_CAMERA);
- studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES, STUDIOLIGHT_CAMERA_FOLDER, STUDIOLIGHT_ORIENTATION_CAMERA);
+ studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES, STUDIOLIGHT_CAMERA_FOLDER, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_USER_DEFINED);
studiolight_add_files_from_datafolder(BLENDER_SYSTEM_DATAFILES, STUDIOLIGHT_WORLD_FOLDER, STUDIOLIGHT_ORIENTATION_WORLD);
- studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES, STUDIOLIGHT_WORLD_FOLDER, STUDIOLIGHT_ORIENTATION_WORLD);
+ studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES, STUDIOLIGHT_WORLD_FOLDER, STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_USER_DEFINED);
+ studiolight_add_files_from_datafolder(BLENDER_SYSTEM_DATAFILES, STUDIOLIGHT_MATCAP_FOLDER, STUDIOLIGHT_ORIENTATION_VIEWNORMAL);
+ studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES, STUDIOLIGHT_MATCAP_FOLDER, STUDIOLIGHT_ORIENTATION_VIEWNORMAL | STUDIOLIGHT_USER_DEFINED);
/* sort studio lights on filename. */
BLI_listbase_sort(&studiolights, studiolight_cmp);
@@ -632,23 +747,34 @@ void BKE_studiolight_free(void)
}
}
+struct StudioLight *BKE_studiolight_find_first(int flag)
+{
+ LISTBASE_FOREACH(StudioLight *, sl, &studiolights) {
+ if ((sl->flag & flag)) {
+ return sl;
+ }
+ }
+ return NULL;
+}
+
struct StudioLight *BKE_studiolight_find(const char *name, int flag)
{
LISTBASE_FOREACH(StudioLight *, sl, &studiolights) {
if (STREQLEN(sl->name, name, FILE_MAXFILE)) {
- if ((sl->flag & flag) == flag) {
+ if ((sl->flag & flag)) {
return sl;
- } else {
+ }
+ else {
/* flags do not match, so use default */
- return studiolights.first;
+ return BKE_studiolight_find_first(flag);
}
}
}
/* When not found, use the default studio light */
- return studiolights.first;
+ return BKE_studiolight_find_first(flag);
}
-struct StudioLight *BKE_studiolight_findindex(int index)
+struct StudioLight *BKE_studiolight_findindex(int index, int flag)
{
LISTBASE_FOREACH(StudioLight *, sl, &studiolights) {
if (sl->index == index) {
@@ -656,19 +782,25 @@ struct StudioLight *BKE_studiolight_findindex(int index)
}
}
/* When not found, use the default studio light */
- return studiolights.first;
+ return BKE_studiolight_find_first(flag);
}
-const struct ListBase *BKE_studiolight_listbase(void)
+struct ListBase *BKE_studiolight_listbase(void)
{
return &studiolights;
}
-unsigned int *BKE_studiolight_preview(StudioLight *sl, int icon_size, int icon_id_type)
+uint *BKE_studiolight_preview(StudioLight *sl, int icon_size, int icon_id_type)
{
if (icon_id_type == STUDIOLIGHT_ICON_ID_TYPE_IRRADIANCE) {
- return studiolight_irradiance_preview(sl, icon_size);
- } else {
+ if (sl->flag & STUDIOLIGHT_ORIENTATION_VIEWNORMAL) {
+ return studiolight_matcap_preview(sl, icon_size);
+ }
+ else {
+ return studiolight_irradiance_preview(sl, icon_size);
+ }
+ }
+ else {
return studiolight_radiance_preview(sl, icon_size);
}
}
@@ -679,19 +811,31 @@ void BKE_studiolight_ensure_flag(StudioLight *sl, int flag)
return;
}
- if ((flag & STUDIOLIGHT_EQUIRECTANGULAR_IMAGE_LOADED)) {
+ if ((flag & STUDIOLIGHT_EXTERNAL_IMAGE_LOADED)) {
studiolight_load_equierectangular_image(sl);
}
if ((flag & STUDIOLIGHT_RADIANCE_BUFFERS_CALCULATED)) {
- studiolight_calculate_radiance_buffers(sl);
+ studiolight_calculate_radiance_cubemap_buffers(sl);
}
if ((flag & STUDIOLIGHT_DIFFUSE_LIGHT_CALCULATED)) {
studiolight_calculate_diffuse_light(sl);
}
- if ((flag & STUDIOLIGHT_EQUIRECTANGULAR_GPUTEXTURE)) {
- studiolight_create_equierectangular_gputexture(sl);
+ if ((flag & STUDIOLIGHT_EQUIRECTANGULAR_RADIANCE_GPUTEXTURE)) {
+ studiolight_create_equierectangular_radiance_gputexture(sl);
}
if ((flag & STUDIOLIGHT_LIGHT_DIRECTION_CALCULATED)) {
studiolight_calculate_light_direction(sl);
}
+ if ((flag & STUDIOLIGHT_EQUIRECTANGULAR_IRRADIANCE_GPUTEXTURE)) {
+ studiolight_create_equierectangular_irradiance_gputexture(sl);
+ }
+ if ((flag & STUDIOLIGHT_EQUIRECTANGULAR_IRRADIANCE_IMAGE_CALCULATED)) {
+ studiolight_calculate_irradiance_equirectangular_image(sl);
+ }
+}
+
+void BKE_studiolight_refresh(void)
+{
+ BKE_studiolight_free();
+ BKE_studiolight_init();
}
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index ed23078a9d8..d735944c93d 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -69,6 +69,7 @@
#include "BKE_mesh_mapping.h"
#include "BKE_modifier.h"
#include "BKE_multires.h"
+#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_scene.h"
#include "BKE_subsurf.h"
@@ -2327,7 +2328,7 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
numGrids, &key, (void **) ccgdm->gridFaces, ccgdm->gridFlagMats, ccgdm->gridHidden);
}
else if (ob->type == OB_MESH) {
- Mesh *me = ob->data;
+ Mesh *me = BKE_object_get_original_mesh(ob);
const int looptris_num = poly_to_tri_count(me->totpoly, me->totloop);
MLoopTri *looptri;
@@ -2351,7 +2352,7 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
totvert = deformdm->getNumVerts(deformdm);
vertCos = MEM_malloc_arrayN(totvert, sizeof(float[3]), "ccgDM_getPBVH vertCos");
deformdm->getVertCos(deformdm, vertCos);
- BKE_pbvh_apply_vertCos(ccgdm->pbvh, vertCos);
+ BKE_pbvh_apply_vertCos(ccgdm->pbvh, vertCos, totvert);
MEM_freeN(vertCos);
}
}
diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c
index eb17e103671..b74143b5c07 100644
--- a/source/blender/blenkernel/intern/suggestions.c
+++ b/source/blender/blenkernel/intern/suggestions.c
@@ -246,12 +246,12 @@ void texttool_docs_show(const char *docs)
/* Ensure documentation ends with a '\n' */
if (docs[len - 1] != '\n') {
documentation = MEM_mallocN(len + 2, "Documentation");
- strncpy(documentation, docs, len);
+ BLI_strncpy(documentation, docs, len);
documentation[len++] = '\n';
}
else {
documentation = MEM_mallocN(len + 1, "Documentation");
- strncpy(documentation, docs, len);
+ BLI_strncpy(documentation, docs, len);
}
documentation[len] = '\0';
}
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 3892b2f0546..226ab33e45e 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -388,7 +388,7 @@ bool BKE_text_reload(Text *text)
}
BLI_strncpy(filepath_abs, text->name, FILE_MAX);
- BLI_path_abs(filepath_abs, G.main->name);
+ BLI_path_abs(filepath_abs, BKE_main_blendfile_path_from_global());
buffer = BLI_file_read_text_as_mem(filepath_abs, 0, &buffer_len);
if (buffer == NULL) {
@@ -557,7 +557,7 @@ int BKE_text_file_modified_check(Text *text)
return 0;
BLI_strncpy(file, text->name, FILE_MAX);
- BLI_path_abs(file, G.main->name);
+ BLI_path_abs(file, BKE_main_blendfile_path_from_global());
if (!BLI_exists(file))
return 2;
@@ -585,7 +585,7 @@ void BKE_text_file_modified_ignore(Text *text)
if (!text->name) return;
BLI_strncpy(file, text->name, FILE_MAX);
- BLI_path_abs(file, G.main->name);
+ BLI_path_abs(file, BKE_main_blendfile_path_from_global());
if (!BLI_exists(file)) return;
@@ -1702,7 +1702,7 @@ static void txt_undo_add_blockop(Text *text, TextUndoBuf *utxt, int op, const ch
/* 4 bytes */
txt_undo_store_uint32(utxt->buf, &utxt->pos, length);
/* 'length' bytes */
- strncpy(utxt->buf + utxt->pos, buf, length);
+ BLI_strncpy(utxt->buf + utxt->pos, buf, length);
utxt->pos += length;
/* 4 bytes */
txt_undo_store_uint32(utxt->buf, &utxt->pos, length);
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 3314e8d01b6..fe9cf1e9609 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -395,7 +395,7 @@ MovieTrackingReconstruction *BKE_tracking_get_active_reconstruction(MovieTrackin
/* Get transformation matrix for a given object which is used
* for parenting motion tracker reconstruction to 3D world.
*/
-void BKE_tracking_get_camera_object_matrix(Scene *scene, Object *ob, float mat[4][4])
+void BKE_tracking_get_camera_object_matrix(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float mat[4][4])
{
if (!ob) {
if (scene->camera)
@@ -405,7 +405,7 @@ void BKE_tracking_get_camera_object_matrix(Scene *scene, Object *ob, float mat[4
}
if (ob)
- BKE_object_where_is_calc_mat4(scene, ob, mat);
+ BKE_object_where_is_calc_mat4(depsgraph, scene, ob, mat);
else
unit_m4(mat);
}
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index f5e4c354a02..a05e79aae1f 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -376,7 +376,7 @@ UndoStep *BKE_undosys_step_push_init_with_type(UndoStack *ustack, bContext *C, c
us->type = ut;
ustack->step_init = us;
ut->step_encode_init(C, us);
- undosys_stack_validate(ustack, true);
+ undosys_stack_validate(ustack, false);
return us;
}
else {
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index fb768333bb6..b71dfaf5aea 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -505,6 +505,13 @@ void BKE_workspace_update_tagged(Main *bmain,
struct Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene,
view_layer,
true);
+ /* TODO(sergey): For now all dependency graphs which are evaluated from
+ * workspace are considered active. This will work all fine with "locked"
+ * view layer and time across windows. This is to be granted separately,
+ * and for until then we have to accept ambiguities when object is shared
+ * across visible view layers and has overrides on it.
+ */
+ DEG_make_active(depsgraph);
BKE_scene_graph_update_tagged(depsgraph, bmain);
}
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 15bf01d2049..1b06e7ed851 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -53,6 +53,8 @@
#include "BKE_node.h"
#include "BKE_world.h"
+#include "DEG_depsgraph.h"
+
#include "GPU_material.h"
/** Free (or release) any data used by this world (does not free the world itself). */
@@ -161,13 +163,10 @@ void BKE_world_make_local(Main *bmain, World *wrld, const bool lib_local)
BKE_id_make_local_generic(bmain, &wrld->id, true, lib_local);
}
-void BKE_world_eval(struct Depsgraph *UNUSED(depsgraph), World *world)
+void BKE_world_eval(struct Depsgraph *depsgraph, World *world)
{
- if (G.debug & G_DEBUG_DEPSGRAPH_EVAL) {
- printf("%s on %s (%p)\n", __func__, world->id.name, world);
- }
+ DEG_debug_print_eval(depsgraph, __func__, world->id.name, world);
if (!BLI_listbase_is_empty(&world->gpumaterial)) {
world->update_flag = 1;
- GPU_material_uniform_buffer_tag_dirty(&world->gpumaterial);
}
}
diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c
index e357f13530d..33ac312425b 100644
--- a/source/blender/blenkernel/intern/writeavi.c
+++ b/source/blender/blenkernel/intern/writeavi.c
@@ -145,7 +145,7 @@ static void filepath_avi(char *string, RenderData *rd, bool preview, const char
}
strcpy(string, rd->pic);
- BLI_path_abs(string, G.main->name);
+ BLI_path_abs(string, BKE_main_blendfile_path_from_global());
BLI_make_existing_file(string);
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index 1f819571b11..17c665f3bcd 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -1042,19 +1042,19 @@ fail:
}
/**
- * Writes any delayed frames in the encoder. This function is called before
+ * Writes any delayed frames in the encoder. This function is called before
* closing the encoder.
*
* <p>
- * Since an encoder may use both past and future frames to predict
- * inter-frames (H.264 B-frames, for example), it can output the frames
+ * Since an encoder may use both past and future frames to predict
+ * inter-frames (H.264 B-frames, for example), it can output the frames
* in a different order from the one it was given.
* For example, when sending frames 1, 2, 3, 4 to the encoder, it may write
* them in the order 1, 4, 2, 3 - first the two frames used for prediction,
- * and then the bidirectionally-predicted frames. What this means in practice
- * is that the encoder may not immediately produce one output frame for each
- * input frame. These delayed frames must be flushed before we close the
- * stream. We do this by calling avcodec_encode_video with NULL for the last
+ * and then the bidirectionally-predicted frames. What this means in practice
+ * is that the encoder may not immediately produce one output frame for each
+ * input frame. These delayed frames must be flushed before we close the
+ * stream. We do this by calling avcodec_encode_video with NULL for the last
* parameter.
* </p>
*/
@@ -1127,7 +1127,7 @@ static void ffmpeg_filepath_get(FFMpegContext *context, char *string, RenderData
}
strcpy(string, rd->pic);
- BLI_path_abs(string, G.main->name);
+ BLI_path_abs(string, BKE_main_blendfile_path_from_global());
BLI_make_existing_file(string);
diff --git a/source/blender/blenkernel/nla_private.h b/source/blender/blenkernel/nla_private.h
index 2e38e33a308..c441f00ceaa 100644
--- a/source/blender/blenkernel/nla_private.h
+++ b/source/blender/blenkernel/nla_private.h
@@ -33,6 +33,8 @@
#ifndef __NLA_PRIVATE_H__
#define __NLA_PRIVATE_H__
+struct Depsgraph;
+
/* --------------- NLA Evaluation DataTypes ----------------------- */
/* used for list of strips to accumulate at current time */
@@ -81,8 +83,8 @@ float nlastrip_get_frame(NlaStrip *strip, float cframe, short mode);
/* --------------- NLA Evaluation (very-private stuff) ----------------------- */
/* these functions are only defined here to avoid problems with the order in which they get defined... */
-NlaEvalStrip *nlastrips_ctime_get_strip(ListBase *list, ListBase *strips, short index, float ctime);
-void nlastrip_evaluate(PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes);
+NlaEvalStrip *nlastrips_ctime_get_strip(struct Depsgraph *depsgraph, ListBase *list, ListBase *strips, short index, float ctime);
+void nlastrip_evaluate(struct Depsgraph *depsgraph, PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes);
void nladata_flush_channels(ListBase *channels);
#endif /* __NLA_PRIVATE_H__ */
diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h
index 06bbf29a223..9f0e7392322 100644
--- a/source/blender/blenlib/BLI_blenlib.h
+++ b/source/blender/blenlib/BLI_blenlib.h
@@ -45,10 +45,10 @@
*
* - blenlib is written in C.
* - The posix-compliance may move to a separate lib that deals with
- * platform dependencies. (There are other platform-dependent
+ * platform dependencies. (There are other platform-dependent
* fixes as well.)
* - The file i/o has some redundant code. It should be cleaned.
- *
+ *
* \subsection dependencies Dependencies
*
* - The blenlib uses type defines from \ref DNA, and functions from
diff --git a/source/blender/blenlib/BLI_dial_2d.h b/source/blender/blenlib/BLI_dial_2d.h
index dbd71a8ad3f..4a265164e10 100644
--- a/source/blender/blenlib/BLI_dial_2d.h
+++ b/source/blender/blenlib/BLI_dial_2d.h
@@ -25,14 +25,14 @@
* \ingroup bli
*
* \note dials act similar to old rotation based phones and output an angle.
- *
+ *
* They just are initialized with the center of the dial and a threshold value as input.
- *
- * When the distance of the current position of the dial from the center
- * exceeds the threshold, this position is used to calculate the initial direction.
+ *
+ * When the distance of the current position of the dial from the center
+ * exceeds the threshold, this position is used to calculate the initial direction.
* After that, the angle from the initial direction is calculated based on
* current and previous directions of the digit, and returned to the user.
- *
+ *
* Usage examples:
*
* \code{.c}
@@ -41,11 +41,11 @@
* float threshold = 0.5f;
* float angle;
* Dial *dial;
- *
+ *
* dial = BLI_dial_initialize(start_position, threshold);
*
* angle = BLI_dial_angle(dial, curent_position);
- *
+ *
* MEM_freeN(dial);
* \endcode
*/
diff --git a/source/blender/blenlib/BLI_dlrbTree.h b/source/blender/blenlib/BLI_dlrbTree.h
index bdde8dbd597..05b67e358a4 100644
--- a/source/blender/blenlib/BLI_dlrbTree.h
+++ b/source/blender/blenlib/BLI_dlrbTree.h
@@ -32,7 +32,7 @@
*/
/* Double-Linked Red-Black Tree Implementation:
- *
+ *
* This is simply a Red-Black Tree implementation whose nodes can later
* be arranged + retrieved as elements in a Double-Linked list (i.e. ListBase).
* The Red-Black Tree implementation is based on the methods defined by Wikipedia.
diff --git a/source/blender/blenlib/BLI_fnmatch.h b/source/blender/blenlib/BLI_fnmatch.h
index 06fa5048622..42033b89f42 100644
--- a/source/blender/blenlib/BLI_fnmatch.h
+++ b/source/blender/blenlib/BLI_fnmatch.h
@@ -2,17 +2,17 @@
*
* NOTE: The canonical source of this file is maintained with the GNU C Library.
* Bugs can be reported to bug-glibc@prep.ai.mit.edu.
- *
+ *
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index 6f8e48d83b2..f455436ce63 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -200,24 +200,28 @@ double double_round(double x, int ndigits);
* check the vector is unit length, or zero length (which can't be helped in some cases).
*/
#ifndef NDEBUG
-/* note: 0.0001 is too small becaues normals may be converted from short's: see [#34322] */
+/** \note 0.0001 is too small becaues normals may be converted from short's: see T34322. */
# define BLI_ASSERT_UNIT_EPSILON 0.0002f
+/**
+ * \note Checks are flipped so NAN doesn't assert. This is done because we're making sure the value was normalized
+ * and in the case we don't want NAN to be raising asserts since there is nothing to be done in that case.
+ */
# define BLI_ASSERT_UNIT_V3(v) { \
const float _test_unit = len_squared_v3(v); \
- BLI_assert((fabsf(_test_unit - 1.0f) < BLI_ASSERT_UNIT_EPSILON) || \
- (fabsf(_test_unit) < BLI_ASSERT_UNIT_EPSILON)); \
+ BLI_assert(!(fabsf(_test_unit - 1.0f) >= BLI_ASSERT_UNIT_EPSILON) || \
+ !(fabsf(_test_unit) >= BLI_ASSERT_UNIT_EPSILON)); \
} (void)0
# define BLI_ASSERT_UNIT_V2(v) { \
const float _test_unit = len_squared_v2(v); \
- BLI_assert((fabsf(_test_unit - 1.0f) < BLI_ASSERT_UNIT_EPSILON) || \
- (fabsf(_test_unit) < BLI_ASSERT_UNIT_EPSILON)); \
+ BLI_assert(!(fabsf(_test_unit - 1.0f) >= BLI_ASSERT_UNIT_EPSILON) || \
+ !(fabsf(_test_unit) >= BLI_ASSERT_UNIT_EPSILON)); \
} (void)0
# define BLI_ASSERT_UNIT_QUAT(q) { \
const float _test_unit = dot_qtqt(q, q); \
- BLI_assert((fabsf(_test_unit - 1.0f) < BLI_ASSERT_UNIT_EPSILON * 10) || \
- (fabsf(_test_unit) < BLI_ASSERT_UNIT_EPSILON * 10)); \
+ BLI_assert(!(fabsf(_test_unit - 1.0f) >= BLI_ASSERT_UNIT_EPSILON * 10) || \
+ !(fabsf(_test_unit) >= BLI_ASSERT_UNIT_EPSILON * 10)); \
} (void)0
# define BLI_ASSERT_ZERO_M3(m) { \
diff --git a/source/blender/blenlib/BLI_memarena.h b/source/blender/blenlib/BLI_memarena.h
index 6b1d32b48f2..8793e44397a 100644
--- a/source/blender/blenlib/BLI_memarena.h
+++ b/source/blender/blenlib/BLI_memarena.h
@@ -23,7 +23,7 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- */
+ */
/** \file BLI_memarena.h
* \ingroup bli
diff --git a/source/blender/blenlib/BLI_noise.h b/source/blender/blenlib/BLI_noise.h
index f3292d26b1e..03f2c588f5e 100644
--- a/source/blender/blenlib/BLI_noise.h
+++ b/source/blender/blenlib/BLI_noise.h
@@ -23,7 +23,7 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- *
+ *
*/
#ifndef __BLI_NOISE_H__
diff --git a/source/blender/blenlib/BLI_task.h b/source/blender/blenlib/BLI_task.h
index d03010af8d2..ad325493309 100644
--- a/source/blender/blenlib/BLI_task.h
+++ b/source/blender/blenlib/BLI_task.h
@@ -40,7 +40,7 @@ extern "C" {
struct BLI_mempool;
/* Task Scheduler
- *
+ *
* Central scheduler that holds running threads ready to execute tasks. A single
* queue holds the task from all pools.
*
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h
index 66eb5cfd22b..96bb739f683 100644
--- a/source/blender/blenlib/BLI_threads.h
+++ b/source/blender/blenlib/BLI_threads.h
@@ -76,7 +76,7 @@ void BLI_system_num_threads_override_set(int num);
int BLI_system_num_threads_override_get(void);
/* Global Mutex Locks
- *
+ *
* One custom lock available now. can be extended. */
#define LOCK_IMAGE 0
diff --git a/source/blender/blenlib/BLI_timecode.h b/source/blender/blenlib/BLI_timecode.h
index a45613c6b1e..bc85b51791b 100644
--- a/source/blender/blenlib/BLI_timecode.h
+++ b/source/blender/blenlib/BLI_timecode.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index 75ddb5e739c..9c90b86832a 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -629,6 +629,14 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
# define UNLIKELY(x) (x)
#endif
+/* Expands to an integer constant expression evaluating to a close upper bound
+ * on the number the number of decimal digits in a value expressible in the
+ * integer type given by the argument (if it is a type name) or the the integer
+ * type of the argument (if it is an expression). The meaning of the resulting
+ * expression is unspecified for other arguments.
+ * i.e: DECIMAL_DIGITS_BOUND(uchar) is equal to 3. */
+#define DECIMAL_DIGITS_BOUND(t) (241 * sizeof(t) / 100 + 1)
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenlib/BLI_vfontdata.h b/source/blender/blenlib/BLI_vfontdata.h
index 0cd50319a33..16fdfa8a468 100644
--- a/source/blender/blenlib/BLI_vfontdata.h
+++ b/source/blender/blenlib/BLI_vfontdata.h
@@ -30,7 +30,7 @@
/** \file BLI_vfontdata.h
* \ingroup bli
- * \brief A structure to represent vector fonts,
+ * \brief A structure to represent vector fonts,
* and to load them from PostScript fonts.
*/
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index b3adf3106c1..c6daae97688 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -513,25 +513,27 @@ static void create_kdop_hull(const BVHTree *tree, BVHNode *node, const float *co
}
/**
- * \note depends on the fact that the BVH's for each face is already build
+ * \note depends on the fact that the BVH's for each face is already built
*/
static void refit_kdop_hull(const BVHTree *tree, BVHNode *node, int start, int end)
{
float newmin, newmax;
- float *bv = node->bv;
+ float *__restrict bv = node->bv;
int j;
axis_t axis_iter;
node_minmax_init(tree, node);
for (j = start; j < end; j++) {
+ float *__restrict node_bv = tree->nodes[j]->bv;
+
/* for all Axes. */
for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) {
- newmin = tree->nodes[j]->bv[(2 * axis_iter)];
+ newmin = node_bv[(2 * axis_iter)];
if ((newmin < bv[(2 * axis_iter)]))
bv[(2 * axis_iter)] = newmin;
- newmax = tree->nodes[j]->bv[(2 * axis_iter) + 1];
+ newmax = node_bv[(2 * axis_iter) + 1];
if ((newmax > bv[(2 * axis_iter) + 1]))
bv[(2 * axis_iter) + 1] = newmax;
}
diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c
index 844f274a81f..800e245d6bd 100644
--- a/source/blender/blenlib/intern/BLI_kdtree.c
+++ b/source/blender/blenlib/intern/BLI_kdtree.c
@@ -751,7 +751,7 @@ static void deduplicate_recursive(const struct DeDuplicateParams *p, uint i)
* although it can still be used as a target.
* \returns The numebr of merges found (includes any merges already in the \a duplicates array).
*
- * \note Merging is always a single step (target indices wont be marked for merging).
+ * \note Merging is always a single step (target indices wont be marked for merging).
*/
int BLI_kdtree_calc_duplicates_fast(
const KDTree *tree, const float range, bool use_index_order,
diff --git a/source/blender/blenlib/intern/boxpack_2d.c b/source/blender/blenlib/intern/boxpack_2d.c
index cf9e29209fb..dea39631389 100644
--- a/source/blender/blenlib/intern/boxpack_2d.c
+++ b/source/blender/blenlib/intern/boxpack_2d.c
@@ -50,7 +50,7 @@
/* BoxPacker for backing 2D rectangles into a square
- *
+ *
* The defined Below are for internal use only */
typedef struct BoxVert {
float x;
@@ -271,7 +271,7 @@ static int vertex_sort(const void *p1, const void *p2, void *vs_ctx_p)
* This sets boxes x,y to positive values, sorting from 0,0 outwards.
* There is no limit to the space boxes may take, only that they will be packed
* tightly into the lower left hand corner (0,0)
- *
+ *
* \param boxarray: a pre allocated array of boxes.
* only the 'box->x' and 'box->y' are set, 'box->w' and 'box->h' are used,
* 'box->index' is not used at all, the only reason its there
diff --git a/source/blender/blenlib/intern/jitter_2d.c b/source/blender/blenlib/intern/jitter_2d.c
index 26351f52c7f..2632e8bc234 100644
--- a/source/blender/blenlib/intern/jitter_2d.c
+++ b/source/blender/blenlib/intern/jitter_2d.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c
index b87fed571b7..5918b4d3cf9 100644
--- a/source/blender/blenlib/intern/listbase.c
+++ b/source/blender/blenlib/intern/listbase.c
@@ -23,7 +23,7 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- *
+ *
*/
/** \file blender/blenlib/intern/listbase.c
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 0f98a648259..f8af6c20ae5 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -979,7 +979,7 @@ float dist_squared_to_projected_aabb_simple(
/* Adapted from "Real-Time Collision Detection" by Christer Ericson,
* published by Morgan Kaufmann Publishers, copyright 2005 Elsevier Inc.
- *
+ *
* Set 'r' to the point in triangle (a, b, c) closest to point 'p' */
void closest_on_tri_to_point_v3(float r[3], const float p[3],
const float a[3], const float b[3], const float c[3])
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 3559500bf63..48bc1a2928b 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -33,6 +33,8 @@
#include "BLI_strict_flags.h"
+#include "eigen_capi.h"
+
/********************************* Init **************************************/
void zero_m2(float m[2][2])
@@ -192,6 +194,25 @@ void mul_m4_m4m4_uniq(float R[4][4], const float A[4][4], const float B[4][4])
BLI_assert(R != A && R != B);
/* matrix product: R[j][k] = A[j][i] . B[i][k] */
+#ifdef __SSE2__
+ __m128 A0 = _mm_loadu_ps(A[0]);
+ __m128 A1 = _mm_loadu_ps(A[1]);
+ __m128 A2 = _mm_loadu_ps(A[2]);
+ __m128 A3 = _mm_loadu_ps(A[3]);
+
+ for (int i = 0; i < 4; i++) {
+ __m128 B0 = _mm_set1_ps(B[i][0]);
+ __m128 B1 = _mm_set1_ps(B[i][1]);
+ __m128 B2 = _mm_set1_ps(B[i][2]);
+ __m128 B3 = _mm_set1_ps(B[i][3]);
+
+ __m128 sum = _mm_add_ps(
+ _mm_add_ps(_mm_mul_ps(B0, A0), _mm_mul_ps(B1, A1)),
+ _mm_add_ps(_mm_mul_ps(B2, A2), _mm_mul_ps(B3, A3)));
+
+ _mm_storeu_ps(R[i], sum);
+ }
+#else
R[0][0] = B[0][0] * A[0][0] + B[0][1] * A[1][0] + B[0][2] * A[2][0] + B[0][3] * A[3][0];
R[0][1] = B[0][0] * A[0][1] + B[0][1] * A[1][1] + B[0][2] * A[2][1] + B[0][3] * A[3][1];
R[0][2] = B[0][0] * A[0][2] + B[0][1] * A[1][2] + B[0][2] * A[2][2] + B[0][3] * A[3][2];
@@ -211,6 +232,7 @@ void mul_m4_m4m4_uniq(float R[4][4], const float A[4][4], const float B[4][4])
R[3][1] = B[3][0] * A[0][1] + B[3][1] * A[1][1] + B[3][2] * A[2][1] + B[3][3] * A[3][1];
R[3][2] = B[3][0] * A[0][2] + B[3][1] * A[1][2] + B[3][2] * A[2][2] + B[3][3] * A[3][2];
R[3][3] = B[3][0] * A[0][3] + B[3][1] * A[1][3] + B[3][2] * A[2][3] + B[3][3] * A[3][3];
+#endif
}
void mul_m4_m4_pre(float R[4][4], const float A[4][4])
@@ -875,74 +897,11 @@ bool invert_m4(float m[4][4])
return success;
}
-/*
- * invertmat -
- * computes the inverse of mat and puts it in inverse. Returns
- * true on success (i.e. can always find a pivot) and false on failure.
- * Uses Gaussian Elimination with partial (maximal column) pivoting.
- *
- * Mark Segal - 1992
- */
-
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
{
- int i, j, k;
- double temp;
- float tempmat[4][4];
- float max;
- int maxj;
-
- BLI_assert(inverse != mat);
-
- /* Set inverse to identity */
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++)
- inverse[i][j] = 0;
- for (i = 0; i < 4; i++)
- inverse[i][i] = 1;
-
- /* Copy original matrix so we don't mess it up */
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++)
- tempmat[i][j] = mat[i][j];
-
- for (i = 0; i < 4; i++) {
- /* Look for row with max pivot */
- max = fabsf(tempmat[i][i]);
- maxj = i;
- for (j = i + 1; j < 4; j++) {
- if (fabsf(tempmat[j][i]) > max) {
- max = fabsf(tempmat[j][i]);
- maxj = j;
- }
- }
- /* Swap rows if necessary */
- if (maxj != i) {
- for (k = 0; k < 4; k++) {
- SWAP(float, tempmat[i][k], tempmat[maxj][k]);
- SWAP(float, inverse[i][k], inverse[maxj][k]);
- }
- }
-
- if (UNLIKELY(tempmat[i][i] == 0.0f)) {
- return false; /* No non-zero pivot */
- }
- temp = (double)tempmat[i][i];
- for (k = 0; k < 4; k++) {
- tempmat[i][k] = (float)((double)tempmat[i][k] / temp);
- inverse[i][k] = (float)((double)inverse[i][k] / temp);
- }
- for (j = 0; j < 4; j++) {
- if (j != i) {
- temp = tempmat[j][i];
- for (k = 0; k < 4; k++) {
- tempmat[j][k] -= (float)((double)tempmat[i][k] * temp);
- inverse[j][k] -= (float)((double)inverse[i][k] * temp);
- }
- }
- }
- }
- return true;
+ /* Use optimized matrix inverse from Eigen, since performance
+ * impact of this function is significant in complex rigs. */
+ return EIG_invert_m4_m4(inverse, mat);
}
/****************************** Linear Algebra *******************************/
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index f19d6ca31d6..a3651de73a2 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -83,7 +83,7 @@ static bool BLI_path_is_abs(const char *name);
* \param tail Optional area to return copy of part of string following digits, or from dot if no digits.
* \param numlen Optional to return number of digits found.
*/
-int BLI_stringdec(const char *string, char *head, char *tail, unsigned short *numlen)
+int BLI_stringdec(const char *string, char *head, char *tail, ushort *r_num_len)
{
uint nums = 0, nume = 0;
int i;
@@ -93,8 +93,12 @@ int BLI_stringdec(const char *string, char *head, char *tail, unsigned short *nu
const uint lslash_len = lslash != NULL ? (int)(lslash - string) : 0;
uint name_end = string_len;
- while (name_end > lslash_len && string[--name_end] != '.') {} /* name ends at dot if present */
- if (name_end == lslash_len && string[name_end] != '.') name_end = string_len;
+ while (name_end > lslash_len && string[--name_end] != '.') {
+ /* name ends at dot if present */
+ }
+ if (name_end == lslash_len && string[name_end] != '.') {
+ name_end = string_len;
+ }
for (i = name_end - 1; i >= (int)lslash_len; i--) {
if (isdigit(string[i])) {
@@ -113,25 +117,35 @@ int BLI_stringdec(const char *string, char *head, char *tail, unsigned short *nu
}
if (found_digit) {
- if (tail) strcpy(tail, &string[nume + 1]);
- if (head) {
- strcpy(head, string);
- head[nums] = 0;
+ const long long int ret = strtoll(&(string[nums]), NULL, 10);
+ if (ret >= INT_MIN && ret <= INT_MAX) {
+ if (tail) {
+ strcpy(tail, &string[nume + 1]);
+ }
+ if (head) {
+ strcpy(head, string);
+ head[nums] = 0;
+ }
+ if (r_num_len) {
+ *r_num_len = nume - nums + 1;
+ }
+ return (int)ret;
}
- if (numlen) *numlen = nume - nums + 1;
- return ((int)atoi(&(string[nums])));
}
- else {
- if (tail) strcpy(tail, string + name_end);
- if (head) {
- /* name_end points to last character of head,
- * make it +1 so null-terminator is nicely placed
- */
- BLI_strncpy(head, string, name_end + 1);
- }
- if (numlen) *numlen = 0;
- return 0;
+
+ if (tail) {
+ strcpy(tail, string + name_end);
+ }
+ if (head) {
+ /* name_end points to last character of head,
+ * make it +1 so null-terminator is nicely placed
+ */
+ BLI_strncpy(head, string, name_end + 1);
+ }
+ if (r_num_len) {
+ *r_num_len = 0;
}
+ return 0;
}
@@ -1745,7 +1759,7 @@ bool BLI_path_name_at_index(const char *path, const int index, int *r_offset, in
#if 0
/**
* Produce image export path.
- *
+ *
* Returns:
* 0 if image filename is empty or if destination path
* matches image path (i.e. both are the same file).
@@ -1759,12 +1773,12 @@ bool BLI_path_name_at_index(const char *path, const int index, int *r_offset, in
* - if an image is "below" current .blend file directory:
* rebuild the same dir structure in dest_dir
*
- * Example:
+ * Example:
* src : //textures/foo/bar.png
* dest: [dest_dir]/textures/foo/bar.png.
*
* - if an image is not "below" current .blend file directory,
- * disregard it's path and copy it into the destination
+ * disregard it's path and copy it into the destination
* directory.
*
* Example:
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index 49630347032..1b3af142b33 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -23,7 +23,7 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- *
+ *
*/
/** \file blender/blenlib/intern/string.c
diff --git a/source/blender/blenlib/intern/string_utils.c b/source/blender/blenlib/intern/string_utils.c
index a693463a302..197169ab381 100644
--- a/source/blender/blenlib/intern/string_utils.c
+++ b/source/blender/blenlib/intern/string_utils.c
@@ -21,7 +21,7 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- *
+ *
*/
/** \file blender/blenlib/intern/string_utils.c
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index e6f5d9839ea..dd79f3f5e5e 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -70,29 +70,29 @@ static void *thread_tls_data;
static TaskScheduler *task_scheduler = NULL;
/* ********** basic thread control API ************
- *
+ *
* Many thread cases have an X amount of jobs, and only an Y amount of
* threads are useful (typically amount of cpus)
*
* This code can be used to start a maximum amount of 'thread slots', which
- * then can be filled in a loop with an idle timer.
+ * then can be filled in a loop with an idle timer.
*
* A sample loop can look like this (pseudo c);
*
* ListBase lb;
* int maxthreads = 2;
* int cont = 1;
- *
+ *
* BLI_threadpool_init(&lb, do_something_func, maxthreads);
- *
+ *
* while (cont) {
* if (BLI_available_threads(&lb) && !(escape loop event)) {
* // get new job (data pointer)
- * // tag job 'processed
+ * // tag job 'processed
* BLI_threadpool_insert(&lb, job);
* }
* else PIL_sleep_ms(50);
- *
+ *
* // find if a job is ready, this the do_something_func() should write in job somewhere
* cont = 0;
* for (go over all jobs)
@@ -103,13 +103,13 @@ static TaskScheduler *task_scheduler = NULL;
* }
* else cont = 1;
* }
- * // conditions to exit loop
+ * // conditions to exit loop
* if (if escape loop event) {
* if (BLI_available_threadslots(&lb) == maxthreads)
* break;
* }
* }
- *
+ *
* BLI_threadpool_end(&lb);
*
************************************************ */
diff --git a/source/blender/blenlib/intern/timecode.c b/source/blender/blenlib/intern/timecode.c
index 7856bad4d99..f59c493206f 100644
--- a/source/blender/blenlib/intern/timecode.c
+++ b/source/blender/blenlib/intern/timecode.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/blenloader/BLO_runtime.h b/source/blender/blenloader/BLO_runtime.h
index c119ea95f66..2c3947c9dda 100644
--- a/source/blender/blenloader/BLO_runtime.h
+++ b/source/blender/blenloader/BLO_runtime.h
@@ -23,7 +23,7 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- *
+ *
*/
#ifndef __BLO_RUNTIME_H__
diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c
index 0963fdd78e0..4fb5d0e1286 100644
--- a/source/blender/blenloader/intern/blend_validate.c
+++ b/source/blender/blenloader/intern/blend_validate.c
@@ -81,7 +81,7 @@ bool BLO_main_validate_libraries(struct Main *bmain, struct ReportList *reports)
continue;
}
- BKE_library_filepath_set(curlib, curlib->name);
+ BKE_library_filepath_set(bmain, curlib, curlib->name);
BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath, reports);
if (bh == NULL) {
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index bc4b8daf0d3..a9f93dff9e6 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -140,6 +140,7 @@
#include "BKE_material.h"
#include "BKE_main.h" // for Main
#include "BKE_mesh.h" // for ME_ defines (patching)
+#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_multires.h"
#include "BKE_node.h" // for tree type defines
@@ -2716,7 +2717,7 @@ static void lib_link_nladata(FileData *fd, ID *id, ListBase *list)
}
/* This handles Animato NLA-Strips linking
- * NOTE: this assumes that link_list has already been called on the list
+ * NOTE: this assumes that link_list has already been called on the list
*/
static void direct_link_nladata_strips(FileData *fd, ListBase *list)
{
@@ -2819,6 +2820,7 @@ static void direct_link_animdata(FileData *fd, AnimData *adt)
/* link drivers */
link_list(fd, &adt->drivers);
direct_link_fcurves(fd, &adt->drivers);
+ adt->driver_array = NULL;
/* link overrides */
// TODO...
@@ -2964,6 +2966,10 @@ static void direct_link_motionpath(FileData *fd, bMotionPath *mpath)
/* relink points cache */
mpath->points = newdataadr(fd, mpath->points);
+
+ mpath->points_vbo = NULL;
+ mpath->batch_line = NULL;
+ mpath->batch_points = NULL;
}
/* ************ READ NODE TREE *************** */
@@ -5523,6 +5529,7 @@ static void direct_link_object(FileData *fd, Object *ob)
ob->bb = NULL;
ob->derivedDeform = NULL;
ob->derivedFinal = NULL;
+ BKE_object_runtime_reset(ob);
BLI_listbase_clear(&ob->gpulamp);
BLI_listbase_clear(&ob->drawdata);
link_list(fd, &ob->pc_ids);
@@ -6390,19 +6397,24 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd)
/* *********** READ AREA **************** */
-static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
+static void direct_link_panel_list(FileData *fd, ListBase *lb)
{
- Panel *pa;
- uiList *ui_list;
-
- link_list(fd, &ar->panels);
+ link_list(fd, lb);
- for (pa = ar->panels.first; pa; pa = pa->next) {
+ for (Panel *pa = lb->first; pa; pa = pa->next) {
pa->paneltab = newdataadr(fd, pa->paneltab);
pa->runtime_flag = 0;
pa->activedata = NULL;
pa->type = NULL;
+ direct_link_panel_list(fd, &pa->children);
}
+}
+
+static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
+{
+ uiList *ui_list;
+
+ direct_link_panel_list(fd, &ar->panels);
link_list(fd, &ar->panels_category_active);
@@ -8266,7 +8278,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short
}
else {
DEBUG_PRINTF("... in %s (%s): ", main->curlib ? main->curlib->id.name : "<NULL>", main->curlib ? main->curlib->name : "<NULL>");
- if ((id = BKE_libblock_find_name_ex(main, GS(idname), idname + 2))) {
+ if ((id = BKE_libblock_find_name(main, GS(idname), idname + 2))) {
DEBUG_PRINTF("FOUND!\n");
/* Even though we found our linked ID, there is no guarantee its address is still the same... */
if (id != bhead->old) {
@@ -8477,11 +8489,11 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead)
if (bfd->filename[0] == 0) {
if (fd->fileversion < 265 || (fd->fileversion == 265 && fg->subversion < 1))
if ((G.fileflags & G_FILE_RECOVER)==0)
- BLI_strncpy(bfd->filename, bfd->main->name, sizeof(bfd->filename));
+ BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename));
/* early 2.50 version patch - filename not in FileGlobal struct at all */
if (fd->fileversion <= 250)
- BLI_strncpy(bfd->filename, bfd->main->name, sizeof(bfd->filename));
+ BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename));
}
if (G.fileflags & G_FILE_RECOVER)
@@ -10052,6 +10064,7 @@ static void add_collections_to_scene(
/* Assign the collection. */
ob->dup_group = collection;
+ id_us_plus(&collection->id);
ob->transflag |= OB_DUPLICOLLECTION;
copy_v3_v3(ob->loc, scene->cursor.location);
}
@@ -10307,7 +10320,7 @@ static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepa
blo_split_main((*fd)->mainlist, mainvar);
/* which one do we need? */
- mainl = blo_find_main(*fd, filepath, G.main->name);
+ mainl = blo_find_main(*fd, filepath, BKE_main_blendfile_path(mainvar));
/* needed for do_version */
mainl->versionfile = (*fd)->fileversion;
@@ -10382,7 +10395,7 @@ static void library_link_end(Main *mainl, FileData **fd, const short flag, Main
BLI_strncpy(curlib->name, curlib->filepath, sizeof(curlib->name));
/* uses current .blend file as reference */
- BLI_path_rel(curlib->name, G.main->name);
+ BLI_path_rel(curlib->name, BKE_main_blendfile_path_from_global());
}
blo_join_main((*fd)->mainlist);
@@ -10412,7 +10425,7 @@ static void library_link_end(Main *mainl, FileData **fd, const short flag, Main
BKE_main_id_tag_all(mainvar, LIB_TAG_NEW, false);
lib_verify_nodetree(mainvar, false);
- fix_relpaths_library(G.main->name, mainvar); /* make all relative paths, relative to the open blend file */
+ fix_relpaths_library(BKE_main_blendfile_path(mainvar), mainvar); /* make all relative paths, relative to the open blend file */
/* Give a base to loose objects and collections.
* Only directly linked objects & collections are instantiated by `BLO_library_link_named_part_ex()` & co,
@@ -10533,7 +10546,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
while (fd == NULL) {
char newlib_path[FILE_MAX] = {0};
printf("Missing library...'\n");
- printf(" current file: %s\n", G.main->name);
+ printf(" current file: %s\n", BKE_main_blendfile_path_from_global());
printf(" absolute lib: %s\n", mainptr->curlib->filepath);
printf(" relative lib: %s\n", mainptr->curlib->name);
printf(" enter a new path:\n");
@@ -10541,7 +10554,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
if (scanf("%1023s", newlib_path) > 0) { /* Warning, keep length in sync with FILE_MAX! */
BLI_strncpy(mainptr->curlib->name, newlib_path, sizeof(mainptr->curlib->name));
BLI_strncpy(mainptr->curlib->filepath, newlib_path, sizeof(mainptr->curlib->filepath));
- BLI_cleanup_path(G.main->name, mainptr->curlib->filepath);
+ BLI_cleanup_path(BKE_main_blendfile_path_from_global(), mainptr->curlib->filepath);
fd = blo_openblenderfile(mainptr->curlib->filepath, basefd->reports);
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index 299c66f2bbb..7618c023882 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -169,14 +169,14 @@ void blo_do_version_old_trackto_to_constraints(struct Object *ob);
void blo_do_versions_view3d_split_250(struct View3D *v3d, struct ListBase *regions);
void blo_do_versions_key_uidgen(struct Key *key);
-void blo_do_versions_pre250(struct FileData *fd, struct Library *lib, struct Main *main);
-void blo_do_versions_250(struct FileData *fd, struct Library *lib, struct Main *main);
-void blo_do_versions_260(struct FileData *fd, struct Library *lib, struct Main *main);
-void blo_do_versions_270(struct FileData *fd, struct Library *lib, struct Main *main);
-void blo_do_versions_280(struct FileData *fd, struct Library *lib, struct Main *main);
-
-void do_versions_after_linking_270(struct Main *main);
-void do_versions_after_linking_280(struct Main *main);
+void blo_do_versions_pre250(struct FileData *fd, struct Library *lib, struct Main *bmain);
+void blo_do_versions_250(struct FileData *fd, struct Library *lib, struct Main *bmain);
+void blo_do_versions_260(struct FileData *fd, struct Library *lib, struct Main *bmain);
+void blo_do_versions_270(struct FileData *fd, struct Library *lib, struct Main *bmain);
+void blo_do_versions_280(struct FileData *fd, struct Library *lib, struct Main *bmain);
+
+void do_versions_after_linking_270(struct Main *bmain);
+void do_versions_after_linking_280(struct Main *bmain);
#endif
diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c
index 7133dee0e82..e1ae267ea11 100644
--- a/source/blender/blenloader/intern/undofile.c
+++ b/source/blender/blenloader/intern/undofile.c
@@ -130,7 +130,7 @@ void memfile_chunk_add(
struct Main *BLO_memfile_main_get(struct MemFile *memfile, struct Main *oldmain, struct Scene **r_scene)
{
struct Main *bmain_undo = NULL;
- BlendFileData *bfd = BLO_read_from_memfile(oldmain, oldmain->name, memfile, NULL, BLO_READ_SKIP_NONE);
+ BlendFileData *bfd = BLO_read_from_memfile(oldmain, BKE_main_blendfile_path(oldmain), memfile, NULL, BLO_READ_SKIP_NONE);
if (bfd) {
bmain_undo = bfd->main;
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 3f85011db0b..d51289bee43 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -641,11 +641,11 @@ static void do_versions_socket_default_value_259(bNodeSocket *sock)
}
}
-void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
+void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
{
/* WATCH IT!!!: pointers from libdata have not been converted */
- if (main->versionfile < 250) {
+ if (bmain->versionfile < 250) {
bScreen *screen;
Scene *scene;
Base *base;
@@ -663,22 +663,22 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
bSound *sound;
Sequence *seq;
- for (sound = main->sound.first; sound; sound = sound->id.next) {
+ for (sound = bmain->sound.first; sound; sound = sound->id.next) {
if (sound->newpackedfile) {
sound->packedfile = sound->newpackedfile;
sound->newpackedfile = NULL;
}
}
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
if (scene->ed && scene->ed->seqbasep) {
SEQ_BEGIN (scene->ed, seq)
{
if (seq->type == SEQ_TYPE_SOUND_HD) {
char str[FILE_MAX];
BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name);
- BLI_path_abs(str, main->name);
- seq->sound = BKE_sound_new_file(main, str);
+ BLI_path_abs(str, BKE_main_blendfile_path(bmain));
+ seq->sound = BKE_sound_new_file(bmain, str);
}
#define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19)
#define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)
@@ -695,21 +695,21 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- for (screen = main->screen.first; screen; screen = screen->id.next) {
+ for (screen = bmain->screen.first; screen; screen = screen->id.next) {
do_versions_windowmanager_2_50(screen);
- do_versions_gpencil_2_50(main, screen);
+ do_versions_gpencil_2_50(bmain, screen);
}
/* shader, composite and texture node trees have id.name empty, put something in
* to have them show in RNA viewer and accessible otherwise.
*/
- for (ma = main->mat.first; ma; ma = ma->id.next) {
+ for (ma = bmain->mat.first; ma; ma = ma->id.next) {
if (ma->nodetree && ma->nodetree->id.name[0] == '\0')
strcpy(ma->nodetree->id.name, "NTShader Nodetree");
}
/* and composite trees */
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->nodetree && sce->nodetree->id.name[0] == '\0')
strcpy(sce->nodetree->id.name, "NTCompositing Nodetree");
@@ -729,7 +729,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
/* and texture trees */
- for (tx = main->tex.first; tx; tx = tx->id.next) {
+ for (tx = bmain->tex.first; tx; tx = tx->id.next) {
bNode *node;
if (tx->nodetree) {
@@ -744,12 +744,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
/* copy standard draw flag to meshes(used to be global, is not available here) */
- for (me = main->mesh.first; me; me = me->id.next) {
+ for (me = bmain->mesh.first; me; me = me->id.next) {
me->drawflag = ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES;
}
/* particle draw and render types */
- for (part = main->particle.first; part; part = part->id.next) {
+ for (part = bmain->particle.first; part; part = part->id.next) {
if (part->draw_as) {
if (part->draw_as == PART_DRAW_DOT) {
part->ren_as = PART_DRAW_HALO;
@@ -768,7 +768,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
/* set old pointcaches to have disk cache flag */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
//BKE_ptcache_ids_from_object(&pidlist, ob);
@@ -779,7 +779,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
/* type was a mixed flag & enum. move the 2d flag elsewhere */
- for (cu = main->curve.first; cu; cu = cu->id.next) {
+ for (cu = bmain->curve.first; cu; cu = cu->id.next) {
Nurb *nu;
for (nu = cu->nurb.first; nu; nu = nu->next) {
@@ -789,7 +789,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 1)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) {
Object *ob;
Tex *tex;
Scene *sce;
@@ -797,7 +797,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
//PTCacheID *pid;
//ListBase pidlist;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
//BKE_ptcache_ids_from_object(&pidlist, ob);
//for (pid = pidlist.first; pid; pid = pid->next) {
@@ -831,12 +831,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
/* texture filter */
- for (tex = main->tex.first; tex; tex = tex->id.next) {
+ for (tex = bmain->tex.first; tex; tex = tex->id.next) {
if (tex->afmax == 0)
tex->afmax = 8;
}
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
ts = sce->toolsettings;
if (!ts->uv_selectmode || ts->vgroup_weight == 0.0f) {
ts->selectmode = SCE_SELECT_VERTEX;
@@ -854,26 +854,26 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 2)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 2)) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->flag & 8192) // OB_POSEMODE = 8192
ob->mode |= OB_MODE_POSE;
}
}
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 4)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 4)) {
Scene *sce;
Object *ob;
ParticleSettings *part;
bool do_gravity = false;
- for (sce = main->scene.first; sce; sce = sce->id.next)
+ for (sce = bmain->scene.first; sce; sce = sce->id.next)
if (sce->unit.scale_length == 0.0f)
sce->unit.scale_length = 1.0f;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
/* fluid-sim stuff */
FluidsimModifierData *fluidmd = (FluidsimModifierData *) modifiers_findByType(ob, eModifierType_Fluidsim);
if (fluidmd)
@@ -883,7 +883,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
ob->rotmode = ROT_MODE_EUL;
}
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->audio.main == 0.0f)
sce->audio.main = 1.0f;
@@ -895,7 +895,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
/* Add default gravity to scenes */
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if ((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 &&
is_zero_v3(sce->physics_settings.gravity))
{
@@ -908,11 +908,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
/* Assign proper global gravity weights for dynamics (only z-coordinate is taken into account) */
if (do_gravity) {
- for (part = main->particle.first; part; part = part->id.next)
+ for (part = bmain->particle.first; part; part = part->id.next)
part->effector_weights->global_gravity = part->acc[2]/-9.81f;
}
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
if (do_gravity) {
@@ -941,11 +941,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 6)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 6)) {
Object *ob;
/* New variables for axis-angle rotations and/or quaternion rotations were added, and need proper initialization */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
/* new variables for all objects */
ob->quat[0] = 1.0f;
ob->rotAxis[1] = 1.0f;
@@ -962,7 +962,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 7)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 7)) {
Mesh *me;
Nurb *nu;
Lattice *lt;
@@ -974,7 +974,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
/* shape keys are no longer applied to the mesh itself, but rather
* to the derivedmesh/displist, so here we ensure that the basis
* shape key is always set in the mesh coordinates. */
- for (me = main->mesh.first; me; me = me->id.next) {
+ for (me = bmain->mesh.first; me; me = me->id.next) {
if ((key = blo_do_versions_newlibadr(fd, lib, me->key)) && key->refkey) {
data = key->refkey->data;
tot = MIN2(me->totvert, key->refkey->totelem);
@@ -984,7 +984,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- for (lt = main->latt.first; lt; lt = lt->id.next) {
+ for (lt = bmain->latt.first; lt; lt = lt->id.next) {
if ((key = blo_do_versions_newlibadr(fd, lib, lt->key)) && key->refkey) {
data = key->refkey->data;
tot = MIN2(lt->pntsu*lt->pntsv*lt->pntsw, key->refkey->totelem);
@@ -994,7 +994,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- for (cu = main->curve.first; cu; cu = cu->id.next) {
+ for (cu = bmain->curve.first; cu; cu = cu->id.next) {
if ((key = blo_do_versions_newlibadr(fd, lib, cu->key)) && key->refkey) {
data = key->refkey->data;
@@ -1022,9 +1022,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 8)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
{
- Scene *sce = main->scene.first;
+ Scene *sce = bmain->scene.first;
while (sce) {
if (sce->r.frame_step == 0)
sce->r.frame_step = 1;
@@ -1039,7 +1039,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
{
/* ensure all nodes have unique names */
- bNodeTree *ntree = main->nodetree.first;
+ bNodeTree *ntree = bmain->nodetree.first;
while (ntree) {
bNode *node = ntree->nodes.first;
@@ -1053,7 +1053,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
{
- Object *ob = main->object.first;
+ Object *ob = bmain->object.first;
while (ob) {
/* shaded mode disabled for now */
if (ob->dt == OB_MATERIAL)
@@ -1067,7 +1067,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
ScrArea *sa;
SpaceLink *sl;
- for (screen = main->screen.first; screen; screen = screen->id.next) {
+ for (screen = bmain->screen.first; screen; screen = screen->id.next) {
for (sa = screen->areabase.first; sa; sa = sa->next) {
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
@@ -1081,10 +1081,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
/* only convert old 2.50 files with color management */
- if (main->versionfile == 250) {
- Scene *sce = main->scene.first;
- Material *ma = main->mat.first;
- Tex *tex = main->tex.first;
+ if (bmain->versionfile == 250) {
+ Scene *sce = bmain->scene.first;
+ Material *ma = bmain->mat.first;
+ Tex *tex = bmain->tex.first;
int i, convert = 0;
/* convert to new color management system:
@@ -1120,20 +1120,20 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 9)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 9)) {
Scene *sce;
Mesh *me;
Object *ob;
- for (sce = main->scene.first; sce; sce = sce->id.next)
+ for (sce = bmain->scene.first; sce; sce = sce->id.next)
if (!sce->toolsettings->particle.selectmode)
sce->toolsettings->particle.selectmode = SCE_SELECT_PATH;
- if (main->versionfile == 250 && main->subversionfile > 1) {
- for (me = main->mesh.first; me; me = me->id.next)
+ if (bmain->versionfile == 250 && bmain->subversionfile > 1) {
+ for (me = bmain->mesh.first; me; me = me->id.next)
multires_load_old_250(me);
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
MultiresModifierData *mmd = (MultiresModifierData *) modifiers_findByType(ob, eModifierType_Multires);
if (mmd) {
@@ -1146,11 +1146,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 10)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 10)) {
Object *ob;
/* properly initialize hair clothsim data on old files */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Cloth) {
@@ -1163,14 +1163,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
/* fix bad area setup in subversion 10 */
- if (main->versionfile == 250 && main->subversionfile == 10) {
+ if (bmain->versionfile == 250 && bmain->subversionfile == 10) {
/* fix for new view type in sequencer */
bScreen *screen;
ScrArea *sa;
SpaceLink *sl;
/* remove all preview window in wrong spaces */
- for (screen = main->screen.first; screen; screen = screen->id.next) {
+ for (screen = bmain->screen.first; screen; screen = screen->id.next) {
for (sa = screen->areabase.first; sa; sa = sa->next) {
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype != SPACE_SEQ) {
@@ -1200,14 +1200,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 11)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 11)) {
{
/* fix for new view type in sequencer */
bScreen *screen;
ScrArea *sa;
SpaceLink *sl;
- for (screen = main->screen.first; screen; screen = screen->id.next) {
+ for (screen = bmain->screen.first; screen; screen = screen->id.next) {
for (sa = screen->areabase.first; sa; sa = sa->next) {
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_SEQ) {
@@ -1243,12 +1243,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 12)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 12)) {
Object *ob;
Brush *brush;
/* anim viz changes */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
/* initialize object defaults */
animviz_settings_init(&ob->avs);
@@ -1323,19 +1323,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
/* brush texture changes */
- for (brush = main->brush.first; brush; brush = brush->id.next) {
+ for (brush = bmain->brush.first; brush; brush = brush->id.next) {
BKE_texture_mtex_default(&brush->mtex);
BKE_texture_mtex_default(&brush->mask_mtex);
}
}
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 13)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 13)) {
/* NOTE: if you do more conversion, be sure to do it outside of this and
* increase subversion again, otherwise it will not be correct */
Object *ob;
/* convert degrees to radians for internal use */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
bPoseChannel *pchan;
do_version_constraints_radians_degrees_250(&ob->constraints);
@@ -1355,13 +1355,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 14)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 14)) {
/* fix for bad View2D extents for Animation Editors */
bScreen *screen;
ScrArea *sa;
SpaceLink *sl;
- for (screen = main->screen.first; screen; screen = screen->id.next) {
+ for (screen = bmain->screen.first; screen; screen = screen->id.next) {
for (sa = screen->areabase.first; sa; sa = sa->next) {
for (sl = sa->spacedata.first; sl; sl = sl->next) {
ListBase *regionbase;
@@ -1385,12 +1385,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 17)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 17)) {
Scene *sce;
Sequence *seq;
/* initialize to sane default so toggling on border shows something */
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->r.border.xmin == 0.0f && sce->r.border.ymin == 0.0f &&
sce->r.border.xmax == 0.0f && sce->r.border.ymax == 0.0f)
{
@@ -1411,7 +1411,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
/* particle brush strength factor was changed from int to float */
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
ParticleEditSettings *pset = &sce->toolsettings->particle;
int a;
@@ -1425,7 +1425,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
ScrArea *sa;
SpaceLink *sl;
- for (screen = main->screen.first; screen; screen = screen->id.next) {
+ for (screen = bmain->screen.first; screen; screen = screen->id.next) {
for (sa = screen->areabase.first; sa; sa = sa->next) {
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_SEQ) {
@@ -1454,14 +1454,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
} /* sequencer changes */
}
- if (main->versionfile <= 251) { /* 2.5.1 had no subversions */
+ if (bmain->versionfile <= 251) { /* 2.5.1 had no subversions */
bScreen *sc;
/* Blender 2.5.2 - subversion 0 introduced a new setting: V3D_RENDER_OVERRIDE.
* This bit was used in the past for V3D_TRANSFORM_SNAP, which is now deprecated.
* Here we clear it for old files so they don't come in with V3D_RENDER_OVERRIDE set,
* which would cause cameras, lamps, etc to become invisible */
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -1475,19 +1475,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 1)) {
+ if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 1)) {
Brush *brush;
Object *ob;
Scene *scene;
bNodeTree *ntree;
- for (brush = main->brush.first; brush; brush = brush->id.next) {
+ for (brush = bmain->brush.first; brush; brush = brush->id.next) {
if (brush->curve)
brush->curve->preset = CURVE_PRESET_SMOOTH;
}
/* properly initialize active flag for fluidsim modifiers */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Fluidsim) {
@@ -1499,7 +1499,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
/* adjustment to color balance node values */
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
if (scene->nodetree) {
bNode *node = scene->nodetree->nodes.first;
@@ -1515,7 +1515,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
/* check inside node groups too */
- for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) {
+ for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) {
bNode *node = ntree->nodes.first;
while (node) {
@@ -1532,18 +1532,18 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
/* old-track -> constraints (this time we're really doing it!) */
- if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 2)) {
+ if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 2)) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next)
+ for (ob = bmain->object.first; ob; ob = ob->id.next)
blo_do_version_old_trackto_to_constraints(ob);
}
- if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) {
+ if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
bScreen *sc;
/* Image editor scopes */
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
@@ -1559,14 +1559,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 253) {
+ if (bmain->versionfile < 253) {
Object *ob;
Scene *scene;
bScreen *sc;
Tex *tex;
Brush *brush;
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -1600,10 +1600,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- do_version_mdef_250(main);
+ do_version_mdef_250(bmain);
/* parent type to modifier */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->parent) {
Object *parent = (Object *) blo_do_versions_newlibadr(fd, lib, ob->parent);
if (parent) { /* parent may not be in group */
@@ -1638,7 +1638,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
/* initialize scene active layer */
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
int i;
for (i = 0; i < 20; i++) {
if (scene->lay & (1<<i)) {
@@ -1648,7 +1648,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- for (tex = main->tex.first; tex; tex = tex->id.next) {
+ for (tex = bmain->tex.first; tex; tex = tex->id.next) {
/* if youre picky, this isn't correct until we do a version bump
* since you could set saturation to be 0.0*/
if (tex->saturation == 0.0f)
@@ -1657,12 +1657,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
{
Curve *cu;
- for (cu = main->curve.first; cu; cu = cu->id.next) {
+ for (cu = bmain->curve.first; cu; cu = cu->id.next) {
cu->smallcaps_scale = 0.75f;
}
}
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
if (scene) {
Sequence *seq;
SEQ_BEGIN (scene->ed, seq)
@@ -1677,7 +1677,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
/* GSOC 2010 Sculpt - New settings for Brush */
- for (brush = main->brush.first; brush; brush = brush->id.next) {
+ for (brush = bmain->brush.first; brush; brush = brush->id.next) {
/* Sanity Check */
/* infinite number of dabs */
@@ -1721,7 +1721,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
brush->rate = 0.1f;
/* New Settings */
- if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) {
+ if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
brush->flag |= BRUSH_SPACE_ATTEN; // explicitly enable adaptive space
/* spacing was originally in pixels, convert it to percentage for new version
@@ -1751,9 +1751,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
/* GSOC Sculpt 2010 - Sanity check on Sculpt/Paint settings */
- if (main->versionfile < 253) {
+ if (bmain->versionfile < 253) {
Scene *sce;
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->toolsettings->sculpt_paint_unified_alpha == 0)
sce->toolsettings->sculpt_paint_unified_alpha = 0.5f;
@@ -1765,10 +1765,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 253 || (main->versionfile == 253 && main->subversionfile < 1)) {
+ if (bmain->versionfile < 253 || (bmain->versionfile == 253 && bmain->subversionfile < 1)) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
@@ -1788,7 +1788,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
/* for now just add it to all flow objects in the scene */
{
Object *ob2;
- for (ob2 = main->object.first; ob2; ob2 = ob2->id.next) {
+ for (ob2 = bmain->object.first; ob2; ob2 = ob2->id.next) {
ModifierData *md2;
for (md2 = ob2->modifiers.first; md2; md2 = md2->next) {
if (md2->type == eModifierType_Smoke) {
@@ -1811,17 +1811,17 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 1)) {
+ if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 1)) {
Brush *br;
ParticleSettings *part;
bScreen *sc;
- for (br = main->brush.first; br; br = br->id.next) {
+ for (br = bmain->brush.first; br; br = br->id.next) {
if (br->ob_mode == 0)
br->ob_mode = OB_MODE_ALL_PAINT;
}
- for (part = main->particle.first; part; part = part->id.next) {
+ for (part = bmain->particle.first; part; part = part->id.next) {
if (part->boids)
part->boids->pitch = 1.0f;
@@ -1829,7 +1829,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
part->kink_amp_clump = 1.f; /* keep old files looking similar */
}
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -1856,11 +1856,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 3)) {
+ if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 3)) {
Object *ob;
/* ocean res is now squared, reset old ones - will be massive */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Ocean) {
@@ -1872,13 +1872,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 256) {
+ if (bmain->versionfile < 256) {
bScreen *sc;
ScrArea *sa;
Key *key;
/* Fix for sample line scope initializing with no height */
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
sa = sc->areabase.first;
while (sa) {
SpaceLink *sl;
@@ -1897,7 +1897,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
* 2.4x would never reveal this to users as a dummy value always ended up getting used
* instead
*/
- for (key = main->key.first; key; key = key->id.next) {
+ for (key = bmain->key.first; key; key = key->id.next) {
KeyBlock *kb;
for (kb = key->block.first; kb; kb = kb->next) {
@@ -1907,19 +1907,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 1)) {
+ if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 1)) {
/* fix for bones that didn't have arm_roll before */
bArmature *arm;
Bone *bone;
Object *ob;
- for (arm = main->armature.first; arm; arm = arm->id.next)
+ for (arm = bmain->armature.first; arm; arm = arm->id.next)
for (bone = arm->bonebase.first; bone; bone = bone->next)
do_version_bone_roll_256(bone);
/* fix for objects which have zero dquat's
* since this is multiplied with the quat rather than added */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (is_zero_v4(ob->dquat)) {
unit_qt(ob->dquat);
}
@@ -1929,7 +1929,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) {
+ if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) {
bNodeTree *ntree;
bNode *node;
bNodeSocket *sock, *gsock;
@@ -1938,7 +1938,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
/* node sockets are not exposed automatically any more,
* this mimics the old behavior by adding all unlinked sockets to groups.
*/
- for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) {
+ for (ntree=bmain->nodetree.first; ntree; ntree=ntree->id.next) {
/* this adds copies and links from all unlinked internal sockets to group inputs/outputs. */
/* first make sure the own_index for new sockets is valid */
@@ -2007,14 +2007,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 3)) {
+ if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 3)) {
bScreen *sc;
Brush *brush;
Object *ob;
ParticleSettings *part;
/* redraws flag in SpaceTime has been moved to Screen level */
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
if (sc->redraws_flag == 0) {
/* just initialize to default? */
/* XXX: we could also have iterated through areas, and taken them from the first timeline available... */
@@ -2022,13 +2022,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- for (brush = main->brush.first; brush; brush = brush->id.next) {
+ for (brush = bmain->brush.first; brush; brush = brush->id.next) {
if (brush->height == 0)
brush->height = 0.4f;
}
/* replace 'rim material' option for in offset*/
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Solidify) {
@@ -2042,24 +2042,24 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
/* particle draw color from material */
- for (part = main->particle.first; part; part = part->id.next) {
+ for (part = bmain->particle.first; part; part = part->id.next) {
if (part->draw & PART_DRAW_MAT_COL)
part->draw_col = PART_DRAW_COL_MAT;
}
}
- if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 6)) {
+ if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 6)) {
Mesh *me;
- for (me = main->mesh.first; me; me = me->id.next)
+ for (me = bmain->mesh.first; me; me = me->id.next)
BKE_mesh_calc_normals_tessface(me->mvert, me->totvert, me->mface, me->totface, NULL);
}
- if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) {
+ if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) {
/* update blur area sizes from 0..1 range to 0..100 percentage */
Scene *scene;
bNode *node;
- for (scene = main->scene.first; scene; scene = scene->id.next)
+ for (scene = bmain->scene.first; scene; scene = scene->id.next)
if (scene->nodetree)
for (node = scene->nodetree->nodes.first; node; node = node->next)
if (node->type == CMP_NODE_BLUR) {
@@ -2069,13 +2069,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 258 || (main->versionfile == 258 && main->subversionfile < 1)) {
+ if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 1)) {
/* screen view2d settings were not properly initialized [#27164]
* v2d->scroll caused the bug but best reset other values too which are in old blend files only.
* need to make less ugly - possibly an iterator? */
bScreen *screen;
- for (screen = main->screen.first; screen; screen = screen->id.next) {
+ for (screen = bmain->screen.first; screen; screen = screen->id.next) {
ScrArea *sa;
/* add regions */
for (sa = screen->areabase.first; sa; sa = sa->next) {
@@ -2106,19 +2106,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
{
ParticleSettings *part;
- for (part = main->particle.first; part; part = part->id.next) {
+ for (part = bmain->particle.first; part; part = part->id.next) {
/* Initialize particle billboard scale */
part->bb_size[0] = part->bb_size[1] = 1.0f;
}
}
}
- if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 1)) {
+ if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) {
{
Scene *scene;
Sequence *seq;
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
scene->r.ffcodecdata.audio_channels = 2;
scene->audio.volume = 1.0f;
SEQ_BEGIN (scene->ed, seq)
@@ -2131,7 +2131,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
{
bScreen *screen;
- for (screen = main->screen.first; screen; screen = screen->id.next) {
+ for (screen = bmain->screen.first; screen; screen = screen->id.next) {
ScrArea *sa;
/* add regions */
@@ -2172,7 +2172,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
bAction *act;
FCurve *fcu;
- for (act = main->action.first; act; act = act->id.next) {
+ for (act = bmain->action.first; act; act = act->id.next) {
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
BezTriple *bezt;
unsigned int i = 0;
@@ -2197,10 +2197,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 2)) {
+ if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 2)) {
{
/* Convert default socket values from bNodeStack */
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE(bmain, ntree, id) {
bNode *node;
bNodeSocket *sock;
@@ -2227,17 +2227,17 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
* associate them with specific node types for polling.
*/
bNodeTree *ntree;
- /* all node trees in main->nodetree are considered groups */
- for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
+ /* all node trees in bmain->nodetree are considered groups */
+ for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next)
ntree->nodetype = NODE_GROUP;
}
}
- if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 4)) {
+ if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 4)) {
{
/* Adaptive time step for particle systems */
ParticleSettings *part;
- for (part = main->particle.first; part; part = part->id.next) {
+ for (part = bmain->particle.first; part; part = part->id.next) {
part->courant_target = 0.2f;
part->time_flag &= ~PART_TIME_AUTOSF;
}
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 8e0795f7e34..2cded68f7ec 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -608,15 +608,15 @@ static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_gro
}
}
-void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
+void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
- if (main->versionfile < 260) {
+ if (bmain->versionfile < 260) {
{
/* set default alpha value of Image outputs in image and render layer nodes to 0 */
Scene *sce;
bNodeTree *ntree;
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
/* there are files with invalid audio_channels value, the real cause
* is unknown, but we fix it here anyway to avoid crashes */
if (sce->r.ffcodecdata.audio_channels == 0)
@@ -626,7 +626,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
do_versions_nodetree_image_default_alpha_output(sce->nodetree);
}
- for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next)
do_versions_nodetree_image_default_alpha_output(ntree);
}
@@ -634,7 +634,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
/* support old particle dupliobject rotation settings */
ParticleSettings *part;
- for (part = main->particle.first; part; part = part->id.next) {
+ for (part = bmain->particle.first; part; part = part->id.next) {
if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
part->draw |= PART_DRAW_ROTATE_OB;
@@ -645,16 +645,16 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 1)) {
+ if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 1)) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ob->collision_boundtype = ob->boundtype;
}
{
Camera *cam;
- for (cam = main->camera.first; cam; cam = cam->id.next) {
+ for (cam = bmain->camera.first; cam; cam = cam->id.next) {
if (cam->sensor_x < 0.01f)
cam->sensor_x = DEFAULT_SENSOR_WIDTH;
@@ -664,8 +664,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 2)) {
- FOREACH_NODETREE(main, ntree, id) {
+ if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 2)) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -682,24 +682,24 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
} FOREACH_NODETREE_END
}
- if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 4)) {
+ if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 4)) {
{
/* Convert node angles to radians! */
Scene *sce;
Material *mat;
bNodeTree *ntree;
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->nodetree)
do_versions_nodetree_convert_angle(sce->nodetree);
}
- for (mat = main->mat.first; mat; mat = mat->id.next) {
+ for (mat = bmain->mat.first; mat; mat = mat->id.next) {
if (mat->nodetree)
do_versions_nodetree_convert_angle(mat->nodetree);
}
- for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next)
do_versions_nodetree_convert_angle(ntree);
}
@@ -708,7 +708,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
bScreen *sc;
MovieClip *clip;
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -732,7 +732,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
MovieTrackingTrack *track;
if (clip->aspx < 1.0f) {
@@ -764,16 +764,16 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 6)) {
+ if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 6)) {
Scene *sce;
MovieClip *clip;
bScreen *sc;
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
do_versions_image_settings_2_60(sce);
}
- for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
MovieTrackingSettings *settings = &clip->tracking.settings;
if (settings->default_pattern_size == 0.0f) {
@@ -784,7 +784,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -799,7 +799,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
{
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
/* convert delta addition into delta scale */
int i;
for (i = 0; i < 3; i++) {
@@ -819,25 +819,25 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
/* sigh, this dscale vs dsize version patching was not done right, fix for fix,
* this intentionally checks an exact subversion, also note this was never in a release,
* at some point this could be removed. */
- else if (main->versionfile == 260 && main->subversionfile == 6) {
+ else if (bmain->versionfile == 260 && bmain->subversionfile == 6) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (is_zero_v3(ob->dscale)) {
copy_vn_fl(ob->dscale, 3, 1.0f);
}
}
}
- if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 8)) {
+ if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 8)) {
Brush *brush;
- for (brush = main->brush.first; brush; brush = brush->id.next) {
+ for (brush = bmain->brush.first; brush; brush = brush->id.next) {
if (brush->sculpt_tool == SCULPT_TOOL_ROTATE)
brush->alpha = 1.0f;
}
}
- if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 1)) {
+ if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 1)) {
{
/* update use flags for node sockets (was only temporary before) */
Scene *sce;
@@ -847,32 +847,32 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
World *world;
bNodeTree *ntree;
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->nodetree)
do_versions_nodetree_socket_use_flags_2_62(sce->nodetree);
}
- for (mat = main->mat.first; mat; mat = mat->id.next) {
+ for (mat = bmain->mat.first; mat; mat = mat->id.next) {
if (mat->nodetree)
do_versions_nodetree_socket_use_flags_2_62(mat->nodetree);
}
- for (tex = main->tex.first; tex; tex = tex->id.next) {
+ for (tex = bmain->tex.first; tex; tex = tex->id.next) {
if (tex->nodetree)
do_versions_nodetree_socket_use_flags_2_62(tex->nodetree);
}
- for (lamp = main->lamp.first; lamp; lamp = lamp->id.next) {
+ for (lamp = bmain->lamp.first; lamp; lamp = lamp->id.next) {
if (lamp->nodetree)
do_versions_nodetree_socket_use_flags_2_62(lamp->nodetree);
}
- for (world = main->world.first; world; world = world->id.next) {
+ for (world = bmain->world.first; world; world = world->id.next) {
if (world->nodetree)
do_versions_nodetree_socket_use_flags_2_62(world->nodetree);
}
- for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) {
+ for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) {
do_versions_nodetree_socket_use_flags_2_62(ntree);
}
}
@@ -880,7 +880,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
MovieClip *clip;
Object *ob;
- for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *tracking_object = tracking->objects.first;
@@ -900,7 +900,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
bConstraint *con;
for (con = ob->constraints.first; con; con = con->next) {
if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
@@ -914,12 +914,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 2)) {
+ if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 2)) {
{
/* convert deprecated sculpt_paint_unified_* fields to
* UnifiedPaintSettings */
Scene *scene;
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
ToolSettings *ts = scene->toolsettings;
UnifiedPaintSettings *ups = &ts->unified_paint_settings;
ups->size = ts->sculpt_paint_unified_size;
@@ -930,11 +930,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 3)) {
+ if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 3)) {
{
/* convert extended ascii to utf-8 for text editor */
Text *text;
- for (text = main->text.first; text; text = text->id.next) {
+ for (text = bmain->text.first; text; text = text->id.next) {
if (!(text->flags & TXT_ISEXT)) {
TextLine *tl;
@@ -952,7 +952,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
{
/* set new dynamic paint values */
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_DynamicPaint) {
@@ -972,9 +972,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 262) {
+ if (bmain->versionfile < 262) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
@@ -987,12 +987,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 263) {
+ if (bmain->versionfile < 263) {
/* set fluidsim rate. the version patch for this in 2.62 was wrong, so
* try to correct it, if rate is 0.0 that's likely not intentional */
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Fluidsim) {
@@ -1004,35 +1004,35 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 1)) {
+ if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 1)) {
/* update use flags for node sockets (was only temporary before) */
Scene *sce;
bNodeTree *ntree;
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->nodetree)
do_versions_nodetree_multi_file_output_format_2_62_1(sce, sce->nodetree);
}
/* XXX can't associate with scene for group nodes, image format will stay uninitialized */
- for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next)
do_versions_nodetree_multi_file_output_format_2_62_1(NULL, ntree);
}
/* only swap for pre-release bmesh merge which had MLoopCol red/blue swap */
- if (main->versionfile == 262 && main->subversionfile == 1) {
+ if (bmain->versionfile == 262 && bmain->subversionfile == 1) {
{
Mesh *me;
- for (me = main->mesh.first; me; me = me->id.next) {
+ for (me = bmain->mesh.first; me; me = me->id.next) {
do_versions_mesh_mloopcol_swap_2_62_1(me);
}
}
}
- if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 2)) {
+ if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 2)) {
/* Set new idname of keyingsets from their now "label-only" name. */
Scene *scene;
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
KeyingSet *ks;
for (ks = scene->keyingsets.first; ks; ks = ks->next) {
if (!ks->idname[0])
@@ -1041,11 +1041,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 3)) {
+ if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 3)) {
Object *ob;
ModifierData *md;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Lattice) {
LatticeModifierData *lmd = (LatticeModifierData *)md;
@@ -1055,11 +1055,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 4)) {
+ if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 4)) {
/* Read Viscosity presets from older files */
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Fluidsim) {
@@ -1079,27 +1079,27 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
- if (main->versionfile < 263) {
+ if (bmain->versionfile < 263) {
/* Default for old files is to save particle rotations to pointcache */
ParticleSettings *part;
- for (part = main->particle.first; part; part = part->id.next) {
+ for (part = bmain->particle.first; part; part = part->id.next) {
part->flag |= PART_ROTATIONS;
}
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 1)) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 1)) {
/* file output node paths are now stored in the file info struct instead socket name */
Scene *sce;
bNodeTree *ntree;
- for (sce = main->scene.first; sce; sce = sce->id.next)
+ for (sce = bmain->scene.first; sce; sce = sce->id.next)
if (sce->nodetree)
do_versions_nodetree_multi_file_output_path_2_63_1(sce->nodetree);
- for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next)
do_versions_nodetree_multi_file_output_path_2_63_1(ntree);
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 3)) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 3)) {
Scene *scene;
Brush *brush;
@@ -1107,7 +1107,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
* unified paint settings also have weight. Update unified
* paint settings and brushes with a default weight value. */
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
ToolSettings *ts = scene->toolsettings;
if (ts) {
ts->unified_paint_settings.weight = ts->vgroup_weight;
@@ -1115,15 +1115,15 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (brush = main->brush.first; brush; brush = brush->id.next) {
+ for (brush = bmain->brush.first; brush; brush = brush->id.next) {
brush->weight = 0.5;
}
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 2)) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 2)) {
bScreen *sc;
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -1155,18 +1155,18 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 4)) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 4)) {
Camera *cam;
Curve *cu;
- for (cam = main->camera.first; cam; cam = cam->id.next) {
+ for (cam = bmain->camera.first; cam; cam = cam->id.next) {
if (cam->flag & CAM_PANORAMA) {
cam->type = CAM_PANO;
cam->flag &= ~CAM_PANORAMA;
}
}
- for (cu = main->curve.first; cu; cu = cu->id.next) {
+ for (cu = bmain->curve.first; cu; cu = cu->id.next) {
if (cu->bevfac2 == 0.0f) {
cu->bevfac1 = 0.0f;
cu->bevfac2 = 1.0f;
@@ -1174,26 +1174,26 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 5)) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 5)) {
{
/* file output node paths are now stored in the file info struct instead socket name */
Scene *sce;
bNodeTree *ntree;
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->nodetree) {
do_versions_nodetree_file_output_layers_2_64_5(sce->nodetree);
do_versions_nodetree_image_layer_2_64_5(sce->nodetree);
}
}
- for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) {
+ for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) {
do_versions_nodetree_file_output_layers_2_64_5(ntree);
do_versions_nodetree_image_layer_2_64_5(ntree);
}
}
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 6)) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 6)) {
/* update use flags for node sockets (was only temporary before) */
Scene *sce;
Material *mat;
@@ -1202,34 +1202,34 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
World *world;
bNodeTree *ntree;
- for (sce = main->scene.first; sce; sce = sce->id.next)
+ for (sce = bmain->scene.first; sce; sce = sce->id.next)
if (sce->nodetree)
do_versions_nodetree_frame_2_64_6(sce->nodetree);
- for (mat = main->mat.first; mat; mat = mat->id.next)
+ for (mat = bmain->mat.first; mat; mat = mat->id.next)
if (mat->nodetree)
do_versions_nodetree_frame_2_64_6(mat->nodetree);
- for (tex = main->tex.first; tex; tex = tex->id.next)
+ for (tex = bmain->tex.first; tex; tex = tex->id.next)
if (tex->nodetree)
do_versions_nodetree_frame_2_64_6(tex->nodetree);
- for (lamp = main->lamp.first; lamp; lamp = lamp->id.next)
+ for (lamp = bmain->lamp.first; lamp; lamp = lamp->id.next)
if (lamp->nodetree)
do_versions_nodetree_frame_2_64_6(lamp->nodetree);
- for (world = main->world.first; world; world = world->id.next)
+ for (world = bmain->world.first; world; world = world->id.next)
if (world->nodetree)
do_versions_nodetree_frame_2_64_6(world->nodetree);
- for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next)
do_versions_nodetree_frame_2_64_6(ntree);
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 7)) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 7)) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Smoke) {
@@ -1244,8 +1244,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 9)) {
- FOREACH_NODETREE(main, ntree, id) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 9)) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -1262,11 +1262,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
} FOREACH_NODETREE_END
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 10)) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 10)) {
{
Scene *scene;
// composite redesign
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
if (scene->nodetree) {
if (scene->nodetree->chunksize == 0) {
scene->nodetree->chunksize = 256;
@@ -1274,7 +1274,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -1292,7 +1292,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
{
bScreen *sc;
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
@@ -1314,16 +1314,16 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
{
MovieClip *clip;
- for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
clip->start_frame = 1;
}
}
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 11)) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 11)) {
MovieClip *clip;
- for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
MovieTrackingTrack *track;
track = clip->tracking.tracks.first;
@@ -1335,8 +1335,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 13)) {
- FOREACH_NODETREE(main, ntree, id) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 13)) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -1352,10 +1352,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
} FOREACH_NODETREE_END
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 14)) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 14)) {
ParticleSettings *part;
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -1371,14 +1371,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
} FOREACH_NODETREE_END
/* keep compatibility for dupliobject particle size */
- for (part = main->particle.first; part; part = part->id.next)
+ for (part = bmain->particle.first; part; part = part->id.next)
if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR))
if ((part->draw & PART_DRAW_ROTATE_OB) == 0)
part->draw |= PART_DRAW_NO_SCALE_OB;
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 17)) {
- FOREACH_NODETREE(main, ntree, id) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 17)) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -1397,10 +1397,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
} FOREACH_NODETREE_END
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 18)) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 18)) {
Scene *scene;
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
if (scene->ed) {
Sequence *seq;
@@ -1434,7 +1434,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
/* color management pipeline changes compatibility code */
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 19)) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 19)) {
Scene *scene;
Image *ima;
bool colormanagement_disabled = false;
@@ -1442,7 +1442,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
/* make scenes which are not using color management have got None as display device,
* so they wouldn't perform linear-to-sRGB conversion on display
*/
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
if ((scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) == 0) {
ColorManagedDisplaySettings *display_settings = &scene->display_settings;
@@ -1455,7 +1455,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (ima = main->image.first; ima; ima = ima->id.next) {
+ for (ima = bmain->image.first; ima; ima = ima->id.next) {
if (ima->source == IMA_SRC_VIEWER) {
ima->flag |= IMA_VIEW_AS_RENDER;
}
@@ -1474,17 +1474,17 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 20)) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 20)) {
Key *key;
- for (key = main->key.first; key; key = key->id.next) {
+ for (key = bmain->key.first; key; key = key->id.next) {
blo_do_versions_key_uidgen(key);
}
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 21)) {
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 21)) {
{
Mesh *me;
- for (me = main->mesh.first; me; me = me->id.next) {
+ for (me = bmain->mesh.first; me; me = me->id.next) {
CustomData_update_typemap(&me->vdata);
CustomData_free_layers(&me->vdata, CD_MSTICKY, me->totvert);
}
@@ -1495,10 +1495,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
* didn't copy animation visualization, which lead to deadlocks on motion
* path calculation for proxied armatures, see [#32742]
*/
- if (main->versionfile < 264) {
+ if (bmain->versionfile < 264) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->pose) {
if (ob->pose->avs.path_step == 0) {
animviz_settings_init(&ob->pose->avs);
@@ -1507,8 +1507,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 1)) {
- FOREACH_NODETREE(main, ntree, id) {
+ if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 1)) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next)
@@ -1518,10 +1518,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
} FOREACH_NODETREE_END
}
- if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 2)) {
+ if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 2)) {
MovieClip *clip;
- for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *tracking_object;
@@ -1537,12 +1537,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 3)) {
+ if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 3)) {
/* smoke branch */
{
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Smoke) {
@@ -1581,7 +1581,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
{
bScreen *sc;
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -1601,11 +1601,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 5)) {
+ if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 5)) {
/* set a unwrapping margin and ABF by default */
Scene *scene;
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
if (scene->toolsettings->uvcalc_margin == 0.0f) {
scene->toolsettings->uvcalc_margin = 0.001f;
scene->toolsettings->unwrapper = 0;
@@ -1613,11 +1613,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 6)) {
+ if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 6)) {
/* Fix for bug #32982, internal_links list could get corrupted from r51630 onward.
* Simply remove bad internal_links lists to avoid NULL pointers.
*/
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE(bmain, ntree, id) {
bNode *node;
bNodeLink *link, *nextlink;
@@ -1632,12 +1632,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
} FOREACH_NODETREE_END
}
- if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 7)) {
+ if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 7)) {
/* convert tiles size from resolution and number of tiles */
{
Scene *scene;
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
if (scene->r.tilex == 0 || scene->r.tiley == 1) {
scene->r.tilex = scene->r.tiley = 64;
}
@@ -1647,7 +1647,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
/* collision masks */
{
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->col_group == 0) {
ob->col_group = 0x01;
ob->col_mask = 0xff;
@@ -1656,10 +1656,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 7)) {
+ if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 7)) {
MovieClip *clip;
- for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
MovieTrackingTrack *track;
MovieTrackingObject *object;
@@ -1675,9 +1675,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 3)) {
+ if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 3)) {
bScreen *sc;
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -1719,11 +1719,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 5)) {
+ if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 5)) {
Scene *scene;
Tex *tex;
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
Sequence *seq;
SEQ_BEGIN (scene->ed, seq)
@@ -1741,7 +1741,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
scene->r.bake_samples = 256;
}
- for (Image *image = main->image.first; image; image = image->id.next) {
+ for (Image *image = bmain->image.first; image; image = image->id.next) {
if (image->flag & IMA_DO_PREMUL) {
image->alpha_mode = IMA_ALPHA_STRAIGHT;
}
@@ -1750,7 +1750,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (tex = main->tex.first; tex; tex = tex->id.next) {
+ for (tex = bmain->tex.first; tex; tex = tex->id.next) {
if (tex->type == TEX_IMAGE && (tex->imaflag & TEX_USEALPHA) == 0) {
Image *image = blo_do_versions_newlibadr(fd, tex->id.lib, tex->ima);
@@ -1759,7 +1759,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -1775,20 +1775,20 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
} FOREACH_NODETREE_END
}
- else if (main->versionfile < 266 || (main->versionfile == 266 && main->subversionfile < 1)) {
+ else if (bmain->versionfile < 266 || (bmain->versionfile == 266 && bmain->subversionfile < 1)) {
/* texture use alpha was removed for 2.66 but added back again for 2.66a,
* for compatibility all textures assumed it to be enabled */
Tex *tex;
- for (tex = main->tex.first; tex; tex = tex->id.next)
+ for (tex = bmain->tex.first; tex; tex = tex->id.next)
if (tex->type == TEX_IMAGE)
tex->imaflag |= TEX_USEALPHA;
}
- if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 7)) {
+ if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 7)) {
Curve *cu;
- for (cu = main->curve.first; cu; cu = cu->id.next) {
+ for (cu = bmain->curve.first; cu; cu = cu->id.next) {
if (cu->flag & (CU_FRONT | CU_BACK)) {
if ( cu->ext1 != 0.0f || cu->ext2 != 0.0f) {
Nurb *nu;
@@ -1820,16 +1820,16 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (MAIN_VERSION_OLDER(main, 265, 9)) {
+ if (MAIN_VERSION_OLDER(bmain, 265, 9)) {
Mesh *me;
- for (me = main->mesh.first; me; me = me->id.next) {
+ for (me = bmain->mesh.first; me; me = me->id.next) {
BKE_mesh_do_versions_cd_flag_init(me);
}
}
- if (MAIN_VERSION_OLDER(main, 265, 10)) {
+ if (MAIN_VERSION_OLDER(bmain, 265, 10)) {
Brush *br;
- for (br = main->brush.first; br; br = br->id.next) {
+ for (br = bmain->brush.first; br; br = br->id.next) {
if (br->ob_mode & OB_MODE_TEXTURE_PAINT) {
br->mtex.brush_map_mode = MTEX_MAP_MODE_TILED;
}
@@ -1837,8 +1837,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
// add storage for compositor translate nodes when not existing
- if (MAIN_VERSION_OLDER(main, 265, 11)) {
- FOREACH_NODETREE(main, ntree, id) {
+ if (MAIN_VERSION_OLDER(bmain, 265, 11)) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -1850,15 +1850,15 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
} FOREACH_NODETREE_END
}
- if (MAIN_VERSION_OLDER(main, 266, 2)) {
- FOREACH_NODETREE(main, ntree, id) {
+ if (MAIN_VERSION_OLDER(bmain, 266, 2)) {
+ FOREACH_NODETREE(bmain, ntree, id) {
do_versions_nodetree_customnodes(ntree, ((ID *)ntree == id));
} FOREACH_NODETREE_END
}
- if (MAIN_VERSION_OLDER(main, 266, 2)) {
+ if (MAIN_VERSION_OLDER(bmain, 266, 2)) {
bScreen *sc;
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -1892,7 +1892,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
/* Set flag for delayed do_versions in lib_verify_nodetree. It needs valid typeinfo pointers ... */
{
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE(bmain, ntree, id) {
/* XXX This should be kept without version check for now!
* As long as USE_NODE_COMPAT_CUSTOMNODES is active, files will write links
* to tree interface sockets for forward compatibility. These links need to be removed again
@@ -1904,22 +1904,22 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
/* Only add interface nodes once.
* In old Blender versions they will be removed automatically due to undefined type */
- if (MAIN_VERSION_OLDER(main, 266, 2))
+ if (MAIN_VERSION_OLDER(bmain, 266, 2))
ntree->flag |= NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE;
}
FOREACH_NODETREE_END
}
- if (MAIN_VERSION_OLDER(main, 266, 3)) {
+ if (MAIN_VERSION_OLDER(bmain, 266, 3)) {
{
/* Fix for a very old issue:
* Node names were nominally made unique in r24478 (2.50.8), but the do_versions check
- * to update existing node names only applied to main->nodetree (i.e. group nodes).
+ * to update existing node names only applied to bmain->nodetree (i.e. group nodes).
* Uniqueness is now required for proper preview mapping,
* so do this now to ensure old files don't break.
*/
bNode *node;
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (id == &ntree->id)
continue; /* already fixed for node groups */
@@ -1930,9 +1930,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 266, 4)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 266, 4)) {
Brush *brush;
- for (brush = main->brush.first; brush; brush = brush->id.next) {
+ for (brush = bmain->brush.first; brush; brush = brush->id.next) {
BKE_texture_mtex_default(&brush->mask_mtex);
if (brush->ob_mode & OB_MODE_TEXTURE_PAINT) {
@@ -1941,11 +1941,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 266, 6)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 266, 6)) {
Brush *brush;
#define BRUSH_TEXTURE_OVERLAY (1 << 21)
- for (brush = main->brush.first; brush; brush = brush->id.next) {
+ for (brush = bmain->brush.first; brush; brush = brush->id.next) {
brush->overlay_flags = 0;
if (brush->flag & BRUSH_TEXTURE_OVERLAY)
brush->overlay_flags |= (BRUSH_OVERLAY_PRIMARY | BRUSH_OVERLAY_CURSOR);
@@ -1953,11 +1953,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
#undef BRUSH_TEXTURE_OVERLAY
}
- if (main->versionfile < 267) {
+ if (bmain->versionfile < 267) {
//if (!DNA_struct_elem_find(fd->filesdna, "Brush", "int", "stencil_pos")) {
Brush *brush;
- for (brush = main->brush.first; brush; brush = brush->id.next) {
+ for (brush = bmain->brush.first; brush; brush = brush->id.next) {
if (brush->stencil_dimension[0] == 0) {
brush->stencil_dimension[0] = 256;
brush->stencil_dimension[1] = 256;
@@ -1982,12 +1982,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
/* default values in Freestyle settings */
- if (main->versionfile < 267) {
+ if (bmain->versionfile < 267) {
Scene *sce;
SceneRenderLayer *srl;
FreestyleLineStyle *linestyle;
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->r.line_thickness_mode == 0) {
sce->r.line_thickness_mode = R_LINE_THICKNESS_ABSOLUTE;
sce->r.unit_line_thickness = 1.0f;
@@ -2023,7 +2023,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
+ for (linestyle = bmain->linestyle.first; linestyle; linestyle = linestyle->id.next) {
#if 1
/* disable the Misc panel for now */
if (linestyle->panel == LS_PANEL_MISC) {
@@ -2041,13 +2041,13 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 267) {
+ if (bmain->versionfile < 267) {
/* Initialize the active_viewer_key for compositing */
bScreen *screen;
Scene *scene;
bNodeInstanceKey active_viewer_key = {0};
/* simply pick the first node space and use that for the active viewer key */
- for (screen = main->screen.first; screen; screen = screen->id.next) {
+ for (screen = bmain->screen.first; screen; screen = screen->id.next) {
ScrArea *sa;
for (sa = screen->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -2069,17 +2069,17 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
break;
}
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
/* NB: scene->nodetree is a local ID block, has been direct_link'ed */
if (scene->nodetree)
scene->nodetree->active_viewer_key = active_viewer_key;
}
}
- if (MAIN_VERSION_OLDER(main, 267, 1)) {
+ if (MAIN_VERSION_OLDER(bmain, 267, 1)) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Smoke) {
@@ -2097,17 +2097,17 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 268, 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 268, 1)) {
Brush *brush;
- for (brush = main->brush.first; brush; brush = brush->id.next) {
+ for (brush = bmain->brush.first; brush; brush = brush->id.next) {
brush->spacing = MAX2(1, brush->spacing);
}
}
- if (!MAIN_VERSION_ATLEAST(main, 268, 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 268, 2)) {
Brush *brush;
#define BRUSH_FIXED (1 << 6)
- for (brush = main->brush.first; brush; brush = brush->id.next) {
+ for (brush = bmain->brush.first; brush; brush = brush->id.next) {
brush->flag &= ~BRUSH_FIXED;
if (brush->cursor_overlay_alpha < 2)
@@ -2121,11 +2121,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
- if (!MAIN_VERSION_ATLEAST(main, 268, 4)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 268, 4)) {
bScreen *sc;
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
bConstraint *con;
for (con = ob->constraints.first; con; con = con->next) {
if (con->type == CONSTRAINT_TYPE_SHRINKWRAP) {
@@ -2138,7 +2138,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Smoke) {
@@ -2157,7 +2157,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
*
* We moved this check to the do versions to be sure the value makes any sense.
*/
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -2173,12 +2173,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 268, 5)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 268, 5)) {
bScreen *sc;
ScrArea *sa;
/* add missing (+) expander in node editor */
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
for (sa = sc->areabase.first; sa; sa = sa->next) {
ARegion *ar, *arnew;
@@ -2207,9 +2207,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 269, 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 1)) {
/* Removal of Cycles SSS Compatible falloff */
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -2223,9 +2223,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
} FOREACH_NODETREE_END
}
- if (!MAIN_VERSION_ATLEAST(main, 269, 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 2)) {
/* Initialize CDL settings for Color Balance nodes */
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -2250,14 +2250,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
} FOREACH_NODETREE_END
}
- if (!MAIN_VERSION_ATLEAST(main, 269, 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 3)) {
bScreen *sc;
ScrArea *sa;
SpaceLink *sl;
Scene *scene;
/* Update files using invalid (outdated) outlinevis Outliner values. */
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
for (sa = sc->areabase.first; sa; sa = sa->next) {
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_OUTLINER) {
@@ -2278,7 +2278,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight")) {
MovieClip *clip;
- for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *tracking_object;
for (tracking_object = tracking->objects.first;
@@ -2299,7 +2299,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "quad_method")) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Triangulate) {
@@ -2317,7 +2317,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
/* this can now be turned off */
ToolSettings *ts = scene->toolsettings;
if (ts->sculpt)
@@ -2337,17 +2337,17 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 269, 4)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 4)) {
/* Internal degrees to radians conversions... */
{
Scene *scene;
Object *ob;
Lamp *lamp;
- for (lamp = main->lamp.first; lamp; lamp = lamp->id.next)
+ for (lamp = bmain->lamp.first; lamp; lamp = lamp->id.next)
lamp->spotsize = DEG2RADF(lamp->spotsize);
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
@@ -2362,7 +2362,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
Sequence *seq;
SEQ_BEGIN (scene->ed, seq)
{
@@ -2374,7 +2374,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
SEQ_END
}
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -2397,7 +2397,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingPlaneTrack", "float", "image_opacity")) {
MovieClip *clip;
- for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
MovieTrackingPlaneTrack *plane_track;
for (plane_track = clip->tracking.plane_tracks.first;
plane_track;
@@ -2409,9 +2409,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 269, 7)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 7)) {
Scene *scene;
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
Sculpt *sd = scene->toolsettings->sculpt;
if (sd) {
@@ -2429,20 +2429,20 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 269, 8)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 8)) {
Curve *cu;
- for (cu = main->curve.first; cu; cu = cu->id.next) {
+ for (cu = bmain->curve.first; cu; cu = cu->id.next) {
if (cu->str) {
cu->len_wchar = BLI_strlen_utf8(cu->str);
}
}
}
- if (!MAIN_VERSION_ATLEAST(main, 269, 9)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 9)) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Build) {
@@ -2455,10 +2455,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 269, 11)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 11)) {
bScreen *sc;
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *space_link;
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index ee589e511c6..ba714405cc0 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -346,14 +346,14 @@ static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id), FCurve *fcu, void
}
-void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
+void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
- if (!MAIN_VERSION_ATLEAST(main, 270, 0)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 270, 0)) {
if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "float", "profile")) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Bevel) {
@@ -366,7 +366,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
/* nodes don't use fixed node->id any more, clean up */
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -380,7 +380,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
{
bScreen *screen;
- for (screen = main->screen.first; screen; screen = screen->id.next) {
+ for (screen = bmain->screen.first; screen; screen = screen->id.next) {
ScrArea *area;
for (area = screen->areabase.first; area; area = area->next) {
SpaceLink *space_link;
@@ -398,17 +398,17 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingSettings", "float", "default_weight")) {
MovieClip *clip;
- for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
clip->tracking.settings.default_weight = 1.0f;
}
}
}
- if (!MAIN_VERSION_ATLEAST(main, 270, 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 270, 1)) {
Object *ob;
/* Update Transform constraint (another deg -> rad stuff). */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
do_version_constraints_radians_degrees_270_1(&ob->constraints);
if (ob->pose) {
@@ -421,32 +421,32 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 270, 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 270, 2)) {
Mesh *me;
/* Mesh smoothresh deg->rad. */
- for (me = main->mesh.first; me; me = me->id.next) {
+ for (me = bmain->mesh.first; me; me = me->id.next) {
me->smoothresh = DEG2RADF(me->smoothresh);
}
}
- if (!MAIN_VERSION_ATLEAST(main, 270, 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 270, 3)) {
FreestyleLineStyle *linestyle;
- for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
+ for (linestyle = bmain->linestyle.first; linestyle; linestyle = linestyle->id.next) {
linestyle->flag |= LS_NO_SORTING;
linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
linestyle->integration_type = LS_INTEGRATION_MEAN;
}
}
- if (!MAIN_VERSION_ATLEAST(main, 270, 4)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 270, 4)) {
/* ui_previews were not handled correctly when copying areas, leading to corrupted files (see T39847).
* This will always reset situation to a valid state.
*/
bScreen *sc;
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -463,11 +463,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 270, 5)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 270, 5)) {
Object *ob;
/* Update Transform constraint (again :|). */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
do_version_constraints_radians_degrees_270_5(&ob->constraints);
if (ob->pose) {
@@ -480,11 +480,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 271, 0)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 271, 0)) {
if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "BakeData", "bake")) {
Scene *sce;
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
sce->r.bake.flag = R_BAKE_CLEAR;
sce->r.bake.width = 512;
sce->r.bake.height = 512;
@@ -506,7 +506,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "FreestyleLineStyle", "float", "texstep")) {
FreestyleLineStyle *linestyle;
- for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
+ for (linestyle = bmain->linestyle.first; linestyle; linestyle = linestyle->id.next) {
linestyle->flag |= LS_TEXTURE;
linestyle->texstep = 1.0;
}
@@ -514,18 +514,18 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
{
Scene *scene;
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
int num_layers = BLI_listbase_count(&scene->r.layers);
scene->r.actlay = min_ff(scene->r.actlay, num_layers - 1);
}
}
}
- if (!MAIN_VERSION_ATLEAST(main, 271, 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 271, 1)) {
if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "line_col[4]")) {
Material *mat;
- for (mat = main->mat.first; mat; mat = mat->id.next) {
+ for (mat = bmain->mat.first; mat; mat = mat->id.next) {
mat->line_col[0] = mat->line_col[1] = mat->line_col[2] = 0.0f;
mat->line_col[3] = mat->alpha;
}
@@ -533,22 +533,22 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) {
Scene *scene;
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
scene->r.preview_start_resolution = 64;
}
}
}
- if (!MAIN_VERSION_ATLEAST(main, 271, 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 271, 3)) {
Brush *br;
- for (br = main->brush.first; br; br = br->id.next) {
+ for (br = bmain->brush.first; br; br = br->id.next) {
br->fill_threshold = 0.2f;
}
if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "int", "mat")) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
@@ -561,9 +561,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 271, 6)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 271, 6)) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
@@ -577,27 +577,27 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 272, 0)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 272, 0)) {
if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) {
Scene *scene;
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
scene->r.preview_start_resolution = 64;
}
}
}
- if (!MAIN_VERSION_ATLEAST(main, 272, 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 272, 1)) {
Brush *br;
- for (br = main->brush.first; br; br = br->id.next) {
+ for (br = bmain->brush.first; br; br = br->id.next) {
if ((br->ob_mode & OB_MODE_SCULPT) && ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK))
br->alpha = 1.0f;
}
}
- if (!MAIN_VERSION_ATLEAST(main, 272, 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 272, 2)) {
if (!DNA_struct_elem_find(fd->filesdna, "Image", "float", "gen_color")) {
Image *image;
- for (image = main->image.first; image != NULL; image = image->id.next) {
+ for (image = bmain->image.first; image != NULL; image = image->id.next) {
image->gen_color[3] = 1.0f;
}
}
@@ -606,7 +606,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
Object *ob;
/* Update Transform constraint (again :|). */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
do_version_constraints_stretch_to_limits(&ob->constraints);
if (ob->pose) {
@@ -620,13 +620,13 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 273, 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 273, 1)) {
#define BRUSH_RAKE (1 << 7)
#define BRUSH_RANDOM_ROTATION (1 << 25)
Brush *br;
- for (br = main->brush.first; br; br = br->id.next) {
+ for (br = bmain->brush.first; br; br = br->id.next) {
if (br->flag & BRUSH_RAKE) {
br->mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
@@ -644,11 +644,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
#undef BRUSH_RANDOM_ROTATION
/* Customizable Safe Areas */
- if (!MAIN_VERSION_ATLEAST(main, 273, 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 273, 2)) {
if (!DNA_struct_elem_find(fd->filesdna, "Scene", "DisplaySafeAreas", "safe_areas")) {
Scene *scene;
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
copy_v2_fl2(scene->safe_areas.title, 3.5f / 100.0f, 3.5f / 100.0f);
copy_v2_fl2(scene->safe_areas.action, 10.0f / 100.0f, 5.0f / 100.0f);
copy_v2_fl2(scene->safe_areas.title_center, 17.5f / 100.0f, 5.0f / 100.0f);
@@ -657,9 +657,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 273, 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 273, 3)) {
ParticleSettings *part;
- for (part = main->particle.first; part; part = part->id.next) {
+ for (part = bmain->particle.first; part; part = part->id.next) {
if (part->clumpcurve)
part->child_flag |= PART_CHILD_USE_CLUMP_CURVE;
if (part->roughcurve)
@@ -667,11 +667,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 273, 6)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 273, 6)) {
if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "bending_damping")) {
Object *ob;
ModifierData *md;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
@@ -689,21 +689,21 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "float", "clump_noise_size")) {
ParticleSettings *part;
- for (part = main->particle.first; part; part = part->id.next) {
+ for (part = bmain->particle.first; part; part = part->id.next) {
part->clump_noise_size = 1.0f;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "int", "kink_extra_steps")) {
ParticleSettings *part;
- for (part = main->particle.first; part; part = part->id.next) {
+ for (part = bmain->particle.first; part; part = part->id.next) {
part->kink_extra_steps = 4;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "MTex", "float", "kinkampfac")) {
ParticleSettings *part;
- for (part = main->particle.first; part; part = part->id.next) {
+ for (part = bmain->particle.first; part; part = part->id.next) {
int a;
for (a = 0; a < MAX_MTEX; a++) {
MTex *mtex = part->mtex[a];
@@ -717,7 +717,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "HookModifierData", "char", "flag")) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Hook) {
@@ -729,7 +729,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
if (!DNA_struct_elem_find(fd->filesdna, "NodePlaneTrackDeformData", "char", "flag")) {
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -747,7 +747,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "Camera", "GPUDOFSettings", "gpu_dof")) {
Camera *ca;
- for (ca = main->camera.first; ca; ca = ca->id.next) {
+ for (ca = bmain->camera.first; ca; ca = ca->id.next) {
ca->gpu_dof.fstop = 128.0f;
ca->gpu_dof.focal_length = 1.0f;
ca->gpu_dof.focus_distance = 1.0f;
@@ -756,9 +756,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 273, 8)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 273, 8)) {
Object *ob;
- for (ob = main->object.first; ob != NULL; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob != NULL; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.last; md != NULL; md = md->prev) {
if (modifier_unique_name(&ob->modifiers, md)) {
@@ -770,14 +770,14 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 273, 9)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 273, 9)) {
bScreen *scr;
ScrArea *sa;
SpaceLink *sl;
ARegion *ar;
/* Make sure sequencer preview area limits zoom */
- for (scr = main->screen.first; scr; scr = scr->id.next) {
+ for (scr = bmain->screen.first; scr; scr = scr->id.next) {
for (sa = scr->areabase.first; sa; sa = sa->next) {
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_SEQ) {
@@ -795,12 +795,12 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 274, 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 274, 1)) {
/* particle systems need to be forced to redistribute for jitter mode fix */
{
Object *ob;
ParticleSystem *psys;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
if ((psys->pointcache->flag & PTCACHE_BAKED) == 0) {
psys->recalc |= PSYS_RECALC_RESET;
@@ -812,7 +812,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
/* hysteresis setted to 10% but not actived */
if (!DNA_struct_elem_find(fd->filesdna, "LodLevel", "int", "obhysteresis")) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
LodLevel *level;
for (level = ob->lodlevels.first; level; level = level->next) {
level->obhysteresis = 10;
@@ -821,7 +821,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 274, 4)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 274, 4)) {
SceneRenderView *srv;
wmWindowManager *wm;
bScreen *screen;
@@ -830,7 +830,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
Camera *cam;
Image *ima;
- for (scene = main->scene.first; scene; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
Sequence *seq;
BKE_scene_add_render_view(scene, STEREO_LEFT_NAME);
@@ -860,7 +860,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
SEQ_END
}
- for (screen = main->screen.first; screen; screen = screen->id.next) {
+ for (screen = bmain->screen.first; screen; screen = screen->id.next) {
ScrArea *sa;
for (sa = screen->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -887,12 +887,12 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (cam = main->camera.first; cam; cam = cam->id.next) {
+ for (cam = bmain->camera.first; cam; cam = cam->id.next) {
cam->stereo.interocular_distance = 0.065f;
cam->stereo.convergence_distance = 30.0f * 0.065f;
}
- for (ima = main->image.first; ima; ima = ima->id.next) {
+ for (ima = bmain->image.first; ima; ima = ima->id.next) {
ima->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Image Stereo 3d Format");
if (ima->packedfile) {
@@ -905,18 +905,18 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (wm = main->wm.first; wm; wm = wm->id.next) {
+ for (wm = bmain->wm.first; wm; wm = wm->id.next) {
for (win = wm->windows.first; win; win = win->next) {
win->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format");
}
}
}
- if (!MAIN_VERSION_ATLEAST(main, 274, 6)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 274, 6)) {
bScreen *screen;
if (!DNA_struct_elem_find(fd->filesdna, "FileSelectParams", "int", "thumbnail_size")) {
- for (screen = main->screen.first; screen; screen = screen->id.next) {
+ for (screen = bmain->screen.first; screen; screen = screen->id.next) {
ScrArea *sa;
for (sa = screen->areabase.first; sa; sa = sa->next) {
@@ -937,7 +937,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "short", "simplify_subsurf_render")) {
Scene *scene;
- for (scene = main->scene.first; scene != NULL; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene != NULL; scene = scene->id.next) {
scene->r.simplify_subsurf_render = scene->r.simplify_subsurf;
scene->r.simplify_particles_render = scene->r.simplify_particles;
}
@@ -946,7 +946,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "DecimateModifierData", "float", "defgrp_factor")) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Decimate) {
@@ -958,20 +958,20 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 275, 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 275, 3)) {
Brush *br;
#define BRUSH_TORUS (1 << 1)
- for (br = main->brush.first; br; br = br->id.next) {
+ for (br = bmain->brush.first; br; br = br->id.next) {
br->flag &= ~BRUSH_TORUS;
}
#undef BRUSH_TORUS
}
- if (!MAIN_VERSION_ATLEAST(main, 276, 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 276, 2)) {
if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "custom_scale")) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->pose) {
bPoseChannel *pchan;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -984,7 +984,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
{
bScreen *screen;
#define RV3D_VIEW_PERSPORTHO 7
- for (screen = main->screen.first; screen; screen = screen->id.next) {
+ for (screen = bmain->screen.first; screen; screen = screen->id.next) {
ScrArea *sa;
for (sa = screen->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -1013,7 +1013,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
{
Lamp *lamp;
#define LA_YF_PHOTON 5
- for (lamp = main->lamp.first; lamp; lamp = lamp->id.next) {
+ for (lamp = bmain->lamp.first; lamp; lamp = lamp->id.next) {
if (lamp->type == LA_YF_PHOTON) {
lamp->type = LA_LOCAL;
}
@@ -1022,10 +1022,10 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 276, 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 276, 3)) {
if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "CurveMapping", "mblur_shutter_curve")) {
Scene *scene;
- for (scene = main->scene.first; scene != NULL; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene != NULL; scene = scene->id.next) {
CurveMapping *curve_mapping = &scene->r.mblur_shutter_curve;
curvemapping_set_defaults(curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f);
curvemapping_initialize(curve_mapping);
@@ -1037,8 +1037,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 276, 4)) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 276, 4)) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
ToolSettings *ts = scene->toolsettings;
if (ts->gp_sculpt.brush[0].size == 0) {
@@ -1113,7 +1113,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
+ for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
bool enabled = false;
/* Ensure that the datablock's onionskinning toggle flag
@@ -1131,13 +1131,13 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
gpd->flag &= ~GP_DATA_SHOW_ONIONSKINS;
}
}
- if (!MAIN_VERSION_ATLEAST(main, 276, 5)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 276, 5)) {
ListBase *lbarray[MAX_LIBARRAY];
int a;
/* Important to clear all non-persistent flags from older versions here, otherwise they could collide
* with any new persistent flag we may add in the future. */
- a = set_listbasepointers(main, lbarray);
+ a = set_listbasepointers(bmain, lbarray);
while (a--) {
for (ID *id = lbarray[a]->first; id; id = id->next) {
id->flag &= LIB_FAKEUSER;
@@ -1145,15 +1145,15 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 276, 7)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 276, 7)) {
Scene *scene;
- for (scene = main->scene.first; scene != NULL; scene = scene->id.next) {
+ for (scene = bmain->scene.first; scene != NULL; scene = scene->id.next) {
scene->r.bake.pass_filter = R_BAKE_PASS_FILTER_ALL;
}
}
- if (!MAIN_VERSION_ATLEAST(main, 277, 1)) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 277, 1)) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
ParticleEditSettings *pset = &scene->toolsettings->particle;
for (int a = 0; a < ARRAY_SIZE(pset->brush); a++) {
if (pset->brush[a].strength > 1.0f) {
@@ -1162,7 +1162,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
@@ -1195,7 +1195,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
CurvePaintSettings *cps = &scene->toolsettings->curve_paint_settings;
if (cps->error_threshold == 0) {
cps->curve_type = CU_BEZIER;
@@ -1206,7 +1206,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
Sequence *seq;
SEQ_BEGIN (scene->ed, seq)
@@ -1230,7 +1230,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
/* Adding "Properties" region to DopeSheet */
- for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
/* handle pushed-back space data first */
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
@@ -1248,14 +1248,14 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 277, 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 277, 2)) {
if (!DNA_struct_elem_find(fd->filesdna, "Bone", "float", "scaleIn")) {
- for (bArmature *arm = main->armature.first; arm; arm = arm->id.next) {
+ for (bArmature *arm = bmain->armature.first; arm; arm = arm->id.next) {
do_version_bones_super_bbone(&arm->bonebase);
}
}
if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "scaleIn")) {
- for (Object *ob = main->object.first; ob; ob = ob->id.next) {
+ for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->pose) {
for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
/* see do_version_bones_super_bbone()... */
@@ -1275,7 +1275,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (Camera *camera = main->camera.first; camera != NULL; camera = camera->id.next) {
+ for (Camera *camera = bmain->camera.first; camera != NULL; camera = camera->id.next) {
if (camera->stereo.pole_merge_angle_from == 0.0f &&
camera->stereo.pole_merge_angle_to == 0.0f)
{
@@ -1287,7 +1287,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "NormalEditModifierData", "float", "mix_limit")) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_NormalEdit) {
@@ -1300,7 +1300,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "BooleanModifierData", "float", "double_threshold")) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Boolean) {
@@ -1311,7 +1311,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (Brush *br = main->brush.first; br; br = br->id.next) {
+ for (Brush *br = bmain->brush.first; br; br = br->id.next) {
if (br->sculpt_tool == SCULPT_TOOL_FLATTEN) {
br->flag |= BRUSH_ACCUMULATE;
}
@@ -1320,7 +1320,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "time_scale")) {
Object *ob;
ModifierData *md;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
@@ -1337,10 +1337,10 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 277, 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 277, 3)) {
/* ------- init of grease pencil initialization --------------- */
if (!DNA_struct_elem_find(fd->filesdna, "bGPDstroke", "bGPDpalettecolor", "*palcolor")) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
ToolSettings *ts = scene->toolsettings;
/* initialize use position for sculpt brushes */
ts->gp_sculpt.flag |= GP_BRUSHEDIT_FLAG_APPLY_POSITION;
@@ -1359,8 +1359,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
/* create a default grease pencil drawing brushes set */
- if (!BLI_listbase_is_empty(&main->gpencil)) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ if (!BLI_listbase_is_empty(&bmain->gpencil)) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
ToolSettings *ts = scene->toolsettings;
if (BLI_listbase_is_empty(&ts->gp_brushes)) {
BKE_gpencil_brush_init_presets(ts);
@@ -1370,7 +1370,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
/* Convert Grease Pencil to new palettes/brushes
* Loop all strokes and create the palette and all colors
*/
- for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
+ for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
if (BLI_listbase_is_empty(&gpd->palettes)) {
/* create palette */
bGPDpalette *palette = BKE_gpencil_palette_addnew(gpd, "GP_Palette", true);
@@ -1423,10 +1423,10 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
/* ------- end of grease pencil initialization --------------- */
}
- if (!MAIN_VERSION_ATLEAST(main, 278, 0)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 278, 0)) {
if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight_stab")) {
MovieClip *clip;
- for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *tracking_object;
for (tracking_object = tracking->objects.first;
@@ -1447,7 +1447,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingStabilization", "int", "tot_rot_track")) {
MovieClip *clip;
- for (clip = main->movieclip.first; clip != NULL; clip = clip->id.next) {
+ for (clip = bmain->movieclip.first; clip != NULL; clip = clip->id.next) {
if (clip->tracking.stabilization.rot_track) {
migrate_single_rot_stabilization_track_settings(&clip->tracking.stabilization);
}
@@ -1467,15 +1467,15 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
- if (!MAIN_VERSION_ATLEAST(main, 278, 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 278, 2)) {
if (!DNA_struct_elem_find(fd->filesdna, "FFMpegCodecData", "int", "ffmpeg_preset")) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
/* "medium" is the preset FFmpeg uses when no presets are given. */
scene->r.ffcodecdata.ffmpeg_preset = FFM_PRESET_MEDIUM;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "FFMpegCodecData", "int", "constant_rate_factor")) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
/* fall back to behaviour from before we introduced CRF for old files */
scene->r.ffcodecdata.constant_rate_factor = FFM_CRF_NONE;
}
@@ -1485,7 +1485,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
Object *ob;
ModifierData *md;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *)md;
@@ -1500,8 +1500,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 278, 3)) {
- for (Scene *scene = main->scene.first; scene != NULL; scene = scene->id.next) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 278, 3)) {
+ for (Scene *scene = bmain->scene.first; scene != NULL; scene = scene->id.next) {
if (scene->toolsettings != NULL) {
ToolSettings *ts = scene->toolsettings;
ParticleEditSettings *pset = &ts->particle;
@@ -1515,7 +1515,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
if (!DNA_struct_elem_find(fd->filesdna, "RigidBodyCon", "float", "spring_stiffness_ang_x")) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
RigidBodyCon *rbc = ob->rigidbody_constraint;
if (rbc) {
rbc->spring_stiffness_ang_x = 10.0;
@@ -1530,7 +1530,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
/* constant detail for sculpting is now a resolution value instead of
* a percentage, we reuse old DNA struct member but convert it */
- for (Scene *scene = main->scene.first; scene != NULL; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene != NULL; scene = scene->id.next) {
if (scene->toolsettings != NULL) {
ToolSettings *ts = scene->toolsettings;
if (ts->sculpt && ts->sculpt->constant_detail != 0.0f) {
@@ -1540,16 +1540,16 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 278, 4)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 278, 4)) {
const float sqrt_3 = (float)M_SQRT3;
- for (Brush *br = main->brush.first; br; br = br->id.next) {
+ for (Brush *br = bmain->brush.first; br; br = br->id.next) {
br->fill_threshold /= sqrt_3;
}
/* Custom motion paths */
if (!DNA_struct_elem_find(fd->filesdna, "bMotionPath", "int", "line_thickness")) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
bMotionPath *mpath;
bPoseChannel *pchan;
mpath = ob->mpath;
@@ -1577,9 +1577,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 278, 5)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 278, 5)) {
/* Mask primitive adding code was not initializing correctly id_type of its points' parent. */
- for (Mask *mask = main->mask.first; mask; mask = mask->id.next) {
+ for (Mask *mask = bmain->mask.first; mask; mask = mask->id.next) {
for (MaskLayer *mlayer = mask->masklayers.first; mlayer; mlayer = mlayer->next) {
for (MaskSpline *mspline = mlayer->splines.first; mspline; mspline = mspline->next) {
int i = 0;
@@ -1594,7 +1594,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
/* Fix for T50736, Glare comp node using same var for two different things. */
if (!DNA_struct_elem_find(fd->filesdna, "NodeGlare", "char", "star_45")) {
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
ntreeSetTypes(NULL, ntree);
for (bNode *node = ntree->nodes.first; node; node = node->next) {
@@ -1617,7 +1617,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
if (!DNA_struct_elem_find(fd->filesdna, "SurfaceDeformModifierData", "float", "mat[4][4]")) {
- for (Object *ob = main->object.first; ob; ob = ob->id.next) {
+ for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_SurfaceDeform) {
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
@@ -1627,32 +1627,32 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
do_versions_compositor_render_passes(ntree);
}
} FOREACH_NODETREE_END
}
- if (!MAIN_VERSION_ATLEAST(main, 279, 0)) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 0)) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
if (scene->r.im_format.exr_codec == R_IMF_EXR_CODEC_DWAB) {
scene->r.im_format.exr_codec = R_IMF_EXR_CODEC_DWAA;
}
}
/* Fix related to VGroup modifiers creating named defgroup CD layers! See T51520. */
- for (Mesh *me = main->mesh.first; me; me = me->id.next) {
+ for (Mesh *me = bmain->mesh.first; me; me = me->id.next) {
CustomData_set_layer_name(&me->vdata, CD_MDEFORMVERT, 0, "");
}
}
- if (!MAIN_VERSION_ATLEAST(main, 279, 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 3)) {
if (!DNA_struct_elem_find(fd->filesdna, "SmokeDomainSettings", "float", "clipping")) {
Object *ob;
ModifierData *md;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *)md;
@@ -1667,7 +1667,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
{
/* Fix for invalid state of screen due to bug in older versions. */
- for (bScreen *sc = main->screen.first; sc; sc = sc->id.next) {
+ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
if (sa->full && sc->state == SCREENNORMAL) {
sa->full = NULL;
@@ -1676,7 +1676,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
if (!DNA_struct_elem_find(fd->filesdna, "Brush", "float", "falloff_angle")) {
- for (Brush *br = main->brush.first; br; br = br->id.next) {
+ for (Brush *br = bmain->brush.first; br; br = br->id.next) {
br->falloff_angle = DEG2RADF(80);
br->flag &= ~(
BRUSH_FLAG_DEPRECATED_1 | BRUSH_FLAG_DEPRECATED_2 |
@@ -1684,7 +1684,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
BRUSH_FRONTFACE_FALLOFF);
}
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
ToolSettings *ts = scene->toolsettings;
for (int i = 0; i < 2; i++) {
VPaint *vp = i ? ts->vpaint : ts->wpaint;
@@ -1699,7 +1699,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
/* Simple deform modifier no longer assumes Z axis (X for bend type).
* Must set previous defaults. */
if (!DNA_struct_elem_find(fd->filesdna, "SimpleDeformModifierData", "char", "deform_axis")) {
- for (Object *ob = main->object.first; ob; ob = ob->id.next) {
+ for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_SimpleDeform) {
SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md;
@@ -1709,7 +1709,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
int preset = scene->r.ffcodecdata.ffmpeg_preset;
if (preset == FFM_PRESET_NONE || preset >= FFM_PRESET_GOOD) {
continue;
@@ -1727,7 +1727,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
if (!DNA_struct_elem_find(fd->filesdna, "ParticleInstanceModifierData", "float", "particle_amount")) {
- for (Object *ob = main->object.first; ob; ob = ob->id.next) {
+ for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_ParticleInstance) {
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
@@ -1740,11 +1740,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
-void do_versions_after_linking_270(Main *main)
+void do_versions_after_linking_270(Main *bmain)
{
/* To be added to next subversion bump! */
- if (!MAIN_VERSION_ATLEAST(main, 279, 0)) {
- FOREACH_NODETREE(main, ntree, id) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 0)) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
ntreeSetTypes(NULL, ntree);
for (bNode *node = ntree->nodes.first; node; node = node->next) {
@@ -1756,9 +1756,9 @@ void do_versions_after_linking_270(Main *main)
} FOREACH_NODETREE_END
}
- if (!MAIN_VERSION_ATLEAST(main, 279, 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 2)) {
/* B-Bones (bbone_in/out -> bbone_easein/out) + Stepped FMod Frame Start/End fix */
/* if (!DNA_struct_elem_find(fd->filesdna, "Bone", "float", "bbone_easein")) */
- BKE_fcurves_main_cb(main, do_version_bbone_easing_fcurve_fix, NULL);
+ BKE_fcurves_main_cb(bmain, do_version_bbone_easing_fcurve_fix, NULL);
}
}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index a25c744afc4..eb165efb4f9 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -67,6 +67,7 @@
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
+#include "BKE_studiolight.h"
#include "BKE_workspace.h"
#include "BLO_readfile.h"
@@ -96,6 +97,9 @@ static void do_version_workspaces_create_from_screens(Main *bmain)
Scene *scene = screen->scene;
WorkSpace *workspace;
ViewLayer *layer = BLI_findlink(&scene->view_layers, scene->r.actlay);
+ if (screen->temp) {
+ continue;
+ }
if (!layer) {
layer = BKE_view_layer_default_view(scene);
}
@@ -671,15 +675,15 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene)
scene->basact = NULL;
}
-void do_versions_after_linking_280(Main *main)
+void do_versions_after_linking_280(Main *bmain)
{
bool use_collection_compat_28 = true;
- if (!MAIN_VERSION_ATLEAST(main, 280, 0)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
use_collection_compat_28 = false;
/* Convert group layer visibility flags to hidden nested collection. */
- for (Collection *collection = main->collection.first; collection; collection = collection->id.next) {
+ for (Collection *collection = bmain->collection.first; collection; collection = collection->id.next) {
/* Add fake user for all existing groups. */
id_fake_user_set(&collection->id);
@@ -694,25 +698,25 @@ void do_versions_after_linking_280(Main *main)
if (!(ob->lay & collection->layer)) {
if (collection_hidden == NULL) {
- collection_hidden = BKE_collection_add(main, collection, "Hidden");
+ collection_hidden = BKE_collection_add(bmain, collection, "Hidden");
collection_hidden->id.lib = collection->id.lib;
collection_hidden->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER;
}
- BKE_collection_object_add(main, collection_hidden, ob);
- BKE_collection_object_remove(main, collection, ob, true);
+ BKE_collection_object_add(bmain, collection_hidden, ob);
+ BKE_collection_object_remove(bmain, collection, ob, true);
}
}
}
/* Convert layers to collections. */
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
- do_version_layers_to_collections(main, scene);
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ do_version_layers_to_collections(bmain, scene);
}
}
- if (!MAIN_VERSION_ATLEAST(main, 280, 0)) {
- for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
/* same render-layer as do_version_workspaces_after_lib_link will activate,
* so same layer as BKE_view_layer_from_workspace_get would return */
ViewLayer *layer = screen->scene->view_layers.first;
@@ -746,14 +750,14 @@ void do_versions_after_linking_280(Main *main)
}
/* New workspace design */
- if (!MAIN_VERSION_ATLEAST(main, 280, 1)) {
- do_version_workspaces_after_lib_link(main);
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 1)) {
+ do_version_workspaces_after_lib_link(bmain);
}
- if (!MAIN_VERSION_ATLEAST(main, 280, 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 2)) {
/* Cleanup any remaining SceneRenderLayer data for files that were created
* with Blender 2.8 before the SceneRenderLayer > RenderLayer refactor. */
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) {
if (srl->prop) {
IDP_FreeProperty(srl->prop);
@@ -765,10 +769,10 @@ void do_versions_after_linking_280(Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 280, 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 3)) {
/* Due to several changes to particle RNA and draw code particles from older files may no longer
* be visible. Here we correct this by setting a default draw size for those files. */
- for (Object *object = main->object.first; object; object = object->id.next) {
+ for (Object *object = bmain->object.first; object; object = object->id.next) {
for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) {
if (psys->part->draw_size == 0.0f) {
psys->part->draw_size = 0.1f;
@@ -777,8 +781,8 @@ void do_versions_after_linking_280(Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 280, 4)) {
- for (Object *object = main->object.first; object; object = object->id.next) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 4)) {
+ for (Object *object = bmain->object.first; object; object = object->id.next) {
#ifndef VERSION_280_SUBVERSION_4
/* If any object already has an initialized value for
* duplicator_visibility_flag it means we've already doversioned it.
@@ -810,9 +814,9 @@ void do_versions_after_linking_280(Main *main)
}
/* SpaceTime & SpaceLogic removal/replacing */
- if (!MAIN_VERSION_ATLEAST(main, 280, 9)) {
- const wmWindowManager *wm = main->wm.first;
- const Scene *scene = main->scene.first;
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 9)) {
+ const wmWindowManager *wm = bmain->wm.first;
+ const Scene *scene = bmain->scene.first;
if (wm != NULL) {
/* Action editors need a scene for creation. First, update active
@@ -832,7 +836,7 @@ void do_versions_after_linking_280(Main *main)
}
}
if (scene != NULL) {
- for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) {
/* Areas that were already handled won't be handled again */
@@ -847,39 +851,39 @@ void do_versions_after_linking_280(Main *main)
}
#ifdef USE_COLLECTION_COMPAT_28
- if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(main, 280, 14)) {
- for (Collection *group = main->collection.first; group; group = group->id.next) {
- do_version_group_collection_to_collection(main, group);
+ if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(bmain, 280, 14)) {
+ for (Collection *group = bmain->collection.first; group; group = group->id.next) {
+ do_version_group_collection_to_collection(bmain, group);
}
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
- do_version_scene_collection_to_collection(main, scene);
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ do_version_scene_collection_to_collection(bmain, scene);
}
}
#endif
}
-void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
+void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
bool use_collection_compat_28 = true;
- if (!MAIN_VERSION_ATLEAST(main, 280, 0)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
use_collection_compat_28 = false;
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
scene->r.gauss = 1.5f;
}
}
- if (!MAIN_VERSION_ATLEAST(main, 280, 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 1)) {
if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "bleedexp")) {
- for (Lamp *la = main->lamp.first; la; la = la->id.next) {
+ for (Lamp *la = bmain->lamp.first; la; la = la->id.next) {
la->bleedexp = 2.5f;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "GPUDOFSettings", "float", "ratio")) {
- for (Camera *ca = main->camera.first; ca; ca = ca->id.next) {
+ for (Camera *ca = bmain->camera.first; ca; ca = ca->id.next) {
ca->gpu_dof.ratio = 1.0f;
}
}
@@ -887,7 +891,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
/* MTexPoly now removed. */
if (DNA_struct_find(fd->filesdna, "MTexPoly")) {
const int cd_mtexpoly = 15; /* CD_MTEXPOLY, deprecated */
- for (Mesh *me = main->mesh.first; me; me = me->id.next) {
+ for (Mesh *me = bmain->mesh.first; me; me = me->id.next) {
/* If we have UV's, so this file will have MTexPoly layers too! */
if (me->mloopuv != NULL) {
CustomData_update_typemap(&me->pdata);
@@ -898,9 +902,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 280, 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 2)) {
if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "cascade_max_dist")) {
- for (Lamp *la = main->lamp.first; la; la = la->id.next) {
+ for (Lamp *la = bmain->lamp.first; la; la = la->id.next) {
la->cascade_max_dist = 1000.0f;
la->cascade_count = 4;
la->cascade_exponent = 0.8f;
@@ -909,7 +913,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "contact_dist")) {
- for (Lamp *la = main->lamp.first; la; la = la->id.next) {
+ for (Lamp *la = bmain->lamp.first; la; la = la->id.next) {
la->contact_dist = 1.0f;
la->contact_bias = 0.03f;
la->contact_spread = 0.2f;
@@ -918,7 +922,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
if (!DNA_struct_elem_find(fd->filesdna, "LightProbe", "float", "vis_bias")) {
- for (LightProbe *probe = main->lightprobe.first; probe; probe = probe->id.next) {
+ for (LightProbe *probe = bmain->lightprobe.first; probe; probe = probe->id.next) {
probe->vis_bias = 1.0f;
probe->vis_blur = 0.2f;
}
@@ -937,7 +941,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
* Also, metallic node is now unified into the principled node. */
eNTreeDoVersionErrors error = NTREE_DOVERSION_NO_ERROR;
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
for (bNode *node = ntree->nodes.first; node; node = node->next) {
if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ &&
@@ -986,7 +990,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
(DNA_struct_elem_find(fd->filesdna, "ViewLayer", "FreestyleConfig", "freestyle_config") == false) &&
DNA_struct_elem_find(fd->filesdna, "Scene", "ListBase", "view_layers"))
{
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
ViewLayer *view_layer;
for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
view_layer->flag |= VIEW_LAYER_FREESTYLE;
@@ -1001,15 +1005,15 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
#ifdef USE_COLLECTION_COMPAT_28
- if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(main, 280, 3)) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(bmain, 280, 3)) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
ViewLayer *view_layer;
for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
do_version_view_layer_visibility(view_layer);
}
}
- for (Collection *group = main->collection.first; group; group = group->id.next) {
+ for (Collection *group = bmain->collection.first; group; group = group->id.next) {
if (group->view_layer != NULL) {
do_version_view_layer_visibility(group->view_layer);
}
@@ -1017,14 +1021,14 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
#endif
- if (!MAIN_VERSION_ATLEAST(main, 280, 6)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 6)) {
if (DNA_struct_elem_find(fd->filesdna, "SpaceOops", "int", "filter") == false) {
bScreen *sc;
ScrArea *sa;
SpaceLink *sl;
/* Update files using invalid (outdated) outlinevis Outliner values. */
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
for (sa = sc->areabase.first; sa; sa = sa->next) {
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_OUTLINER) {
@@ -1046,12 +1050,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
if (!DNA_struct_elem_find(fd->filesdna, "LightProbe", "float", "intensity")) {
- for (LightProbe *probe = main->lightprobe.first; probe; probe = probe->id.next) {
+ for (LightProbe *probe = bmain->lightprobe.first; probe; probe = probe->id.next) {
probe->intensity = 1.0f;
}
}
- for (Object *ob = main->object.first; ob; ob = ob->id.next) {
+ for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
bConstraint *con, *con_next;
con = ob->constraints.first;
while (con) {
@@ -1066,12 +1070,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
if (!DNA_struct_elem_find(fd->filesdna, "Scene", "int", "orientation_index_custom")) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
scene->orientation_index_custom = -1;
}
}
- for (bScreen *sc = main->screen.first; sc; sc = sc->id.next) {
+ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
@@ -1081,7 +1085,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
/* Assume (demo) files written with 2.8 want to show
* Eevee renders in the viewport. */
- if (MAIN_VERSION_ATLEAST(main, 280, 0)) {
+ if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
v3d->drawtype = OB_MATERIAL;
}
}
@@ -1090,20 +1094,20 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 280, 7)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 7)) {
/* Render engine storage moved elsewhere and back during 2.8
* development, we assume any files saved in 2.8 had Eevee set
* as scene render engine. */
- if (MAIN_VERSION_ATLEAST(main, 280, 0)) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
}
}
}
- if (!MAIN_VERSION_ATLEAST(main, 280, 8)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 8)) {
/* Blender Internal removal */
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
if (STREQ(scene->r.engine, "BLENDER_RENDER") ||
STREQ(scene->r.engine, "BLENDER_GAME"))
{
@@ -1113,7 +1117,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
scene->r.bake_mode = 0;
}
- for (Tex *tex = main->tex.first; tex; tex = tex->id.next) {
+ for (Tex *tex = bmain->tex.first; tex; tex = tex->id.next) {
/* Removed envmap, pointdensity, voxeldata, ocean textures. */
if (ELEM(tex->type, 10, 14, 15, 16)) {
tex->type = 0;
@@ -1121,10 +1125,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 280, 11)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 11)) {
/* Remove info editor, but only if at the top of the window. */
- for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
/* Calculate window width/height from screen vertices */
int win_width = 0, win_height = 0;
for (ScrVert *vert = screen->vertbase.first; vert; vert = vert->next) {
@@ -1154,8 +1158,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 280, 11)) {
- for (Lamp *lamp = main->lamp.first; lamp; lamp = lamp->id.next) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 11)) {
+ for (Lamp *lamp = bmain->lamp.first; lamp; lamp = lamp->id.next) {
if (lamp->mode & (1 << 13)) { /* LA_SHAD_RAY */
lamp->mode |= LA_SHADOW;
lamp->mode &= ~(1 << 13);
@@ -1163,9 +1167,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 280, 12)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 12)) {
/* Remove tool property regions. */
- for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_CLIP)) {
@@ -1185,16 +1189,16 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 280, 13)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 13)) {
/* Initialize specular factor. */
if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "spec_fac")) {
- for (Lamp *la = main->lamp.first; la; la = la->id.next) {
+ for (Lamp *la = bmain->lamp.first; la; la = la->id.next) {
la->spec_fac = 1.0f;
}
}
/* Initialize new view3D options. */
- for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
@@ -1206,16 +1210,17 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
v3d->overlay.backwire_opacity = 0.5f;
v3d->overlay.normals_length = 0.1f;
+ v3d->overlay.flag = V3D_OVERLAY_LOOK_DEV;
}
}
}
}
if (!DNA_struct_find(fd->filesdna, "View3DCursor")) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
unit_qt(scene->cursor.rotation);
}
- for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
@@ -1228,34 +1233,34 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 280, 14)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 14)) {
if (!DNA_struct_elem_find(fd->filesdna, "Scene", "SceneDisplay", "display")) {
/* Initialize new scene.SceneDisplay */
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
copy_v3_v3(scene->display.light_direction, (float[3]){-M_SQRT1_3, -M_SQRT1_3, M_SQRT1_3});
}
}
if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "float", "shadow_shift")) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
scene->display.shadow_shift = 0.1;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "Object", "ObjectDisplay", "display")) {
/* Initialize new object.ObjectDisplay */
- for (Object *ob = main->object.first; ob; ob = ob->id.next) {
+ for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
ob->display.flag = OB_SHOW_SHADOW;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "transform_pivot_point")) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
scene->toolsettings->transform_pivot_point = V3D_AROUND_CENTER_MEAN;
}
}
if (!DNA_struct_find(fd->filesdna, "SceneEEVEE")) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
/* First set the default for all the properties. */
scene->eevee.gi_diffuse_bounces = 3;
@@ -1436,8 +1441,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "int", "matcap_icon")) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 15)) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
scene->display.matcap_icon = 1;
scene->display.matcap_type = CLAY_MATCAP_NONE;
scene->display.matcap_hue = 0.5f;
@@ -1449,10 +1455,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
scene->display.matcap_ssao_factor_edge = 1.0f;
scene->display.matcap_ssao_samples = 16;
}
- }
- if (!DNA_struct_elem_find(fd->filesdna, "SpaceOops", "short", "filter_id_type")) {
- for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_OUTLINER) {
@@ -1463,25 +1467,130 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
+
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ switch (scene->toolsettings->snap_mode) {
+ case 0: scene->toolsettings->snap_mode = SCE_SNAP_MODE_INCREMENT; break;
+ case 1: scene->toolsettings->snap_mode = SCE_SNAP_MODE_VERTEX ; break;
+ case 2: scene->toolsettings->snap_mode = SCE_SNAP_MODE_EDGE ; break;
+ case 3: scene->toolsettings->snap_mode = SCE_SNAP_MODE_FACE ; break;
+ case 4: scene->toolsettings->snap_mode = SCE_SNAP_MODE_VOLUME ; break;
+ }
+ switch (scene->toolsettings->snap_node_mode) {
+ case 5: scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_X; break;
+ case 6: scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_Y; break;
+ case 7: scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_X | SCE_SNAP_MODE_NODE_Y; break;
+ case 8: scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID ; break;
+ }
+ switch (scene->toolsettings->snap_uv_mode) {
+ case 0: scene->toolsettings->snap_uv_mode = SCE_SNAP_MODE_INCREMENT; break;
+ case 1: scene->toolsettings->snap_uv_mode = SCE_SNAP_MODE_VERTEX ; break;
+ }
+ }
+
+ ParticleSettings *part;
+ for (part = bmain->particle.first; part; part = part->id.next) {
+ part->shape_flag = PART_SHAPE_CLOSE_TIP;
+ part->shape = 0.0f;
+ part->rad_root = 1.0f;
+ part->rad_tip = 0.0f;
+ part->rad_scale = 0.01f;
+ }
}
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
- switch (scene->toolsettings->snap_mode) {
- case 0: scene->toolsettings->snap_mode = SCE_SNAP_MODE_INCREMENT; break;
- case 1: scene->toolsettings->snap_mode = SCE_SNAP_MODE_VERTEX ; break;
- case 2: scene->toolsettings->snap_mode = SCE_SNAP_MODE_EDGE ; break;
- case 3: scene->toolsettings->snap_mode = SCE_SNAP_MODE_FACE ; break;
- case 4: scene->toolsettings->snap_mode = SCE_SNAP_MODE_VOLUME ; break;
+ }
+ {
+ if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "roughness")) {
+ for (Material *mat = bmain->mat.first; mat; mat = mat->id.next) {
+ if (mat->use_nodes) {
+ if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
+ mat->roughness = mat->gloss_mir;
+ }
+ else {
+ mat->roughness = 0.25f;
+ }
+ }
+ else {
+ mat->roughness = 1.0f - mat->gloss_mir;
+ }
+ mat->metallic = mat->ray_mirror;
}
- switch (scene->toolsettings->snap_node_mode) {
- case 5: scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_X; break;
- case 6: scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_Y; break;
- case 7: scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_X | SCE_SNAP_MODE_NODE_Y; break;
- case 8: scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID ; break;
+
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.flag |= V3D_SHADING_SPECULAR_HIGHLIGHT;
+ }
+ }
+ }
}
- switch (scene->toolsettings->snap_uv_mode) {
- case 0: scene->toolsettings->snap_uv_mode = SCE_SNAP_MODE_INCREMENT; break;
- case 1: scene->toolsettings->snap_uv_mode = SCE_SNAP_MODE_VERTEX ; break;
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "xray_alpha")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.xray_alpha = 0.5f;
+ }
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "matcap[256]")) {
+ StudioLight *default_matcap = BKE_studiolight_find_first(STUDIOLIGHT_ORIENTATION_VIEWNORMAL);
+ /* when loading the internal file is loaded before the matcaps */
+ if (default_matcap) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ BLI_strncpy(v3d->shading.matcap, default_matcap->name, FILE_MAXFILE);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "wireframe_threshold")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.wireframe_threshold = 0.5f;
+ }
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "cavity_valley_factor")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.cavity_valley_factor = 1.0f;
+ v3d->shading.cavity_ridge_factor = 1.0f;
+ }
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "bone_selection_alpha")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.bone_selection_alpha = 0.5f;
+ }
+ }
+ }
}
}
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 764eaecd1e9..cbd6988655d 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -270,7 +270,7 @@ void BLO_update_defaults_startup_blend(Main *bmain)
{
Object *ob;
- ob = (Object *)BKE_libblock_find_name_ex(bmain, ID_OB, "Camera");
+ ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, "Camera");
if (ob) {
ob->rot[1] = 0.0f;
}
@@ -279,7 +279,7 @@ void BLO_update_defaults_startup_blend(Main *bmain)
{
Brush *br;
- br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Fill");
+ br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Fill");
if (!br) {
br = BKE_brush_add(bmain, "Fill", OB_MODE_TEXTURE_PAINT);
id_us_min(&br->id); /* fake user only */
@@ -288,14 +288,14 @@ void BLO_update_defaults_startup_blend(Main *bmain)
}
/* Vertex/Weight Paint */
- br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Average");
+ br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Average");
if (!br) {
br = BKE_brush_add(bmain, "Average", OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT);
id_us_min(&br->id); /* fake user only */
br->vertexpaint_tool = PAINT_BLEND_AVERAGE;
br->ob_mode = OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT;
}
- br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Smear");
+ br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Smear");
if (!br) {
br = BKE_brush_add(bmain, "Smear", OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT);
id_us_min(&br->id); /* fake user only */
@@ -303,49 +303,49 @@ void BLO_update_defaults_startup_blend(Main *bmain)
br->ob_mode = OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT;
}
- br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Mask");
+ br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Mask");
if (br) {
br->imagepaint_tool = PAINT_TOOL_MASK;
br->ob_mode |= OB_MODE_TEXTURE_PAINT;
}
/* remove polish brush (flatten/contrast does the same) */
- br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Polish");
+ br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Polish");
if (br) {
BKE_libblock_delete(bmain, br);
}
/* remove brush brush (huh?) from some modes (draw brushes do the same) */
- br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Brush");
+ br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Brush");
if (br) {
BKE_libblock_delete(bmain, br);
}
/* remove draw brush from texpaint (draw brushes do the same) */
- br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Draw");
+ br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Draw");
if (br) {
br->ob_mode &= ~OB_MODE_TEXTURE_PAINT;
}
/* rename twist brush to rotate brush to match rotate tool */
- br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Twist");
+ br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Twist");
if (br) {
BKE_libblock_rename(bmain, &br->id, "Rotate");
}
/* use original normal for grab brush (otherwise flickers with normal weighting). */
- br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Grab");
+ br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Grab");
if (br) {
br->flag |= BRUSH_ORIGINAL_NORMAL;
}
/* increase strength, better for smoothing method */
- br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Blur");
+ br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Blur");
if (br) {
br->alpha = 1.0f;
}
- br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Flatten/Contrast");
+ br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Flatten/Contrast");
if (br) {
br->flag |= BRUSH_ACCUMULATE;
}
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 9e0c3f3ccdc..bc69b1d99fc 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -483,13 +483,13 @@ void blo_do_version_old_trackto_to_constraints(Object *ob)
ob->track = NULL;
}
-void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
+void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
{
/* WATCH IT!!!: pointers from libdata have not been converted */
- if (main->versionfile == 100) {
+ if (bmain->versionfile == 100) {
/* tex->extend and tex->imageflag have changed: */
- Tex *tex = main->tex.first;
+ Tex *tex = bmain->tex.first;
while (tex) {
if (tex->id.tag & LIB_TAG_NEED_LINK) {
@@ -508,9 +508,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 101) {
+ if (bmain->versionfile <= 101) {
/* frame mapping */
- Scene *sce = main->scene.first;
+ Scene *sce = bmain->scene.first;
while (sce) {
sce->r.framapto = 100;
sce->r.images = 100;
@@ -519,9 +519,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 103) {
+ if (bmain->versionfile <= 103) {
/* new variable in object: colbits */
- Object *ob = main->object.first;
+ Object *ob = bmain->object.first;
int a;
while (ob) {
ob->colbits = 0;
@@ -535,9 +535,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 104) {
+ if (bmain->versionfile <= 104) {
/* timeoffs moved */
- Object *ob = main->object.first;
+ Object *ob = bmain->object.first;
while (ob) {
if (ob->transflag & 1) {
ob->transflag -= 1;
@@ -546,8 +546,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 105) {
- Object *ob = main->object.first;
+ if (bmain->versionfile <= 105) {
+ Object *ob = bmain->object.first;
while (ob) {
ob->dupon = 1;
ob->dupoff = 0;
@@ -557,9 +557,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 106) {
+ if (bmain->versionfile <= 106) {
/* mcol changed */
- Mesh *me = main->mesh.first;
+ Mesh *me = bmain->mesh.first;
while (me) {
if (me->mcol)
vcol_to_fcol(me);
@@ -568,9 +568,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
- if (main->versionfile <= 107) {
+ if (bmain->versionfile <= 107) {
Object *ob;
- ob = main->object.first;
+ ob = bmain->object.first;
while (ob) {
if (ob->dt == 0)
ob->dt = OB_SOLID;
@@ -579,9 +579,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
- if (main->versionfile <= 109) {
+ if (bmain->versionfile <= 109) {
/* new variable: gridlines */
- bScreen *sc = main->screen.first;
+ bScreen *sc = bmain->screen.first;
while (sc) {
ScrArea *sa = sc->areabase.first;
while (sa) {
@@ -601,8 +601,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 134) {
- Tex *tex = main->tex.first;
+ if (bmain->versionfile <= 134) {
+ Tex *tex = bmain->tex.first;
while (tex) {
if ((tex->rfac == 0.0f) &&
(tex->gfac == 0.0f) &&
@@ -617,9 +617,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 140) {
+ if (bmain->versionfile <= 140) {
/* r-g-b-fac in texture */
- Tex *tex = main->tex.first;
+ Tex *tex = bmain->tex.first;
while (tex) {
if ((tex->rfac == 0.0f) &&
(tex->gfac == 0.0f) &&
@@ -634,8 +634,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 153) {
- Scene *sce = main->scene.first;
+ if (bmain->versionfile <= 153) {
+ Scene *sce = bmain->scene.first;
while (sce) {
if (sce->r.blurfac == 0.0f)
sce->r.blurfac = 1.0f;
@@ -643,8 +643,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 163) {
- Scene *sce = main->scene.first;
+ if (bmain->versionfile <= 163) {
+ Scene *sce = bmain->scene.first;
while (sce) {
if (sce->r.frs_sec == 0)
sce->r.frs_sec = 25;
@@ -652,16 +652,16 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 164) {
- Mesh *me = main->mesh.first;
+ if (bmain->versionfile <= 164) {
+ Mesh *me = bmain->mesh.first;
while (me) {
me->smoothresh = 30;
me = me->id.next;
}
}
- if (main->versionfile <= 165) {
- Mesh *me = main->mesh.first;
+ if (bmain->versionfile <= 165) {
+ Mesh *me = bmain->mesh.first;
TFace *tface;
int nr;
char *cp;
@@ -687,8 +687,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 169) {
- Mesh *me = main->mesh.first;
+ if (bmain->versionfile <= 169) {
+ Mesh *me = bmain->mesh.first;
while (me) {
if (me->subdiv == 0)
me->subdiv = 1;
@@ -696,8 +696,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 169) {
- bScreen *sc = main->screen.first;
+ if (bmain->versionfile <= 169) {
+ bScreen *sc = bmain->screen.first;
while (sc) {
ScrArea *sa = sc->areabase.first;
while (sa) {
@@ -715,8 +715,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 170) {
- Object *ob = main->object.first;
+ if (bmain->versionfile <= 170) {
+ Object *ob = bmain->object.first;
PartEff *paf;
while (ob) {
paf = blo_do_version_give_parteff_245(ob);
@@ -729,8 +729,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 171) {
- bScreen *sc = main->screen.first;
+ if (bmain->versionfile <= 171) {
+ bScreen *sc = bmain->screen.first;
while (sc) {
ScrArea *sa = sc->areabase.first;
while (sa) {
@@ -748,9 +748,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 173) {
+ if (bmain->versionfile <= 173) {
int a, b;
- Mesh *me = main->mesh.first;
+ Mesh *me = bmain->mesh.first;
while (me) {
if (me->tface) {
TFace *tface = me->tface;
@@ -765,10 +765,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 204) {
+ if (bmain->versionfile <= 204) {
bSound *sound;
- sound = main->sound.first;
+ sound = bmain->sound.first;
while (sound) {
if (sound->volume < 0.01f) {
sound->volume = 1.0f;
@@ -777,11 +777,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 212) {
+ if (bmain->versionfile <= 212) {
bSound *sound;
Mesh *me;
- sound = main->sound.first;
+ sound = bmain->sound.first;
while (sound) {
sound->max_gain = 1.0;
sound->min_gain = 0.0;
@@ -800,7 +800,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
* it a subsurf, and reset the subdiv level because subsurf
* takes a lot more work to calculate.
*/
- for (me = main->mesh.first; me; me = me->id.next) {
+ for (me = bmain->mesh.first; me; me = me->id.next) {
if (me->flag & ME_SMESH) {
me->flag &= ~ME_SMESH;
me->flag |= ME_SUBSURF;
@@ -816,14 +816,14 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 220) {
+ if (bmain->versionfile <= 220) {
Mesh *me;
/* Began using alpha component of vertex colors, but
* old file vertex colors are undefined, reset them
* to be fully opaque. -zr
*/
- for (me = main->mesh.first; me; me = me->id.next) {
+ for (me = bmain->mesh.first; me; me = me->id.next) {
if (me->mcol) {
int i;
@@ -848,22 +848,22 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 223) {
+ if (bmain->versionfile <= 223) {
VFont *vf;
- for (vf = main->vfont.first; vf; vf = vf->id.next) {
+ for (vf = bmain->vfont.first; vf; vf = vf->id.next) {
if (STREQ(vf->name + strlen(vf->name) - 6, ".Bfont")) {
strcpy(vf->name, FO_BUILTIN_NAME);
}
}
}
- if (main->versionfile <= 224) {
+ if (bmain->versionfile <= 224) {
bSound *sound;
Scene *sce;
Mesh *me;
bScreen *sc;
- for (sound = main->sound.first; sound; sound = sound->id.next) {
+ for (sound = bmain->sound.first; sound; sound = sound->id.next) {
if (sound->packedfile) {
if (sound->newpackedfile == NULL) {
sound->newpackedfile = sound->packedfile;
@@ -872,17 +872,17 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
/* Make sure that old subsurf meshes don't have zero subdivision level for rendering */
- for (me = main->mesh.first; me; me = me->id.next) {
+ for (me = bmain->mesh.first; me; me = me->id.next) {
if ((me->flag & ME_SUBSURF) && (me->subdivr == 0))
me->subdivr = me->subdiv;
}
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
sce->r.stereomode = 1; // no stereo
}
/* some oldfile patch, moved from set_func_space */
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
@@ -898,7 +898,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 227) {
+ if (bmain->versionfile <= 227) {
Scene *sce;
bScreen *sc;
Object *ob;
@@ -906,7 +906,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
/* As of now, this insures that the transition from the old Track system
* to the new full constraint Track is painless for everyone. - theeth
*/
- ob = main->object.first;
+ ob = bmain->object.first;
while (ob) {
ListBase *list;
@@ -949,13 +949,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
ob = ob->id.next;
}
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
sce->audio.mixrate = 48000;
sce->audio.flag |= AUDIO_SCRUB;
}
/* patch for old wrong max view2d settings, allows zooming out more */
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
@@ -975,14 +975,14 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 228) {
+ if (bmain->versionfile <= 228) {
bScreen *sc;
Object *ob;
/* As of now, this insures that the transition from the old Track system
* to the new full constraint Track is painless for everyone.
*/
- ob = main->object.first;
+ ob = bmain->object.first;
while (ob) {
ListBase *list;
@@ -1022,7 +1022,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
/* convert old mainb values for new button panels */
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
@@ -1089,19 +1089,17 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
* check apart from the do_versions()
*/
- if (main->versionfile <= 230) {
+ if (bmain->versionfile <= 230) {
bScreen *sc;
/* new variable blockscale, for panels in any area */
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->blockscale == 0.0f)
- sl->blockscale = 0.7f;
/* added: 5x better zoom in for action */
if (sl->spacetype == SPACE_ACTION) {
SpaceAction *sac = (SpaceAction *)sl;
@@ -1112,9 +1110,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 231) {
+ if (bmain->versionfile <= 231) {
/* new bit flags for showing/hiding grid floor and axes */
- bScreen *sc = main->screen.first;
+ bScreen *sc = bmain->screen.first;
while (sc) {
ScrArea *sa = sc->areabase.first;
@@ -1139,8 +1137,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 231) {
- bScreen *sc = main->screen.first;
+ if (bmain->versionfile <= 231) {
+ bScreen *sc = bmain->screen.first;
/* new bit flags for showing/hiding grid floor and axes */
@@ -1167,9 +1165,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 232) {
- Tex *tex = main->tex.first;
- World *wrld = main->world.first;
+ if (bmain->versionfile <= 232) {
+ Tex *tex = bmain->tex.first;
+ World *wrld = bmain->world.first;
bScreen *sc;
while (tex) {
@@ -1206,14 +1204,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
/* new variable blockscale, for panels in any area, do again because new
* areas didnt initialize it to 0.7 yet
*/
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->blockscale == 0.0f)
- sl->blockscale = 0.7f;
-
/* added: 5x better zoom in for nla */
if (sl->spacetype == SPACE_NLA) {
SpaceNla *snla = (SpaceNla *) sl;
@@ -1224,10 +1219,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 233) {
+ if (bmain->versionfile <= 233) {
bScreen *sc;
- Material *ma = main->mat.first;
- /* Object *ob = main->object.first; */
+ Material *ma = bmain->mat.first;
+ /* Object *ob = bmain->object.first; */
while (ma) {
if (ma->pr_lamp == 0)
@@ -1235,7 +1230,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
ma = ma->id.next;
}
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -1249,10 +1244,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 234) {
+ if (bmain->versionfile <= 234) {
bScreen *sc;
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -1271,9 +1266,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 235) {
- Tex *tex = main->tex.first;
- Scene *sce = main->scene.first;
+ if (bmain->versionfile <= 235) {
+ Tex *tex = bmain->tex.first;
+ Scene *sce = bmain->scene.first;
Sequence *seq;
Editing *ed;
@@ -1297,9 +1292,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 236) {
+ if (bmain->versionfile <= 236) {
Object *ob;
- Camera *cam = main->camera.first;
+ Camera *cam = bmain->camera.first;
while (cam) {
if (cam->ortho_scale == 0.0f) {
@@ -1313,7 +1308,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
/* set time line var */
/* softbody init new vars */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->soft) {
if (ob->soft->defgoal == 0.0f)
ob->soft->defgoal = 0.7f;
@@ -1336,20 +1331,20 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 237) {
+ if (bmain->versionfile <= 237) {
bArmature *arm;
bConstraint *con;
Object *ob;
Bone *bone;
/* armature recode checks */
- for (arm = main->armature.first; arm; arm = arm->id.next) {
+ for (arm = bmain->armature.first; arm; arm = arm->id.next) {
BKE_armature_where_is(arm);
for (bone = arm->bonebase.first; bone; bone = bone->next)
do_version_bone_head_tail_237(bone);
}
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->parent) {
Object *parent = blo_do_versions_newlibadr(fd, lib, ob->parent);
if (parent && parent->type == OB_LATTICE)
@@ -1359,7 +1354,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
/* btw. armature_rebuild_pose is further only called on leave editmode */
if (ob->type == OB_ARMATURE) {
if (ob->pose)
- BKE_pose_tag_recalc(main, ob->pose);
+ BKE_pose_tag_recalc(bmain, ob->pose);
/* cannot call stuff now (pointers!), done in setup_app_data */
ob->id.recalc |= ID_RECALC_ALL;
@@ -1410,13 +1405,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 238) {
+ if (bmain->versionfile <= 238) {
Lattice *lt;
Object *ob;
bArmature *arm;
Mesh *me;
Key *key;
- Scene *sce = main->scene.first;
+ Scene *sce = bmain->scene.first;
while (sce) {
if (sce->toolsettings == NULL) {
@@ -1426,7 +1421,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
sce = sce->id.next;
}
- for (lt = main->latt.first; lt; lt = lt->id.next) {
+ for (lt = bmain->latt.first; lt; lt = lt->id.next) {
if (lt->fu == 0.0f && lt->fv == 0.0f && lt->fw == 0.0f) {
calc_lat_fudu(lt->flag, lt->pntsu, &lt->fu, &lt->du);
calc_lat_fudu(lt->flag, lt->pntsv, &lt->fv, &lt->dv);
@@ -1434,7 +1429,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
PartEff *paf;
@@ -1483,7 +1478,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
data->rootbone = -1;
/* update_pose_etc handles rootbone == -1 */
- BKE_pose_tag_recalc(main, ob->pose);
+ BKE_pose_tag_recalc(bmain, ob->pose);
}
}
}
@@ -1501,12 +1496,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- for (arm = main->armature.first; arm; arm = arm->id.next) {
+ for (arm = bmain->armature.first; arm; arm = arm->id.next) {
bone_version_238(&arm->bonebase);
arm->deformflag |= ARM_DEF_VGROUP;
}
- for (me = main->mesh.first; me; me = me->id.next) {
+ for (me = bmain->mesh.first; me; me = me->id.next) {
if (!me->medge) {
BKE_mesh_calc_edges_legacy(me, true); /* true = use mface->edcode */
}
@@ -1515,7 +1510,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- for (key = main->key.first; key; key = key->id.next) {
+ for (key = bmain->key.first; key; key = key->id.next) {
KeyBlock *kb;
int index = 1;
@@ -1534,15 +1529,15 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 239) {
+ if (bmain->versionfile <= 239) {
bArmature *arm;
Object *ob;
- Scene *sce = main->scene.first;
- Camera *cam = main->camera.first;
+ Scene *sce = bmain->scene.first;
+ Camera *cam = bmain->camera.first;
int set_passepartout = 0;
/* deformflag is local in modifier now */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
@@ -1558,7 +1553,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
/* updating stepsize for ghost drawing */
- for (arm = main->armature.first; arm; arm = arm->id.next) {
+ for (arm = bmain->armature.first; arm; arm = arm->id.next) {
if (arm->ghostsize == 0)
arm->ghostsize = 1;
bone_version_239(&arm->bonebase);
@@ -1587,7 +1582,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 241) {
+ if (bmain->versionfile <= 241) {
Object *ob;
Scene *sce;
Lamp *la;
@@ -1595,12 +1590,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
bNodeTree *ntree;
/* updating layers still */
- for (arm = main->armature.first; arm; arm = arm->id.next) {
+ for (arm = bmain->armature.first; arm; arm = arm->id.next) {
bone_version_239(&arm->bonebase);
if (arm->layer == 0)
arm->layer = 1;
}
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->audio.mixrate == 0)
sce->audio.mixrate = 48000;
@@ -1627,15 +1622,15 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next)
ntree_version_241(ntree);
- for (la = main->lamp.first; la; la = la->id.next)
+ for (la = bmain->lamp.first; la; la = la->id.next)
if (la->buffers == 0)
la->buffers = 1;
/* for empty drawsize and drawtype */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->empty_drawsize == 0.0f) {
ob->empty_drawtype = OB_ARROWS;
ob->empty_drawsize = 1.0;
@@ -1643,9 +1638,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
/* during 2.41 images with this name were used for viewer node output, lets fix that */
- if (main->versionfile == 241) {
+ if (bmain->versionfile == 241) {
Image *ima;
- for (ima = main->image.first; ima; ima = ima->id.next) {
+ for (ima = bmain->image.first; ima; ima = ima->id.next) {
if (STREQ(ima->name, "Compositor")) {
strcpy(ima->id.name + 2, "Viewer Node");
strcpy(ima->name, "Viewer Node");
@@ -1654,7 +1649,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 242) {
+ if (bmain->versionfile <= 242) {
Scene *sce;
bScreen *sc;
Object *ob;
@@ -1668,7 +1663,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
bNodeTree *ntree;
int a;
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
sa = sc->areabase.first;
while (sa) {
@@ -1685,7 +1680,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->toolsettings->select_thresh == 0.0f)
sce->toolsettings->select_thresh = 0.01f;
@@ -1699,11 +1694,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
ntree_version_242(sce->nodetree);
}
- for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next)
ntree_version_242(ntree);
/* add default radius values to old curve points */
- for (cu = main->curve.first; cu; cu = cu->id.next) {
+ for (cu = bmain->curve.first; cu; cu = cu->id.next) {
for (nu = cu->nurb.first; nu; nu = nu->next) {
if (nu) {
if (nu->bezt) {
@@ -1722,7 +1717,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
ListBase *list;
list = &ob->constraints;
@@ -1810,25 +1805,25 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
- for (ma = main->mat.first; ma; ma = ma->id.next) {
+ for (ma = bmain->mat.first; ma; ma = ma->id.next) {
if (ma->nodetree)
ntree_version_242(ma->nodetree);
}
- for (me = main->mesh.first; me; me = me->id.next)
+ for (me = bmain->mesh.first; me; me = me->id.next)
customdata_version_242(me);
- for (collection = main->collection.first; collection; collection = collection->id.next)
+ for (collection = bmain->collection.first; collection; collection = collection->id.next)
if (collection->layer == 0)
collection->layer = (1 << 20) - 1;
/* now, subversion control! */
- if (main->subversionfile < 3) {
+ if (bmain->subversionfile < 3) {
Image *ima;
Tex *tex;
/* Image refactor initialize */
- for (ima = main->image.first; ima; ima = ima->id.next) {
+ for (ima = bmain->image.first; ima; ima = ima->id.next) {
ima->source = IMA_SRC_FILE;
ima->type = IMA_TYPE_IMAGE;
@@ -1845,7 +1840,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- for (tex = main->tex.first; tex; tex = tex->id.next) {
+ for (tex = bmain->tex.first; tex; tex = tex->id.next) {
if (tex->type == TEX_IMAGE && tex->ima) {
ima = blo_do_versions_newlibadr(fd, lib, tex->ima);
if (tex->imaflag & TEX_ANIM5_)
@@ -1861,17 +1856,17 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
tex->iuser.sfra = tex->sfra;
tex->iuser.cycl = (tex->imaflag & TEX_ANIMCYCLIC_)!=0;
}
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->nodetree)
do_version_ntree_242_2(sce->nodetree);
}
- for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next)
do_version_ntree_242_2(ntree);
- for (ma = main->mat.first; ma; ma = ma->id.next)
+ for (ma = bmain->mat.first; ma; ma = ma->id.next)
if (ma->nodetree)
do_version_ntree_242_2(ma->nodetree);
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
@@ -1884,8 +1879,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->subversionfile < 4) {
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ if (bmain->subversionfile < 4) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
sce->r.bake_mode = 1; /* prevent to include render stuff here */
sce->r.bake_filter = 16;
sce->r.bake_flag = R_BAKE_CLEAR;
@@ -1893,8 +1888,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 243) {
- Object *ob = main->object.first;
+ if (bmain->versionfile <= 243) {
+ Object *ob = bmain->object.first;
for (; ob; ob = ob->id.next) {
bDeformGroup *curdef;
@@ -1906,7 +1901,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 243 || main->subversionfile < 1) {
+ if (bmain->versionfile < 243 || bmain->subversionfile < 1) {
ModifierData *md;
/* translate old mirror modifier axis values to new flags */
@@ -1933,20 +1928,20 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
/* render layer added, this is not the active layer */
- if (main->versionfile <= 243 || main->subversionfile < 2) {
+ if (bmain->versionfile <= 243 || bmain->subversionfile < 2) {
Mesh *me;
- for (me = main->mesh.first; me; me = me->id.next)
+ for (me = bmain->mesh.first; me; me = me->id.next)
customdata_version_243(me);
}
}
- if (main->versionfile <= 244) {
+ if (bmain->versionfile <= 244) {
bScreen *sc;
- if (main->versionfile != 244 || main->subversionfile < 2) {
+ if (bmain->versionfile != 244 || bmain->subversionfile < 2) {
/* correct older action editors - incorrect scrolling */
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
sa = sc->areabase.first;
while (sa) {
@@ -1969,7 +1964,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 245) {
+ if (bmain->versionfile <= 245) {
Scene *sce;
Object *ob;
Image *ima;
@@ -1983,10 +1978,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
ParticleSystem *psys;
/* unless the file was created 2.44.3 but not 2.45, update the constraints */
- if (!(main->versionfile == 244 && main->subversionfile == 3) &&
- ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile == 0)) )
+ if (!(bmain->versionfile == 244 && bmain->subversionfile == 3) &&
+ ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile == 0)) )
{
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ListBase *list;
list = &ob->constraints;
@@ -2053,16 +2048,16 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
/* fix all versions before 2.45 */
- if (main->versionfile != 245) {
+ if (bmain->versionfile != 245) {
/* repair preview from 242 - 244*/
- for (ima = main->image.first; ima; ima = ima->id.next) {
+ for (ima = bmain->image.first; ima; ima = ima->id.next) {
ima->preview = NULL;
}
}
/* add point caches */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->soft && !ob->soft->pointcache)
ob->soft->pointcache = BKE_ptcache_add(&ob->soft->ptcaches);
@@ -2090,7 +2085,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
/* Copy over old per-level multires vertex data
* into a single vertex array in struct Multires */
- for (me = main->mesh.first; me; me = me->id.next) {
+ for (me = bmain->mesh.first; me; me = me->id.next) {
if (me->mr && !me->mr->verts) {
MultiresLevel *lvl = me->mr->levels.last;
if (lvl) {
@@ -2105,8 +2100,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile != 245 || main->subversionfile < 1) {
- for (la = main->lamp.first; la; la = la->id.next) {
+ if (bmain->versionfile != 245 || bmain->subversionfile < 1) {
+ for (la = bmain->lamp.first; la; la = la->id.next) {
la->falloff_type = LA_FALLOFF_INVLINEAR;
if (la->curfalloff == NULL) {
@@ -2116,18 +2111,18 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- for (ma = main->mat.first; ma; ma = ma->id.next) {
+ for (ma = bmain->mat.first; ma; ma = ma->id.next) {
if (ma->gloss_mir == 0.0f) {
ma->gloss_mir = 1.0f;
}
}
- for (part = main->particle.first; part; part = part->id.next) {
+ for (part = bmain->particle.first; part; part = part->id.next) {
if (part->ren_child_nbr == 0)
part->ren_child_nbr = part->child_nbr;
}
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->nodetree)
ntree_version_245(fd, lib, sce->nodetree);
@@ -2137,18 +2132,18 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next)
ntree_version_245(fd, lib, ntree);
/* fix for temporary flag changes during 245 cycle */
- for (ima = main->image.first; ima; ima = ima->id.next) {
+ for (ima = bmain->image.first; ima; ima = ima->id.next) {
if (ima->flag & IMA_OLD_PREMUL) {
ima->flag &= ~IMA_OLD_PREMUL;
ima->alpha_mode = IMA_ALPHA_STRAIGHT;
}
}
- for (tex = main->tex.first; tex; tex = tex->id.next) {
+ for (tex = bmain->tex.first; tex; tex = tex->id.next) {
if (tex->iuser.flag & IMA_OLD_PREMUL) {
tex->iuser.flag &= ~IMA_OLD_PREMUL;
}
@@ -2161,24 +2156,24 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 2)) {
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 2)) {
Image *ima;
/* initialize 1:1 Aspect */
- for (ima = main->image.first; ima; ima = ima->id.next) {
+ for (ima = bmain->image.first; ima; ima = ima->id.next) {
ima->aspx = ima->aspy = 1.0f;
}
}
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 4)) {
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 4)) {
bArmature *arm;
ModifierData *md;
Object *ob;
- for (arm = main->armature.first; arm; arm = arm->id.next)
+ for (arm = bmain->armature.first; arm; arm = arm->id.next)
arm->deformflag |= ARM_DEF_B_BONE_REST;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Armature)
((ArmatureModifierData*) md)->deformflag |= ARM_DEF_B_BONE_REST;
@@ -2186,10 +2181,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 5)) {
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 5)) {
/* foreground color needs to be something other then black */
Scene *sce;
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8f;
sce->r.fg_stamp[3] = 1.0f; /* don't use text alpha yet */
sce->r.bg_stamp[3] = 0.25f; /* make sure the background has full alpha */
@@ -2197,21 +2192,21 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 6)) {
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 6)) {
Scene *sce;
/* fix frs_sec_base */
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->r.frs_sec_base == 0) {
sce->r.frs_sec_base = 1;
}
}
}
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 7)) {
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 7)) {
Object *ob;
bPoseChannel *pchan;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->pose) {
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
do_version_constraints_245(&pchan->constraints);
@@ -2236,12 +2231,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 8)) {
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 8)) {
Scene *sce;
Object *ob;
PartEff *paf = NULL;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->soft && ob->soft->keys) {
SoftBody *sb = ob->soft;
int k;
@@ -2268,7 +2263,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
psys = MEM_callocN(sizeof(ParticleSystem), "particle_system");
psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
- part = psys->part = BKE_particlesettings_add(main, "ParticleSettings");
+ part = psys->part = BKE_particlesettings_add(bmain, "ParticleSettings");
/* needed for proper libdata lookup */
blo_do_versions_oldnewmap_insert(fd->libmap, psys->part, psys->part, 0);
@@ -2348,7 +2343,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
/* dupliobjects */
if (ob->transflag & OB_DUPLIVERTS) {
- Object *dup = main->object.first;
+ Object *dup = bmain->object.first;
for (; dup; dup = dup->id.next) {
if (ob == blo_do_versions_newlibadr(fd, lib, dup->parent)) {
@@ -2376,7 +2371,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
ParticleEditSettings *pset = &sce->toolsettings->particle;
int a;
@@ -2398,20 +2393,20 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 10)) {
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 10)) {
Object *ob;
/* dupliface scale */
- for (ob = main->object.first; ob; ob = ob->id.next)
+ for (ob = bmain->object.first; ob; ob = ob->id.next)
ob->dupfacesca = 1.0f;
}
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 11)) {
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) {
Object *ob;
bActionStrip *strip;
/* nla-strips - scale */
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
for (strip = ob->nlastrips.first; strip; strip = strip->next) {
float length, actlength, repeat;
@@ -2436,11 +2431,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 14)) {
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 14)) {
Scene *sce;
Sequence *seq;
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
SEQ_BEGIN (sce->ed, seq)
{
if (seq->blend_mode == 0)
@@ -2451,39 +2446,39 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
/* fix broken group lengths in id properties */
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 15)) {
- idproperties_fix_group_lengths(main->scene);
- idproperties_fix_group_lengths(main->library);
- idproperties_fix_group_lengths(main->object);
- idproperties_fix_group_lengths(main->mesh);
- idproperties_fix_group_lengths(main->curve);
- idproperties_fix_group_lengths(main->mball);
- idproperties_fix_group_lengths(main->mat);
- idproperties_fix_group_lengths(main->tex);
- idproperties_fix_group_lengths(main->image);
- idproperties_fix_group_lengths(main->latt);
- idproperties_fix_group_lengths(main->lamp);
- idproperties_fix_group_lengths(main->camera);
- idproperties_fix_group_lengths(main->ipo);
- idproperties_fix_group_lengths(main->key);
- idproperties_fix_group_lengths(main->world);
- idproperties_fix_group_lengths(main->screen);
- idproperties_fix_group_lengths(main->vfont);
- idproperties_fix_group_lengths(main->text);
- idproperties_fix_group_lengths(main->sound);
- idproperties_fix_group_lengths(main->collection);
- idproperties_fix_group_lengths(main->armature);
- idproperties_fix_group_lengths(main->action);
- idproperties_fix_group_lengths(main->nodetree);
- idproperties_fix_group_lengths(main->brush);
- idproperties_fix_group_lengths(main->particle);
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 15)) {
+ idproperties_fix_group_lengths(bmain->scene);
+ idproperties_fix_group_lengths(bmain->library);
+ idproperties_fix_group_lengths(bmain->object);
+ idproperties_fix_group_lengths(bmain->mesh);
+ idproperties_fix_group_lengths(bmain->curve);
+ idproperties_fix_group_lengths(bmain->mball);
+ idproperties_fix_group_lengths(bmain->mat);
+ idproperties_fix_group_lengths(bmain->tex);
+ idproperties_fix_group_lengths(bmain->image);
+ idproperties_fix_group_lengths(bmain->latt);
+ idproperties_fix_group_lengths(bmain->lamp);
+ idproperties_fix_group_lengths(bmain->camera);
+ idproperties_fix_group_lengths(bmain->ipo);
+ idproperties_fix_group_lengths(bmain->key);
+ idproperties_fix_group_lengths(bmain->world);
+ idproperties_fix_group_lengths(bmain->screen);
+ idproperties_fix_group_lengths(bmain->vfont);
+ idproperties_fix_group_lengths(bmain->text);
+ idproperties_fix_group_lengths(bmain->sound);
+ idproperties_fix_group_lengths(bmain->collection);
+ idproperties_fix_group_lengths(bmain->armature);
+ idproperties_fix_group_lengths(bmain->action);
+ idproperties_fix_group_lengths(bmain->nodetree);
+ idproperties_fix_group_lengths(bmain->brush);
+ idproperties_fix_group_lengths(bmain->particle);
}
/* convert fluids to modifier */
- if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) {
+ if (bmain->versionfile < 246 || (bmain->versionfile == 246 && bmain->subversionfile < 1)) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->fluidsimSettings) {
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifier_new(eModifierType_Fluidsim);
BLI_addhead(&ob->modifiers, (ModifierData *)fluidmd);
@@ -2500,20 +2495,20 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) {
+ if (bmain->versionfile < 246 || (bmain->versionfile == 246 && bmain->subversionfile < 1)) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->pd && (ob->pd->forcefield == PFIELD_WIND))
ob->pd->f_noise = 0.0f;
}
}
/* set the curve radius interpolation to 2.47 default - easy */
- if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 6)) {
+ if (bmain->versionfile < 247 || (bmain->versionfile == 247 && bmain->subversionfile < 6)) {
Curve *cu;
Nurb *nu;
- for (cu = main->curve.first; cu; cu = cu->id.next) {
+ for (cu = bmain->curve.first; cu; cu = cu->id.next) {
for (nu = cu->nurb.first; nu; nu = nu->next) {
if (nu) {
nu->radius_interp = 3;
@@ -2531,21 +2526,21 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 2)) {
+ if (bmain->versionfile < 248 || (bmain->versionfile == 248 && bmain->subversionfile < 2)) {
Scene *sce;
/* Note, these will need to be added for painting */
- for (sce = main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
sce->toolsettings->imapaint.seam_bleed = 2;
sce->toolsettings->imapaint.normal_angle = 80;
}
}
- if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) {
+ if (bmain->versionfile < 248 || (bmain->versionfile == 248 && bmain->subversionfile < 3)) {
bScreen *sc;
/* adjust default settings for Animation Editors */
- for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
@@ -2580,17 +2575,17 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
/* correct introduce of seed for wind force */
- if (main->versionfile < 249 && main->subversionfile < 1) {
+ if (bmain->versionfile < 249 && bmain->subversionfile < 1) {
Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->pd)
ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer())) + 1) % 128;
}
}
- if (main->versionfile < 249 && main->subversionfile < 2) {
- Scene *sce = main->scene.first;
+ if (bmain->versionfile < 249 && bmain->subversionfile < 2) {
+ Scene *sce = bmain->scene.first;
Sequence *seq;
Editing *ed;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index de1699e24b7..6abcf6cfa02 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2762,14 +2762,19 @@ static void write_soops(WriteData *wd, SpaceOops *so)
}
}
+static void write_panel_list(WriteData *wd, ListBase *lb)
+{
+ for (Panel *pa = lb->first; pa; pa = pa->next) {
+ writestruct(wd, DATA, Panel, 1, pa);
+ write_panel_list(wd, &pa->children);
+ }
+}
+
static void write_area_regions(WriteData *wd, ScrArea *area)
{
for (ARegion *region = area->regionbase.first; region; region = region->next) {
write_region(wd, region, area->spacetype);
-
- for (Panel *pa = region->panels.first; pa; pa = pa->next) {
- writestruct(wd, DATA, Panel, 1, pa);
- }
+ write_panel_list(wd, &region->panels);
for (PanelCategoryStack *pc_act = region->panels_category_active.first; pc_act; pc_act = pc_act->next) {
writestruct(wd, DATA, PanelCategoryStack, 1, pc_act);
@@ -4088,7 +4093,7 @@ bool BLO_write_file(
* we should not have any relative paths, but if there
* is somehow, an invalid or empty G.main->name it will
* print an error, don't try make the absolute in this case. */
- BKE_bpath_absolute_convert(mainvar, G.main->name, NULL);
+ BKE_bpath_absolute_convert(mainvar, BKE_main_blendfile_path_from_global(), NULL);
}
}
}
diff --git a/source/blender/blentranslation/BLT_lang.h b/source/blender/blentranslation/BLT_lang.h
index fddb18d382f..72b4e5b39bc 100644
--- a/source/blender/blentranslation/BLT_lang.h
+++ b/source/blender/blentranslation/BLT_lang.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/blentranslation/BLT_translation.h b/source/blender/blentranslation/BLT_translation.h
index ba4ae964842..cf9e3f6a66d 100644
--- a/source/blender/blentranslation/BLT_translation.h
+++ b/source/blender/blentranslation/BLT_translation.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/blentranslation/intern/blt_lang.c b/source/blender/blentranslation/intern/blt_lang.c
index 74c2b4b7472..916de3a5d20 100644
--- a/source/blender/blentranslation/intern/blt_lang.c
+++ b/source/blender/blentranslation/intern/blt_lang.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation.
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/blentranslation/intern/blt_translation.c b/source/blender/blentranslation/intern/blt_translation.c
index c552bac25b0..9175585f1b3 100644
--- a/source/blender/blentranslation/intern/blt_translation.c
+++ b/source/blender/blentranslation/intern/blt_translation.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index 8159aae1ab8..5ff1d2c970f 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -121,7 +121,7 @@ typedef struct BMEdge {
/* the list of loops around the edge (use l->radial_prev/next)
* to access the other loops using the edge */
struct BMLoop *l;
-
+
/* disk cycle pointers
* relative data: d1 indicates indicates the next/prev edge around vertex v1 and d2 does the same for v2 */
BMDiskLink v1_disk_link, v2_disk_link;
@@ -231,7 +231,7 @@ typedef struct BMesh {
int toolflag_index;
struct BMOperator *currentop;
-
+
CustomData vdata, edata, ldata, pdata;
#ifdef USE_BMESH_HOLES
@@ -246,10 +246,10 @@ typedef struct BMesh {
* make sure they're in sync!
* Only use when the edit mesh cant be accessed - campbell */
short selectmode;
-
+
/* ID of the shape key this bmesh came from */
int shapenr;
-
+
int totflags;
ListBase selected;
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index f8ecbe1756b..1b300b24808 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -712,7 +712,7 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
/* safety check */
BLI_assert(i == bm_old->totvert);
-
+
BM_ITER_MESH_INDEX (e, &iter, bm_old, BM_EDGES_OF_MESH, i) {
e_new = BM_edge_create(bm_new,
vtable[BM_elem_index_get(e->v1)],
@@ -730,7 +730,7 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
/* safety check */
BLI_assert(i == bm_old->totedge);
-
+
BM_ITER_MESH_INDEX (f, &iter, bm_old, BM_FACES_OF_MESH, i) {
BM_elem_index_set(f, i); /* set_inline */
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index 7e35866887d..c6836187eee 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -158,7 +158,7 @@ BMEdge *BM_edge_create(
if ((create_flag & BM_CREATE_NO_DOUBLE) && (e = BM_edge_exists(v1, v2)))
return e;
-
+
e = BLI_mempool_alloc(bm->epool);
@@ -286,7 +286,7 @@ static BMLoop *bm_face_boundary_add(
BMLoopList *lst = BLI_mempool_calloc(bm->looplistpool);
#endif
BMLoop *l = bm_loop_create(bm, startv, starte, f, NULL /* starte->l */, create_flag);
-
+
bmesh_radial_loop_append(starte, l);
#ifdef USE_BMESH_HOLES
@@ -295,7 +295,7 @@ static BMLoop *bm_face_boundary_add(
#else
f->l_first = l;
#endif
-
+
return l;
}
@@ -330,7 +330,7 @@ BMFace *BM_face_copy(
do {
if (copy_edges) {
BMVert *v1, *v2;
-
+
if (l_iter->e->v1 == verts[i]) {
v1 = verts[i];
v2 = verts[(i + 1) % f->len];
@@ -339,7 +339,7 @@ BMFace *BM_face_copy(
v2 = verts[i];
v1 = verts[(i + 1) % f->len];
}
-
+
edges[i] = BM_edge_create(bm_dst, v1, v2, l_iter->e, BM_CREATE_NOP);
}
else {
@@ -347,11 +347,11 @@ BMFace *BM_face_copy(
}
i++;
} while ((l_iter = l_iter->next) != l_first);
-
+
f_copy = BM_face_create(bm_dst, verts, edges, f->len, NULL, BM_CREATE_SKIP_CD);
-
+
BM_elem_attrs_copy(bm_src, bm_dst, f, f_copy);
-
+
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
l_copy = BM_FACE_FIRST_LOOP(f_copy);
do {
@@ -463,12 +463,12 @@ BMFace *BM_face_create(
lastl->next = l;
lastl = l;
}
-
+
startl->prev = lastl;
lastl->next = startl;
-
+
f->len = len;
-
+
if (!(create_flag & BM_CREATE_SKIP_CD)) {
if (f_example) {
BM_elem_attrs_copy(bm, bm, f_example, f);
@@ -563,7 +563,7 @@ int bmesh_elem_check(void *element, const char htype)
if (head->htype != htype)
return IS_WRONG_TYPE;
-
+
switch (htype) {
case BM_VERT:
{
@@ -830,12 +830,12 @@ void BM_face_edges_kill(BMesh *bm, BMFace *f)
BMLoop *l_iter;
BMLoop *l_first;
int i = 0;
-
+
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
edges[i++] = l_iter->e;
} while ((l_iter = l_iter->next) != l_first);
-
+
for (i = 0; i < f->len; i++) {
BM_edge_kill(bm, edges[i]);
}
@@ -851,12 +851,12 @@ void BM_face_verts_kill(BMesh *bm, BMFace *f)
BMLoop *l_iter;
BMLoop *l_first;
int i = 0;
-
+
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
verts[i++] = l_iter->v;
} while ((l_iter = l_iter->next) != l_first);
-
+
for (i = 0; i < f->len; i++) {
BM_vert_kill(bm, verts[i]);
}
@@ -979,7 +979,7 @@ void BM_edge_kill(BMesh *bm, BMEdge *e)
bmesh_disk_edge_remove(e, e->v1);
bmesh_disk_edge_remove(e, e->v2);
-
+
bm_kill_only_edge(bm, e);
}
@@ -1159,11 +1159,11 @@ static bool bm_vert_is_manifold_flagged(BMVert *v, const char api_flag)
if (!l) {
return false;
}
-
+
if (BM_edge_is_boundary(l->e)) {
return false;
}
-
+
do {
if (!BM_ELEM_API_FLAG_TEST(l->f, api_flag))
return false;
@@ -1361,7 +1361,7 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const bool do_del)
BM_face_kill(bm, faces[i]);
}
}
-
+
BLI_array_free(edges);
BLI_array_free(deledges);
BLI_array_free(delverts);
@@ -1562,7 +1562,7 @@ BMFace *bmesh_kernel_split_face_make_edge(
BM_CHECK_ELEMENT(e);
BM_CHECK_ELEMENT(f);
BM_CHECK_ELEMENT(f2);
-
+
return f2;
}
@@ -1664,7 +1664,7 @@ BMVert *bmesh_kernel_split_edge_make_vert(BMesh *bm, BMVert *tv, BMEdge *e, BMEd
is_first = false;
l->radial_next = l->radial_prev = NULL;
}
-
+
bmesh_radial_loop_append(l_new->e, l_new);
bmesh_radial_loop_append(l->e, l);
}
@@ -1784,7 +1784,7 @@ BMEdge *bmesh_kernel_join_edge_kill_vert(
if (BM_vert_in_edge(e_kill, v_kill) == 0) {
return NULL;
}
-
+
if (bmesh_disk_count_at_most(v_kill, 3) == 2) {
#ifndef NDEBUG
int valence1, valence2;
@@ -2122,10 +2122,10 @@ BMFace *bmesh_kernel_join_face_kill_edge(BMesh *bm, BMFace *f1, BMFace *f2, BMEd
/* join the two loop */
l_f1->prev->next = l_f2->next;
l_f2->next->prev = l_f1->prev;
-
+
l_f1->next->prev = l_f2->prev;
l_f2->prev->next = l_f1->next;
-
+
/* if l_f1 was baseloop, make l_f1->next the base. */
if (BM_FACE_FIRST_LOOP(f1) == l_f1)
BM_FACE_FIRST_LOOP(f1) = l_f1->next;
@@ -2137,11 +2137,11 @@ BMFace *bmesh_kernel_join_face_kill_edge(BMesh *bm, BMFace *f1, BMFace *f2, BMEd
newlen = f1->len;
for (i = 0, l_iter = BM_FACE_FIRST_LOOP(f1); i < newlen; i++, l_iter = l_iter->next)
l_iter->f = f1;
-
+
/* remove edge from the disk cycle of its two vertices */
bmesh_disk_edge_remove(l_f1->e, l_f1->e->v1);
bmesh_disk_edge_remove(l_f1->e, l_f1->e->v2);
-
+
/* deallocate edge and its two loops as well as f2 */
if (bm->etoolflagpool) {
BLI_mempool_free(bm->etoolflagpool, ((BMEdge_OFlag *)l_f1->e)->oflags);
@@ -2165,7 +2165,7 @@ BMFace *bmesh_kernel_join_face_kill_edge(BMesh *bm, BMFace *f1, BMFace *f2, BMEd
/* validate the new loop cycle */
edok = bmesh_loop_validate(f1);
BMESH_ASSERT(edok != false);
-
+
return f1;
}
@@ -2600,7 +2600,7 @@ void bmesh_kernel_edge_separate(
BLI_assert(l_sep->e == e);
BLI_assert(e->l);
-
+
if (BM_edge_is_boundary(e)) {
BLI_assert(0); /* no cut required */
return;
diff --git a/source/blender/bmesh/intern/bmesh_delete.c b/source/blender/bmesh/intern/bmesh_delete.c
index 1449a6ef9d7..1869bc49da0 100644
--- a/source/blender/bmesh/intern/bmesh_delete.c
+++ b/source/blender/bmesh/intern/bmesh_delete.c
@@ -105,7 +105,7 @@ void BMO_mesh_delete_oflag_tagged(BMesh *bm, const short oflag, const char htype
bmo_remove_tagged_edges(bm, oflag);
}
if (htype & BM_VERT) {
- bmo_remove_tagged_verts(bm, oflag);
+ bmo_remove_tagged_verts(bm, oflag);
}
}
diff --git a/source/blender/bmesh/intern/bmesh_edgeloop.c b/source/blender/bmesh/intern/bmesh_edgeloop.c
index 54fe2801d0c..9e107c822ac 100644
--- a/source/blender/bmesh/intern/bmesh_edgeloop.c
+++ b/source/blender/bmesh/intern/bmesh_edgeloop.c
@@ -160,7 +160,7 @@ int BM_mesh_edgeloops_find(
BMEdge **edges = MEM_mallocN(sizeof(*edges) * edges_len, __func__);
BLI_stack_pop_n_reverse(edge_stack, edges, BLI_stack_count(edge_stack));
BLI_stack_free(edge_stack);
-
+
for (uint i = 0; i < edges_len; i += 1) {
e = edges[i];
if (BM_elem_flag_test(e, BM_ELEM_INTERNAL_TAG)) {
diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c
index 8a1090891f2..e3b779ddbcd 100644
--- a/source/blender/bmesh/intern/bmesh_interp.c
+++ b/source/blender/bmesh/intern/bmesh_interp.c
@@ -152,7 +152,7 @@ void BM_data_interp_face_vert_edge(
l_v = l_iter;
l_v2 = l_iter->prev;
}
-
+
if (!l_v1 || !l_v2) {
return;
}
@@ -260,15 +260,15 @@ static int compute_mdisp_quad(
mid_v3_v3v3(p, l->prev->v->co, l->v->co);
mid_v3_v3v3(n, l->next->v->co, l->v->co);
-
+
copy_v3_v3(v1, l_f_center);
copy_v3_v3(v2, p);
copy_v3_v3(v3, l->v->co);
copy_v3_v3(v4, n);
-
+
sub_v3_v3v3(e1, v2, v1);
sub_v3_v3v3(e2, v3, v4);
-
+
return 1;
}
@@ -331,7 +331,7 @@ static bool mdisp_in_mdispquad(
{
float v1[3], v2[3], c[3], v3[3], v4[3], e1[3], e2[3];
float eps = FLT_EPSILON * 4000;
-
+
if (is_zero_v3(l_src->v->no))
BM_vert_normal_update_all(l_src->v);
if (is_zero_v3(l_dst->v->no))
@@ -341,17 +341,17 @@ static bool mdisp_in_mdispquad(
/* expand quad a bit */
mid_v3_v3v3v3v3(c, v1, v2, v3, v4);
-
+
sub_v3_v3(v1, c); sub_v3_v3(v2, c);
sub_v3_v3(v3, c); sub_v3_v3(v4, c);
mul_v3_fl(v1, 1.0f + eps); mul_v3_fl(v2, 1.0f + eps);
mul_v3_fl(v3, 1.0f + eps); mul_v3_fl(v4, 1.0f + eps);
add_v3_v3(v1, c); add_v3_v3(v2, c);
add_v3_v3(v3, c); add_v3_v3(v4, c);
-
+
if (!quad_co(v1, v2, v3, v4, p, l_src->v->no, r_uv))
return 0;
-
+
mul_v2_fl(r_uv, (float)(res - 1));
mdisp_axis_from_quad(v1, v2, v3, v4, r_axis_x, r_axis_y);
@@ -478,14 +478,14 @@ void BM_loop_interp_multires_ex(
MDisps *md_dst;
float v1[3], v2[3], v3[3], v4[3] = {0.0f, 0.0f, 0.0f}, e1[3], e2[3];
float axis_x[3], axis_y[3];
-
+
/* ignore 2-edged faces */
if (UNLIKELY(l_dst->f->len < 3))
return;
md_dst = BM_ELEM_CD_GET_VOID_P(l_dst, cd_loop_mdisp_offset);
compute_mdisp_quad(l_dst, f_dst_center, v1, v2, v3, v4, e1, e2);
-
+
/* if no disps data allocate a new grid, the size of the first grid in f_src. */
if (!md_dst->totdisp) {
const MDisps *md_src = BM_ELEM_CD_GET_VOID_P(BM_FACE_FIRST_LOOP(f_src), cd_loop_mdisp_offset);
@@ -499,7 +499,7 @@ void BM_loop_interp_multires_ex(
return;
}
}
-
+
mdisp_axis_from_quad(v1, v2, v3, v4, axis_x, axis_y);
const int res = (int)sqrt(md_dst->totdisp);
@@ -571,10 +571,10 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS);
BMLoop *l;
BMIter liter;
-
+
if (cd_loop_mdisp_offset == -1)
return;
-
+
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
MDisps *mdp = BM_ELEM_CD_GET_VOID_P(l->prev, cd_loop_mdisp_offset);
MDisps *mdl = BM_ELEM_CD_GET_VOID_P(l, cd_loop_mdisp_offset);
@@ -582,7 +582,7 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
float co1[3];
int sides;
int y;
-
+
/*
* mdisps is a grid of displacements, ordered thus:
*
@@ -605,14 +605,14 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
copy_v3_v3(mdl->disps[y], co1);
}
}
-
+
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
MDisps *mdl1 = BM_ELEM_CD_GET_VOID_P(l, cd_loop_mdisp_offset);
MDisps *mdl2;
float co1[3], co2[3], co[3];
int sides;
int y;
-
+
/*
* mdisps is a grid of displacements, ordered thus:
*
@@ -638,11 +638,11 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
sides = (int)sqrt(mdl1->totdisp);
for (y = 0; y < sides; y++) {
int a1, a2, o1, o2;
-
+
if (l->v != l->radial_next->v) {
a1 = sides * y + sides - 2;
a2 = (sides - 2) * sides + y;
-
+
o1 = sides * y + sides - 1;
o2 = (sides - 1) * sides + y;
}
@@ -652,16 +652,16 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
o1 = sides * y + sides - 1;
o2 = sides * y + sides - 1;
}
-
+
/* magic blending numbers, hardcoded! */
add_v3_v3v3(co1, mdl1->disps[a1], mdl2->disps[a2]);
mul_v3_fl(co1, 0.18);
-
+
add_v3_v3v3(co2, mdl1->disps[o1], mdl2->disps[o2]);
mul_v3_fl(co2, 0.32);
-
+
add_v3_v3v3(co, co1, co2);
-
+
copy_v3_v3(mdl1->disps[o1], co);
copy_v3_v3(mdl2->disps[o2], co);
}
diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c
index 9fe28561b93..c9b7b80b658 100644
--- a/source/blender/bmesh/intern/bmesh_iterators.c
+++ b/source/blender/bmesh/intern/bmesh_iterators.c
@@ -508,7 +508,7 @@ void *bmiter__face_of_vert_step(struct BMIter__face_of_vert *iter)
iter->l_next = iter->l_first;
}
}
-
+
if (!((BMIter *)iter)->count) {
iter->l_next = NULL;
}
@@ -549,7 +549,7 @@ void *bmiter__loop_of_vert_step(struct BMIter__loop_of_vert *iter)
iter->l_next = iter->l_first;
}
}
-
+
if (!((BMIter *)iter)->count) {
iter->l_next = NULL;
}
@@ -590,7 +590,7 @@ void bmiter__loop_of_loop_begin(struct BMIter__loop_of_loop *iter)
{
iter->l_first = iter->ldata;
iter->l_next = iter->l_first->radial_next;
-
+
if (iter->l_next == iter->l_first)
iter->l_next = NULL;
}
@@ -598,7 +598,7 @@ void bmiter__loop_of_loop_begin(struct BMIter__loop_of_loop *iter)
void *bmiter__loop_of_loop_step(struct BMIter__loop_of_loop *iter)
{
BMLoop *l_curr = iter->l_next;
-
+
if (iter->l_next) {
iter->l_next = iter->l_next->radial_next;
if (iter->l_next == iter->l_first) {
@@ -696,7 +696,7 @@ void *bmiter__edge_of_face_step(struct BMIter__edge_of_face *iter)
iter->l_next = NULL;
}
}
-
+
return l_curr ? l_curr->e : NULL;
}
diff --git a/source/blender/bmesh/intern/bmesh_iterators_inline.h b/source/blender/bmesh/intern/bmesh_iterators_inline.h
index 88985d639cf..e7bd6164c27 100644
--- a/source/blender/bmesh/intern/bmesh_iterators_inline.h
+++ b/source/blender/bmesh/intern/bmesh_iterators_inline.h
@@ -156,7 +156,7 @@ BLI_INLINE bool BM_iter_init(BMIter *iter, BMesh *bm, const char itype, void *da
return false;
break;
}
-
+
iter->begin(iter);
return true;
diff --git a/source/blender/bmesh/intern/bmesh_log.c b/source/blender/bmesh/intern/bmesh_log.c
index 5ae72851c7e..30ab0dd9459 100644
--- a/source/blender/bmesh/intern/bmesh_log.c
+++ b/source/blender/bmesh/intern/bmesh_log.c
@@ -141,7 +141,7 @@ static uint bm_log_vert_id_get(BMLog *log, BMVert *v)
static void bm_log_vert_id_set(BMLog *log, BMVert *v, uint id)
{
void *vid = SET_UINT_IN_POINTER(id);
-
+
BLI_ghash_reinsert(log->id_to_elem, vid, v, NULL, NULL);
BLI_ghash_reinsert(log->elem_to_id, v, vid, NULL, NULL);
}
@@ -654,17 +654,21 @@ void BM_log_mesh_elems_reorder(BMesh *bm, BMLog *log)
*/
BMLogEntry *BM_log_entry_add(BMLog *log)
{
- BMLogEntry *entry, *next;
-
+ /* WARNING: this is now handled by the UndoSystem: BKE_UNDOSYS_TYPE_SCULPT
+ * freeing here causes unnecesssary complications. */
+ BMLogEntry *entry;
+#if 0
/* Delete any entries after the current one */
entry = log->current_entry;
if (entry) {
+ BMLogEntry *next;
for (entry = entry->next; entry; entry = next) {
next = entry->next;
bm_log_entry_free(entry);
BLI_freelinkN(&log->entries, entry);
}
}
+#endif
/* Create and append the new entry */
entry = bm_log_entry_create();
@@ -906,7 +910,7 @@ void BM_log_face_added(BMLog *log, BMFace *f)
/* Log a vertex as removed from the BMesh
*
* A couple things can happen here:
- *
+ *
* If the vertex was added as part of the current log entry, then it's
* deleted and forgotten about entirely. Its unique ID is returned to
* the unused pool.
@@ -950,7 +954,7 @@ void BM_log_vert_removed(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
/* Log a face as removed from the BMesh
*
* A couple things can happen here:
- *
+ *
* If the face was added as part of the current log entry, then it's
* deleted and forgotten about entirely. Its unique ID is returned to
* the unused pool.
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c
index 1b96237e262..10a03050d4b 100644
--- a/source/blender/bmesh/intern/bmesh_marking.c
+++ b/source/blender/bmesh/intern/bmesh_marking.c
@@ -609,7 +609,7 @@ void BM_mesh_select_mode_set(BMesh *bm, int selectmode)
{
BMIter iter;
BMElem *ele;
-
+
bm->selectmode = selectmode;
if (bm->selectmode & SCE_SELECT_VERTEX) {
@@ -737,13 +737,13 @@ BMFace *BM_mesh_active_face_get(BMesh *bm, const bool is_sloppy, const bool is_s
BMIter iter;
BMFace *f = NULL;
BMEditSelection *ese;
-
+
/* Find the latest non-hidden face from the BMEditSelection */
ese = bm->selected.last;
for ( ; ese; ese = ese->prev) {
if (ese->htype == BM_FACE) {
f = (BMFace *)ese->ele;
-
+
if (BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
f = NULL;
}
@@ -842,10 +842,10 @@ void BM_editselection_normal(BMEditSelection *ese, float r_normal[3])
BMEdge *eed = (BMEdge *)ese->ele;
float plane[3]; /* need a plane to correct the normal */
float vec[3]; /* temp vec storage */
-
+
add_v3_v3v3(r_normal, eed->v1->no, eed->v2->no);
sub_v3_v3v3(plane, eed->v2->co, eed->v1->co);
-
+
/* the 2 vertex normals will be close but not at rightangles to the edge
* for rotate about edge we want them to be at right angles, so we need to
* do some extra calculation to correct the vert normals,
@@ -853,7 +853,7 @@ void BM_editselection_normal(BMEditSelection *ese, float r_normal[3])
cross_v3_v3v3(vec, r_normal, plane);
cross_v3_v3v3(r_normal, plane, vec);
normalize_v3(r_normal);
-
+
}
else if (ese->htype == BM_FACE) {
BMFace *efa = (BMFace *)ese->ele;
@@ -869,7 +869,7 @@ void BM_editselection_plane(BMEditSelection *ese, float r_plane[3])
if (ese->htype == BM_VERT) {
BMVert *eve = (BMVert *)ese->ele;
float vec[3] = {0.0f, 0.0f, 0.0f};
-
+
if (ese->prev) { /* use previously selected data to make a useful vertex plane */
BM_editselection_center(ese->prev, vec);
sub_v3_v3v3(r_plane, vec, eve->co);
@@ -1261,7 +1261,7 @@ void BM_edge_hide_set(BMEdge *e, const bool hide)
BM_elem_flag_set(l_iter->f, BM_ELEM_HIDDEN, hide);
} while ((l_iter = l_iter->radial_next) != l_first);
}
-
+
BM_elem_flag_set(e, BM_ELEM_HIDDEN, hide);
/* hide vertices if necessary */
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 3a4aec8cc69..4d0f259b4e3 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -169,7 +169,7 @@ BMesh *BM_mesh_create(
{
/* allocate the structure */
BMesh *bm = MEM_callocN(sizeof(BMesh), __func__);
-
+
/* allocate the memory pools for the mesh elements */
bm_mempool_init(bm, allocsize, params->use_toolflags);
@@ -1482,41 +1482,41 @@ static void UNUSED_FUNCTION(bm_mdisps_space_set)(
BMFace *f;
BMIter iter;
// int i = 0; // UNUSED
-
+
multires_set_space(dm, ob, from, to);
-
+
mdisps = CustomData_get_layer(&dm->loopData, CD_MDISPS);
-
+
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
BMLoop *l;
BMIter liter;
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
MDisps *lmd = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MDISPS);
-
+
if (!lmd->disps) {
printf("%s: warning - 'lmd->disps' == NULL\n", __func__);
}
-
+
if (lmd->disps && lmd->totdisp == mdisps->totdisp) {
memcpy(lmd->disps, mdisps->disps, sizeof(float) * 3 * lmd->totdisp);
}
else if (mdisps->disps) {
if (lmd->disps)
MEM_freeN(lmd->disps);
-
+
lmd->disps = MEM_dupallocN(mdisps->disps);
lmd->totdisp = mdisps->totdisp;
lmd->level = mdisps->level;
}
-
+
mdisps++;
// i += 1;
}
}
-
+
dm->needsFree = 1;
dm->release(dm);
-
+
/* setting this to NULL prevents BKE_editmesh_free from freeing it */
em->bm = NULL;
BKE_editmesh_free(em);
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c
index cf6bc0e0bac..5ba3f149689 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c
@@ -88,6 +88,7 @@
#include "BLI_math_vector.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_customdata.h"
#include "BKE_multires.h"
diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c
index 4290f94bba1..a10f2e2bb3f 100644
--- a/source/blender/bmesh/intern/bmesh_mods.c
+++ b/source/blender/bmesh/intern/bmesh_mods.c
@@ -66,7 +66,7 @@ bool BM_vert_dissolve(BMesh *bm, BMVert *v)
{
/* logic for 3 or more is identical */
const int len = BM_vert_edge_count_at_most(v, 3);
-
+
if (len == 1) {
BM_vert_kill(bm, v); /* will kill edges too */
return true;
@@ -110,7 +110,7 @@ bool BM_disk_dissolve(BMesh *bm, BMVert *v)
if (!BM_vert_is_manifold(v)) {
return false;
}
-
+
if (v->e) {
/* v->e we keep, what else */
e = v->e;
@@ -124,7 +124,7 @@ bool BM_disk_dissolve(BMesh *bm, BMVert *v)
len++;
} while (e != v->e);
}
-
+
/* this code for handling 2 and 3-valence verts
* may be totally bad */
if (keepedge == NULL && len == 3) {
@@ -200,7 +200,7 @@ bool BM_disk_dissolve(BMesh *bm, BMVert *v)
if (!e) {
return false;
}
-
+
if (e->l) {
/* get remaining two faces */
if (e->l != e->l->radial_next) {
@@ -286,13 +286,13 @@ BMFace *BM_face_split(
if (cd_loop_mdisp_offset != -1) {
f_tmp = BM_face_copy(bm, bm, f, false, false);
}
-
+
#ifdef USE_BMESH_HOLES
f_new = bmesh_kernel_split_face_make_edge(bm, f, l_a, l_b, r_l, NULL, example, no_double);
#else
f_new = bmesh_kernel_split_face_make_edge(bm, f, l_a, l_b, r_l, example, no_double);
#endif
-
+
if (f_new) {
/* handle multires update */
if (cd_loop_mdisp_offset != -1) {
@@ -368,7 +368,7 @@ BMFace *BM_face_split_n(
}
f_tmp = BM_face_copy(bm, bm, f, true, true);
-
+
#ifdef USE_BMESH_HOLES
f_new = bmesh_kernel_split_face_make_edge(bm, f, l_a, l_b, &l_new, NULL, example, false);
#else
@@ -600,13 +600,13 @@ BMVert *BM_edge_split(BMesh *bm, BMEdge *e, BMVert *v, BMEdge **r_e, float fac)
if (cd_loop_mdisp_offset != -1) {
BMLoop *l;
int i;
-
+
l = e->l;
do {
BLI_array_append(oldfaces, l->f);
l = l->radial_next;
} while (l != e->l);
-
+
/* flag existing faces so we can differentiate oldfaces from new faces */
for (i = 0; i < BLI_array_len(oldfaces); i++) {
BM_ELEM_API_FLAG_ENABLE(oldfaces[i], _FLAG_OVERLAP);
@@ -647,7 +647,7 @@ BMVert *BM_edge_split(BMesh *bm, BMEdge *e, BMVert *v, BMEdge **r_e, float fac)
for (j = 0; j < 2; j++) {
BMEdge *e1 = j ? e_new : e;
BMLoop *l;
-
+
l = e1->l;
if (UNLIKELY(!l)) {
@@ -669,31 +669,31 @@ BMVert *BM_edge_split(BMesh *bm, BMEdge *e, BMVert *v, BMEdge **r_e, float fac)
} while (l != e1->l);
}
}
-
+
/* destroy the old faces */
for (i = 0; i < BLI_array_len(oldfaces); i++) {
BM_face_verts_kill(bm, oldfaces[i]);
}
-
+
/* fix boundaries a bit, doesn't work too well quite yet */
#if 0
for (j = 0; j < 2; j++) {
BMEdge *e1 = j ? e_new : e;
BMLoop *l, *l2;
-
+
l = e1->l;
if (UNLIKELY(!l)) {
BMESH_ASSERT(0);
break;
}
-
+
do {
BM_face_multires_bounds_smooth(bm, l->f);
l = l->radial_next;
} while (l != e1->l);
}
#endif
-
+
BLI_array_free(oldfaces);
}
@@ -710,7 +710,7 @@ BMVert *BM_edge_split_n(BMesh *bm, BMEdge *e, int numcuts, BMVert **r_varr)
int i;
float percent;
BMVert *v_new = NULL;
-
+
for (i = 0; i < numcuts; i++) {
percent = 1.0f / (float)(numcuts + 1 - i);
v_new = BM_edge_split(bm, e, e->v2, NULL, percent);
@@ -734,7 +734,7 @@ bool BM_face_validate(BMFace *face, FILE *err)
BMLoop *l;
int i, j;
bool ret = true;
-
+
if (face->len == 2) {
fprintf(err, "warning: found two-edged face. face ptr: %p\n", face);
fflush(err);
@@ -765,7 +765,7 @@ bool BM_face_validate(BMFace *face, FILE *err)
}
}
}
-
+
BLI_array_free(verts);
return ret;
}
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index f814767a200..62d892712fd 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -65,10 +65,10 @@ BLI_STATIC_ASSERT(ARRAY_SIZE(bmo_error_messages) + 1 == BMERR_TOTAL, "message mi
/* operator slot type information - size of one element of the type given. */
const int BMO_OPSLOT_TYPEINFO[BMO_OP_SLOT_TOTAL_TYPES] = {
0, /* 0: BMO_OP_SLOT_SENTINEL */
- sizeof(int), /* 1: BMO_OP_SLOT_BOOL */
- sizeof(int), /* 2: BMO_OP_SLOT_INT */
- sizeof(float), /* 3: BMO_OP_SLOT_FLT */
- sizeof(void *), /* 4: BMO_OP_SLOT_PNT */
+ sizeof(int), /* 1: BMO_OP_SLOT_BOOL */
+ sizeof(int), /* 2: BMO_OP_SLOT_INT */
+ sizeof(float), /* 3: BMO_OP_SLOT_FLT */
+ sizeof(void *), /* 4: BMO_OP_SLOT_PNT */
sizeof(void *), /* 5: BMO_OP_SLOT_PNT */
0, /* 6: unused */
0, /* 7: unused */
@@ -185,7 +185,7 @@ void BMO_op_init(BMesh *bm, BMOperator *op, const int flag, const char *opname)
op->type = opcode;
op->type_flag = bmo_opdefines[opcode]->type_flag;
op->flag = flag;
-
+
/* initialize the operator slot types */
bmo_op_slots_init(bmo_opdefines[opcode]->slot_types_in, op->slots_in);
bmo_op_slots_init(bmo_opdefines[opcode]->slot_types_out, op->slots_out);
@@ -217,10 +217,10 @@ void BMO_op_exec(BMesh *bm, BMOperator *op)
if (bm->toolflag_index == 1)
bmesh_edit_begin(bm, op->type_flag);
op->exec(bm, op);
-
+
if (bm->toolflag_index == 1)
bmesh_edit_end(bm, op->type_flag);
-
+
BMO_pop(bm);
}
@@ -406,7 +406,7 @@ void BMO_slot_mat_set(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], cons
slot->len = 4;
slot->data.p = BLI_memarena_alloc(op->arena, sizeof(float) * 4 * 4);
-
+
if (size == 4) {
copy_m4_m4(slot->data.p, (float (*)[4])mat);
}
@@ -661,7 +661,7 @@ int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
-
+
/* check if its actually a buffer */
if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF)
return 0;
@@ -697,7 +697,7 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slot_code, int totadd)
BMOpSlot *slot = &op->slots[slot_code];
void *tmp;
ssize_t allocsize;
-
+
BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF);
/* check if its actually a buffer */
@@ -760,7 +760,7 @@ void *BMO_slot_buffer_alloc(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS]
/* check if its actually a buffer */
if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF)
return NULL;
-
+
slot->len = len;
if (len) {
slot->data.buf = BLI_memarena_alloc(op->arena, BMO_OPSLOT_TYPEINFO[slot->slot_type] * len);
@@ -783,7 +783,7 @@ void BMO_slot_buffer_from_all(
{
BMOpSlot *output = BMO_slot_get(slot_args, slot_name);
int totelement = 0, i = 0;
-
+
BLI_assert(output->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
BLI_assert(((output->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype);
@@ -1365,7 +1365,7 @@ static void bmo_flag_layer_clear(BMesh *bm)
void *BMO_slot_buffer_get_first(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
-
+
if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF)
return NULL;
@@ -1505,14 +1505,14 @@ void BMO_error_clear(BMesh *bm)
void BMO_error_raise(BMesh *bm, BMOperator *owner, int errcode, const char *msg)
{
BMOpError *err = MEM_callocN(sizeof(BMOpError), "bmop_error");
-
+
err->errorcode = errcode;
if (!msg) {
msg = bmo_error_messages[errcode];
}
err->msg = msg;
err->op = owner;
-
+
BLI_addhead(&bm->errorstack, err);
}
@@ -1531,17 +1531,17 @@ int BMO_error_get(BMesh *bm, const char **msg, BMOperator **op)
if (msg) *msg = err->msg;
if (op) *op = err->op;
-
+
return err->errorcode;
}
int BMO_error_pop(BMesh *bm, const char **msg, BMOperator **op)
{
int errorcode = BMO_error_get(bm, msg, op);
-
+
if (errorcode) {
BMOpError *err = bm->errorstack.first;
-
+
BLI_remlink(&bm->errorstack, bm->errorstack.first);
MEM_freeN(err);
}
@@ -1680,7 +1680,7 @@ bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt,
/* we muck around in here, so dup it */
fmt = ofmt = BLI_strdup(_fmt);
-
+
/* find operator name */
i = strcspn(fmt, " ");
@@ -1689,7 +1689,7 @@ bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt,
opname[i] = '\0';
fmt += i + (noslot ? 0 : 1);
-
+
i = BMO_opcode_from_opname_check(opname);
if (i == -1) {
@@ -1700,7 +1700,7 @@ bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt,
BMO_op_init(bm, op, flag, opname);
// def = bmo_opdefines[i];
-
+
i = 0;
state = true; /* false: not inside slot_code name, true: inside slot_code name */
@@ -1709,7 +1709,7 @@ bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt,
/* jump past leading whitespace */
i = strspn(fmt, " ");
fmt += i;
-
+
/* ignore trailing whitespace */
if (!fmt[i])
break;
@@ -1725,9 +1725,9 @@ bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt,
if (bmo_name_to_slotcode_check(op->slots_in, fmt) < 0) {
GOTO_ERROR("name to slot code check failed");
}
-
+
BLI_strncpy(slot_name, fmt, sizeof(slot_name));
-
+
state = false;
fmt += i;
}
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index bcb940f8b96..7cbc6461667 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -611,7 +611,7 @@ void BM_edge_normals_update(BMEdge *e)
{
BMIter iter;
BMFace *f;
-
+
BM_ITER_ELEM (f, &iter, e, BM_FACES_OF_EDGE) {
BM_face_normal_update(f);
}
@@ -886,7 +886,7 @@ bool BM_face_point_inside_test(const BMFace *f, const float co[3])
float co_2d[2];
BMLoop *l_iter;
int i;
-
+
BLI_assert(BM_face_is_normal_valid(f));
axis_dominant_v3_to_m3(axis_mat, f->no);
@@ -1199,7 +1199,7 @@ void BM_face_splits_check_legal(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int l
out[1] = max_ff(out[1], projverts[i][1]);
}
bm->elem_index_dirty |= BM_LOOP;
-
+
/* ensure we are well outside the face bounds (value is arbitrary) */
add_v2_fl(out, 1.0f);
@@ -1212,7 +1212,7 @@ void BM_face_splits_check_legal(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int l
for (i = 0; i < len; i++) {
float mid[2];
mid_v2_v2v2(mid, edgeverts[i][0], edgeverts[i][1]);
-
+
int isect = 0;
int j_prev;
for (j = 0, j_prev = f->len - 1; j < f->len; j_prev = j++) {
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index ab2f017d103..5ce4b236d03 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -424,7 +424,7 @@ int BM_verts_in_face_count(BMVert **varr, int len, BMFace *f)
#endif
int i, count = 0;
-
+
for (i = 0; i < len; i++) {
BM_ELEM_API_FLAG_ENABLE(varr[i], _FLAG_OVERLAP);
}
@@ -1213,7 +1213,7 @@ int BM_face_share_edge_count(BMFace *f_a, BMFace *f_b)
BMLoop *l_iter;
BMLoop *l_first;
int count = 0;
-
+
l_iter = l_first = BM_FACE_FIRST_LOOP(f_a);
do {
if (BM_edge_in_face(l_iter->e, f_b)) {
diff --git a/source/blender/bmesh/intern/bmesh_structure.c b/source/blender/bmesh/intern/bmesh_structure.c
index 8aa9502c0f7..ff744ae1a42 100644
--- a/source/blender/bmesh/intern/bmesh_structure.c
+++ b/source/blender/bmesh/intern/bmesh_structure.c
@@ -217,7 +217,7 @@ void bmesh_disk_edge_remove(BMEdge *e, BMVert *v)
BMEdge *bmesh_disk_edge_exists(const BMVert *v1, const BMVert *v2)
{
BMEdge *e_iter, *e_first;
-
+
if (v1->e) {
e_first = e_iter = v1->e;
@@ -227,7 +227,7 @@ BMEdge *bmesh_disk_edge_exists(const BMVert *v1, const BMVert *v2)
}
} while ((e_iter = bmesh_disk_edge_next(e_iter, v1)) != e_first);
}
-
+
return NULL;
}
@@ -380,7 +380,7 @@ bool bmesh_radial_validate(int radlen, BMLoop *l)
{
BMLoop *l_iter = l;
int i = 0;
-
+
if (bmesh_radial_length(l) != radlen)
return false;
@@ -389,17 +389,17 @@ bool bmesh_radial_validate(int radlen, BMLoop *l)
BMESH_ASSERT(0);
return false;
}
-
+
if (l_iter->e != l->e)
return false;
if (l_iter->v != l->e->v1 && l_iter->v != l->e->v2)
return false;
-
+
if (UNLIKELY(i > BM_LOOP_RADIAL_MAX)) {
BMESH_ASSERT(0);
return false;
}
-
+
i++;
} while ((l_iter = l_iter->radial_next) != l);
@@ -529,7 +529,7 @@ int bmesh_radial_length(const BMLoop *l)
BMESH_ASSERT(0);
return 0;
}
-
+
i++;
if (UNLIKELY(i >= BM_LOOP_RADIAL_MAX)) {
BMESH_ASSERT(0);
diff --git a/source/blender/bmesh/intern/bmesh_walkers.c b/source/blender/bmesh/intern/bmesh_walkers.c
index d39fb382b96..77e9d441bbb 100644
--- a/source/blender/bmesh/intern/bmesh_walkers.c
+++ b/source/blender/bmesh/intern/bmesh_walkers.c
@@ -63,7 +63,7 @@ void *BMW_begin(BMWalker *walker, void *start)
BLI_assert(((BMHeader *)start)->htype & walker->begin_htype);
walker->begin(walker, start);
-
+
return BMW_current_state(walker) ? walker->step(walker) : NULL;
}
@@ -101,7 +101,7 @@ void BMW_init(
BLI_assert(0);
return;
}
-
+
if (type != BMW_CUSTOM) {
walker->begin_htype = bm_walker_types[type]->begin_htype;
walker->begin = bm_walker_types[type]->begin;
@@ -118,7 +118,7 @@ void BMW_init(
BLI_assert(mask_edge == 0 || (walker->valid_mask & BM_EDGE));
BLI_assert(mask_face == 0 || (walker->valid_mask & BM_FACE));
}
-
+
walker->worklist = BLI_mempool_create(walker->structsize, 0, 128, BLI_MEMPOOL_NOP);
BLI_listbase_clear(&walker->states);
}
diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c
index 279440984bb..81487b70edc 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -210,7 +210,7 @@ static void *bmw_VertShellWalker_step(BMWalker *walker)
BMVert *v_old = NULL;
bool restrictpass = true;
BMwShellWalker shellWalk = *((BMwShellWalker *)BMW_current_state(walker));
-
+
if (!BLI_gset_haskey(walker->visit_set, shellWalk.base)) {
BLI_gset_insert(walker->visit_set, shellWalk.base);
}
@@ -228,11 +228,11 @@ static void *bmw_VertShellWalker_step(BMWalker *walker)
BMwShellWalker *newstate;
v_old = BM_edge_other_vert(curedge, shellWalk.base);
-
+
/* push a new state onto the stac */
newState = BMW_state_add(walker);
BLI_gset_insert(walker->visit_set, curedge);
-
+
/* populate the new stat */
newState->base = v_old;
@@ -240,7 +240,7 @@ static void *bmw_VertShellWalker_step(BMWalker *walker)
}
}
} while ((curedge = bmesh_disk_edge_next(curedge, shellWalk.base)) != shellWalk.curedge);
-
+
return shellWalk.curedge;
}
#endif
@@ -711,12 +711,12 @@ static void *bmw_IslandboundWalker_step(BMWalker *walker)
e = l->e;
v = BM_edge_other_vert(e, iwalk->lastv);
-
+
/* pop off current state */
BMW_state_remove(walker);
-
+
f = l->f;
-
+
while (1) {
l = BM_loop_other_edge_loop(l, v);
if (BM_loop_is_manifold(l)) {
@@ -736,7 +736,7 @@ static void *bmw_IslandboundWalker_step(BMWalker *walker)
break;
}
}
-
+
if (l == owalk.curloop) {
return NULL;
}
@@ -789,7 +789,7 @@ static void *bmw_IslandWalker_step_ex(BMWalker *walker, bool only_manifold)
{
BMwIslandWalker *iwalk, owalk;
BMLoop *l_iter, *l_first;
-
+
BMW_state_remove_r(walker, &owalk);
iwalk = &owalk;
@@ -1154,7 +1154,7 @@ static bool bmw_FaceLoopWalker_edge_begins_loop(BMWalker *walker, BMEdge *e)
if (BM_edge_is_wire(e)) {
return false;
}
-
+
/* Don't start a loop from a boundary edge if it cannot
* be extended to cover any faces */
if (BM_edge_is_boundary(e)) {
@@ -1162,7 +1162,7 @@ static bool bmw_FaceLoopWalker_edge_begins_loop(BMWalker *walker, BMEdge *e)
return false;
}
}
-
+
/* Don't start a face loop from non-manifold edges */
if (!BM_edge_is_manifold(e)) {
return false;
@@ -1206,7 +1206,7 @@ static void bmw_FaceLoopWalker_begin(BMWalker *walker, void *data)
static void *bmw_FaceLoopWalker_yield(BMWalker *walker)
{
BMwFaceLoopWalker *lwalk = BMW_current_state(walker);
-
+
if (!lwalk) {
return NULL;
}
@@ -1225,7 +1225,7 @@ static void *bmw_FaceLoopWalker_step(BMWalker *walker)
f = lwalk->l->f;
l = lwalk->l->radial_next;
-
+
if (lwalk->no_calc) {
return f;
}
@@ -1314,7 +1314,7 @@ static void bmw_EdgeringWalker_begin(BMWalker *walker, void *data)
static void *bmw_EdgeringWalker_yield(BMWalker *walker)
{
BMwEdgeringWalker *lwalk = BMW_current_state(walker);
-
+
if (!lwalk) {
return NULL;
}
@@ -1381,7 +1381,7 @@ static void *bmw_EdgeringWalker_step(BMWalker *walker)
l = l->radial_next;
l = l->next->next;
-
+
if ((l->f->len != 4) || !EDGE_CHECK(l->e) || !bmw_mask_check_face(walker, l->f)) {
l = owalk.l->next->next;
}
@@ -1502,7 +1502,7 @@ static void bmw_UVEdgeWalker_begin(BMWalker *walker, void *data)
static void *bmw_UVEdgeWalker_yield(BMWalker *walker)
{
BMwUVEdgeWalker *lwalk = BMW_current_state(walker);
-
+
if (!lwalk) {
return NULL;
}
diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c
index fa08d009d40..aeaedf6417c 100644
--- a/source/blender/bmesh/operators/bmo_create.c
+++ b/source/blender/bmesh/operators/bmo_create.c
@@ -21,7 +21,7 @@
*/
/** \file blender/bmesh/operators/bmo_create.c
- * \ingroup bmesh
+ * \ingroup bmesh
*
* Create faces or edges (Fkey by default).
*/
@@ -66,7 +66,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
break;
}
}
-
+
/* --- Support Edge Creation ---
* simple case when we only have 2 verts selected.
*/
diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c
index 816d2e8d009..0ad800cbddd 100644
--- a/source/blender/bmesh/operators/bmo_dissolve.c
+++ b/source/blender/bmesh/operators/bmo_dissolve.c
@@ -158,7 +158,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
}
BMO_slot_buffer_flag_enable(bm, op->slots_in, "faces", BM_FACE, FACE_MARK | FACE_TAG);
-
+
/* collect region */
BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) {
BMFace *f_iter;
@@ -178,7 +178,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
BLI_array_append(faces, f_iter);
}
BMW_end(&regwalker);
-
+
for (i = 0; i < BLI_array_len(faces); i++) {
f_iter = faces[i];
BMO_face_flag_disable(bm, f_iter, FACE_TAG);
@@ -190,7 +190,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
BMO_error_raise(bm, op, BMERR_DISSOLVEFACES_FAILED, NULL);
goto cleanup;
}
-
+
BLI_array_append(faces, NULL);
BLI_array_append(regions, faces);
}
@@ -201,17 +201,17 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
for (i = 0; i < BLI_array_len(regions); i++) {
BMFace *f_new;
int tot = 0;
-
+
faces = regions[i];
if (!faces[0]) {
BMO_error_raise(bm, op, BMERR_DISSOLVEFACES_FAILED,
"Could not find boundary of dissolve region");
goto cleanup;
}
-
+
while (faces[tot])
tot++;
-
+
f_new = BM_faces_join(bm, faces, tot, true);
if (f_new) {
diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c
index 394faabbd25..eed87ed20af 100644
--- a/source/blender/bmesh/operators/bmo_dupe.c
+++ b/source/blender/bmesh/operators/bmo_dupe.c
@@ -64,7 +64,7 @@ static BMVert *bmo_vert_copy(
/* Mark the vert for output */
BMO_vert_flag_enable(bm_dst, v_dst, DUPE_NEW);
-
+
return v_dst;
}
@@ -103,7 +103,7 @@ static BMEdge *bmo_edge_copy(
/* Lookup v1 and v2 */
e_dst_v1 = BLI_ghash_lookup(vhash, e_src->v1);
e_dst_v2 = BLI_ghash_lookup(vhash, e_src->v2);
-
+
/* Create a new edge */
e_dst = BM_edge_create(bm_dst, e_dst_v1, e_dst_v2, NULL, BM_CREATE_SKIP_CD);
BMO_slot_map_elem_insert(op, slot_edgemap_out, e_src, e_dst);
@@ -124,7 +124,7 @@ static BMEdge *bmo_edge_copy(
/* Mark the edge for output */
BMO_edge_flag_enable(bm_dst, e_dst, DUPE_NEW);
-
+
return e_dst;
}
@@ -164,7 +164,7 @@ static BMFace *bmo_face_copy(
/* Copy attributes */
BM_elem_attrs_copy(bm_src, bm_dst, f_src, f_dst);
-
+
/* copy per-loop custom data */
l_iter_src = l_first_src;
l_iter_dst = BM_FACE_FIRST_LOOP(f_dst);
@@ -192,7 +192,7 @@ static void bmo_mesh_copy(BMOperator *op, BMesh *bm_dst, BMesh *bm_src)
BMVert *v = NULL, *v2;
BMEdge *e = NULL;
BMFace *f = NULL;
-
+
BMIter viter, eiter, fiter;
GHash *vhash, *ehash;
@@ -286,7 +286,7 @@ static void bmo_mesh_copy(BMOperator *op, BMesh *bm_dst, BMesh *bm_src)
BMO_face_flag_enable(bm_src, f, DUPE_DONE);
}
}
-
+
/* free pointer hashes */
BLI_ghash_free(vhash, NULL, NULL);
BLI_ghash_free(ehash, NULL, NULL);
@@ -326,7 +326,7 @@ void bmo_duplicate_exec(BMesh *bm, BMOperator *op)
{
BMOperator *dupeop = op;
BMesh *bm_dst = BMO_slot_ptr_get(op->slots_in, "dest");
-
+
if (!bm_dst)
bm_dst = bm;
@@ -335,7 +335,7 @@ void bmo_duplicate_exec(BMesh *bm, BMOperator *op)
/* use the internal copy function */
bmo_mesh_copy(dupeop, bm_dst, bm);
-
+
/* Output */
/* First copy the input buffers to output buffers - original data */
BMO_slot_copy(dupeop, slots_in, "geom",
@@ -393,11 +393,11 @@ void bmo_split_exec(BMesh *bm, BMOperator *op)
/* initialize our sub-operator */
BMO_op_init(bm, &dupeop, op->flag, "duplicate");
-
+
BMO_slot_copy(splitop, slots_in, "geom",
&dupeop, slots_in, "geom");
BMO_op_exec(bm, &dupeop);
-
+
BMO_slot_buffer_flag_enable(bm, splitop->slots_in, "geom", BM_ALL_NOLOOP, SPLIT_INPUT);
if (use_only_faces) {
diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c
index 87369472df7..3a6fbd419c1 100644
--- a/source/blender/bmesh/operators/bmo_extrude.c
+++ b/source/blender/bmesh/operators/bmo_extrude.c
@@ -175,7 +175,7 @@ static void bm_extrude_copy_face_loop_attributes(BMesh *bm, BMFace *f)
static void bm_extrude_disable_skin_root(BMesh *bm, BMVert *v)
{
MVertSkin *vs;
-
+
vs = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_MVERT_SKIN);
vs->flag &= ~MVERT_SKIN_ROOT;
}
@@ -186,7 +186,7 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op)
BMOperator dupeop;
BMFace *f;
BMEdge *e, *e_new;
-
+
BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
BMO_edge_flag_enable(bm, e, EXT_INPUT);
BMO_vert_flag_enable(bm, e->v1, EXT_INPUT);
@@ -227,16 +227,16 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op)
/* not sure what to do about example face, pass NULL for now */
f = BM_face_create_verts(bm, f_verts, 4, NULL, BM_CREATE_NOP, true);
bm_extrude_copy_face_loop_attributes(bm, f);
-
+
if (BMO_edge_flag_test(bm, e, EXT_INPUT)) {
e = e_new;
}
-
+
BMO_face_flag_enable(bm, f, EXT_KEEP);
BMO_edge_flag_enable(bm, e, EXT_KEEP);
BMO_vert_flag_enable(bm, e->v1, EXT_KEEP);
BMO_vert_flag_enable(bm, e->v2, EXT_KEEP);
-
+
}
BMO_op_finish(bm, &dupeop);
@@ -343,7 +343,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
BMO_slot_bool_get(op->slots_in, "use_select_history"));
BMO_slot_buffer_flag_enable(bm, op->slots_in, "geom", BM_EDGE | BM_FACE, EXT_INPUT);
-
+
/* if one flagged face is bordered by an un-flagged face, then we delete
* original geometry unless caller explicitly asked to keep it. */
if (!BMO_slot_bool_get(op->slots_in, "use_keep_orig")) {
@@ -404,7 +404,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
}
}
}
-
+
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
if (BMO_face_flag_test(bm, f, EXT_INPUT)) {
BMO_face_flag_enable(bm, f, EXT_DEL);
@@ -436,7 +436,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
if (delorig) {
BMO_op_exec(bm, &delop);
}
-
+
/* if not delorig, reverse loops of original face */
if (!delorig) {
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
@@ -445,7 +445,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
}
}
}
-
+
BMO_slot_copy(&dupeop, slots_out, "geom.out",
op, slots_out, "geom.out");
@@ -493,7 +493,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
else
fwd = (e_new->l->v == e_new->v1);
-
+
if (fwd) {
f_verts[0] = e->v1;
f_verts[1] = e->v2;
diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c
index d52cb00e172..ca727de5756 100644
--- a/source/blender/bmesh/operators/bmo_hull.c
+++ b/source/blender/bmesh/operators/bmo_hull.c
@@ -46,10 +46,10 @@
/* Internal operator flags */
typedef enum {
HULL_FLAG_INPUT = (1 << 0),
-
+
HULL_FLAG_INTERIOR_ELE = (1 << 1),
HULL_FLAG_OUTPUT_GEOM = (1 << 2),
-
+
HULL_FLAG_DEL = (1 << 3),
HULL_FLAG_HOLE = (1 << 4)
} HullFlags;
@@ -106,7 +106,7 @@ static BMFace *hull_find_example_face(BMesh *bm, BMEdge *e)
static void hull_output_triangles(BMesh *bm, GSet *hull_triangles)
{
GSetIterator iter;
-
+
GSET_ITER (iter, hull_triangles) {
HullTriangle *t = BLI_gsetIterator_getKey(&iter);
int i;
@@ -213,7 +213,7 @@ static HullFinalEdges *hull_final_edges(GSet *hull_triangles)
{
HullFinalEdges *final_edges;
GSetIterator iter;
-
+
final_edges = MEM_callocN(sizeof(HullFinalEdges), "HullFinalEdges");
final_edges->edges = BLI_ghash_ptr_new("final edges ghash");
final_edges->base_pool = BLI_mempool_create(sizeof(ListBase), 0, 128, BLI_MEMPOOL_NOP);
@@ -286,7 +286,7 @@ static void hull_remove_overlapping(
break;
}
}
-
+
/* Note: can't change ghash while iterating, so mark
* with 'skip' flag rather than deleting triangles */
if (BM_vert_in_face(t->v[1], f) &&
@@ -336,7 +336,7 @@ static void hull_tag_unused(BMesh *bm, BMOperator *op)
BMO_ITER (v, &oiter, op->slots_in, "input", BM_VERT) {
if (BMO_vert_flag_test(bm, v, HULL_FLAG_INTERIOR_ELE)) {
bool del = true;
-
+
BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
if (!BMO_edge_flag_test(bm, e, HULL_FLAG_INPUT)) {
del = false;
@@ -406,7 +406,7 @@ static void hull_tag_holes(BMesh *bm, BMOperator *op)
BMO_ITER (e, &oiter, op->slots_in, "input", BM_EDGE) {
bool hole = true;
bool any_faces = false;
-
+
BM_ITER_ELEM (f, &iter, e, BM_FACES_OF_EDGE) {
any_faces = true;
if (!BMO_face_flag_test(bm, f, HULL_FLAG_HOLE)) {
@@ -511,7 +511,7 @@ static void hull_from_bullet(
hull = plConvexHullCompute(coords, num_input_verts);
hull_verts = hull_verts_from_bullet(hull, input_verts, num_input_verts);
-
+
count = plConvexHullNumFaces(hull);
for (i = 0; i < count; i++) {
const int len = plConvexHullGetFaceSize(hull, i);
@@ -601,7 +601,7 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op)
hull_from_bullet(bm, op, hull_triangles, hull_pool);
final_edges = hull_final_edges(hull_triangles);
-
+
hull_mark_interior_elements(bm, op, final_edges);
/* Remove hull triangles covered by an existing face */
diff --git a/source/blender/bmesh/operators/bmo_mirror.c b/source/blender/bmesh/operators/bmo_mirror.c
index f1bf3179cd6..64f9773714b 100644
--- a/source/blender/bmesh/operators/bmo_mirror.c
+++ b/source/blender/bmesh/operators/bmo_mirror.c
@@ -57,13 +57,13 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
BMOpSlot *slot_targetmap;
ototvert = bm->totvert;
-
+
BMO_slot_mat4_get(op->slots_in, "matrix", mtx);
invert_m4_m4(imtx, mtx);
-
+
BMO_op_initf(bm, &dupeop, op->flag, "duplicate geom=%s", op, "geom");
BMO_op_exec(bm, &dupeop);
-
+
BMO_slot_buffer_flag_enable(bm, dupeop.slots_out, "geom.out", BM_ALL_NOLOOP, ELE_NEW);
/* create old -> new mappin */
@@ -74,7 +74,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
BMO_op_callf(bm, op->flag, "transform verts=%fv matrix=%m4", ELE_NEW, mtx);
BMO_op_callf(bm, op->flag, "scale verts=%fv vec=%v", ELE_NEW, scale);
BMO_op_callf(bm, op->flag, "transform verts=%fv matrix=%m4", ELE_NEW, imtx);
-
+
BMO_op_init(bm, &weldop, op->flag, "weld_verts");
slot_targetmap = BMO_slot_get(weldop.slots_in, "targetmap");
@@ -87,7 +87,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
}
v = BM_iter_step(&iter);
}
-
+
if (mirror_u || mirror_v) {
BMFace *f;
BMLoop *l;
@@ -109,7 +109,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
}
BMO_op_exec(bm, &weldop);
-
+
BMO_op_finish(bm, &weldop);
BMO_op_finish(bm, &dupeop);
diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c
index 95d61763902..fd9b88ca4d3 100644
--- a/source/blender/bmesh/operators/bmo_primitive.c
+++ b/source/blender/bmesh/operators/bmo_primitive.c
@@ -940,7 +940,7 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_VERT, VERT_MARK);
BMO_op_callf(bm, op->flag, "rotate cent=%v matrix=%m3 verts=%S", vec, cmat, &bmop, "geom.out");
-
+
prevop = bmop;
}
@@ -1041,7 +1041,7 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op)
v3 = eva[icoface[a][2]];
f = BM_face_create_quad_tri(bm, v1, v2, v3, NULL, NULL, BM_CREATE_NOP);
-
+
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
BMO_edge_flag_enable(bm, l->e, EDGE_MARK);
}
@@ -1296,10 +1296,10 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
BMVert *v1, *lastv1 = NULL, *cent1, *firstv1 = NULL;
float vec[3], mat[4][4], phi, phid;
int a;
-
+
if (!segs)
return;
-
+
BMO_slot_mat4_get(op->slots_in, "matrix", mat);
phid = 2.0f * (float)M_PI / segs;
@@ -1308,7 +1308,7 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
if (cap_ends) {
zero_v3(vec);
mul_m4_v3(mat, vec);
-
+
cent1 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
BMO_vert_flag_enable(bm, cent1, VERT_MARK);
}
@@ -1322,17 +1322,17 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
v1 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
BMO_vert_flag_enable(bm, v1, VERT_MARK);
-
+
if (lastv1)
BM_edge_create(bm, v1, lastv1, NULL, BM_CREATE_NOP);
-
+
if (a && cap_ends) {
BMFace *f;
-
+
f = BM_face_create_quad_tri(bm, cent1, lastv1, v1, NULL, NULL, BM_CREATE_NOP);
BMO_face_flag_enable(bm, f, FACE_NEW);
}
-
+
if (!firstv1)
firstv1 = v1;
@@ -1346,7 +1346,7 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
if (cap_ends) {
BMFace *f;
-
+
f = BM_face_create_quad_tri(bm, cent1, v1, firstv1, NULL, NULL, BM_CREATE_NOP);
BMO_face_flag_enable(bm, f, FACE_NEW);
@@ -1354,11 +1354,11 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
BM_mesh_calc_uvs_circle(bm, mat, radius, FACE_NEW, cd_loop_uv_offset);
}
}
-
+
if (!cap_tris) {
BMO_op_callf(bm, op->flag, "dissolve_faces faces=%ff", FACE_NEW);
}
-
+
BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
}
@@ -1421,10 +1421,10 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
const bool calc_uvs = (cd_loop_uv_offset != -1) && BMO_slot_bool_get(op->slots_in, "calc_uvs");
int a;
-
+
if (!segs)
return;
-
+
BMO_slot_mat4_get(op->slots_in, "matrix", mat);
phid = 2.0f * (float)M_PI / segs;
@@ -1435,13 +1435,13 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
vec[0] = vec[1] = 0.0f;
vec[2] = -depth;
mul_m4_v3(mat, vec);
-
+
cent1 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
vec[0] = vec[1] = 0.0f;
vec[2] = depth;
mul_m4_v3(mat, vec);
-
+
cent2 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
BMO_vert_flag_enable(bm, cent1, VERT_MARK);
@@ -1522,7 +1522,7 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
if (!cap_tris) {
BMO_op_callf(bm, op->flag, "dissolve_faces faces=%ff", FACE_NEW);
}
-
+
BMO_op_callf(bm, op->flag, "remove_doubles verts=%fv dist=%f", VERT_MARK, 0.000001);
BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
}
diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c
index e85751531ae..8468227d17e 100644
--- a/source/blender/bmesh/operators/bmo_removedoubles.c
+++ b/source/blender/bmesh/operators/bmo_removedoubles.c
@@ -303,7 +303,7 @@ void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op)
if (l_first == NULL) {
l_first = l;
}
-
+
for (i = 0; i < bm->ldata.totlayer; i++) {
if (CustomData_layer_has_math(&bm->ldata, i)) {
const int type = bm->ldata.layers[i].type;
@@ -312,7 +312,7 @@ void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op)
e1 = BM_ELEM_CD_GET_VOID_P(l_first, offset);
e2 = BM_ELEM_CD_GET_VOID_P(l, offset);
-
+
CustomData_data_multiply(type, e2, fac);
if (l != l_first) {
@@ -348,7 +348,7 @@ void bmo_average_vert_facedata_exec(BMesh *bm, BMOperator *op)
if (!CustomData_layer_has_math(&bm->ldata, i))
continue;
-
+
CustomData_data_initminmax(type, &min, &max);
BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) {
@@ -378,7 +378,7 @@ void bmo_pointmerge_exec(BMesh *bm, BMOperator *op)
BMVert *v, *vert_snap = NULL;
float vec[3];
BMOpSlot *slot_targetmap;
-
+
BMO_slot_vec_get(op->slots_in, "merge_co", vec);
//BMO_op_callf(bm, op->flag, "collapse_uvs edges=%s", op, "edges");
diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c
index 8f998797a16..90cbe9a5d76 100644
--- a/source/blender/bmesh/operators/bmo_subdivide.c
+++ b/source/blender/bmesh/operators/bmo_subdivide.c
@@ -156,7 +156,7 @@ static BMEdge *connect_smallest_face(BMesh *bm, BMVert *v_a, BMVert *v_b, BMFace
BLI_assert(!BM_loop_is_adjacent(l_a, l_b));
f_new = BM_face_split(bm, f, l_a, l_b, &l_new, NULL, false);
-
+
if (r_f_new) *r_f_new = f_new;
return l_new ? l_new->e : NULL;
}
@@ -380,7 +380,7 @@ static BMVert *bm_subdivide_edge_addvert(
BMEdge **r_edge)
{
BMVert *v_new;
-
+
v_new = BM_edge_split(bm, edge, edge->v1, r_edge, factor_edge_split);
BMO_vert_flag_enable(bm, v_new, ELE_INNER);
@@ -402,7 +402,7 @@ static BMVert *bm_subdivide_edge_addvert(
}
}
#endif
-
+
interp_v3_v3v3(v_new->no, v_a->no, v_b->no, factor_subd);
normalize_v3(v_new->no);
@@ -426,7 +426,7 @@ static BMVert *subdivide_edge_num(
factor_edge_split = 1.0f / (float)(totpoint + 1 - curpoint);
factor_subd = (float)(curpoint + 1) / (float)(totpoint + 1);
}
-
+
v_new = bm_subdivide_edge_addvert(
bm, edge, e_orig, params,
factor_edge_split, factor_subd,
@@ -444,7 +444,7 @@ static void bm_subdivide_multicut(
e_tmp.v1 = &v1_tmp;
e_tmp.v2 = &v2_tmp;
-
+
for (i = 0; i < numcuts; i++) {
v = subdivide_edge_num(bm, eed, &e_tmp, i, params->numcuts, params, v_a, v_b, &e_new);
@@ -456,7 +456,7 @@ static void bm_subdivide_multicut(
if (v->e) BM_CHECK_ELEMENT(v->e);
if (v->e && v->e->l) BM_CHECK_ELEMENT(v->e->l->f);
}
-
+
alter_co(v1, &e_tmp, params, 0, &v1_tmp, &v2_tmp);
alter_co(v2, &e_tmp, params, 1.0, &v1_tmp, &v2_tmp);
}
@@ -526,7 +526,7 @@ static void quad_2edge_split_path(BMesh *bm, BMFace *UNUSED(face), BMVert **vert
{
BMFace *f_new;
int i, numcuts = params->numcuts;
-
+
for (i = 0; i < numcuts; i++) {
connect_smallest_face(bm, verts[i], verts[numcuts + (numcuts - i)], &f_new);
}
@@ -556,7 +556,7 @@ static void quad_2edge_split_innervert(BMesh *bm, BMFace *UNUSED(face), BMVert *
BMVert *v, *v_last;
BMEdge *e, *e_new, e_tmp;
int i, numcuts = params->numcuts;
-
+
v_last = verts[numcuts];
for (i = numcuts - 1; i >= 0; i--) {
@@ -629,7 +629,7 @@ static void quad_3edge_split(BMesh *bm, BMFace *UNUSED(face), BMVert **verts,
{
BMFace *f_new;
int i, add = 0, numcuts = params->numcuts;
-
+
for (i = 0; i < numcuts; i++) {
if (i == numcuts / 2) {
if (numcuts % 2 != 0) {
@@ -687,12 +687,12 @@ static void quad_4edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts
for (i = 0; i < numcuts + 2; i++) {
lines[(s - 1) * s + i] = verts[numcuts + i];
}
-
+
/* first and last members of middle lines */
for (i = 0; i < numcuts; i++) {
a = i;
b = numcuts + 1 + numcuts + 1 + (numcuts - i - 1);
-
+
e = connect_smallest_face(bm, verts[a], verts[b], &f_new);
if (!e)
continue;
@@ -700,10 +700,10 @@ static void quad_4edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts
BMO_edge_flag_enable(bm, e, ELE_INNER);
BMO_face_flag_enable(bm, f_new, ELE_INNER);
-
+
v1 = lines[(i + 1) * s] = verts[a];
v2 = lines[(i + 1) * s + s - 1] = verts[b];
-
+
e_tmp = *e;
for (a = 0; a < numcuts; a++) {
v = subdivide_edge_num(bm, e, &e_tmp, a, numcuts, params, v1, v2, &e_new);
@@ -748,7 +748,7 @@ static void tri_1edge_split(BMesh *bm, BMFace *UNUSED(face), BMVert **verts,
{
BMFace *f_new;
int i, numcuts = params->numcuts;
-
+
for (i = 0; i < numcuts; i++) {
connect_smallest_face(bm, verts[i], verts[numcuts + 1], &f_new);
}
@@ -780,13 +780,13 @@ static void tri_3edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts,
BMVert ***lines, *v, v1_tmp, v2_tmp;
void *stackarr[1];
int i, j, a, b, numcuts = params->numcuts;
-
+
/* number of verts in each lin */
lines = MEM_callocN(sizeof(void *) * (numcuts + 2), "triangle vert table");
-
+
lines[0] = (BMVert **) stackarr;
lines[0][0] = verts[numcuts * 2 + 1];
-
+
lines[numcuts + 1] = MEM_callocN(sizeof(void *) * (numcuts + 2), "triangle vert table 2");
for (i = 0; i < numcuts; i++) {
lines[numcuts + 1][i + 1] = verts[i];
@@ -806,7 +806,7 @@ static void tri_3edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts,
lines[i + 1][0] = verts[a];
lines[i + 1][i + 1] = verts[b];
-
+
e_tmp = *e;
v1_tmp = *verts[a];
v2_tmp = *verts[b];
@@ -819,7 +819,7 @@ static void tri_3edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts,
BMO_edge_flag_enable(bm, e_new, ELE_INNER);
}
}
-
+
/**
* <pre>
* v5
@@ -906,9 +906,9 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
float smooth, fractal, along_normal;
bool use_sphere, use_single_edge, use_grid_fill, use_only_quads;
int cornertype, seed, i, j, a, b, numcuts, totesel, smooth_falloff;
-
+
BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, SUBD_SPLIT);
-
+
numcuts = BMO_slot_int_get(op->slots_in, "cuts");
seed = BMO_slot_int_get(op->slots_in, "seed");
smooth = BMO_slot_float_get(op->slots_in, "smooth");
@@ -935,7 +935,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
patterns[1] = &quad_2edge_fan;
break;
}
-
+
if (use_single_edge) {
patterns[0] = &quad_1edge;
patterns[2] = &tri_1edge;
@@ -953,12 +953,12 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
patterns[3] = NULL;
patterns[5] = NULL;
}
-
+
/* add a temporary shapekey layer to store displacements on current geometry */
BM_data_layer_add(bm, &bm->vdata, CD_SHAPEKEY);
bmo_subd_init_shape_info(bm, &params);
-
+
BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
float *co = BM_ELEM_CD_GET_VOID_P(v, params.shape_info.cd_vert_shape_offset_tmp);
copy_v3_v3(co, v->co);
@@ -990,7 +990,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
BLI_rng_free(rng);
}
-
+
BMO_slot_map_to_flag(bm, op->slots_in, "custom_patterns",
BM_FACE, FACE_CUSTOMFILL);
@@ -1105,10 +1105,10 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
}
}
-
+
if (!matched && totesel) {
SubDFaceData *fd;
-
+
BMO_face_flag_enable(bm, face, SUBD_SPLIT);
/* must initialize all members here */
@@ -1146,7 +1146,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
if (!pat && fd->totedgesel == 2) {
int vlen;
-
+
/* ok, no pattern. we still may be able to do something */
BLI_array_clear(loops);
BLI_array_clear(loops_split);
@@ -1156,7 +1156,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
BM_ITER_ELEM_INDEX (l, &liter, face, BM_LOOPS_OF_FACE, a) {
loops[a] = l;
}
-
+
vlen = BLI_array_len(loops);
/* find the boundary of one of the split edges */
@@ -1167,7 +1167,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
break;
}
}
-
+
if (BMO_vert_flag_test(bm, loops[(a + numcuts + 1) % vlen]->v, ELE_INNER)) {
b = (a + numcuts + 1) % vlen;
}
@@ -1182,7 +1182,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
}
}
}
-
+
b += numcuts - 1;
BLI_array_grow_items(loops_split, numcuts);
@@ -1230,7 +1230,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
b = (b - 1) % vlen;
a = (a + 1) % vlen;
}
-
+
/* Since these are newly created vertices, we don't need to worry about them being legal,
* ... though there are some cases we _should_ check for
* - concave corner of an ngon.
@@ -1281,7 +1281,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
}
BM_data_layer_free_n(bm, &bm->vdata, CD_SHAPEKEY, params.shape_info.tmpkey);
-
+
BLI_stack_free(facedata);
if (edges) BLI_array_free(edges);
if (verts) BLI_array_free(verts);
@@ -1290,7 +1290,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_inner.out", BM_ALL_NOLOOP, ELE_INNER);
BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_split.out", BM_ALL_NOLOOP, ELE_SPLIT);
-
+
BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_ALL_NOLOOP, ELE_INNER | ELE_SPLIT | SUBD_SPLIT);
}
@@ -1306,7 +1306,7 @@ void BM_mesh_esubdivide(
const int seed)
{
BMOperator op;
-
+
/* use_sphere isnt exposed here since its only used for new primitives */
BMO_op_initf(bm, &op, BMO_FLAG_DEFAULTS,
"subdivide_edges edges=%he "
@@ -1325,9 +1325,9 @@ void BM_mesh_esubdivide(
use_single_edge, use_grid_fill,
use_only_quads,
seed);
-
+
BMO_op_exec(bm, &op);
-
+
switch (seltype) {
case SUBDIV_SELECT_NONE:
break;
@@ -1354,11 +1354,11 @@ void bmo_bisect_edges_exec(BMesh *bm, BMOperator *op)
BMOIter siter;
BMEdge *e;
SubDParams params = {0};
-
+
params.numcuts = BMO_slot_int_get(op->slots_in, "cuts");
params.op = op;
params.slot_edge_percents = BMO_slot_get(op->slots_in, "edge_percents");
-
+
BM_data_layer_add(bm, &bm->vdata, CD_SHAPEKEY);
bmo_subd_init_shape_info(bm, &params);
diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c
index 163a9ef599c..e686ef0429a 100644
--- a/source/blender/bmesh/operators/bmo_triangulate.c
+++ b/source/blender/bmesh/operators/bmo_triangulate.c
@@ -83,9 +83,9 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op)
sf_vert_map = BLI_ghash_ptr_new_ex(__func__, BMO_slot_buffer_count(op->slots_in, "edges"));
BMO_slot_vec_get(op->slots_in, "normal", normal);
-
+
BLI_scanfill_begin(&sf_ctx);
-
+
BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
ScanFillVert *sf_verts[2];
BMVert **e_verts = &e->v1;
@@ -108,7 +108,7 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op)
}
nors_tot = BLI_ghash_len(sf_vert_map);
BLI_ghash_free(sf_vert_map, NULL, NULL);
-
+
if (is_zero_v3(normal)) {
/* calculate the normal from the cross product of vert-edge pairs.
@@ -225,7 +225,7 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op)
f = BM_face_create_quad_tri(bm,
sf_tri->v1->tmp.p, sf_tri->v2->tmp.p, sf_tri->v3->tmp.p, NULL,
NULL, BM_CREATE_NO_DOUBLE);
-
+
BMO_face_flag_enable(bm, f, ELE_NEW);
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
if (!BMO_edge_flag_test(bm, l->e, EDGE_MARK)) {
@@ -233,9 +233,9 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op)
}
}
}
-
+
BLI_scanfill_end(&sf_ctx);
-
+
if (use_beauty) {
BMOperator bmop;
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 18039261735..39ca5a2d1ca 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -154,7 +154,7 @@ typedef struct BoundVert {
int add_seam;
int sharp_len;
// int _pad;
-} BoundVert;
+} BoundVert;
/* Mesh structure replacing a vertex */
typedef struct VMesh {
@@ -517,7 +517,7 @@ static BMFace *bev_create_ngon(
static BMFace *bev_create_quad(
BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4,
- BMFace *f1, BMFace *f2, BMFace *f3, BMFace *f4,
+ BMFace *f1, BMFace *f2, BMFace *f3, BMFace *f4,
int mat_nr)
{
BMVert *varr[4] = {v1, v2, v3, v4};
@@ -527,7 +527,7 @@ static BMFace *bev_create_quad(
static BMFace *bev_create_quad_ex(
BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4,
- BMFace *f1, BMFace *f2, BMFace *f3, BMFace *f4,
+ BMFace *f1, BMFace *f2, BMFace *f3, BMFace *f4,
BMEdge *e1, BMEdge *e2, BMEdge *e3, BMEdge *e4,
int mat_nr)
{
@@ -1361,7 +1361,7 @@ static void get_profile_point(BevelParams *bp, const Profile *pro, int i, int n,
else
copy_v3_v3(r_co, pro->cob);
}
-
+
else {
if (n == bp->seg) {
BLI_assert(pro->prof_co != NULL);
@@ -2324,7 +2324,7 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
#ifdef DEBUG_ADJUST
printf("b[%d]=%f * %f, for e%d->offset_r\n", row, weight, eright->offset_r, BM_elem_index_get(eright->e));
#endif
-
+
/* residue np + 2*i + 1 (if cycle) else np - 1 + 2*i + 1:
* left offset for parm i matches its spec; weighted */
row = row + 1;
@@ -2812,7 +2812,7 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm0)
float beta, gamma;
VMesh *vm1;
BoundVert *bndv;
-
+
n = vm0->count;
ns0 = vm0->seg;
ns20 = ns0 / 2;
@@ -2832,7 +2832,7 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm0)
add_v3_v3v3(acc, co1, co2);
madd_v3_v3fl(acc, co, -2.0f);
madd_v3_v3fl(co, acc, -1.0f / 6.0f);
-
+
copy_v3_v3(mesh_vert_canon(vm1, i, 0, 2 * k)->co, co);
}
}
@@ -2847,7 +2847,7 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm0)
add_v3_v3v3(acc, co1, co2);
madd_v3_v3fl(acc, co, -2.0f);
madd_v3_v3fl(co, acc, -1.0f / 6.0f);
-
+
copy_v3_v3(mesh_vert_canon(vm1, i, 0, k)->co, co);
}
bndv = bndv->next;
@@ -2866,7 +2866,7 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm0)
/* Now we do the internal vertices, using standard Catmull-Clark
* and assuming all boundary vertices have valence 4 */
-
+
/* The new face vertices */
for (i = 0; i < n; i++) {
for (j = 0; j < ns20; j++) {
@@ -3087,7 +3087,7 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp)
copy_v3_v3(bndv->profile.proj_dir, bndv->profile.plane_no);
calculate_profile(bp, bndv);
get_profile_point(bp, &bndv->profile, 1, 2, mesh_vert(vm0, i, 0, 1)->co);
-
+
bndv = bndv->next;
}
/* center vertex */
@@ -4823,7 +4823,7 @@ static void bevel_reattach_wires(BMesh *bm, BevelParams *bp, BMVert *v)
vclosest = bndv->nv.v;
votherclosest = bndvother->nv.v;
dclosest = d;
-
+
}
} while ((bndvother = bndvother->next) != bvother->vmesh->boundstart);
}
@@ -5420,7 +5420,7 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb)
kc = kc / bp->offset;
th1 = angle_v3v3v3(va->co, vb->co, vc->co);
th2 = angle_v3v3v3(vb->co, vc->co, vd->co);
-
+
/* First calculate offset at which edge B collapses, which happens
* when advancing clones of A, B, C all meet at a point.
* This only happens if at least two of those three edges have non-zero k's */
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index a3e26451a38..95298986f5a 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -60,7 +60,7 @@ bool AnimationExporter::is_flat_line(std::vector<float> &values, int channel_cou
return true;
}
/*
- * This function creates a complete LINEAR Collada <Animation> Entry with all needed
+ * This function creates a complete LINEAR Collada <Animation> Entry with all needed
* <source>, <sampler>, and <channel> entries.
* This is is used for creating sampled Transformation Animations for either:
*
@@ -78,8 +78,8 @@ bool AnimationExporter::is_flat_line(std::vector<float> &values, int channel_cou
* axis_name = "" (actually not used)
* is_rot = false (see xxx below)
*
- * xxx: I tried to create a 3 axis rotation animation
- * like for translation or scale. But i could not
+ * xxx: I tried to create a 3 axis rotation animation
+ * like for translation or scale. But i could not
* figure out how to setup the channel for this case.
* So for now rotations are exported as 3 separate 1-axis collada animations
* See export_sampled_animation() further down.
@@ -270,7 +270,7 @@ void AnimationExporter::export_sampled_transrotloc_animation(Object *ob, std::ve
create_sampled_animation(3, ctimes, baked_curves[SCALE], ob_name, "scale", "", false);
create_sampled_animation(3, ctimes, baked_curves[LOC], ob_name, "location", "", false);
- /* Not sure how to export rotation as a 3channel animation,
+ /* Not sure how to export rotation as a 3channel animation,
* so separate into 3 single animations for now:
*/
@@ -314,7 +314,7 @@ void AnimationExporter::operator()(Object *ob)
//This needs to be handled by extra profiles, so postponed for now
//export_morph_animation(ob);
-
+
//Export Lamp parameter animations
if ( (ob->type == OB_LAMP) && ((Lamp *)ob->data)->adt && ((Lamp *)ob->data)->adt->action) {
FCurve *fcu = (FCurve *)(((Lamp *)ob->data)->adt->action->curves.first);
@@ -338,7 +338,7 @@ void AnimationExporter::operator()(Object *ob)
if ((STREQ(transformName, "lens")) ||
(STREQ(transformName, "ortho_scale")) ||
- (STREQ(transformName, "clip_end")) ||
+ (STREQ(transformName, "clip_end")) ||
(STREQ(transformName, "clip_start")))
{
create_keyframed_animation(ob, fcu, transformName, true);
@@ -380,7 +380,7 @@ void AnimationExporter::export_object_constraint_animation(Object *ob)
}
void AnimationExporter::export_morph_animation(Object *ob)
-{
+{
FCurve *fcu;
char *transformName;
Key *key = BKE_key_from_object(ob);
@@ -388,12 +388,12 @@ void AnimationExporter::export_morph_animation(Object *ob)
if (key->adt && key->adt->action) {
fcu = (FCurve *)key->adt->action->curves.first;
-
+
while (fcu) {
transformName = extract_transform_name(fcu->rna_path);
create_keyframed_animation(ob, fcu, transformName, true);
-
+
fcu = fcu->next;
}
}
@@ -407,17 +407,17 @@ void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector<fl
bConstraint *con;
for (con = (bConstraint *)conlist->first; con; con = con->next) {
ListBase targets = {NULL, NULL};
-
+
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
-
+
if (!validateConstraints(con)) continue;
if (cti && cti->get_constraint_targets) {
bConstraintTarget *ct;
Object *obtar;
- /* get targets
+ /* get targets
* - constraints should use ct->matrix, not directly accessing values
- * - ct->matrix members have not yet been calculated here!
+ * - ct->matrix members have not yet been calculated here!
*/
cti->get_constraint_targets(con, &targets);
@@ -438,7 +438,7 @@ void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector<fl
float *AnimationExporter::get_eul_source_for_quat(Object *ob)
{
FCurve *fcu = (FCurve *)ob->adt->action->curves.first;
- const int keys = fcu->totvert;
+ const int keys = fcu->totvert;
float *quat = (float *)MEM_callocN(sizeof(float) * fcu->totvert * 4, "quat output source values");
float *eul = (float *)MEM_callocN(sizeof(float) * fcu->totvert * 3, "quat output source values");
float temp_quat[4];
@@ -520,11 +520,11 @@ void AnimationExporter::create_keyframed_animation(Object *ob, FCurve *fcu, char
/*
* Note: Handle transformation animations separately (to apply matrix inverse to fcurves)
- * We will use the object to evaluate the animation on all keyframes and calculate the
+ * We will use the object to evaluate the animation on all keyframes and calculate the
* resulting object matrix. We need this to incorporate the
* effects of the parent inverse matrix (when it contains a rotation component)
*
- * TODO: try to combine exported fcurves into 3 channel animations like done
+ * TODO: try to combine exported fcurves into 3 channel animations like done
* in export_sampled_animation(). For now each channel is exported as separate <Animation>.
*/
@@ -648,7 +648,7 @@ void AnimationExporter::create_keyframed_animation(Object *ob, FCurve *fcu, char
"/common/" /*profile common is only supported */ + get_transform_sid(fcu->rna_path, -1, axis_name, true);
//if shape key animation, this is the main problem, how to define the channel targets.
/*target = get_morph_id(ob) +
- "/value" +*/
+ "/value" +*/
}
addChannel(COLLADABU::URI(empty, sampler_id), target);
@@ -673,7 +673,7 @@ void AnimationExporter::write_bone_animation_matrix(Object *ob_arm, Bone *bone)
}
bool AnimationExporter::is_bone_deform_group(Bone *bone)
-{
+{
bool is_def;
//Check if current bone is deform
if ((bone->flag & BONE_NO_DEFORM) == 0) return true;
@@ -707,7 +707,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B
fcu = fcu->next;
}
- if (!(fcu)) return;*/
+ if (!(fcu)) return;*/
bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name);
if (!pchan)
@@ -728,7 +728,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B
dae_baked_animation(fra, ob_arm, bone);
}
- if (flag & ARM_RESTPOS)
+ if (flag & ARM_RESTPOS)
arm->flag = flag;
BKE_pose_where_is(depsgraph, scene, ob_arm);
}
@@ -921,7 +921,7 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa
if (axis) {
param.push_back(axis);
}
- else
+ else
if (transform) {
param.push_back("TRANSFORM");
}
@@ -1004,7 +1004,7 @@ std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemanti
void AnimationExporter::evaluate_anim_with_constraints(Object *ob, float ctime)
{
- BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL);
ListBase *conlist = get_active_constraints(ob);
bConstraint *con;
for (con = (bConstraint *)conlist->first; con; con = con->next) {
@@ -1020,7 +1020,7 @@ void AnimationExporter::evaluate_anim_with_constraints(Object *ob, float ctime)
obtar = ct->tar;
if (obtar) {
- BKE_animsys_evaluate_animdata(scene, &obtar->id, obtar->adt, ctime, ADT_RECALC_ANIM);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &obtar->id, obtar->adt, ctime, ADT_RECALC_ANIM);
BKE_object_where_is_calc_time(this->depsgraph, scene, obtar, ctime);
}
}
@@ -1035,8 +1035,8 @@ void AnimationExporter::evaluate_anim_with_constraints(Object *ob, float ctime)
/*
* ob is needed to aply parent inverse information to fcurve.
* TODO: Here we have to step over all keyframes for each object and for each fcurve.
- * Instead of processing each fcurve one by one,
- * step over the animation from keyframe to keyframe,
+ * Instead of processing each fcurve one by one,
+ * step over the animation from keyframe to keyframe,
* then create adjusted fcurves (and entries) for all affected objects.
* Then we would need to step through the scene only once.
*/
@@ -1307,7 +1307,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
enable_fcurves(ob->adt->action, bone->name);
}
-
+
std::vector<float>::iterator it;
int j = 0;
for (it = frames.begin(); it != frames.end(); it++) {
@@ -1320,13 +1320,13 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
if (pchan->flag & POSE_CHAIN) {
enable_fcurves(ob->adt->action, NULL);
- BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL);
BKE_pose_where_is(depsgraph, scene, ob);
}
else {
BKE_pose_where_is_bone(depsgraph, scene, ob, pchan, ctime, 1);
}
-
+
// compute bone local mat
if (bone->parent) {
invert_m4_m4(ipar, parchan->pose_mat);
@@ -1334,7 +1334,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
}
else
copy_m4_m4(mat, pchan->pose_mat);
-
+
/* OPEN_SIM_COMPATIBILITY
* AFAIK animation to second life is via BVH, but no
* reason to not have the collada-animation be correct
@@ -1359,7 +1359,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
else {
copy_m4_m4(mat, ob->obmat);
}
-
+
UnitConverter converter;
double outmat[4][4];
@@ -1515,7 +1515,7 @@ std::string AnimationExporter::get_light_param_sid(char *rna_path, int tm_type,
if (tm_name.size()) {
if (axis_name[0])
return tm_name + "." + std::string(axis_name);
- else
+ else
return tm_name;
}
@@ -1564,7 +1564,7 @@ std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type,
if (tm_name.size()) {
if (axis_name[0])
return tm_name + "." + std::string(axis_name);
- else
+ else
return tm_name;
}
@@ -1572,7 +1572,7 @@ std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type,
}
/*
- * Assign sid of the animated parameter or transform for rotation,
+ * Assign sid of the animated parameter or transform for rotation,
* axis name is always appended and the value of append_axis is ignored
*/
std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis)
@@ -1751,7 +1751,7 @@ void AnimationExporter::find_sampleframes(Object *ob, std::vector<float> &fra)
} while (true);
}
-/*
+/*
* find keyframes of all the objects animations
*/
void AnimationExporter::find_keyframes(Object *ob, std::vector<float> &fra)
@@ -1844,7 +1844,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo
arm->flag &= ~ARM_RESTPOS;
BKE_pose_where_is(depsgraph, scene, ob_arm);
}
- //v array will hold all values which will be exported.
+ //v array will hold all values which will be exported.
if (fra.size()) {
float *values = (float *)MEM_callocN(sizeof(float) * 3 * fra.size(), "temp. anim frames");
sample_animation(values, fra, transform_type, bone, ob_arm, pchan);
@@ -1870,7 +1870,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo
}
// restore restpos
- if (flag & ARM_RESTPOS)
+ if (flag & ARM_RESTPOS)
arm->flag = flag;
BKE_pose_where_is(depsgraph, scene, ob_arm);
}
@@ -1896,7 +1896,7 @@ void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, i
float ctime = BKE_scene_frame_get_from_ctime(scene, *it);
- BKE_animsys_evaluate_animdata(scene, &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM);
BKE_pose_where_is_bone(depsgraph, scene, ob_arm, pchan, ctime, 1);
// compute bone local mat
diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h
index 2ed0a92d89c..a50bcaf0ef4 100644
--- a/source/blender/collada/AnimationExporter.h
+++ b/source/blender/collada/AnimationExporter.h
@@ -23,7 +23,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
-extern "C"
+extern "C"
{
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
@@ -100,8 +100,8 @@ public:
bool exportAnimations(Scene *sce);
// called for each exported object
- void operator() (Object *ob);
-
+ void operator() (Object *ob);
+
protected:
const ExportSettings *export_settings;
@@ -127,7 +127,7 @@ protected:
// dae_bone_animation -> add_bone_animation
// (blend this into dae_bone_animation)
void dae_bone_animation(std::vector<float> &fra, float *v, int tm_type, int axis, std::string ob_name, std::string bone_name);
-
+
void dae_baked_animation(std::vector<float> &fra, Object *ob_arm, Bone *bone);
void dae_baked_object_animation(std::vector<float> &fra, Object *ob);
@@ -140,9 +140,9 @@ protected:
void add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param,
COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform);
-
+
void get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool is_angle, float *values, int *length);
-
+
float* get_eul_source_for_quat(Object *ob );
bool is_flat_line(std::vector<float> &values, int channel_count);
@@ -171,12 +171,12 @@ protected:
std::string create_interpolation_source(FCurve *fcu, const std::string& anim_id, const char *axis_name, bool *has_tangents);
std::string fake_interpolation_source(int tot, const std::string& anim_id, const char *axis_name);
-
+
// for rotation, axis name is always appended and the value of append_axis is ignored
std::string get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis);
std::string get_light_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis);
std::string get_camera_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis);
-
+
void find_keyframes(Object *ob, std::vector<float> &fra, const char *prefix, const char *tm_name);
void find_keyframes(Object *ob, std::vector<float> &fra);
void find_sampleframes(Object *ob, std::vector<float> &fra);
@@ -185,13 +185,13 @@ protected:
void make_anim_frames_from_targets(Object *ob, std::vector<float> &frames );
void find_rotation_frames(Object *ob, std::vector<float> &fra, const char *prefix, int rotmode);
-
+
// enable fcurves driving a specific bone, disable all the rest
// if bone_name = NULL enable all fcurves
void enable_fcurves(bAction *act, char *bone_name);
-
+
bool hasAnimations(Scene *sce);
-
+
char *extract_transform_name(char *rna_path);
std::string getObjectBoneName(Object *ob, const FCurve * fcu);
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index f37b0ee1319..e57f8c2f652 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -118,7 +118,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
// input, output
- bez.vec[1][0] = bc_get_float_value(input, j) * fps;
+ bez.vec[1][0] = bc_get_float_value(input, j) * fps;
bez.vec[1][1] = bc_get_float_value(output, j * dim + i);
@@ -135,14 +135,14 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
// outtangent
bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim) + (2 * i)) * fps;
bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim) + (2 * i) + 1);
- if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER)
+ if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER)
bez.ipo = BEZT_IPO_BEZ;
- else
+ else
bez.ipo = BEZT_IPO_CONST;
//bez.h1 = bez.h2 = HD_AUTO;
}
else {
- bez.h1 = bez.h2 = HD_AUTO;
+ bez.h1 = bez.h2 = HD_AUTO;
bez.ipo = BEZT_IPO_LIN;
}
// bez.ipo = U.ipo_new; /* use default interpolation mode here... */
@@ -180,13 +180,13 @@ void AnimationImporter::fcurve_is_used(FCurve *fcu)
}
-void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector<FCurve *>& curves, char *rna_path, int array_index, Animation *animated)
+void AnimationImporter::add_fcurves_to_object(Main *bmain, Object *ob, std::vector<FCurve *>& curves, char *rna_path, int array_index, Animation *animated)
{
bAction *act;
-
- if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID *)&ob->id, 1);
+
+ if (!ob->adt || !ob->adt->action) act = verify_adt_action(bmain, (ID *)&ob->id, 1);
else act = ob->adt->action;
-
+
std::vector<FCurve *>::iterator it;
int i;
@@ -198,39 +198,39 @@ void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector<FCurve *>&
if (is_rotation)
fcurve_deg_to_rad(fcu);
#endif
-
+
for (it = curves.begin(), i = 0; it != curves.end(); it++, i++) {
FCurve *fcu = *it;
fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path));
-
+
if (array_index == -1) fcu->array_index = i;
else fcu->array_index = array_index;
-
+
if (ob->type == OB_ARMATURE) {
bActionGroup *grp = NULL;
const char *bone_name = bc_get_joint_name(animated->node);
-
+
if (bone_name) {
/* try to find group */
grp = BKE_action_group_find_name(act, bone_name);
-
+
/* no matching groups, so add one */
if (grp == NULL) {
/* Add a new group, and make it active */
grp = (bActionGroup *)MEM_callocN(sizeof(bActionGroup), "bActionGroup");
-
+
grp->flag = AGRP_SELECTED;
BLI_strncpy(grp->name, bone_name, sizeof(grp->name));
-
+
BLI_addtail(&act->groups, grp);
BLI_uniquename(&act->groups, grp, CTX_DATA_(BLT_I18NCONTEXT_ID_ACTION, "Group"), '.',
offsetof(bActionGroup, name), 64);
}
-
+
/* add F-Curve to group */
action_groups_add_channel(act, grp, fcu);
fcurve_is_used(fcu);
-
+
}
#if 0
if (is_rotation) {
@@ -263,7 +263,7 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim)
{
if (anim->getAnimationType() == COLLADAFW::Animation::ANIMATION_CURVE) {
COLLADAFW::AnimationCurve *curve = (COLLADAFW::AnimationCurve *)anim;
-
+
// XXX Don't know if it's necessary
// Should we check outPhysicalDimension?
if (curve->getInPhysicalDimension() != COLLADAFW::PHYSICAL_DIMENSION_TIME) {
@@ -296,10 +296,10 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim)
else {
fprintf(stderr, "FORMULA animation type is not supported yet.\n");
}
-
+
return true;
}
-
+
// called on post-process stage after writeVisualScenes
bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList *animlist)
{
@@ -340,16 +340,16 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
{
bActionGroup *grp;
int i;
-
+
for (grp = (bActionGroup *)act->groups.first; grp; grp = grp->next) {
FCurve *eulcu[3] = {NULL, NULL, NULL};
-
+
if (fcurves_actionGroup_map.find(grp) == fcurves_actionGroup_map.end())
continue;
std::vector<FCurve *> &rot_fcurves = fcurves_actionGroup_map[grp];
-
+
if (rot_fcurves.size() > 3) continue;
for (i = 0; i < rot_fcurves.size(); i++)
@@ -437,7 +437,7 @@ void AnimationImporter::modify_fcurve(std::vector<FCurve *> *curves, const char
for (it = curves->begin(), i = 0; it != curves->end(); it++, i++) {
FCurve *fcu = *it;
fcu->rna_path = BLI_strdup(rna_path);
-
+
if (array_index == -1) fcu->array_index = i;
else fcu->array_index = array_index;
@@ -674,7 +674,7 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list
}
}
}
-
+
}
float AnimationImporter::convert_to_focal_length(float in_xfov, int fov_type, float aspect, float sensorx)
@@ -711,7 +711,7 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId& listid
//Add the curves of the current animation to the object
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
-
+
for (unsigned int i = 0; i < fcu->totvert; i++) {
fcu->bezt[i].vec[0][1] = convert_to_focal_length(fcu->bezt[i].vec[0][1], fov_type, aspect, cam->sensor_x);
fcu->bezt[i].vec[1][1] = convert_to_focal_length(fcu->bezt[i].vec[1][1], fov_type, aspect, cam->sensor_x);
@@ -725,7 +725,7 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId& listid
}
}
-void AnimationImporter::apply_matrix_curves(Object *ob, std::vector<FCurve *>& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node,
+void AnimationImporter::apply_matrix_curves(Main *bmain, Object *ob, std::vector<FCurve *>& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node,
COLLADAFW::Transformation *tm)
{
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
@@ -840,7 +840,7 @@ void AnimationImporter::apply_matrix_curves(Object *ob, std::vector<FCurve *>& a
add_bezt(newcu[i], fra, scale[i - 7]);
}
}
- verify_adt_action((ID *)&ob->id, 1);
+ verify_adt_action(bmain, (ID *)&ob->id, 1);
ListBase *curves = &ob->adt->action->curves;
@@ -869,7 +869,7 @@ void AnimationImporter::apply_matrix_curves(Object *ob, std::vector<FCurve *>& a
/*
* This function returns the aspet ration from the Collada camera.
*
- * Note:COLLADA allows to specify either XFov, or YFov alone.
+ * Note:COLLADA allows to specify either XFov, or YFov alone.
* In that case the aspect ratio can be determined from
* the viewport aspect ratio (which is 1:1 ?)
* XXX: check this: its probably wrong!
@@ -897,18 +897,18 @@ static const double get_aspect_ratio(const COLLADAFW::Camera *camera)
return aspect;
}
-static ListBase &get_animation_curves(Material *ma)
+static ListBase &get_animation_curves(Main *bmain, Material *ma)
{
bAction *act;
if (!ma->adt || !ma->adt->action)
- act = verify_adt_action((ID *)&ma->id, 1);
+ act = verify_adt_action(bmain, (ID *)&ma->id, 1);
else
act = ma->adt->action;
return act->curves;
}
-void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
+void AnimationImporter::translate_Animations(Main *bmain, COLLADAFW::Node *node,
std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>& root_map,
std::multimap<COLLADAFW::UniqueId, Object *>& object_map,
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map,
@@ -941,7 +941,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path));
- if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID *)&ob->id, 1);
+ if (!ob->adt || !ob->adt->action) act = verify_adt_action(bmain, (ID *)&ob->id, 1);
else act = ob->adt->action;
//Get the list of animation curves of the object
@@ -949,7 +949,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations();
- //for each transformation in node
+ //for each transformation in node
for (unsigned int i = 0; i < nodeTransforms.getCount(); i++) {
COLLADAFW::Transformation *transform = nodeTransforms[i];
COLLADAFW::Transformation::TransformationType tm_type = transform->getTransformationType();
@@ -972,12 +972,11 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
if (is_matrix) {
- apply_matrix_curves(ob, animcurves, root, node, transform);
+ apply_matrix_curves(bmain, ob, animcurves, root, node, transform);
}
- else {
-
+ else {
if (is_joint) {
- add_bone_animation_sampled(ob, animcurves, root, node, transform);
+ add_bone_animation_sampled(bmain, ob, animcurves, root, node, transform);
}
else {
//calculate rnapaths and array index of fcurves according to transformation and animation class
@@ -987,12 +986,12 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
//Add the curves of the current animation to the object
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
-
+
BLI_addtail(AnimCurves, fcu);
fcurve_is_used(fcu);
}
}
-
+
}
}
}
@@ -1005,7 +1004,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
if ((animType->light) != 0) {
Lamp *lamp = (Lamp *) ob->data;
- if (!lamp->adt || !lamp->adt->action) act = verify_adt_action((ID *)&lamp->id, 1);
+ if (!lamp->adt || !lamp->adt->action) act = verify_adt_action(bmain, (ID *)&lamp->id, 1);
else act = lamp->adt->action;
ListBase *AnimCurves = &(act->curves);
@@ -1018,7 +1017,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
const COLLADAFW::Color *col = &(light->getColor());
const COLLADAFW::UniqueId& listid = col->getAnimationList();
- Assign_color_animations(listid, AnimCurves, "color");
+ Assign_color_animations(listid, AnimCurves, "color");
}
if ((animType->light & LIGHT_FOA) != 0) {
const COLLADAFW::AnimatableFloat *foa = &(light->getFallOffAngle());
@@ -1039,7 +1038,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
if (animType->camera != 0) {
Camera *cam = (Camera *) ob->data;
if (!cam->adt || !cam->adt->action)
- act = verify_adt_action((ID *)&cam->id, 1);
+ act = verify_adt_action(bmain, (ID *)&cam->id, 1);
else
act = cam->adt->action;
@@ -1052,14 +1051,14 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
if ((animType->camera & CAMERA_XFOV) != 0) {
const COLLADAFW::AnimatableFloat *xfov = &(camera->getXFov());
const COLLADAFW::UniqueId& listid = xfov->getAnimationList();
- double aspect = get_aspect_ratio(camera);
+ double aspect = get_aspect_ratio(camera);
Assign_lens_animations(listid, AnimCurves, aspect, cam, "lens", CAMERA_XFOV);
}
else if ((animType->camera & CAMERA_YFOV) != 0) {
const COLLADAFW::AnimatableFloat *yfov = &(camera->getYFov());
const COLLADAFW::UniqueId& listid = yfov->getAnimationList();
- double aspect = get_aspect_ratio(camera);
+ double aspect = get_aspect_ratio(camera);
Assign_lens_animations(listid, AnimCurves, aspect, cam, "lens", CAMERA_YFOV);
}
@@ -1103,7 +1102,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
fprintf(stderr, "Collada: Node %s refers to undefined material\n", node->getName().c_str());
continue;
}
- ListBase &AnimCurves = get_animation_curves(ma);
+ ListBase &AnimCurves = get_animation_curves(bmain, ma);
const COLLADAFW::CommonEffectPointerArray& commonEffects = ef->getCommonEffects();
COLLADAFW::EffectCommon *efc = commonEffects[0];
if ((animType->material & MATERIAL_SHININESS) != 0) {
@@ -1137,7 +1136,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
delete animType;
}
-void AnimationImporter::add_bone_animation_sampled(Object *ob, std::vector<FCurve *>& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node, COLLADAFW::Transformation *tm)
+void AnimationImporter::add_bone_animation_sampled(Main *bmain, Object *ob, std::vector<FCurve *>& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node, COLLADAFW::Transformation *tm)
{
const char *bone_name = bc_get_joint_name(node);
char joint_path[200];
@@ -1260,7 +1259,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob, std::vector<FCurv
add_bezt(newcu[i], fra, scale[i - 7]);
}
}
- verify_adt_action((ID *)&ob->id, 1);
+ verify_adt_action(bmain, (ID *)&ob->id, 1);
// add curves
for (int i = 0; i < totcu; i++) {
@@ -1282,7 +1281,7 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(const COLLADAF
const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations();
- //for each transformation in node
+ //for each transformation in node
for (unsigned int i = 0; i < nodeTransforms.getCount(); i++) {
COLLADAFW::Transformation *transform = nodeTransforms[i];
const COLLADAFW::UniqueId& listid = transform->getAnimationList();
@@ -1370,7 +1369,7 @@ int AnimationImporter::setAnimType(const COLLADAFW::Animatable *prop, int types,
anim_type = types;
return anim_type;
-}
+}
// Is not used anymore.
void AnimationImporter::find_frames_old(std::vector<float> *frames, COLLADAFW::Node *node, COLLADAFW::Transformation::TransformationType tm_type)
@@ -1392,7 +1391,7 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames, COLLADAFW::N
const COLLADAFW::UniqueId& listid = transform->getAnimationList();
//if transform is animated its animlist must exist.
if (animlist_map.find(listid) != animlist_map.end()) {
-
+
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings();
@@ -1436,17 +1435,17 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames, COLLADAFW::N
// prerequisites:
// animlist_map - map animlist id -> animlist
// curve_map - map anim id -> curve(s)
-Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
+Object *AnimationImporter::translate_animation_OLD(Main *bmain, COLLADAFW::Node *node,
std::map<COLLADAFW::UniqueId, Object *>& object_map,
std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>& root_map,
COLLADAFW::Transformation::TransformationType tm_type,
Object *par_job)
{
-
+
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
-
+
COLLADAFW::Node *root = root_map.find(node->getUniqueId()) == root_map.end() ? node : root_map[node->getUniqueId()];
Object *ob = is_joint ? armature_importer->get_armature_for_joint(node) : object_map[node->getUniqueId()];
const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL;
@@ -1457,11 +1456,11 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
// frames at which to sample
std::vector<float> frames;
-
+
find_frames_old(&frames, node, tm_type);
-
+
unsigned int i;
-
+
float irest_dae[4][4];
float rest[4][4], irest[4][4];
@@ -1659,7 +1658,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
#endif
}
- verify_adt_action((ID *)&ob->id, 1);
+ verify_adt_action(bmain, (ID *)&ob->id, 1);
ListBase *curves = &ob->adt->action->curves;
@@ -1732,9 +1731,9 @@ void AnimationImporter::evaluate_transform_at_frame(float mat[4][4], COLLADAFW::
}
}
-static void report_class_type_unsupported(const char *path,
+static void report_class_type_unsupported(const char *path,
const COLLADAFW::AnimationList::AnimationClass animclass,
- const COLLADAFW::Transformation::TransformationType type)
+ const COLLADAFW::Transformation::TransformationType type)
{
if (animclass == COLLADAFW::AnimationList::UNKNOWN_CLASS) {
fprintf(stderr, "%s: UNKNOWN animation class\n", path);
@@ -1829,7 +1828,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
fprintf(stderr, "%s: expected 1 curve, got %d\n", path, (int)curves.size());
return false;
}
-
+
switch (animclass) {
case COLLADAFW::AnimationList::POSITION_X:
vec[0] = evaluate_fcurve(curves[0], fra);
@@ -2011,7 +2010,7 @@ void AnimationImporter::add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurv
{
const char *bone_name = bc_get_joint_name(node);
bAction *act = ob->adt->action;
-
+
/* try to find group */
bActionGroup *grp = BKE_action_group_find_name(act, bone_name);
diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h
index e25116cac9f..f63329158f0 100644
--- a/source/blender/collada/AnimationImporter.h
+++ b/source/blender/collada/AnimationImporter.h
@@ -19,7 +19,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
/** \file AnimationImporter.h
* \ingroup collada
*/
@@ -75,9 +75,9 @@ private:
std::map<COLLADAFW::UniqueId, const COLLADAFW::AnimationList*> animlist_map;
std::vector<FCurve*> unused_curves;
std::map<COLLADAFW::UniqueId, Object*> joint_objects;
-
+
FCurve *create_fcurve(int array_index, const char *rna_path);
-
+
void add_bezt(FCurve *fcu, float frame, float value, eBezTriple_Interpolation ipo=BEZT_IPO_LIN);
// create one or several fcurves depending on the number of parameters being animated
@@ -87,9 +87,9 @@ private:
void fcurve_is_used(FCurve *fcu);
- void add_fcurves_to_object(Object *ob, std::vector<FCurve*>& curves, char *rna_path, int array_index, Animation *animated);
+ void add_fcurves_to_object(Main *bmain, Object *ob, std::vector<FCurve*>& curves, char *rna_path, int array_index, Animation *animated);
+
-
int typeFlag;
std::string import_from_version;
@@ -121,7 +121,7 @@ private:
MATERIAL_TRANSPARENCY = 1 << 4,
MATERIAL_IOR = 1 << 5
};
-
+
enum AnimationType
{
INANIMATE = 0,
@@ -144,7 +144,7 @@ public:
void set_import_from_version(std::string import_from_version);
bool write_animation(const COLLADAFW::Animation* anim);
-
+
// called on post-process stage after writeVisualScenes
bool write_animation_list(const COLLADAFW::AnimationList* animlist);
@@ -153,7 +153,7 @@ public:
virtual void change_eul_to_quat(Object *ob, bAction *act);
#endif
- void translate_Animations(COLLADAFW::Node * Node,
+ void translate_Animations(Main *bmain, COLLADAFW::Node * Node,
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
std::multimap<COLLADAFW::UniqueId, Object*>& object_map,
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map,
@@ -161,10 +161,10 @@ public:
AnimMix* get_animation_type( const COLLADAFW::Node * node, std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map );
- void apply_matrix_curves(Object *ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node,
+ void apply_matrix_curves(Main *bmain, Object *ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node,
COLLADAFW::Transformation * tm );
-
- void add_bone_animation_sampled(Object *ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, COLLADAFW::Transformation * tm);
+
+ void add_bone_animation_sampled(Main *bmain, Object *ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, COLLADAFW::Transformation * tm);
void Assign_transform_animations(COLLADAFW::Transformation* transform,
const COLLADAFW::AnimationList::AnimationBinding *binding,
@@ -175,18 +175,18 @@ public:
void Assign_lens_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, const double aspect, Camera *cam, const char *anim_type, int fov_type);
int setAnimType ( const COLLADAFW::Animatable * prop, int type, int addition);
-
+
void modify_fcurve(std::vector<FCurve*>* curves, const char *rna_path, int array_index );
void unused_fcurve(std::vector<FCurve*>* curves );
// prerequisites:
// animlist_map - map animlist id -> animlist
// curve_map - map anim id -> curve(s)
- Object * translate_animation_OLD(COLLADAFW::Node *node,
+ Object * translate_animation_OLD(Main *bmain, COLLADAFW::Node *node,
std::map<COLLADAFW::UniqueId, Object*>& object_map,
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
COLLADAFW::Transformation::TransformationType tm_type,
Object *par_job = NULL);
-
+
void find_frames( std::vector<float>* frames, std::vector<FCurve*>* curves );
void find_frames_old( std::vector<float>* frames, COLLADAFW::Node * node, COLLADAFW::Transformation::TransformationType tm_type );
// internal, better make it private
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp
index 5e349535610..85b9d3297ca 100644
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@ -62,10 +62,11 @@ ArmatureExporter::ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSett
}
// write bone nodes
-void ArmatureExporter::add_armature_bones(Depsgraph *depsgraph, Object *ob_arm,
+void ArmatureExporter::add_armature_bones(bContext *C, Depsgraph *depsgraph, Object *ob_arm,
Scene *sce, SceneExporter *se,
std::list<Object *>& child_objects)
{
+ Main *bmain = CTX_data_main(C);
// write bone nodes
bArmature * armature = (bArmature *)ob_arm->data;
@@ -77,11 +78,11 @@ void ArmatureExporter::add_armature_bones(Depsgraph *depsgraph, Object *ob_arm,
for (Bone *bone = (Bone *)armature->bonebase.first; bone; bone = bone->next) {
// start from root bones
if (!bone->parent)
- add_bone_node(depsgraph, bone, ob_arm, sce, se, child_objects);
+ add_bone_node(C, depsgraph, bone, ob_arm, sce, se, child_objects);
}
if (!is_edited) {
- ED_armature_from_edit(armature);
+ ED_armature_from_edit(bmain, armature);
ED_armature_edit_free(armature);
}
}
@@ -117,7 +118,7 @@ bool ArmatureExporter::add_instance_controller(Object *ob)
}
InstanceWriter::add_material_bindings(ins.getBindMaterial(), ob, this->export_settings->active_uv_only);
-
+
ins.add();
return true;
}
@@ -146,7 +147,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O
Base *base = (Base *) sce->base.first;
while (base) {
Object *ob = base->object;
-
+
if (ob->type == OB_MESH && get_assigned_armature(ob) == ob_arm) {
objects.push_back(ob);
}
@@ -157,7 +158,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O
#endif
// parent_mat is armature-space
-void ArmatureExporter::add_bone_node(Depsgraph *depsgraph, Bone *bone, Object *ob_arm, Scene *sce,
+void ArmatureExporter::add_bone_node(bContext *C, Depsgraph *depsgraph, Bone *bone, Object *ob_arm, Scene *sce,
SceneExporter *se,
std::list<Object *>& child_objects)
{
@@ -231,7 +232,7 @@ void ArmatureExporter::add_bone_node(Depsgraph *depsgraph, Bone *bone, Object *o
mul_m4_m4m4((*i)->parentinv, temp, (*i)->parentinv);
}
- se->writeNodes(depsgraph, *i, sce);
+ se->writeNodes(C, depsgraph, *i, sce);
copy_m4_m4((*i)->parentinv, backup_parinv);
child_objects.erase(i++);
@@ -240,13 +241,13 @@ void ArmatureExporter::add_bone_node(Depsgraph *depsgraph, Bone *bone, Object *o
}
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
- add_bone_node(depsgraph, child, ob_arm, sce, se, child_objects);
+ add_bone_node(C, depsgraph, child, ob_arm, sce, se, child_objects);
}
node.end();
}
else {
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
- add_bone_node(depsgraph, child, ob_arm, sce, se, child_objects);
+ add_bone_node(C, depsgraph, child, ob_arm, sce, se, child_objects);
}
}
}
@@ -264,7 +265,7 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW:
if (!has_restmat) {
/* Have no restpose matrix stored, try old style <= Blender 2.78 */
-
+
bc_create_restpose_mat(this->export_settings, bone, bone_rest_mat, bone->arm_mat, true);
if (bone->parent) {
diff --git a/source/blender/collada/ArmatureExporter.h b/source/blender/collada/ArmatureExporter.h
index 17c02d637e8..7efa8b70e43 100644
--- a/source/blender/collada/ArmatureExporter.h
+++ b/source/blender/collada/ArmatureExporter.h
@@ -60,7 +60,7 @@ public:
ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
// write bone nodes
- void add_armature_bones(struct Depsgraph *depsgraph, Object *ob_arm, Scene *sce, SceneExporter *se,
+ void add_armature_bones(bContext *C, struct Depsgraph *depsgraph, Object *ob_arm, Scene *sce, SceneExporter *se,
std::list<Object *>& child_objects);
bool add_instance_controller(Object *ob);
@@ -85,7 +85,7 @@ private:
// Scene, SceneExporter and the list of child_objects
// are required for writing bone parented objects
- void add_bone_node(struct Depsgraph *depsgraph, Bone *bone, Object *ob_arm, Scene *sce, SceneExporter *se,
+ void add_bone_node(bContext *C, struct Depsgraph *depsgraph, Bone *bone, Object *ob_arm, Scene *sce, SceneExporter *se,
std::list<Object *>& child_objects);
void add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node);
diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp
index f24688479af..19f174d4840 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -61,7 +61,7 @@ ArmatureImporter::ArmatureImporter(UnitConverter *conv, MeshImporterBase *mesh,
view_layer(view_layer),
unit_converter(conv),
import_settings(import_settings),
- empty(NULL),
+ empty(NULL),
mesh_importer(mesh) {
}
@@ -103,7 +103,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBon
std::vector<COLLADAFW::Node *>::iterator it;
it = std::find(finished_joints.begin(), finished_joints.end(), node);
if (it != finished_joints.end()) return chain_length;
-
+
EditBone *bone = ED_armature_ebone_add(arm, bc_get_joint_name(node));
totbone++;
@@ -141,7 +141,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBon
if (parent) bone->parent = parent;
- float loc[3], size[3], rot[3][3];
+ float loc[3], size[3], rot[3][3];
BoneExtensionMap &extended_bones = bone_extension_manager.getExtensionMap(arm);
BoneExtended &be = add_bone_extended(bone, node, totchild, layer_labels, extended_bones);
int layer = be.get_bone_layers();
@@ -386,7 +386,7 @@ void ArmatureImporter::set_euler_rotmode()
COLLADAFW::Node *joint = it->second;
std::map<COLLADAFW::UniqueId, SkinInfo>::iterator sit;
-
+
for (sit = skin_by_data_uid.begin(); sit != skin_by_data_uid.end(); sit++) {
SkinInfo& skin = sit->second;
@@ -410,7 +410,7 @@ void ArmatureImporter::set_euler_rotmode()
Object *ArmatureImporter::get_empty_for_leaves()
{
if (empty) return empty;
-
+
empty = bc_add_object(scene, view_layer, OB_EMPTY, NULL);
empty->empty_drawtype = OB_EMPTY_SPHERE;
@@ -448,7 +448,7 @@ ArmatureJoints& ArmatureImporter::get_armature_joints(Object *ob_arm)
return armature_joints.back();
}
#endif
-void ArmatureImporter::create_armature_bones(std::vector<Object *> &ob_arms)
+void ArmatureImporter::create_armature_bones(Main *bmain, std::vector<Object *> &ob_arms)
{
std::vector<COLLADAFW::Node *>::iterator ri;
std::vector<std::string> layer_labels;
@@ -456,7 +456,7 @@ void ArmatureImporter::create_armature_bones(std::vector<Object *> &ob_arms)
//if there is an armature created for root_joint next root_joint
for (ri = root_joints.begin(); ri != root_joints.end(); ri++) {
if (get_armature_for_joint(*ri) != NULL) continue;
-
+
Object *ob_arm = joint_parent_map[(*ri)->getUniqueId()];
if (!ob_arm)
continue;
@@ -481,7 +481,7 @@ void ArmatureImporter::create_armature_bones(std::vector<Object *> &ob_arms)
}
/* exit armature edit mode to populate the Armature object */
- ED_armature_from_edit(armature);
+ ED_armature_from_edit(bmain, armature);
ED_armature_edit_free(armature);
ED_armature_to_edit(armature);
@@ -489,7 +489,7 @@ void ArmatureImporter::create_armature_bones(std::vector<Object *> &ob_arms)
fix_leaf_bone_hierarchy(armature, (Bone *)armature->bonebase.first, this->import_settings->fix_orientation);
unskinned_armature_map[(*ri)->getUniqueId()] = ob_arm;
- ED_armature_from_edit(armature);
+ ED_armature_from_edit(bmain, armature);
ED_armature_edit_free(armature);
int index = std::find(ob_arms.begin(), ob_arms.end(), ob_arm) - ob_arms.begin();
@@ -501,7 +501,7 @@ void ArmatureImporter::create_armature_bones(std::vector<Object *> &ob_arms)
}
}
-Object *ArmatureImporter::create_armature_bones(SkinInfo& skin)
+Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo& skin)
{
// just do like so:
// - get armature
@@ -572,8 +572,8 @@ Object *ArmatureImporter::create_armature_bones(SkinInfo& skin)
}
if (!shared && this->joint_parent_map.size() > 0) {
- // All armatures have been created while creating the Node tree.
- // The Collada exporter currently does not create a
+ // All armatures have been created while creating the Node tree.
+ // The Collada exporter currently does not create a
// strict relationship between geometries and armatures
// So when we reimport a Blender collada file, then we have
// to guess what is meant.
@@ -619,7 +619,7 @@ Object *ArmatureImporter::create_armature_bones(SkinInfo& skin)
}
/* exit armature edit mode to populate the Armature object */
- ED_armature_from_edit(armature);
+ ED_armature_from_edit(bmain, armature);
ED_armature_edit_free(armature);
ED_armature_to_edit(armature);
@@ -627,7 +627,7 @@ Object *ArmatureImporter::create_armature_bones(SkinInfo& skin)
connect_bone_chains(armature, (Bone *)armature->bonebase.first, UNLIMITED_CHAIN_MAX);
}
fix_leaf_bone_hierarchy(armature, (Bone *)armature->bonebase.first, this->import_settings->fix_orientation);
- ED_armature_from_edit(armature);
+ ED_armature_from_edit(bmain, armature);
ED_armature_edit_free(armature);
DEG_id_tag_update(&ob_arm->id, OB_RECALC_OB | OB_RECALC_DATA);
@@ -657,12 +657,12 @@ void ArmatureImporter::set_pose(Object *ob_arm, COLLADAFW::Node *root_node, con
}
else {
-
+
copy_m4_m4(mat, obmat);
float invObmat[4][4];
invert_m4_m4(invObmat, ob_arm->obmat);
mul_m4_m4m4(pchan->pose_mat, invObmat, mat);
-
+
}
//float angle = 0.0f;
@@ -709,6 +709,7 @@ void ArmatureImporter::add_root_joint(COLLADAFW::Node *node)
// here we add bones to armatures, having armatures previously created in write_controller
void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &objects_to_scale)
{
+ Main *bmain = CTX_data_main(C);
std::vector<Object *> ob_arms;
std::map<COLLADAFW::UniqueId, SkinInfo>::iterator it;
@@ -718,7 +719,7 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
SkinInfo& skin = it->second;
- Object *ob_arm = create_armature_bones(skin);
+ Object *ob_arm = create_armature_bones(bmain, skin);
// link armature with a mesh object
const COLLADAFW::UniqueId &uid = skin.get_controller_uid();
@@ -757,9 +758,9 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
// free memory stolen from SkinControllerData
skin.free();
}
-
+
//for bones without skins
- create_armature_bones(ob_arms);
+ create_armature_bones(bmain, ob_arms);
// Fix bone relations
std::vector<Object *>::iterator ob_arm_it;
@@ -773,7 +774,7 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
fix_parent_connect(armature, (Bone *)armature->bonebase.first);
- ED_armature_from_edit(armature);
+ ED_armature_from_edit(bmain, armature);
ED_armature_edit_free(armature);
}
}
@@ -807,9 +808,9 @@ bool ArmatureImporter::write_skin_controller_data(const COLLADAFW::SkinControlle
// don't forget to call defgroup_unique_name before we copy
- // controller data uid -> [armature] -> joint data,
+ // controller data uid -> [armature] -> joint data,
// [mesh object]
- //
+ //
SkinInfo skin(unit_converter);
skin.borrow_skin_controller_data(data);
@@ -867,7 +868,7 @@ void ArmatureImporter::make_shape_keys()
//Prereq: all the geometries must be imported and mesh objects must be made
Object *source_ob = this->mesh_importer->get_object_by_geom_uid((*mc)->getSource());
-
+
if (source_ob) {
Mesh *source_me = (Mesh *)source_ob->data;
@@ -875,7 +876,7 @@ void ArmatureImporter::make_shape_keys()
Key *key = source_me->key = BKE_key_add((ID *)source_me);
key->type = KEY_RELATIVE;
KeyBlock *kb;
-
+
//insert basis key
kb = BKE_keyblock_add_ctime(key, "Basis", false);
BKE_keyblock_convert_from_mesh(source_me, kb);
@@ -886,14 +887,14 @@ void ArmatureImporter::make_shape_keys()
//This'll do for now since only mesh morphing is imported
Mesh *me = this->mesh_importer->get_mesh_by_geom_uid(morphTargetIds[i]);
-
+
if (me) {
me->key = key;
std::string morph_name = *this->mesh_importer->get_geometry_name(me->id.name);
kb = BKE_keyblock_add_ctime(key, morph_name.c_str(), false);
BKE_keyblock_convert_from_mesh(me, kb);
-
+
//apply weights
weight = morphWeights.getFloatValues()->getData()[i];
kb->curval = weight;
@@ -989,14 +990,14 @@ BoneExtended &ArmatureImporter::add_bone_extended(EditBone *bone, COLLADAFW::Nod
has_connect = et->setData("connect", &connect_type);
bool has_roll = et->setData("roll", &roll);
-
+
layers = et->setData("layer", layers);
if (has_tail && !has_connect)
{
/* got a bone tail definition but no connect info -> bone is not connected */
has_connect = true;
- connect_type = 0;
+ connect_type = 0;
}
be->set_bone_layers(layers, layer_labels);
diff --git a/source/blender/collada/ArmatureImporter.h b/source/blender/collada/ArmatureImporter.h
index f260bb2307c..b13e40bf855 100644
--- a/source/blender/collada/ArmatureImporter.h
+++ b/source/blender/collada/ArmatureImporter.h
@@ -130,8 +130,8 @@ private:
ArmatureJoints& get_armature_joints(Object *ob_arm);
#endif
- Object *create_armature_bones(SkinInfo& skin);
- void create_armature_bones(std::vector<Object *> &arm_objs);
+ Object *create_armature_bones(Main *bmain, SkinInfo& skin);
+ void create_armature_bones(Main *bmain, std::vector<Object *> &arm_objs);
/** TagsMap typedef for uid_tags_map. */
typedef std::map<std::string, ExtraTags*> TagsMap;
@@ -158,16 +158,16 @@ public:
bool write_controller(const COLLADAFW::Controller* controller);
COLLADAFW::UniqueId *get_geometry_uid(const COLLADAFW::UniqueId& controller_uid);
-
+
Object *get_armature_for_joint(COLLADAFW::Node *node);
void get_rna_path_for_joint(COLLADAFW::Node *node, char *joint_path, size_t count);
-
+
// gives a world-space mat
bool get_joint_bind_mat(float m[4][4], COLLADAFW::Node *joint);
void set_tags_map( TagsMap& tags_map);
-
+
};
#endif
diff --git a/source/blender/collada/CameraExporter.cpp b/source/blender/collada/CameraExporter.cpp
index 649288c2db4..32bd24f1e0b 100644
--- a/source/blender/collada/CameraExporter.cpp
+++ b/source/blender/collada/CameraExporter.cpp
@@ -56,9 +56,9 @@ void forEachCameraObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set
void CamerasExporter::exportCameras(Scene *sce)
{
openLibrary();
-
+
forEachCameraObjectInExportSet(sce, *this, this->export_settings->export_set);
-
+
closeLibrary();
}
void CamerasExporter::operator()(Object *ob, Scene *sce)
diff --git a/source/blender/collada/ControllerExporter.cpp b/source/blender/collada/ControllerExporter.cpp
index f6dbc965b42..122094e33a6 100644
--- a/source/blender/collada/ControllerExporter.cpp
+++ b/source/blender/collada/ControllerExporter.cpp
@@ -99,7 +99,7 @@ bool ControllerExporter::add_instance_controller(Object *ob)
}
InstanceWriter::add_material_bindings(ins.getBindMaterial(), ob, this->export_settings->active_uv_only);
-
+
ins.add();
return true;
}
@@ -148,7 +148,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O
Base *base = (Base *) sce->base.first;
while (base) {
Object *ob = base->object;
-
+
if (ob->type == OB_MESH && get_assigned_armature(ob) == ob_arm) {
objects.push_back(ob);
}
@@ -203,7 +203,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
this->export_settings->export_mesh_type,
this->export_settings->apply_modifiers,
this->export_settings->triangulate);
-
+
if (!me->dvert) return;
std::string controller_name = id_name(ob_arm);
@@ -246,7 +246,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
for (j = 0; j < vert->totweight; j++) {
int idx = vert->dw[j].def_nr;
if (idx >= joint_index_by_def_index.size()) {
- // XXX: Maybe better find out where and
+ // XXX: Maybe better find out where and
// why the Out Of Bound indexes get created ?
oob_counter += 1;
}
@@ -314,7 +314,7 @@ void ControllerExporter::export_morph_controller(Object *ob, Key *key)
std::string targets_id = add_morph_targets(key, ob);
std::string morph_weights_id = add_morph_weights(key, ob);
-
+
COLLADASW::TargetsElement targets(mSW);
COLLADASW::InputList &input = targets.getInputList();
@@ -376,7 +376,7 @@ std::string ControllerExporter::add_morph_weights(Key *key, Object *ob)
COLLADASW::SourceBase::ParameterNameList &param = source.getParameterNameList();
param.push_back("MORPH_WEIGHT");
-
+
source.prepareToAppendValues();
KeyBlock *kb = (KeyBlock *)key->block.first;
@@ -396,7 +396,7 @@ void ControllerExporter::add_weight_extras(Key *key)
{
// can also try the base element and param alternative
COLLADASW::BaseExtraTechnique extra;
-
+
KeyBlock * kb = (KeyBlock *)key->block.first;
//skip the basis
kb = kb->next;
@@ -447,7 +447,7 @@ std::string ControllerExporter::add_joints_source(Object *ob_arm, ListBase *defb
source.setArrayId(source_id + ARRAY_ID_SUFFIX);
source.setAccessorCount(totjoint);
source.setAccessorStride(1);
-
+
COLLADASW::SourceBase::ParameterNameList &param = source.getParameterNameList();
param.push_back("JOINT");
@@ -480,7 +480,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, ListBas
source.setArrayId(source_id + ARRAY_ID_SUFFIX);
source.setAccessorCount(totjoint); //BLI_listbase_count(defbase));
source.setAccessorStride(16);
-
+
source.setParameterTypeName(&COLLADASW::CSWC::CSW_VALUE_TYPE_FLOAT4x4);
COLLADASW::SourceBase::ParameterNameList &param = source.getParameterNameList();
param.push_back("TRANSFORM");
@@ -509,7 +509,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, ListBas
float bind_mat[4][4]; /* derived from bone->arm_mat */
bool has_bindmat = bc_get_property_matrix(pchan->bone, "bind_mat", bind_mat);
-
+
if (!has_bindmat) {
/* Have no bind matrix stored, try old style <= Blender 2.78 */
@@ -571,7 +571,7 @@ std::string ControllerExporter::add_weights_source(Mesh *me, const std::string&
source.setArrayId(source_id + ARRAY_ID_SUFFIX);
source.setAccessorCount(weights.size());
source.setAccessorStride(1);
-
+
COLLADASW::SourceBase::ParameterNameList &param = source.getParameterNameList();
param.push_back("WEIGHT");
diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp
index a66c4db7b4d..9e78c164dad 100644
--- a/source/blender/collada/DocumentExporter.cpp
+++ b/source/blender/collada/DocumentExporter.cpp
@@ -62,7 +62,7 @@
#include "COLLADASWInstanceNode.h"
#include "COLLADASWBaseInputElement.h"
-extern "C"
+extern "C"
{
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
@@ -180,8 +180,7 @@ static COLLADABU::NativeString make_temp_filepath(const char *name, const char *
// COLLADA allows this through multiple <channel>s in <animation>.
// For this to work, we need to know objects that use a certain action.
-
-int DocumentExporter::exportCurrentScene(Scene *sce)
+int DocumentExporter::exportCurrentScene(bContext *C, Scene *sce)
{
PointerRNA sceneptr, unit_settings;
PropertyRNA *system; /* unused , *scale; */
@@ -258,14 +257,14 @@ int DocumentExporter::exportCurrentScene(Scene *sce)
#endif
asset.getContributor().mAuthoringTool = version_buf;
asset.add();
-
+
LinkNode *export_set = this->export_settings->export_set;
// <library_cameras>
if (bc_has_object_type(export_set, OB_CAMERA)) {
CamerasExporter ce(writer, this->export_settings);
ce.exportCameras(sce);
}
-
+
// <library_lights>
if (bc_has_object_type(export_set, OB_LAMP)) {
LightsExporter le(writer, this->export_settings);
@@ -275,11 +274,11 @@ int DocumentExporter::exportCurrentScene(Scene *sce)
// <library_images>
ImagesExporter ie(writer, this->export_settings);
ie.exportImages(sce);
-
+
// <library_effects>
EffectsExporter ee(writer, this->export_settings);
ee.exportEffects(sce);
-
+
// <library_materials>
MaterialsExporter me(writer, this->export_settings);
me.exportMaterials(sce);
@@ -293,7 +292,7 @@ int DocumentExporter::exportCurrentScene(Scene *sce)
// <library_controllers>
ArmatureExporter arm_exporter(writer, this->export_settings);
ControllerExporter controller_exporter(writer, this->export_settings);
- if (bc_has_object_type(export_set, OB_ARMATURE) || this->export_settings->include_shapekeys)
+ if (bc_has_object_type(export_set, OB_ARMATURE) || this->export_settings->include_shapekeys)
{
controller_exporter.export_controllers(depsgraph, sce);
}
@@ -307,14 +306,14 @@ int DocumentExporter::exportCurrentScene(Scene *sce)
AnimationExporter ae(depsgraph, writer, this->export_settings);
ae.exportAnimations(sce);
}
- se.exportScene(depsgraph, sce);
-
+ se.exportScene(C, depsgraph, sce);
+
// <scene>
std::string scene_name(translate_id(id_name(sce)));
COLLADASW::Scene scene(writer, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING,
scene_name));
scene.add();
-
+
// close <Collada>
writer->endDocument();
delete writer;
diff --git a/source/blender/collada/DocumentExporter.h b/source/blender/collada/DocumentExporter.h
index c98f82e68b4..8a48ca29090 100644
--- a/source/blender/collada/DocumentExporter.h
+++ b/source/blender/collada/DocumentExporter.h
@@ -40,7 +40,7 @@ class DocumentExporter
{
public:
DocumentExporter(Depsgraph *depsgraph, const ExportSettings *export_settings);
- int exportCurrentScene(Scene *sce);
+ int exportCurrentScene(bContext *C, Scene *sce);
void exportScenes(const char *filename);
private:
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 89015f45e5a..aab5a4ecfa9 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -130,7 +130,7 @@ bool DocumentImporter::import()
COLLADASaxFWL::Loader loader(&errorHandler);
COLLADAFW::Root root(&loader, this);
ExtraHandler *ehandler = new ExtraHandler(this, &(this->anim_importer));
-
+
loader.registerExtraDataCallbackHandler(ehandler);
// deselect all to select new objects
@@ -143,19 +143,19 @@ bool DocumentImporter::import()
delete ehandler;
return false;
}
-
+
if (errorHandler.hasError()) {
delete ehandler;
return false;
}
-
+
/** TODO set up scene graph and such here */
-
+
mImportStage = Controller;
-
+
COLLADASaxFWL::Loader loader2;
COLLADAFW::Root root2(&loader2, this);
-
+
if (!root2.loadDocument(encodedFilename)) {
fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 2nd pass\n");
delete ehandler;
@@ -198,7 +198,7 @@ void DocumentImporter::finish()
for (sit = vscenes.begin(); sit != vscenes.end(); sit++) {
PointerRNA sceneptr, unit_settings;
PropertyRNA *system, *scale;
-
+
// for scene unit settings: system, scale_length
RNA_id_pointer_create(&sce->id, &sceneptr);
@@ -207,7 +207,7 @@ void DocumentImporter::finish()
scale = RNA_struct_find_property(&unit_settings, "scale_length");
if (this->import_settings->import_units) {
-
+
switch (unit_converter.isMetricSystem()) {
case UnitConverter::Metric:
RNA_property_enum_set(&unit_settings, system, USER_UNIT_METRIC);
@@ -272,7 +272,7 @@ void DocumentImporter::finish()
DEG_relations_tag_update(bmain);
}
-
+
bc_match_scale(objects_to_scale, unit_converter, !this->import_settings->import_units);
delete objects_to_scale;
@@ -281,7 +281,7 @@ void DocumentImporter::finish()
void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW::Node *par = NULL, Object *parob = NULL)
{
-
+ Main *bmain = CTX_data_main(mContext);
// The split in #29246, rootmap must point at actual root when
// calculating bones in apply_curves_as_matrix. - actual root is the root node.
// This has to do with inverse bind poses being world space
@@ -316,7 +316,7 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW
translate_anim_recursive(node, node, parob);
}
else {
- anim_importer.translate_Animations(node, root_map, object_map, FW_object_map, uid_material_map);
+ anim_importer.translate_Animations(bmain, node, root_map, object_map, FW_object_map, uid_material_map);
COLLADAFW::NodePointerArray &children = node->getChildNodes();
for (i = 0; i < children.getCount(); i++) {
translate_anim_recursive(children[i], node, NULL);
@@ -473,7 +473,7 @@ void DocumentImporter::create_constraints(ExtraTags *et, Object *ob)
short type = 0;
et->setData("type", &type);
BKE_constraint_add_for_object(ob, "Test_con", type);
-
+
}
}
@@ -634,7 +634,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
root_objects->push_back(ob);
}
}
-
+
// XXX: if there're multiple instances, only one is stored
if (!ob) {
@@ -700,7 +700,7 @@ bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScen
{
if (mImportStage != General)
return true;
-
+
// this method called on post process after writeGeometry, writeMaterial, etc.
// for each <node> in <visual_scene>:
@@ -712,18 +712,18 @@ bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScen
// we link Objects with Meshes here
vscenes.push_back(visualScene);
-
+
return true;
}
-/** When this method is called, the writer must handle all nodes contained in the
+/** When this method is called, the writer must handle all nodes contained in the
* library nodes.
* \return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeLibraryNodes(const COLLADAFW::LibraryNodes *libraryNodes)
{
if (mImportStage != General)
return true;
-
+
Scene *sce = CTX_data_scene(mContext);
const COLLADAFW::NodePointerArray& nodes = libraryNodes->getNodes();
@@ -743,7 +743,7 @@ bool DocumentImporter::writeGeometry(const COLLADAFW::Geometry *geom)
{
if (mImportStage != General)
return true;
-
+
return mesh_importer.write_geometry(geom);
}
@@ -753,13 +753,13 @@ bool DocumentImporter::writeMaterial(const COLLADAFW::Material *cmat)
{
if (mImportStage != General)
return true;
-
+
const std::string& str_mat_id = cmat->getName().size() ? cmat->getName() : cmat->getOriginalId();
Material *ma = BKE_material_add(G.main, (char *)str_mat_id.c_str());
-
+
this->uid_effect_map[cmat->getInstantiatedEffect()] = ma;
this->uid_material_map[cmat->getUniqueId()] = ma;
-
+
return true;
}
@@ -768,7 +768,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
COLLADAFW::EffectCommon::ShaderType shader = ef->getShaderType();
// TODO: add back texture and extended material parameter support
-
+
// blinn
if (shader == COLLADAFW::EffectCommon::SHADER_BLINN) {
#if 0
@@ -797,14 +797,14 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
#endif
}
// reflectivity
- ma->ray_mirror = ef->getReflectivity().getFloatValue();
+ ma->metallic = ef->getReflectivity().getFloatValue();
// index of refraction
#if 0
ma->ang = ef->getIndexOfRefraction().getFloatValue();
#endif
-
+
COLLADAFW::Color col;
-
+
// DIFFUSE
// color
if (ef->getDiffuse().isColor()) {
@@ -816,7 +816,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
// texture
else if (ef->getDiffuse().isTexture()) {
#if 0
- COLLADAFW::Texture ctex = ef->getDiffuse().getTexture();
+ COLLADAFW::Texture ctex = ef->getDiffuse().getTexture();
#endif
}
// AMBIENT
@@ -829,7 +829,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
// texture
else if (ef->getAmbient().isTexture()) {
#if 0
- COLLADAFW::Texture ctex = ef->getAmbient().getTexture();
+ COLLADAFW::Texture ctex = ef->getAmbient().getTexture();
#endif
}
// SPECULAR
@@ -843,7 +843,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
// texture
else if (ef->getSpecular().isTexture()) {
#if 0
- COLLADAFW::Texture ctex = ef->getSpecular().getTexture();
+ COLLADAFW::Texture ctex = ef->getSpecular().getTexture();
#endif
}
// REFLECTIVE
@@ -856,7 +856,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
// texture
else if (ef->getReflective().isTexture()) {
#if 0
- COLLADAFW::Texture ctex = ef->getReflective().getTexture();
+ COLLADAFW::Texture ctex = ef->getReflective().getTexture();
#endif
}
@@ -869,7 +869,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
// texture
else if (ef->getEmission().isTexture()) {
#if 0
- COLLADAFW::Texture ctex = ef->getEmission().getTexture();
+ COLLADAFW::Texture ctex = ef->getEmission().getTexture();
#endif
}
@@ -902,14 +902,14 @@ bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect)
{
if (mImportStage != General)
return true;
-
+
const COLLADAFW::UniqueId& uid = effect->getUniqueId();
-
+
if (uid_effect_map.find(uid) == uid_effect_map.end()) {
fprintf(stderr, "Couldn't find a material by UID.\n");
return true;
}
-
+
Material *ma = uid_effect_map[uid];
std::map<COLLADAFW::UniqueId, Material *>::iterator iter;
for (iter = uid_material_map.begin(); iter != uid_material_map.end(); iter++) {
@@ -928,7 +928,7 @@ bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect)
COLLADAFW::EffectCommon *ef = common_efs[0];
write_profile_COMMON(ef, ma);
this->FW_object_map[effect->getUniqueId()] = effect;
-
+
return true;
}
@@ -939,16 +939,16 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
{
if (mImportStage != General)
return true;
-
+
Camera *cam = NULL;
std::string cam_id, cam_name;
-
+
ExtraTags *et=getExtraTags(camera->getUniqueId());
cam_id = camera->getOriginalId();
cam_name = camera->getName();
if (cam_name.size()) cam = (Camera *)BKE_camera_add(G.main, (char *)cam_name.c_str());
else cam = (Camera *)BKE_camera_add(G.main, (char *)cam_id.c_str());
-
+
if (!cam) {
fprintf(stderr, "Cannot create camera.\n");
return true;
@@ -961,7 +961,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
}
cam->clipsta = camera->getNearClippingPlane().getValue();
cam->clipend = camera->getFarClippingPlane().getValue();
-
+
COLLADAFW::Camera::CameraType type = camera->getCameraType();
switch (type) {
case COLLADAFW::Camera::ORTHOGRAPHIC:
@@ -981,7 +981,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
}
break;
}
-
+
switch (camera->getDescriptionType()) {
case COLLADAFW::Camera::ASPECTRATIO_AND_Y:
{
@@ -1051,7 +1051,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
// read nothing, use blender defaults.
break;
}
-
+
this->uid_camera_map[camera->getUniqueId()] = cam;
this->FW_object_map[camera->getUniqueId()] = camera;
// XXX import camera options
@@ -1064,7 +1064,7 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image)
{
if (mImportStage != General)
return true;
-
+
const std::string& imagepath = image->getImageURI().toNativePath();
char dir[FILE_MAX];
@@ -1075,7 +1075,7 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image)
BLI_join_dirfile(absolute_path, sizeof(absolute_path), dir, imagepath.c_str());
if (BLI_exists(absolute_path)) {
workpath = absolute_path;
- }
+ }
else {
// Maybe imagepath was already absolute ?
if (!BLI_exists(imagepath.c_str())) {
@@ -1085,13 +1085,13 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image)
workpath = imagepath.c_str();
}
- Image *ima = BKE_image_load_exists(workpath);
+ Image *ima = BKE_image_load_exists(CTX_data_main(mContext), workpath);
if (!ima) {
fprintf(stderr, "Cannot create image: %s\n", workpath);
return true;
}
this->uid_image_map[image->getUniqueId()] = ima;
-
+
return true;
}
@@ -1185,7 +1185,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
// assuming point light (const att = 1.0);
att1 = 1.0f;
}
-
+
d *= (1.0f / unit_converter.getLinearMeter());
lamp->energy = e;
@@ -1247,7 +1247,7 @@ bool DocumentImporter::writeAnimation(const COLLADAFW::Animation *anim)
{
if (mImportStage != General)
return true;
-
+
// return true;
return anim_importer.write_animation(anim);
}
@@ -1257,7 +1257,7 @@ bool DocumentImporter::writeAnimationList(const COLLADAFW::AnimationList *animat
{
if (mImportStage != General)
return true;
-
+
// return true;
return anim_importer.write_animation_list(animationList);
}
@@ -1274,7 +1274,7 @@ bool DocumentImporter::writeController(const COLLADAFW::Controller *controller)
{
if (mImportStage != General)
return true;
-
+
return armature_importer.write_controller(controller);
}
diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h
index 758caef7e60..b31a086d710 100644
--- a/source/blender/collada/DocumentImporter.h
+++ b/source/blender/collada/DocumentImporter.h
@@ -78,7 +78,7 @@ public:
void create_constraints(ExtraTags *et, Object *ob);
std::vector<Object *> *write_node(COLLADAFW::Node*, COLLADAFW::Node*, Scene*, Object*, bool);
void write_profile_COMMON(COLLADAFW::EffectCommon*, Material*);
-
+
void translate_anim_recursive(COLLADAFW::Node*, COLLADAFW::Node*, Object*);
/**
@@ -149,7 +149,7 @@ private:
ArmatureImporter armature_importer;
MeshImporter mesh_importer;
AnimationImporter anim_importer;
-
+
/** TagsMap typedef for uid_tags_map. */
typedef std::map<std::string, ExtraTags*> TagsMap;
/** Tags map of unique id as a string and ExtraTags instance. */
@@ -165,7 +165,7 @@ private:
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> node_map;
std::vector<const COLLADAFW::VisualScene*> vscenes;
std::vector<Object*> libnode_ob;
-
+
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> root_map; // find root joint by child joint uid, for bone tree evaluation during resampling
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map;
diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp
index dbcdfd01a9c..271dab5deea 100644
--- a/source/blender/collada/EffectExporter.cpp
+++ b/source/blender/collada/EffectExporter.cpp
@@ -57,7 +57,7 @@ static std::string getActiveUVLayerName(Object *ob)
int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
if (num_layers)
return std::string(bc_CustomData_get_active_layer_name(&me->fdata, CD_MTFACE));
-
+
return "";
}
@@ -105,12 +105,12 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
// TODO: add back texture and extended material parameter support
openEffect(translate_id(id_name(ma)) + "-effect");
-
+
COLLADASW::EffectProfile ep(mSW);
ep.setProfileType(COLLADASW::EffectProfile::COMMON);
ep.openProfile();
writeLambert(ep, ma);
-
+
COLLADASW::ColorOrTexture cot;
// transparency
@@ -144,7 +144,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
//COLLADASW::Surface surfaces[MAX_MTEX];
//void *samp_surf[MAX_MTEX][2];
void *samp_surf[MAX_MTEX];
-
+
// image to index to samp_surf map
// samp_surf[index] stores 2 pointers, sampler and surface
std::map<std::string, int> im_samp_map;
@@ -153,10 +153,10 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
for (a = 0, b = 0; a < tex_indices.size(); a++) {
MTex *t = ma->mtex[tex_indices[a]];
Image *ima = t->tex->ima;
-
+
// Image not set for texture
if (!ima) continue;
-
+
std::string key(id_name(ima));
key = translate_id(key);
@@ -171,7 +171,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
// COLLADASW::NewParamSurface surface(mSW);
// surface->setParamType(COLLADASW::CSW_SURFACE_TYPE_2D);
-
+
//<newparam> <sampler> <source>
COLLADASW::Sampler sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D,
key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX,
@@ -180,11 +180,11 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
// copy values to arrays since they will live longer
samplers[a] = sampler;
//surfaces[a] = surface;
-
+
// store pointers so they can be used later when we create <texture>s
samp_surf[b] = &samplers[a];
//samp_surf[b][1] = &surfaces[a];
-
+
im_samp_map[key] = b;
b++;
}
@@ -238,12 +238,12 @@ COLLADASW::ColorOrTexture EffectsExporter::createTexture(Image *ima,
COLLADASW::Sampler *sampler
/*COLLADASW::Surface *surface*/)
{
-
+
COLLADASW::Texture texture(translate_id(id_name(ima)));
texture.setTexcoord(uv_layer_name);
//texture.setSurface(*surface);
texture.setSampler(*sampler);
-
+
COLLADASW::ColorOrTexture cot(texture);
return cot;
}
diff --git a/source/blender/collada/EffectExporter.h b/source/blender/collada/EffectExporter.h
index eac428ae330..a1395bfde9f 100644
--- a/source/blender/collada/EffectExporter.h
+++ b/source/blender/collada/EffectExporter.h
@@ -50,25 +50,25 @@ public:
void exportEffects(Scene *sce);
void operator()(Material *ma, Object *ob);
-
+
COLLADASW::ColorOrTexture createTexture(Image *ima,
std::string& uv_layer_name,
COLLADASW::Sampler *sampler
/*COLLADASW::Surface *surface*/);
-
+
COLLADASW::ColorOrTexture getcol(float r, float g, float b, float a);
private:
void writeLambert(COLLADASW::EffectProfile &ep, Material *ma);
void writeTextures(COLLADASW::EffectProfile &ep,
std::string &key,
- COLLADASW::Sampler *sampler,
+ COLLADASW::Sampler *sampler,
MTex *t, Image *ima,
std::string &uvname );
bool hasEffects(Scene *sce);
-
+
const ExportSettings *export_settings;
-
+
Scene *scene;
};
diff --git a/source/blender/collada/ErrorHandler.cpp b/source/blender/collada/ErrorHandler.cpp
index 7e18328f000..26674445d98 100644
--- a/source/blender/collada/ErrorHandler.cpp
+++ b/source/blender/collada/ErrorHandler.cpp
@@ -53,7 +53,7 @@ bool ErrorHandler::handleError(const COLLADASaxFWL::IError *error)
See https://github.com/KhronosGroup/OpenCOLLADA/issues/442
*/
bool isWarning = false;
-
+
if (error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXPARSER) {
COLLADASaxFWL::SaxParserError *saxParserError = (COLLADASaxFWL::SaxParserError *) error;
const GeneratedSaxParser::ParserError& parserError = saxParserError->getError();
diff --git a/source/blender/collada/ExtraHandler.cpp b/source/blender/collada/ExtraHandler.cpp
index bef7accd9f7..5d704bc9abc 100644
--- a/source/blender/collada/ExtraHandler.cpp
+++ b/source/blender/collada/ExtraHandler.cpp
@@ -54,9 +54,9 @@ bool ExtraHandler::elementEnd(const char *elementName)
bool ExtraHandler::textData(const char *text, size_t textLength)
{
char buf[1024];
-
+
if (currentElement.length() == 0 || currentExtraTags == 0) return false;
-
+
BLI_strncpy(buf, text, textLength + 1);
currentExtraTags->addTag(currentElement, std::string(buf));
return true;
diff --git a/source/blender/collada/ExtraHandler.h b/source/blender/collada/ExtraHandler.h
index f380c3d6871..4dda862b3cc 100644
--- a/source/blender/collada/ExtraHandler.h
+++ b/source/blender/collada/ExtraHandler.h
@@ -50,31 +50,31 @@ public:
/** Handle the beginning of an element. */
bool elementBegin( const char* elementName, const char** attributes);
-
+
/** Handle the end of an element. */
bool elementEnd(const char* elementName );
-
+
/** Receive the data in text format. */
bool textData(const char* text, size_t textLength);
/** Method to ask, if the current callback handler want to read the data of the given extra element. */
- bool parseElement (
- const char* profileName,
- const unsigned long& elementHash,
+ bool parseElement (
+ const char* profileName,
+ const unsigned long& elementHash,
const COLLADAFW::UniqueId& uniqueId,
COLLADAFW::Object* object);
/** For backwards compatibility with older OpenCollada, new version added object parameter */
- bool parseElement (
- const char* profileName,
- const unsigned long& elementHash,
+ bool parseElement (
+ const char* profileName,
+ const unsigned long& elementHash,
const COLLADAFW::UniqueId& uniqueId);
private:
/** Disable default copy constructor. */
ExtraHandler(const ExtraHandler& pre);
/** Disable default assignment operator. */
const ExtraHandler& operator= ( const ExtraHandler& pre );
-
+
/** Handle to DocumentImporter for interface to extra element data saving. */
DocumentImporter* dimp;
AnimationImporter* aimp;
diff --git a/source/blender/collada/ExtraTags.cpp b/source/blender/collada/ExtraTags.cpp
index ea225d8a4ae..fd249884c3f 100644
--- a/source/blender/collada/ExtraTags.cpp
+++ b/source/blender/collada/ExtraTags.cpp
@@ -50,7 +50,7 @@ bool ExtraTags::isProfile(std::string profile)
bool ExtraTags::addTag(std::string tag, std::string data)
{
tags[tag] = data;
-
+
return true;
}
diff --git a/source/blender/collada/ExtraTags.h b/source/blender/collada/ExtraTags.h
index ad272dcba65..84857622ee8 100644
--- a/source/blender/collada/ExtraTags.h
+++ b/source/blender/collada/ExtraTags.h
@@ -41,35 +41,35 @@ public:
/** Handle the beginning of an element. */
bool addTag(std::string tag, std::string data);
-
+
/** Set given short pointer to value of tag, if it exists. */
bool setData(std::string tag, short *data);
-
+
/** Set given int pointer to value of tag, if it exists. */
bool setData(std::string tag, int *data);
-
+
/** Set given float pointer to value of tag, if it exists. */
bool setData(std::string tag, float *data);
-
+
/** Set given char pointer to value of tag, if it exists. */
bool setData(std::string tag, char *data);
std::string setData(std::string tag, std::string &data);
/** Return true if the extra tags is for specified profile. */
bool isProfile(std::string profile);
-
+
private:
/** Disable default copy constructor. */
ExtraTags(const ExtraTags& pre);
/** Disable default assignment operator. */
const ExtraTags& operator= ( const ExtraTags& pre );
-
+
/** The profile for which the tags are. */
std::string profile;
-
+
/** Map of tag and text pairs. */
std::map<std::string, std::string> tags;
-
+
/** Get text data for tag as an int. */
int asInt(std::string tag, bool *ok);
/** Get text data for tag as a float. */
diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp
index 87b47353596..65e844cbe50 100644
--- a/source/blender/collada/GeometryExporter.cpp
+++ b/source/blender/collada/GeometryExporter.cpp
@@ -70,14 +70,14 @@ void GeometryExporter::exportGeom(struct Depsgraph *depsgraph, Scene *sce)
}
void GeometryExporter::operator()(Object *ob)
-{
+{
// XXX don't use DerivedMesh, Mesh instead?
-#if 0
+#if 0
DerivedMesh *dm = mesh_get_derived_final(mScene, ob, CD_MASK_BAREMESH);
#endif
bool use_instantiation = this->export_settings->use_object_instantiation;
- Mesh *me = bc_get_mesh_copy(mDepsgraph, mScene,
+ Mesh *me = bc_get_mesh_copy(mDepsgraph, mScene,
ob,
this->export_settings->export_mesh_type,
this->export_settings->apply_modifiers,
@@ -88,7 +88,7 @@ void GeometryExporter::operator()(Object *ob)
std::vector<BCPolygonNormalsIndices> norind;
// Skip if linked geometry was already exported from another reference
- if (use_instantiation &&
+ if (use_instantiation &&
exportedGeometry.find(geom_id) != exportedGeometry.end())
{
return;
@@ -104,15 +104,15 @@ void GeometryExporter::operator()(Object *ob)
// openMesh(geoId, geoName, meshId)
openMesh(geom_id, geom_name);
-
+
// writes <source> for vertex coords
createVertsSource(geom_id, me);
-
+
// writes <source> for normal coords
createNormalsSource(geom_id, me, nor);
bool has_uvs = (bool)CustomData_has_layer(&me->fdata, CD_MTFACE);
-
+
// writes <source> for uv coords if mesh has uv coords
if (has_uvs) {
createTexcoordsSource(geom_id, me);
@@ -144,9 +144,9 @@ void GeometryExporter::operator()(Object *ob)
createPolylist(0, has_uvs, has_color, ob, me, geom_id, norind);
}
}
-
+
closeMesh();
-
+
if (me->flag & ME_TWOSIDED) {
mSW->appendTextBlock("<extra><technique profile=\"MAYA\"><double_sided>1</double_sided></technique></extra>");
}
@@ -175,7 +175,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
std::string geom_id = get_geometry_id(ob, false) + "_morph_" + translate_id(kb->name);
std::vector<Normal> nor;
std::vector<BCPolygonNormalsIndices> norind;
-
+
if (exportedGeometry.find(geom_id) != exportedGeometry.end())
{
return;
@@ -191,15 +191,15 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
// openMesh(geoId, geoName, meshId)
openMesh(geom_id, geom_name);
-
+
// writes <source> for vertex coords
createVertsSource(geom_id, me);
-
+
// writes <source> for normal coords
createNormalsSource(geom_id, me, nor);
bool has_uvs = (bool)CustomData_has_layer(&me->fdata, CD_MTFACE);
-
+
// writes <source> for uv coords if mesh has uv coords
if (has_uvs) {
createTexcoordsSource(geom_id, me);
@@ -220,7 +220,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
//createLooseEdgeList(ob, me, geom_id, norind);
- // XXX slow
+ // XXX slow
if (ob->totcol) {
for (int a = 0; a < ob->totcol; a++) {
createPolylist(a, has_uvs, has_color, ob, me, geom_id, norind);
@@ -229,9 +229,9 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
else {
createPolylist(0, has_uvs, has_color, ob, me, geom_id, norind);
}
-
+
closeMesh();
-
+
if (me->flag & ME_TWOSIDED) {
mSW->appendTextBlock("<extra><technique profile=\"MAYA\"><double_sided>1</double_sided></technique></extra>");
}
@@ -250,9 +250,9 @@ void GeometryExporter::createLooseEdgeList(Object *ob,
std::vector<unsigned int> edge_list;
int index;
- // Find all loose edges in Mesh
+ // Find all loose edges in Mesh
// and save vertex indices in edge_list
- for (index = 0; index < totedges; index++)
+ for (index = 0; index < totedges; index++)
{
MEdge *edge = &medges[index];
@@ -273,14 +273,14 @@ void GeometryExporter::createLooseEdgeList(Object *ob,
COLLADASW::InputList &til = lines.getInputList();
-
- // creates <input> in <lines> for vertices
+
+ // creates <input> in <lines> for vertices
COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX), 0);
til.push_back(input1);
lines.prepareToAppendValues();
- for (index = 0; index < edges_in_linelist; index++)
+ for (index = 0; index < edges_in_linelist; index++)
{
lines.appendValues(edge_list[2 * index + 1]);
lines.appendValues(edge_list[2 * index]);
@@ -318,7 +318,7 @@ void GeometryExporter::createPolylist(short material_index,
// count faces with this material
for (i = 0; i < totpolys; i++) {
MPoly *p = &mpolys[i];
-
+
if (p->mat_nr == material_index) {
faces_in_polylist++;
vcount_list.push_back(p->totloop);
@@ -330,13 +330,13 @@ void GeometryExporter::createPolylist(short material_index,
fprintf(stderr, "%s: material with index %d is not used.\n", id_name(ob).c_str(), material_index);
return;
}
-
+
Material *ma = ob->totcol ? give_current_material(ob, material_index + 1) : NULL;
COLLADASW::Polylist polylist(mSW);
-
+
// sets count attribute in <polylist>
polylist.setCount(faces_in_polylist);
-
+
// sets material name
if (ma) {
std::string material_id = get_material_id(ma);
@@ -344,18 +344,18 @@ void GeometryExporter::createPolylist(short material_index,
ostr << translate_id(material_id);
polylist.setMaterial(ostr.str());
}
-
+
COLLADASW::InputList &til = polylist.getInputList();
-
- // creates <input> in <polylist> for vertices
+
+ // creates <input> in <polylist> for vertices
COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX), 0);
-
+
// creates <input> in <polylist> for normals
COLLADASW::Input input2(COLLADASW::InputSemantic::NORMAL, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL), 1);
-
+
til.push_back(input1);
til.push_back(input2);
-
+
// if mesh has uv coords writes <input> for TEXCOORD
int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
int active_uv_index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE)-1;
@@ -387,13 +387,13 @@ void GeometryExporter::createPolylist(short material_index,
map_index++;
}
}
-
+
// sets <vcount>
polylist.setVCountList(vcount_list);
-
+
// performs the actual writing
polylist.prepareToAppendValues();
-
+
// <p>
int texindex = 0;
for (i = 0; i < totpolys; i++) {
@@ -417,7 +417,7 @@ void GeometryExporter::createPolylist(short material_index,
texindex += loop_count;
}
-
+
polylist.finish();
}
@@ -430,7 +430,7 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
#endif
int totverts = me->totvert;
MVert *verts = me->mvert;
-
+
COLLADASW::FloatSourceF source(mSW);
source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::POSITION));
source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::POSITION) +
@@ -450,7 +450,7 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
for (i = 0; i < totverts; i++) {
source.appendValues(verts[i].co[0], verts[i].co[1], verts[i].co[2]);
}
-
+
source.finish();
}
@@ -502,7 +502,7 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
);
}
}
-
+
source.finish();
}
}
@@ -537,20 +537,20 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
int layer_index = CustomData_get_layer_index_n(&me->ldata, CD_MLOOPUV, a);
if (!this->export_settings->active_uv_only || layer_index == active_uv_index) {
MLoopUV *mloops = (MLoopUV *)CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, a);
-
+
COLLADASW::FloatSourceF source(mSW);
std::string layer_id = makeTexcoordSourceId(geom_id, a, this->export_settings->active_uv_only);
source.setId(layer_id);
source.setArrayId(layer_id + ARRAY_ID_SUFFIX);
-
+
source.setAccessorCount(totuv);
source.setAccessorStride(2);
COLLADASW::SourceBase::ParameterNameList &param = source.getParameterNameList();
param.push_back("S");
param.push_back("T");
-
+
source.prepareToAppendValues();
-
+
for (int index = 0; index < totpoly; index++) {
MPoly *mpoly = mpolys+index;
MLoopUV *mloop = mloops+mpoly->loopstart;
@@ -559,7 +559,7 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
mloop[j].uv[1]);
}
}
-
+
source.finish();
}
}
@@ -589,7 +589,7 @@ void GeometryExporter::createNormalsSource(std::string geom_id, Mesh *me, std::v
param.push_back("X");
param.push_back("Y");
param.push_back("Z");
-
+
source.prepareToAppendValues();
std::vector<Normal>::iterator it;
@@ -674,10 +674,10 @@ std::string GeometryExporter::getIdBySemantics(std::string geom_id, COLLADASW::I
COLLADASW::URI GeometryExporter::getUrlBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix)
{
-
+
std::string id(getIdBySemantics(geom_id, type, other_suffix));
return COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, id);
-
+
}
COLLADASW::URI GeometryExporter::makeUrl(std::string id)
diff --git a/source/blender/collada/GeometryExporter.h b/source/blender/collada/GeometryExporter.h
index 88420b4ad2f..b0cd650adcd 100644
--- a/source/blender/collada/GeometryExporter.h
+++ b/source/blender/collada/GeometryExporter.h
@@ -96,7 +96,7 @@ public:
Mesh *me,
std::string& geom_id,
std::vector<BCPolygonNormalsIndices>& norind);
-
+
// creates <source> for positions
void createVertsSource(std::string geom_id, Mesh *me);
@@ -112,7 +112,7 @@ public:
void createNormalsSource(std::string geom_id, Mesh *me, std::vector<Normal>& nor);
void create_normals(std::vector<Normal> &nor, std::vector<BCPolygonNormalsIndices> &ind, Mesh *me);
-
+
std::string getIdBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix = "");
std::string makeVertexColorSourceId(std::string& geom_id, char *layer_name);
@@ -121,10 +121,10 @@ public:
COLLADASW::URI makeUrl(std::string id);
void export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb);
-
+
private:
std::set<std::string> exportedGeometry;
-
+
const ExportSettings *export_settings;
Mesh * get_mesh(Scene *sce, Object *ob, int apply_modifiers);
diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp
index 657037a869a..bb3cebf4cf0 100644
--- a/source/blender/collada/ImageExporter.cpp
+++ b/source/blender/collada/ImageExporter.cpp
@@ -34,7 +34,7 @@ extern "C" {
#include "DNA_image_types.h"
#include "DNA_meshdata_types.h"
-#include "BKE_customdata.h"
+#include "BKE_customdata.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_main.h"
@@ -53,7 +53,7 @@ ImagesExporter::ImagesExporter(COLLADASW::StreamWriter *sw, const ExportSettings
{
}
-void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
+void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
{
std::string name(id_name(image));
std::string translated_name(translate_id(name));
@@ -113,11 +113,11 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
// make absolute source path
BLI_strncpy(source_path, image->name, sizeof(source_path));
- BLI_path_abs(source_path, G.main->name);
+ BLI_path_abs(source_path, BKE_main_blendfile_path_from_global());
BLI_cleanup_path(NULL, source_path);
if (use_copies) {
-
+
// This image is already located on the file system.
// But we want to create copies here.
// To move images into the same export directory.
@@ -155,7 +155,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
bool ImagesExporter::hasImages(Scene *sce)
{
LinkNode *node;
-
+
for (node = this->export_settings->export_set; node; node = node->next) {
Object *ob = (Object *)node->link;
diff --git a/source/blender/collada/ImageExporter.h b/source/blender/collada/ImageExporter.h
index f3dd2b336e4..1867c44ac9c 100644
--- a/source/blender/collada/ImageExporter.h
+++ b/source/blender/collada/ImageExporter.h
@@ -45,7 +45,7 @@ class ImagesExporter: COLLADASW::LibraryImages
{
public:
ImagesExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
-
+
void exportImages(Scene *sce);
void operator()(Material *ma, Object *ob);
private:
diff --git a/source/blender/collada/InstanceWriter.cpp b/source/blender/collada/InstanceWriter.cpp
index d96d590597a..68842596550 100644
--- a/source/blender/collada/InstanceWriter.cpp
+++ b/source/blender/collada/InstanceWriter.cpp
@@ -45,7 +45,7 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia
{
for (int a = 0; a < ob->totcol; a++) {
Material *ma = give_current_material(ob, a + 1);
-
+
COLLADASW::InstanceMaterialList& iml = bind_material.getInstanceMaterialList();
if (ma) {
@@ -54,11 +54,11 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia
std::ostringstream ostr;
ostr << matid;
COLLADASW::InstanceMaterial im(ostr.str(), COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, matid));
-
+
// create <bind_vertex_input> for each uv map
Mesh *me = (Mesh *)ob->data;
int totlayer = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
-
+
int map_index = 0;
int active_uv_index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE) -1;
for (int b = 0; b < totlayer; b++) {
@@ -67,7 +67,7 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia
im.push_back(COLLADASW::BindVertexInput(name, "TEXCOORD", map_index++));
}
}
-
+
iml.push_back(im);
}
}
diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp
index d17941574d7..11377e06ce8 100644
--- a/source/blender/collada/LightExporter.cpp
+++ b/source/blender/collada/LightExporter.cpp
@@ -54,9 +54,9 @@ LightsExporter::LightsExporter(COLLADASW::StreamWriter *sw, const ExportSettings
void LightsExporter::exportLights(Scene *sce)
{
openLibrary();
-
+
forEachLampObjectInExportSet(sce, *this, this->export_settings->export_set);
-
+
closeLibrary();
}
@@ -67,11 +67,11 @@ void LightsExporter::operator()(Object *ob)
std::string la_name(id_name(la));
COLLADASW::Color col(la->r * la->energy, la->g * la->energy, la->b * la->energy);
float d, constatt, linatt, quadatt;
-
+
d = la->dist;
-
+
constatt = 1.0f;
-
+
if (la->falloff_type == LA_FALLOFF_INVLINEAR) {
linatt = 1.0f / d;
quadatt = 0.0f;
@@ -80,7 +80,7 @@ void LightsExporter::operator()(Object *ob)
linatt = 0.0f;
quadatt = 1.0f / (d * d);
}
-
+
// sun
if (la->type == LA_SUN) {
COLLADASW::DirectionalLight cla(mSW, la_id, la_name);
@@ -130,7 +130,7 @@ void LightsExporter::operator()(Object *ob)
exportBlenderProfile(cla, la);
addLight(cla);
}
-
+
}
bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la)
@@ -164,6 +164,6 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la)
cla.addExtraTechniqueParameter("blender", "area_size", la->area_size);
cla.addExtraTechniqueParameter("blender", "area_sizey", la->area_sizey);
cla.addExtraTechniqueParameter("blender", "area_sizez", la->area_sizez);
-
+
return true;
}
diff --git a/source/blender/collada/MaterialExporter.h b/source/blender/collada/MaterialExporter.h
index ef44bf8a03e..e830a433432 100644
--- a/source/blender/collada/MaterialExporter.h
+++ b/source/blender/collada/MaterialExporter.h
@@ -65,7 +65,7 @@ class ForEachMaterialFunctor
Functor *f;
public:
ForEachMaterialFunctor(Functor*f) : f(f) {}
-
+
void operator ()(Object *ob)
{
int a;
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index 4c6d00a79cb..e95f8ed0888 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -154,7 +154,7 @@ void UVDataWrapper::getUV(int uv_index, float *uv)
if (values->empty()) return;
uv[0] = (*values)[uv_index * stride];
uv[1] = (*values)[uv_index * stride + 1];
-
+
}
break;
case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
@@ -163,7 +163,7 @@ void UVDataWrapper::getUV(int uv_index, float *uv)
if (values->empty()) return;
uv[0] = (float)(*values)[uv_index * stride];
uv[1] = (float)(*values)[uv_index * stride + 1];
-
+
}
break;
case COLLADAFW::MeshVertexData::DATA_TYPE_UNKNOWN:
@@ -208,7 +208,7 @@ void VCOLDataWrapper::get_vcol(int v_index, MLoopCol *mloopcol)
}
MeshImporter::MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce, ViewLayer *view_layer):
- unitconverter(unitconv),
+ unitconverter(unitconv),
scene(sce),
view_layer(view_layer),
armature_importer(arm) {
@@ -320,7 +320,7 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has su
return false;
}
}
-
+
return true;
}
@@ -360,7 +360,7 @@ bool MeshImporter::primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp) {
int normals_count = mp->getNormalIndices().getCount();
if (normals_count > 0) {
int index_count = mp->getPositionIndices().getCount();
- if (index_count == normals_count)
+ if (index_count == normals_count)
has_useable_normals = true;
else {
fprintf(stderr,
@@ -391,7 +391,7 @@ bool MeshImporter::primitive_has_faces(COLLADAFW::MeshPrimitive *mp) {
break;
}
default: {
- has_faces = false;
+ has_faces = false;
break;
}
}
@@ -435,7 +435,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
size_t prim_poly_count = mpvc->getFaceCount();
size_t prim_loop_count = 0;
- for (int index=0; index < prim_poly_count; index++)
+ for (int index=0; index < prim_poly_count; index++)
{
int vcount = get_vertex_count(mpvc, index);
if (vcount > 0) {
@@ -547,7 +547,7 @@ unsigned int MeshImporter::get_loose_edge_count(COLLADAFW::Mesh *mesh) {
// This functin is copied from source/blender/editors/mesh/mesh_data.c
//
// TODO: (As discussed with sergey-) :
-// Maybe move this function to blenderkernel/intern/mesh.c
+// Maybe move this function to blenderkernel/intern/mesh.c
// and add definition to BKE_mesh.c
// =================================================================
void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
@@ -582,7 +582,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
// =================================================================
// Read all loose edges.
-// Important: This function assumes that all edges from existing
+// Important: This function assumes that all edges from existing
// faces have allready been generated and added to me->medge
// So this function MUST be called after read_faces() (see below)
// =================================================================
@@ -593,21 +593,21 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
unsigned int face_edge_count = me->totedge;
/* unsigned int total_edge_count = loose_edge_count + face_edge_count; */ /* UNUSED */
-
+
mesh_add_edges(me, loose_edge_count);
MEdge *med = me->medge + face_edge_count;
COLLADAFW::MeshPrimitiveArray& prim_arr = mesh->getMeshPrimitives();
for (int i = 0; i < prim_arr.getCount(); i++) {
-
+
COLLADAFW::MeshPrimitive *mp = prim_arr[i];
int type = mp->getPrimitiveType();
if (type == COLLADAFW::MeshPrimitive::LINES) {
unsigned int edge_count = mp->getFaceCount();
unsigned int *indices = mp->getPositionIndices().getData();
-
+
for (int j = 0; j < edge_count; j++, med++) {
med->bweight = 0;
med->crease = 0;
@@ -624,7 +624,7 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
// =======================================================================
// Read all faces from TRIANGLES, TRIANGLE_FANS, POLYLIST, POLYGON
-// Important: This function MUST be called before read_lines()
+// Important: This function MUST be called before read_lines()
// Otherwise we will loose all edges from faces (see read_lines() above)
//
// TODO: import uv set names
@@ -632,7 +632,7 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
{
unsigned int i;
-
+
allocate_poly_data(collada_mesh, me);
UVDataWrapper uvs(collada_mesh->getUVCoords());
@@ -648,7 +648,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
COLLADAFW::MeshVertexData& nor = collada_mesh->getNormals();
for (i = 0; i < prim_arr.getCount(); i++) {
-
+
COLLADAFW::MeshPrimitive *mp = prim_arr[i];
// faces
@@ -661,7 +661,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
bool mp_has_faces = primitive_has_faces(mp);
int collada_meshtype = mp->getPrimitiveType();
-
+
// since we cannot set mpoly->mat_nr here, we store a portion of me->mpoly in Primitive
Primitive prim = {mpoly, 0};
@@ -688,7 +688,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
mpoly->flag |= ME_SMOOTH;
normal_indices++;
}
-
+
mpoly++;
mloop += 3;
loop_index += 3;
@@ -798,7 +798,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i, int stride)
{
i *= stride;
-
+
switch (arr.getType()) {
case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
{
@@ -888,7 +888,7 @@ static bool bc_has_same_material_configuration(Object *ob1, Object *ob2)
{
if (ob1->totcol != ob2->totcol) return false; // not same number of materials
if (ob1->totcol == 0) return false; // no material at all
-
+
for (int index=0; index < ob1->totcol; index++) {
if (ob1->matbits[index] != ob2->matbits[index]) return false; // shouldn't happen
if (ob1->matbits[index] == 0) return false; // shouldn't happen
@@ -1019,34 +1019,34 @@ void MeshImporter::assign_material_to_geom(
short mat_index)
{
const COLLADAFW::UniqueId& ma_uid = cmaterial.getReferencedMaterial();
-
+
// do we know this material?
if (uid_material_map.find(ma_uid) == uid_material_map.end()) {
-
+
fprintf(stderr, "Cannot find material by UID.\n");
return;
}
// first time we get geom_uid, ma_uid pair. Save for later check.
materials_mapped_to_geom.insert(std::pair<COLLADAFW::UniqueId, COLLADAFW::UniqueId>(*geom_uid, ma_uid));
-
+
Material *ma = uid_material_map[ma_uid];
// Attention! This temporaly assigns material to object on purpose!
// See note above.
ob->actcol=0;
- assign_material(ob, ma, mat_index + 1, BKE_MAT_ASSIGN_OBJECT);
-
+ assign_material(G.main, ob, ma, mat_index + 1, BKE_MAT_ASSIGN_OBJECT);
+
MaterialIdPrimitiveArrayMap& mat_prim_map = geom_uid_mat_mapping_map[*geom_uid];
COLLADAFW::MaterialId mat_id = cmaterial.getMaterialId();
-
+
// assign material indices to mesh faces
if (mat_prim_map.find(mat_id) != mat_prim_map.end()) {
-
+
std::vector<Primitive>& prims = mat_prim_map[mat_id];
-
+
std::vector<Primitive>::iterator it;
-
+
for (it = prims.begin(); it != prims.end(); it++) {
Primitive& prim = *it;
MPoly *mpoly = prim.mpoly;
@@ -1055,7 +1055,7 @@ void MeshImporter::assign_material_to_geom(
mpoly->mat_nr = mat_index;
}
}
- }
+ }
}
Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom,
@@ -1063,19 +1063,19 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
std::map<COLLADAFW::UniqueId, Material *>& uid_material_map)
{
const COLLADAFW::UniqueId *geom_uid = &geom->getInstanciatedObjectId();
-
+
// check if node instanciates controller or geometry
if (isController) {
-
+
geom_uid = armature_importer->get_geometry_uid(*geom_uid);
-
+
if (!geom_uid) {
fprintf(stderr, "Couldn't find a mesh UID by controller's UID.\n");
return NULL;
}
}
else {
-
+
if (uid_mesh_map.find(*geom_uid) == uid_mesh_map.end()) {
// this could happen if a mesh was not created
// (e.g. if it contains unsupported geometry)
@@ -1084,11 +1084,11 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
}
}
if (!uid_mesh_map[*geom_uid]) return NULL;
-
+
// name Object
const std::string& id = node->getName().size() ? node->getName() : node->getOriginalId();
const char *name = (id.length()) ? id.c_str() : NULL;
-
+
// add object
Object *ob = bc_add_object(scene, view_layer, OB_MESH, name);
bc_set_mark(ob); // used later for material assignement optimization
@@ -1097,12 +1097,12 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
// store object pointer for ArmatureImporter
uid_object_map[*geom_uid] = ob;
imported_objects.push_back(ob);
-
+
// replace ob->data freeing the old one
Mesh *old_mesh = (Mesh *)ob->data;
Mesh *new_mesh = uid_mesh_map[*geom_uid];
- BKE_mesh_assign_object(ob, new_mesh);
+ BKE_mesh_assign_object(G.main, ob, new_mesh);
BKE_mesh_calc_normals(new_mesh);
id_us_plus(&old_mesh->id); /* Because BKE_mesh_assign_object would have already decreased it... */
@@ -1110,10 +1110,10 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
COLLADAFW::MaterialBindingArray& mat_array =
geom->getMaterialBindings();
-
+
// loop through geom's materials
for (unsigned int i = 0; i < mat_array.getCount(); i++) {
-
+
if (mat_array[i].getReferencedMaterial().isValid()) {
assign_material_to_geom(
mat_array[i], uid_material_map, ob, geom_uid,
@@ -1136,14 +1136,14 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom)
fprintf(stderr, "Mesh type %s is not supported\n", bc_geomTypeToStr(geom->getType()));
return true;
}
-
+
COLLADAFW::Mesh *mesh = (COLLADAFW::Mesh *)geom;
-
+
if (!is_nice_mesh(mesh)) {
fprintf(stderr, "Ignoring mesh %s\n", bc_get_dae_name(mesh).c_str());
return true;
}
-
+
const std::string& str_geom_id = mesh->getName().size() ? mesh->getName() : mesh->getOriginalId();
Mesh *me = BKE_mesh_add(G.main, (char *)str_geom_id.c_str());
id_us_min(&me->id); // is already 1 here, but will be set later in BKE_mesh_assign_object
@@ -1152,7 +1152,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom)
// mesh_geom_map needed to map mesh to its geometry name (for shape key naming)
this->uid_mesh_map[mesh->getUniqueId()] = me;
this->mesh_geom_map[std::string(me->id.name)] = str_geom_id;
-
+
read_vertices(mesh, me);
read_polys(mesh, me);
diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h
index 09b3005d795..c98126916d7 100644
--- a/source/blender/collada/MeshImporter.h
+++ b/source/blender/collada/MeshImporter.h
@@ -109,7 +109,7 @@ private:
typedef std::map<COLLADAFW::MaterialId, std::vector<Primitive> > MaterialIdPrimitiveArrayMap;
std::map<COLLADAFW::UniqueId, MaterialIdPrimitiveArrayMap> geom_uid_mat_mapping_map; // crazy name!
std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId> materials_mapped_to_geom; //< materials that have already been mapped to a geometry. A pair of geom uid and mat uid, one geometry can have several materials
-
+
bool set_poly_indices(MPoly *mpoly,
MLoop *mloop,
int loop_index,
@@ -135,7 +135,7 @@ private:
bool is_nice_mesh(COLLADAFW::Mesh *mesh);
void read_vertices(COLLADAFW::Mesh *mesh, Mesh *me);
-
+
bool primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp);
bool primitive_has_faces(COLLADAFW::MeshPrimitive *mp);
@@ -165,7 +165,7 @@ public:
virtual Object *get_object_by_geom_uid(const COLLADAFW::UniqueId& geom_uid);
virtual Mesh *get_mesh_by_geom_uid(const COLLADAFW::UniqueId& geom_uid);
-
+
void optimize_material_assignements();
void assign_material_to_geom(
@@ -173,8 +173,8 @@ public:
std::map<COLLADAFW::UniqueId, Material*>& uid_material_map,
Object *ob, const COLLADAFW::UniqueId *geom_uid,
short mat_index);
-
-
+
+
Object *create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom,
bool isController,
std::map<COLLADAFW::UniqueId, Material*>& uid_material_map);
diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
index 5d1df800746..d909203488e 100644
--- a/source/blender/collada/SceneExporter.cpp
+++ b/source/blender/collada/SceneExporter.cpp
@@ -39,18 +39,18 @@ SceneExporter::SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm,
{
}
-void SceneExporter::exportScene(Depsgraph *depsgraph, Scene *sce)
+void SceneExporter::exportScene(bContext *C, Depsgraph *depsgraph, Scene *sce)
{
// <library_visual_scenes> <visual_scene>
std::string id_naming = id_name(sce);
openVisualScene(translate_id(id_naming), id_naming);
- exportHierarchy(depsgraph, sce);
+ exportHierarchy(C, depsgraph, sce);
closeVisualScene();
closeLibrary();
}
-void SceneExporter::exportHierarchy(Depsgraph *depsgraph, Scene *sce)
-{
+void SceneExporter::exportHierarchy(bContext *C, Depsgraph *depsgraph, Scene *sce)
+{
LinkNode *node;
std::vector<Object *> base_objects;
@@ -59,7 +59,7 @@ void SceneExporter::exportHierarchy(Depsgraph *depsgraph, Scene *sce)
Object *ob = (Object *) node->link;
ob->id.tag |= LIB_TAG_DOIT;
}
-
+
// Now find all exportable base ojects (highest in export hierarchy)
for (node = this->export_settings->export_set; node; node = node->next) {
Object *ob = (Object *) node->link;
@@ -81,13 +81,13 @@ void SceneExporter::exportHierarchy(Depsgraph *depsgraph, Scene *sce)
Object *ob = base_objects[index];
if (bc_is_marked(ob)) {
bc_remove_mark(ob);
- writeNodes(depsgraph, ob, sce);
+ writeNodes(C, depsgraph, ob, sce);
}
}
}
-void SceneExporter::writeNodes(Depsgraph *depsgraph, Object *ob, Scene *sce)
+void SceneExporter::writeNodes(bContext *C, Depsgraph *depsgraph, Object *ob, Scene *sce)
{
// Add associated armature first if available
bool armature_exported = false;
@@ -96,7 +96,7 @@ void SceneExporter::writeNodes(Depsgraph *depsgraph, Object *ob, Scene *sce)
armature_exported = bc_is_in_Export_set(this->export_settings->export_set, ob_arm);
if (armature_exported && bc_is_marked(ob_arm)) {
bc_remove_mark(ob_arm);
- writeNodes(depsgraph, ob_arm, sce);
+ writeNodes(C, depsgraph, ob_arm, sce);
armature_exported = true;
}
}
@@ -155,7 +155,7 @@ void SceneExporter::writeNodes(Depsgraph *depsgraph, Object *ob, Scene *sce)
// <instance_controller>
else if (ob->type == OB_ARMATURE) {
- arm_exporter->add_armature_bones(depsgraph, ob, sce, this, child_objects);
+ arm_exporter->add_armature_bones(C, depsgraph, ob, sce, this, child_objects);
}
// <instance_camera>
@@ -203,17 +203,17 @@ void SceneExporter::writeNodes(Depsgraph *depsgraph, Object *ob, Scene *sce)
colladaNode.addExtraTechniqueChildParameter("blender",con_tag,"rot_error",con->rot_error);
colladaNode.addExtraTechniqueChildParameter("blender",con_tag,"tar_space",con->tarspace);
colladaNode.addExtraTechniqueChildParameter("blender",con_tag,"lin_error",con->lin_error);
-
- //not ideal: add the target object name as another parameter.
+
+ //not ideal: add the target object name as another parameter.
//No real mapping in the .dae
//Need support for multiple target objects also.
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
if (cti && cti->get_constraint_targets) {
-
+
bConstraintTarget *ct;
Object *obtar;
-
+
cti->get_constraint_targets(con, &targets);
for (ct = (bConstraintTarget *)targets.first; ct; ct = ct->next) {
@@ -234,7 +234,7 @@ void SceneExporter::writeNodes(Depsgraph *depsgraph, Object *ob, Scene *sce)
for (std::list<Object *>::iterator i = child_objects.begin(); i != child_objects.end(); ++i) {
if (bc_is_marked(*i)) {
bc_remove_mark(*i);
- writeNodes(depsgraph, *i, sce);
+ writeNodes(C, depsgraph, *i, sce);
}
}
diff --git a/source/blender/collada/SceneExporter.h b/source/blender/collada/SceneExporter.h
index c330aa81e91..91f98063020 100644
--- a/source/blender/collada/SceneExporter.h
+++ b/source/blender/collada/SceneExporter.h
@@ -96,13 +96,13 @@ class SceneExporter: COLLADASW::LibraryVisualScenes, protected TransformWriter,
{
public:
SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings);
- void exportScene(Depsgraph *depsgraph, Scene *sce);
+ void exportScene(bContext *C, Depsgraph *depsgraph, Scene *sce);
private:
friend class ArmatureExporter;
- void exportHierarchy(struct Depsgraph *depsgraph, Scene *sce);
- void writeNodes(struct Depsgraph *depsgraph, Object *ob, Scene *sce);
-
+ void exportHierarchy(bContext *C, struct Depsgraph *depsgraph, Scene *sce);
+ void writeNodes(bContext *C, struct Depsgraph *depsgraph, Object *ob, Scene *sce);
+
ArmatureExporter *arm_exporter;
const ExportSettings *export_settings;
};
diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp
index a2cb8237d08..7ec3f04aabf 100644
--- a/source/blender/collada/SkinInfo.cpp
+++ b/source/blender/collada/SkinInfo.cpp
@@ -121,7 +121,7 @@ void SkinInfo::borrow_skin_controller_data(const COLLADAFW::SkinControllerData *
unit_converter->dae_matrix_to_mat4_(bind_shape_matrix, skin->getBindShapeMatrix());
}
-
+
void SkinInfo::free()
{
joints_per_vertex.releaseMemory();
@@ -199,7 +199,7 @@ const COLLADAFW::UniqueId& SkinInfo::get_controller_uid()
}
// check if this skin controller references a joint or any descendant of it
-//
+//
// some nodes may not be referenced by SkinController,
// in this case to determine if the node belongs to this armature,
// we need to search down the tree
@@ -259,9 +259,9 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique
// skip joints that have invalid UID
if ((*it).joint_uid == COLLADAFW::UniqueId::INVALID) continue;
-
+
// name group by joint node name
-
+
if (joint_by_uid.find((*it).joint_uid) != joint_by_uid.end()) {
name = bc_get_joint_name(joint_by_uid[(*it).joint_uid]);
}
diff --git a/source/blender/collada/SkinInfo.h b/source/blender/collada/SkinInfo.h
index a399bff9e3c..fdfee0a943a 100644
--- a/source/blender/collada/SkinInfo.h
+++ b/source/blender/collada/SkinInfo.h
@@ -88,7 +88,7 @@ public:
void transfer_uint_array_data_const(const COLLADAFW::UIntValuesArray& src, COLLADAFW::UIntValuesArray& dest);
void borrow_skin_controller_data(const COLLADAFW::SkinControllerData* skin);
-
+
void free();
// using inverse bind matrices to construct armature
@@ -110,7 +110,7 @@ public:
const COLLADAFW::UniqueId& get_controller_uid();
// check if this skin controller references a joint or any descendant of it
- //
+ //
// some nodes may not be referenced by SkinController,
// in this case to determine if the node belongs to this armature,
// we need to search down the tree
diff --git a/source/blender/collada/TransformReader.cpp b/source/blender/collada/TransformReader.cpp
index 7f742be7e30..bf9c34153b7 100644
--- a/source/blender/collada/TransformReader.cpp
+++ b/source/blender/collada/TransformReader.cpp
@@ -54,7 +54,7 @@ void TransformReader::get_node_mat(
float copy[4][4];
unit_m4(mat);
-
+
for (unsigned int i = 0; i < node->getTransformations().getCount(); i++) {
COLLADAFW::Transformation *tm = node->getTransformations()[i];
@@ -87,11 +87,11 @@ void TransformReader::get_node_mat(
copy_m4_m4(copy, mat);
mul_m4_m4m4(mat, copy, cur);
-
+
if (animation_map) {
// AnimationList that drives this Transformation
const COLLADAFW::UniqueId& anim_list_id = tm->getAnimationList();
-
+
// store this so later we can link animation data with ob
Animation anim = {ob, node, tm};
(*animation_map)[anim_list_id] = anim;
diff --git a/source/blender/collada/TransformReader.h b/source/blender/collada/TransformReader.h
index 08bb17ccac1..6544aa1c040 100644
--- a/source/blender/collada/TransformReader.h
+++ b/source/blender/collada/TransformReader.h
@@ -19,7 +19,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
/** \file TransformReader.h
* \ingroup collada
*/
diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp
index 1fb54e99147..9f75a604f96 100644
--- a/source/blender/collada/TransformWriter.cpp
+++ b/source/blender/collada/TransformWriter.cpp
@@ -119,7 +119,7 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob,
{
float loc[3], rot[3], scale[3];
bc_decompose(f_obmat, loc, rot, NULL, scale);
- add_transform(node, loc, rot, scale);
+ add_transform(node, loc, rot, scale);
break;
}
}
diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp
index 5def6638df6..bf310cb24d8 100644
--- a/source/blender/collada/collada.cpp
+++ b/source/blender/collada/collada.cpp
@@ -51,7 +51,8 @@ int collada_import(bContext *C, ImportSettings *import_settings)
return (imp.import())? 1:0;
}
-int collada_export(Depsgraph *depsgraph,
+int collada_export(bContext *C,
+ Depsgraph *depsgraph,
Scene *sce,
ExportSettings *export_settings)
{
@@ -80,7 +81,7 @@ int collada_export(Depsgraph *depsgraph,
}
DocumentExporter exporter(depsgraph, export_settings);
- int status = exporter.exportCurrentScene(sce);
+ int status = exporter.exportCurrentScene(C, sce);
BLI_linklist_free(export_settings->export_set, NULL);
diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h
index 5cf526af1f2..a47463b5a7a 100644
--- a/source/blender/collada/collada.h
+++ b/source/blender/collada/collada.h
@@ -51,8 +51,8 @@ struct ViewLayer;
int collada_import(struct bContext *C,
ImportSettings *import_settings);
-
-int collada_export(struct Depsgraph *depsgraph,
+int collada_export(struct bContext *C,
+ struct Depsgraph *depsgraph,
struct Scene *sce,
ExportSettings *export_settings);
diff --git a/source/blender/collada/collada_internal.h b/source/blender/collada/collada_internal.h
index 299e13326ce..1eac5b68778 100644
--- a/source/blender/collada/collada_internal.h
+++ b/source/blender/collada/collada_internal.h
@@ -51,7 +51,7 @@ private:
float y_up_mat4[4][4];
float z_up_mat4[4][4];
float scale_mat4[4][4];
-
+
public:
enum UnitSystem {
@@ -66,11 +66,11 @@ public:
void read_asset(const COLLADAFW::FileInfo *asset);
void convertVector3(COLLADABU::Math::Vector3 &vec, float *v);
-
+
UnitConverter::UnitSystem isMetricSystem(void);
-
+
float getLinearMeter(void);
-
+
// TODO need also for angle conversion, time conversion...
void dae_matrix_to_mat4_(float out[4][4], const COLLADABU::Math::Matrix4& in);
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index b8fde34cc96..945dda68745 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -77,7 +77,7 @@ float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned in
if (array.getType() == COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT)
return array.getFloatValues()->getData()[index];
- else
+ else
return array.getDoubleValues()->getData()[index];
}
@@ -85,10 +85,10 @@ float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned in
int bc_test_parent_loop(Object *par, Object *ob)
{
/* test if 'ob' is a parent somewhere in par's parents */
-
+
if (par == NULL) return 0;
if (ob == par) return 1;
-
+
return bc_test_parent_loop(par->parent, ob);
}
@@ -117,7 +117,7 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
mul_m4_m4m4(mat, par->obmat, ob->obmat);
copy_m4_m4(ob->obmat, mat);
}
-
+
// apply child obmat (i.e. decompose it into rot/loc/size)
BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
@@ -231,7 +231,7 @@ Object *bc_get_assigned_armature(Object *ob)
// IMPORTANT: This function expects that
// all exported objects have set:
// ob->id.tag & LIB_TAG_DOIT
-Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob)
+Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob)
{
Object *ancestor = ob;
while (ob->parent && bc_is_marked(ob->parent)) {
@@ -256,7 +256,7 @@ bool bc_is_in_Export_set(LinkNode *export_set, Object *ob)
bool bc_has_object_type(LinkNode *export_set, short obtype)
{
LinkNode *node;
-
+
for (node = export_set; node; node = node->next) {
Object *ob = (Object *)node->link;
/* XXX - why is this checking for ob->data? - we could be looking for empties */
@@ -290,7 +290,7 @@ void bc_bubble_sort_by_Object_name(LinkNode *export_set)
for (node = export_set; node->next && !sorted; node = node->next) {
sorted = true;
-
+
LinkNode *current;
for (current = export_set; current->next; current = current->next) {
Object *a = (Object *)current->link;
@@ -301,13 +301,13 @@ void bc_bubble_sort_by_Object_name(LinkNode *export_set)
current->next->link = a;
sorted = false;
}
-
+
}
}
}
-/* Check if a bone is the top most exportable bone in the bone hierarchy.
- * When deform_bones_only == false, then only bones with NO parent
+/* Check if a bone is the top most exportable bone in the bone hierarchy.
+ * When deform_bones_only == false, then only bones with NO parent
* can be root bones. Otherwise the top most deform bones in the hierarchy
* are root bones.
*/
@@ -367,13 +367,13 @@ void bc_match_scale(Object *ob, UnitConverter &bc_unit, bool scale_to_scene)
BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
}
-void bc_match_scale(std::vector<Object *> *objects_done,
+void bc_match_scale(std::vector<Object *> *objects_done,
UnitConverter &bc_unit,
bool scale_to_scene)
{
for (std::vector<Object *>::iterator it = objects_done->begin();
it != objects_done->end();
- ++it)
+ ++it)
{
Object *ob = *it;
if (ob -> parent == NULL) {
@@ -781,7 +781,7 @@ float bc_get_property(Bone *bone, std::string key, float def)
/**
* Read a custom bone property and convert to matrix
* Return true if conversion was succesfull
-*
+*
* Return false if:
* - the property does not exist
* - is not an array of size 16
diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h
index 89765375afb..20c569834d8 100644
--- a/source/blender/collada/collada_utils.h
+++ b/source/blender/collada/collada_utils.h
@@ -92,8 +92,8 @@ extern void bc_bubble_sort_by_Object_name(LinkNode *export_set);
extern bool bc_is_root_bone(Bone *aBone, bool deform_bones_only);
extern int bc_get_active_UVLayer(Object *ob);
-extern std::string bc_replace_string(std::string data, const std::string& pattern, const std::string& replacement);
-extern std::string bc_url_encode(std::string data);
+extern std::string bc_replace_string(std::string data, const std::string& pattern, const std::string& replacement);
+extern std::string bc_url_encode(std::string data);
extern void bc_match_scale(Object *ob, UnitConverter &bc_unit, bool scale_to_scene);
extern void bc_match_scale(std::vector<Object *> *objects_done, UnitConverter &unit_converter, bool scale_to_scene);
@@ -135,8 +135,8 @@ class BCPolygonNormalsIndices
normal_indices.push_back(index);
}
- unsigned int operator[](unsigned int i) {
- return normal_indices[i];
+ unsigned int operator[](unsigned int i) {
+ return normal_indices[i];
}
};
diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h
index 3b24f9c69a2..10b62070978 100644
--- a/source/blender/compositor/COM_compositor.h
+++ b/source/blender/compositor/COM_compositor.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
@@ -326,7 +326,7 @@ void COM_execute(RenderData *rd, Scene *scene, bNodeTree *editingtree, int rende
void COM_deinitialize(void);
/**
- * @brief Clear all compositor caches. (Compositor system will still remain available).
+ * @brief Clear all compositor caches. (Compositor system will still remain available).
* To deinitialize the compositor use the COM_deinitialize method.
*/
// void COM_clearCaches(void); // NOT YET WRITTEN
diff --git a/source/blender/compositor/COM_defines.h b/source/blender/compositor/COM_defines.h
index 9936914d3d8..67b7f9b592b 100644
--- a/source/blender/compositor/COM_defines.h
+++ b/source/blender/compositor/COM_defines.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_CPUDevice.cpp b/source/blender/compositor/intern/COM_CPUDevice.cpp
index a5824ec5248..970338d41cc 100644
--- a/source/blender/compositor/intern/COM_CPUDevice.cpp
+++ b/source/blender/compositor/intern/COM_CPUDevice.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_CPUDevice.h b/source/blender/compositor/intern/COM_CPUDevice.h
index d12666593d4..f98a75e5978 100644
--- a/source/blender/compositor/intern/COM_CPUDevice.h
+++ b/source/blender/compositor/intern/COM_CPUDevice.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_ChunkOrder.cpp b/source/blender/compositor/intern/COM_ChunkOrder.cpp
index 3b094609a26..5ed183dbc08 100644
--- a/source/blender/compositor/intern/COM_ChunkOrder.cpp
+++ b/source/blender/compositor/intern/COM_ChunkOrder.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_ChunkOrder.h b/source/blender/compositor/intern/COM_ChunkOrder.h
index 108836d5299..0310933e5c5 100644
--- a/source/blender/compositor/intern/COM_ChunkOrder.h
+++ b/source/blender/compositor/intern/COM_ChunkOrder.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
index 1e64e0b9ea0..58e04f9fe7b 100644
--- a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
+++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.h b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h
index b166a7af57f..09e9fa44c3b 100644
--- a/source/blender/compositor/intern/COM_ChunkOrderHotspot.h
+++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp
index 807d78b620d..5d6497f147f 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.cpp
+++ b/source/blender/compositor/intern/COM_CompositorContext.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h
index 3cc6e9d4ac8..d58e8502414 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.h
+++ b/source/blender/compositor/intern/COM_CompositorContext.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index 9fa59be4a1c..3d49443c146 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h
index 311cec35644..7ed5616d899 100644
--- a/source/blender/compositor/intern/COM_Converter.h
+++ b/source/blender/compositor/intern/COM_Converter.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_Debug.cpp b/source/blender/compositor/intern/COM_Debug.cpp
index 68439ff8469..b95b7500cca 100644
--- a/source/blender/compositor/intern/COM_Debug.cpp
+++ b/source/blender/compositor/intern/COM_Debug.cpp
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
+ * Contributor:
* Lukas Toenne
*/
diff --git a/source/blender/compositor/intern/COM_Debug.h b/source/blender/compositor/intern/COM_Debug.h
index 204e7e4f57c..4b4894d36cf 100644
--- a/source/blender/compositor/intern/COM_Debug.h
+++ b/source/blender/compositor/intern/COM_Debug.h
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
+ * Contributor:
* Lukas Toenne
*/
diff --git a/source/blender/compositor/intern/COM_Device.cpp b/source/blender/compositor/intern/COM_Device.cpp
index 64172cdd472..ee59976f45d 100644
--- a/source/blender/compositor/intern/COM_Device.cpp
+++ b/source/blender/compositor/intern/COM_Device.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_Device.h b/source/blender/compositor/intern/COM_Device.h
index dc39b2baca7..62653357fdf 100644
--- a/source/blender/compositor/intern/COM_Device.h
+++ b/source/blender/compositor/intern/COM_Device.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
index 9a47c6b2438..8a8193bcb62 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h
index d3b11accd96..0f84dccb711 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.h
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
index 5e847439830..8e8539e3016 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h
index 41d63fb3a72..2c67a5f7b7f 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.h
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
index 8900a5940e3..f5045e6f3ab 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index 5ff3b51ce5a..27baca0ab6f 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_MemoryProxy.cpp b/source/blender/compositor/intern/COM_MemoryProxy.cpp
index 1df3e59db62..138b508c45b 100644
--- a/source/blender/compositor/intern/COM_MemoryProxy.cpp
+++ b/source/blender/compositor/intern/COM_MemoryProxy.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_MemoryProxy.h b/source/blender/compositor/intern/COM_MemoryProxy.h
index b332852088b..755d513c72f 100644
--- a/source/blender/compositor/intern/COM_MemoryProxy.h
+++ b/source/blender/compositor/intern/COM_MemoryProxy.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp
index 67f4d2523f3..a374403fef7 100644
--- a/source/blender/compositor/intern/COM_Node.cpp
+++ b/source/blender/compositor/intern/COM_Node.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h
index 559ca46ae8b..1c28292fb2e 100644
--- a/source/blender/compositor/intern/COM_Node.h
+++ b/source/blender/compositor/intern/COM_Node.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_NodeConverter.cpp b/source/blender/compositor/intern/COM_NodeConverter.cpp
index 208a3db812f..df8a7e6353c 100644
--- a/source/blender/compositor/intern/COM_NodeConverter.cpp
+++ b/source/blender/compositor/intern/COM_NodeConverter.cpp
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
+ * Contributor:
* Lukas Toenne
*/
diff --git a/source/blender/compositor/intern/COM_NodeConverter.h b/source/blender/compositor/intern/COM_NodeConverter.h
index 414b4f1ee95..fb7529ae2a7 100644
--- a/source/blender/compositor/intern/COM_NodeConverter.h
+++ b/source/blender/compositor/intern/COM_NodeConverter.h
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
+ * Contributor:
* Lukas Toenne
*/
diff --git a/source/blender/compositor/intern/COM_NodeGraph.cpp b/source/blender/compositor/intern/COM_NodeGraph.cpp
index c5096a6b352..5196108818b 100644
--- a/source/blender/compositor/intern/COM_NodeGraph.cpp
+++ b/source/blender/compositor/intern/COM_NodeGraph.cpp
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
+ * Contributor:
* Lukas Toenne
*/
diff --git a/source/blender/compositor/intern/COM_NodeGraph.h b/source/blender/compositor/intern/COM_NodeGraph.h
index 67f94bf3465..fe8740fee97 100644
--- a/source/blender/compositor/intern/COM_NodeGraph.h
+++ b/source/blender/compositor/intern/COM_NodeGraph.h
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
+ * Contributor:
* Lukas Toenne
*/
diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp
index f780c609dce..496a27b379c 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index 7c87524b4b3..1f3c72a820e 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
index e899b7b14fd..fc1584e3dbb 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
+ * Contributor:
* Lukas Toenne
*/
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.h b/source/blender/compositor/intern/COM_NodeOperationBuilder.h
index 633ddc9152a..2bb5b94c57f 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.h
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.h
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
+ * Contributor:
* Lukas Toenne
*/
diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
index 1c9e59a4b7a..54044f747fb 100644
--- a/source/blender/compositor/intern/COM_OpenCLDevice.cpp
+++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.h b/source/blender/compositor/intern/COM_OpenCLDevice.h
index ad40b4851fb..78d3c66cb5c 100644
--- a/source/blender/compositor/intern/COM_OpenCLDevice.h
+++ b/source/blender/compositor/intern/COM_OpenCLDevice.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp b/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
index b17f5d6b429..27d4d0951e8 100644
--- a/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
+++ b/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_SingleThreadedOperation.h b/source/blender/compositor/intern/COM_SingleThreadedOperation.h
index a6b2f777cb5..82d0b04e064 100644
--- a/source/blender/compositor/intern/COM_SingleThreadedOperation.h
+++ b/source/blender/compositor/intern/COM_SingleThreadedOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_SocketReader.cpp b/source/blender/compositor/intern/COM_SocketReader.cpp
index 45f3be5a66c..7517abc1430 100644
--- a/source/blender/compositor/intern/COM_SocketReader.cpp
+++ b/source/blender/compositor/intern/COM_SocketReader.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h
index ab8a3c06ef5..ff72d925184 100644
--- a/source/blender/compositor/intern/COM_SocketReader.h
+++ b/source/blender/compositor/intern/COM_SocketReader.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_WorkPackage.cpp b/source/blender/compositor/intern/COM_WorkPackage.cpp
index fa332ffa23e..0d8d71e9b08 100644
--- a/source/blender/compositor/intern/COM_WorkPackage.cpp
+++ b/source/blender/compositor/intern/COM_WorkPackage.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_WorkPackage.h b/source/blender/compositor/intern/COM_WorkPackage.h
index 2bb124a1c84..970a69b38d8 100644
--- a/source/blender/compositor/intern/COM_WorkPackage.h
+++ b/source/blender/compositor/intern/COM_WorkPackage.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
index e2dc289eb1c..ce45b9fdbe9 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cpp
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.h b/source/blender/compositor/intern/COM_WorkScheduler.h
index 67d3fc87ce1..7f07978a9c7 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.h
+++ b/source/blender/compositor/intern/COM_WorkScheduler.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp
index 40db5efda27..467286084f9 100644
--- a/source/blender/compositor/intern/COM_compositor.cpp
+++ b/source/blender/compositor/intern/COM_compositor.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.cpp b/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
index e9b99b6aaf1..0c35f079a8b 100644
--- a/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
+++ b/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.h b/source/blender/compositor/nodes/COM_AlphaOverNode.h
index 45febd62683..b1fe85cf800 100644
--- a/source/blender/compositor/nodes/COM_AlphaOverNode.h
+++ b/source/blender/compositor/nodes/COM_AlphaOverNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
index 90ff4ecf235..fe6b447b23b 100644
--- a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.h b/source/blender/compositor/nodes/COM_BilateralBlurNode.h
index dfd7361dabe..6d13cd5b96a 100644
--- a/source/blender/compositor/nodes/COM_BilateralBlurNode.h
+++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp
index 6fbfc24a6b6..66ccbaa4de8 100644
--- a/source/blender/compositor/nodes/COM_BlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BlurNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_BlurNode.h b/source/blender/compositor/nodes/COM_BlurNode.h
index 68844ca3d78..fecba9c0eef 100644
--- a/source/blender/compositor/nodes/COM_BlurNode.h
+++ b/source/blender/compositor/nodes/COM_BlurNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
index 91c26eecb73..b71f2f5fa07 100644
--- a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.h b/source/blender/compositor/nodes/COM_BokehBlurNode.h
index 60ba79bed78..2c8d52ad277 100644
--- a/source/blender/compositor/nodes/COM_BokehBlurNode.h
+++ b/source/blender/compositor/nodes/COM_BokehBlurNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.cpp b/source/blender/compositor/nodes/COM_BokehImageNode.cpp
index 7b7cfc812aa..7f25a19ee37 100644
--- a/source/blender/compositor/nodes/COM_BokehImageNode.cpp
+++ b/source/blender/compositor/nodes/COM_BokehImageNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.h b/source/blender/compositor/nodes/COM_BokehImageNode.h
index 6768bf0e88f..36ee1300661 100644
--- a/source/blender/compositor/nodes/COM_BokehImageNode.h
+++ b/source/blender/compositor/nodes/COM_BokehImageNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.cpp b/source/blender/compositor/nodes/COM_BoxMaskNode.cpp
index b8bf23b8549..b3cffb90459 100644
--- a/source/blender/compositor/nodes/COM_BoxMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_BoxMaskNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.h b/source/blender/compositor/nodes/COM_BoxMaskNode.h
index 3f466ef798e..8229aa58ac1 100644
--- a/source/blender/compositor/nodes/COM_BoxMaskNode.h
+++ b/source/blender/compositor/nodes/COM_BoxMaskNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_BrightnessNode.cpp b/source/blender/compositor/nodes/COM_BrightnessNode.cpp
index 6729571fac0..fc7294eb6b1 100644
--- a/source/blender/compositor/nodes/COM_BrightnessNode.cpp
+++ b/source/blender/compositor/nodes/COM_BrightnessNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_BrightnessNode.h b/source/blender/compositor/nodes/COM_BrightnessNode.h
index bd414b84e95..bacd3510517 100644
--- a/source/blender/compositor/nodes/COM_BrightnessNode.h
+++ b/source/blender/compositor/nodes/COM_BrightnessNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
index 46a70716349..98d2e048807 100644
--- a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.h b/source/blender/compositor/nodes/COM_ColorBalanceNode.h
index f0b9694ec77..1244dbbb7c5 100644
--- a/source/blender/compositor/nodes/COM_ColorBalanceNode.h
+++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp b/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp
index e926d131c1a..c4eefe038a5 100644
--- a/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ColorCorrectionNode.h b/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
index aa2c475734d..d943136ceb8 100644
--- a/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
+++ b/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ColorCurveNode.cpp b/source/blender/compositor/nodes/COM_ColorCurveNode.cpp
index 5a4dc79e6b2..41052ef536d 100644
--- a/source/blender/compositor/nodes/COM_ColorCurveNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorCurveNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ColorCurveNode.h b/source/blender/compositor/nodes/COM_ColorCurveNode.h
index 5420058ea64..0f99625e31a 100644
--- a/source/blender/compositor/nodes/COM_ColorCurveNode.h
+++ b/source/blender/compositor/nodes/COM_ColorCurveNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ColorNode.cpp b/source/blender/compositor/nodes/COM_ColorNode.cpp
index c3770e79dea..2c37a927e46 100644
--- a/source/blender/compositor/nodes/COM_ColorNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ColorNode.h b/source/blender/compositor/nodes/COM_ColorNode.h
index ac8c6c221b9..d03c910bfd2 100644
--- a/source/blender/compositor/nodes/COM_ColorNode.h
+++ b/source/blender/compositor/nodes/COM_ColorNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.cpp b/source/blender/compositor/nodes/COM_ColorRampNode.cpp
index 1feaa88bebb..175267a3a4f 100644
--- a/source/blender/compositor/nodes/COM_ColorRampNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorRampNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.h b/source/blender/compositor/nodes/COM_ColorRampNode.h
index d303616a417..c5e6b2f6154 100644
--- a/source/blender/compositor/nodes/COM_ColorRampNode.h
+++ b/source/blender/compositor/nodes/COM_ColorRampNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp
index f09c6bac3ee..2ce4dd5d3a8 100644
--- a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.h b/source/blender/compositor/nodes/COM_ColorToBWNode.h
index 6932c153c0c..350ab88513d 100644
--- a/source/blender/compositor/nodes/COM_ColorToBWNode.h
+++ b/source/blender/compositor/nodes/COM_ColorToBWNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_CombineColorNode.cpp b/source/blender/compositor/nodes/COM_CombineColorNode.cpp
index a39e946fe5f..b7b84b9986c 100644
--- a/source/blender/compositor/nodes/COM_CombineColorNode.cpp
+++ b/source/blender/compositor/nodes/COM_CombineColorNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Lukas Toenne
*/
diff --git a/source/blender/compositor/nodes/COM_CombineColorNode.h b/source/blender/compositor/nodes/COM_CombineColorNode.h
index 2eff1a28f20..4cb626ea384 100644
--- a/source/blender/compositor/nodes/COM_CombineColorNode.h
+++ b/source/blender/compositor/nodes/COM_CombineColorNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Lukas Toenne
*/
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp
index 4754f23a167..b2a1df7ee9e 100644
--- a/source/blender/compositor/nodes/COM_CompositorNode.cpp
+++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.h b/source/blender/compositor/nodes/COM_CompositorNode.h
index aa9a4cdd8bb..4e96eb63776 100644
--- a/source/blender/compositor/nodes/COM_CompositorNode.h
+++ b/source/blender/compositor/nodes/COM_CompositorNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_CropNode.cpp b/source/blender/compositor/nodes/COM_CropNode.cpp
index ee148f41c68..12eb5268be4 100644
--- a/source/blender/compositor/nodes/COM_CropNode.cpp
+++ b/source/blender/compositor/nodes/COM_CropNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_CropNode.h b/source/blender/compositor/nodes/COM_CropNode.h
index c1b84247ba2..cdec70a4a5c 100644
--- a/source/blender/compositor/nodes/COM_CropNode.h
+++ b/source/blender/compositor/nodes/COM_CropNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp
index d2ea385fde0..5df246db1d2 100644
--- a/source/blender/compositor/nodes/COM_DefocusNode.cpp
+++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.h b/source/blender/compositor/nodes/COM_DefocusNode.h
index 8c607f0737e..917499ee93a 100644
--- a/source/blender/compositor/nodes/COM_DefocusNode.h
+++ b/source/blender/compositor/nodes/COM_DefocusNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
index 2cb0e2301ac..f19cfd443a8 100644
--- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
index e221d43180b..98fb917e152 100644
--- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
index 933cb8365f9..6e78fcb38f1 100644
--- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.h b/source/blender/compositor/nodes/COM_DilateErodeNode.h
index b69592f7fc1..560087da30a 100644
--- a/source/blender/compositor/nodes/COM_DilateErodeNode.h
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
index 3d95a462117..9a4ced2bf96 100644
--- a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.h b/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
index 8c806aa5437..720ac32005e 100644
--- a/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
+++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.cpp b/source/blender/compositor/nodes/COM_DisplaceNode.cpp
index ffbb85882d5..34b3ec6d1a1 100644
--- a/source/blender/compositor/nodes/COM_DisplaceNode.cpp
+++ b/source/blender/compositor/nodes/COM_DisplaceNode.cpp
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
+ * Contributor:
* Dalai Felinto
*/
diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
index c67abb1ab99..913d97a6395 100644
--- a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
index 8e5f81e5ba5..4ee58e18c9b 100644
--- a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
+++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp b/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp
index b0a45c4e2fc..c0c99a2efe8 100644
--- a/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.h b/source/blender/compositor/nodes/COM_EllipseMaskNode.h
index 370f28f1ec2..50c578c2d7b 100644
--- a/source/blender/compositor/nodes/COM_EllipseMaskNode.h
+++ b/source/blender/compositor/nodes/COM_EllipseMaskNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_FilterNode.cpp b/source/blender/compositor/nodes/COM_FilterNode.cpp
index e8b08ce2ce1..627f2a30f6e 100644
--- a/source/blender/compositor/nodes/COM_FilterNode.cpp
+++ b/source/blender/compositor/nodes/COM_FilterNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_FilterNode.h b/source/blender/compositor/nodes/COM_FilterNode.h
index ef228c770de..0991b256ebb 100644
--- a/source/blender/compositor/nodes/COM_FilterNode.h
+++ b/source/blender/compositor/nodes/COM_FilterNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_FlipNode.cpp b/source/blender/compositor/nodes/COM_FlipNode.cpp
index 0177dc7017a..4cbae9bab66 100644
--- a/source/blender/compositor/nodes/COM_FlipNode.cpp
+++ b/source/blender/compositor/nodes/COM_FlipNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_FlipNode.h b/source/blender/compositor/nodes/COM_FlipNode.h
index 3e7b2de4812..033f893ab76 100644
--- a/source/blender/compositor/nodes/COM_FlipNode.h
+++ b/source/blender/compositor/nodes/COM_FlipNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_GammaNode.cpp b/source/blender/compositor/nodes/COM_GammaNode.cpp
index bf24bee55d3..383231ff326 100644
--- a/source/blender/compositor/nodes/COM_GammaNode.cpp
+++ b/source/blender/compositor/nodes/COM_GammaNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_GammaNode.h b/source/blender/compositor/nodes/COM_GammaNode.h
index 858d21cad9e..3b8a530edd9 100644
--- a/source/blender/compositor/nodes/COM_GammaNode.h
+++ b/source/blender/compositor/nodes/COM_GammaNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_GlareNode.cpp b/source/blender/compositor/nodes/COM_GlareNode.cpp
index 7afe1510ae4..b52ef9ebb33 100644
--- a/source/blender/compositor/nodes/COM_GlareNode.cpp
+++ b/source/blender/compositor/nodes/COM_GlareNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_GlareNode.h b/source/blender/compositor/nodes/COM_GlareNode.h
index 1e19cc5510e..afc9ad3e6f3 100644
--- a/source/blender/compositor/nodes/COM_GlareNode.h
+++ b/source/blender/compositor/nodes/COM_GlareNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp
index 851d43fc062..0c572c1ddc7 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
index 099ea3d11ce..cc425626608 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
index 36bc176b1a6..b31fe7ac030 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
index a599781a3b1..669cb6d2cff 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.cpp b/source/blender/compositor/nodes/COM_IDMaskNode.cpp
index 2c16616dc59..47137352226 100644
--- a/source/blender/compositor/nodes/COM_IDMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_IDMaskNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.h b/source/blender/compositor/nodes/COM_IDMaskNode.h
index a549a3e6ef8..120d173e5c3 100644
--- a/source/blender/compositor/nodes/COM_IDMaskNode.h
+++ b/source/blender/compositor/nodes/COM_IDMaskNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp
index 1399749fc8d..337169ba748 100644
--- a/source/blender/compositor/nodes/COM_ImageNode.cpp
+++ b/source/blender/compositor/nodes/COM_ImageNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Lukas Tönne
*/
diff --git a/source/blender/compositor/nodes/COM_ImageNode.h b/source/blender/compositor/nodes/COM_ImageNode.h
index 267794510e1..d8bf3ea3122 100644
--- a/source/blender/compositor/nodes/COM_ImageNode.h
+++ b/source/blender/compositor/nodes/COM_ImageNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Lukas Tönne
*/
diff --git a/source/blender/compositor/nodes/COM_InpaintNode.cpp b/source/blender/compositor/nodes/COM_InpaintNode.cpp
index 9e78625684d..17cc2fa653e 100644
--- a/source/blender/compositor/nodes/COM_InpaintNode.cpp
+++ b/source/blender/compositor/nodes/COM_InpaintNode.cpp
@@ -16,7 +16,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor: Peter Schlaile
- * Jeroen Bakker
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_InpaintNode.h b/source/blender/compositor/nodes/COM_InpaintNode.h
index c5ef1c0549e..6c167ed90ff 100644
--- a/source/blender/compositor/nodes/COM_InpaintNode.h
+++ b/source/blender/compositor/nodes/COM_InpaintNode.h
@@ -16,7 +16,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor: Peter Schlaile
- * Jeroen Bakker
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_InvertNode.cpp b/source/blender/compositor/nodes/COM_InvertNode.cpp
index da499d66c2c..ebdb2cdb7c5 100644
--- a/source/blender/compositor/nodes/COM_InvertNode.cpp
+++ b/source/blender/compositor/nodes/COM_InvertNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_InvertNode.h b/source/blender/compositor/nodes/COM_InvertNode.h
index 27f3da6cdca..a946799ce67 100644
--- a/source/blender/compositor/nodes/COM_InvertNode.h
+++ b/source/blender/compositor/nodes/COM_InvertNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
index 3d3cc841715..b6cc2acb9a6 100644
--- a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
+++ b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.h b/source/blender/compositor/nodes/COM_LensDistortionNode.h
index 4d5dc2e2705..231de6a5175 100644
--- a/source/blender/compositor/nodes/COM_LensDistortionNode.h
+++ b/source/blender/compositor/nodes/COM_LensDistortionNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_MapRangeNode.cpp b/source/blender/compositor/nodes/COM_MapRangeNode.cpp
index 148ca00205c..81ee4f0d7a9 100644
--- a/source/blender/compositor/nodes/COM_MapRangeNode.cpp
+++ b/source/blender/compositor/nodes/COM_MapRangeNode.cpp
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
+ * Contributor:
* Dalai Felinto
* Daniel Salazar
*/
diff --git a/source/blender/compositor/nodes/COM_MapRangeNode.h b/source/blender/compositor/nodes/COM_MapRangeNode.h
index 0ef4309602d..8c2b8d1f807 100644
--- a/source/blender/compositor/nodes/COM_MapRangeNode.h
+++ b/source/blender/compositor/nodes/COM_MapRangeNode.h
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
+ * Contributor:
* Dalai Felinto
* Daniel Salazar
*/
diff --git a/source/blender/compositor/nodes/COM_MapUVNode.cpp b/source/blender/compositor/nodes/COM_MapUVNode.cpp
index ec38e23ec07..c593805c940 100644
--- a/source/blender/compositor/nodes/COM_MapUVNode.cpp
+++ b/source/blender/compositor/nodes/COM_MapUVNode.cpp
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
+ * Contributor:
* Dalai Felinto
*/
diff --git a/source/blender/compositor/nodes/COM_MapValueNode.cpp b/source/blender/compositor/nodes/COM_MapValueNode.cpp
index f04c6a2d316..9a4c4880b62 100644
--- a/source/blender/compositor/nodes/COM_MapValueNode.cpp
+++ b/source/blender/compositor/nodes/COM_MapValueNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_MapValueNode.h b/source/blender/compositor/nodes/COM_MapValueNode.h
index 8b82b31350d..dca1657ce0b 100644
--- a/source/blender/compositor/nodes/COM_MapValueNode.h
+++ b/source/blender/compositor/nodes/COM_MapValueNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp
index 0fb6933afe7..e9bed136a37 100644
--- a/source/blender/compositor/nodes/COM_MathNode.cpp
+++ b/source/blender/compositor/nodes/COM_MathNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_MathNode.h b/source/blender/compositor/nodes/COM_MathNode.h
index 72403e7059f..4c84dc2a331 100644
--- a/source/blender/compositor/nodes/COM_MathNode.h
+++ b/source/blender/compositor/nodes/COM_MathNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_MixNode.cpp b/source/blender/compositor/nodes/COM_MixNode.cpp
index 0607d6d6705..e807365d9db 100644
--- a/source/blender/compositor/nodes/COM_MixNode.cpp
+++ b/source/blender/compositor/nodes/COM_MixNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_MixNode.h b/source/blender/compositor/nodes/COM_MixNode.h
index 3e61a855d31..e5424c2f4e5 100644
--- a/source/blender/compositor/nodes/COM_MixNode.h
+++ b/source/blender/compositor/nodes/COM_MixNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.cpp b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
index b3f1b5a4458..269d7f2cafe 100644
--- a/source/blender/compositor/nodes/COM_MovieClipNode.cpp
+++ b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.h b/source/blender/compositor/nodes/COM_MovieClipNode.h
index ff7b2869f05..78fcf24de35 100644
--- a/source/blender/compositor/nodes/COM_MovieClipNode.h
+++ b/source/blender/compositor/nodes/COM_MovieClipNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp b/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp
index fd907465984..c4277354b43 100644
--- a/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp
+++ b/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_MovieDistortionNode.h b/source/blender/compositor/nodes/COM_MovieDistortionNode.h
index 6ff0295083f..5ef0115bbaa 100644
--- a/source/blender/compositor/nodes/COM_MovieDistortionNode.h
+++ b/source/blender/compositor/nodes/COM_MovieDistortionNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_NormalNode.cpp b/source/blender/compositor/nodes/COM_NormalNode.cpp
index 26da61cb9e7..bde5a126325 100644
--- a/source/blender/compositor/nodes/COM_NormalNode.cpp
+++ b/source/blender/compositor/nodes/COM_NormalNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_NormalNode.h b/source/blender/compositor/nodes/COM_NormalNode.h
index 5cccaab5875..c9b37580eca 100644
--- a/source/blender/compositor/nodes/COM_NormalNode.h
+++ b/source/blender/compositor/nodes/COM_NormalNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
index 42805d1ff37..46e7f7fe790 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.cpp
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Lukas Tönne
*/
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.h b/source/blender/compositor/nodes/COM_OutputFileNode.h
index 54e29417c14..b321572d638 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.h
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Lukas Tönne
*/
diff --git a/source/blender/compositor/nodes/COM_PixelateNode.h b/source/blender/compositor/nodes/COM_PixelateNode.h
index a5e73eb3683..06ac886c843 100644
--- a/source/blender/compositor/nodes/COM_PixelateNode.h
+++ b/source/blender/compositor/nodes/COM_PixelateNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.h b/source/blender/compositor/nodes/COM_RenderLayersNode.h
index 5c6c5e17d1f..edbc91fff70 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.h
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_RotateNode.cpp b/source/blender/compositor/nodes/COM_RotateNode.cpp
index 6fd7e357775..77638d66987 100644
--- a/source/blender/compositor/nodes/COM_RotateNode.cpp
+++ b/source/blender/compositor/nodes/COM_RotateNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_RotateNode.h b/source/blender/compositor/nodes/COM_RotateNode.h
index f192fa8db25..e897c9a49df 100644
--- a/source/blender/compositor/nodes/COM_RotateNode.h
+++ b/source/blender/compositor/nodes/COM_RotateNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ScaleNode.h b/source/blender/compositor/nodes/COM_ScaleNode.h
index d009b3f6781..614866d2318 100644
--- a/source/blender/compositor/nodes/COM_ScaleNode.h
+++ b/source/blender/compositor/nodes/COM_ScaleNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_SeparateColorNode.cpp b/source/blender/compositor/nodes/COM_SeparateColorNode.cpp
index 780ce73d340..68fdaf01f5c 100644
--- a/source/blender/compositor/nodes/COM_SeparateColorNode.cpp
+++ b/source/blender/compositor/nodes/COM_SeparateColorNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Lukas Toenne
*/
diff --git a/source/blender/compositor/nodes/COM_SeparateColorNode.h b/source/blender/compositor/nodes/COM_SeparateColorNode.h
index 6730e471e06..d378a311e73 100644
--- a/source/blender/compositor/nodes/COM_SeparateColorNode.h
+++ b/source/blender/compositor/nodes/COM_SeparateColorNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Lukas Toenne
*/
diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.cpp b/source/blender/compositor/nodes/COM_SetAlphaNode.cpp
index 32c03c695be..4c55a4bdc0a 100644
--- a/source/blender/compositor/nodes/COM_SetAlphaNode.cpp
+++ b/source/blender/compositor/nodes/COM_SetAlphaNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.h b/source/blender/compositor/nodes/COM_SetAlphaNode.h
index 6dbc7ebed04..efc8ccf1f27 100644
--- a/source/blender/compositor/nodes/COM_SetAlphaNode.h
+++ b/source/blender/compositor/nodes/COM_SetAlphaNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
index 465a94e8335..c76b057577c 100644
--- a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
+++ b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.h b/source/blender/compositor/nodes/COM_SocketProxyNode.h
index 5dbf39382cc..410cbf94842 100644
--- a/source/blender/compositor/nodes/COM_SocketProxyNode.h
+++ b/source/blender/compositor/nodes/COM_SocketProxyNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
index 0f917d317f9..725ef292d86 100644
--- a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
+++ b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.h b/source/blender/compositor/nodes/COM_SplitViewerNode.h
index 1cc0c4cb9a8..674067696ea 100644
--- a/source/blender/compositor/nodes/COM_SplitViewerNode.h
+++ b/source/blender/compositor/nodes/COM_SplitViewerNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
index f25c7b3fc2d..a575cf65b99 100644
--- a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.h b/source/blender/compositor/nodes/COM_Stabilize2dNode.h
index 3b5890460c2..d0b5f6e96f6 100644
--- a/source/blender/compositor/nodes/COM_Stabilize2dNode.h
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_SwitchNode.cpp b/source/blender/compositor/nodes/COM_SwitchNode.cpp
index eb854983d4c..e0c12e4dbea 100644
--- a/source/blender/compositor/nodes/COM_SwitchNode.cpp
+++ b/source/blender/compositor/nodes/COM_SwitchNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_SwitchNode.h b/source/blender/compositor/nodes/COM_SwitchNode.h
index 4fedf4b0aa7..37ba73528f3 100644
--- a/source/blender/compositor/nodes/COM_SwitchNode.h
+++ b/source/blender/compositor/nodes/COM_SwitchNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_TextureNode.cpp b/source/blender/compositor/nodes/COM_TextureNode.cpp
index b80ca2fcdbd..411dea2925f 100644
--- a/source/blender/compositor/nodes/COM_TextureNode.cpp
+++ b/source/blender/compositor/nodes/COM_TextureNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_TextureNode.h b/source/blender/compositor/nodes/COM_TextureNode.h
index 8d0fb467b1b..4809f8a781e 100644
--- a/source/blender/compositor/nodes/COM_TextureNode.h
+++ b/source/blender/compositor/nodes/COM_TextureNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_TimeNode.cpp b/source/blender/compositor/nodes/COM_TimeNode.cpp
index b5e8ece9028..8450b521267 100644
--- a/source/blender/compositor/nodes/COM_TimeNode.cpp
+++ b/source/blender/compositor/nodes/COM_TimeNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_TimeNode.h b/source/blender/compositor/nodes/COM_TimeNode.h
index 078720f7150..065c55f2780 100644
--- a/source/blender/compositor/nodes/COM_TimeNode.h
+++ b/source/blender/compositor/nodes/COM_TimeNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_TonemapNode.cpp b/source/blender/compositor/nodes/COM_TonemapNode.cpp
index 961139d4855..1ecc42a0a27 100644
--- a/source/blender/compositor/nodes/COM_TonemapNode.cpp
+++ b/source/blender/compositor/nodes/COM_TonemapNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_TonemapNode.h b/source/blender/compositor/nodes/COM_TonemapNode.h
index 4a8636fd041..e504db4c014 100644
--- a/source/blender/compositor/nodes/COM_TonemapNode.h
+++ b/source/blender/compositor/nodes/COM_TonemapNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_TransformNode.cpp b/source/blender/compositor/nodes/COM_TransformNode.cpp
index 148409a6427..5b772d1ce56 100644
--- a/source/blender/compositor/nodes/COM_TransformNode.cpp
+++ b/source/blender/compositor/nodes/COM_TransformNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_TransformNode.h b/source/blender/compositor/nodes/COM_TransformNode.h
index 6e210d266de..9a7c415cc5d 100644
--- a/source/blender/compositor/nodes/COM_TransformNode.h
+++ b/source/blender/compositor/nodes/COM_TransformNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_TranslateNode.cpp b/source/blender/compositor/nodes/COM_TranslateNode.cpp
index 04dc1d435d3..0e658e09931 100644
--- a/source/blender/compositor/nodes/COM_TranslateNode.cpp
+++ b/source/blender/compositor/nodes/COM_TranslateNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_TranslateNode.h b/source/blender/compositor/nodes/COM_TranslateNode.h
index 160da410aff..484f28b1089 100644
--- a/source/blender/compositor/nodes/COM_TranslateNode.h
+++ b/source/blender/compositor/nodes/COM_TranslateNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ValueNode.cpp b/source/blender/compositor/nodes/COM_ValueNode.cpp
index c75d9296807..f2eef188861 100644
--- a/source/blender/compositor/nodes/COM_ValueNode.cpp
+++ b/source/blender/compositor/nodes/COM_ValueNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ValueNode.h b/source/blender/compositor/nodes/COM_ValueNode.h
index e5b80fb4c60..b88c502be7f 100644
--- a/source/blender/compositor/nodes/COM_ValueNode.h
+++ b/source/blender/compositor/nodes/COM_ValueNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
index cbe02388f90..5cfd83360c7 100644
--- a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.h b/source/blender/compositor/nodes/COM_VectorBlurNode.h
index f402aee9670..0e7ad015cc5 100644
--- a/source/blender/compositor/nodes/COM_VectorBlurNode.h
+++ b/source/blender/compositor/nodes/COM_VectorBlurNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_VectorCurveNode.cpp b/source/blender/compositor/nodes/COM_VectorCurveNode.cpp
index 7222a018fa0..db7e1597bf3 100644
--- a/source/blender/compositor/nodes/COM_VectorCurveNode.cpp
+++ b/source/blender/compositor/nodes/COM_VectorCurveNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_VectorCurveNode.h b/source/blender/compositor/nodes/COM_VectorCurveNode.h
index 8499bbf99df..8cf76cff206 100644
--- a/source/blender/compositor/nodes/COM_VectorCurveNode.h
+++ b/source/blender/compositor/nodes/COM_VectorCurveNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp b/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
index 06f12ccc559..b7e4c9e8a1d 100644
--- a/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
+++ b/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ViewLevelsNode.h b/source/blender/compositor/nodes/COM_ViewLevelsNode.h
index dbcc770f88a..c56c6b0cef1 100644
--- a/source/blender/compositor/nodes/COM_ViewLevelsNode.h
+++ b/source/blender/compositor/nodes/COM_ViewLevelsNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp
index ab819ce6e30..8ad3b219598 100644
--- a/source/blender/compositor/nodes/COM_ViewerNode.cpp
+++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ViewerNode.h b/source/blender/compositor/nodes/COM_ViewerNode.h
index 289c2650342..1f2cb02dcd6 100644
--- a/source/blender/compositor/nodes/COM_ViewerNode.h
+++ b/source/blender/compositor/nodes/COM_ViewerNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.cpp b/source/blender/compositor/nodes/COM_ZCombineNode.cpp
index d46600cc368..c77bd031824 100644
--- a/source/blender/compositor/nodes/COM_ZCombineNode.cpp
+++ b/source/blender/compositor/nodes/COM_ZCombineNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.h b/source/blender/compositor/nodes/COM_ZCombineNode.h
index 474be8db6ba..9a438d6dde3 100644
--- a/source/blender/compositor/nodes/COM_ZCombineNode.h
+++ b/source/blender/compositor/nodes/COM_ZCombineNode.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
index d4103a61685..928525f2594 100644
--- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
index eceee43e600..8e4a0c93202 100644
--- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
index 1dba542e142..990ec5f5370 100644
--- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
index ff6d1a978b8..8c97b065792 100644
--- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
index 60a2fd6a442..1f397e8a126 100644
--- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
index db68583baa6..1dad453ca4e 100644
--- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.h b/source/blender/compositor/operations/COM_AntiAliasOperation.h
index 996c7c2fe41..13632a81084 100644
--- a/source/blender/compositor/operations/COM_AntiAliasOperation.h
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
index b24e48f52bc..4a6da3092a2 100644
--- a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.h b/source/blender/compositor/operations/COM_BilateralBlurOperation.h
index cfd96617681..b013e357b9c 100644
--- a/source/blender/compositor/operations/COM_BilateralBlurOperation.h
+++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
index 2003d6e7b69..7b130edc46d 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.h b/source/blender/compositor/operations/COM_BlurBaseOperation.h
index 84cdcfeeba8..9fd7c017715 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.h
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
index 5ed36635f81..c413f45cbaa 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.h b/source/blender/compositor/operations/COM_BokehBlurOperation.h
index ed967d0fdb9..3bfaae6617e 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cpp b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
index 18846f2a2c5..5c694a21ad9 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.h b/source/blender/compositor/operations/COM_BokehImageOperation.h
index 3cf9afda32a..a2dd3b6ddb7 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.h
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
@@ -39,7 +39,7 @@
* is evaluating.
*
* The edge is detected by finding the closest point on the direct line between the two nearest flap-corners.
- * this edge is interpolated with a full circle.
+ * this edge is interpolated with a full circle.
* Result of this edge detection is stored as the distance between the center of the image and the edge.
*
* catadioptric lenses are simulated to interpolate between the center of the image and the distance of the edge.
diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
index c4765b849bf..e19e5bf031c 100644
--- a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.h b/source/blender/compositor/operations/COM_BoxMaskOperation.h
index 04dc8a90fd7..c8b2ba14467 100644
--- a/source/blender/compositor/operations/COM_BoxMaskOperation.h
+++ b/source/blender/compositor/operations/COM_BoxMaskOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.cpp b/source/blender/compositor/operations/COM_BrightnessOperation.cpp
index c7ba86b66bc..099113dbf47 100644
--- a/source/blender/compositor/operations/COM_BrightnessOperation.cpp
+++ b/source/blender/compositor/operations/COM_BrightnessOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.h b/source/blender/compositor/operations/COM_BrightnessOperation.h
index ff492f2b102..0b7656c5364 100644
--- a/source/blender/compositor/operations/COM_BrightnessOperation.h
+++ b/source/blender/compositor/operations/COM_BrightnessOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
index ecbc7a9a93d..0fa8b5fa5d2 100644
--- a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
+++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.h b/source/blender/compositor/operations/COM_CalculateMeanOperation.h
index 53edea4977e..4fa89290c82 100644
--- a/source/blender/compositor/operations/COM_CalculateMeanOperation.h
+++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
index 56b402f2b3b..ff4857b7b0f 100644
--- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
+++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
index 92c4b7fa4a0..dfeaa7297a8 100644
--- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
+++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
index 7ea974a41dc..a02c1b03006 100644
--- a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.h b/source/blender/compositor/operations/COM_ChangeHSVOperation.h
index 800c09c05ff..e6f45c5ad36 100644
--- a/source/blender/compositor/operations/COM_ChangeHSVOperation.h
+++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
index 3482f639ecb..23390bd337d 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
index bf3495869b0..cc6bd894748 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
index 627bbb73e3b..e13fd26aed2 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
index da3a141e3c2..86d7abc92bc 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
index 54e0fb41abf..05edaf51a25 100644
--- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
index 2b47d6a8034..c386a2f3e6e 100644
--- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
+++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
index 19deb2f2ba0..5967147b3d1 100644
--- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.h b/source/blender/compositor/operations/COM_ColorCurveOperation.h
index 1eb77553953..3b10786fb2c 100644
--- a/source/blender/compositor/operations/COM_ColorCurveOperation.h
+++ b/source/blender/compositor/operations/COM_ColorCurveOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.cpp b/source/blender/compositor/operations/COM_ColorRampOperation.cpp
index c67f906b374..eb1d96c81ec 100644
--- a/source/blender/compositor/operations/COM_ColorRampOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorRampOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.h b/source/blender/compositor/operations/COM_ColorRampOperation.h
index f143e1568d5..55f711165d6 100644
--- a/source/blender/compositor/operations/COM_ColorRampOperation.h
+++ b/source/blender/compositor/operations/COM_ColorRampOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp
index 241ae20ce33..16e33c908d6 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.cpp
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp
@@ -22,6 +22,7 @@
#include "COM_CompositorOperation.h"
#include "BLI_listbase.h"
+#include "BKE_global.h"
#include "BKE_image.h"
extern "C" {
@@ -109,7 +110,7 @@ void CompositorOperation::deinitExecution()
}
BLI_thread_lock(LOCK_DRAW_IMAGE);
- BKE_image_signal(BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"), NULL, IMA_SIGNAL_FREE);
+ BKE_image_signal(G.main, BKE_image_verify_viewer(G.main, IMA_TYPE_R_RESULT, "Render Result"), NULL, IMA_SIGNAL_FREE);
BLI_thread_unlock(LOCK_DRAW_IMAGE);
}
else {
diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
index b99940a8862..a854749990c 100644
--- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
index e68a9bdf7c1..ceba2a85da0 100644
--- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
index 7fdd10affaf..9057c3c92ec 100644
--- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
index b92eb65d01e..697ac455702 100644
--- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ConvertOperation.cpp b/source/blender/compositor/operations/COM_ConvertOperation.cpp
index 8e79931d6f0..3746fc85f9c 100644
--- a/source/blender/compositor/operations/COM_ConvertOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ConvertOperation.h b/source/blender/compositor/operations/COM_ConvertOperation.h
index 957df812a2e..5dee63ea739 100644
--- a/source/blender/compositor/operations/COM_ConvertOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
index 5f78067220a..56815459ee7 100644
--- a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h
index c666dc2cd42..650d3ddda58 100644
--- a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h
+++ b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
index 6ac1ff9a1eb..41cc504af05 100644
--- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h
index faab6577be9..75fba0ee1e4 100644
--- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h
+++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_CropOperation.cpp b/source/blender/compositor/operations/COM_CropOperation.cpp
index e5427589fce..162811ac31d 100644
--- a/source/blender/compositor/operations/COM_CropOperation.cpp
+++ b/source/blender/compositor/operations/COM_CropOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_CropOperation.h b/source/blender/compositor/operations/COM_CropOperation.h
index 0b396ca7800..7c5b995fb17 100644
--- a/source/blender/compositor/operations/COM_CropOperation.h
+++ b/source/blender/compositor/operations/COM_CropOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
index 9bb5ac88343..97129f8ec66 100644
--- a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.h b/source/blender/compositor/operations/COM_CurveBaseOperation.h
index 154eb18e387..169022de5f5 100644
--- a/source/blender/compositor/operations/COM_CurveBaseOperation.h
+++ b/source/blender/compositor/operations/COM_CurveBaseOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
index aa58c0571cf..770a5bd205b 100644
--- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
index a3647e1e5db..ddf6bf6f893 100644
--- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
+++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
index fc3ec7dd11a..2ea438d070d 100644
--- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.h b/source/blender/compositor/operations/COM_DilateErodeOperation.h
index 51bad81d0ca..c929fcf7fec 100644
--- a/source/blender/compositor/operations/COM_DilateErodeOperation.h
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
index 14881ebb265..2e0be8d8410 100644
--- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h
index d9809eb0296..a6194a0ca73 100644
--- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_DotproductOperation.cpp b/source/blender/compositor/operations/COM_DotproductOperation.cpp
index 368db185adc..e2e54ee4aa7 100644
--- a/source/blender/compositor/operations/COM_DotproductOperation.cpp
+++ b/source/blender/compositor/operations/COM_DotproductOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_DotproductOperation.h b/source/blender/compositor/operations/COM_DotproductOperation.h
index 4378e280d17..218409cbf5b 100644
--- a/source/blender/compositor/operations/COM_DotproductOperation.h
+++ b/source/blender/compositor/operations/COM_DotproductOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
index ca3c5f7b069..8d2a0f3b427 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h
index 528aae7218f..a12c44b02a1 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
index 49c4662ed0c..482473cbe1f 100644
--- a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.h b/source/blender/compositor/operations/COM_EllipseMaskOperation.h
index 753615df370..419b2c2d63b 100644
--- a/source/blender/compositor/operations/COM_EllipseMaskOperation.h
+++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
index b83ebdd0913..a223ac31e3d 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
index 58bf1d4f596..1cfaee3f537 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_FlipOperation.cpp b/source/blender/compositor/operations/COM_FlipOperation.cpp
index 7ff7d694fa8..80e67a7297b 100644
--- a/source/blender/compositor/operations/COM_FlipOperation.cpp
+++ b/source/blender/compositor/operations/COM_FlipOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_FlipOperation.h b/source/blender/compositor/operations/COM_FlipOperation.h
index a1fcde19876..3a7bf77f29b 100644
--- a/source/blender/compositor/operations/COM_FlipOperation.h
+++ b/source/blender/compositor/operations/COM_FlipOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
index 357677d6832..f7d9ad838d1 100644
--- a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
+++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.h b/source/blender/compositor/operations/COM_GammaCorrectOperation.h
index 68eaab83c99..b3f0cedce22 100644
--- a/source/blender/compositor/operations/COM_GammaCorrectOperation.h
+++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_GammaOperation.cpp b/source/blender/compositor/operations/COM_GammaOperation.cpp
index d98f2c4663f..79b70b5170e 100644
--- a/source/blender/compositor/operations/COM_GammaOperation.cpp
+++ b/source/blender/compositor/operations/COM_GammaOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_GammaOperation.h b/source/blender/compositor/operations/COM_GammaOperation.h
index d8e08457812..9243ece6b30 100644
--- a/source/blender/compositor/operations/COM_GammaOperation.h
+++ b/source/blender/compositor/operations/COM_GammaOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
index cbe41076b2a..0fab888b9d9 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Campbell Barton
*/
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h
index 0d61e964009..fc5b3384749 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Campbell Barton
*/
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
index 30563e8cc45..b4e535cbf20 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Campbell Barton
*/
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h
index 36b1201c9d7..4f2f2ec3fe4 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Campbell Barton
*/
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
index 7c4132238e3..c268cff557a 100644
--- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h
index 081c3743076..e483ffd4f2d 100644
--- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
index 4d05ece7ef0..ef438e1d364 100644
--- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h
index d7ae8b1e3dc..46a5c4e3c03 100644
--- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
index 3203914b5a7..6f8f96a6344 100644
--- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h
index 4b5751c0968..ca3172bd505 100644
--- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
index 1acbd2ae090..8942bbaa3e1 100644
--- a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
index 573049cf07f..3e480ca04ef 100644
--- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
+++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
index 0a0e82bf168..06d785f2c51 100644
--- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
+++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.cpp b/source/blender/compositor/operations/COM_IDMaskOperation.cpp
index 05462d31ed2..d294dd3e8ba 100644
--- a/source/blender/compositor/operations/COM_IDMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.h b/source/blender/compositor/operations/COM_IDMaskOperation.h
index 841d4a76124..89f9855303c 100644
--- a/source/blender/compositor/operations/COM_IDMaskOperation.h
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp
index 7d59358831c..2215f482e4d 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_ImageOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ImageOperation.h b/source/blender/compositor/operations/COM_ImageOperation.h
index 75222559810..1f9a9a45af1 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.h
+++ b/source/blender/compositor/operations/COM_ImageOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp
index 43b7b30319d..11896b1d78c 100644
--- a/source/blender/compositor/operations/COM_InpaintOperation.cpp
+++ b/source/blender/compositor/operations/COM_InpaintOperation.cpp
@@ -16,7 +16,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor: Peter Schlaile
- * Jeroen Bakker
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.h b/source/blender/compositor/operations/COM_InpaintOperation.h
index 59465ed3432..9ddcac93c5c 100644
--- a/source/blender/compositor/operations/COM_InpaintOperation.h
+++ b/source/blender/compositor/operations/COM_InpaintOperation.h
@@ -16,7 +16,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor: Peter Schlaile
- * Jeroen Bakker
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_InvertOperation.cpp b/source/blender/compositor/operations/COM_InvertOperation.cpp
index dc5a2653129..833b91ac1e3 100644
--- a/source/blender/compositor/operations/COM_InvertOperation.cpp
+++ b/source/blender/compositor/operations/COM_InvertOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_InvertOperation.h b/source/blender/compositor/operations/COM_InvertOperation.h
index be1e933f1e9..977feeb87af 100644
--- a/source/blender/compositor/operations/COM_InvertOperation.h
+++ b/source/blender/compositor/operations/COM_InvertOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.cpp b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
index 7a38d066122..6124a53d5b9 100644
--- a/source/blender/compositor/operations/COM_MapRangeOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
+ * Contributor:
* Dalai Felinto
* Daniel Salazar
*/
diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.h b/source/blender/compositor/operations/COM_MapRangeOperation.h
index a232f89ea9d..48ecad9d226 100644
--- a/source/blender/compositor/operations/COM_MapRangeOperation.h
+++ b/source/blender/compositor/operations/COM_MapRangeOperation.h
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
+ * Contributor:
* Dalai Felinto
* Daniel Salazar
*/
diff --git a/source/blender/compositor/operations/COM_MapValueOperation.cpp b/source/blender/compositor/operations/COM_MapValueOperation.cpp
index d6aaf560fce..59d4d836b1b 100644
--- a/source/blender/compositor/operations/COM_MapValueOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapValueOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_MapValueOperation.h b/source/blender/compositor/operations/COM_MapValueOperation.h
index a9a59d6633a..ba19e76f4db 100644
--- a/source/blender/compositor/operations/COM_MapValueOperation.h
+++ b/source/blender/compositor/operations/COM_MapValueOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
index dbc91980acd..bb6e1f9da8d 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h
index 04019372711..862783fff5d 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.h
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_MixOperation.cpp b/source/blender/compositor/operations/COM_MixOperation.cpp
index e202006e954..314e16895f3 100644
--- a/source/blender/compositor/operations/COM_MixOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_MixOperation.h b/source/blender/compositor/operations/COM_MixOperation.h
index d399edba6e9..f375a47f087 100644
--- a/source/blender/compositor/operations/COM_MixOperation.h
+++ b/source/blender/compositor/operations/COM_MixOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
index 5d682352d46..5f8c3ef435c 100644
--- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
index 659f54c1ca2..436b89a0dfb 100644
--- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.cpp b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
index 1e4821f0cd3..a19cb1a34d2 100644
--- a/source/blender/compositor/operations/COM_MovieClipOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.h b/source/blender/compositor/operations/COM_MovieClipOperation.h
index c16262cbd02..93452752234 100644
--- a/source/blender/compositor/operations/COM_MovieClipOperation.h
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
index b57dd4e32c3..133a780fc6d 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Lukas Tönne
*/
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.h b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
index 46a9319c373..2e68f922dd9 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.h
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Lukas Tönne
*/
diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
index 7786359c06a..f7fcf63fabb 100644
--- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
@@ -31,6 +31,7 @@
#include "BLI_string.h"
#include "BKE_image.h"
#include "BKE_global.h"
+#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_scene.h"
@@ -100,11 +101,10 @@ void OutputOpenExrSingleLayerMultiViewOperation::deinitExecution()
if (width != 0 && height != 0) {
void *exrhandle;
- Main *bmain = G.main; /* TODO, have this passed along */
char filename[FILE_MAX];
BKE_image_path_from_imtype(
- filename, this->m_path, bmain->name, this->m_rd->cfra, R_IMF_IMTYPE_OPENEXR,
+ filename, this->m_path, BKE_main_blendfile_path_from_global(), this->m_rd->cfra, R_IMF_IMTYPE_OPENEXR,
(this->m_rd->scemode & R_EXTENSION) != 0, true, NULL);
exrhandle = this->get_handle(filename);
@@ -190,11 +190,10 @@ void OutputOpenExrMultiLayerMultiViewOperation::deinitExecution()
if (width != 0 && height != 0) {
void *exrhandle;
- Main *bmain = G.main; /* TODO, have this passed along */
char filename[FILE_MAX];
BKE_image_path_from_imtype(
- filename, this->m_path, bmain->name, this->m_rd->cfra, R_IMF_IMTYPE_MULTILAYER,
+ filename, this->m_path, BKE_main_blendfile_path_from_global(), this->m_rd->cfra, R_IMF_IMTYPE_MULTILAYER,
(this->m_rd->scemode & R_EXTENSION) != 0, true, NULL);
exrhandle = this->get_handle(filename);
@@ -283,7 +282,6 @@ void OutputStereoOperation::deinitExecution()
if (BKE_scene_multiview_is_render_view_last(this->m_rd, this->m_viewName)) {
ImBuf *ibuf[3] = {NULL};
const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
- Main *bmain = G.main; /* TODO, have this passed along */
char filename[FILE_MAX];
int i;
@@ -307,7 +305,7 @@ void OutputStereoOperation::deinitExecution()
ibuf[2] = IMB_stereo3d_ImBuf(this->m_format, ibuf[0], ibuf[1]);
BKE_image_path_from_imformat(
- filename, this->m_path, bmain->name, this->m_rd->cfra, this->m_format,
+ filename, this->m_path, BKE_main_blendfile_path_from_global(), this->m_rd->cfra, this->m_format,
(this->m_rd->scemode & R_EXTENSION) != 0, true, NULL);
BKE_imbuf_write(ibuf[2], filename, this->m_format);
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
index fdf5a0b48cf..39877e35605 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Lukas Tönne
*/
@@ -28,6 +28,7 @@
#include "BLI_string.h"
#include "BKE_image.h"
#include "BKE_global.h"
+#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_scene.h"
@@ -185,7 +186,6 @@ void OutputSingleLayerOperation::deinitExecution()
int size = get_datatype_size(this->m_datatype);
ImBuf *ibuf = IMB_allocImBuf(this->getWidth(), this->getHeight(), this->m_format->planes, 0);
- Main *bmain = G.main; /* TODO, have this passed along */
char filename[FILE_MAX];
const char *suffix;
@@ -200,7 +200,7 @@ void OutputSingleLayerOperation::deinitExecution()
suffix = BKE_scene_multiview_view_suffix_get(this->m_rd, this->m_viewName);
BKE_image_path_from_imformat(
- filename, this->m_path, bmain->name, this->m_rd->cfra, this->m_format,
+ filename, this->m_path, BKE_main_blendfile_path_from_global(), this->m_rd->cfra, this->m_format,
(this->m_rd->scemode & R_EXTENSION) != 0, true, suffix);
if (0 == BKE_imbuf_write(ibuf, filename, this->m_format))
@@ -271,14 +271,13 @@ void OutputOpenExrMultiLayerOperation::deinitExecution()
unsigned int width = this->getWidth();
unsigned int height = this->getHeight();
if (width != 0 && height != 0) {
- Main *bmain = G.main; /* TODO, have this passed along */
char filename[FILE_MAX];
const char *suffix;
void *exrhandle = IMB_exr_get_handle();
suffix = BKE_scene_multiview_view_suffix_get(this->m_rd, this->m_viewName);
BKE_image_path_from_imtype(
- filename, this->m_path, bmain->name, this->m_rd->cfra, R_IMF_IMTYPE_MULTILAYER,
+ filename, this->m_path, BKE_main_blendfile_path_from_global(), this->m_rd->cfra, R_IMF_IMTYPE_MULTILAYER,
(this->m_rd->scemode & R_EXTENSION) != 0, true, suffix);
BLI_make_existing_file(filename);
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h
index 93468977a66..60862de48cb 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.h
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
* Lukas Tönne
*/
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp
index 2845b972f65..d4075844f0e 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.cpp
+++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h
index 5da7a25ac5d..ca1d6f54cdc 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.h
+++ b/source/blender/compositor/operations/COM_PreviewOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
index 02d1809efbb..020bdde8c93 100644
--- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
index fc9c760ed77..9eb90b6006b 100644
--- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_QualityStepHelper.cpp b/source/blender/compositor/operations/COM_QualityStepHelper.cpp
index 4d9c15f9747..a1d84e7d569 100644
--- a/source/blender/compositor/operations/COM_QualityStepHelper.cpp
+++ b/source/blender/compositor/operations/COM_QualityStepHelper.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_QualityStepHelper.h b/source/blender/compositor/operations/COM_QualityStepHelper.h
index 34e2ba1b47c..9076e5a0776 100644
--- a/source/blender/compositor/operations/COM_QualityStepHelper.h
+++ b/source/blender/compositor/operations/COM_QualityStepHelper.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
index 6dbe132257a..f256d3a6aa1 100644
--- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.h b/source/blender/compositor/operations/COM_ReadBufferOperation.h
index cd706ed0b75..898b568bb91 100644
--- a/source/blender/compositor/operations/COM_ReadBufferOperation.h
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
index a5e2d275e4f..ca135a650bd 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.h b/source/blender/compositor/operations/COM_RenderLayersProg.h
index 7cfead7e98c..90d57d422e3 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.h
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_RotateOperation.cpp b/source/blender/compositor/operations/COM_RotateOperation.cpp
index 6aca9fe22c4..2d0d5aaf8d3 100644
--- a/source/blender/compositor/operations/COM_RotateOperation.cpp
+++ b/source/blender/compositor/operations/COM_RotateOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_RotateOperation.h b/source/blender/compositor/operations/COM_RotateOperation.h
index 40acad1abe6..7b99b6faa97 100644
--- a/source/blender/compositor/operations/COM_RotateOperation.h
+++ b/source/blender/compositor/operations/COM_RotateOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h
index 17cd31f9710..93f9827aabf 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.h
+++ b/source/blender/compositor/operations/COM_ScaleOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
index e0e5e923654..651c336452e 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
index c35bbdef4d0..648a7a6e551 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
index efdc844704a..91933484027 100644
--- a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.h b/source/blender/compositor/operations/COM_SetAlphaOperation.h
index a0869ec90b2..12e3debf3d3 100644
--- a/source/blender/compositor/operations/COM_SetAlphaOperation.h
+++ b/source/blender/compositor/operations/COM_SetAlphaOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_SetColorOperation.h b/source/blender/compositor/operations/COM_SetColorOperation.h
index 7dfed6b570b..f9fa06f5132 100644
--- a/source/blender/compositor/operations/COM_SetColorOperation.h
+++ b/source/blender/compositor/operations/COM_SetColorOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
index 7057ecb14c1..e02fcad1574 100644
--- a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.h b/source/blender/compositor/operations/COM_SetSamplerOperation.h
index 145d82bd407..903bcef95f0 100644
--- a/source/blender/compositor/operations/COM_SetSamplerOperation.h
+++ b/source/blender/compositor/operations/COM_SetSamplerOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_SetValueOperation.cpp b/source/blender/compositor/operations/COM_SetValueOperation.cpp
index b6cfb760a98..5deb7fe672d 100644
--- a/source/blender/compositor/operations/COM_SetValueOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetValueOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_SetValueOperation.h b/source/blender/compositor/operations/COM_SetValueOperation.h
index 7cb914ffa48..10de8825d38 100644
--- a/source/blender/compositor/operations/COM_SetValueOperation.h
+++ b/source/blender/compositor/operations/COM_SetValueOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.cpp b/source/blender/compositor/operations/COM_SetVectorOperation.cpp
index 1b0327683a9..2e1045fc2e3 100644
--- a/source/blender/compositor/operations/COM_SetVectorOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetVectorOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.h b/source/blender/compositor/operations/COM_SetVectorOperation.h
index d29ca726056..b01f2f7a6b5 100644
--- a/source/blender/compositor/operations/COM_SetVectorOperation.h
+++ b/source/blender/compositor/operations/COM_SetVectorOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
index 21d2f28332e..0d813f7313f 100644
--- a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.h b/source/blender/compositor/operations/COM_SocketProxyOperation.h
index c9d6cb6ef9e..86c8b23b115 100644
--- a/source/blender/compositor/operations/COM_SocketProxyOperation.h
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_SplitOperation.cpp b/source/blender/compositor/operations/COM_SplitOperation.cpp
index cd2166591bc..49eff79ace9 100644
--- a/source/blender/compositor/operations/COM_SplitOperation.cpp
+++ b/source/blender/compositor/operations/COM_SplitOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_SplitOperation.h b/source/blender/compositor/operations/COM_SplitOperation.h
index 2853c845d03..4375c760963 100644
--- a/source/blender/compositor/operations/COM_SplitOperation.h
+++ b/source/blender/compositor/operations/COM_SplitOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
index 70e0b2cfb57..81b967bf530 100644
--- a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
+++ b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
@@ -50,7 +50,7 @@ void SunBeamsOperation::initExecution()
* For a target point (x,y) the sector should be chosen such that
* ``u >= v >= 0``
* This removes the need to handle all sorts of special cases.
- *
+ *
* Template parameters:
* fxu : buffer increment in x for sector u+1
* fxv : buffer increment in x for sector v+1
diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp
index d0c72935b16..78d5976c744 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.cpp
+++ b/source/blender/compositor/operations/COM_TextureOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h
index 59ff58a7289..a2fb7c7501f 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.h
+++ b/source/blender/compositor/operations/COM_TextureOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_TonemapOperation.cpp b/source/blender/compositor/operations/COM_TonemapOperation.cpp
index abef644bab8..ce9a5260fb6 100644
--- a/source/blender/compositor/operations/COM_TonemapOperation.cpp
+++ b/source/blender/compositor/operations/COM_TonemapOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_TonemapOperation.h b/source/blender/compositor/operations/COM_TonemapOperation.h
index 9b6858cdaf1..51ffaac8503 100644
--- a/source/blender/compositor/operations/COM_TonemapOperation.h
+++ b/source/blender/compositor/operations/COM_TonemapOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.h b/source/blender/compositor/operations/COM_TranslateOperation.h
index f2ae976e2ef..e30ba7ff2d7 100644
--- a/source/blender/compositor/operations/COM_TranslateOperation.h
+++ b/source/blender/compositor/operations/COM_TranslateOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
index 9ff0bf9ce12..e8dbff9b2d7 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
index cab38698296..110bb6b4952 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
index 9c04e74a7da..d14d745d049 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.h b/source/blender/compositor/operations/COM_VectorBlurOperation.h
index 4c6fca3cf83..05c2c3183c1 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.h
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
index dfdc54012a8..3cd9a6f21ca 100644
--- a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.h b/source/blender/compositor/operations/COM_VectorCurveOperation.h
index 677af77b05e..444f848cb0a 100644
--- a/source/blender/compositor/operations/COM_VectorCurveOperation.h
+++ b/source/blender/compositor/operations/COM_VectorCurveOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp
index 42fe24120dc..0eff52f4d9a 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h
index 107aee3a82f..e5eed3e8024 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.h
+++ b/source/blender/compositor/operations/COM_ViewerOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_WrapOperation.h b/source/blender/compositor/operations/COM_WrapOperation.h
index 92c93565691..4a17b29ede8 100644
--- a/source/blender/compositor/operations/COM_WrapOperation.h
+++ b/source/blender/compositor/operations/COM_WrapOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
index b3c1c00804e..85602e6741c 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h
index 9220cb179c6..afcdc70889b 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.h
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.cpp b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
index 6cb88919b1b..8b99d5872fe 100644
--- a/source/blender/compositor/operations/COM_ZCombineOperation.cpp
+++ b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.h b/source/blender/compositor/operations/COM_ZCombineOperation.h
index 199120fa3be..a89a2c7bd62 100644
--- a/source/blender/compositor/operations/COM_ZCombineOperation.h
+++ b/source/blender/compositor/operations/COM_ZCombineOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
diff --git a/source/blender/datatoc/CMakeLists.txt b/source/blender/datatoc/CMakeLists.txt
index af7f954cad1..0c68cdeb8e9 100644
--- a/source/blender/datatoc/CMakeLists.txt
+++ b/source/blender/datatoc/CMakeLists.txt
@@ -37,7 +37,7 @@ if(NOT WITH_HEADLESS)
set(SRC
datatoc_icon.c
)
-
+ setup_platform_linker_flags()
if(WIN32)
include_directories(
../blenlib
@@ -52,8 +52,6 @@ if(NOT WITH_HEADLESS)
../../../intern/utfconv/utfconv.c
)
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}")
- set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
endif()
include_directories(${PNG_INCLUDE_DIRS})
diff --git a/source/blender/datatoc/datatoc_icon.c b/source/blender/datatoc/datatoc_icon.c
index 92048f32a28..e5f82ae09c8 100644
--- a/source/blender/datatoc/datatoc_icon.c
+++ b/source/blender/datatoc/datatoc_icon.c
@@ -386,7 +386,7 @@ int main(int argc, char **argv)
{
const char *path_src;
const char *file_dst;
-
+
if (argc < 3) {
printf("Usage: datatoc_icon <dir_icons> <data_icon_to.png>\n");
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index 589df5df878..0174b002292 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -42,9 +42,9 @@
* Evaluation Engine
* =================
*
- * The evaluation takes the operation-nodes the Depsgraph has tagged for updating,
+ * The evaluation takes the operation-nodes the Depsgraph has tagged for updating,
* and schedules them up for being evaluated/executed such that the all dependency
- * relationship constraints are satisfied.
+ * relationship constraints are satisfied.
*/
/* ************************************************* */
@@ -70,8 +70,7 @@ struct ViewLayer;
typedef enum eEvaluationMode {
DAG_EVAL_VIEWPORT = 0, /* evaluate for OpenGL viewport */
- DAG_EVAL_PREVIEW = 1, /* evaluate for render with preview settings */
- DAG_EVAL_RENDER = 2, /* evaluate for render purposes */
+ DAG_EVAL_RENDER = 1, /* evaluate for render purposes */
} eEvaluationMode;
/* DagNode->eval_flags */
@@ -91,9 +90,6 @@ enum {
extern "C" {
#endif
-bool DEG_depsgraph_use_copy_on_write(void);
-void DEG_depsgraph_disable_copy_on_write(void);
-
/* ************************************************ */
/* Depsgraph API */
@@ -173,7 +169,7 @@ void DEG_graph_id_tag_update(struct Main *bmain,
*/
void DEG_id_type_tag(struct Main *bmain, short id_type);
-void DEG_ids_clear_recalc(struct Main *bmain);
+void DEG_ids_clear_recalc(struct Main *bmain, Depsgraph *depsgraph);
/* Update Flushing ------------------------------- */
@@ -232,6 +228,12 @@ typedef void (*DEG_EditorUpdateSceneCb)(
void DEG_editors_set_update_cb(DEG_EditorUpdateIDCb id_func,
DEG_EditorUpdateSceneCb scene_func);
+/* Evaluation ----------------------------------- */
+
+bool DEG_is_active(const struct Depsgraph *depsgraph);
+void DEG_make_active(struct Depsgraph *depsgraph);
+void DEG_make_inactive(struct Depsgraph *depsgraph);
+
/* Evaluation Debug ------------------------------ */
void DEG_debug_print_begin(struct Depsgraph *depsgraph);
diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h
index 99c5d2dc291..1c4e11d1197 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -66,7 +66,8 @@ float DEG_get_ctime(const Depsgraph *graph);
/* ********************* DEG evaluated data ******************* */
/* Check if given ID type was tagged for update. */
-bool DEG_id_type_tagged(struct Main *bmain, short id_type);
+bool DEG_id_type_updated(const struct Depsgraph *depsgraph, short id_type);
+bool DEG_id_type_any_updated(const struct Depsgraph *depsgraph);
/* Get additional evaluation flags for the given ID. */
short DEG_get_eval_flags_for_id(const struct Depsgraph *graph, struct ID *id);
@@ -96,7 +97,7 @@ struct Object *DEG_get_original_object(struct Object *object);
/* Get original version of given evaluated ID datablock. */
struct ID *DEG_get_original_id(struct ID *id);
-/* ************************ DEG iterators ********************* */
+/* ************************ DEG object iterators ********************* */
enum {
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY = (1 << 0),
@@ -106,14 +107,8 @@ enum {
DEG_ITER_OBJECT_FLAG_DUPLI = (1 << 4),
};
-typedef enum eDepsObjectIteratorMode {
- DEG_ITER_OBJECT_MODE_VIEWPORT = 0,
- DEG_ITER_OBJECT_MODE_RENDER = 1,
-} eDepsObjectIteratorMode;
-
typedef struct DEGObjectIterData {
struct Depsgraph *graph;
- eDepsObjectIteratorMode mode;
int flag;
struct Scene *scene;
@@ -151,11 +146,10 @@ void DEG_iterator_objects_end(struct BLI_Iterator *iter);
* Although they are available they have no overrides (collection_properties)
* and will crash if you try to access it.
*/
-#define DEG_OBJECT_ITER_BEGIN(graph_, instance_, mode_, flag_) \
+#define DEG_OBJECT_ITER_BEGIN(graph_, instance_, flag_) \
{ \
DEGObjectIterData data_ = { \
graph_, \
- mode_, \
flag_ \
}; \
\
@@ -171,8 +165,8 @@ void DEG_iterator_objects_end(struct BLI_Iterator *iter);
/**
* Depsgraph objects iterator for draw manager and final render
*/
-#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(graph_, instance_, mode_) \
- DEG_OBJECT_ITER_BEGIN(graph_, instance_, mode_, \
+#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(graph_, instance_) \
+ DEG_OBJECT_ITER_BEGIN(graph_, instance_, \
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | \
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | \
DEG_ITER_OBJECT_FLAG_VISIBLE | \
@@ -181,6 +175,21 @@ void DEG_iterator_objects_end(struct BLI_Iterator *iter);
#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END \
DEG_OBJECT_ITER_END
+
+/* ************************ DEG ID iterators ********************* */
+
+typedef struct DEGIDIterData {
+ struct Depsgraph *graph;
+ bool only_updated;
+
+ size_t id_node_index;
+ size_t num_id_nodes;
+} DEGIDIterData;
+
+void DEG_iterator_ids_begin(struct BLI_Iterator *iter, DEGIDIterData *data);
+void DEG_iterator_ids_next(struct BLI_Iterator *iter);
+void DEG_iterator_ids_end(struct BLI_Iterator *iter);
+
/* ************************ DEG traversal ********************* */
typedef void (*DEGForeachIDCallback)(ID *id, void *user_data);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc
index 2fcad233044..f1f3da85968 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -35,6 +35,7 @@
#include "intern/depsgraph.h"
#include "intern/depsgraph_types.h"
+#include "intern/eval/deg_eval_copy_on_write.h"
#include "intern/nodes/deg_node.h"
#include "intern/nodes/deg_node_id.h"
@@ -46,7 +47,6 @@ namespace DEG {
void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)
{
- const bool use_copy_on_write = DEG_depsgraph_use_copy_on_write();
/* Re-tag IDs for update if it was tagged before the relations
* update tag.
*/
@@ -54,12 +54,9 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)
ID *id = id_node->id_orig;
id_node->finalize_build(graph);
if ((id->recalc & ID_RECALC_ALL)) {
- id_node->tag_update(graph);
+ DEG_id_tag_update_ex(bmain, id_node->id_orig, 0);
}
- /* TODO(sergey): This is not ideal at all, since this forces
- * re-evaluaiton of the whole tree.
- */
- if (use_copy_on_write) {
+ if (!deg_copy_on_write_is_expanded(id_node->id_cow)) {
DEG_id_tag_update_ex(bmain, id_node->id_orig, DEG_TAG_COPY_ON_WRITE);
}
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
index 026aa309b02..feaba1a4aa8 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
@@ -68,7 +68,9 @@ struct CyclesSolverState {
: graph(graph),
traversal_stack(BLI_stack_new(sizeof(StackEntry),
"DEG detect cycles stack")),
- num_cycles(0) {
+ num_cycles(0)
+ {
+ /* pass */
}
~CyclesSolverState() {
BLI_stack_free(traversal_stack);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 98881ba3e57..d67f702ba85 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -150,9 +150,6 @@ DepsgraphNodeBuilder::~DepsgraphNodeBuilder()
IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id)
{
- if (!DEG_depsgraph_use_copy_on_write()) {
- return graph_->add_id_node(id);
- }
IDDepsNode *id_node = NULL;
ID *id_cow = (ID *)BLI_ghash_lookup(cow_id_hash_, id);
if (id_cow != NULL) {
@@ -314,7 +311,7 @@ ID *DepsgraphNodeBuilder::get_cow_id(const ID *id_orig) const
ID *DepsgraphNodeBuilder::ensure_cow_id(ID *id_orig)
{
- if (id_orig->tag & LIB_TAG_COPY_ON_WRITE) {
+ if (id_orig->tag & LIB_TAG_COPIED_ON_WRITE) {
/* ID is already remapped to copy-on-write. */
return id_orig;
}
@@ -324,22 +321,21 @@ ID *DepsgraphNodeBuilder::ensure_cow_id(ID *id_orig)
/* **** Build functions for entity nodes **** */
-void DepsgraphNodeBuilder::begin_build() {
- if (DEG_depsgraph_use_copy_on_write()) {
- /* Store existing copy-on-write versions of datablock, so we can re-use
- * them for new ID nodes.
- */
- cow_id_hash_ = BLI_ghash_ptr_new("Depsgraph id hash");
- foreach (IDDepsNode *id_node, graph_->id_nodes) {
- if (deg_copy_on_write_is_expanded(id_node->id_cow)) {
- if (id_node->id_orig == id_node->id_cow) {
- continue;
- }
- BLI_ghash_insert(cow_id_hash_,
- id_node->id_orig,
- id_node->id_cow);
- id_node->id_cow = NULL;
+void DepsgraphNodeBuilder::begin_build()
+{
+ /* Store existing copy-on-write versions of datablock, so we can re-use
+ * them for new ID nodes.
+ */
+ cow_id_hash_ = BLI_ghash_ptr_new("Depsgraph id hash");
+ foreach (IDDepsNode *id_node, graph_->id_nodes) {
+ if (deg_copy_on_write_is_expanded(id_node->id_cow)) {
+ if (id_node->id_orig == id_node->id_cow) {
+ continue;
}
+ BLI_ghash_insert(cow_id_hash_,
+ id_node->id_orig,
+ id_node->id_cow);
+ id_node->id_cow = NULL;
}
}
@@ -382,17 +378,32 @@ void DepsgraphNodeBuilder::end_build()
}
}
-void DepsgraphNodeBuilder::build_id(ID* id) {
+void DepsgraphNodeBuilder::build_id(ID *id) {
if (id == NULL) {
return;
}
switch (GS(id->name)) {
+ case ID_AR:
+ build_armature((bArmature *)id);
+ break;
+ case ID_CA:
+ build_camera((Camera *)id);
+ break;
case ID_GR:
- build_collection((Collection *)id);
+ build_collection(DEG_COLLECTION_OWNER_UNKNOWN, (Collection *)id);
break;
case ID_OB:
build_object(-1, (Object *)id, DEG_ID_LINKED_INDIRECTLY);
break;
+ case ID_KE:
+ build_shapekeys((Key *)id);
+ break;
+ case ID_LA:
+ build_lamp((Lamp *)id);
+ break;
+ case ID_LP:
+ build_lightprobe((LightProbe *)id);
+ break;
case ID_NT:
build_nodetree((bNodeTree *)id);
break;
@@ -414,26 +425,45 @@ void DepsgraphNodeBuilder::build_id(ID* id) {
case ID_MC:
build_movieclip((MovieClip *)id);
break;
+ case ID_ME:
+ case ID_CU:
+ case ID_MB:
+ case ID_LT:
+ build_object_data_geometry_datablock(id);
+ break;
default:
fprintf(stderr, "Unhandled ID %s\n", id->name);
+ BLI_assert(!"Should never happen");
+ break;
}
}
-void DepsgraphNodeBuilder::build_collection(Collection *collection)
+void DepsgraphNodeBuilder::build_collection(
+ eDepsNode_CollectionOwner owner_type,
+ Collection *collection)
{
if (built_map_.checkIsBuiltAndTag(collection)) {
return;
}
+ const bool allow_restrict_flags = (owner_type == DEG_COLLECTION_OWNER_SCENE);
+ if (allow_restrict_flags) {
+ const int restrict_flag = (graph_->mode == DAG_EVAL_VIEWPORT)
+ ? COLLECTION_RESTRICT_VIEW
+ : COLLECTION_RESTRICT_RENDER;
+ if (collection->flag & restrict_flag) {
+ return;
+ }
+ }
+ /* Collection itself. */
+ add_id_node(&collection->id);
/* Build collection objects. */
LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
build_object(-1, cob->ob, DEG_ID_LINKED_INDIRECTLY);
}
/* Build child collections. */
LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
- build_collection(child->collection);
+ build_collection(owner_type, child->collection);
}
-
- add_id_node(&collection->id);
}
void DepsgraphNodeBuilder::build_object(int base_index,
@@ -499,14 +529,13 @@ void DepsgraphNodeBuilder::build_object(int base_index,
if (object->gpd != NULL) {
build_gpencil(object->gpd);
}
- /* Object that this is a proxy for. */
- if (object->proxy) {
- object->proxy->proxy_from = object;
- build_object(-1, object->proxy, DEG_ID_LINKED_INDIRECTLY);
+ /* Proxy object to copy from. */
+ if (object->proxy_from) {
+ build_object(-1, object->proxy_from, DEG_ID_LINKED_INDIRECTLY);
}
/* Object dupligroup. */
if (object->dup_group != NULL) {
- build_collection(object->dup_group);
+ build_collection(DEG_COLLECTION_OWNER_OBJECT, object->dup_group);
}
}
@@ -547,7 +576,7 @@ void DepsgraphNodeBuilder::build_object_data(Object *object)
case OB_SURF:
case OB_MBALL:
case OB_LATTICE:
- build_obdata_geom(object);
+ build_object_data_geometry(object);
/* TODO(sergey): Only for until we support granular
* update of curves.
*/
@@ -567,13 +596,13 @@ void DepsgraphNodeBuilder::build_object_data(Object *object)
}
break;
case OB_LAMP:
- build_lamp(object);
+ build_object_data_lamp(object);
break;
case OB_CAMERA:
- build_camera(object);
+ build_object_data_camera(object);
break;
case OB_LIGHTPROBE:
- build_lightprobe(object);
+ build_object_data_lightprobe(object);
break;
default:
{
@@ -586,6 +615,28 @@ void DepsgraphNodeBuilder::build_object_data(Object *object)
}
}
+void DepsgraphNodeBuilder::build_object_data_camera(Object *object)
+{
+ Camera *camera = (Camera *)object->data;
+ build_camera(camera);
+}
+
+void DepsgraphNodeBuilder::build_object_data_lamp(Object *object)
+{
+ Lamp *lamp = (Lamp *)object->data;
+ build_lamp(lamp);
+}
+
+void DepsgraphNodeBuilder::build_object_data_lightprobe(Object *object)
+{
+ LightProbe *probe = (LightProbe *)object->data;
+ build_lightprobe(probe);
+ add_operation_node(&object->id,
+ DEG_NODE_TYPE_PARAMETERS,
+ NULL,
+ DEG_OPCODE_LIGHT_PROBE_EVAL);
+}
+
void DepsgraphNodeBuilder::build_object_transform(Object *object)
{
OperationDepsNode *op_node;
@@ -704,9 +755,10 @@ void DepsgraphNodeBuilder::build_animdata(ID *id)
}
/* drivers */
+ int driver_index = 0;
LISTBASE_FOREACH (FCurve *, fcu, &adt->drivers) {
/* create driver */
- build_driver(id, fcu);
+ build_driver(id, fcu, driver_index++);
}
}
}
@@ -715,16 +767,21 @@ void DepsgraphNodeBuilder::build_animdata(ID *id)
* Build graph node(s) for Driver
* \param id: ID-Block that driver is attached to
* \param fcu: Driver-FCurve
+ * \param driver_index: Index in animation data drivers list
*/
-void DepsgraphNodeBuilder::build_driver(ID *id, FCurve *fcurve)
+void DepsgraphNodeBuilder::build_driver(ID *id, FCurve *fcurve, int driver_index)
{
+ /* Create data node for this driver */
ID *id_cow = get_cow_id(id);
+ ChannelDriver *driver_orig = fcurve->driver;
- /* Create data node for this driver */
- /* TODO(sergey): Shall we use COW of fcu itself here? */
+ /* TODO(sergey): ideally we could pass the COW of fcu, but since it
+ * has not yet been allocated at this point we can't. As a workaround
+ * the animation systems allocates an array so we can do a fast lookup
+ * with the driver index. */
ensure_operation_node(id,
DEG_NODE_TYPE_PARAMETERS,
- function_bind(BKE_animsys_eval_driver, _1, id_cow, fcurve),
+ function_bind(BKE_animsys_eval_driver, _1, id_cow, driver_index, driver_orig),
DEG_OPCODE_DRIVER,
fcurve->rna_path ? fcurve->rna_path : "",
fcurve->array_index);
@@ -915,7 +972,7 @@ void DepsgraphNodeBuilder::build_particles(Object *object)
break;
case PART_DRAW_GR:
if (part->dup_group != NULL) {
- build_collection(part->dup_group);
+ build_collection(DEG_COLLECTION_OWNER_OBJECT, part->dup_group);
}
break;
}
@@ -960,6 +1017,9 @@ void DepsgraphNodeBuilder::build_cloth(Object *object)
/* Shapekeys */
void DepsgraphNodeBuilder::build_shapekeys(Key *key)
{
+ if (built_map_.checkIsBuiltAndTag(key)) {
+ return;
+ }
build_animdata(&key->id);
add_operation_node(&key->id,
DEG_NODE_TYPE_GEOMETRY,
@@ -969,12 +1029,11 @@ void DepsgraphNodeBuilder::build_shapekeys(Key *key)
/* ObData Geometry Evaluation */
// XXX: what happens if the datablock is shared!
-void DepsgraphNodeBuilder::build_obdata_geom(Object *object)
+void DepsgraphNodeBuilder::build_object_data_geometry(Object *object)
{
OperationDepsNode *op_node;
Scene *scene_cow = get_cow_datablock(scene_);
Object *object_cow = get_cow_datablock(object);
-
/* Temporary uber-update node, which does everything.
* It is for the being we're porting old dependencies into the new system.
* We'll get rid of this node as soon as all the granular update functions
@@ -997,17 +1056,14 @@ void DepsgraphNodeBuilder::build_obdata_geom(Object *object)
DEG_OPCODE_PLACEHOLDER,
"Eval Init");
op_node->set_as_entry();
-
// TODO: "Done" operation
-
/* Cloth modifier. */
LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
if (md->type == eModifierType_Cloth) {
build_cloth(object);
}
}
-
- /* materials */
+ /* Materials. */
if (object->totcol != 0) {
if (object->type == OB_MESH) {
add_operation_node(&object->id,
@@ -1025,37 +1081,36 @@ void DepsgraphNodeBuilder::build_obdata_geom(Object *object)
}
}
}
-
- /* geometry collision */
+ /* Geometry collision. */
if (ELEM(object->type, OB_MESH, OB_CURVE, OB_LATTICE)) {
// add geometry collider relations
}
+ build_object_data_geometry_datablock((ID *)object->data);
+}
- ID *obdata = (ID *)object->data;
+void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata)
+{
if (built_map_.checkIsBuiltAndTag(obdata)) {
return;
}
+ OperationDepsNode *op_node;
/* Make sure we've got an ID node before requesting CoW pointer. */
(void) add_id_node((ID *)obdata);
ID *obdata_cow = get_cow_id(obdata);
-
+ /* Animation. */
+ build_animdata(obdata);
/* ShapeKeys */
- Key *key = BKE_key_from_object(object);
+ Key *key = BKE_key_from_id(obdata);
if (key) {
build_shapekeys(key);
}
-
- build_animdata(obdata);
-
/* Nodes for result of obdata's evaluation, and geometry
* evaluation on object.
*/
- switch (object->type) {
- case OB_MESH:
+ const ID_Type id_type = GS(obdata->name);
+ switch (id_type) {
+ case ID_ME:
{
- //Mesh *me = (Mesh *)object->data;
-
- /* evaluation operations */
op_node = add_operation_node(obdata,
DEG_NODE_TYPE_GEOMETRY,
function_bind(BKE_mesh_eval_geometry,
@@ -1066,41 +1121,18 @@ void DepsgraphNodeBuilder::build_obdata_geom(Object *object)
op_node->set_as_entry();
break;
}
-
- case OB_MBALL:
+ case ID_MB:
{
- Object *mom = BKE_mball_basis_find(scene_, object);
- /* NOTE: Only the motherball gets evaluated, it's children are
- * having empty placeholders for the correct relations being built.
- */
- if (mom == object) {
- /* metaball evaluation operations */
- op_node = add_operation_node(obdata,
- DEG_NODE_TYPE_GEOMETRY,
- function_bind(
- BKE_mball_eval_geometry,
- _1,
- (MetaBall *)obdata_cow),
- DEG_OPCODE_PLACEHOLDER,
- "Geometry Eval");
- }
- else {
- op_node = add_operation_node(obdata,
- DEG_NODE_TYPE_GEOMETRY,
- NULL,
- DEG_OPCODE_PLACEHOLDER,
- "Geometry Eval");
- op_node->set_as_entry();
- }
+ op_node = add_operation_node(obdata,
+ DEG_NODE_TYPE_GEOMETRY,
+ NULL,
+ DEG_OPCODE_PLACEHOLDER,
+ "Geometry Eval");
+ op_node->set_as_entry();
break;
}
-
- case OB_CURVE:
- case OB_SURF:
- case OB_FONT:
+ case ID_CU:
{
- /* Curve/nurms evaluation operations. */
- /* - calculate curve geometry (including path) */
op_node = add_operation_node(obdata,
DEG_NODE_TYPE_GEOMETRY,
function_bind(BKE_curve_eval_geometry,
@@ -1119,15 +1151,13 @@ void DepsgraphNodeBuilder::build_obdata_geom(Object *object)
if (cu->taperobj != NULL) {
build_object(-1, cu->taperobj, DEG_ID_LINKED_INDIRECTLY);
}
- if (object->type == OB_FONT && cu->textoncurve != NULL) {
+ if (cu->textoncurve != NULL) {
build_object(-1, cu->textoncurve, DEG_ID_LINKED_INDIRECTLY);
}
break;
}
-
- case OB_LATTICE:
+ case ID_LT:
{
- /* Lattice evaluation operations. */
op_node = add_operation_node(obdata,
DEG_NODE_TYPE_GEOMETRY,
function_bind(BKE_lattice_eval_geometry,
@@ -1138,18 +1168,18 @@ void DepsgraphNodeBuilder::build_obdata_geom(Object *object)
op_node->set_as_entry();
break;
}
+ default:
+ BLI_assert(!"Should not happen");
+ break;
}
-
op_node = add_operation_node(obdata, DEG_NODE_TYPE_GEOMETRY, NULL,
DEG_OPCODE_PLACEHOLDER, "Eval Done");
op_node->set_as_exit();
-
/* Parameters for driver sources. */
add_operation_node(obdata,
DEG_NODE_TYPE_PARAMETERS,
NULL,
DEG_OPCODE_PARAMETERS_EVAL);
-
/* Batch cache. */
add_operation_node(obdata,
DEG_NODE_TYPE_BATCH_CACHE,
@@ -1159,35 +1189,46 @@ void DepsgraphNodeBuilder::build_obdata_geom(Object *object)
DEG_OPCODE_GEOMETRY_SELECT_UPDATE);
}
-/* Cameras */
-void DepsgraphNodeBuilder::build_camera(Object *object)
+void DepsgraphNodeBuilder::build_armature(bArmature *armature)
{
- /* Object data. */
- /* TODO: Link scene-camera links in somehow... */
- Camera *camera = (Camera *)object->data;
- if (built_map_.checkIsBuiltAndTag(camera)) {
+ if (built_map_.checkIsBuiltAndTag(armature)) {
return;
}
- build_animdata(&camera->id);
- add_operation_node(&camera->id,
+ build_animdata(&armature->id);
+ /* Make sure pose is up-to-date with armature updates. */
+ add_operation_node(&armature->id,
DEG_NODE_TYPE_PARAMETERS,
NULL,
- DEG_OPCODE_PARAMETERS_EVAL);
+ DEG_OPCODE_PLACEHOLDER,
+ "Armature Eval");
}
-/* Lamps */
-void DepsgraphNodeBuilder::build_lamp(Object *object)
+void DepsgraphNodeBuilder::build_camera(Camera *camera)
+{
+ if (built_map_.checkIsBuiltAndTag(camera)) {
+ return;
+ }
+ OperationDepsNode *op_node;
+ build_animdata(&camera->id);
+ op_node = add_operation_node(&camera->id,
+ DEG_NODE_TYPE_PARAMETERS,
+ NULL,
+ DEG_OPCODE_PARAMETERS_EVAL);
+ op_node->set_as_exit();
+}
+
+void DepsgraphNodeBuilder::build_lamp(Lamp *lamp)
{
- /* Object data. */
- Lamp *lamp = (Lamp *)object->data;
if (built_map_.checkIsBuiltAndTag(lamp)) {
return;
}
+ OperationDepsNode *op_node;
build_animdata(&lamp->id);
- add_operation_node(&lamp->id,
- DEG_NODE_TYPE_PARAMETERS,
- NULL,
- DEG_OPCODE_PARAMETERS_EVAL);
+ op_node = add_operation_node(&lamp->id,
+ DEG_NODE_TYPE_PARAMETERS,
+ NULL,
+ DEG_OPCODE_PARAMETERS_EVAL);
+ op_node->set_as_exit();
/* lamp's nodetree */
build_nodetree(lamp->nodetree);
}
@@ -1397,9 +1438,8 @@ void DepsgraphNodeBuilder::build_movieclip(MovieClip *clip)
DEG_OPCODE_MOVIECLIP_EVAL);
}
-void DepsgraphNodeBuilder::build_lightprobe(Object *object)
+void DepsgraphNodeBuilder::build_lightprobe(LightProbe *probe)
{
- LightProbe *probe = (LightProbe *)object->data;
if (built_map_.checkIsBuiltAndTag(probe)) {
return;
}
@@ -1407,13 +1447,7 @@ void DepsgraphNodeBuilder::build_lightprobe(Object *object)
add_operation_node(&probe->id,
DEG_NODE_TYPE_PARAMETERS,
NULL,
- DEG_OPCODE_PLACEHOLDER,
- "LightProbe Eval");
- add_operation_node(&object->id,
- DEG_NODE_TYPE_PARAMETERS,
- NULL,
- DEG_OPCODE_PLACEHOLDER,
- "LightProbe Eval");
+ DEG_OPCODE_LIGHT_PROBE_EVAL);
build_animdata(&probe->id);
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index 488f4f273b9..72aa5dbe003 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -33,10 +33,12 @@
#include "intern/builder/deg_builder_map.h"
#include "intern/depsgraph_types.h"
-#include "DEG_depsgraph.h" /* used for DEG_depsgraph_use_copy_on_write() */
+#include "DEG_depsgraph.h"
struct Base;
+struct bArmature;
struct CacheFile;
+struct Camera;
struct bGPdata;
struct ListBase;
struct GHash;
@@ -45,7 +47,9 @@ struct Image;
struct FCurve;
struct Collection;
struct Key;
+struct Lamp;
struct LayerCollection;
+struct LightProbe;
struct Main;
struct Material;
struct Mask;
@@ -92,12 +96,7 @@ struct DepsgraphNodeBuilder {
/* For a given COW datablock get corresponding original one. */
template<typename T>
T *get_orig_datablock(const T *cow) const {
- if (DEG_depsgraph_use_copy_on_write()) {
- return (T *)cow->id.orig_id;
- }
- else {
- return (T *)cow;
- }
+ return (T *)cow->id.orig_id;
}
void begin_build();
@@ -160,9 +159,10 @@ struct DepsgraphNodeBuilder {
void build_id(ID* id);
void build_layer_collections(ListBase *lb);
void build_view_layer(Scene *scene,
- ViewLayer *view_layer,
- eDepsNode_LinkedState_Type linked_state);
- void build_collection(Collection *collection);
+ ViewLayer *view_layer,
+ eDepsNode_LinkedState_Type linked_state);
+ void build_collection(eDepsNode_CollectionOwner owner_type,
+ Collection *collection);
void build_object(int base_index,
Object *object,
eDepsNode_LinkedState_Type linked_state);
@@ -170,6 +170,11 @@ struct DepsgraphNodeBuilder {
Object *object,
eDepsNode_LinkedState_Type linked_state);
void build_object_data(Object *object);
+ void build_object_data_camera(Object *object);
+ void build_object_data_geometry(Object *object);
+ void build_object_data_geometry_datablock(ID *obdata);
+ void build_object_data_lamp(Object *object);
+ void build_object_data_lightprobe(Object *object);
void build_object_transform(Object *object);
void build_object_constraints(Object *object);
void build_pose_constraints(Object *object, bPoseChannel *pchan, int pchan_index);
@@ -178,7 +183,7 @@ struct DepsgraphNodeBuilder {
void build_particle_settings(ParticleSettings *part);
void build_cloth(Object *object);
void build_animdata(ID *id);
- void build_driver(ID *id, FCurve *fcurve);
+ void build_driver(ID *id, FCurve *fcurve, int driver_index);
void build_driver_variables(ID *id, FCurve *fcurve);
void build_driver_id_property(ID *id, const char *rna_path);
void build_ik_pose(Object *object,
@@ -189,10 +194,10 @@ struct DepsgraphNodeBuilder {
bConstraint *con);
void build_rig(Object *object);
void build_proxy_rig(Object *object);
+ void build_armature(bArmature *armature);
void build_shapekeys(Key *key);
- void build_obdata_geom(Object *object);
- void build_camera(Object *object);
- void build_lamp(Object *object);
+ void build_camera(Camera *camera);
+ void build_lamp(Lamp *lamp);
void build_nodetree(bNodeTree *ntree);
void build_material(Material *ma);
void build_texture(Tex *tex);
@@ -203,7 +208,7 @@ struct DepsgraphNodeBuilder {
void build_cachefile(CacheFile *cache_file);
void build_mask(Mask *mask);
void build_movieclip(MovieClip *clip);
- void build_lightprobe(Object *object);
+ void build_lightprobe(LightProbe *probe);
protected:
struct SavedEntryTag {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
index c48381481f5..00d7a5da455 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
@@ -145,18 +145,9 @@ void DepsgraphNodeBuilder::build_splineik_pose(Object *object,
void DepsgraphNodeBuilder::build_rig(Object *object)
{
bArmature *armature = (bArmature *)object->data;
- Scene *scene_cow;
- Object *object_cow;
- if (DEG_depsgraph_use_copy_on_write()) {
- scene_cow = get_cow_datablock(scene_);
- object_cow = get_cow_datablock(object);
- }
- else {
- scene_cow = scene_;
- object_cow = object;
- }
+ Scene *scene_cow = get_cow_datablock(scene_);
+ Object *object_cow = get_cow_datablock(object);
OperationDepsNode *op_node;
-
/* Animation and/or drivers linking posebones to base-armature used to
* define them.
*
@@ -166,16 +157,8 @@ void DepsgraphNodeBuilder::build_rig(Object *object)
* mechanism in-between here to ensure that we can use same rig
* multiple times in same scene.
*/
- if (!built_map_.checkIsBuiltAndTag(armature)) {
- build_animdata(&armature->id);
- /* Make sure pose is up-to-date with armature updates. */
- add_operation_node(&armature->id,
- DEG_NODE_TYPE_PARAMETERS,
- NULL,
- DEG_OPCODE_PLACEHOLDER,
- "Armature Eval");
- }
-
+ /* Armature. */
+ build_armature(armature);
/* Rebuild pose if not up to date. */
if (object->pose == NULL || (object->pose->flag & POSE_RECALC)) {
BKE_pose_rebuild(object, armature);
@@ -187,15 +170,13 @@ void DepsgraphNodeBuilder::build_rig(Object *object)
object->adt->recalc |= ADT_RECALC_ANIM;
}
}
-
- /* speed optimization for animation lookups */
+ /* Speed optimization for animation lookups. */
if (object->pose != NULL) {
BKE_pose_channels_hash_make(object->pose);
if (object->pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) {
BKE_pose_update_constraint_flags(object->pose);
}
}
-
/**
* Pose Rig Graph
* ==============
@@ -217,8 +198,7 @@ void DepsgraphNodeBuilder::build_rig(Object *object)
* only so that we can redirect those to point at either the the post-IK/
* post-constraint/post-matrix steps, as needed.
*/
-
- /* pose eval context */
+ /* Pose eval context. */
op_node = add_operation_node(&object->id,
DEG_NODE_TYPE_EVAL_POSE,
function_bind(BKE_pose_eval_init,
@@ -244,8 +224,7 @@ void DepsgraphNodeBuilder::build_rig(Object *object)
object_cow),
DEG_OPCODE_POSE_DONE);
op_node->set_as_exit();
-
- /* bones */
+ /* Bones. */
int pchan_index = 0;
LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) {
/* Node for bone evaluation. */
@@ -310,31 +289,23 @@ void DepsgraphNodeBuilder::build_rig(Object *object)
break;
}
}
-
/* Custom shape. */
if (pchan->custom != NULL) {
build_object(-1, pchan->custom, DEG_ID_LINKED_INDIRECTLY);
}
-
pchan_index++;
}
}
void DepsgraphNodeBuilder::build_proxy_rig(Object *object)
{
- bArmature *arm = (bArmature *)object->data;
+ bArmature *armature = (bArmature *)object->data;
OperationDepsNode *op_node;
- Object *object_cow;
- if (DEG_depsgraph_use_copy_on_write()) {
- object_cow = get_cow_datablock(object);
- }
- else {
- object_cow = object;
- }
+ Object *object_cow = get_cow_datablock(object);
/* Sanity check. */
BLI_assert(object->pose != NULL);
- /* Animation. */
- build_animdata(&arm->id);
+ /* Armature. */
+ build_armature(armature);
/* speed optimization for animation lookups */
BKE_pose_channels_hash_make(object->pose);
if (object->pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
index a396aecd3a8..e2526272570 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
@@ -67,8 +67,16 @@ namespace DEG {
void DepsgraphNodeBuilder::build_layer_collections(ListBase *lb)
{
+ const int restrict_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ?
+ COLLECTION_RESTRICT_VIEW : COLLECTION_RESTRICT_RENDER;
+
for (LayerCollection *lc = (LayerCollection *)lb->first; lc; lc = lc->next) {
- build_collection(lc->collection);
+ if (lc->collection->flag & restrict_flag) {
+ continue;
+ }
+ if ((lc->flag & LAYER_COLLECTION_EXCLUDE) == 0) {
+ build_collection(DEG_COLLECTION_OWNER_SCENE, lc->collection);
+ }
build_layer_collections(&lc->layer_collections);
}
}
@@ -88,13 +96,7 @@ void DepsgraphNodeBuilder::build_view_layer(
scene_ = scene;
view_layer_ = view_layer;
/* Get pointer to a CoW version of scene ID. */
- Scene *scene_cow;
- if (DEG_depsgraph_use_copy_on_write()) {
- scene_cow = get_cow_datablock(scene);
- }
- else {
- scene_cow = scene;
- }
+ Scene *scene_cow = get_cow_datablock(scene);
/* Scene objects. */
int select_color = 1;
/* NOTE: Base is used for function bindings as-is, so need to pass CoW base,
@@ -102,10 +104,14 @@ void DepsgraphNodeBuilder::build_view_layer(
* tricks here iterating over the view layer.
*/
int base_index = 0;
+ const int base_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ?
+ BASE_VISIBLE_VIEWPORT : BASE_VISIBLE_RENDER;
LISTBASE_FOREACH(Base *, base, &view_layer->object_bases) {
/* object itself */
- build_object(base_index, base->object, linked_state);
- base->object->select_color = select_color++;
+ if (base->flag & base_flag) {
+ build_object(base_index, base->object, linked_state);
+ base->object->select_color = select_color++;
+ }
++base_index;
}
build_layer_collections(&view_layer->layer_collections);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 64bdbe49dac..eb1ee0c1535 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -161,6 +161,9 @@ static bool particle_system_depends_on_time(ParticleSystem *psys)
static bool object_particles_depends_on_time(Object *object)
{
+ if (object->type != OB_MESH) {
+ return false;
+ }
LISTBASE_FOREACH (ParticleSystem *, psys, &object->particlesystem) {
if (particle_system_depends_on_time(psys)) {
return true;
@@ -396,12 +399,27 @@ void DepsgraphRelationBuilder::build_id(ID *id)
return;
}
switch (GS(id->name)) {
+ case ID_AR:
+ build_armature((bArmature *)id);
+ break;
+ case ID_CA:
+ build_camera((Camera *)id);
+ break;
case ID_GR:
- build_collection(NULL, (Collection *)id);
+ build_collection(DEG_COLLECTION_OWNER_UNKNOWN, NULL, (Collection *)id);
break;
case ID_OB:
build_object(NULL, (Object *)id);
break;
+ case ID_KE:
+ build_shapekeys((Key *)id);
+ break;
+ case ID_LA:
+ build_lamp((Lamp *)id);
+ break;
+ case ID_LP:
+ build_lightprobe((LightProbe *)id);
+ break;
case ID_NT:
build_nodetree((bNodeTree *)id);
break;
@@ -420,13 +438,33 @@ void DepsgraphRelationBuilder::build_id(ID *id)
case ID_MC:
build_movieclip((MovieClip *)id);
break;
+ case ID_ME:
+ case ID_CU:
+ case ID_MB:
+ case ID_LT:
+ build_object_data_geometry_datablock(id);
+ break;
default:
fprintf(stderr, "Unhandled ID %s\n", id->name);
+ BLI_assert(!"Should never happen");
+ break;
}
}
-void DepsgraphRelationBuilder::build_collection(Object *object, Collection *collection)
+void DepsgraphRelationBuilder::build_collection(
+ eDepsNode_CollectionOwner owner_type,
+ Object *object,
+ Collection *collection)
{
+ const bool allow_restrict_flags = (owner_type == DEG_COLLECTION_OWNER_SCENE);
+ if (allow_restrict_flags) {
+ const int restrict_flag = (graph_->mode == DAG_EVAL_VIEWPORT)
+ ? COLLECTION_RESTRICT_VIEW
+ : COLLECTION_RESTRICT_RENDER;
+ if (collection->flag & restrict_flag) {
+ return;
+ }
+ }
const bool group_done = built_map_.checkIsBuiltAndTag(collection);
OperationKey object_local_transform_key(object != NULL ? &object->id : NULL,
DEG_NODE_TYPE_TRANSFORM,
@@ -436,12 +474,17 @@ void DepsgraphRelationBuilder::build_collection(Object *object, Collection *coll
build_object(NULL, cob->ob);
}
LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
- build_collection(NULL, child->collection);
+ build_collection(owner_type, NULL, child->collection);
}
}
if (object != NULL) {
const ListBase group_objects = BKE_collection_object_cache_get(collection);
+ const int base_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ?
+ BASE_VISIBLE_VIEWPORT : BASE_VISIBLE_RENDER;
LISTBASE_FOREACH (Base *, base, &group_objects) {
+ if ((base->flag & base_flag) == 0) {
+ continue;
+ }
ComponentKey dupli_transform_key(&base->object->id, DEG_NODE_TYPE_TRANSFORM);
add_relation(dupli_transform_key, object_local_transform_key, "Dupligroup");
}
@@ -540,24 +583,21 @@ void DepsgraphRelationBuilder::build_object(Base *base, Object *object)
if (object->gpd != NULL) {
build_gpencil(object->gpd);
}
- /* Object that this is a proxy for. */
- if (object->proxy != NULL) {
- object->proxy->proxy_from = object;
- build_object(NULL, object->proxy);
- /* TODO(sergey): This is an inverted relation, matches old depsgraph
- * behavior and need to be investigated if it still need to be inverted.
- */
- ComponentKey ob_pose_key(&object->id, DEG_NODE_TYPE_EVAL_POSE);
- ComponentKey proxy_pose_key(&object->proxy->id, DEG_NODE_TYPE_EVAL_POSE);
+ /* Proxy object to copy from. */
+ if (object->proxy_from != NULL) {
+ build_object(NULL, object->proxy_from);
+ ComponentKey ob_pose_key(&object->proxy_from->id, DEG_NODE_TYPE_EVAL_POSE);
+ ComponentKey proxy_pose_key(&object->id, DEG_NODE_TYPE_EVAL_POSE);
add_relation(ob_pose_key, proxy_pose_key, "Proxy Pose");
- ComponentKey ob_transform_key(&object->id, DEG_NODE_TYPE_TRANSFORM);
- ComponentKey proxy_transform_key(&object->proxy->id, DEG_NODE_TYPE_TRANSFORM);
+ ComponentKey ob_transform_key(&object->proxy_from->id, DEG_NODE_TYPE_TRANSFORM);
+ ComponentKey proxy_transform_key(&object->id, DEG_NODE_TYPE_TRANSFORM);
add_relation(ob_transform_key, proxy_transform_key, "Proxy Transform");
}
+
/* Object dupligroup. */
if (object->dup_group != NULL) {
- build_collection(object, object->dup_group);
+ build_collection(DEG_COLLECTION_OWNER_OBJECT, object, object->dup_group);
}
}
@@ -594,7 +634,7 @@ void DepsgraphRelationBuilder::build_object_data(Object *object)
case OB_MBALL:
case OB_LATTICE:
{
- build_obdata_geom(object);
+ build_object_data_geometry(object);
break;
}
case OB_ARMATURE:
@@ -606,13 +646,13 @@ void DepsgraphRelationBuilder::build_object_data(Object *object)
}
break;
case OB_LAMP:
- build_lamp(object);
+ build_object_data_lamp(object);
break;
case OB_CAMERA:
- build_camera(object);
+ build_object_data_camera(object);
break;
case OB_LIGHTPROBE:
- build_lightprobe(object);
+ build_object_data_lightprobe(object);
break;
}
Key *key = BKE_key_from_object(object);
@@ -624,6 +664,37 @@ void DepsgraphRelationBuilder::build_object_data(Object *object)
}
}
+void DepsgraphRelationBuilder::build_object_data_camera(Object *object)
+{
+ Camera *camera = (Camera *)object->data;
+ build_camera(camera);
+ ComponentKey object_parameters_key(&object->id, DEG_NODE_TYPE_PARAMETERS);
+ ComponentKey camera_parameters_key(&camera->id, DEG_NODE_TYPE_PARAMETERS);
+ add_relation(camera_parameters_key, object_parameters_key, "Camera -> Object");
+}
+
+void DepsgraphRelationBuilder::build_object_data_lamp(Object *object)
+{
+ Lamp *lamp = (Lamp *)object->data;
+ build_lamp(lamp);
+ ComponentKey object_parameters_key(&object->id, DEG_NODE_TYPE_PARAMETERS);
+ ComponentKey lamp_parameters_key(&lamp->id, DEG_NODE_TYPE_PARAMETERS);
+ add_relation(lamp_parameters_key, object_parameters_key, "Lamp -> Object");
+}
+
+void DepsgraphRelationBuilder::build_object_data_lightprobe(Object *object)
+{
+ LightProbe *probe = (LightProbe *)object->data;
+ build_lightprobe(probe);
+ OperationKey probe_key(&probe->id,
+ DEG_NODE_TYPE_PARAMETERS,
+ DEG_OPCODE_LIGHT_PROBE_EVAL);
+ OperationKey object_key(&object->id,
+ DEG_NODE_TYPE_PARAMETERS,
+ DEG_OPCODE_LIGHT_PROBE_EVAL);
+ add_relation(probe_key, object_key, "LightProbe Update");
+}
+
void DepsgraphRelationBuilder::build_object_parent(Object *object)
{
/* XXX: for now, need to use the component key (not just direct to the parent op),
@@ -1022,14 +1093,12 @@ void DepsgraphRelationBuilder::build_animdata_curves_targets(
/* It is possible that animation is writing to a nested ID datablock,
* need to make sure animation is evaluated after target ID is copied.
*/
- if (DEG_depsgraph_use_copy_on_write()) {
- const IDDepsNode *id_node_from = operation_from->owner->owner;
- const IDDepsNode *id_node_to = operation_to->owner->owner;
- if (id_node_from != id_node_to) {
- ComponentKey cow_key(id_node_to->id_orig,
- DEG_NODE_TYPE_COPY_ON_WRITE);
- add_relation(cow_key, adt_key, "Target CoW -> Animation", true);
- }
+ const IDDepsNode *id_node_from = operation_from->owner->owner;
+ const IDDepsNode *id_node_to = operation_to->owner->owner;
+ if (id_node_from != id_node_to) {
+ ComponentKey cow_key(id_node_to->id_orig,
+ DEG_NODE_TYPE_COPY_ON_WRITE);
+ add_relation(cow_key, adt_key, "Target CoW -> Animation", true);
}
}
}
@@ -1203,7 +1272,7 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu)
* datablock, which means driver execution should wait for that
* datablock to be copied.
*/
- if (DEG_depsgraph_use_copy_on_write()) {
+ {
PointerRNA id_ptr;
PointerRNA ptr;
RNA_id_pointer_create(id, &id_ptr);
@@ -1539,7 +1608,7 @@ void DepsgraphRelationBuilder::build_particles(Object *object)
break;
case PART_DRAW_GR:
if (part->dup_group != NULL) {
- build_collection(NULL, part->dup_group);
+ build_collection(DEG_COLLECTION_OWNER_OBJECT, NULL, part->dup_group);
LISTBASE_FOREACH (CollectionObject *, go, &part->dup_group->gobject) {
build_particles_visualization_object(object,
psys,
@@ -1611,27 +1680,13 @@ void DepsgraphRelationBuilder::build_cloth(Object *object,
}
/* Shapekeys */
-void DepsgraphRelationBuilder::build_shapekeys(ID *obdata, Key *key)
+void DepsgraphRelationBuilder::build_shapekeys(Key *key)
{
- ComponentKey obdata_key(obdata, DEG_NODE_TYPE_GEOMETRY);
-
+ if (built_map_.checkIsBuiltAndTag(key)) {
+ return;
+ }
/* attach animdata to geometry */
build_animdata(&key->id);
-
- if (key->adt) {
- // TODO: this should really be handled in build_animdata, since many of these cases will need it
- if (key->adt->action || key->adt->nla_tracks.first) {
- ComponentKey adt_key(&key->id, DEG_NODE_TYPE_ANIMATION);
- add_relation(adt_key, obdata_key, "Animation");
- }
-
- /* NOTE: individual shapekey drivers are handled above already */
- }
-
- /* attach to geometry */
- // XXX: aren't shapekeys now done as a pseudo-modifier on object?
- //ComponentKey key_key(&key->id, DEG_NODE_TYPE_GEOMETRY); // FIXME: this doesn't exist
- //add_relation(key_key, obdata_key, "Shapekeys");
}
/**
@@ -1639,56 +1694,53 @@ void DepsgraphRelationBuilder::build_shapekeys(ID *obdata, Key *key)
* ==========================
*
* The evaluation of geometry on objects is as follows:
- * - The actual evaluated of the derived geometry (e.g. DerivedMesh, DispList, etc.)
- * occurs in the Geometry component of the object which references this. This includes
- * modifiers, and the temporary "ubereval" for geometry.
- * - Therefore, each user of a piece of shared geometry data ends up evaluating its own
- * version of the stuff, complete with whatever modifiers it may use.
+ * - The actual evaluated of the derived geometry (e.g. DerivedMesh, DispList)
+ * occurs in the Geometry component of the object which references this.
+ * This includes modifiers, and the temporary "ubereval" for geometry.
+ * Therefore, each user of a piece of shared geometry data ends up evaluating
+ * its own version of the stuff, complete with whatever modifiers it may use.
*
- * - The datablocks for the geometry data - "obdata" (e.g. ID_ME, ID_CU, ID_LT, etc.) are used for
+ * - The datablocks for the geometry data - "obdata" (e.g. ID_ME, ID_CU, ID_LT.)
+ * are used for
* 1) calculating the bounding boxes of the geometry data,
- * 2) aggregating inward links from other objects (e.g. for text on curve, etc.)
+ * 2) aggregating inward links from other objects (e.g. for text on curve)
* and also for the links coming from the shapekey datablocks
- * - Animation/Drivers affecting the parameters of the geometry are made to trigger
- * updates on the obdata geometry component, which then trigger downstream
- * re-evaluation of the individual instances of this geometry.
+ * - Animation/Drivers affecting the parameters of the geometry are made to
+ * trigger updates on the obdata geometry component, which then trigger
+ * downstream re-evaluation of the individual instances of this geometry.
*/
-// TODO: Materials and lighting should probably get their own component, instead of being lumped under geometry?
-void DepsgraphRelationBuilder::build_obdata_geom(Object *object)
+void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
{
ID *obdata = (ID *)object->data;
-
/* Init operation of object-level geometry evaluation. */
- OperationKey geom_init_key(&object->id, DEG_NODE_TYPE_GEOMETRY, DEG_OPCODE_PLACEHOLDER, "Eval Init");
-
- /* get nodes for result of obdata's evaluation, and geometry evaluation on object */
+ OperationKey geom_init_key(&object->id,
+ DEG_NODE_TYPE_GEOMETRY,
+ DEG_OPCODE_PLACEHOLDER,
+ "Eval Init");
+ /* Get nodes for result of obdata's evaluation, and geometry evaluation
+ * on object.
+ */
ComponentKey obdata_geom_key(obdata, DEG_NODE_TYPE_GEOMETRY);
ComponentKey geom_key(&object->id, DEG_NODE_TYPE_GEOMETRY);
-
- /* link components to each other */
+ /* Link components to each other. */
add_relation(obdata_geom_key, geom_key, "Object Geometry Base Data");
-
OperationKey obdata_ubereval_key(&object->id,
DEG_NODE_TYPE_GEOMETRY,
DEG_OPCODE_GEOMETRY_UBEREVAL);
-
- /* Special case: modifiers and DerivedMesh creation queries scene for various
- * things like data mask to be used. We add relation here to ensure object is
- * never evaluated prior to Scene's CoW is ready.
+ /* Special case: modifiers evaluation queries scene for various things like
+ * data mask to be used. We add relation here to ensure object is never
+ * evaluated prior to Scene's CoW is ready.
*/
OperationKey scene_key(&scene_->id,
- DEG_NODE_TYPE_PARAMETERS,
- DEG_OPCODE_PLACEHOLDER,
- "Scene Eval");
+ DEG_NODE_TYPE_LAYER_COLLECTIONS,
+ DEG_OPCODE_VIEW_LAYER_EVAL);
DepsRelation *rel = add_relation(scene_key, obdata_ubereval_key, "CoW Relation");
rel->flag |= DEPSREL_FLAG_NO_FLUSH;
-
/* Modifiers */
if (object->modifiers.first != NULL) {
ModifierUpdateDepsgraphContext ctx = {};
ctx.scene = scene_;
ctx.object = object;
-
LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
const ModifierTypeInfo *mti = modifierType_getInfo((ModifierType)md->type);
if (mti->updateDepsgraph) {
@@ -1705,8 +1757,7 @@ void DepsgraphRelationBuilder::build_obdata_geom(Object *object)
}
}
}
-
- /* materials */
+ /* Materials. */
if (object->totcol) {
for (int a = 1; a <= object->totcol; a++) {
Material *ma = give_current_material(object, a);
@@ -1717,181 +1768,183 @@ void DepsgraphRelationBuilder::build_obdata_geom(Object *object)
OperationKey material_key(&ma->id,
DEG_NODE_TYPE_SHADING,
DEG_OPCODE_MATERIAL_UPDATE);
- OperationKey shading_key(&object->id, DEG_NODE_TYPE_SHADING, DEG_OPCODE_SHADING);
+ OperationKey shading_key(&object->id,
+ DEG_NODE_TYPE_SHADING,
+ DEG_OPCODE_SHADING);
add_relation(material_key, shading_key, "Material Update");
}
}
}
}
-
- /* geometry collision */
+ /* Geometry collision. */
if (ELEM(object->type, OB_MESH, OB_CURVE, OB_LATTICE)) {
// add geometry collider relations
}
-
/* Make sure uber update is the last in the dependencies.
*
* TODO(sergey): Get rid of this node.
*/
if (object->type != OB_ARMATURE) {
/* Armatures does no longer require uber node. */
- OperationKey obdata_ubereval_key(&object->id, DEG_NODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_UBEREVAL);
- add_relation(geom_init_key, obdata_ubereval_key, "Object Geometry UberEval");
+ OperationKey obdata_ubereval_key(&object->id,
+ DEG_NODE_TYPE_GEOMETRY,
+ DEG_OPCODE_GEOMETRY_UBEREVAL);
+ add_relation(geom_init_key,
+ obdata_ubereval_key,
+ "Object Geometry UberEval");
+ }
+ if (object->type == OB_MBALL) {
+ Object *mom = BKE_mball_basis_find(scene_, object);
+ ComponentKey mom_geom_key(&mom->id, DEG_NODE_TYPE_GEOMETRY);
+ /* motherball - mom depends on children! */
+ if (mom == object) {
+ ComponentKey mom_transform_key(&mom->id,
+ DEG_NODE_TYPE_TRANSFORM);
+ add_relation(mom_transform_key,
+ mom_geom_key,
+ "Metaball Motherball Transform -> Geometry");
+ }
+ else {
+ ComponentKey transform_key(&object->id, DEG_NODE_TYPE_TRANSFORM);
+ add_relation(geom_key, mom_geom_key, "Metaball Motherball");
+ add_relation(transform_key, mom_geom_key, "Metaball Motherball");
+ }
}
+ /* NOTE: This is compatibility code to support particle systems
+ *
+ * for viewport being properly rendered in final render mode.
+ * This relation is similar to what dag_object_time_update_flags()
+ * was doing for mesh objects with particle system.
+ *
+ * Ideally we need to get rid of this relation.
+ */
+ if (object_particles_depends_on_time(object)) {
+ TimeSourceKey time_key;
+ OperationKey obdata_ubereval_key(&object->id,
+ DEG_NODE_TYPE_GEOMETRY,
+ DEG_OPCODE_GEOMETRY_UBEREVAL);
+ add_relation(time_key, obdata_ubereval_key, "Legacy particle time");
+ }
+ /* Object data datablock. */
+ build_object_data_geometry_datablock((ID *)object->data);
+ Key *key = BKE_key_from_object(object);
+ if (key != NULL) {
+ if (key->adt != NULL) {
+ if (key->adt->action || key->adt->nla_tracks.first) {
+ ComponentKey obdata_key((ID *)object->data,
+ DEG_NODE_TYPE_GEOMETRY);
+ ComponentKey adt_key(&key->id, DEG_NODE_TYPE_ANIMATION);
+ add_relation(adt_key, obdata_key, "Animation");
+ }
+ }
+ }
+}
+void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
+{
if (built_map_.checkIsBuiltAndTag(obdata)) {
return;
}
-
+ /* Animation. */
+ build_animdata(obdata);
+ /* ShapeKeys. */
+ Key *key = BKE_key_from_id(obdata);
+ if (key != NULL) {
+ build_shapekeys(key);
+ }
/* Link object data evaluation node to exit operation. */
- OperationKey obdata_geom_eval_key(obdata, DEG_NODE_TYPE_GEOMETRY, DEG_OPCODE_PLACEHOLDER, "Geometry Eval");
- OperationKey obdata_geom_done_key(obdata, DEG_NODE_TYPE_GEOMETRY, DEG_OPCODE_PLACEHOLDER, "Eval Done");
- add_relation(obdata_geom_eval_key, obdata_geom_done_key, "ObData Geom Eval Done");
-
- /* type-specific node/links */
- switch (object->type) {
- case OB_MESH:
- /* NOTE: This is compatibility code to support particle systems
- *
- * for viewport being properly rendered in final render mode.
- * This relation is similar to what dag_object_time_update_flags()
- * was doing for mesh objects with particle system.
- *
- * Ideally we need to get rid of this relation.
- */
- if (object_particles_depends_on_time(object)) {
- TimeSourceKey time_key;
- OperationKey obdata_ubereval_key(&object->id,
- DEG_NODE_TYPE_GEOMETRY,
- DEG_OPCODE_GEOMETRY_UBEREVAL);
- add_relation(time_key, obdata_ubereval_key, "Legacy particle time");
- }
+ OperationKey obdata_geom_eval_key(obdata,
+ DEG_NODE_TYPE_GEOMETRY,
+ DEG_OPCODE_PLACEHOLDER,
+ "Geometry Eval");
+ OperationKey obdata_geom_done_key(obdata,
+ DEG_NODE_TYPE_GEOMETRY,
+ DEG_OPCODE_PLACEHOLDER,
+ "Eval Done");
+ add_relation(obdata_geom_eval_key,
+ obdata_geom_done_key,
+ "ObData Geom Eval Done");
+ /* Type-specific links. */
+ const ID_Type id_type = GS(obdata->name);
+ switch (id_type) {
+ case ID_ME:
break;
-
- case OB_MBALL:
- {
- Object *mom = BKE_mball_basis_find(scene_, object);
- ComponentKey mom_geom_key(&mom->id, DEG_NODE_TYPE_GEOMETRY);
- /* motherball - mom depends on children! */
- if (mom == object) {
- ComponentKey mom_transform_key(&mom->id,
- DEG_NODE_TYPE_TRANSFORM);
- add_relation(mom_transform_key,
- mom_geom_key,
- "Metaball Motherball Transform -> Geometry");
- }
- else {
- ComponentKey transform_key(&object->id, DEG_NODE_TYPE_TRANSFORM);
- add_relation(geom_key, mom_geom_key, "Metaball Motherball");
- add_relation(transform_key, mom_geom_key, "Metaball Motherball");
- }
+ case ID_MB:
break;
- }
-
- case OB_CURVE:
- case OB_FONT:
+ case ID_CU:
{
Curve *cu = (Curve *)obdata;
-
- /* curve's dependencies */
- // XXX: these needs geom data, but where is geom stored?
- if (cu->bevobj) {
- ComponentKey bevob_geom_key(&cu->bevobj->id, DEG_NODE_TYPE_GEOMETRY);
- add_relation(bevob_geom_key, obdata_geom_key, "Curve Bevel Geometry");
- /* We only need scale, but we can't tag individual TRANSFORM components. */
- ComponentKey bevob_key(&cu->bevobj->id, DEG_NODE_TYPE_TRANSFORM);
- add_relation(bevob_key, obdata_geom_key, "Curve Bevel Scale");
+ if (cu->bevobj != NULL) {
+ ComponentKey bevob_geom_key(&cu->bevobj->id,
+ DEG_NODE_TYPE_GEOMETRY);
+ add_relation(bevob_geom_key,
+ obdata_geom_eval_key,
+ "Curve Bevel Geometry");
+ ComponentKey bevob_key(&cu->bevobj->id,
+ DEG_NODE_TYPE_TRANSFORM);
+ add_relation(bevob_key,
+ obdata_geom_eval_key,
+ "Curve Bevel Transform");
build_object(NULL, cu->bevobj);
}
- if (cu->taperobj) {
- ComponentKey taperob_key(&cu->taperobj->id, DEG_NODE_TYPE_GEOMETRY);
+ if (cu->taperobj != NULL) {
+ ComponentKey taperob_key(&cu->taperobj->id,
+ DEG_NODE_TYPE_GEOMETRY);
+ add_relation(taperob_key, obdata_geom_eval_key, "Curve Taper");
build_object(NULL, cu->taperobj);
- add_relation(taperob_key, geom_key, "Curve Taper");
}
- if (object->type == OB_FONT) {
- if (cu->textoncurve) {
- ComponentKey textoncurve_key(&cu->textoncurve->id, DEG_NODE_TYPE_GEOMETRY);
- build_object(NULL, cu->textoncurve);
- add_relation(textoncurve_key, geom_key, "Text on Curve");
- }
+ if (cu->textoncurve != NULL) {
+ ComponentKey textoncurve_key(&cu->textoncurve->id,
+ DEG_NODE_TYPE_GEOMETRY);
+ add_relation(textoncurve_key,
+ obdata_geom_eval_key,
+ "Text on Curve");
+ build_object(NULL, cu->textoncurve);
}
break;
}
-
- case OB_SURF: /* Nurbs Surface */
- {
+ case ID_LT:
break;
- }
-
- case OB_LATTICE: /* Lattice */
- {
+ default:
+ BLI_assert(!"Should not happen");
break;
- }
}
+}
- /* ShapeKeys */
- Key *key = BKE_key_from_object(object);
- if (key) {
- build_shapekeys(obdata, key);
+void DepsgraphRelationBuilder::build_armature(bArmature *armature)
+{
+ if (built_map_.checkIsBuiltAndTag(armature)) {
+ return;
}
+ build_animdata(&armature->id);
}
-/* Cameras */
-// TODO: Link scene-camera links in somehow...
-void DepsgraphRelationBuilder::build_camera(Object *object)
+void DepsgraphRelationBuilder::build_camera(Camera *camera)
{
- Camera *camera = (Camera *)object->data;
if (built_map_.checkIsBuiltAndTag(camera)) {
return;
}
-
- ComponentKey object_parameters_key(&object->id, DEG_NODE_TYPE_PARAMETERS);
- ComponentKey camera_parameters_key(&camera->id, DEG_NODE_TYPE_PARAMETERS);
-
- add_relation(camera_parameters_key, object_parameters_key,
- "Camera -> Object");
-
- /* DOF */
if (camera->dof_ob != NULL) {
+ ComponentKey camera_parameters_key(&camera->id, DEG_NODE_TYPE_PARAMETERS);
ComponentKey dof_ob_key(&camera->dof_ob->id, DEG_NODE_TYPE_TRANSFORM);
- add_relation(dof_ob_key, object_parameters_key, "Camera DOF");
+ add_relation(dof_ob_key, camera_parameters_key, "Camera DOF");
}
}
/* Lamps */
-void DepsgraphRelationBuilder::build_lamp(Object *object)
+void DepsgraphRelationBuilder::build_lamp(Lamp *lamp)
{
- Lamp *lamp = (Lamp *)object->data;
if (built_map_.checkIsBuiltAndTag(lamp)) {
return;
}
-
- ComponentKey object_parameters_key(&object->id, DEG_NODE_TYPE_PARAMETERS);
- ComponentKey lamp_parameters_key(&lamp->id, DEG_NODE_TYPE_PARAMETERS);
-
- add_relation(lamp_parameters_key, object_parameters_key,
- "Lamp -> Object");
-
/* lamp's nodetree */
if (lamp->nodetree != NULL) {
build_nodetree(lamp->nodetree);
+ ComponentKey lamp_parameters_key(&lamp->id, DEG_NODE_TYPE_PARAMETERS);
ComponentKey nodetree_key(&lamp->nodetree->id, DEG_NODE_TYPE_SHADING);
add_relation(nodetree_key, lamp_parameters_key, "NTree->Lamp Parameters");
build_nested_nodetree(&lamp->id, lamp->nodetree);
}
-
- if (DEG_depsgraph_use_copy_on_write()) {
- /* Make sure copy on write of lamp data is always properly updated for
- * visible lamps.
- */
- OperationKey ob_copy_on_write_key(&object->id,
- DEG_NODE_TYPE_COPY_ON_WRITE,
- DEG_OPCODE_COPY_ON_WRITE);
- OperationKey lamp_copy_on_write_key(&lamp->id,
- DEG_NODE_TYPE_COPY_ON_WRITE,
- DEG_OPCODE_COPY_ON_WRITE);
- add_relation(lamp_copy_on_write_key, ob_copy_on_write_key, "Eval Order");
- }
}
void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
@@ -1953,7 +2006,7 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
if (check_id_has_anim_component(&ntree->id)) {
ComponentKey animation_key(&ntree->id, DEG_NODE_TYPE_ANIMATION);
- add_relation(shading_parameters_key, animation_key, "NTree Shading Parameters");
+ add_relation(animation_key, shading_parameters_key, "NTree Shading Parameters");
}
}
@@ -2046,23 +2099,12 @@ void DepsgraphRelationBuilder::build_movieclip(MovieClip *clip)
build_animdata(&clip->id);
}
-void DepsgraphRelationBuilder::build_lightprobe(Object *object)
+void DepsgraphRelationBuilder::build_lightprobe(LightProbe *probe)
{
- LightProbe *probe = (LightProbe *)object->data;
if (built_map_.checkIsBuiltAndTag(probe)) {
return;
}
build_animdata(&probe->id);
-
- OperationKey probe_key(&probe->id,
- DEG_NODE_TYPE_PARAMETERS,
- DEG_OPCODE_PLACEHOLDER,
- "LightProbe Eval");
- OperationKey object_key(&object->id,
- DEG_NODE_TYPE_PARAMETERS,
- DEG_OPCODE_PLACEHOLDER,
- "LightProbe Eval");
- add_relation(probe_key, object_key, "LightProbe Update");
}
void DepsgraphRelationBuilder::build_copy_on_write_relations()
@@ -2079,9 +2121,6 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations()
*/
void DepsgraphRelationBuilder::build_nested_datablock(ID *owner, ID *id)
{
- if (!DEG_depsgraph_use_copy_on_write()) {
- return;
- }
OperationKey owner_copy_on_write_key(owner,
DEG_NODE_TYPE_COPY_ON_WRITE,
DEG_OPCODE_COPY_ON_WRITE);
@@ -2136,12 +2175,18 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node
/* Component explicitly requests to not add relation. */
continue;
}
+ int rel_flag = 0;
+ if (comp_node->type == DEG_NODE_TYPE_ANIMATION) {
+ rel_flag |= DEPSREL_FLAG_NO_FLUSH;
+ }
/* All entry operations of each component should wait for a proper
* copy of ID.
*/
OperationDepsNode *op_entry = comp_node->get_entry_operation();
if (op_entry != NULL) {
- graph_->add_new_relation(op_cow, op_entry, "CoW Dependency");
+ DepsRelation *rel = graph_->add_new_relation(
+ op_cow, op_entry, "CoW Dependency");
+ rel->flag |= rel_flag;
}
/* All dangling operations should also be executed after copy-on-write. */
GHASH_FOREACH_BEGIN(OperationDepsNode *, op_node, comp_node->operations_map)
@@ -2150,22 +2195,27 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node
continue;
}
if (op_node->inlinks.size() == 0) {
- graph_->add_new_relation(op_cow, op_node, "CoW Dependency");
+ DepsRelation *rel = graph_->add_new_relation(
+ op_cow, op_node, "CoW Dependency");
+ rel->flag |= rel_flag;
}
else {
bool has_same_comp_dependency = false;
- foreach (DepsRelation *rel, op_node->inlinks) {
- if (rel->from->type != DEG_NODE_TYPE_OPERATION) {
+ foreach (DepsRelation *rel_current, op_node->inlinks) {
+ if (rel_current->from->type != DEG_NODE_TYPE_OPERATION) {
continue;
}
- OperationDepsNode *op_node_from = (OperationDepsNode *)rel->from;
+ OperationDepsNode *op_node_from =
+ (OperationDepsNode *)rel_current->from;
if (op_node_from->owner == op_node->owner) {
has_same_comp_dependency = true;
break;
}
}
if (!has_same_comp_dependency) {
- graph_->add_new_relation(op_cow, op_node, "CoW Dependency");
+ DepsRelation *rel = graph_->add_new_relation(
+ op_cow, op_node, "CoW Dependency");
+ rel->flag |= rel_flag;
}
}
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index dbfaff4dc18..3d3a73b6551 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -49,15 +49,19 @@
#include "intern/nodes/deg_node_operation.h"
struct Base;
+struct bArmature;
struct bGPdata;
struct CacheFile;
+struct Camera;
struct ListBase;
struct GHash;
struct ID;
struct FCurve;
struct Collection;
struct Key;
+struct Lamp;
struct LayerCollection;
+struct LightProbe;
struct Main;
struct Mask;
struct Material;
@@ -197,10 +201,17 @@ struct DepsgraphRelationBuilder
void build_id(ID *id);
void build_layer_collections(ListBase *lb);
void build_view_layer(Scene *scene, ViewLayer *view_layer);
- void build_collection(Object *object, Collection *collection);
+ void build_collection(eDepsNode_CollectionOwner owner_type,
+ Object *object,
+ Collection *collection);
void build_object(Base *base, Object *object);
void build_object_flags(Base *base, Object *object);
void build_object_data(Object *object);
+ void build_object_data_camera(Object *object);
+ void build_object_data_geometry(Object *object);
+ void build_object_data_geometry_datablock(ID *obdata);
+ void build_object_data_lamp(Object *object);
+ void build_object_data_lightprobe(Object *object);
void build_object_parent(Object *object);
void build_constraints(ID *id,
eDepsNode_Type component_type,
@@ -239,10 +250,10 @@ struct DepsgraphRelationBuilder
RootPChanMap *root_map);
void build_rig(Object *object);
void build_proxy_rig(Object *object);
- void build_shapekeys(ID *obdata, Key *key);
- void build_obdata_geom(Object *object);
- void build_camera(Object *object);
- void build_lamp(Object *object);
+ void build_shapekeys(Key *key);
+ void build_armature(bArmature *armature);
+ void build_camera(Camera *camera);
+ void build_lamp(Lamp *lamp);
void build_nodetree(bNodeTree *ntree);
void build_material(Material *ma);
void build_texture(Tex *tex);
@@ -251,7 +262,7 @@ struct DepsgraphRelationBuilder
void build_cachefile(CacheFile *cache_file);
void build_mask(Mask *mask);
void build_movieclip(MovieClip *clip);
- void build_lightprobe(Object *object);
+ void build_lightprobe(LightProbe *probe);
void build_nested_datablock(ID *owner, ID *id);
void build_nested_nodetree(ID *owner, bNodeTree *ntree);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
index a9895eb3af1..49c107c988f 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
@@ -304,27 +304,21 @@ void DepsgraphRelationBuilder::build_splineik_pose(Object *object,
void DepsgraphRelationBuilder::build_rig(Object *object)
{
/* Armature-Data */
- bArmature *arm = (bArmature *)object->data;
-
+ bArmature *armature = (bArmature *)object->data;
// TODO: selection status?
-
- /* attach links between pose operations */
+ /* Attach links between pose operations. */
OperationKey init_key(&object->id, DEG_NODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT);
OperationKey init_ik_key(&object->id, DEG_NODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT_IK);
OperationKey flush_key(&object->id, DEG_NODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE);
-
add_relation(init_key, init_ik_key, "Pose Init -> Pose Init IK");
add_relation(init_ik_key, flush_key, "Pose Init IK -> Pose Cleanup");
-
/* Make sure pose is up-to-date with armature updates. */
- if (!built_map_.checkIsBuiltAndTag(arm)) {
- OperationKey armature_key(&arm->id,
- DEG_NODE_TYPE_PARAMETERS,
- DEG_OPCODE_PLACEHOLDER,
- "Armature Eval");
- add_relation(armature_key, init_key, "Data dependency");
- }
-
+ build_armature(armature);
+ OperationKey armature_key(&armature->id,
+ DEG_NODE_TYPE_PARAMETERS,
+ DEG_OPCODE_PLACEHOLDER,
+ "Armature Eval");
+ add_relation(armature_key, init_key, "Data dependency");
/* IK Solvers...
* - These require separate processing steps are pose-level
* to be executed between chains of bones (i.e. once the
@@ -337,7 +331,8 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
* references, or with bones being parented to IK'd bones)
*
* Unsolved Issues:
- * - Care is needed to ensure that multi-headed trees work out the same as in ik-tree building
+ * - Care is needed to ensure that multi-headed trees work out the same as
+ * in ik-tree building
* - Animated chain-lengths are a problem...
*/
RootPChanMap root_map;
@@ -372,7 +367,6 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
}
}
//root_map.print_debug();
-
if (pose_depends_on_local_transform) {
/* TODO(sergey): Once partial updates are possible use relation between
* object transform and solver itself in it's build function.
@@ -381,8 +375,7 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
ComponentKey local_transform_key(&object->id, DEG_NODE_TYPE_TRANSFORM);
add_relation(local_transform_key, pose_key, "Local Transforms");
}
-
- /* links between operations for each bone */
+ /* Links between operations for each bone. */
LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) {
OperationKey bone_local_key(&object->id, DEG_NODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_LOCAL);
OperationKey bone_pose_key(&object->id, DEG_NODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_POSE_PARENT);
@@ -397,7 +390,9 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
if (pchan->parent != NULL) {
eDepsOperation_Code parent_key_opcode;
- /* NOTE: this difference in handling allows us to prevent lockups while ensuring correct poses for separate chains */
+ /* NOTE: this difference in handling allows us to prevent lockups
+ * while ensuring correct poses for separate chains.
+ */
if (root_map.has_common_root(pchan->name, pchan->parent->name)) {
parent_key_opcode = DEG_OPCODE_BONE_READY;
}
@@ -433,14 +428,15 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
/* bone ready -> done
* NOTE: For bones without IK, this is all that's needed.
- * For IK chains however, an additional rel is created from IK to done,
- * with transitive reduction removing this one...
+ * For IK chains however, an additional rel is created from IK
+ * to done, with transitive reduction removing this one..
*/
add_relation(bone_ready_key, bone_done_key, "Ready -> Done");
- /* assume that all bones must be done for the pose to be ready (for deformers) */
+ /* assume that all bones must be done for the pose to be ready
+ * (for deformers)
+ */
add_relation(bone_done_key, flush_key, "PoseEval Result-Bone Link");
-
/* Custom shape. */
if (pchan->custom != NULL) {
build_object(NULL, pchan->custom);
@@ -450,7 +446,9 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
void DepsgraphRelationBuilder::build_proxy_rig(Object *object)
{
+ bArmature *armature = (bArmature *)object->data;
Object *proxy_from = object->proxy_from;
+ build_armature(armature);
OperationKey pose_init_key(&object->id,
DEG_NODE_TYPE_EVAL_POSE,
DEG_OPCODE_POSE_INIT);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
index f575be9f659..b940fc3035e 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
@@ -71,8 +71,16 @@ namespace DEG {
void DepsgraphRelationBuilder::build_layer_collections(ListBase *lb)
{
+ const int restrict_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ?
+ COLLECTION_RESTRICT_VIEW : COLLECTION_RESTRICT_RENDER;
+
for (LayerCollection *lc = (LayerCollection *)lb->first; lc; lc = lc->next) {
- build_collection(NULL, lc->collection);
+ if ((lc->collection->flag & restrict_flag)) {
+ continue;
+ }
+ if ((lc->flag & LAYER_COLLECTION_EXCLUDE) == 0) {
+ build_collection(DEG_COLLECTION_OWNER_SCENE, NULL, lc->collection);
+ }
build_layer_collections(&lc->layer_collections);
}
}
@@ -86,8 +94,12 @@ void DepsgraphRelationBuilder::build_view_layer(Scene *scene, ViewLayer *view_la
* passed to the evaluation functions. During relations builder we only
* do NULL-pointer check of the base, so it's fine to pass original one.
*/
+ const int base_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ?
+ BASE_VISIBLE_VIEWPORT : BASE_VISIBLE_RENDER;
LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
- build_object(base, base->object);
+ if (base->flag & base_flag) {
+ build_object(base, base->object);
+ }
}
build_layer_collections(&view_layer->layer_collections);
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index 32cbee7597c..26a23cff372 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -70,18 +70,6 @@ extern "C" {
#include "intern/depsgraph_intern.h"
#include "util/deg_util_foreach.h"
-static bool use_copy_on_write = true;
-
-bool DEG_depsgraph_use_copy_on_write(void)
-{
- return use_copy_on_write;
-}
-
-void DEG_depsgraph_disable_copy_on_write(void)
-{
- use_copy_on_write = false;
-}
-
namespace DEG {
static DEG_EditorUpdateIDCb deg_editor_update_id_cb = NULL;
@@ -104,12 +92,14 @@ Depsgraph::Depsgraph(Scene *scene,
view_layer(view_layer),
mode(mode),
ctime(BKE_scene_frame_get(scene)),
- scene_cow(NULL)
+ scene_cow(NULL),
+ is_active(false)
{
BLI_spin_init(&lock);
id_hash = BLI_ghash_ptr_new("Depsgraph id hash");
entry_tags = BLI_gset_ptr_new("Depsgraph entry_tags");
debug_flags = G.debug;
+ memset(id_type_updated, 0, sizeof(id_type_updated));
}
Depsgraph::~Depsgraph()
@@ -320,7 +310,7 @@ IDDepsNode *Depsgraph::find_id_node(const ID *id) const
IDDepsNode *Depsgraph::add_id_node(ID *id, ID *id_cow_hint)
{
- BLI_assert((id->tag & LIB_TAG_COPY_ON_WRITE) == 0);
+ BLI_assert((id->tag & LIB_TAG_COPIED_ON_WRITE) == 0);
IDDepsNode *id_node = find_id_node(id);
if (!id_node) {
DepsNodeFactory *factory = deg_type_get_factory(DEG_NODE_TYPE_ID_REF);
@@ -340,7 +330,7 @@ IDDepsNode *Depsgraph::add_id_node(ID *id, ID *id_cow_hint)
void Depsgraph::clear_id_nodes()
{
/* Free memory used by ID nodes. */
- if (use_copy_on_write) {
+ {
/* Stupid workaround to ensure we free IDs in a proper order. */
foreach (IDDepsNode *id_node, id_nodes) {
if (id_node->id_cow == NULL) {
@@ -510,7 +500,7 @@ ID *Depsgraph::get_cow_id(const ID *id_orig) const
* We try to enforce that in debug builds, for for release we play a bit
* safer game here.
*/
- if ((id_orig->tag & LIB_TAG_COPY_ON_WRITE) == 0) {
+ if ((id_orig->tag & LIB_TAG_COPIED_ON_WRITE) == 0) {
/* TODO(sergey): This is nice sanity check to have, but it fails
* in following situations:
*
@@ -600,6 +590,34 @@ void DEG_editors_set_update_cb(DEG_EditorUpdateIDCb id_func,
DEG::deg_editor_update_scene_cb = scene_func;
}
+bool DEG_is_active(const struct Depsgraph *depsgraph)
+{
+ if (depsgraph == NULL) {
+ /* Happens for such cases as work object in what_does_obaction(),
+ * and sine render pipeline parts. Shouldn't really be accepting
+ * NULL depsgraph, but is quite hard to get proper one in those
+ * cases.
+ */
+ return false;
+ }
+ const DEG::Depsgraph *deg_graph =
+ reinterpret_cast<const DEG::Depsgraph *>(depsgraph);
+ return deg_graph->is_active;
+}
+
+void DEG_make_active(struct Depsgraph *depsgraph)
+{
+ DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
+ deg_graph->is_active = true;
+ /* TODO(sergey): Copy data from evaluated state to original. */
+}
+
+void DEG_make_inactive(struct Depsgraph *depsgraph)
+{
+ DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
+ deg_graph->is_active = false;
+}
+
/* Evaluation and debug */
static DEG::string depsgraph_name_for_logging(struct Depsgraph *depsgraph)
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index 7b6af9deee1..3c1233cd5bb 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -36,6 +36,10 @@
#pragma once
+#include <stdlib.h>
+
+#include "BKE_library.h" /* for MAX_LIBARRAY */
+
#include "BLI_threads.h" /* for SpinLock */
#include "DEG_depsgraph.h"
@@ -174,6 +178,9 @@ struct Depsgraph {
/* Indicates whether relations needs to be updated. */
bool need_update;
+ /* Indicates which ID types were updated. */
+ char id_type_updated[MAX_LIBARRAY];
+
/* Quick-Access Temp Data ............. */
/* Nodes which have been tagged as "directly modified". */
@@ -203,6 +210,16 @@ struct Depsgraph {
*/
Scene *scene_cow;
+ /* Active dependency graph is a dependency graph which is used by the
+ * currently active window. When dependency graph is active, it is allowed
+ * for evaluation functions to write animation f-curve result, drivers
+ * result and other selective things (object matrix?) to original object.
+ *
+ * This way we simplify operators, which don't need to worry about where
+ * to read stuff from.
+ */
+ bool is_active;
+
/* NITE: Corresponds to G_DEBUG_DEPSGRAPH_* flags. */
int debug_flags;
string debug_name;
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index 84b9bad17c9..c39f6222a13 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -231,9 +231,7 @@ void DEG_graph_build_from_view_layer(Depsgraph *graph,
DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph);
relation_builder.begin_build();
relation_builder.build_view_layer(scene, view_layer);
- if (DEG_depsgraph_use_copy_on_write()) {
- relation_builder.build_copy_on_write_relations();
- }
+ relation_builder.build_copy_on_write_relations();
/* Detect and solve cycles. */
DEG::deg_graph_detect_cycles(deg_graph);
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index 734b0ef931a..ca9f32d4d8c 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -80,9 +80,24 @@ float DEG_get_ctime(const Depsgraph *graph)
}
-bool DEG_id_type_tagged(Main *bmain, short id_type)
+bool DEG_id_type_updated(const Depsgraph *graph, short id_type)
{
- return bmain->id_tag_update[BKE_idcode_to_index(id_type)] != 0;
+ const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
+ return deg_graph->id_type_updated[BKE_idcode_to_index(id_type)] != 0;
+}
+
+bool DEG_id_type_any_updated(const Depsgraph *graph)
+{
+ const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
+
+ /* Loop over all ID types. */
+ for (int id_type_index = 0; id_type_index < MAX_LIBARRAY; id_type_index++) {
+ if (deg_graph->id_type_updated[id_type_index]) {
+ return true;
+ }
+ }
+
+ return false;
}
short DEG_get_eval_flags_for_id(const Depsgraph *graph, ID *id)
@@ -225,6 +240,6 @@ ID *DEG_get_original_id(ID *id)
if (id->orig_id == NULL) {
return id;
}
- BLI_assert((id->tag & LIB_TAG_COPY_ON_WRITE) != 0);
+ BLI_assert((id->tag & LIB_TAG_COPIED_ON_WRITE) != 0);
return (ID *)id->orig_id;
}
diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
index 1726c7c855a..5dca0e83124 100644
--- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
@@ -41,6 +41,7 @@ extern "C" {
#include "BKE_anim.h"
#include "BKE_idprop.h"
#include "BKE_layer.h"
+#include "BKE_node.h"
#include "BKE_object.h"
} /* extern "C" */
@@ -119,7 +120,7 @@ static bool deg_objects_dupli_iterator_next(BLI_Iterator *iter)
/* Duplicated elements shouldn't care whether their original collection is visible or not. */
temp_dupli_object->base_flag |= BASE_VISIBLED;
- if (BKE_object_is_visible(temp_dupli_object, (eObjectVisibilityCheck)data->visibility_check) == false) {
+ if (BKE_object_is_visible(temp_dupli_object, OB_VISIBILITY_CHECK_UNKNOWN_RENDER_MODE) == false) {
continue;
}
@@ -196,13 +197,13 @@ void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data)
DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
const size_t num_id_nodes = deg_graph->id_nodes.size();
+ iter->data = data;
+
if (num_id_nodes == 0) {
- iter->data = NULL;
iter->valid = false;
return;
}
- iter->data = data;
data->dupli_parent = NULL;
data->dupli_list = NULL;
data->dupli_object_next = NULL;
@@ -210,7 +211,8 @@ void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data)
data->scene = DEG_get_evaluated_scene(depsgraph);
data->id_node_index = 0;
data->num_id_nodes = num_id_nodes;
- data->visibility_check = (data->mode == DEG_ITER_OBJECT_MODE_RENDER)
+ eEvaluationMode eval_mode = DEG_get_mode(depsgraph);
+ data->visibility_check = (eval_mode == DAG_EVAL_RENDER)
? OB_VISIBILITY_CHECK_FOR_RENDER
: OB_VISIBILITY_CHECK_FOR_VIEWPORT;
@@ -269,3 +271,73 @@ void DEG_iterator_objects_end(BLI_Iterator *iter)
(void) iter;
#endif
}
+
+/* ************************ DEG ID ITERATOR ********************* */
+
+static void DEG_iterator_ids_step(BLI_Iterator *iter, DEG::IDDepsNode *id_node, bool only_updated)
+{
+ ID *id_cow = id_node->id_cow;
+
+ if (only_updated && !(id_cow->recalc & ID_RECALC_ALL)) {
+ bNodeTree *ntree = ntreeFromID(id_cow);
+
+ /* Nodetree is considered part of the datablock. */
+ if (!(ntree && (ntree->id.recalc & ID_RECALC_ALL))) {
+ iter->skip = true;
+ return;
+ }
+ }
+
+ iter->current = id_cow;
+ iter->skip = false;
+}
+
+void DEG_iterator_ids_begin(BLI_Iterator *iter, DEGIDIterData *data)
+{
+ Depsgraph *depsgraph = data->graph;
+ DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
+ const size_t num_id_nodes = deg_graph->id_nodes.size();
+
+ iter->data = data;
+
+ if ((num_id_nodes == 0) ||
+ (data->only_updated && !DEG_id_type_any_updated(depsgraph)))
+ {
+ iter->valid = false;
+ return;
+ }
+
+ data->id_node_index = 0;
+ data->num_id_nodes = num_id_nodes;
+
+ DEG::IDDepsNode *id_node = deg_graph->id_nodes[data->id_node_index];
+ DEG_iterator_ids_step(iter, id_node, data->only_updated);
+
+ if (iter->skip) {
+ DEG_iterator_ids_next(iter);
+ }
+}
+
+void DEG_iterator_ids_next(BLI_Iterator *iter)
+{
+ DEGIDIterData *data = (DEGIDIterData *)iter->data;
+ Depsgraph *depsgraph = data->graph;
+ DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
+
+ do {
+ iter->skip = false;
+
+ ++data->id_node_index;
+ if (data->id_node_index == data->num_id_nodes) {
+ iter->valid = false;
+ return;
+ }
+
+ DEG::IDDepsNode *id_node = deg_graph->id_nodes[data->id_node_index];
+ DEG_iterator_ids_step(iter, id_node, data->only_updated);
+ } while (iter->skip);
+}
+
+void DEG_iterator_ids_end(BLI_Iterator *UNUSED(iter))
+{
+}
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 466e6053ef3..8ff11ca5fd2 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -40,6 +40,7 @@
#include "BLI_task.h"
extern "C" {
+#include "DNA_anim_types.h"
#include "DNA_curve_types.h"
#include "DNA_key_types.h"
#include "DNA_lattice_types.h"
@@ -49,6 +50,7 @@ extern "C" {
#include "DNA_screen_types.h"
#include "DNA_windowmanager_types.h"
+#include "BKE_animsys.h"
#include "BKE_idcode.h"
#include "BKE_library.h"
#include "BKE_main.h"
@@ -62,6 +64,7 @@ extern "C" {
} /* extern "C" */
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "intern/builder/deg_builder.h"
#include "intern/eval/deg_eval_flush.h"
@@ -281,7 +284,7 @@ void depsgraph_tag_component(Depsgraph *graph,
}
}
/* If component depends on copy-on-write, tag it as well. */
- if (DEG_depsgraph_use_copy_on_write() && component_node->depends_on_cow()) {
+ if (component_node->depends_on_cow()) {
ComponentDepsNode *cow_comp =
id_node->find_component(DEG_NODE_TYPE_COPY_ON_WRITE);
cow_comp->tag_update(graph);
@@ -347,11 +350,11 @@ void deg_graph_id_tag_legacy_compat(Main *bmain,
}
}
-void deg_graph_id_tag_update_single_flag(Main *bmain,
- Depsgraph *graph,
- ID *id,
- IDDepsNode *id_node,
- eDepsgraph_Tag tag)
+static void deg_graph_id_tag_update_single_flag(Main *bmain,
+ Depsgraph *graph,
+ ID *id,
+ IDDepsNode *id_node,
+ eDepsgraph_Tag tag)
{
if (tag == DEG_TAG_EDITORS_UPDATE) {
if (graph != NULL) {
@@ -376,15 +379,6 @@ void deg_graph_id_tag_update_single_flag(Main *bmain,
DepsNodeFactory *factory = deg_type_get_factory(component_type);
BLI_assert(factory != NULL);
id->recalc |= factory->id_recalc_tag();
- /* NOTE: This way we clearly separate direct animation recalc flag from
- * a flushed one. Needed for auto-keyframe hack feature.
- *
- * TODO(sergey): Find a more generic way to set/access direct tagged ID
- * recalc flags.
- */
- if (tag == DEG_TAG_TIME) {
- id->recalc |= ID_RECALC_TIME;
- }
/* Some sanity checks before moving forward. */
if (id_node == NULL) {
/* Happens when object is tagged for update and not yet in the
@@ -438,6 +432,41 @@ string stringify_update_bitfield(int flag)
return result;
}
+/* Special tag function which tags all components which needs to be tagged
+ * for update flag=0.
+ *
+ * TODO(sergey): This is something to be avoid in the future, make it more
+ * explicit and granular for users to tag what they really need.
+ */
+void deg_graph_node_tag_zero(Main *bmain, Depsgraph *graph, IDDepsNode *id_node)
+{
+ if (id_node == NULL) {
+ return;
+ }
+ ID *id = id_node->id_orig;
+ /* TODO(sergey): Which recalc flags to set here? */
+ id->recalc |= ID_RECALC_ALL & ~(DEG_TAG_PSYS_ALL | ID_RECALC_ANIMATION);
+ GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, id_node->components)
+ {
+ if (comp_node->type == DEG_NODE_TYPE_ANIMATION) {
+ AnimData *adt = BKE_animdata_from_id(id);
+ /* NOTE: Animation data might be null if relations are tagged
+ * for update.
+ */
+ if (adt == NULL || (adt->recalc & ADT_RECALC_ANIM) == 0) {
+ /* If there is no animation, or animation is not tagged for
+ * update yet, we don't force animation channel to be evaluated.
+ */
+ continue;
+ }
+ id->recalc |= ID_RECALC_ANIMATION;
+ }
+ comp_node->tag_update(graph);
+ }
+ GHASH_FOREACH_END();
+ deg_graph_id_tag_legacy_compat(bmain, id, (eDepsgraph_Tag)0);
+}
+
void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag)
{
const int debug_flags = (graph != NULL)
@@ -453,12 +482,7 @@ void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag)
: NULL;
DEG_id_type_tag(bmain, GS(id->name));
if (flag == 0) {
- /* TODO(sergey): Which recalc flags to set here? */
- id->recalc |= ID_RECALC_ALL & ~DEG_TAG_PSYS_ALL;
- if (id_node != NULL) {
- id_node->tag_update(graph);
- }
- deg_graph_id_tag_legacy_compat(bmain, id, (eDepsgraph_Tag)0);
+ deg_graph_node_tag_zero(bmain, graph, id_node);
}
id->recalc |= (flag & PSYS_RECALC);
int current_flag = flag;
@@ -496,7 +520,7 @@ void deg_graph_on_visible_update(Main *bmain, Depsgraph *graph)
/* Make sure objects are up to date. */
foreach (DEG::IDDepsNode *id_node, graph->id_nodes) {
const ID_Type id_type = GS(id_node->id_orig->name);
- int flag = DEG_TAG_TIME | DEG_TAG_COPY_ON_WRITE;
+ int flag = DEG_TAG_COPY_ON_WRITE;
/* We only tag components which needs an update. Tagging everything is
* not a good idea because that might reset particles cache (or any
* other type of cache).
@@ -589,7 +613,20 @@ void DEG_id_type_tag(Main *bmain, short id_type)
DEG_id_type_tag(bmain, ID_SCE);
}
- bmain->id_tag_update[BKE_idcode_to_index(id_type)] = 1;
+ int id_type_index = BKE_idcode_to_index(id_type);
+
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scene) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
+ Depsgraph *depsgraph =
+ (Depsgraph *)BKE_scene_get_depsgraph(scene,
+ view_layer,
+ false);
+ if (depsgraph != NULL) {
+ DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
+ deg_graph->id_type_updated[id_type_index] = 1;
+ }
+ }
+ }
}
void DEG_graph_flush_update(Main *bmain, Depsgraph *depsgraph)
@@ -631,58 +668,62 @@ void DEG_ids_check_recalc(Main *bmain,
ViewLayer *view_layer,
bool time)
{
- ListBase *lbarray[MAX_LIBARRAY];
- int a;
- bool updated = false;
-
- /* Loop over all ID types. */
- a = set_listbasepointers(bmain, lbarray);
- while (a--) {
- ListBase *lb = lbarray[a];
- ID *id = (ID *)lb->first;
-
- if (id && bmain->id_tag_update[BKE_idcode_to_index(GS(id->name))]) {
- updated = true;
- break;
- }
- }
+ bool updated = time || DEG_id_type_any_updated(depsgraph);
DEGEditorUpdateContext update_ctx = {NULL};
update_ctx.bmain = bmain;
update_ctx.depsgraph = depsgraph;
update_ctx.scene = scene;
update_ctx.view_layer = view_layer;
- DEG::deg_editors_scene_update(&update_ctx, (updated || time));
+ DEG::deg_editors_scene_update(&update_ctx, updated);
}
-void DEG_ids_clear_recalc(Main *bmain)
+static void deg_graph_clear_id_node_func(
+ void *__restrict data_v,
+ const int i,
+ const ParallelRangeTLS *__restrict /*tls*/)
{
- ListBase *lbarray[MAX_LIBARRAY];
- bNodeTree *ntree;
- int a;
+ /* TODO: we clear original ID recalc flags here, but this may not work
+ * correctly when there are multiple depsgraph with others still using
+ * the recalc flag. */
+ DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(data_v);
+ DEG::IDDepsNode *id_node = deg_graph->id_nodes[i];
+ id_node->id_cow->recalc &= ~ID_RECALC_ALL;
+ id_node->id_orig->recalc &= ~ID_RECALC_ALL;
+
+ /* Clear embedded node trees too. */
+ bNodeTree *ntree_cow = ntreeFromID(id_node->id_cow);
+ if (ntree_cow) {
+ ntree_cow->id.recalc &= ~ID_RECALC_ALL;
+ }
+ bNodeTree *ntree_orig = ntreeFromID(id_node->id_orig);
+ if (ntree_orig) {
+ ntree_orig->id.recalc &= ~ID_RECALC_ALL;
+ }
+}
+
+void DEG_ids_clear_recalc(Main *UNUSED(bmain),
+ Depsgraph *depsgraph)
+{
+ DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
/* TODO(sergey): Re-implement POST_UPDATE_HANDLER_WORKAROUND using entry_tags
* and id_tags storage from the new dependency graph.
*/
- /* Loop over all ID types. */
- a = set_listbasepointers(bmain, lbarray);
- while (a--) {
- ListBase *lb = lbarray[a];
- ID *id = (ID *)lb->first;
-
- if (id && bmain->id_tag_update[BKE_idcode_to_index(GS(id->name))]) {
- for (; id; id = (ID *)id->next) {
- id->recalc &= ~ID_RECALC_ALL;
-
- /* Some ID's contain semi-datablock nodetree */
- ntree = ntreeFromID(id);
- if (ntree != NULL) {
- ntree->id.recalc &= ~ID_RECALC_ALL;
- }
- }
- }
+ if (!DEG_id_type_any_updated(depsgraph)) {
+ return;
}
- memset(bmain->id_tag_update, 0, sizeof(bmain->id_tag_update));
+ /* Go over all ID nodes nodes, clearing tags. */
+ const int num_id_nodes = deg_graph->id_nodes.size();
+ ParallelRangeSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ settings.min_iter_per_thread = 1024;
+ BLI_task_parallel_range(0, num_id_nodes,
+ deg_graph,
+ deg_graph_clear_id_node_func,
+ &settings);
+
+ memset(deg_graph->id_type_updated, 0, sizeof(deg_graph->id_type_updated));
}
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cc b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
index 19cc82a6b10..79d29f72b8d 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cc
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
@@ -138,6 +138,8 @@ const char *operationCodeAsString(eDepsOperation_Code opcode)
STRINGIFY_OPCODE(GEOMETRY_UBEREVAL);
STRINGIFY_OPCODE(GEOMETRY_CLOTH_MODIFIER);
STRINGIFY_OPCODE(GEOMETRY_SHAPEKEY);
+ /* Object data. */
+ STRINGIFY_OPCODE(LIGHT_PROBE_EVAL);
/* Pose. */
STRINGIFY_OPCODE(POSE_INIT);
STRINGIFY_OPCODE(POSE_INIT_IK);
diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h
index 14cd62e6cec..cec279a04bb 100644
--- a/source/blender/depsgraph/intern/depsgraph_types.h
+++ b/source/blender/depsgraph/intern/depsgraph_types.h
@@ -205,6 +205,9 @@ typedef enum eDepsOperation_Code {
DEG_OPCODE_GEOMETRY_CLOTH_MODIFIER,
DEG_OPCODE_GEOMETRY_SHAPEKEY,
+ /* Object data. ------------------------------------- */
+ DEG_OPCODE_LIGHT_PROBE_EVAL,
+
/* Pose. -------------------------------------------- */
/* Init pose, clear flags, etc. */
DEG_OPCODE_POSE_INIT,
@@ -269,7 +272,17 @@ typedef enum eDepsOperation_Code {
DEG_NUM_OPCODES,
} eDepsOperation_Code;
-
const char *operationCodeAsString(eDepsOperation_Code opcode);
+typedef enum eDepsNode_CollectionOwner {
+ /* Unknown owner of collection, collection is pulled directly, maybe
+ * via driver.
+ */
+ DEG_COLLECTION_OWNER_UNKNOWN,
+ /* Collection belongs to a scene. */
+ DEG_COLLECTION_OWNER_SCENE,
+ /* Collection is used by object, as a dupli-system. */
+ DEG_COLLECTION_OWNER_OBJECT,
+} eDepsNode_CollectionOwner;
+
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc
index 95084717dad..f911383b273 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -228,9 +228,6 @@ static void depsgraph_ensure_view_layer(Depsgraph *graph)
* - It was tagged for update of CoW component.
* This allows us to have proper view layer pointer.
*/
- if (!DEG_depsgraph_use_copy_on_write()) {
- return;
- }
Scene *scene_cow = graph->scene_cow;
if (!deg_copy_on_write_is_expanded(&scene_cow->id) ||
scene_cow->id.recalc & ID_RECALC_COPY_ON_WRITE)
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 0e8d4669108..0f49d57a826 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -510,6 +510,17 @@ void update_particle_system_orig_pointers(const Object *object_orig,
}
}
+void update_pose_orig_pointers(const bPose *pose_orig, bPose *pose_cow)
+{
+ bPoseChannel *pchan_cow = (bPoseChannel *) pose_cow->chanbase.first;
+ bPoseChannel *pchan_orig = (bPoseChannel *) pose_orig->chanbase.first;
+ while (pchan_orig != NULL) {
+ pchan_cow->orig_pchan = pchan_orig;
+ pchan_cow = pchan_cow->next;
+ pchan_orig = pchan_orig->next;
+ }
+}
+
/* Do some special treatment of data transfer from original ID to it's
* CoW complementary part.
*
@@ -527,13 +538,17 @@ void update_special_pointers(const Depsgraph *depsgraph,
*/
Object *object_cow = (Object *)id_cow;
const Object *object_orig = (const Object *)id_orig;
- (void) object_cow; /* Ignored for release builds. */
BLI_assert(object_cow->derivedFinal == NULL);
BLI_assert(object_cow->derivedDeform == NULL);
object_cow->mode = object_orig->mode;
+ object_cow->sculpt = object_orig->sculpt;
+ if (object_cow->type == OB_MESH) {
+ object_cow->runtime.mesh_orig = (Mesh *)object_cow->data;
+ }
if (object_cow->type == OB_ARMATURE) {
BKE_pose_remap_bone_pointers((bArmature *)object_cow->data,
object_cow->pose);
+ update_pose_orig_pointers(object_orig->pose, object_cow->pose);
}
update_particle_system_orig_pointers(object_orig, object_cow);
break;
@@ -542,6 +557,7 @@ void update_special_pointers(const Depsgraph *depsgraph,
break;
}
update_edit_mode_pointers(depsgraph, id_orig, id_cow);
+ BKE_animsys_update_driver_array(id_cow);
}
/* This callback is used to validate that all nested ID datablocks are
@@ -693,6 +709,77 @@ static void deg_update_copy_on_write_animation(const Depsgraph *depsgraph,
IDWALK_NOP);
}
+typedef struct ObjectRuntimeBackup {
+ CurveCache *curve_cache;
+ Object_Runtime runtime;
+ short base_flag;
+} ObjectRuntimeBackup;
+
+/* Make a backup of object's evaluation runtime data, additionally
+ * male object to be safe for free without invalidating backed up
+ * pointers.
+ */
+static void deg_backup_object_runtime(
+ Object *object,
+ ObjectRuntimeBackup *object_runtime_backup)
+{
+ /* Store evaluated mesh, and make sure we don't free it. */
+ Mesh *mesh_eval = object->runtime.mesh_eval;
+ object_runtime_backup->runtime = object->runtime;
+ BKE_object_runtime_reset(object);
+ /* Object update will override actual object->data to an evaluated version.
+ * Need to make sure we don't have data set to evaluated one before free
+ * anything.
+ */
+ if (mesh_eval != NULL && object->data == mesh_eval) {
+ object->data = object->runtime.mesh_orig;
+ }
+ /* Store curve cache and make sure we don't free it. */
+ object_runtime_backup->curve_cache = object->curve_cache;
+ object->curve_cache = NULL;
+ /* Make a backup of base flags. */
+ object_runtime_backup->base_flag = object->base_flag;
+}
+
+static void deg_restore_object_runtime(
+ Object *object,
+ const ObjectRuntimeBackup *object_runtime_backup)
+{
+ Mesh *mesh_orig = object->runtime.mesh_orig;
+ object->runtime = object_runtime_backup->runtime;
+ object->runtime.mesh_orig = mesh_orig;
+ if (object->runtime.mesh_eval != NULL) {
+ if (object->id.recalc & ID_RECALC_GEOMETRY) {
+ /* If geometry is tagged for update it means, that part of
+ * evaluated mesh are not valid anymore. In this case we can not
+ * have any "persistent" pointers to point to an invalid data.
+ *
+ * We restore object's data datablock to an original copy of
+ * that datablock.
+ */
+ object->data = mesh_orig;
+ }
+ else {
+ Mesh *mesh_eval = object->runtime.mesh_eval;
+ /* Do same thing as object update: override actual object data
+ * pointer with evaluated datablock.
+ */
+ if (object->type == OB_MESH) {
+ object->data = mesh_eval;
+ /* Evaluated mesh simply copied edit_btmesh pointer from
+ * original mesh during update, need to make sure no dead
+ * pointers are left behind.
+ */
+ mesh_eval->edit_btmesh = mesh_orig->edit_btmesh;
+ }
+ }
+ }
+ if (object_runtime_backup->curve_cache != NULL) {
+ object->curve_cache = object_runtime_backup->curve_cache;
+ }
+ object->base_flag = object_runtime_backup->base_flag;
+}
+
ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
const IDDepsNode *id_node)
{
@@ -714,11 +801,12 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
* Copy-on-Write components in a way that only needed parts are being
* copied over.
*/
+ /* TODO(sergey): Wrap GPU material backup and object runtime backup to a
+ * generic backup structure.
+ */
ListBase gpumaterial_backup;
ListBase *gpumaterial_ptr = NULL;
- Mesh *mesh_evaluated = NULL;
- CurveCache *curve_cache = NULL;
- short base_flag = 0;
+ ObjectRuntimeBackup object_runtime_backup = {NULL};
if (check_datablock_expanded(id_cow)) {
switch (id_type) {
case ID_MA:
@@ -753,28 +841,9 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
break;
}
case ID_OB:
- {
- Object *object = (Object *)id_cow;
- /* Store evaluated mesh, make sure we don't free it. */
- mesh_evaluated = object->mesh_evaluated;
- object->mesh_evaluated = NULL;
- /* Currently object update will override actual object->data
- * to an evaluated version. Need to make sure we don't have
- * data set to evaluated one before free anything.
- */
- if (mesh_evaluated != NULL) {
- if (object->data == mesh_evaluated) {
- object->data = mesh_evaluated->id.orig_id;
- }
- }
- /* Store curve cache and make sure we don't free it. */
- curve_cache = object->curve_cache;
- object->curve_cache = NULL;
-
- /* Make a backup of base flags. */
- base_flag = object->base_flag;
+ deg_backup_object_runtime((Object *)id_cow,
+ &object_runtime_backup);
break;
- }
default:
break;
}
@@ -790,26 +859,7 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
*gpumaterial_ptr = gpumaterial_backup;
}
if (id_type == ID_OB) {
- Object *object = (Object *)id_cow;
- if (mesh_evaluated != NULL) {
- object->mesh_evaluated = mesh_evaluated;
- /* Do same thing as object update: override actual object data
- * pointer with evaluated datablock.
- */
- if (object->type == OB_MESH) {
- object->data = mesh_evaluated;
- /* Evaluated mesh simply copied edit_btmesh pointer from
- * original mesh during update, need to make sure no dead
- * pointers are left behind.
- */
- mesh_evaluated->edit_btmesh =
- ((Mesh *)mesh_evaluated->id.orig_id)->edit_btmesh;
- }
- }
- if (curve_cache != NULL) {
- object->curve_cache = curve_cache;
- }
- object->base_flag = base_flag;
+ deg_restore_object_runtime((Object *)id_cow, &object_runtime_backup);
}
return id_cow;
}
@@ -916,6 +966,7 @@ void deg_free_copy_on_write_datablock(ID *id_cow)
*/
Object *ob_cow = (Object *)id_cow;
ob_cow->data = NULL;
+ ob_cow->sculpt = NULL;
break;
}
default:
@@ -960,8 +1011,8 @@ bool deg_validate_copy_on_write_datablock(ID *id_cow)
void deg_tag_copy_on_write_id(ID *id_cow, const ID *id_orig)
{
BLI_assert(id_cow != id_orig);
- BLI_assert((id_orig->tag & LIB_TAG_COPY_ON_WRITE) == 0);
- id_cow->tag |= LIB_TAG_COPY_ON_WRITE;
+ BLI_assert((id_orig->tag & LIB_TAG_COPIED_ON_WRITE) == 0);
+ id_cow->tag |= LIB_TAG_COPIED_ON_WRITE;
id_cow->orig_id = (ID *)id_orig;
}
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
index 02f10130fed..3330c802aa9 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -313,16 +313,6 @@ static void graph_clear_operation_func(
node->flag &= ~(DEPSOP_FLAG_DIRECTLY_MODIFIED | DEPSOP_FLAG_NEEDS_UPDATE);
}
-static void graph_clear_id_node_func(
- void *__restrict data_v,
- const int i,
- const ParallelRangeTLS *__restrict /*tls*/)
-{
- Depsgraph *graph = (Depsgraph *)data_v;
- IDDepsNode *id_node = graph->id_nodes[i];
- id_node->id_cow->recalc &= ~ID_RECALC_ALL;
-}
-
/* Clear tags from all operation nodes. */
void deg_graph_clear_tags(Depsgraph *graph)
{
@@ -337,17 +327,6 @@ void deg_graph_clear_tags(Depsgraph *graph)
graph_clear_operation_func,
&settings);
}
- /* Go over all ID nodes nodes, clearing tags. */
- {
- const int num_id_nodes = graph->id_nodes.size();
- ParallelRangeSettings settings;
- BLI_parallel_range_settings_defaults(&settings);
- settings.min_iter_per_thread = 1024;
- BLI_task_parallel_range(0, num_id_nodes,
- graph,
- graph_clear_id_node_func,
- &settings);
- }
/* Clear any entry tags which haven't been flushed. */
BLI_gset_clear(graph->entry_tags, NULL);
}
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.cc b/source/blender/depsgraph/intern/nodes/deg_node_component.cc
index 786faa6e86c..699ee1a3cad 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.cc
@@ -383,7 +383,7 @@ DEG_COMPONENT_NODE_DEFINE(Bone, BONE, ID_RECALC_GEOME
DEG_COMPONENT_NODE_DEFINE(Cache, CACHE, ID_RECALC);
DEG_COMPONENT_NODE_DEFINE(CopyOnWrite, COPY_ON_WRITE, ID_RECALC_COPY_ON_WRITE);
DEG_COMPONENT_NODE_DEFINE(Geometry, GEOMETRY, ID_RECALC_GEOMETRY);
-DEG_COMPONENT_NODE_DEFINE(LayerCollections, LAYER_COLLECTIONS, ID_RECALC_COLLECTIONS);
+DEG_COMPONENT_NODE_DEFINE(LayerCollections, LAYER_COLLECTIONS, 0);
DEG_COMPONENT_NODE_DEFINE(Parameters, PARAMETERS, ID_RECALC);
DEG_COMPONENT_NODE_DEFINE(Particles, EVAL_PARTICLES, ID_RECALC_GEOMETRY);
DEG_COMPONENT_NODE_DEFINE(Proxy, PROXY, ID_RECALC_GEOMETRY);
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_id.cc b/source/blender/depsgraph/intern/nodes/deg_node_id.cc
index 9f161db73ad..956c23978ab 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_id.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node_id.cc
@@ -112,14 +112,6 @@ void IDDepsNode::init(const ID *id, const char *UNUSED(subdata))
void IDDepsNode::init_copy_on_write(ID *id_cow_hint)
{
- /* Early output for non-copy-on-write case: we keep CoW pointer same as
- * an original one.
- */
- if (!DEG_depsgraph_use_copy_on_write()) {
- UNUSED_VARS(id_cow_hint);
- id_cow = id_orig;
- return;
- }
/* Create pointer as early as possible, so we can use it for function
* bindings. Rest of data we'll be copying to the new datablock when
* it is actually needed.
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_time.cc b/source/blender/depsgraph/intern/nodes/deg_node_time.cc
index 7b871d6d42b..1295af666bf 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_time.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node_time.cc
@@ -39,7 +39,6 @@ namespace DEG {
void TimeSourceDepsNode::tag_update(Depsgraph *graph)
{
- graph->scene_cow->id.recalc |= ID_RECALC_TIME;
foreach (DepsRelation *rel, outlinks) {
DepsNode *node = rel->to;
node->tag_update(graph);
diff --git a/source/blender/depsgraph/util/deg_util_function.h b/source/blender/depsgraph/util/deg_util_function.h
index 41669919c99..e91986d54ba 100644
--- a/source/blender/depsgraph/util/deg_util_function.h
+++ b/source/blender/depsgraph/util/deg_util_function.h
@@ -19,7 +19,7 @@
* All rights reserved.
*
* Original Author: Lukas Toenne
- * Contributor(s):
+ * Contributor(s):
*
* ***** END GPL LICENSE BLOCK *****
*/
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 965faa7ba53..7d869982f29 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -53,6 +53,7 @@ set(INC_SYS
)
set(SRC
+ intern/draw_anim_viz.c
intern/draw_armature.c
intern/draw_cache.c
intern/draw_cache_impl_curve.c
@@ -63,6 +64,7 @@ set(SRC
intern/draw_cache_impl_particles.c
intern/draw_common.c
intern/draw_debug.c
+ intern/draw_hair.c
intern/draw_instance_data.c
intern/draw_manager.c
intern/draw_manager_data.c
@@ -123,6 +125,7 @@ set(SRC
intern/draw_cache_impl.h
intern/draw_common.h
intern/draw_debug.h
+ intern/draw_hair_private.h
intern/draw_instance_data.h
intern/draw_manager.h
intern/draw_manager_text.h
@@ -198,7 +201,6 @@ data_to_c_simple(engines/eevee/shaders/shadow_store_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/shadow_copy_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/bsdf_lut_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/btdf_lut_frag.glsl SRC)
-data_to_c_simple(engines/eevee/shaders/bsdf_direct_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/bsdf_common_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/irradiance_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/octahedron_lib.glsl SRC)
@@ -216,6 +218,8 @@ data_to_c_simple(engines/eevee/shaders/volumetric_scatter_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/volumetric_integration_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_background_lib.glsl SRC)
+data_to_c_simple(engines/workbench/shaders/workbench_cavity_lib.glsl SRC)
+data_to_c_simple(engines/workbench/shaders/workbench_cavity_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_checkerboard_depth_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_common_lib.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_data_lib.glsl SRC)
@@ -223,7 +227,6 @@ data_to_c_simple(engines/workbench/shaders/workbench_deferred_composite_frag.gls
data_to_c_simple(engines/workbench/shaders/workbench_forward_composite_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_forward_depth_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl SRC)
-data_to_c_simple(engines/workbench/shaders/workbench_forward_transparent_revealage_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_object_outline_lib.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_prepass_vert.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_prepass_frag.glsl SRC)
@@ -234,9 +237,14 @@ data_to_c_simple(engines/workbench/shaders/workbench_shadow_debug_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_world_light_lib.glsl SRC)
data_to_c_simple(modes/shaders/common_globals_lib.glsl SRC)
+data_to_c_simple(modes/shaders/common_hair_lib.glsl SRC)
+data_to_c_simple(modes/shaders/common_hair_refine_vert.glsl SRC)
data_to_c_simple(modes/shaders/common_view_lib.glsl SRC)
data_to_c_simple(modes/shaders/common_fxaa_lib.glsl SRC)
data_to_c_simple(modes/shaders/common_fullscreen_vert.glsl SRC)
+data_to_c_simple(modes/shaders/animviz_mpath_lines_vert.glsl SRC)
+data_to_c_simple(modes/shaders/animviz_mpath_lines_geom.glsl SRC)
+data_to_c_simple(modes/shaders/animviz_mpath_points_vert.glsl SRC)
data_to_c_simple(modes/shaders/armature_axes_vert.glsl SRC)
data_to_c_simple(modes/shaders/armature_sphere_solid_vert.glsl SRC)
data_to_c_simple(modes/shaders/armature_sphere_solid_frag.glsl SRC)
@@ -270,11 +278,16 @@ data_to_c_simple(modes/shaders/edit_normals_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_normals_geom.glsl SRC)
data_to_c_simple(modes/shaders/overlay_face_orientation_frag.glsl SRC)
data_to_c_simple(modes/shaders/overlay_face_orientation_vert.glsl SRC)
+data_to_c_simple(modes/shaders/overlay_face_wireframe_vert.glsl SRC)
+data_to_c_simple(modes/shaders/overlay_face_wireframe_geom.glsl SRC)
+data_to_c_simple(modes/shaders/overlay_face_wireframe_frag.glsl SRC)
data_to_c_simple(modes/shaders/object_empty_image_frag.glsl SRC)
data_to_c_simple(modes/shaders/object_empty_image_vert.glsl SRC)
data_to_c_simple(modes/shaders/object_outline_resolve_frag.glsl SRC)
data_to_c_simple(modes/shaders/object_outline_expand_frag.glsl SRC)
data_to_c_simple(modes/shaders/object_outline_detect_frag.glsl SRC)
+data_to_c_simple(modes/shaders/object_outline_prepass_vert.glsl SRC)
+data_to_c_simple(modes/shaders/object_outline_prepass_geom.glsl SRC)
data_to_c_simple(modes/shaders/object_outline_prepass_frag.glsl SRC)
data_to_c_simple(modes/shaders/object_grid_frag.glsl SRC)
data_to_c_simple(modes/shaders/object_grid_vert.glsl SRC)
diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c
index c86574f7557..2c771578514 100644
--- a/source/blender/draw/engines/basic/basic_engine.c
+++ b/source/blender/draw/engines/basic/basic_engine.c
@@ -155,7 +155,7 @@ static void basic_cache_populate(void *vedata, Object *ob)
continue;
}
if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
- return;
+ continue;
}
ParticleSettings *part = psys->part;
const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
diff --git a/source/blender/draw/engines/clay/clay_engine.c b/source/blender/draw/engines/clay/clay_engine.c
index d08fee6039f..5d3717097b1 100644
--- a/source/blender/draw/engines/clay/clay_engine.c
+++ b/source/blender/draw/engines/clay/clay_engine.c
@@ -838,7 +838,7 @@ static void clay_cache_populate_particles(void *vedata, Object *ob)
continue;
}
if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
- return;
+ continue;
}
ParticleSettings *part = psys->part;
const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c
index 211a8abd42c..d7a978066d5 100644
--- a/source/blender/draw/engines/eevee/eevee_effects.c
+++ b/source/blender/draw/engines/eevee/eevee_effects.c
@@ -511,10 +511,13 @@ void EEVEE_draw_effects(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
/* Save the final texture and framebuffer for final transformation or read. */
effects->final_tx = effects->source_buffer;
effects->final_fb = (effects->target_buffer != fbl->main_color_fb) ? fbl->main_fb : fbl->effect_fb;
- if ((effects->enabled_effects & EFFECT_TAA) && (effects->enabled_effects & (EFFECT_BLOOM | EFFECT_DOF | EFFECT_MOTION_BLUR)) == 0) {
+ if ((effects->enabled_effects & EFFECT_TAA) &&
+ (effects->enabled_effects & (EFFECT_BLOOM | EFFECT_DOF | EFFECT_MOTION_BLUR)) == 0)
+ {
if (!effects->swap_double_buffer) {
effects->final_fb = fbl->double_buffer_fb;
- } else {
+ }
+ else {
effects->final_fb = fbl->main_fb;
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index f6776d43665..d7c6684f086 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -129,35 +129,40 @@ static void eevee_cache_populate(void *vedata, Object *ob)
const DRWContextState *draw_ctx = DRW_context_state_get();
const bool is_active = (ob == draw_ctx->obact);
+ bool cast_shadow = false;
+
if (is_active) {
if (DRW_object_is_mode_shade(ob) == true) {
return;
}
}
- if (DRW_check_object_visible_within_active_context(ob) == false) {
- return;
+ if (ob->base_flag & BASE_VISIBLED) {
+ EEVEE_hair_cache_populate(vedata, sldata, ob, &cast_shadow);
}
- if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) {
- bool cast_shadow;
-
- EEVEE_materials_cache_populate(vedata, sldata, ob, &cast_shadow);
-
- if (cast_shadow) {
- EEVEE_lights_cache_shcaster_object_add(sldata, ob);
+ if (DRW_check_object_visible_within_active_context(ob)) {
+ if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) {
+ EEVEE_materials_cache_populate(vedata, sldata, ob, &cast_shadow);
}
- }
- else if (ob->type == OB_LIGHTPROBE) {
- if ((ob->base_flag & BASE_FROMDUPLI) != 0) {
- /* TODO: Special case for dupli objects because we cannot save the object pointer. */
+ else if (!USE_SCENE_LIGHT(draw_ctx->v3d)) {
+ /* do not add any scene light sources to the cache */
}
- else {
- EEVEE_lightprobes_cache_add(sldata, ob);
+ else if (ob->type == OB_LIGHTPROBE) {
+ if ((ob->base_flag & BASE_FROMDUPLI) != 0) {
+ /* TODO: Special case for dupli objects because we cannot save the object pointer. */
+ }
+ else {
+ EEVEE_lightprobes_cache_add(sldata, ob);
+ }
+ }
+ else if (ob->type == OB_LAMP) {
+ EEVEE_lights_cache_add(sldata, ob);
}
}
- else if (ob->type == OB_LAMP) {
- EEVEE_lights_cache_add(sldata, ob);
+
+ if (cast_shadow) {
+ EEVEE_lights_cache_shcaster_object_add(sldata, ob);
}
}
@@ -187,6 +192,7 @@ static void eevee_draw_background(void *vedata)
/* Default framebuffer and texture */
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
+
/* Sort transparents before the loop. */
DRW_pass_sort_shgroup_z(psl->transparent_pass);
@@ -312,7 +318,7 @@ static void eevee_draw_background(void *vedata)
/* LookDev */
EEVEE_lookdev_draw_background(vedata);
/* END */
-
+
/* Tonemapping and transfer result to default framebuffer. */
GPU_framebuffer_bind(dfbl->default_fb);
@@ -367,20 +373,18 @@ static void eevee_view_update(void *vedata)
static void eevee_id_object_update(void *UNUSED(vedata), Object *object)
{
/* This is a bit mask of components which update is to be ignored. */
- const int ignore_updates = ID_RECALC_COLLECTIONS;
- const int allowed_updates = ~ignore_updates;
EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_get(object);
- if (ped != NULL && (ped->engine_data.recalc & allowed_updates) != 0) {
+ if (ped != NULL && ped->engine_data.recalc != 0) {
ped->need_full_update = true;
ped->engine_data.recalc = 0;
}
EEVEE_LampEngineData *led = EEVEE_lamp_data_get(object);
- if (led != NULL && (led->engine_data.recalc & allowed_updates) != 0) {
+ if (led != NULL && led->engine_data.recalc != 0) {
led->need_update = true;
led->engine_data.recalc = 0;
}
EEVEE_ObjectEngineData *oedata = EEVEE_object_data_get(object);
- if (oedata != NULL && (oedata->engine_data.recalc & allowed_updates) != 0) {
+ if (oedata != NULL && oedata->engine_data.recalc != 0) {
oedata->need_update = true;
oedata->engine_data.recalc = 0;
}
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index c7a2951a670..a45d69794f3 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -417,7 +417,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
float *col = ts.colorBackground;
/* LookDev */
- EEVEE_lookdev_cache_init(vedata, &grp, e_data.probe_default_studiolight_sh, psl->probe_background, pinfo);
+ EEVEE_lookdev_cache_init(vedata, &grp, e_data.probe_default_studiolight_sh, psl->probe_background, wo, pinfo);
/* END */
if (!grp && wo) {
col = &wo->horr;
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index dd69e19e7c1..f5673d1a616 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -40,7 +40,9 @@
static struct {
struct GPUShader *shadow_sh;
struct GPUShader *shadow_store_cube_sh[SHADOW_METHOD_MAX];
+ struct GPUShader *shadow_store_cube_high_sh[SHADOW_METHOD_MAX];
struct GPUShader *shadow_store_cascade_sh[SHADOW_METHOD_MAX];
+ struct GPUShader *shadow_store_cascade_high_sh[SHADOW_METHOD_MAX];
struct GPUShader *shadow_copy_cube_sh[SHADOW_METHOD_MAX];
struct GPUShader *shadow_copy_cascade_sh[SHADOW_METHOD_MAX];
} e_data = {NULL}; /* Engine data */
@@ -172,22 +174,7 @@ void EEVEE_lights_init(EEVEE_ViewLayerData *sldata)
linfo->shadow_cascade_size = sh_cascade_size;
/* only compile the ones needed. reduce startup time. */
- if ((sh_method == SHADOW_ESM) && !e_data.shadow_store_cube_sh[SHADOW_ESM]) {
- DynStr *ds_frag = BLI_dynstr_new();
- BLI_dynstr_append(ds_frag, datatoc_concentric_samples_lib_glsl);
- BLI_dynstr_append(ds_frag, datatoc_shadow_store_frag_glsl);
- char *store_shadow_shader_str = BLI_dynstr_get_cstring(ds_frag);
- BLI_dynstr_free(ds_frag);
-
- e_data.shadow_store_cube_sh[SHADOW_ESM] = DRW_shader_create_fullscreen(
- store_shadow_shader_str,
- "#define ESM\n");
- e_data.shadow_store_cascade_sh[SHADOW_ESM] = DRW_shader_create_fullscreen(
- store_shadow_shader_str,
- "#define ESM\n"
- "#define CSM\n");
- MEM_freeN(store_shadow_shader_str);
-
+ if ((sh_method == SHADOW_ESM) && !e_data.shadow_copy_cube_sh[SHADOW_ESM]) {
e_data.shadow_copy_cube_sh[SHADOW_ESM] = DRW_shader_create_fullscreen(
datatoc_shadow_copy_frag_glsl,
"#define ESM\n"
@@ -198,22 +185,7 @@ void EEVEE_lights_init(EEVEE_ViewLayerData *sldata)
"#define COPY\n"
"#define CSM\n");
}
- else if ((sh_method == SHADOW_VSM) && !e_data.shadow_store_cube_sh[SHADOW_VSM]) {
- DynStr *ds_frag = BLI_dynstr_new();
- BLI_dynstr_append(ds_frag, datatoc_concentric_samples_lib_glsl);
- BLI_dynstr_append(ds_frag, datatoc_shadow_store_frag_glsl);
- char *store_shadow_shader_str = BLI_dynstr_get_cstring(ds_frag);
- BLI_dynstr_free(ds_frag);
-
- e_data.shadow_store_cube_sh[SHADOW_VSM] = DRW_shader_create_fullscreen(
- store_shadow_shader_str,
- "#define VSM\n");
- e_data.shadow_store_cascade_sh[SHADOW_VSM] = DRW_shader_create_fullscreen(
- store_shadow_shader_str,
- "#define VSM\n"
- "#define CSM\n");
- MEM_freeN(store_shadow_shader_str);
-
+ else if ((sh_method == SHADOW_VSM) && !e_data.shadow_copy_cube_sh[SHADOW_VSM]) {
e_data.shadow_copy_cube_sh[SHADOW_VSM] = DRW_shader_create_fullscreen(
datatoc_shadow_copy_frag_glsl,
"#define VSM\n"
@@ -226,6 +198,78 @@ void EEVEE_lights_init(EEVEE_ViewLayerData *sldata)
}
}
+static GPUShader *eevee_lights_get_store_sh(int shadow_method, bool high_blur, bool cascade)
+{
+ GPUShader **shader;
+
+ if (cascade) {
+ shader = (high_blur) ? &e_data.shadow_store_cascade_high_sh[shadow_method]
+ : &e_data.shadow_store_cascade_sh[shadow_method];
+ }
+ else {
+ shader = (high_blur) ? &e_data.shadow_store_cube_high_sh[shadow_method]
+ : &e_data.shadow_store_cube_sh[shadow_method];
+ }
+
+ if (*shader == NULL) {
+ DynStr *ds_frag = BLI_dynstr_new();
+ BLI_dynstr_append(ds_frag, datatoc_concentric_samples_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_shadow_store_frag_glsl);
+ char *store_shadow_shader_str = BLI_dynstr_get_cstring(ds_frag);
+ BLI_dynstr_free(ds_frag);
+
+ ds_frag = BLI_dynstr_new();
+ BLI_dynstr_append(ds_frag, (shadow_method == SHADOW_VSM) ? "#define VSM\n" : "#define ESM\n");
+ if (high_blur) BLI_dynstr_append(ds_frag, "#define HIGH_BLUR\n");
+ if (cascade) BLI_dynstr_append(ds_frag, "#define CSM\n");
+ char *define_str = BLI_dynstr_get_cstring(ds_frag);
+ BLI_dynstr_free(ds_frag);
+
+ *shader = DRW_shader_create_fullscreen(
+ store_shadow_shader_str, define_str);
+
+ MEM_freeN(store_shadow_shader_str);
+ MEM_freeN(define_str);
+ }
+
+ return *shader;
+}
+
+static DRWPass *eevee_lights_cube_store_pass_get(EEVEE_PassList *psl, EEVEE_ViewLayerData *sldata, int shadow_method, int shadow_samples_ct)
+{
+ bool high_blur = shadow_samples_ct > 16;
+ DRWPass **pass = (high_blur) ? &psl->shadow_cube_store_pass : &psl->shadow_cube_store_high_pass;
+ if (*pass == NULL) {
+ EEVEE_LampsInfo *linfo = sldata->lamps;
+ *pass = DRW_pass_create("Shadow Cube Storage Pass", DRW_STATE_WRITE_COLOR);
+ GPUShader *shader = eevee_lights_get_store_sh(shadow_method, high_blur, false);
+ DRWShadingGroup *grp = DRW_shgroup_create(shader, *pass);
+ DRW_shgroup_uniform_texture_ref(grp, "shadowTexture", &sldata->shadow_cube_blur);
+ DRW_shgroup_uniform_block(grp, "shadow_render_block", sldata->shadow_render_ubo);
+ DRW_shgroup_uniform_float(grp, "shadowFilterSize", &linfo->filter_size, 1);
+ DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
+ }
+ return *pass;
+}
+
+static DRWPass *eevee_lights_cascade_store_pass_get(EEVEE_PassList *psl, EEVEE_ViewLayerData *sldata, int shadow_method, int shadow_samples_ct)
+{
+ bool high_blur = shadow_samples_ct > 16;
+ DRWPass **pass = (high_blur) ? &psl->shadow_cascade_store_pass : &psl->shadow_cascade_store_high_pass;
+ if (*pass == NULL) {
+ EEVEE_LampsInfo *linfo = sldata->lamps;
+ *pass = DRW_pass_create("Shadow Cascade Storage Pass", DRW_STATE_WRITE_COLOR);
+ GPUShader *shader = eevee_lights_get_store_sh(shadow_method, high_blur, true);
+ DRWShadingGroup *grp = DRW_shgroup_create(shader, *pass);
+ DRW_shgroup_uniform_texture_ref(grp, "shadowTexture", &sldata->shadow_cascade_blur);
+ DRW_shgroup_uniform_block(grp, "shadow_render_block", sldata->shadow_render_ubo);
+ DRW_shgroup_uniform_int(grp, "cascadeId", &linfo->current_shadow_cascade, 1);
+ DRW_shgroup_uniform_float(grp, "shadowFilterSize", &linfo->filter_size, 1);
+ DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
+ }
+ return *pass;
+}
+
void EEVEE_lights_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
{
EEVEE_LampsInfo *linfo = sldata->lamps;
@@ -247,28 +291,10 @@ void EEVEE_lights_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
memset(linfo->shcaster_backbuffer->flags, (char)SHADOW_CASTER_PRUNED, linfo->shcaster_backbuffer->alloc_count);
memset(linfo->shcaster_frontbuffer->flags, 0x00, linfo->shcaster_frontbuffer->alloc_count);
- {
- psl->shadow_cube_store_pass = DRW_pass_create("Shadow Storage Pass", DRW_STATE_WRITE_COLOR);
-
- DRWShadingGroup *grp = DRW_shgroup_create(
- e_data.shadow_store_cube_sh[linfo->shadow_method], psl->shadow_cube_store_pass);
- DRW_shgroup_uniform_texture_ref(grp, "shadowTexture", &sldata->shadow_cube_blur);
- DRW_shgroup_uniform_block(grp, "shadow_render_block", sldata->shadow_render_ubo);
- DRW_shgroup_uniform_float(grp, "shadowFilterSize", &linfo->filter_size, 1);
- DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
- }
-
- {
- psl->shadow_cascade_store_pass = DRW_pass_create("Shadow Cascade Storage Pass", DRW_STATE_WRITE_COLOR);
-
- DRWShadingGroup *grp = DRW_shgroup_create(
- e_data.shadow_store_cascade_sh[linfo->shadow_method], psl->shadow_cascade_store_pass);
- DRW_shgroup_uniform_texture_ref(grp, "shadowTexture", &sldata->shadow_cascade_blur);
- DRW_shgroup_uniform_block(grp, "shadow_render_block", sldata->shadow_render_ubo);
- DRW_shgroup_uniform_int(grp, "cascadeId", &linfo->current_shadow_cascade, 1);
- DRW_shgroup_uniform_float(grp, "shadowFilterSize", &linfo->filter_size, 1);
- DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
- }
+ psl->shadow_cube_store_pass = NULL;
+ psl->shadow_cube_store_high_pass = NULL;
+ psl->shadow_cascade_store_pass = NULL;
+ psl->shadow_cascade_store_high_pass = NULL;
{
psl->shadow_cube_copy_pass = DRW_pass_create("Shadow Copy Pass", DRW_STATE_WRITE_COLOR);
@@ -1124,7 +1150,9 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl)
GPU_framebuffer_texture_layer_attach(sldata->shadow_cube_store_fb, sldata->shadow_cube_pool, 0, evscd->layer_id, 0);
GPU_framebuffer_bind(sldata->shadow_cube_store_fb);
- DRW_draw_pass(psl->shadow_cube_store_pass);
+
+ DRWPass *store_pass = eevee_lights_cube_store_pass_get(psl, sldata, linfo->shadow_method, srd->shadow_samples_ct);
+ DRW_draw_pass(store_pass);
led->need_update = false;
}
@@ -1224,7 +1252,9 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl)
int layer = evscd->layer_id + linfo->current_shadow_cascade;
GPU_framebuffer_texture_layer_attach(sldata->shadow_cascade_store_fb, sldata->shadow_cascade_pool, 0, layer, 0);
GPU_framebuffer_bind(sldata->shadow_cascade_store_fb);
- DRW_draw_pass(psl->shadow_cascade_store_pass);
+
+ DRWPass *store_pass = eevee_lights_cascade_store_pass_get(psl, sldata, linfo->shadow_method, srd->shadow_samples_ct);
+ DRW_draw_pass(store_pass);
}
}
@@ -1241,7 +1271,9 @@ void EEVEE_lights_free(void)
DRW_SHADER_FREE_SAFE(e_data.shadow_sh);
for (int i = 0; i < SHADOW_METHOD_MAX; ++i) {
DRW_SHADER_FREE_SAFE(e_data.shadow_store_cube_sh[i]);
+ DRW_SHADER_FREE_SAFE(e_data.shadow_store_cube_high_sh[i]);
DRW_SHADER_FREE_SAFE(e_data.shadow_store_cascade_sh[i]);
+ DRW_SHADER_FREE_SAFE(e_data.shadow_store_cascade_high_sh[i]);
DRW_SHADER_FREE_SAFE(e_data.shadow_copy_cube_sh[i]);
DRW_SHADER_FREE_SAFE(e_data.shadow_copy_cascade_sh[i]);
}
diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c
index 4ae13669a01..5c626b42ddd 100644
--- a/source/blender/draw/engines/eevee/eevee_lookdev.c
+++ b/source/blender/draw/engines/eevee/eevee_lookdev.c
@@ -28,33 +28,52 @@
#include "BKE_studiolight.h"
#include "DNA_screen_types.h"
+#include "DNA_world_types.h"
+
+#include "ED_screen.h"
#include "eevee_private.h"
-void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, DRWShadingGroup **grp, GPUShader *shader, DRWPass *pass, EEVEE_LightProbesInfo *pinfo)
+void EEVEE_lookdev_cache_init(
+ EEVEE_Data *vedata, DRWShadingGroup **grp, GPUShader *shader, DRWPass *pass,
+ World *world, EEVEE_LightProbesInfo *pinfo)
{
EEVEE_StorageList *stl = vedata->stl;
const DRWContextState *draw_ctx = DRW_context_state_get();
View3D *v3d = draw_ctx->v3d;
- if (v3d && v3d->drawtype == OB_MATERIAL)
- {
- StudioLight *sl = BKE_studiolight_find(v3d->shading.studio_light, STUDIOLIGHT_ORIENTATION_WORLD);
+ if (LOOK_DEV_MODE_ENABLED(v3d)) {
+ StudioLight *sl = BKE_studiolight_find(v3d->shading.studio_light, STUDIOLIGHT_INTERNAL | STUDIOLIGHT_ORIENTATION_WORLD);
if ((sl->flag & STUDIOLIGHT_ORIENTATION_WORLD)) {
struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
+ GPUTexture *tex;
- BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECTANGULAR_GPUTEXTURE);
*grp = DRW_shgroup_create(shader, pass);
- GPUTexture *tex = sl->equirectangular_gputexture;
- DRW_shgroup_uniform_texture(*grp, "image", tex);
-
axis_angle_to_mat3_single(stl->g_data->studiolight_matrix, 'Z', v3d->shading.studiolight_rot_z);
DRW_shgroup_uniform_mat3(*grp, "StudioLightMatrix", stl->g_data->studiolight_matrix);
+ if (world) {
+ DRW_shgroup_uniform_vec3(*grp, "color", &world->horr, 1);
+ }
DRW_shgroup_uniform_float(*grp, "backgroundAlpha", &stl->g_data->background_alpha, 1);
DRW_shgroup_call_add(*grp, geom, NULL);
+ if (!pinfo) {
+ /* Do not fadeout when doing probe rendering, only when drawing the background */
+ DRW_shgroup_uniform_float(*grp, "studioLightBackground", &v3d->shading.studiolight_background, 1);
+
+ BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECTANGULAR_IRRADIANCE_GPUTEXTURE);
+ tex = sl->equirectangular_irradiance_gputexture;
+ }
+ else {
+ BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECTANGULAR_RADIANCE_GPUTEXTURE);
+ tex = sl->equirectangular_radiance_gputexture;
+ }
+ DRW_shgroup_uniform_texture(*grp, "image", tex);
/* Do we need to recalc the lightprobes? */
- if (pinfo && (pinfo->studiolight_index != sl->index || pinfo->studiolight_rot_z != v3d->shading.studiolight_rot_z)) {
+ if (pinfo &&
+ ((pinfo->studiolight_index != sl->index) ||
+ (pinfo->studiolight_rot_z != v3d->shading.studiolight_rot_z)))
+ {
pinfo->update_world |= PROBE_UPDATE_ALL;
pinfo->studiolight_index = sl->index;
pinfo->studiolight_rot_z = v3d->shading.studiolight_rot_z;
@@ -71,10 +90,11 @@ void EEVEE_lookdev_draw_background(EEVEE_Data *vedata)
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
EEVEE_EffectsInfo *effects = stl->effects;
EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
-
+ DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
+
const DRWContextState *draw_ctx = DRW_context_state_get();
- if (psl->lookdev_pass && draw_ctx->v3d) {
+ if (psl->lookdev_pass && LOOK_DEV_OVERLAY_ENABLED(draw_ctx->v3d)) {
DRW_stats_group_start("Look Dev");
CameraParams params;
BKE_camera_params_init(&params);
@@ -84,14 +104,22 @@ void EEVEE_lookdev_draw_background(EEVEE_Data *vedata)
BKE_camera_params_from_view3d(&params, draw_ctx->depsgraph, v3d, rv3d);
params.is_ortho = true;
- params.ortho_scale = 4.0;
+ params.ortho_scale = 3.0f;
params.zoom = CAMERA_PARAM_ZOOM_INIT_PERSP;
+ params.offsetx = 0.0f;
+ params.offsety = 0.0f;
+ params.shiftx = 0.0f;
+ params.shifty = 0.0f;
+ params.clipsta = 0.001f;
+ params.clipend = 20.0f;
BKE_camera_params_compute_viewplane(&params, ar->winx, ar->winy, 1.0f, 1.0f);
BKE_camera_params_compute_matrix(&params);
const float *viewport_size = DRW_viewport_size_get();
- int viewport_inset_x = viewport_size[0]/4;
- int viewport_inset_y = viewport_size[1]/4;
+ rcti rect;
+ ED_region_visible_rect(draw_ctx->ar, &rect);
+ int viewport_inset_x = viewport_size[0] / 4;
+ int viewport_inset_y = viewport_size[1] / 4;
EEVEE_CommonUniformBuffer *common = &sldata->common_data;
common->la_num_light = 0;
@@ -121,10 +149,15 @@ void EEVEE_lookdev_draw_background(EEVEE_Data *vedata)
GPUFrameBuffer *fb = effects->final_fb;
GPU_framebuffer_bind(fb);
- GPU_framebuffer_viewport_set(fb, viewport_size[0]-viewport_inset_x, 0, viewport_inset_x, viewport_inset_y);
+ GPU_framebuffer_viewport_set(fb, rect.xmax - viewport_inset_x, 0, viewport_inset_x, viewport_inset_y);
+ DRW_draw_pass(psl->lookdev_pass);
+
+ fb = dfbl->depth_only_fb;
+ GPU_framebuffer_bind(fb);
+ GPU_framebuffer_viewport_set(fb, rect.xmax - viewport_inset_x, 0, viewport_inset_x, viewport_inset_y);
DRW_draw_pass(psl->lookdev_pass);
DRW_viewport_matrix_override_unset_all();
DRW_stats_group_end();
}
-} \ No newline at end of file
+}
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 1134c82954c..1a5c26f1c31 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -49,10 +49,13 @@
/* *********** STATIC *********** */
static struct {
char *frag_shader_lib;
+ char *vert_shader_str;
char *volume_shader_lib;
struct GPUShader *default_prepass_sh;
struct GPUShader *default_prepass_clip_sh;
+ struct GPUShader *default_hair_prepass_sh;
+ struct GPUShader *default_hair_prepass_clip_sh;
struct GPUShader *default_lit[VAR_MAT_MAX];
struct GPUShader *default_background;
struct GPUShader *default_studiolight_background;
@@ -80,9 +83,9 @@ extern char datatoc_ltc_lib_glsl[];
extern char datatoc_bsdf_lut_frag_glsl[];
extern char datatoc_btdf_lut_frag_glsl[];
extern char datatoc_bsdf_common_lib_glsl[];
-extern char datatoc_bsdf_direct_lib_glsl[];
extern char datatoc_bsdf_sampling_lib_glsl[];
extern char datatoc_common_uniforms_lib_glsl[];
+extern char datatoc_common_hair_lib_glsl[];
extern char datatoc_common_view_lib_glsl[];
extern char datatoc_irradiance_lib_glsl[];
extern char datatoc_octahedron_lib_glsl[];
@@ -100,6 +103,8 @@ extern char datatoc_volumetric_geom_glsl[];
extern char datatoc_volumetric_frag_glsl[];
extern char datatoc_volumetric_lib_glsl[];
+extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
+
extern Material defmaterial;
extern GlobalsUboStorage ts;
@@ -421,7 +426,7 @@ static void create_default_shader(int options)
char *defines = eevee_get_defines(options);
- e_data.default_lit[options] = DRW_shader_create(datatoc_lit_surface_vert_glsl, NULL, frag_str, defines);
+ e_data.default_lit[options] = DRW_shader_create(e_data.vert_shader_str, NULL, frag_str, defines);
MEM_freeN(defines);
MEM_freeN(frag_str);
@@ -533,8 +538,6 @@ static void EEVEE_update_viewvecs(float invproj[4][4], float winmat[4][4], float
void EEVEE_materials_init(EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, EEVEE_FramebufferList *fbl)
{
if (!e_data.frag_shader_lib) {
- char *frag_str = NULL;
-
/* Shaders */
e_data.frag_shader_lib = BLI_string_joinN(
datatoc_common_view_lib_glsl,
@@ -548,7 +551,6 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, E
datatoc_irradiance_lib_glsl,
datatoc_lightprobe_lib_glsl,
datatoc_ltc_lib_glsl,
- datatoc_bsdf_direct_lib_glsl,
datatoc_lamps_lib_glsl,
/* Add one for each Closure */
datatoc_lit_surface_frag_glsl,
@@ -570,14 +572,14 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, E
datatoc_irradiance_lib_glsl,
datatoc_lightprobe_lib_glsl,
datatoc_ltc_lib_glsl,
- datatoc_bsdf_direct_lib_glsl,
datatoc_lamps_lib_glsl,
datatoc_volumetric_lib_glsl,
datatoc_volumetric_frag_glsl);
- frag_str = BLI_string_joinN(
- e_data.frag_shader_lib,
- datatoc_default_frag_glsl);
+ e_data.vert_shader_str = BLI_string_joinN(
+ datatoc_common_view_lib_glsl,
+ datatoc_common_hair_lib_glsl,
+ datatoc_lit_surface_vert_glsl);
e_data.default_background = DRW_shader_create(
datatoc_background_vert_glsl, NULL, datatoc_default_world_frag_glsl,
@@ -595,7 +597,21 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, E
datatoc_prepass_vert_glsl, NULL, datatoc_prepass_frag_glsl,
"#define CLIP_PLANES\n");
- MEM_freeN(frag_str);
+ char *vert_str = BLI_string_joinN(
+ datatoc_common_view_lib_glsl,
+ datatoc_common_hair_lib_glsl,
+ datatoc_prepass_vert_glsl);
+
+ e_data.default_hair_prepass_sh = DRW_shader_create(
+ vert_str, NULL, datatoc_prepass_frag_glsl,
+ "#define HAIR_SHADER\n");
+
+ e_data.default_hair_prepass_clip_sh = DRW_shader_create(
+ vert_str, NULL, datatoc_prepass_frag_glsl,
+ "#define HAIR_SHADER\n"
+ "#define CLIP_PLANES\n");
+
+ MEM_freeN(vert_str);
e_data.update_noise_sh = DRW_shader_create_fullscreen(
datatoc_update_noise_frag_glsl, NULL);
@@ -712,7 +728,7 @@ struct GPUMaterial *EEVEE_material_mesh_get(
mat = DRW_shader_create_from_material(
scene, ma, engine, options,
- datatoc_lit_surface_vert_glsl, NULL, e_data.frag_shader_lib,
+ e_data.vert_shader_str, NULL, e_data.frag_shader_lib,
defines);
MEM_freeN(defines);
@@ -772,7 +788,7 @@ struct GPUMaterial *EEVEE_material_mesh_depth_get(
mat = DRW_shader_create_from_material(
scene, ma, engine, options,
- (is_shadow) ? datatoc_shadow_vert_glsl : datatoc_lit_surface_vert_glsl,
+ (is_shadow) ? datatoc_shadow_vert_glsl : e_data.vert_shader_str,
NULL,
frag_str,
defines);
@@ -800,7 +816,7 @@ struct GPUMaterial *EEVEE_material_hair_get(
mat = DRW_shader_create_from_material(
scene, ma, engine, options,
- datatoc_lit_surface_vert_glsl, NULL, e_data.frag_shader_lib,
+ e_data.vert_shader_str, NULL, e_data.frag_shader_lib,
defines);
MEM_freeN(defines);
@@ -842,12 +858,15 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_create(
**/
static struct DRWShadingGroup *EEVEE_default_shading_group_get(
EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata,
+ Object *ob, ParticleSystem *psys, ModifierData *md,
bool is_hair, bool is_flat_normal, bool use_ssr, int shadow_method)
{
static int ssr_id;
ssr_id = (use_ssr) ? 1 : -1;
int options = VAR_MAT_MESH;
+ BLI_assert(!is_hair || (ob && psys && md));
+
if (is_hair) options |= VAR_MAT_HAIR;
if (is_flat_normal) options |= VAR_MAT_FLAT;
@@ -861,13 +880,25 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_get(
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_CLIP_PLANES | DRW_STATE_WIRE;
vedata->psl->default_pass[options] = DRW_pass_create("Default Lit Pass", state);
- DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.default_lit[options], vedata->psl->default_pass[options]);
/* XXX / WATCH: This creates non persistent binds for the ubos and textures.
- * But it's currently OK because the following shgroups does not add any bind. */
- add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, false, false);
+ * But it's currently OK because the following shgroups does not add any bind.
+ * EDIT: THIS IS NOT THE CASE FOR HAIRS !!! DUMMY!!! */
+ if (!is_hair) {
+ DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.default_lit[options], vedata->psl->default_pass[options]);
+ add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, false, false);
+ }
}
- return DRW_shgroup_create(e_data.default_lit[options], vedata->psl->default_pass[options]);
+ if (is_hair) {
+ DRWShadingGroup *shgrp = DRW_shgroup_hair_create(ob, psys, md,
+ vedata->psl->default_pass[options],
+ e_data.default_lit[options]);
+ add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, false, false);
+ return shgrp;
+ }
+ else {
+ return DRW_shgroup_create(e_data.default_lit[options], vedata->psl->default_pass[options]);
+ }
}
/**
@@ -907,7 +938,6 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
/* Create Material Ghash */
{
stl->g_data->material_hash = BLI_ghash_ptr_new("Eevee_material ghash");
- stl->g_data->hair_material_hash = BLI_ghash_ptr_new("Eevee_hair_material ghash");
}
{
@@ -923,7 +953,7 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
float *col = ts.colorBackground;
/* LookDev */
- EEVEE_lookdev_cache_init(vedata, &grp, e_data.default_studiolight_background, psl->background_pass, NULL);
+ EEVEE_lookdev_cache_init(vedata, &grp, e_data.default_studiolight_background, psl->background_pass, wo, NULL);
/* END */
if (!grp && wo) {
@@ -984,7 +1014,7 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
}
{
- DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_CLIP_PLANES | DRW_STATE_WIRE;
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CLIP_PLANES | DRW_STATE_WIRE;
psl->material_pass = DRW_pass_create("Material Shader Pass", state);
}
@@ -1038,7 +1068,6 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
DRW_shgroup_uniform_vec3(grp, "offsets", e_data.noise_offsets, 1);
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
}
-
}
#define ADD_SHGROUP_CALL(shgrp, ob, geom, oedata) do { \
@@ -1080,9 +1109,9 @@ static void material_opaque(
EEVEE_LampsInfo *linfo = sldata->lamps;
float *color_p = &ma->r;
- float *metal_p = &ma->ray_mirror;
+ float *metal_p = &ma->metallic;
float *spec_p = &ma->spec;
- float *rough_p = &ma->gloss_mir;
+ float *rough_p = &ma->roughness;
const bool use_gpumat = (ma->use_nodes && ma->nodetree);
const bool use_refract = ((ma->blend_flag & MA_BL_SS_REFRACTION) != 0) &&
@@ -1216,7 +1245,9 @@ static void material_opaque(
/* Fallback to default shader */
if (*shgrp == NULL) {
bool use_ssr = ((effects->enabled_effects & EFFECT_SSR) != 0);
- *shgrp = EEVEE_default_shading_group_get(sldata, vedata, false, use_flat_nor, use_ssr, linfo->shadow_method);
+ *shgrp = EEVEE_default_shading_group_get(sldata, vedata,
+ NULL, NULL, NULL,
+ false, use_flat_nor, use_ssr, linfo->shadow_method);
DRW_shgroup_uniform_vec3(*shgrp, "basecol", color_p, 1);
DRW_shgroup_uniform_float(*shgrp, "metallic", metal_p, 1);
DRW_shgroup_uniform_float(*shgrp, "specular", spec_p, 1);
@@ -1258,9 +1289,9 @@ static void material_transparent(
((stl->effects->enabled_effects & EFFECT_REFRACT) != 0)
);
float *color_p = &ma->r;
- float *metal_p = &ma->ray_mirror;
+ float *metal_p = &ma->metallic;
float *spec_p = &ma->spec;
- float *rough_p = &ma->gloss_mir;
+ float *rough_p = &ma->roughness;
if (ma->use_nodes && ma->nodetree) {
static float error_col[3] = {1.0f, 0.0f, 1.0f};
@@ -1375,7 +1406,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
const bool is_default_mode_shader = is_sculpt_mode;
/* First get materials for this mesh. */
- if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) {
+ if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) {
const int materials_len = MAX2(1, (is_sculpt_mode_draw ? 1 : ob->totcol));
struct DRWShadingGroup **shgrp_array = BLI_array_alloca(shgrp_array, materials_len);
@@ -1453,6 +1484,9 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
&auto_layer_count);
if (mat_geom) {
for (int i = 0; i < materials_len; ++i) {
+ if (mat_geom[i] == NULL) {
+ continue;
+ }
EEVEE_ObjectEngineData *oedata = NULL;
Material *ma = give_current_material(ob, i + 1);
@@ -1537,10 +1571,19 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
EEVEE_volumes_cache_object_add(sldata, vedata, scene, ob);
}
}
+}
+
+void EEVEE_hair_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, Object *ob, bool *cast_shadow)
+{
+ EEVEE_PassList *psl = vedata->psl;
+ EEVEE_StorageList *stl = vedata->stl;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ Scene *scene = draw_ctx->scene;
+
+ bool use_ssr = ((stl->effects->enabled_effects & EFFECT_SSR) != 0);
if (ob->type == OB_MESH) {
if (ob != draw_ctx->object_edit) {
- material_hash = stl->g_data->hair_material_hash;
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
if (md->type != eModifierType_ParticleSystem) {
continue;
@@ -1557,7 +1600,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
if (draw_as != PART_DRAW_PATH) {
continue;
}
- struct Gwn_Batch *hair_geom = DRW_cache_particles_get_hair(ob, psys, md);
+
DRWShadingGroup *shgrp = NULL;
Material *ma = give_current_material(ob, part->omat);
@@ -1566,61 +1609,73 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
}
float *color_p = &ma->r;
- float *metal_p = &ma->ray_mirror;
+ float *metal_p = &ma->metallic;
float *spec_p = &ma->spec;
- float *rough_p = &ma->gloss_mir;
-
- DRW_shgroup_call_add(stl->g_data->depth_shgrp, hair_geom, NULL);
- DRW_shgroup_call_add(stl->g_data->depth_shgrp_clip, hair_geom, NULL);
-
- shgrp = BLI_ghash_lookup(material_hash, (const void *)ma);
-
- if (shgrp) {
- DRW_shgroup_call_add(shgrp, hair_geom, NULL);
- }
- else {
- if (ma->use_nodes && ma->nodetree) {
- static float half = 0.5f;
- static float error_col[3] = {1.0f, 0.0f, 1.0f};
- static float compile_col[3] = {0.5f, 0.5f, 0.5f};
- struct GPUMaterial *gpumat = EEVEE_material_hair_get(scene, ma, sldata->lamps->shadow_method);
-
- switch (GPU_material_status(gpumat)) {
- case GPU_MAT_SUCCESS:
- {
- shgrp = DRW_shgroup_material_create(gpumat, psl->material_pass);
- add_standard_uniforms(shgrp, sldata, vedata, NULL, NULL, false, false);
- break;
- }
- case GPU_MAT_QUEUED:
- {
- sldata->probes->all_materials_updated = false;
- color_p = compile_col;
- metal_p = spec_p = rough_p = &half;
- break;
- }
- case GPU_MAT_FAILED:
- default:
- color_p = error_col;
- metal_p = spec_p = rough_p = &half;
- break;
+ float *rough_p = &ma->roughness;
+
+ shgrp = DRW_shgroup_hair_create(
+ ob, psys, md,
+ psl->depth_pass,
+ e_data.default_hair_prepass_sh);
+
+ shgrp = DRW_shgroup_hair_create(
+ ob, psys, md,
+ psl->depth_pass_clip,
+ e_data.default_hair_prepass_clip_sh);
+ DRW_shgroup_uniform_block(shgrp, "clip_block", sldata->clip_ubo);
+
+ shgrp = NULL;
+ if (ma->use_nodes && ma->nodetree) {
+ static int ssr_id;
+ ssr_id = (use_ssr) ? 1 : -1;
+ static float half = 0.5f;
+ static float error_col[3] = {1.0f, 0.0f, 1.0f};
+ static float compile_col[3] = {0.5f, 0.5f, 0.5f};
+ struct GPUMaterial *gpumat = EEVEE_material_hair_get(scene, ma, sldata->lamps->shadow_method);
+
+ switch (GPU_material_status(gpumat)) {
+ case GPU_MAT_SUCCESS:
+ {
+ shgrp = DRW_shgroup_material_hair_create(
+ ob, psys, md,
+ psl->material_pass,
+ gpumat);
+ add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, false, false);
+ break;
}
+ case GPU_MAT_QUEUED:
+ {
+ sldata->probes->all_materials_updated = false;
+ color_p = compile_col;
+ metal_p = spec_p = rough_p = &half;
+ break;
+ }
+ case GPU_MAT_FAILED:
+ default:
+ color_p = error_col;
+ metal_p = spec_p = rough_p = &half;
+ break;
}
+ }
- /* Fallback to default shader */
- if (shgrp == NULL) {
- bool use_ssr = ((stl->effects->enabled_effects & EFFECT_SSR) != 0);
- shgrp = EEVEE_default_shading_group_get(sldata, vedata, true, false, use_ssr,
- sldata->lamps->shadow_method);
- DRW_shgroup_uniform_vec3(shgrp, "basecol", color_p, 1);
- DRW_shgroup_uniform_float(shgrp, "metallic", metal_p, 1);
- DRW_shgroup_uniform_float(shgrp, "specular", spec_p, 1);
- DRW_shgroup_uniform_float(shgrp, "roughness", rough_p, 1);
- }
-
- DRW_shgroup_call_add(shgrp, hair_geom, NULL);
- BLI_ghash_insert(material_hash, ma, shgrp);
+ /* Fallback to default shader */
+ if (shgrp == NULL) {
+ shgrp = EEVEE_default_shading_group_get(sldata, vedata,
+ ob, psys, md,
+ true, false, use_ssr,
+ sldata->lamps->shadow_method);
+ DRW_shgroup_uniform_vec3(shgrp, "basecol", color_p, 1);
+ DRW_shgroup_uniform_float(shgrp, "metallic", metal_p, 1);
+ DRW_shgroup_uniform_float(shgrp, "specular", spec_p, 1);
+ DRW_shgroup_uniform_float(shgrp, "roughness", rough_p, 1);
}
+
+ /* Shadows */
+ DRW_shgroup_hair_create(
+ ob, psys, md,
+ psl->shadow_pass,
+ e_data.default_hair_prepass_sh);
+ *cast_shadow = true;
}
}
}
@@ -1633,7 +1688,7 @@ void EEVEE_materials_cache_finish(EEVEE_Data *vedata)
/* Look-Dev */
const DRWContextState *draw_ctx = DRW_context_state_get();
const View3D *v3d = draw_ctx->v3d;
- if (v3d && v3d->drawtype == OB_MATERIAL) {
+ if (LOOK_DEV_OVERLAY_ENABLED(v3d)) {
EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
EEVEE_LampsInfo *linfo = sldata->lamps;
struct Gwn_Batch *sphere = DRW_cache_sphere_get();
@@ -1670,7 +1725,6 @@ void EEVEE_materials_cache_finish(EEVEE_Data *vedata)
/* END */
BLI_ghash_free(stl->g_data->material_hash, NULL, MEM_freeN);
- BLI_ghash_free(stl->g_data->hair_material_hash, NULL, NULL);
}
void EEVEE_materials_free(void)
@@ -1679,8 +1733,10 @@ void EEVEE_materials_free(void)
DRW_SHADER_FREE_SAFE(e_data.default_lit[i]);
}
MEM_SAFE_FREE(e_data.frag_shader_lib);
- MEM_SAFE_FREE(e_data.frag_shader_lib);
+ MEM_SAFE_FREE(e_data.vert_shader_str);
MEM_SAFE_FREE(e_data.volume_shader_lib);
+ DRW_SHADER_FREE_SAFE(e_data.default_hair_prepass_sh);
+ DRW_SHADER_FREE_SAFE(e_data.default_hair_prepass_clip_sh);
DRW_SHADER_FREE_SAFE(e_data.default_prepass_sh);
DRW_SHADER_FREE_SAFE(e_data.default_prepass_clip_sh);
DRW_SHADER_FREE_SAFE(e_data.default_background);
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index b2ea9ff4229..6dabc8f91cb 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -72,8 +72,8 @@ static void eevee_motion_blur_camera_get_matrix_at_time(
/* Past matrix */
/* FIXME : This is a temporal solution that does not take care of parent animations */
/* Recalc Anim manualy */
- BKE_animsys_evaluate_animdata(scene, &cam_cpy.id, cam_cpy.adt, time, ADT_RECALC_ALL);
- BKE_animsys_evaluate_animdata(scene, &camdata_cpy.id, camdata_cpy.adt, time, ADT_RECALC_ALL);
+ BKE_animsys_evaluate_animdata(draw_ctx->depsgraph, scene, &cam_cpy.id, cam_cpy.adt, time, ADT_RECALC_ALL);
+ BKE_animsys_evaluate_animdata(draw_ctx->depsgraph, scene, &camdata_cpy.id, camdata_cpy.adt, time, ADT_RECALC_ALL);
BKE_object_where_is_calc_time(draw_ctx->depsgraph, scene, &cam_cpy, time);
/* Compute winmat */
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 10a53db5e35..fa9d2453934 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -92,6 +92,11 @@ extern struct DrawEngineType draw_engine_eevee_type;
} \
} ((void)0)
+#define OVERLAY_ENABLED(v3d) ((v3d) && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0)
+#define LOOK_DEV_MODE_ENABLED(v3d) ((v3d) && (v3d->drawtype == OB_MATERIAL))
+#define LOOK_DEV_OVERLAY_ENABLED(v3d) (LOOK_DEV_MODE_ENABLED(v3d) && OVERLAY_ENABLED(v3d) && ((v3d->overlay.flag & V3D_OVERLAY_LOOK_DEV) > 0))
+#define USE_SCENE_LIGHT(v3d) ((!v3d) || (!LOOK_DEV_MODE_ENABLED(v3d)) || ((LOOK_DEV_MODE_ENABLED(v3d) && (v3d->shading.flag & V3D_SHADING_SCENE_LIGHT))))
+
/* World shader variations */
enum {
VAR_WORLD_BACKGROUND = 0,
@@ -139,8 +144,10 @@ typedef struct EEVEE_PassList {
struct DRWPass *shadow_pass;
struct DRWPass *shadow_cube_copy_pass;
struct DRWPass *shadow_cube_store_pass;
+ struct DRWPass *shadow_cube_store_high_pass;
struct DRWPass *shadow_cascade_copy_pass;
struct DRWPass *shadow_cascade_store_pass;
+ struct DRWPass *shadow_cascade_store_high_pass;
/* Probes */
struct DRWPass *probe_background;
@@ -777,7 +784,6 @@ typedef struct EEVEE_PrivateData {
struct DRWShadingGroup *cube_display_shgrp;
struct DRWShadingGroup *planar_display_shgrp;
struct GHash *material_hash;
- struct GHash *hair_material_hash;
float background_alpha; /* TODO find a better place for this. */
/* For planar probes */
float planar_texel_size[2];
@@ -809,6 +815,7 @@ struct GPUTexture *EEVEE_materials_get_util_tex(void); /* XXX */
void EEVEE_materials_init(EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, EEVEE_FramebufferList *fbl);
void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, Object *ob, bool *cast_shadow);
+void EEVEE_hair_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, Object *ob, bool *cast_shadow);
void EEVEE_materials_cache_finish(EEVEE_Data *vedata);
struct GPUMaterial *EEVEE_material_world_lightprobe_get(struct Scene *scene, struct World *wo);
struct GPUMaterial *EEVEE_material_world_background_get(struct Scene *scene, struct World *wo);
@@ -937,7 +944,7 @@ void EEVEE_render_draw(EEVEE_Data *vedata, struct RenderEngine *engine, struct R
void EEVEE_render_update_passes(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer);
/** eevee_lookdev.c */
-void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, DRWShadingGroup **grp, GPUShader *shader, DRWPass *pass, EEVEE_LightProbesInfo *pinfo);
+void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, DRWShadingGroup **grp, GPUShader *shader, DRWPass *pass, struct World *world, EEVEE_LightProbesInfo *pinfo);
void EEVEE_lookdev_draw_background(EEVEE_Data *vedata);
/* Shadow Matrix */
diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c
index 6cb3fa259eb..5d31488d75f 100644
--- a/source/blender/draw/engines/eevee/eevee_render.c
+++ b/source/blender/draw/engines/eevee/eevee_render.c
@@ -143,25 +143,26 @@ void EEVEE_render_cache(
char info[42];
BLI_snprintf(info, sizeof(info), "Syncing %s", ob->id.name + 2);
RE_engine_update_stats(engine, NULL, info);
+ bool cast_shadow = false;
- if (DRW_check_object_visible_within_active_context(ob) == false) {
- return;
+ if (ob->base_flag & BASE_VISIBLED) {
+ EEVEE_hair_cache_populate(vedata, sldata, ob, &cast_shadow);
}
- if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) {
- bool cast_shadow;
-
- EEVEE_materials_cache_populate(vedata, sldata, ob, &cast_shadow);
-
- if (cast_shadow) {
- EEVEE_lights_cache_shcaster_object_add(sldata, ob);
+ if (DRW_check_object_visible_within_active_context(ob)) {
+ if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) {
+ EEVEE_materials_cache_populate(vedata, sldata, ob, &cast_shadow);
+ }
+ else if (ob->type == OB_LIGHTPROBE) {
+ EEVEE_lightprobes_cache_add(sldata, ob);
+ }
+ else if (ob->type == OB_LAMP) {
+ EEVEE_lights_cache_add(sldata, ob);
}
}
- else if (ob->type == OB_LIGHTPROBE) {
- EEVEE_lightprobes_cache_add(sldata, ob);
- }
- else if (ob->type == OB_LAMP) {
- EEVEE_lights_cache_add(sldata, ob);
+
+ if (cast_shadow) {
+ EEVEE_lights_cache_shcaster_object_add(sldata, ob);
}
}
@@ -421,6 +422,9 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl
/* Push instances attribs to the GPU. */
DRW_render_instance_buffer_finish();
+ /* Need to be called after DRW_render_instance_buffer_finish() */
+ DRW_hair_update();
+
if ((view_layer->passflag & (SCE_PASS_SUBSURFACE_COLOR |
SCE_PASS_SUBSURFACE_DIRECT |
SCE_PASS_SUBSURFACE_INDIRECT)) != 0)
diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c
index 2d074eea522..560f898b275 100644
--- a/source/blender/draw/engines/eevee/eevee_volumes.c
+++ b/source/blender/draw/engines/eevee/eevee_volumes.c
@@ -65,7 +65,6 @@ static struct {
} e_data = {NULL}; /* Engine data */
extern char datatoc_bsdf_common_lib_glsl[];
-extern char datatoc_bsdf_direct_lib_glsl[];
extern char datatoc_common_uniforms_lib_glsl[];
extern char datatoc_common_view_lib_glsl[];
extern char datatoc_octahedron_lib_glsl[];
@@ -92,7 +91,6 @@ static void eevee_create_shader_volumes(void)
datatoc_common_view_lib_glsl,
datatoc_common_uniforms_lib_glsl,
datatoc_bsdf_common_lib_glsl,
- datatoc_bsdf_direct_lib_glsl,
datatoc_octahedron_lib_glsl,
datatoc_irradiance_lib_glsl,
datatoc_lamps_lib_glsl,
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
index 704b039e0f6..a1890433b0f 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
@@ -143,6 +143,20 @@ vec2 mip_ratio_interp(float mip) {
float low_mip = floor(mip);
return mix(mipRatio[int(low_mip)], mipRatio[int(low_mip + 1.0)], mip - low_mip);
}
+
+/* ------- RNG ------- */
+
+float wang_hash_noise(uint s)
+{
+ s = (s ^ 61u) ^ (s >> 16u);
+ s *= 9u;
+ s = s ^ (s >> 4u);
+ s *= 0x27d4eb2du;
+ s = s ^ (s >> 15u);
+
+ return fract(float(s) / 4294967296.0);
+}
+
/* ------- Fast Math ------- */
/* [Drobot2014a] Low Level Optimizations for GCN */
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_direct_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_direct_lib.glsl
deleted file mode 100644
index aad71b3e48e..00000000000
--- a/source/blender/draw/engines/eevee/shaders/bsdf_direct_lib.glsl
+++ /dev/null
@@ -1,186 +0,0 @@
-/* Bsdf direct light function */
-/* in other word, how materials react to scene lamps */
-
-/* Naming convention
- * V View vector (normalized)
- * N World Normal (normalized)
- * L Outgoing Light Vector (Surface to Light in World Space) (normalized)
- * Ldist Distance from surface to the light
- * W World Pos
- */
-
-/* ------------ Diffuse ------------- */
-
-float direct_diffuse_point(vec3 N, vec4 l_vector)
-{
- float dist = l_vector.w;
- vec3 L = l_vector.xyz / dist;
- float bsdf = max(0.0, dot(N, L));
- bsdf /= dist * dist;
- return bsdf;
-}
-
-/* infinitly far away point source, no decay */
-float direct_diffuse_sun(LightData ld, vec3 N)
-{
- float bsdf = max(0.0, dot(N, -ld.l_forward));
- bsdf *= M_1_PI; /* Normalize */
- return bsdf;
-}
-
-#ifdef USE_LTC
-float direct_diffuse_sphere(LightData ld, vec3 N, vec4 l_vector)
-{
- float NL = dot(N, l_vector.xyz / l_vector.w);
-
- return ltc_evaluate_disk_simple(ld.l_radius / l_vector.w, NL);
-}
-
-float direct_diffuse_rectangle(LightData ld, vec3 N, vec3 V, vec4 l_vector)
-{
- vec3 corners[4];
- corners[0] = normalize(l_vector.xyz + ld.l_right * -ld.l_sizex + ld.l_up * ld.l_sizey);
- corners[1] = normalize(l_vector.xyz + ld.l_right * -ld.l_sizex + ld.l_up * -ld.l_sizey);
- corners[2] = normalize(l_vector.xyz + ld.l_right * ld.l_sizex + ld.l_up * -ld.l_sizey);
- corners[3] = normalize(l_vector.xyz + ld.l_right * ld.l_sizex + ld.l_up * ld.l_sizey);
-
- return ltc_evaluate_quad(corners, N);
-}
-
-float direct_diffuse_ellipse(LightData ld, vec3 N, vec3 V, vec4 l_vector)
-{
- vec3 points[3];
- points[0] = l_vector.xyz + ld.l_right * -ld.l_sizex + ld.l_up * -ld.l_sizey;
- points[1] = l_vector.xyz + ld.l_right * ld.l_sizex + ld.l_up * -ld.l_sizey;
- points[2] = l_vector.xyz + ld.l_right * ld.l_sizex + ld.l_up * ld.l_sizey;
-
- return ltc_evaluate_disk(N, V, mat3(1), points);
-}
-
-float direct_diffuse_unit_disc(LightData ld, vec3 N, vec3 V)
-{
- float NL = dot(N, -ld.l_forward);
-
- return ltc_evaluate_disk_simple(ld.l_radius, NL);
-}
-#endif
-
-/* ----------- GGx ------------ */
-vec3 direct_ggx_point(vec3 N, vec3 V, vec4 l_vector, float roughness, vec3 f0)
-{
- roughness = max(1e-3, roughness);
- float dist = l_vector.w;
- vec3 L = l_vector.xyz / dist;
- float bsdf = bsdf_ggx(N, L, V, roughness);
- bsdf /= dist * dist;
-
- /* Fresnel */
- float VH = max(dot(V, normalize(V + L)), 0.0);
- return F_schlick(f0, VH) * bsdf;
-}
-
-vec3 direct_ggx_sun(LightData ld, vec3 N, vec3 V, float roughness, vec3 f0)
-{
- roughness = max(1e-3, roughness);
- float bsdf = bsdf_ggx(N, -ld.l_forward, V, roughness);
- float VH = dot(V, -ld.l_forward) * 0.5 + 0.5;
- return F_schlick(f0, VH) * bsdf;
-}
-
-#ifdef USE_LTC
-vec3 direct_ggx_sphere(LightData ld, vec3 N, vec3 V, vec4 l_vector, float roughness, vec3 f0)
-{
- roughness = clamp(roughness, 0.0008, 0.999); /* Fix low roughness artifacts. */
-
- vec2 uv = lut_coords(dot(N, V), sqrt(roughness));
- vec3 brdf_lut = texture(utilTex, vec3(uv, 1.0)).rgb;
- vec4 ltc_lut = texture(utilTex, vec3(uv, 0.0)).rgba;
- mat3 ltc_mat = ltc_matrix(ltc_lut);
-
- /* Make orthonormal basis. */
- vec3 L = l_vector.xyz / l_vector.w;
- vec3 Px, Py;
- make_orthonormal_basis(L, Px, Py);
- Px *= ld.l_radius;
- Py *= ld.l_radius;
-
- vec3 points[3];
- points[0] = l_vector.xyz - Px - Py;
- points[1] = l_vector.xyz + Px - Py;
- points[2] = l_vector.xyz + Px + Py;
-
- float bsdf = ltc_evaluate_disk(N, V, ltc_mat, points);
- bsdf *= brdf_lut.b; /* Bsdf intensity */
-
- vec3 spec = F_area(f0, brdf_lut.xy) * bsdf;
-
- return spec;
-}
-
-vec3 direct_ggx_ellipse(LightData ld, vec3 N, vec3 V, vec4 l_vector, float roughness, vec3 f0)
-{
- vec3 points[3];
- points[0] = l_vector.xyz + ld.l_right * -ld.l_sizex + ld.l_up * -ld.l_sizey;
- points[1] = l_vector.xyz + ld.l_right * ld.l_sizex + ld.l_up * -ld.l_sizey;
- points[2] = l_vector.xyz + ld.l_right * ld.l_sizex + ld.l_up * ld.l_sizey;
-
- vec2 uv = lut_coords(dot(N, V), sqrt(roughness));
- vec3 brdf_lut = texture(utilTex, vec3(uv, 1.0)).rgb;
- vec4 ltc_lut = texture(utilTex, vec3(uv, 0.0)).rgba;
- mat3 ltc_mat = ltc_matrix(ltc_lut);
-
- float bsdf = ltc_evaluate_disk(N, V, ltc_mat, points);
- bsdf *= brdf_lut.b; /* Bsdf intensity */
-
- vec3 spec = F_area(f0, brdf_lut.xy) * bsdf;
-
- return spec;
-}
-
-vec3 direct_ggx_rectangle(LightData ld, vec3 N, vec3 V, vec4 l_vector, float roughness, vec3 f0)
-{
- vec3 corners[4];
- corners[0] = l_vector.xyz + ld.l_right * -ld.l_sizex + ld.l_up * ld.l_sizey;
- corners[1] = l_vector.xyz + ld.l_right * -ld.l_sizex + ld.l_up * -ld.l_sizey;
- corners[2] = l_vector.xyz + ld.l_right * ld.l_sizex + ld.l_up * -ld.l_sizey;
- corners[3] = l_vector.xyz + ld.l_right * ld.l_sizex + ld.l_up * ld.l_sizey;
-
- vec2 uv = lut_coords(dot(N, V), sqrt(roughness));
- vec3 brdf_lut = texture(utilTex, vec3(uv, 1.0)).rgb;
- vec4 ltc_lut = texture(utilTex, vec3(uv, 0.0)).rgba;
- mat3 ltc_mat = ltc_matrix(ltc_lut);
-
- ltc_transform_quad(N, V, ltc_mat, corners);
- float bsdf = ltc_evaluate_quad(corners, vec3(0.0, 0.0, 1.0));
- bsdf *= brdf_lut.b; /* Bsdf intensity */
-
- vec3 spec = F_area(f0, brdf_lut.xy) * bsdf;
-
- return spec;
-}
-
-vec3 direct_ggx_unit_disc(LightData ld, vec3 N, vec3 V, float roughness, vec3 f0)
-{
- roughness = clamp(roughness, 0.0004, 0.999); /* Fix low roughness artifacts. */
-
- vec2 uv = lut_coords(dot(N, V), sqrt(roughness));
- vec3 brdf_lut = texture(utilTex, vec3(uv, 1.0)).rgb;
- vec4 ltc_lut = texture(utilTex, vec3(uv, 0.0)).rgba;
- mat3 ltc_mat = ltc_matrix(ltc_lut);
-
- vec3 Px = ld.l_right * ld.l_radius;
- vec3 Py = ld.l_up * ld.l_radius;
-
- vec3 points[3];
- points[0] = -ld.l_forward - Px - Py;
- points[1] = -ld.l_forward + Px - Py;
- points[2] = -ld.l_forward + Px + Py;
-
- float bsdf = ltc_evaluate_disk(N, V, ltc_mat, points);
- bsdf *= brdf_lut.b; /* Bsdf intensity */
-
- vec3 spec = F_area(f0, brdf_lut.xy) * bsdf;
-
- return spec;
-}
-#endif
diff --git a/source/blender/draw/engines/eevee/shaders/default_frag.glsl b/source/blender/draw/engines/eevee/shaders/default_frag.glsl
index fd1a10de548..c5dbf29a3f4 100644
--- a/source/blender/draw/engines/eevee/shaders/default_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/default_frag.glsl
@@ -6,14 +6,38 @@ uniform float roughness;
Closure nodetree_exec(void)
{
+#ifdef HAIR_SHADER
+ vec3 B = normalize(cross(worldNormal, hairTangent));
+ float cos_theta;
+ if (hairThicknessRes == 1) {
+ vec4 rand = texelFetch(utilTex, ivec3(ivec2(gl_FragCoord.xy) % LUT_SIZE, 2.0), 0);
+ /* Random cosine normal distribution on the hair surface. */
+ cos_theta = rand.x * 2.0 - 1.0;
+ }
+ else {
+ /* Shade as a cylinder. */
+ cos_theta = hairThickTime / hairThickness;
+ }
+ float sin_theta = sqrt(max(0.0, 1.0f - cos_theta*cos_theta));;
+ vec3 N = normalize(worldNormal * sin_theta + B * cos_theta);
+ vec3 vN = mat3(ViewMatrix) * N;
+#else
+ vec3 N = normalize(gl_FrontFacing ? worldNormal : -worldNormal);
+ vec3 vN = normalize(gl_FrontFacing ? viewNormal : -viewNormal);
+#endif
+
vec3 dielectric = vec3(0.034) * specular * 2.0;
vec3 albedo = mix(basecol, vec3(0.0), metallic);
vec3 f0 = mix(dielectric, basecol, metallic);
- vec3 N = (gl_FrontFacing) ? worldNormal : -worldNormal;
vec3 out_diff, out_spec, ssr_spec;
eevee_closure_default(N, albedo, f0, 1, roughness, 1.0, out_diff, out_spec, ssr_spec);
- Closure result = Closure(out_spec + out_diff * albedo, 1.0, vec4(ssr_spec, roughness), normal_encode(normalize(viewNormal), viewCameraVec), 0);
+ Closure result = Closure(
+ out_spec + out_diff * albedo,
+ 1.0,
+ vec4(ssr_spec, roughness),
+ normal_encode(vN, viewCameraVec),
+ 0);
#ifdef LOOKDEV
gl_FragDepth = 0.0;
diff --git a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl b/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl
index 472d9c577b4..1f0ef76da0c 100644
--- a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl
@@ -1,3 +1,4 @@
+
#define M_PI 3.14159265358979323846
uniform float backgroundAlpha;
@@ -7,10 +8,10 @@ uniform mat4 ViewMatrixInverse;
#ifdef LOOKDEV
uniform mat3 StudioLightMatrix;
uniform sampler2D image;
+uniform float studioLightBackground = 1.0;
in vec3 viewPosition;
-#else
-uniform vec3 color;
#endif
+uniform vec3 color;
out vec4 FragColor;
@@ -35,8 +36,9 @@ void node_tex_environment_equirectangular(vec3 co, sampler2D ima, out vec4 color
float v = atan(nco.z, hypot(nco.x, nco.y)) / M_PI + 0.5;
/* Fix pole bleeding */
- float half_width = 0.5 / float(textureSize(ima, 0).x);
- v = clamp(v, half_width, 1.0 - half_width);
+ float width = float(textureSize(ima, 0).x);
+ float texel_width = 1.0 / width;
+ v = clamp(v, texel_width, 1.0 - texel_width);
/* Fix u = 0 seam */
/* This is caused by texture filtering, since uv don't have smooth derivatives
@@ -48,10 +50,13 @@ void node_tex_environment_equirectangular(vec3 co, sampler2D ima, out vec4 color
void main() {
#ifdef LOOKDEV
vec3 worldvec;
- vec4 color;
+ vec4 background_color;
background_transform_to_world(viewPosition, worldvec);
- node_tex_environment_equirectangular(StudioLightMatrix * worldvec, image, color);
+ node_tex_environment_equirectangular(StudioLightMatrix * worldvec, image, background_color);
+ background_color.rgb = mix(color, background_color.rgb, studioLightBackground);
+#else
+ vec3 background_color = color;
#endif
- FragColor = vec4(clamp(color.rgb, vec3(0.0), vec3(1e10)), backgroundAlpha);
+ FragColor = vec4(clamp(background_color.rgb, vec3(0.0), vec3(1e10)), backgroundAlpha);
}
diff --git a/source/blender/draw/engines/eevee/shaders/lamps_lib.glsl b/source/blender/draw/engines/eevee/shaders/lamps_lib.glsl
index 0e6f976187a..ec5f6f4472f 100644
--- a/source/blender/draw/engines/eevee/shaders/lamps_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lamps_lib.glsl
@@ -249,55 +249,70 @@ float light_visibility(LightData ld, vec3 W,
return vis;
}
+#ifdef USE_LTC
float light_diffuse(LightData ld, vec3 N, vec3 V, vec4 l_vector)
{
-#ifdef USE_LTC
- if (ld.l_type == SUN) {
- return direct_diffuse_unit_disc(ld, N, V);
- }
- else if (ld.l_type == AREA_RECT) {
- return direct_diffuse_rectangle(ld, N, V, l_vector);
+ if (ld.l_type == AREA_RECT) {
+ vec3 corners[4];
+ corners[0] = normalize((l_vector.xyz + ld.l_right * -ld.l_sizex) + ld.l_up * ld.l_sizey);
+ corners[1] = normalize((l_vector.xyz + ld.l_right * -ld.l_sizex) + ld.l_up * -ld.l_sizey);
+ corners[2] = normalize((l_vector.xyz + ld.l_right * ld.l_sizex) + ld.l_up * -ld.l_sizey);
+ corners[3] = normalize((l_vector.xyz + ld.l_right * ld.l_sizex) + ld.l_up * ld.l_sizey);
+
+ return ltc_evaluate_quad(corners, N);
}
else if (ld.l_type == AREA_ELLIPSE) {
- return direct_diffuse_ellipse(ld, N, V, l_vector);
- }
- else {
- return direct_diffuse_sphere(ld, N, l_vector);
- }
-#else
- if (ld.l_type == SUN) {
- return direct_diffuse_sun(ld, N);
+ vec3 points[3];
+ points[0] = (l_vector.xyz + ld.l_right * -ld.l_sizex) + ld.l_up * -ld.l_sizey;
+ points[1] = (l_vector.xyz + ld.l_right * ld.l_sizex) + ld.l_up * -ld.l_sizey;
+ points[2] = (l_vector.xyz + ld.l_right * ld.l_sizex) + ld.l_up * ld.l_sizey;
+
+ return ltc_evaluate_disk(N, V, mat3(1.0), points);
}
else {
- return direct_diffuse_point(N, l_vector);
+ float radius = ld.l_radius;
+ radius /= (ld.l_type == SUN) ? 1.0 : l_vector.w;
+ vec3 L = (ld.l_type == SUN) ? -ld.l_forward : (l_vector.xyz / l_vector.w);
+
+ return ltc_evaluate_disk_simple(radius, dot(N, L));
}
-#endif
}
-vec3 light_specular(LightData ld, vec3 N, vec3 V, vec4 l_vector, float roughness, vec3 f0)
+float light_specular(LightData ld, vec4 ltc_mat, vec3 N, vec3 V, vec4 l_vector)
{
-#ifdef USE_LTC
- if (ld.l_type == SUN) {
- return direct_ggx_unit_disc(ld, N, V, roughness, f0);
- }
- else if (ld.l_type == AREA_RECT) {
- return direct_ggx_rectangle(ld, N, V, l_vector, roughness, f0);
- }
- else if (ld.l_type == AREA_ELLIPSE) {
- return direct_ggx_ellipse(ld, N, V, l_vector, roughness, f0);
- }
- else {
- return direct_ggx_sphere(ld, N, V, l_vector, roughness, f0);
- }
-#else
- if (ld.l_type == SUN) {
- return direct_ggx_sun(ld, N, V, roughness, f0);
+ if (ld.l_type == AREA_RECT) {
+ vec3 corners[4];
+ corners[0] = (l_vector.xyz + ld.l_right * -ld.l_sizex) + ld.l_up * ld.l_sizey;
+ corners[1] = (l_vector.xyz + ld.l_right * -ld.l_sizex) + ld.l_up * -ld.l_sizey;
+ corners[2] = (l_vector.xyz + ld.l_right * ld.l_sizex) + ld.l_up * -ld.l_sizey;
+ corners[3] = (l_vector.xyz + ld.l_right * ld.l_sizex) + ld.l_up * ld.l_sizey;
+
+ ltc_transform_quad(N, V, ltc_matrix(ltc_mat), corners);
+
+ return ltc_evaluate_quad(corners, vec3(0.0, 0.0, 1.0));
}
else {
- return direct_ggx_point(N, V, l_vector, roughness, f0);
+ bool is_ellipse = (ld.l_type == AREA_ELLIPSE);
+ float radius_x = is_ellipse ? ld.l_sizex : ld.l_radius;
+ float radius_y = is_ellipse ? ld.l_sizey : ld.l_radius;
+
+ vec3 L = (ld.l_type == SUN) ? -ld.l_forward : l_vector.xyz;
+ vec3 Px = ld.l_right;
+ vec3 Py = ld.l_up;
+
+ if (ld.l_type == SPOT || ld.l_type == POINT) {
+ make_orthonormal_basis(l_vector.xyz / l_vector.w, Px, Py);
+ }
+
+ vec3 points[3];
+ points[0] = (L + Px * -radius_x) + Py * -radius_y;
+ points[1] = (L + Px * radius_x) + Py * -radius_y;
+ points[2] = (L + Px * radius_x) + Py * radius_y;
+
+ return ltc_evaluate_disk(N, V, ltc_matrix(ltc_mat), points);
}
-#endif
}
+#endif
#define MAX_SSS_SAMPLES 65
#define SSS_LUT_SIZE 64.0
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
index 737a2977146..ac1dd071a29 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
@@ -21,6 +21,16 @@ in vec3 worldNormal;
in vec3 viewNormal;
#endif
+#ifdef HAIR_SHADER
+in vec3 hairTangent; /* world space */
+in float hairThickTime;
+in float hairThickness;
+in float hairTime;
+flat in int hairStrandID;
+
+uniform int hairThicknessRes = 1;
+#endif
+
#endif /* LIT_SURFACE_UNIFORM */
/** AUTO CONFIG
@@ -168,28 +178,21 @@ void CLOSURE_NAME(
vec4 rand = texelFetch(utilTex, ivec3(ivec2(gl_FragCoord.xy) % LUT_SIZE, 2.0), 0);
-#ifdef HAIR_SHADER
- /* Random normal distribution on the hair surface. */
- vec3 T = normalize(worldNormal); /* meh, TODO fix worldNormal misnaming. */
- vec3 B = normalize(cross(V, T));
- N = cross(T, B); /* Normal facing view */
- /* We want a cosine distribution. */
- float cos_theta = rand.x * 2.0 - 1.0;
- float sin_theta = sqrt(max(0.0, 1.0f - cos_theta*cos_theta));;
- N = N * sin_theta + B * cos_theta;
-
-# ifdef CLOSURE_GLOSSY
- /* Hair random normal does not work with SSR :(.
- * It just create self reflection feedback (which is beautifful btw)
- * but not correct. */
- ssr_id = NO_SSR; /* Force bypass */
-# endif
-#endif
-
/* ---------------------------------------------------------------- */
/* -------------------- SCENE LAMPS LIGHTING ---------------------- */
/* ---------------------------------------------------------------- */
+#ifdef CLOSURE_GLOSSY
+ vec2 lut_uv = lut_coords(dot(N, V), roughness);
+ vec4 ltc_mat = texture(utilTex, vec3(lut_uv, 0.0)).rgba;
+#endif
+
+#ifdef CLOSURE_CLEARCOAT
+ vec2 lut_uv_clear = lut_coords(dot(C_N, V), C_roughness);
+ vec4 ltc_mat_clear = texture(utilTex, vec3(lut_uv_clear, 0.0)).rgba;
+ vec3 out_spec_clear = vec3(0.0);
+#endif
+
for (int i = 0; i < MAX_LIGHT && i < laNumLight; ++i) {
LightData ld = lights_data[i];
@@ -208,14 +211,24 @@ void CLOSURE_NAME(
#endif
#ifdef CLOSURE_GLOSSY
- out_spec += l_color_vis * light_specular(ld, N, V, l_vector, roughnessSquared, f0) * ld.l_spec;
+ out_spec += l_color_vis * light_specular(ld, ltc_mat, N, V, l_vector) * ld.l_spec;
#endif
#ifdef CLOSURE_CLEARCOAT
- out_spec += l_color_vis * light_specular(ld, C_N, V, l_vector, C_roughnessSquared, f0) * C_intensity * ld.l_spec;
+ out_spec_clear += l_color_vis * light_specular(ld, ltc_mat_clear, C_N, V, l_vector) * C_intensity * ld.l_spec;
#endif
}
+#ifdef CLOSURE_GLOSSY
+ vec3 brdf_lut_lamps = texture(utilTex, vec3(lut_uv, 1.0)).rgb;
+ out_spec *= F_area(f0, brdf_lut_lamps.xy) * brdf_lut_lamps.z;
+#endif
+
+#ifdef CLOSURE_CLEARCOAT
+ vec3 brdf_lut_lamps_clear = texture(utilTex, vec3(lut_uv_clear, 1.0)).rgb;
+ out_spec_clear *= F_area(f0, brdf_lut_lamps_clear.xy) * brdf_lut_lamps_clear.z;
+ out_spec += out_spec_clear;
+#endif
/* ---------------------------------------------------------------- */
/* ---------------- SPECULAR ENVIRONMENT LIGHTING ----------------- */
@@ -392,12 +405,6 @@ void CLOSURE_NAME(
}
out_spec += spec_accum.rgb * ssr_spec * spec_occlu * float(specToggle);
-
-# ifdef HAIR_SHADER
- /* Hack: Overide spec color so that ssr will not be computed
- * even if ssr_id match the active ssr. */
- ssr_spec = vec3(0.0);
-# endif
#endif
#ifdef CLOSURE_REFRACTION
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
index cbc4c80e59b..58bcea7d605 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
@@ -5,10 +5,13 @@ uniform mat4 ModelViewMatrix;
uniform mat3 WorldNormalMatrix;
#ifndef ATTRIB
uniform mat3 NormalMatrix;
+uniform mat4 ModelMatrixInverse;
#endif
+#ifndef HAIR_SHADER
in vec3 pos;
in vec3 nor;
+#endif
out vec3 worldPosition;
out vec3 viewPosition;
@@ -27,12 +30,37 @@ out vec3 worldNormal;
out vec3 viewNormal;
#endif
-void main() {
+#ifdef HAIR_SHADER
+out vec3 hairTangent;
+out float hairThickTime;
+out float hairThickness;
+out float hairTime;
+flat out int hairStrandID;
+#endif
+
+void main()
+{
+#ifdef HAIR_SHADER
+ hairStrandID = hair_get_strand_id();
+ vec3 pos, binor;
+ hair_get_pos_tan_binor_time(
+ (ProjectionMatrix[3][3] == 0.0),
+ ViewMatrixInverse[3].xyz, ViewMatrixInverse[2].xyz,
+ pos, hairTangent, binor, hairTime, hairThickness, hairThickTime);
+
+ gl_Position = ViewProjectionMatrix * vec4(pos, 1.0);
+ viewPosition = (ViewMatrix * vec4(pos, 1.0)).xyz;
+ worldPosition = pos;
+ hairTangent = normalize(hairTangent);
+ worldNormal = cross(binor, hairTangent);
+ viewNormal = normalize(mat3(ViewMatrix) * worldNormal);
+#else
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
viewPosition = (ModelViewMatrix * vec4(pos, 1.0)).xyz;
worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
- viewNormal = normalize(NormalMatrix * nor);
worldNormal = normalize(WorldNormalMatrix * nor);
+ viewNormal = normalize(NormalMatrix * nor);
+#endif
/* Used for planar reflections */
gl_ClipDistance[0] = dot(vec4(worldPosition, 1.0), ClipPlanes[0]);
diff --git a/source/blender/draw/engines/eevee/shaders/prepass_vert.glsl b/source/blender/draw/engines/eevee/shaders/prepass_vert.glsl
index c756e061d70..f2e9e7001e8 100644
--- a/source/blender/draw/engines/eevee/shaders/prepass_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/prepass_vert.glsl
@@ -7,13 +7,28 @@ layout(std140) uniform clip_block {
vec4 ClipPlanes[1];
};
+#ifndef HAIR_SHADER
in vec3 pos;
+#endif
void main()
{
+#ifdef HAIR_SHADER
+ float time, thick_time, thickness;
+ vec3 pos, tan, binor;
+ hair_get_pos_tan_binor_time(
+ (ProjectionMatrix[3][3] == 0.0),
+ ViewMatrixInverse[3].xyz, ViewMatrixInverse[2].xyz,
+ pos, tan, binor, time, thickness, thick_time);
+
+ gl_Position = ViewProjectionMatrix * vec4(pos, 1.0);
+ vec4 worldPosition = vec4(pos, 1.0);
+#else
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
-#ifdef CLIP_PLANES
vec4 worldPosition = (ModelMatrix * vec4(pos, 1.0));
+#endif
+
+#ifdef CLIP_PLANES
gl_ClipDistance[0] = dot(vec4(worldPosition.xyz, 1.0), ClipPlanes[0]);
#endif
/* TODO motion vectors */
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl
index b40155be454..d5ac821c3fa 100644
--- a/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl
@@ -165,6 +165,7 @@ void main() {
grouped_samples_accum(cos, concentric[28], concentric[29], concentric[30], concentric[31], accum);
grouped_samples_accum(cos, concentric[32], concentric[33], concentric[34], concentric[35], accum);
}
+#ifdef HIGH_BLUR
if (shadowSampleCount > 36) {
grouped_samples_accum(cos, concentric[36], concentric[37], concentric[38], concentric[39], accum);
grouped_samples_accum(cos, concentric[40], concentric[41], concentric[42], concentric[43], accum);
@@ -230,6 +231,7 @@ void main() {
grouped_samples_accum(cos, concentric[248], concentric[249], concentric[250], concentric[251], accum);
grouped_samples_accum(cos, concentric[252], concentric[253], concentric[254], concentric[255], accum);
}
+#endif
#ifdef ESM
accum.x = ln_space_prefilter(1.0, accum.x, 1.0, accum.y);
diff --git a/source/blender/draw/engines/external/external_engine.c b/source/blender/draw/engines/external/external_engine.c
index 420209279ad..2917805d233 100644
--- a/source/blender/draw/engines/external/external_engine.c
+++ b/source/blender/draw/engines/external/external_engine.c
@@ -153,7 +153,7 @@ static void external_draw_scene_do(void *vedata)
if (!rv3d->render_engine) {
RenderEngineType *engine_type = draw_ctx->engine_type;
- if (!(engine_type->view_update && engine_type->render_to_view)) {
+ if (!(engine_type->view_update && engine_type->view_draw)) {
return;
}
@@ -170,7 +170,7 @@ static void external_draw_scene_do(void *vedata)
/* Render result draw. */
type = rv3d->render_engine->type;
- type->render_to_view(rv3d->render_engine, draw_ctx->evil_C);
+ type->view_draw(rv3d->render_engine, draw_ctx->evil_C);
gpuPopProjectionMatrix();
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_cavity_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_cavity_frag.glsl
new file mode 100644
index 00000000000..38f55015877
--- /dev/null
+++ b/source/blender/draw/engines/workbench/shaders/workbench_cavity_frag.glsl
@@ -0,0 +1,71 @@
+out vec4 fragColor;
+
+uniform sampler2D depthBuffer;
+uniform sampler2D colorBuffer;
+uniform sampler2D normalBuffer;
+uniform sampler2D positionBuffer;
+
+uniform vec2 invertedViewportSize;
+uniform mat4 WinMatrix; /* inverse WinMatrix */
+
+uniform vec4 viewvecs[3];
+uniform vec4 ssao_params;
+uniform vec4 ssao_settings;
+uniform sampler2D ssao_jitter;
+
+layout(std140) uniform samples_block {
+ vec4 ssao_samples[500];
+};
+
+#define ssao_samples_num ssao_params.x
+#define jitter_tilling ssao_params.yz
+#define dfdy_sign ssao_params.w
+
+#define ssao_distance ssao_settings.x
+#define ssao_factor_cavity ssao_settings.y
+#define ssao_factor_edge ssao_settings.z
+#define ssao_attenuation ssao_settings.a
+
+vec3 get_view_space_from_depth(in vec2 uvcoords, in float depth)
+{
+ if (WinMatrix[3][3] == 0.0) {
+ /* Perspective */
+ float d = 2.0 * depth - 1.0;
+
+ float zview = -WinMatrix[3][2] / (d + WinMatrix[2][2]);
+
+ return zview * (viewvecs[0].xyz + vec3(uvcoords, 0.0) * viewvecs[1].xyz);
+ }
+ else {
+ /* Orthographic */
+ vec3 offset = vec3(uvcoords, depth);
+
+ return viewvecs[0].xyz + offset * viewvecs[1].xyz;
+ }
+}
+
+/* forward declartion */
+void ssao_factors(
+ in float depth, in vec3 normal, in vec3 position, in vec2 screenco,
+ out float cavities, out float edges);
+
+
+void main()
+{
+ vec2 screenco = vec2(gl_FragCoord.xy) * invertedViewportSize;
+ ivec2 texel = ivec2(gl_FragCoord.xy);
+
+ float depth = texelFetch(depthBuffer, texel, 0).x;
+ vec3 position = get_view_space_from_depth(screenco, depth);
+
+ vec4 diffuse_color = texelFetch(colorBuffer, texel, 0);
+ vec3 normal_viewport = normal_decode(texelFetch(normalBuffer, texel, 0).rg);
+ if (diffuse_color.a == 0.0) {
+ normal_viewport = -normal_viewport;
+ }
+
+ float cavity = 0.0, edges = 0.0;
+ ssao_factors(depth, normal_viewport, position, screenco, cavity, edges);
+
+ fragColor = vec4(cavity, edges, 0.0, 1.0);
+}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl
new file mode 100644
index 00000000000..da0198ab2e7
--- /dev/null
+++ b/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl
@@ -0,0 +1,79 @@
+
+
+/* from The Alchemy screen-space ambient obscurance algorithm
+ * http://graphics.cs.williams.edu/papers/AlchemyHPG11/VV11AlchemyAO.pdf */
+
+void ssao_factors(
+ in float depth, in vec3 normal, in vec3 position, in vec2 screenco,
+ out float cavities, out float edges)
+{
+ cavities = edges = 0.0;
+ /* early out if there is no need for SSAO */
+ if (ssao_factor_cavity == 0.0 && ssao_factor_edge == 0.0)
+ return;
+
+ /* take the normalized ray direction here */
+ vec3 noise = texture(ssao_jitter, screenco.xy * jitter_tilling).rgb;
+
+ /* find the offset in screen space by multiplying a point
+ * in camera space at the depth of the point by the projection matrix. */
+ vec2 offset;
+ float homcoord = WinMatrix[2][3] * position.z + WinMatrix[3][3];
+ offset.x = WinMatrix[0][0] * ssao_distance / homcoord;
+ offset.y = WinMatrix[1][1] * ssao_distance / homcoord;
+ /* convert from -1.0...1.0 range to 0.0..1.0 for easy use with texture coordinates */
+ offset *= 0.5;
+
+ int num_samples = int(ssao_samples_num);
+
+ /* Note. Putting noise usage here to put some ALU after texture fetch. */
+ vec2 rotX = noise.rg;
+ vec2 rotY = vec2(-rotX.y, rotX.x);
+
+ for (int x = 0; x < num_samples && x < 500; x++) {
+ /* ssao_samples[x].xy is sample direction (normalized).
+ * ssao_samples[x].z is sample distance from disk center. */
+
+ /* Rotate with random direction to get jittered result. */
+ vec2 dir_jittered = vec2(dot(ssao_samples[x].xy, rotX), dot(ssao_samples[x].xy, rotY));
+ dir_jittered.xy *= ssao_samples[x].z + noise.b;
+
+ vec2 uvcoords = screenco.xy + dir_jittered * offset;
+
+ if (uvcoords.x > 1.0 || uvcoords.x < 0.0 || uvcoords.y > 1.0 || uvcoords.y < 0.0)
+ continue;
+
+ float depth_new = texture(depthBuffer, uvcoords).r;
+
+ /* Handle Background case */
+ bool is_background = (depth_new == 1.0);
+
+ /* This trick provide good edge effect even if no neighboor is found. */
+ vec3 pos_new = get_view_space_from_depth(uvcoords, (is_background) ? depth : depth_new);
+
+ if (is_background)
+ pos_new.z -= ssao_distance;
+
+ vec3 dir = pos_new - position;
+ float len = length(dir);
+ float f_cavities = dot(dir, normal);
+ float f_edge = -f_cavities;
+ float f_bias = 0.05 * len + 0.0001;
+
+ float attenuation = 1.0 / (len * (1.0 + len * len * ssao_attenuation));
+
+ /* use minor bias here to avoid self shadowing */
+ if (f_cavities > -f_bias)
+ cavities += f_cavities * attenuation;
+
+ if (f_edge > f_bias)
+ edges += f_edge * attenuation;
+ }
+
+ cavities /= ssao_samples_num;
+ edges /= ssao_samples_num;
+
+ /* don't let cavity wash out the surface appearance */
+ cavities = clamp(cavities * ssao_factor_cavity, 0.0, 1.0);
+ edges = edges * ssao_factor_edge;
+}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_checkerboard_depth_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_checkerboard_depth_frag.glsl
index 4e44f6e1914..7027543f5a9 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_checkerboard_depth_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_checkerboard_depth_frag.glsl
@@ -1,8 +1,35 @@
+
+/* 4x4 bayer matrix. */
+#define P(x) ((x + 0.5) * (1.0 / 16.0))
+const vec4 dither_mat[4] = vec4[4](
+ vec4( P(0.0), P(8.0), P(2.0), P(10.0)),
+ vec4(P(12.0), P(4.0), P(14.0), P(6.0)),
+ vec4( P(3.0), P(11.0), P(1.0), P(9.0)),
+ vec4(P(15.0), P(7.0), P(13.0), P(5.0))
+);
+
+uniform float threshold = 0.5;
+
+/* Noise dithering pattern
+ * 0 - Bayer matrix
+ * 1 - Interlieved gradient noise
+ */
+#define NOISE 1
+
void main()
{
- vec2 p= vec2(floor(gl_FragCoord.x), floor(gl_FragCoord.y));
- vec2 test = mod(p, 2.0);
- if (mod(test.x + test.y, 2.0)==0.0) {
+#if NOISE == 0
+ ivec2 tx = ivec2(gl_FragCoord.xy) % 4;
+ float noise = dither_mat[tx.x][tx.y];
+#elif NOISE == 1
+ /* Interlieved gradient noise by Jorge Jimenez
+ * http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare */
+ float noise = fract(52.9829189 * fract(0.06711056 * gl_FragCoord.x + 0.00583715 * gl_FragCoord.y));
+#else
+#error
+#endif
+
+ if (noise > threshold) {
discard;
} else {
gl_FragDepth = 1.0;
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl
index 88b715f55a8..c56e02e72d6 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl
@@ -1,5 +1,7 @@
#define NO_OBJECT_ID uint(0)
#define EPSILON 0.00001
+#define M_PI 3.14159265358979323846
+
/* 4x4 bayer matrix prepared for 8bit UNORM precision error. */
#define P(x) (((x + 0.5) * (1.0 / 16.0) - 0.5) * (1.0 / 255.0))
const vec4 dither_mat4x4[4] = vec4[4](
@@ -63,9 +65,57 @@ void fresnel(vec3 I, vec3 N, float ior, out float kr)
// kt = 1 - kr;
}
-vec4 calculate_transparent_accum(vec4 premultiplied) {
- float a = min(1.0, premultiplied.a) * 8.0 + 0.01;
+float calculate_transparent_weight(float z, float alpha)
+{
+#if 0
+ /* Eq 10 : Good for surfaces with varying opacity (like particles) */
+ float a = min(1.0, alpha * 10.0) + 0.01;
float b = -gl_FragCoord.z * 0.95 + 1.0;
- float w = clamp(a * a * a * 1e8 * b * b * b, 1e-2, 3e2);
- return premultiplied * w;
+ float w = a * a * a * 3e2 * b * b * b;
+#else
+ /* Eq 7 put more emphasis on surfaces closer to the view. */
+ // float w = 10.0 / (1e-5 + pow(abs(z) / 5.0, 2.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 7 */
+ // float w = 10.0 / (1e-5 + pow(abs(z) / 10.0, 3.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 8 */
+ // float w = 10.0 / (1e-5 + pow(abs(z) / 200.0, 4.0)); /* Eq 9 */
+ /* Same as eq 7, but optimized. */
+ float a = abs(z) / 5.0;
+ float b = abs(z) / 200.0;
+ b *= b;
+ float w = 10.0 / ((1e-5 + a * a) + b * (b * b)); /* Eq 7 */
+#endif
+ return alpha * clamp(w, 1e-2, 3e2);
+}
+
+/* Special function only to be used with calculate_transparent_weight(). */
+float linear_zdepth(float depth, vec4 viewvecs[3], mat4 proj_mat)
+{
+ if (proj_mat[3][3] == 0.0) {
+ float d = 2.0 * depth - 1.0;
+ return -proj_mat[3][2] / (d + proj_mat[2][2]);
+ }
+ else {
+ /* Return depth from near plane. */
+ return depth * viewvecs[1].z;
+ }
+}
+
+vec3 view_vector_from_screen_uv(vec2 uv, vec4 viewvecs[3], mat4 proj_mat)
+{
+ return (proj_mat[3][3] == 0.0)
+ ? normalize(viewvecs[0].xyz + vec3(uv, 0.0) * viewvecs[1].xyz)
+ : vec3(0.0, 0.0, 1.0);
+}
+
+vec2 matcap_uv_compute(vec3 I, vec3 N, bool flipped)
+{
+ /* Quick creation of an orthonormal basis */
+ float a = 1.0 / (1.0 + I.z);
+ float b = -I.x * I.y * a;
+ vec3 b1 = vec3(1.0 - I.x * I.x * a, b, -I.x);
+ vec3 b2 = vec3(b, 1.0 - I.y * I.y * a, -I.y);
+ vec2 matcap_uv = vec2(dot(b1, N), dot(b2, N));
+ if (flipped) {
+ matcap_uv.x = -matcap_uv.x;
+ }
+ return matcap_uv * 0.496 + 0.5;
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl
index d0b1c580e5f..f67d2ff6745 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl
@@ -1,3 +1,8 @@
+struct LightData {
+ vec4 light_direction_vs;
+ vec4 specular_color;
+};
+
struct WorldData {
vec4 diffuse_light_x_pos;
vec4 diffuse_light_x_neg;
@@ -8,4 +13,15 @@ struct WorldData {
vec4 background_color_low;
vec4 background_color_high;
vec4 object_outline_color;
+ vec4 light_direction_vs;
+ LightData lights[3];
+ int num_lights;
+ int matcap_orientation;
+ int pad[2];
+};
+
+struct MaterialData {
+ vec4 diffuse_color;
+ vec4 specular_color;
+ float roughness;
};
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
index 35867a566f1..461fb2fb130 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
@@ -1,16 +1,24 @@
out vec4 fragColor;
+uniform mat4 ProjectionMatrix;
+
uniform usampler2D objectId;
uniform sampler2D colorBuffer;
+uniform sampler2D specularBuffer;
uniform sampler2D normalBuffer;
/* normalBuffer contains viewport normals */
+uniform sampler2D cavityBuffer;
+
uniform vec2 invertedViewportSize;
+uniform vec4 viewvecs[3];
uniform float shadowMultiplier;
uniform float lightMultiplier;
uniform float shadowShift = 0.1;
uniform mat3 normalWorldMatrix;
-uniform vec3 lightDirection; /* light direction in view space */
+#ifdef STUDIOLIGHT_ORIENTATION_VIEWNORMAL
+uniform sampler2D matcapImage;
+#endif
layout(std140) uniform world_block {
WorldData world_data;
@@ -43,38 +51,68 @@ void main()
#endif /* !V3D_SHADING_OBJECT_OUTLINE */
vec4 diffuse_color = texelFetch(colorBuffer, texel, 0);
+
/* Do we need normals */
#ifdef NORMAL_VIEWPORT_PASS_ENABLED
-#ifdef WORKBENCH_ENCODE_NORMALS
+# ifdef WORKBENCH_ENCODE_NORMALS
vec3 normal_viewport = normal_decode(texelFetch(normalBuffer, texel, 0).rg);
- if (diffuse_color.a == 1.0) {
+ if (diffuse_color.a == 0.0) {
normal_viewport = -normal_viewport;
}
-#else /* WORKBENCH_ENCODE_NORMALS */
+# else /* WORKBENCH_ENCODE_NORMALS */
vec3 normal_viewport = texelFetch(normalBuffer, texel, 0).rgb;
-#endif /* WORKBENCH_ENCODE_NORMALS */
+# endif /* WORKBENCH_ENCODE_NORMALS */
+#endif
+
+ vec3 I_vs = view_vector_from_screen_uv(uv_viewport, viewvecs, ProjectionMatrix);
+
+#ifdef STUDIOLIGHT_ORIENTATION_VIEWNORMAL
+ bool flipped = world_data.matcap_orientation != 0;
+ vec2 matcap_uv = matcap_uv_compute(I_vs, normal_viewport, flipped);
+ diffuse_color = textureLod(matcapImage, matcap_uv, 0.0);
+#endif
+
+#ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
+ vec4 specular_data = texelFetch(specularBuffer, texel, 0);
+ vec3 specular_color = get_world_specular_lights(world_data, specular_data, normal_viewport, I_vs);
+#else
+ vec3 specular_color = vec3(0.0);
+#endif
+
+#ifdef V3D_LIGHTING_FLAT
+ vec3 diffuse_light = vec3(1.0);
#endif
+#ifdef V3D_LIGHTING_MATCAP
+ vec3 diffuse_light = texelFetch(specularBuffer, texel, 0).rgb;
+#endif
#ifdef V3D_LIGHTING_STUDIO
-#ifdef STUDIOLIGHT_ORIENTATION_CAMERA
+# ifdef STUDIOLIGHT_ORIENTATION_CAMERA
vec3 diffuse_light = get_camera_diffuse_light(world_data, normal_viewport);
-#endif
-#ifdef STUDIOLIGHT_ORIENTATION_WORLD
+# endif
+
+# ifdef STUDIOLIGHT_ORIENTATION_WORLD
vec3 normal_world = normalWorldMatrix * normal_viewport;
vec3 diffuse_light = get_world_diffuse_light(world_data, normal_world);
+# endif
#endif
- vec3 shaded_color = diffuse_light * diffuse_color.rgb;
+ vec3 shaded_color = diffuse_light * diffuse_color.rgb + specular_color;
-#else /* V3D_LIGHTING_STUDIO */
- vec3 shaded_color = diffuse_color.rgb;
-
-#endif /* V3D_LIGHTING_STUDIO */
+#ifdef V3D_SHADING_CAVITY
+ vec2 cavity = texelFetch(cavityBuffer, texel, 0).rg;
+ shaded_color *= 1.0 - cavity.x;
+ shaded_color *= 1.0 + cavity.y;
+#endif
#ifdef V3D_SHADING_SHADOW
- float shadow_mix = step(-shadowShift, dot(normal_viewport, lightDirection));
- float light_multiplier;
- light_multiplier = mix(lightMultiplier, shadowMultiplier, shadow_mix);
+ float light_factor = -dot(normal_viewport, world_data.light_direction_vs.xyz);
+ /* The step function might be ok for meshes but it's
+ * clearly not the case for hairs. Do smoothstep in this case. */
+ float shadow_mix = (diffuse_color.a == 1.0 || diffuse_color.a == 0.0)
+ ? step(-shadowShift, -light_factor)
+ : smoothstep(1.0, shadowShift, light_factor);
+ float light_multiplier = mix(lightMultiplier, shadowMultiplier, shadow_mix);
#else /* V3D_SHADING_SHADOW */
float light_multiplier = 1.0;
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl
index 12d6296655d..1d9f37274bd 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl
@@ -2,9 +2,7 @@ out vec4 fragColor;
uniform usampler2D objectId;
uniform sampler2D transparentAccum;
-#ifdef WORKBENCH_REVEALAGE_ENABLED
uniform sampler2D transparentRevealage;
-#endif
uniform vec2 invertedViewportSize;
layout(std140) uniform world_block {
@@ -16,27 +14,24 @@ void main()
ivec2 texel = ivec2(gl_FragCoord.xy);
vec2 uv_viewport = gl_FragCoord.xy * invertedViewportSize;
uint object_id = texelFetch(objectId, texel, 0).r;
- vec4 transparent_accum = texelFetch(transparentAccum, texel, 0);
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- float transparent_revealage = texelFetch(transparentRevealage, texel, 0).r;
-#endif
- vec4 color;
+
+ /* Listing 4 */
+ vec4 trans_accum = texelFetch(transparentAccum, texel, 0);
+ float trans_revealage = trans_accum.a;
+ trans_accum.a = texelFetch(transparentRevealage, texel, 0).r;
#ifdef V3D_SHADING_OBJECT_OUTLINE
float outline = calculate_object_outline(objectId, texel, object_id);
#else /* V3D_SHADING_OBJECT_OUTLINE */
float outline = 1.0;
#endif /* V3D_SHADING_OBJECT_OUTLINE */
+ vec3 bg_color = background_color(world_data, uv_viewport.y);
+
+ /* TODO: Bypass the whole shader if there is no xray pass and no outline pass. */
+ vec3 trans_color = trans_accum.rgb / clamp(trans_accum.a, 1e-4, 5e4);
+ vec3 color = mix(trans_color, bg_color, trans_revealage);
+
+ color = mix(world_data.object_outline_color.rgb, color, outline);
- if (object_id == NO_OBJECT_ID) {
- color = vec4(background_color(world_data, uv_viewport.y), 0.0);
- } else {
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- color = vec4((transparent_accum.xyz / max(transparent_accum.a, EPSILON)) * (1.0 - transparent_revealage), 1.0);
-#else
- color = vec4(transparent_accum.xyz / max(transparent_accum.a, EPSILON), 1.0);
-#endif
- }
-
- fragColor = vec4(mix(world_data.object_outline_color.rgb, color.xyz, outline), 1.0);
+ fragColor = vec4(color, 1.0);
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl
index 309ae063284..4a7d195a56a 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl
@@ -1,8 +1,11 @@
-uniform vec4 color = vec4(0.0, 0.0, 1.0, 1.0);
#ifdef OB_TEXTURE
uniform sampler2D image;
#endif
+uniform mat4 ProjectionMatrix;
uniform mat3 normalWorldMatrix;
+uniform float alpha = 0.5;
+uniform vec2 invertedViewportSize;
+uniform vec4 viewvecs[3];
#ifdef NORMAL_VIEWPORT_PASS_ENABLED
in vec3 normal_viewport;
@@ -10,40 +13,71 @@ in vec3 normal_viewport;
#ifdef OB_TEXTURE
in vec2 uv_interp;
#endif
+#ifdef STUDIOLIGHT_ORIENTATION_VIEWNORMAL
+uniform sampler2D matcapImage;
+#endif
layout(std140) uniform world_block {
WorldData world_data;
};
-layout(location=0) out vec4 transparentAccum;
+layout(std140) uniform material_block {
+ MaterialData material_data;
+};
+layout(location=0) out vec4 transparentAccum;
+layout(location=1) out float revealageAccum; /* revealage actually stored in transparentAccum.a */
void main()
{
vec4 diffuse_color;
+ vec3 diffuse_light = vec3(1.0);
#ifdef OB_SOLID
- diffuse_color = color;
+ diffuse_color = material_data.diffuse_color;
#endif /* OB_SOLID */
#ifdef OB_TEXTURE
diffuse_color = texture(image, uv_interp);
#endif /* OB_TEXTURE */
-#ifdef V3D_LIGHTING_STUDIO
-#ifdef STUDIOLIGHT_ORIENTATION_CAMERA
- vec3 diffuse_light = get_camera_diffuse_light(world_data, normal_viewport);
+ vec2 uv_viewport = gl_FragCoord.xy * invertedViewportSize;
+ vec3 I_vs = view_vector_from_screen_uv(uv_viewport, viewvecs, ProjectionMatrix);
+
+#ifdef NORMAL_VIEWPORT_PASS_ENABLED
+ vec3 nor = normalize(normal_viewport);
#endif
-#ifdef STUDIOLIGHT_ORIENTATION_WORLD
- vec3 normal_world = normalWorldMatrix * normal_viewport;
- vec3 diffuse_light = get_world_diffuse_light(world_data, normal_world);
+
+#ifdef V3D_LIGHTING_MATCAP
+ bool flipped = world_data.matcap_orientation != 0;
+ vec2 matcap_uv = matcap_uv_compute(I_vs, nor, flipped);
+ diffuse_light = texture(matcapImage, matcap_uv).rgb;
+#endif
+
+#ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
+ vec3 specular_color = get_world_specular_lights(world_data, vec4(material_data.specular_color.rgb, material_data.roughness), nor, I_vs);
+#else
+ vec3 specular_color = vec3(0.0);
+#endif
+
+#ifdef V3D_LIGHTING_STUDIO
+# ifdef STUDIOLIGHT_ORIENTATION_CAMERA
+ diffuse_light = get_camera_diffuse_light(world_data, nor);
+# endif
+# ifdef STUDIOLIGHT_ORIENTATION_WORLD
+ vec3 normal_world = normalWorldMatrix * nor;
+ diffuse_light = get_world_diffuse_light(world_data, normal_world);
+# endif
#endif
- vec3 shaded_color = diffuse_light * diffuse_color.rgb;
-#else /* V3D_LIGHTING_STUDIO */
- vec3 shaded_color = diffuse_color.rgb;
-#endif /* V3D_LIGHTING_STUDIO */
+ vec3 shaded_color = diffuse_light * diffuse_color.rgb + specular_color;
- float alpha = 0.5 ;
- vec4 premultiplied = vec4(shaded_color.rgb * alpha, alpha);
- transparentAccum = calculate_transparent_accum(premultiplied);
+ /* Based on :
+ * McGuire and Bavoil, Weighted Blended Order-Independent Transparency, Journal of
+ * Computer Graphics Techniques (JCGT), vol. 2, no. 2, 122–141, 2013
+ */
+ /* Listing 4 */
+ float z = linear_zdepth(gl_FragCoord.z, viewvecs, ProjectionMatrix);
+ float weight = calculate_transparent_weight(z, alpha);
+ transparentAccum = vec4(shaded_color * weight, alpha);
+ revealageAccum = weight;
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_revealage_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_revealage_frag.glsl
deleted file mode 100644
index da87fe8f542..00000000000
--- a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_revealage_frag.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-layout(location=0) out float transparentRevealage;
-
-void main()
-{
- transparentRevealage = 0.5;
-}
-
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
index 2cc0ff3723d..200850e3036 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
@@ -1,5 +1,9 @@
uniform int object_id = 0;
-uniform vec3 object_color = vec3(1.0, 0.0, 1.0);
+
+layout(std140) uniform material_block {
+ MaterialData material_data;
+};
+
#ifdef OB_TEXTURE
uniform sampler2D image;
#endif
@@ -7,42 +11,67 @@ uniform sampler2D image;
#ifdef NORMAL_VIEWPORT_PASS_ENABLED
in vec3 normal_viewport;
#endif /* NORMAL_VIEWPORT_PASS_ENABLED */
+
#ifdef OB_TEXTURE
in vec2 uv_interp;
#endif /* OB_TEXTURE */
+#ifdef HAIR_SHADER
+flat in float hair_rand;
+#endif
+
layout(location=0) out uint objectId;
layout(location=1) out vec4 diffuseColor;
+layout(location=2) out vec4 specularColor;
#ifdef NORMAL_VIEWPORT_PASS_ENABLED
- #ifdef WORKBENCH_ENCODE_NORMALS
-layout(location=2) out vec2 normalViewport;
- #else /* WORKBENCH_ENCODE_NORMALS */
-layout(location=2) out vec3 normalViewport;
- #endif /* WORKBENCH_ENCODE_NORMALS */
+# ifdef WORKBENCH_ENCODE_NORMALS
+layout(location=3) out vec2 normalViewport;
+# else /* WORKBENCH_ENCODE_NORMALS */
+layout(location=3) out vec3 normalViewport;
+# endif /* WORKBENCH_ENCODE_NORMALS */
#endif /* NORMAL_VIEWPORT_PASS_ENABLED */
void main()
{
objectId = uint(object_id);
+
+#ifdef NORMAL_VIEWPORT_PASS_ENABLED
+ vec3 n = (gl_FrontFacing) ? normal_viewport : -normal_viewport;
+ n = normalize(n);
+#endif
+
#ifdef OB_SOLID
- diffuseColor = vec4(object_color, 0.0);
+ diffuseColor = vec4(material_data.diffuse_color.rgb, 0.0);
+# ifdef STUDIOLIGHT_ORIENTATION_VIEWNORMAL
+
+ specularColor = vec4(material_data.diffuse_color.rgb, 0.0);
+# endif
#endif /* OB_SOLID */
+
#ifdef OB_TEXTURE
diffuseColor = texture(image, uv_interp);
#endif /* OB_TEXTURE */
+#ifdef HAIR_SHADER
+ float hair_color_variation = hair_rand * 0.1;
+ diffuseColor.rgb = clamp(diffuseColor.rgb - hair_color_variation, 0.0, 1.0);
+#endif
+
+#ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
+ specularColor = vec4(material_data.specular_color.rgb, material_data.roughness);
+# ifdef HAIR_SHADER
+ specularColor.rgb = clamp(specularColor.rgb - hair_color_variation, 0.0, 1.0);
+# endif
+#endif
#ifdef NORMAL_VIEWPORT_PASS_ENABLED
- #ifdef WORKBENCH_ENCODE_NORMALS
- if (!gl_FrontFacing) {
- normalViewport = normal_encode(normalize(-normal_viewport));
- diffuseColor.a = 1.0;
- }
- else {
- normalViewport = normal_encode(normalize(normal_viewport));
- diffuseColor.a = 0.0;
- }
- #else /* WORKBENCH_ENCODE_NORMALS */
- normalViewport = normal_viewport;
- #endif /* WORKBENCH_ENCODE_NORMALS */
+# ifdef WORKBENCH_ENCODE_NORMALS
+ diffuseColor.a = float(gl_FrontFacing);
+ normalViewport = normal_encode(n);
+# else /* WORKBENCH_ENCODE_NORMALS */
+ normalViewport = n;
+# endif /* WORKBENCH_ENCODE_NORMALS */
+# ifdef HAIR_SHADER
+ diffuseColor.a = 0.5;
+# endif
#endif /* NORMAL_VIEWPORT_PASS_ENABLED */
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
index f2df117d897..82443e7336b 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
@@ -1,30 +1,68 @@
uniform mat4 ModelViewProjectionMatrix;
-#ifdef NORMAL_VIEWPORT_PASS_ENABLED
+uniform mat4 ProjectionMatrix;
+uniform mat4 ViewProjectionMatrix;
+uniform mat4 ViewMatrixInverse;
uniform mat3 NormalMatrix;
-#endif /* NORMAL_VIEWPORT_PASS_ENABLED */
+#ifndef HAIR_SHADER
in vec3 pos;
-#ifdef NORMAL_VIEWPORT_PASS_ENABLED
in vec3 nor;
-#endif /* NORMAL_VIEWPORT_PASS_ENABLED */
-#ifdef OB_TEXTURE
in vec2 uv;
-#endif
+#else /* HAIR_SHADER */
+# ifdef OB_TEXTURE
+uniform samplerBuffer u; /* active texture layer */
+# endif
+flat out float hair_rand;
+#endif /* HAIR_SHADER */
#ifdef NORMAL_VIEWPORT_PASS_ENABLED
out vec3 normal_viewport;
-#endif /* NORMAL_VIEWPORT_PASS_ENABLED */
+#endif
+
#ifdef OB_TEXTURE
out vec2 uv_interp;
#endif
+/* From http://libnoise.sourceforge.net/noisegen/index.html */
+float integer_noise(int n)
+{
+ n = (n >> 13) ^ n;
+ int nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
+ return (float(nn) / 1073741824.0);
+}
+
void main()
{
+#ifdef HAIR_SHADER
+# ifdef OB_TEXTURE
+ vec2 uv = hair_get_customdata_vec2(u);
+# endif
+ float time, thick_time, thickness;
+ vec3 pos, tan, binor;
+ hair_get_pos_tan_binor_time(
+ (ProjectionMatrix[3][3] == 0.0),
+ ViewMatrixInverse[3].xyz, ViewMatrixInverse[2].xyz,
+ pos, tan, binor, time, thickness, thick_time);
+ /* To "simulate" anisotropic shading, randomize hair normal per strand. */
+ hair_rand = integer_noise(hair_get_strand_id());
+ tan = normalize(tan);
+ vec3 nor = normalize(cross(binor, tan));
+ nor = normalize(mix(nor, -tan, hair_rand * 0.10));
+ float cos_theta = (hair_rand*2.0 - 1.0) * 0.20;
+ float sin_theta = sqrt(max(0.0, 1.0f - cos_theta*cos_theta));
+ nor = nor * sin_theta + binor * cos_theta;
+ gl_Position = ViewProjectionMatrix * vec4(pos, 1.0);
+#else
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+#endif
#ifdef OB_TEXTURE
uv_interp = uv;
#endif
+
#ifdef NORMAL_VIEWPORT_PASS_ENABLED
- normal_viewport = normalize(NormalMatrix * nor);
-#endif /* NORMAL_VIEWPORT_PASS_ENABLED */
- gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+ normal_viewport = NormalMatrix * nor;
+# ifndef HAIR_SHADER
+ normal_viewport = normalize(normal_viewport);
+# endif
+#endif
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl b/source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl
index 32b31718cf8..948392bd8ee 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl
@@ -6,9 +6,9 @@
#ifdef DOUBLE_MANIFOLD
# ifdef USE_INVOC_EXT
-# define invoc_ct 4
+# define invoc_ct 2
# else
-# define vert_ct 12
+# define vert_ct 6
# endif
#else
# ifdef USE_INVOC_EXT
@@ -39,17 +39,17 @@ vec4 get_pos(int v, bool backface)
return (backface) ? vData[v].backPosition : vData[v].frontPosition;
}
-void emit_cap(const bool front)
+void emit_cap(const bool front, bool reversed)
{
if (front) {
gl_Position = vData[0].frontPosition; EmitVertex();
- gl_Position = vData[1].frontPosition; EmitVertex();
- gl_Position = vData[2].frontPosition; EmitVertex();
+ gl_Position = vData[reversed ? 2 : 1].frontPosition; EmitVertex();
+ gl_Position = vData[reversed ? 1 : 2].frontPosition; EmitVertex();
}
else {
gl_Position = vData[0].backPosition; EmitVertex();
- gl_Position = vData[2].backPosition; EmitVertex();
- gl_Position = vData[1].backPosition; EmitVertex();
+ gl_Position = vData[reversed ? 1 : 2].backPosition; EmitVertex();
+ gl_Position = vData[reversed ? 2 : 1].backPosition; EmitVertex();
}
EndPrimitive();
}
@@ -64,17 +64,22 @@ void main()
bool backface = facing > 0.0;
+#ifdef DOUBLE_MANIFOLD
+ /* In case of non manifold geom, we only increase/decrease
+ * the stencil buffer by one but do every faces as they were facing the light. */
+ bool invert = backface;
+#else
+ const bool invert = false;
if (!backface) {
+#endif
#ifdef USE_INVOC_EXT
bool do_front = (gl_InvocationID & 1) == 0;
- emit_cap(do_front);
+ emit_cap(do_front, invert);
#else
- emit_cap(true);
- emit_cap(false);
-# ifdef DOUBLE_MANIFOLD
- emit_cap(true);
- emit_cap(false);
-# endif
+ emit_cap(true, invert);
+ emit_cap(false, invert);
#endif
+#ifndef DOUBLE_MANIFOLD
}
+#endif
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl
index 3a61bf0a286..50a721f948f 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl
@@ -3,6 +3,7 @@
uniform mat4 ModelViewProjectionMatrix;
uniform vec3 lightDirection = vec3(0.57, 0.57, -0.57);
+uniform float lightDistance = 1e4;
in vec3 pos;
@@ -16,5 +17,5 @@ void main()
{
vData.pos = pos;
vData.frontPosition = ModelViewProjectionMatrix * vec4(pos, 1.0);
- vData.backPosition = ModelViewProjectionMatrix * vec4(pos + lightDirection * INFINITE, 1.0);
+ vData.backPosition = ModelViewProjectionMatrix * vec4(pos + lightDirection * lightDistance, 1.0);
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl
index 6507f1ec707..9d256e5350a 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl
@@ -1,3 +1,5 @@
+#define BLINN
+
vec3 get_world_diffuse_light(WorldData world_data, vec3 N)
{
vec4 result = world_data.diffuse_light_x_pos * clamp(N.x, 0.0, 1.0);
@@ -16,5 +18,45 @@ vec3 get_camera_diffuse_light(WorldData world_data, vec3 N)
result = mix(result, world_data.diffuse_light_z_neg, clamp(-N.y, 0.0, 1.0));
result = mix(result, world_data.diffuse_light_y_pos, clamp( N.z, 0.0, 1.0));
result = mix(result, world_data.diffuse_light_y_neg, clamp(-N.z, 0.0, 1.0));
- return result.xyz;
+ return result.rgb;
+}
+
+/* N And I are in View Space. */
+vec3 get_world_specular_light(vec4 specular_data, LightData light_data, vec3 N, vec3 I)
+{
+#ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
+ vec3 specular_light = specular_data.rgb * light_data.specular_color.rgb * light_data.specular_color.a;
+
+ float shininess = exp2(10*(1.0-specular_data.a) + 1);
+
+# ifdef BLINN
+ float normalization_factor = (shininess + 8) / (8 * M_PI);
+ vec3 L = -light_data.light_direction_vs.xyz;
+ vec3 halfDir = normalize(L + I);
+ float specAngle = max(dot(halfDir, N), 0.0);
+ float NL = max(dot(L, N), 0.0);
+ float specular_influence = pow(specAngle, shininess) * NL * normalization_factor;
+
+# else
+ vec3 reflection_vector = reflect(I, N);
+ float specAngle = max(dot(light_data.light_direction_vs.xyz, reflection_vector), 0.0);
+ float specular_influence = pow(specAngle, shininess);
+# endif
+
+ vec3 specular_color = specular_light * specular_influence;
+
+#else /* V3D_SHADING_SPECULAR_HIGHLIGHT */
+ vec3 specular_color = vec3(0.0);
+#endif /* V3D_SHADING_SPECULAR_HIGHLIGHT */
+ return specular_color;
+}
+
+vec3 get_world_specular_lights(WorldData world_data, vec4 specular_data, vec3 N, vec3 I)
+{
+ vec3 specular_light = vec3(0.0);
+ specular_light += get_world_specular_light(specular_data, world_data.lights[0], N, I);
+ for (int i = 0 ; i < world_data.num_lights ; i ++) {
+ specular_light += get_world_specular_light(specular_data, world_data.lights[i], N, I);
+ }
+ return specular_light;
}
diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c
index bbd8c57a5b9..df0a2bf4684 100644
--- a/source/blender/draw/engines/workbench/workbench_data.c
+++ b/source/blender/draw/engines/workbench/workbench_data.c
@@ -1,17 +1,28 @@
#include "workbench_private.h"
+#include "DNA_userdef_types.h"
+
#include "UI_resources.h"
+
void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
+ const Scene *scene = draw_ctx->scene;
wpd->material_hash = BLI_ghash_ptr_new(__func__);
View3D *v3d = draw_ctx->v3d;
if (v3d) {
wpd->shading = v3d->shading;
wpd->drawtype = v3d->drawtype;
- wpd->studio_light = BKE_studiolight_find(wpd->shading.studio_light, 0);
+ if (wpd->shading.light == V3D_LIGHTING_MATCAP) {
+ wpd->studio_light = BKE_studiolight_find(
+ wpd->shading.matcap, STUDIOLIGHT_ORIENTATION_VIEWNORMAL);
+ }
+ else {
+ wpd->studio_light = BKE_studiolight_find(
+ wpd->shading.studio_light, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD);
+ }
}
else {
memset(&wpd->shading, 0, sizeof(wpd->shading));
@@ -19,18 +30,28 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
wpd->shading.shadow_intensity = 0.5;
copy_v3_fl(wpd->shading.single_color, 0.8f);
wpd->drawtype = OB_SOLID;
- wpd->studio_light = BKE_studiolight_findindex(0);
+ wpd->studio_light = BKE_studiolight_find_first(STUDIOLIGHT_INTERNAL);
}
wpd->shadow_multiplier = 1.0 - wpd->shading.shadow_intensity;
WORKBENCH_UBO_World *wd = &wpd->world_data;
- UI_GetThemeColor3fv(UI_GetThemeValue(TH_SHOW_BACK_GRAD) ? TH_LOW_GRAD : TH_HIGH_GRAD, wd->background_color_low);
- UI_GetThemeColor3fv(TH_HIGH_GRAD, wd->background_color_high);
+ wd->matcap_orientation = (wpd->shading.flag & V3D_SHADING_MATCAP_FLIP_X) > 0;
- /* XXX: Really quick conversion to avoid washed out background.
- * Needs to be adressed properly (color managed using ocio). */
- srgb_to_linearrgb_v3_v3(wd->background_color_high, wd->background_color_high);
- srgb_to_linearrgb_v3_v3(wd->background_color_low, wd->background_color_low);
+ if ((v3d->flag3 & V3D_SHOW_WORLD) &&
+ (scene->world != NULL))
+ {
+ copy_v3_v3(wd->background_color_low, &scene->world->horr);
+ copy_v3_v3(wd->background_color_high, &scene->world->horr);
+ }
+ else {
+ UI_GetThemeColor3fv(UI_GetThemeValue(TH_SHOW_BACK_GRAD) ? TH_LOW_GRAD : TH_HIGH_GRAD, wd->background_color_low);
+ UI_GetThemeColor3fv(TH_HIGH_GRAD, wd->background_color_high);
+
+ /* XXX: Really quick conversion to avoid washed out background.
+ * Needs to be adressed properly (color managed using ocio). */
+ srgb_to_linearrgb_v3_v3(wd->background_color_high, wd->background_color_high);
+ srgb_to_linearrgb_v3_v3(wd->background_color_low, wd->background_color_low);
+ }
studiolight_update_world(wpd->studio_light, wd);
@@ -38,10 +59,126 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
wd->object_outline_color[3] = 1.0f;
wpd->world_ubo = DRW_uniformbuffer_create(sizeof(WORKBENCH_UBO_World), &wpd->world_data);
+
+ /* Cavity settings */
+ {
+ const int ssao_samples = scene->display.matcap_ssao_samples;
+
+ float invproj[4][4];
+ float dfdyfacs[2];
+ const bool is_persp = DRW_viewport_is_persp_get();
+ /* view vectors for the corners of the view frustum.
+ * Can be used to recreate the world space position easily */
+ float viewvecs[3][4] = {
+ {-1.0f, -1.0f, -1.0f, 1.0f},
+ {1.0f, -1.0f, -1.0f, 1.0f},
+ {-1.0f, 1.0f, -1.0f, 1.0f}
+ };
+ int i;
+ const float *size = DRW_viewport_size_get();
+
+ DRW_state_dfdy_factors_get(dfdyfacs);
+
+ wpd->ssao_params[0] = ssao_samples;
+ wpd->ssao_params[1] = size[0] / 64.0;
+ wpd->ssao_params[2] = size[1] / 64.0;
+ wpd->ssao_params[3] = dfdyfacs[1]; /* dfdy sign for offscreen */
+
+ /* distance, factor, factor, attenuation */
+ copy_v4_fl4(wpd->ssao_settings, scene->display.matcap_ssao_distance, wpd->shading.cavity_valley_factor, wpd->shading.cavity_ridge_factor, scene->display.matcap_ssao_attenuation);
+
+ /* invert the view matrix */
+ DRW_viewport_matrix_get(wpd->winmat, DRW_MAT_WIN);
+ invert_m4_m4(invproj, wpd->winmat);
+
+ /* convert the view vectors to view space */
+ for (i = 0; i < 3; i++) {
+ mul_m4_v4(invproj, viewvecs[i]);
+ /* normalized trick see:
+ * http://www.derschmale.com/2014/01/26/reconstructing-positions-from-the-depth-buffer */
+ mul_v3_fl(viewvecs[i], 1.0f / viewvecs[i][3]);
+ if (is_persp)
+ mul_v3_fl(viewvecs[i], 1.0f / viewvecs[i][2]);
+ viewvecs[i][3] = 1.0;
+
+ copy_v4_v4(wpd->viewvecs[i], viewvecs[i]);
+ }
+
+ /* we need to store the differences */
+ wpd->viewvecs[1][0] -= wpd->viewvecs[0][0];
+ wpd->viewvecs[1][1] = wpd->viewvecs[2][1] - wpd->viewvecs[0][1];
+
+ /* calculate a depth offset as well */
+ if (!is_persp) {
+ float vec_far[] = {-1.0f, -1.0f, 1.0f, 1.0f};
+ mul_m4_v4(invproj, vec_far);
+ mul_v3_fl(vec_far, 1.0f / vec_far[3]);
+ wpd->viewvecs[1][2] = vec_far[2] - wpd->viewvecs[0][2];
+ }
+ }
+
+}
+
+void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, float light_direction[3])
+{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ Scene *scene = draw_ctx->scene;
+ WORKBENCH_UBO_World *wd = &wpd->world_data;
+ float view_matrix[4][4];
+ DRW_viewport_matrix_get(view_matrix, DRW_MAT_VIEW);
+
+ {
+ WORKBENCH_UBO_Light *light = &wd->lights[0];
+ mul_v3_mat3_m4v3(light->light_direction_vs, view_matrix, light_direction);
+ light->light_direction_vs[3] = 0.0f;
+ copy_v3_fl(light->specular_color, 1.0f);
+ light->energy = 1.0f;
+ copy_v4_v4(wd->light_direction_vs, light->light_direction_vs);
+ wd->num_lights = 1;
+ }
+
+ if (!STUDIOLIGHT_ORIENTATION_WORLD_ENABLED(wpd)) {
+ int light_index = 0;
+ for (int index = 0 ; index < 3; index++) {
+ SolidLight *sl = &U.light[index];
+ if (sl->flag) {
+ WORKBENCH_UBO_Light *light = &wd->lights[light_index++];
+ copy_v4_v4(light->light_direction_vs, sl->vec);
+ negate_v3(light->light_direction_vs);
+ copy_v4_v4(light->specular_color, sl->spec);
+ light->energy = 1.0f;
+ }
+ }
+ wd->num_lights = light_index;
+ }
+
+#if 0
+ if (STUDIOLIGHT_ORIENTATION_WORLD_ENABLED(wpd)) {
+ BKE_studiolight_ensure_flag(wpd->studio_light, STUDIOLIGHT_LIGHT_DIRECTION_CALCULATED);
+ float rot_matrix[3][3];
+ axis_angle_to_mat3_single(rot_matrix, 'Z', wpd->shading.studiolight_rot_z);
+ mul_v3_m3v3(e_data.display.light_direction, rot_matrix, wpd->studio_light->light_direction);
+ }
+ else {
+#else
+ {
+#endif
+ copy_v3_v3(light_direction, scene->display.light_direction);
+ negate_v3(light_direction);
+ }
+
+ DRW_uniformbuffer_update(wpd->world_ubo, &wpd->world_data);
+}
+
+static void workbench_private_material_free(void *data)
+{
+ WORKBENCH_MaterialData *material_data = data;
+ DRW_UBO_FREE_SAFE(material_data->material_ubo);
+ MEM_freeN(material_data);
}
void workbench_private_data_free(WORKBENCH_PrivateData *wpd)
{
- BLI_ghash_free(wpd->material_hash, NULL, MEM_freeN);
+ BLI_ghash_free(wpd->material_hash, NULL, workbench_private_material_free);
DRW_UBO_FREE_SAFE(wpd->world_ubo);
}
diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c
index 6a96822984d..37978882abe 100644
--- a/source/blender/draw/engines/workbench/workbench_deferred.c
+++ b/source/blender/draw/engines/workbench/workbench_deferred.c
@@ -30,6 +30,7 @@
#include "BLI_alloca.h"
#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
+#include "BLI_rand.h"
#include "BKE_node.h"
#include "BKE_particle.h"
@@ -44,6 +45,7 @@
#include "GPU_shader.h"
#include "GPU_texture.h"
+#include "../eevee/eevee_lut.h" /* TODO find somewhere to share blue noise Table */
/* *********** STATIC *********** */
@@ -56,6 +58,7 @@
static struct {
struct GPUShader *prepass_sh_cache[MAX_SHADERS];
struct GPUShader *composite_sh_cache[MAX_SHADERS];
+ struct GPUShader *cavity_sh;
struct GPUShader *shadow_fail_sh;
struct GPUShader *shadow_fail_manifold_sh;
struct GPUShader *shadow_pass_sh;
@@ -65,6 +68,8 @@ static struct {
struct GPUTexture *object_id_tx; /* ref only, not alloced */
struct GPUTexture *color_buffer_tx; /* ref only, not alloced */
+ struct GPUTexture *cavity_buffer_tx; /* ref only, not alloced */
+ struct GPUTexture *specular_buffer_tx; /* ref only, not alloced */
struct GPUTexture *normal_buffer_tx; /* ref only, not alloced */
struct GPUTexture *composite_buffer_tx; /* ref only, not alloced */
@@ -72,11 +77,18 @@ static struct {
float light_direction_vs[3];
int next_object_id;
float normal_world_matrix[3][3];
+
+ struct GPUUniformBuffer *sampling_ubo;
+ struct GPUTexture *jitter_tx;
+ int cached_sample_num;
} e_data = {{NULL}};
/* Shaders */
+extern char datatoc_common_hair_lib_glsl[];
+
extern char datatoc_workbench_prepass_vert_glsl[];
extern char datatoc_workbench_prepass_frag_glsl[];
+extern char datatoc_workbench_cavity_frag_glsl[];
extern char datatoc_workbench_deferred_composite_frag_glsl[];
extern char datatoc_workbench_shadow_vert_glsl[];
@@ -85,6 +97,7 @@ extern char datatoc_workbench_shadow_caps_geom_glsl[];
extern char datatoc_workbench_shadow_debug_frag_glsl[];
extern char datatoc_workbench_background_lib_glsl[];
+extern char datatoc_workbench_cavity_lib_glsl[];
extern char datatoc_workbench_common_lib_glsl[];
extern char datatoc_workbench_data_lib_glsl[];
extern char datatoc_workbench_object_outline_lib_glsl[];
@@ -100,7 +113,7 @@ static char *workbench_build_composite_frag(WORKBENCH_PrivateData *wpd)
BLI_dynstr_append(ds, datatoc_workbench_common_lib_glsl);
BLI_dynstr_append(ds, datatoc_workbench_background_lib_glsl);
- if (wpd->shading.light & V3D_LIGHTING_STUDIO) {
+ if ((wpd->shading.light & V3D_LIGHTING_MATCAP) || (wpd->shading.light & V3D_LIGHTING_STUDIO) || (wpd->shading.flag & V3D_SHADING_SPECULAR_HIGHLIGHT)) {
BLI_dynstr_append(ds, datatoc_workbench_world_light_lib_glsl);
}
if (wpd->shading.flag & V3D_SHADING_OBJECT_OUTLINE) {
@@ -120,6 +133,7 @@ static char *workbench_build_prepass_frag(void)
DynStr *ds = BLI_dynstr_new();
+ BLI_dynstr_append(ds, datatoc_workbench_data_lib_glsl);
BLI_dynstr_append(ds, datatoc_workbench_common_lib_glsl);
BLI_dynstr_append(ds, datatoc_workbench_prepass_frag_glsl);
@@ -128,17 +142,49 @@ static char *workbench_build_prepass_frag(void)
return str;
}
-static void ensure_deferred_shaders(WORKBENCH_PrivateData *wpd, int index, int drawtype)
+static char *workbench_build_prepass_vert(void)
+{
+ char *str = NULL;
+
+ DynStr *ds = BLI_dynstr_new();
+
+ BLI_dynstr_append(ds, datatoc_common_hair_lib_glsl);
+ BLI_dynstr_append(ds, datatoc_workbench_prepass_vert_glsl);
+
+ str = BLI_dynstr_get_cstring(ds);
+ BLI_dynstr_free(ds);
+ return str;
+}
+
+static char *workbench_build_cavity_frag(void)
+{
+ char *str = NULL;
+
+ DynStr *ds = BLI_dynstr_new();
+
+ BLI_dynstr_append(ds, datatoc_workbench_common_lib_glsl);
+ BLI_dynstr_append(ds, datatoc_workbench_cavity_frag_glsl);
+ BLI_dynstr_append(ds, datatoc_workbench_cavity_lib_glsl);
+
+ str = BLI_dynstr_get_cstring(ds);
+ BLI_dynstr_free(ds);
+ return str;
+}
+
+static void ensure_deferred_shaders(WORKBENCH_PrivateData *wpd, int index, int drawtype, bool is_hair)
{
if (e_data.prepass_sh_cache[index] == NULL) {
- char *defines = workbench_material_build_defines(wpd, drawtype);
+ char *defines = workbench_material_build_defines(wpd, drawtype, is_hair);
char *composite_frag = workbench_build_composite_frag(wpd);
+ char *prepass_vert = workbench_build_prepass_vert();
char *prepass_frag = workbench_build_prepass_frag();
e_data.prepass_sh_cache[index] = DRW_shader_create(
- datatoc_workbench_prepass_vert_glsl, NULL, prepass_frag, defines);
- if (drawtype == OB_SOLID) {
+ prepass_vert, NULL,
+ prepass_frag, defines);
+ if (drawtype == OB_SOLID && !is_hair) {
e_data.composite_sh_cache[index] = DRW_shader_create_fullscreen(composite_frag, defines);
}
+ MEM_freeN(prepass_vert);
MEM_freeN(prepass_frag);
MEM_freeN(composite_frag);
MEM_freeN(defines);
@@ -147,24 +193,74 @@ static void ensure_deferred_shaders(WORKBENCH_PrivateData *wpd, int index, int d
static void select_deferred_shaders(WORKBENCH_PrivateData *wpd)
{
- int index_solid = workbench_material_get_shader_index(wpd, OB_SOLID);
- int index_texture = workbench_material_get_shader_index(wpd, OB_TEXTURE);
+ int index_solid = workbench_material_get_shader_index(wpd, OB_SOLID, false);
+ int index_solid_hair = workbench_material_get_shader_index(wpd, OB_SOLID, true);
+ int index_texture = workbench_material_get_shader_index(wpd, OB_TEXTURE, false);
+ int index_texture_hair = workbench_material_get_shader_index(wpd, OB_TEXTURE, true);
- ensure_deferred_shaders(wpd, index_solid, OB_SOLID);
- ensure_deferred_shaders(wpd, index_texture, OB_TEXTURE);
+ ensure_deferred_shaders(wpd, index_solid, OB_SOLID, false);
+ ensure_deferred_shaders(wpd, index_solid_hair, OB_SOLID, true);
+ ensure_deferred_shaders(wpd, index_texture, OB_TEXTURE, false);
+ ensure_deferred_shaders(wpd, index_texture_hair, OB_TEXTURE, true);
wpd->prepass_solid_sh = e_data.prepass_sh_cache[index_solid];
+ wpd->prepass_solid_hair_sh = e_data.prepass_sh_cache[index_solid_hair];
wpd->prepass_texture_sh = e_data.prepass_sh_cache[index_texture];
+ wpd->prepass_texture_hair_sh = e_data.prepass_sh_cache[index_texture_hair];
wpd->composite_sh = e_data.composite_sh_cache[index_solid];
}
+
+/* Using Hammersley distribution */
+static float *create_disk_samples(int num_samples)
+{
+ /* vec4 to ensure memory alignment. */
+ float (*texels)[4] = MEM_mallocN(sizeof(float[4]) * num_samples, "concentric_tex");
+ const float num_samples_inv = 1.0f / num_samples;
+
+ for (int i = 0; i < num_samples; i++) {
+ float r = (i + 0.5f) * num_samples_inv;
+ double dphi;
+ BLI_hammersley_1D(i, &dphi);
+
+ float phi = (float)dphi * 2.0f * M_PI;
+ texels[i][0] = cosf(phi);
+ texels[i][1] = sinf(phi);
+ /* This deliberatly distribute more samples
+ * at the center of the disk (and thus the shadow). */
+ texels[i][2] = r;
+ }
+
+ return (float *)texels;
+}
+
+static struct GPUTexture *create_jitter_texture(int num_samples)
+{
+ float jitter[64 * 64][3];
+ const float num_samples_inv = 1.0f / num_samples;
+
+ for (int i = 0; i < 64 * 64; i++) {
+ float phi = blue_noise[i][0] * 2.0f * M_PI;
+ /* This rotate the sample per pixels */
+ jitter[i][0] = cosf(phi);
+ jitter[i][1] = sinf(phi);
+ /* This offset the sample along it's direction axis (reduce banding) */
+ float bn = blue_noise[i][1] - 0.5f;
+ CLAMP(bn, -0.499f, 0.499f); /* fix fireflies */
+ jitter[i][2] = bn * num_samples_inv;
+ }
+
+ UNUSED_VARS(bsdf_split_sum_ggx, btdf_split_sum_ggx, ltc_mag_ggx, ltc_mat_ggx, ltc_disk_integral);
+
+ return DRW_texture_create_2D(64, 64, GPU_RGB16F, DRW_TEX_FILTER | DRW_TEX_WRAP, &jitter[0][0]);
+}
/* Functions */
static void workbench_init_object_data(ObjectEngineData *engine_data)
{
WORKBENCH_ObjectData *data = (WORKBENCH_ObjectData *)engine_data;
- data->object_id = e_data.next_object_id++;
+ data->object_id = ((e_data.next_object_id++) & 0xff) + 1;
data->shadow_bbox_dirty = true;
}
@@ -217,6 +313,10 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
datatoc_workbench_shadow_caps_geom_glsl,
shadow_frag,
"#define SHADOW_FAIL\n");
+
+ char *cavity_frag = workbench_build_cavity_frag();
+ e_data.cavity_sh = DRW_shader_create_fullscreen(cavity_frag, NULL);
+ MEM_freeN(cavity_frag);
}
if (!stl->g_data) {
@@ -224,13 +324,16 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
}
- workbench_private_data_init(stl->g_data);
+ WORKBENCH_PrivateData *wpd = stl->g_data;
+ workbench_private_data_init(wpd);
{
const float *viewport_size = DRW_viewport_size_get();
const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
e_data.object_id_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_R32UI, &draw_engine_workbench_solid);
e_data.color_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8, &draw_engine_workbench_solid);
+ e_data.cavity_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RG16, &draw_engine_workbench_solid);
+ e_data.specular_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8, &draw_engine_workbench_solid);
e_data.composite_buffer_tx = DRW_texture_pool_query_2D(
size[0], size[1], GPU_RGBA16F, &draw_engine_workbench_solid);
@@ -247,18 +350,61 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
GPU_ATTACHMENT_TEXTURE(dtxl->depth),
GPU_ATTACHMENT_TEXTURE(e_data.object_id_tx),
GPU_ATTACHMENT_TEXTURE(e_data.color_buffer_tx),
+ GPU_ATTACHMENT_TEXTURE(e_data.specular_buffer_tx),
GPU_ATTACHMENT_TEXTURE(e_data.normal_buffer_tx),
});
+ GPU_framebuffer_ensure_config(&fbl->cavity_fb, {
+ GPU_ATTACHMENT_NONE,
+ GPU_ATTACHMENT_TEXTURE(e_data.cavity_buffer_tx),
+ });
GPU_framebuffer_ensure_config(&fbl->composite_fb, {
GPU_ATTACHMENT_TEXTURE(dtxl->depth),
GPU_ATTACHMENT_TEXTURE(e_data.composite_buffer_tx),
});
}
+ {
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ Scene *scene = draw_ctx->scene;
+ /* AO Samples Tex */
+ const int ssao_samples = scene->display.matcap_ssao_samples;
+ if (e_data.sampling_ubo && (e_data.cached_sample_num != ssao_samples)) {
+ DRW_UBO_FREE_SAFE(e_data.sampling_ubo);
+ DRW_TEXTURE_FREE_SAFE(e_data.jitter_tx);
+ }
+
+ if (e_data.sampling_ubo == NULL) {
+ float *samples = create_disk_samples(ssao_samples);
+ e_data.jitter_tx = create_jitter_texture(ssao_samples);
+ e_data.sampling_ubo = DRW_uniformbuffer_create(sizeof(float[4]) * ssao_samples, samples);
+ e_data.cached_sample_num = ssao_samples;
+ MEM_freeN(samples);
+ }
+ }
+
/* Prepass */
{
int state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL;
psl->prepass_pass = DRW_pass_create("Prepass", state);
+ psl->prepass_hair_pass = DRW_pass_create("Prepass", state);
+ }
+
+ {
+ int state = DRW_STATE_WRITE_COLOR;
+ psl->cavity_pass = DRW_pass_create("Cavity", state);
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.cavity_sh, psl->cavity_pass);
+ DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
+ DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &e_data.color_buffer_tx);
+ DRW_shgroup_uniform_texture_ref(grp, "normalBuffer", &e_data.normal_buffer_tx);
+
+ DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
+ DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)wpd->viewvecs, 3);
+ DRW_shgroup_uniform_vec4(grp, "ssao_params", wpd->ssao_params, 1);
+ DRW_shgroup_uniform_vec4(grp, "ssao_settings", wpd->ssao_settings, 1);
+ DRW_shgroup_uniform_mat4(grp, "WinMatrix", wpd->winmat);
+ DRW_shgroup_uniform_texture(grp, "ssao_jitter", e_data.jitter_tx);
+ DRW_shgroup_uniform_block(grp, "samples_block", e_data.sampling_ubo);
+ DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
}
}
@@ -268,24 +414,41 @@ void workbench_deferred_engine_free()
DRW_SHADER_FREE_SAFE(e_data.prepass_sh_cache[index]);
DRW_SHADER_FREE_SAFE(e_data.composite_sh_cache[index]);
}
+ DRW_SHADER_FREE_SAFE(e_data.cavity_sh);
+ DRW_UBO_FREE_SAFE(e_data.sampling_ubo);
+ DRW_TEXTURE_FREE_SAFE(e_data.jitter_tx);
+
DRW_SHADER_FREE_SAFE(e_data.shadow_pass_sh);
DRW_SHADER_FREE_SAFE(e_data.shadow_pass_manifold_sh);
DRW_SHADER_FREE_SAFE(e_data.shadow_fail_sh);
DRW_SHADER_FREE_SAFE(e_data.shadow_fail_manifold_sh);
DRW_SHADER_FREE_SAFE(e_data.shadow_caps_sh);
DRW_SHADER_FREE_SAFE(e_data.shadow_caps_manifold_sh);
+
}
static void workbench_composite_uniforms(WORKBENCH_PrivateData *wpd, DRWShadingGroup *grp)
{
DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &e_data.color_buffer_tx);
DRW_shgroup_uniform_texture_ref(grp, "objectId", &e_data.object_id_tx);
- if (NORMAL_VIEWPORT_PASS_ENABLED(wpd)) {
+ if (NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd)) {
DRW_shgroup_uniform_texture_ref(grp, "normalBuffer", &e_data.normal_buffer_tx);
}
+ if (CAVITY_ENABLED(wpd)) {
+ DRW_shgroup_uniform_texture_ref(grp, "cavityBuffer", &e_data.cavity_buffer_tx);
+ }
+ if (SPECULAR_HIGHLIGHT_ENABLED(wpd) || MATCAP_ENABLED(wpd)) {
+ DRW_shgroup_uniform_texture_ref(grp, "specularBuffer", &e_data.specular_buffer_tx);
+ DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)wpd->viewvecs, 3);
+ }
DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo);
DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
+ if (STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)) {
+ BKE_studiolight_ensure_flag(wpd->studio_light, STUDIOLIGHT_EQUIRECTANGULAR_RADIANCE_GPUTEXTURE);
+ DRW_shgroup_uniform_texture(grp, "matcapImage", wpd->studio_light->equirectangular_radiance_gputexture); DRW_shgroup_uniform_texture(grp, "matcapImage", wpd->studio_light->equirectangular_radiance_gputexture);
+ }
+
workbench_material_set_normal_world_matrix(grp, wpd, e_data.normal_world_matrix);
}
@@ -304,22 +467,10 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata)
select_deferred_shaders(wpd);
/* Deferred Mix Pass */
{
- copy_v3_v3(e_data.display.light_direction, scene->display.light_direction);
- negate_v3(e_data.display.light_direction);
-#if 0
- if (STUDIOLIGHT_ORIENTATION_WORLD_ENABLED(wpd)) {
- BKE_studiolight_ensure_flag(wpd->studio_light, STUDIOLIGHT_LIGHT_DIRECTION_CALCULATED);
- float rot_matrix[3][3];
- // float dir[3] = {0.57, 0.57, -0.57};
- axis_angle_to_mat3_single(rot_matrix, 'Z', wpd->shading.studiolight_rot_z);
- mul_v3_m3v3(e_data.display.light_direction, rot_matrix, wpd->studio_light->light_direction);
- }
-#endif
- float view_matrix[4][4];
- DRW_viewport_matrix_get(view_matrix, DRW_MAT_VIEW);
- mul_v3_mat3_m4v3(e_data.light_direction_vs, view_matrix, e_data.display.light_direction);
+ workbench_private_data_get_light_direction(wpd, e_data.display.light_direction);
e_data.display.shadow_shift = scene->display.shadow_shift;
+ copy_v3_v3(e_data.light_direction_vs, wpd->world_data.lights[0].light_direction_vs);
if (SHADOW_ENABLED(wpd)) {
psl->composite_pass = DRW_pass_create(
@@ -327,7 +478,6 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata)
grp = DRW_shgroup_create(wpd->composite_sh, psl->composite_pass);
workbench_composite_uniforms(wpd, grp);
DRW_shgroup_stencil_mask(grp, 0x00);
- DRW_shgroup_uniform_vec3(grp, "lightDirection", e_data.light_direction_vs, 1);
DRW_shgroup_uniform_float(grp, "lightMultiplier", &light_multiplier, 1);
DRW_shgroup_uniform_float(grp, "shadowMultiplier", &wpd->shadow_multiplier, 1);
DRW_shgroup_uniform_float(grp, "shadowShift", &scene->display.shadow_shift, 1);
@@ -349,8 +499,6 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata)
psl->shadow_depth_fail_caps_mani_pass = DRW_pass_create("Shadow Fail Caps Mani", depth_fail_state);
#ifndef DEBUG_SHADOW_VOLUME
- grp = DRW_shgroup_create(e_data.shadow_caps_sh, psl->shadow_depth_fail_caps_pass);
- DRW_shgroup_stencil_mask(grp, 0xFF);
grp = DRW_shgroup_create(e_data.shadow_pass_sh, psl->shadow_depth_pass_pass);
DRW_shgroup_stencil_mask(grp, 0xFF);
grp = DRW_shgroup_create(e_data.shadow_pass_manifold_sh, psl->shadow_depth_pass_mani_pass);
@@ -368,7 +516,6 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata)
grp = DRW_shgroup_create(wpd->composite_sh, psl->composite_shadow_pass);
DRW_shgroup_stencil_mask(grp, 0x00);
workbench_composite_uniforms(wpd, grp);
- DRW_shgroup_uniform_vec3(grp, "lightDirection", e_data.light_direction_vs, 1);
DRW_shgroup_uniform_float(grp, "lightMultiplier", &wpd->shadow_multiplier, 1);
DRW_shgroup_uniform_float(grp, "shadowMultiplier", &wpd->shadow_multiplier, 1);
DRW_shgroup_uniform_float(grp, "shadowShift", &scene->display.shadow_shift, 1);
@@ -399,8 +546,8 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
WORKBENCH_MaterialData material_template;
/* Solid */
- workbench_material_get_solid_color(wpd, ob, mat, material_template.color);
- material_template.object_id = engine_object_data->object_id;
+ workbench_material_update_data(wpd, ob, mat, &material_template);
+ material_template.object_id = OBJECT_ID_PASS_ENABLED(wpd) ? engine_object_data->object_id : 1;
material_template.drawtype = drawtype;
material_template.ima = ima;
uint hash = workbench_material_get_hash(&material_template);
@@ -411,11 +558,12 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
material->shgrp = DRW_shgroup_create(
drawtype == OB_SOLID ? wpd->prepass_solid_sh : wpd->prepass_texture_sh, psl->prepass_pass);
DRW_shgroup_stencil_mask(material->shgrp, 0xFF);
- material->object_id = engine_object_data->object_id;
- copy_v4_v4(material->color, material_template.color);
+ material->object_id = material_template.object_id;
+ copy_v4_v4(material->material_data.diffuse_color, material_template.material_data.diffuse_color);
+ copy_v4_v4(material->material_data.specular_color, material_template.material_data.specular_color);
+ material->material_data.roughness = material_template.material_data.roughness;
switch (drawtype) {
case OB_SOLID:
- DRW_shgroup_uniform_vec3(material->shgrp, "object_color", material->color, 1);
break;
case OB_TEXTURE:
@@ -426,6 +574,9 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
}
}
DRW_shgroup_uniform_int(material->shgrp, "object_id", &material->object_id, 1);
+ material->material_ubo = DRW_uniformbuffer_create(sizeof(WORKBENCH_UBO_Material), &material->material_data);
+ DRW_shgroup_uniform_block(material->shgrp, "material_block", material->material_ubo);
+
BLI_ghash_insert(wpd->material_hash, SET_UINT_IN_POINTER(hash), material);
}
return material;
@@ -433,27 +584,56 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
static void workbench_cache_populate_particles(WORKBENCH_Data *vedata, Object *ob)
{
+ WORKBENCH_StorageList *stl = vedata->stl;
+ WORKBENCH_PassList *psl = vedata->psl;
+ WORKBENCH_PrivateData *wpd = stl->g_data;
const DRWContextState *draw_ctx = DRW_context_state_get();
if (ob == draw_ctx->object_edit) {
return;
}
- for (ParticleSystem *psys = ob->particlesystem.first; psys != NULL; psys = psys->next) {
+ for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ if (md->type != eModifierType_ParticleSystem) {
+ continue;
+ }
+ ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
if (!psys_check_enabled(ob, psys, false)) {
continue;
}
if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
- return;
+ continue;
}
ParticleSettings *part = psys->part;
const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
- static float mat[4][4];
- unit_m4(mat);
-
if (draw_as == PART_DRAW_PATH) {
- struct Gwn_Batch *geom = DRW_cache_particles_get_hair(ob, psys, NULL);
- WORKBENCH_MaterialData *material = get_or_create_material_data(vedata, ob, NULL, NULL, OB_SOLID);
- DRW_shgroup_call_add(material->shgrp, geom, mat);
+ Image *image = NULL;
+ Material *mat = give_current_material(ob, part->omat);
+ int mat_drawtype = OB_SOLID;
+
+ if (wpd->drawtype == OB_TEXTURE) {
+ ED_object_get_active_image(ob, part->omat, &image, NULL, NULL, NULL);
+ /* use OB_SOLID when no texture could be determined */
+ if (image) {
+ mat_drawtype = OB_TEXTURE;
+ }
+ }
+
+ WORKBENCH_MaterialData *material = get_or_create_material_data(vedata, ob, mat, image, mat_drawtype);
+
+ struct GPUShader *shader = (mat_drawtype == OB_SOLID)
+ ? wpd->prepass_solid_hair_sh
+ : wpd->prepass_texture_hair_sh;
+ DRWShadingGroup *shgrp = DRW_shgroup_hair_create(
+ ob, psys, md,
+ psl->prepass_hair_pass,
+ shader);
+ DRW_shgroup_stencil_mask(shgrp, 0xFF);
+ DRW_shgroup_uniform_int(shgrp, "object_id", &material->object_id, 1);
+ DRW_shgroup_uniform_block(shgrp, "material_block", material->material_ubo);
+ if (image) {
+ GPUTexture *tex = GPU_texture_from_blender(image, NULL, GL_TEXTURE_2D, false, false, false);
+ DRW_shgroup_uniform_texture(shgrp, "image", tex);
+ }
}
}
}
@@ -463,7 +643,6 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
WORKBENCH_StorageList *stl = vedata->stl;
WORKBENCH_PassList *psl = vedata->psl;
WORKBENCH_PrivateData *wpd = stl->g_data;
-
if (!DRW_object_is_renderable(ob))
return;
@@ -471,13 +650,17 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
workbench_cache_populate_particles(vedata, ob);
}
+ if (!DRW_check_object_visible_within_active_context(ob)) {
+ return;
+ }
+
WORKBENCH_MaterialData *material;
- if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) {
+ if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) {
const DRWContextState *draw_ctx = DRW_context_state_get();
const bool is_active = (ob == draw_ctx->obact);
const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
bool is_drawn = false;
- if (!is_sculpt_mode && wpd->drawtype == OB_TEXTURE && ob->type == OB_MESH) {
+ if (!is_sculpt_mode && wpd->drawtype == OB_TEXTURE && ELEM(ob->type, OB_MESH)) {
const Mesh *me = ob->data;
if (me->mloopuv) {
const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol));
@@ -485,6 +668,10 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
if (materials_len > 0 && geom_array) {
for (int i = 0; i < materials_len; i++) {
+ if (geom_array[i] == NULL) {
+ continue;
+ }
+
Material *mat = give_current_material(ob, i + 1);
Image *image;
ED_object_get_active_image(ob, i + 1, &image, NULL, NULL, NULL);
@@ -527,6 +714,10 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
ob, gpumat_array, materials_len, NULL, NULL, NULL);
if (mat_geom) {
for (int i = 0; i < materials_len; ++i) {
+ if (mat_geom[i] == NULL) {
+ continue;
+ }
+
Material *mat = give_current_material(ob, i + 1);
material = get_or_create_material_data(vedata, ob, mat, NULL, OB_SOLID);
DRW_shgroup_call_object_add(material->shgrp, mat_geom[i], ob);
@@ -557,13 +748,6 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
DRWShadingGroup *grp;
bool use_shadow_pass_technique = !studiolight_camera_in_object_shadow(wpd, ob, engine_object_data);
- /* Unless we expose a parameter to the user, it's better to use the depth pass technique if the object is
- * non manifold. Exposing a switch to the user to force depth fail in this case can be beneficial for
- * planes and non-closed terrains. */
- if (!is_manifold) {
- use_shadow_pass_technique = true;
- }
-
if (use_shadow_pass_technique) {
if (is_manifold) {
grp = DRW_shgroup_create(e_data.shadow_pass_manifold_sh, psl->shadow_depth_pass_mani_pass);
@@ -572,12 +756,15 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
grp = DRW_shgroup_create(e_data.shadow_pass_sh, psl->shadow_depth_pass_pass);
}
DRW_shgroup_uniform_vec3(grp, "lightDirection", engine_object_data->shadow_dir, 1);
+ DRW_shgroup_uniform_float_copy(grp, "lightDistance", 1e5f);
DRW_shgroup_call_add(grp, geom_shadow, ob->obmat);
#ifdef DEBUG_SHADOW_VOLUME
DRW_debug_bbox(&engine_object_data->shadow_bbox, (float[4]){1.0f, 0.0f, 0.0f, 1.0f});
#endif
}
else {
+ float extrude_distance = studiolight_object_shadow_distance(wpd, ob, engine_object_data);
+
/* TODO(fclem): only use caps if they are in the view frustum. */
const bool need_caps = true;
if (need_caps) {
@@ -588,6 +775,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
grp = DRW_shgroup_create(e_data.shadow_caps_sh, psl->shadow_depth_fail_caps_pass);
}
DRW_shgroup_uniform_vec3(grp, "lightDirection", engine_object_data->shadow_dir, 1);
+ DRW_shgroup_uniform_float_copy(grp, "lightDistance", extrude_distance);
DRW_shgroup_call_add(grp, DRW_cache_object_surface_get(ob), ob->obmat);
}
@@ -598,6 +786,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
grp = DRW_shgroup_create(e_data.shadow_fail_sh, psl->shadow_depth_fail_pass);
}
DRW_shgroup_uniform_vec3(grp, "lightDirection", engine_object_data->shadow_dir, 1);
+ DRW_shgroup_uniform_float_copy(grp, "lightDistance", extrude_distance);
DRW_shgroup_call_add(grp, geom_shadow, ob->obmat);
#ifdef DEBUG_SHADOW_VOLUME
DRW_debug_bbox(&engine_object_data->shadow_bbox, (float[4]){0.0f, 1.0f, 0.0f, 1.0f});
@@ -642,6 +831,13 @@ void workbench_deferred_draw_scene(WORKBENCH_Data *vedata)
/* clear in background */
GPU_framebuffer_bind(fbl->prepass_fb);
DRW_draw_pass(psl->prepass_pass);
+ DRW_draw_pass(psl->prepass_hair_pass);
+
+ if (CAVITY_ENABLED(wpd)) {
+ GPU_framebuffer_bind(fbl->cavity_fb);
+ DRW_draw_pass(psl->cavity_pass);
+ }
+
if (SHADOW_ENABLED(wpd)) {
#ifdef DEBUG_SHADOW_VOLUME
GPU_framebuffer_bind(fbl->composite_fb);
diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c
index d2c262bc4ac..1a387c8087c 100644
--- a/source/blender/draw/engines/workbench/workbench_forward.c
+++ b/source/blender/draw/engines/workbench/workbench_forward.c
@@ -50,28 +50,23 @@
static struct {
struct GPUShader *composite_sh_cache[MAX_SHADERS];
struct GPUShader *transparent_accum_sh_cache[MAX_SHADERS];
- struct GPUShader *transparent_revealage_sh;
struct GPUShader *object_outline_sh;
- struct GPUShader *depth_sh;
+ struct GPUShader *object_outline_hair_sh;
struct GPUShader *checker_depth_sh;
struct GPUTexture *object_id_tx; /* ref only, not alloced */
struct GPUTexture *transparent_accum_tx; /* ref only, not alloced */
-#ifdef WORKBENCH_REVEALAGE_ENABLED
struct GPUTexture *transparent_revealage_tx; /* ref only, not alloced */
-#endif
struct GPUTexture *composite_buffer_tx; /* ref only, not alloced */
int next_object_id;
float normal_world_matrix[3][3];
} e_data = {{NULL}};
/* Shaders */
+extern char datatoc_common_hair_lib_glsl[];
extern char datatoc_workbench_forward_composite_frag_glsl[];
extern char datatoc_workbench_forward_depth_frag_glsl[];
extern char datatoc_workbench_forward_transparent_accum_frag_glsl[];
-#ifdef WORKBENCH_REVEALAGE_ENABLED
-extern char datatoc_workbench_forward_transparent_revealage_frag_glsl[];
-#endif
extern char datatoc_workbench_data_lib_glsl[];
extern char datatoc_workbench_background_lib_glsl[];
extern char datatoc_workbench_checkerboard_depth_frag_glsl[];
@@ -95,37 +90,35 @@ static char *workbench_build_forward_depth_frag(void)
return str;
}
-static char *workbench_build_forward_transparent_accum_frag(void)
+static char *workbench_build_forward_vert(void)
{
char *str = NULL;
DynStr *ds = BLI_dynstr_new();
- BLI_dynstr_append(ds, datatoc_workbench_data_lib_glsl);
- BLI_dynstr_append(ds, datatoc_workbench_common_lib_glsl);
- BLI_dynstr_append(ds, datatoc_workbench_world_light_lib_glsl);
- BLI_dynstr_append(ds, datatoc_workbench_forward_transparent_accum_frag_glsl);
+ BLI_dynstr_append(ds, datatoc_common_hair_lib_glsl);
+ BLI_dynstr_append(ds, datatoc_workbench_prepass_vert_glsl);
str = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
return str;
}
-#ifdef WORKBENCH_REVEALAGE_ENABLED
-static char *workbench_build_forward_transparent_revealage_frag(void)
+static char *workbench_build_forward_transparent_accum_frag(void)
{
char *str = NULL;
DynStr *ds = BLI_dynstr_new();
+ BLI_dynstr_append(ds, datatoc_workbench_data_lib_glsl);
BLI_dynstr_append(ds, datatoc_workbench_common_lib_glsl);
- BLI_dynstr_append(ds, datatoc_workbench_forward_transparent_revealage_frag_glsl);
+ BLI_dynstr_append(ds, datatoc_workbench_world_light_lib_glsl);
+ BLI_dynstr_append(ds, datatoc_workbench_forward_transparent_accum_frag_glsl);
str = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
return str;
}
-#endif
static char *workbench_build_forward_composite_frag(void)
{
@@ -147,7 +140,7 @@ static char *workbench_build_forward_composite_frag(void)
static void workbench_init_object_data(ObjectEngineData *engine_data)
{
WORKBENCH_ObjectData *data = (WORKBENCH_ObjectData *)engine_data;
- data->object_id = e_data.next_object_id++;
+ data->object_id = ((e_data.next_object_id++) & 0xff) + 1;
}
static WORKBENCH_MaterialData *get_or_create_material_data(
@@ -163,8 +156,8 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
DRWShadingGroup *grp;
/* Solid */
- workbench_material_get_solid_color(wpd, ob, mat, material_template.color);
- material_template.object_id = engine_object_data->object_id;
+ workbench_material_update_data(wpd, ob, mat, &material_template);
+ material_template.object_id = OBJECT_ID_PASS_ENABLED(wpd) ? engine_object_data->object_id : 1;
material_template.drawtype = drawtype;
material_template.ima = ima;
uint hash = workbench_material_get_hash(&material_template);
@@ -178,12 +171,25 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
drawtype == OB_SOLID ? wpd->transparent_accum_sh : wpd->transparent_accum_texture_sh,
psl->transparent_accum_pass);
DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo);
+ DRW_shgroup_uniform_float(grp, "alpha", &wpd->shading.xray_alpha, 1);
+ DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)wpd->viewvecs, 3);
workbench_material_set_normal_world_matrix(grp, wpd, e_data.normal_world_matrix);
- copy_v4_v4(material->color, material_template.color);
+ material->object_id = engine_object_data->object_id;
+ copy_v4_v4(material->material_data.diffuse_color, material_template.material_data.diffuse_color);
+ copy_v4_v4(material->material_data.specular_color, material_template.material_data.specular_color);
+ material->material_data.roughness = material_template.material_data.roughness;
switch (drawtype) {
case OB_SOLID:
- DRW_shgroup_uniform_vec4(grp, "color", material->color, 1);
+ {
+ if (STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)) {
+ BKE_studiolight_ensure_flag(wpd->studio_light, STUDIOLIGHT_EQUIRECTANGULAR_RADIANCE_GPUTEXTURE);
+ DRW_shgroup_uniform_texture(grp, "matcapImage", wpd->studio_light->equirectangular_radiance_gputexture);
+ }
+ if (SPECULAR_HIGHLIGHT_ENABLED(wpd) || MATCAP_ENABLED(wpd)) {
+ DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
+ }
break;
+ }
case OB_TEXTURE:
{
@@ -192,6 +198,8 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
break;
}
}
+ material->material_ubo = DRW_uniformbuffer_create(sizeof(WORKBENCH_UBO_Material), &material->material_data);
+ DRW_shgroup_uniform_block(grp, "material_block", material->material_ubo);
material->shgrp = grp;
/* Depth */
@@ -203,10 +211,10 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
return material;
}
-static void ensure_forward_shaders(WORKBENCH_PrivateData *wpd, int index, int drawtype)
+static void ensure_forward_shaders(WORKBENCH_PrivateData *wpd, int index, int drawtype, bool is_hair)
{
- if (e_data.composite_sh_cache[index] == NULL && drawtype == OB_SOLID) {
- char *defines = workbench_material_build_defines(wpd, drawtype);
+ if (e_data.composite_sh_cache[index] == NULL && drawtype == OB_SOLID && !is_hair) {
+ char *defines = workbench_material_build_defines(wpd, drawtype, is_hair);
char *composite_frag = workbench_build_forward_composite_frag();
e_data.composite_sh_cache[index] = DRW_shader_create_fullscreen(composite_frag, defines);
MEM_freeN(composite_frag);
@@ -214,27 +222,35 @@ static void ensure_forward_shaders(WORKBENCH_PrivateData *wpd, int index, int dr
}
if (e_data.transparent_accum_sh_cache[index] == NULL) {
- char *defines = workbench_material_build_defines(wpd, drawtype);
+ char *defines = workbench_material_build_defines(wpd, drawtype, is_hair);
+ char *transparent_accum_vert = workbench_build_forward_vert();
char *transparent_accum_frag = workbench_build_forward_transparent_accum_frag();
e_data.transparent_accum_sh_cache[index] = DRW_shader_create(
- datatoc_workbench_prepass_vert_glsl, NULL, transparent_accum_frag, defines);
+ transparent_accum_vert, NULL,
+ transparent_accum_frag, defines);
+ MEM_freeN(transparent_accum_vert);
MEM_freeN(transparent_accum_frag);
-
MEM_freeN(defines);
}
}
static void select_forward_shaders(WORKBENCH_PrivateData *wpd)
{
- int index_solid = workbench_material_get_shader_index(wpd, OB_SOLID);
- int index_texture = workbench_material_get_shader_index(wpd, OB_TEXTURE);
+ int index_solid = workbench_material_get_shader_index(wpd, OB_SOLID, false);
+ int index_solid_hair = workbench_material_get_shader_index(wpd, OB_SOLID, true);
+ int index_texture = workbench_material_get_shader_index(wpd, OB_TEXTURE, false);
+ int index_texture_hair = workbench_material_get_shader_index(wpd, OB_TEXTURE, true);
- ensure_forward_shaders(wpd, index_solid, OB_SOLID);
- ensure_forward_shaders(wpd, index_texture, OB_TEXTURE);
+ ensure_forward_shaders(wpd, index_solid, OB_SOLID, false);
+ ensure_forward_shaders(wpd, index_solid_hair, OB_SOLID, true);
+ ensure_forward_shaders(wpd, index_texture, OB_TEXTURE, false);
+ ensure_forward_shaders(wpd, index_texture_hair, OB_TEXTURE, true);
wpd->composite_sh = e_data.composite_sh_cache[index_solid];
wpd->transparent_accum_sh = e_data.transparent_accum_sh_cache[index_solid];
+ wpd->transparent_accum_hair_sh = e_data.transparent_accum_sh_cache[index_solid_hair];
wpd->transparent_accum_texture_sh = e_data.transparent_accum_sh_cache[index_texture];
+ wpd->transparent_accum_texture_hair_sh = e_data.transparent_accum_sh_cache[index_texture_hair];
}
/* public functions */
@@ -252,29 +268,31 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
}
WORKBENCH_PrivateData *wpd = stl->g_data;
workbench_private_data_init(wpd);
+ float light_direction[3];
+ workbench_private_data_get_light_direction(wpd, light_direction);
if (!e_data.next_object_id) {
e_data.next_object_id = 1;
memset(e_data.composite_sh_cache, 0x00, sizeof(struct GPUShader *) * MAX_SHADERS);
memset(e_data.transparent_accum_sh_cache, 0x00, sizeof(struct GPUShader *) * MAX_SHADERS);
- char *defines = workbench_material_build_defines(wpd, OB_SOLID);
+ char *defines = workbench_material_build_defines(wpd, OB_SOLID, false);
+ char *defines_hair = workbench_material_build_defines(wpd, OB_SOLID, true);
+ char *forward_vert = workbench_build_forward_vert();
char *forward_depth_frag = workbench_build_forward_depth_frag();
e_data.object_outline_sh = DRW_shader_create(
- datatoc_workbench_prepass_vert_glsl, NULL, forward_depth_frag, defines);
-
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- char *forward_transparent_revealage_frag = workbench_build_forward_transparent_revealage_frag();
- e_data.transparent_revealage_sh = DRW_shader_create(
- datatoc_workbench_prepass_vert_glsl, NULL, forward_transparent_revealage_frag, defines);
- MEM_freeN(forward_transparent_revealage_frag);
-#endif
+ forward_vert, NULL,
+ forward_depth_frag, defines);
+ e_data.object_outline_hair_sh = DRW_shader_create(
+ forward_vert, NULL,
+ forward_depth_frag, defines_hair);
- e_data.depth_sh = DRW_shader_create_3D_depth_only();
e_data.checker_depth_sh = DRW_shader_create_fullscreen(
datatoc_workbench_checkerboard_depth_frag_glsl, NULL);
+ MEM_freeN(forward_vert);
MEM_freeN(forward_depth_frag);
MEM_freeN(defines);
+ MEM_freeN(defines_hair);
}
select_forward_shaders(wpd);
@@ -285,62 +303,32 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
size[0], size[1], GPU_R32UI, &draw_engine_workbench_transparent);
e_data.transparent_accum_tx = DRW_texture_pool_query_2D(
size[0], size[1], GPU_RGBA16F, &draw_engine_workbench_transparent);
-#ifdef WORKBENCH_REVEALAGE_ENABLED
e_data.transparent_revealage_tx = DRW_texture_pool_query_2D(
size[0], size[1], GPU_R16F, &draw_engine_workbench_transparent);
-#endif
e_data.composite_buffer_tx = DRW_texture_pool_query_2D(
size[0], size[1], GPU_RGBA16F, &draw_engine_workbench_transparent);
+
GPU_framebuffer_ensure_config(&fbl->object_outline_fb, {
GPU_ATTACHMENT_TEXTURE(dtxl->depth),
GPU_ATTACHMENT_TEXTURE(e_data.object_id_tx),
});
+
GPU_framebuffer_ensure_config(&fbl->transparent_accum_fb, {
GPU_ATTACHMENT_NONE,
GPU_ATTACHMENT_TEXTURE(e_data.transparent_accum_tx),
- });
-
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- GPU_framebuffer_ensure_config(&fbl->transparent_revealage_fb, {
- GPU_ATTACHMENT_NONE,
GPU_ATTACHMENT_TEXTURE(e_data.transparent_revealage_tx),
});
-#endif
GPU_framebuffer_ensure_config(&fbl->composite_fb, {
GPU_ATTACHMENT_NONE,
GPU_ATTACHMENT_TEXTURE(e_data.composite_buffer_tx),
});
- const float clear_color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- DRW_stats_group_start("Clear Buffers");
- GPU_framebuffer_bind(fbl->transparent_accum_fb);
- GPU_framebuffer_clear_color(fbl->transparent_accum_fb, clear_color);
-
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- const float clear_color1[4] = {1.0f, 1.0f, 1.0f, 1.0f};
- GPU_framebuffer_bind(fbl->transparent_revealage_fb);
- GPU_framebuffer_clear_color(fbl->transparent_revealage_fb, clear_color1);
-#endif
- GPU_framebuffer_bind(fbl->object_outline_fb);
- GPU_framebuffer_clear_color_depth(fbl->object_outline_fb, clear_color, 1.0f);
- DRW_stats_group_end();
- /* Treansparecy Accum */
+ /* Transparency Accum */
{
- int state = DRW_STATE_WRITE_COLOR | DRW_STATE_ADDITIVE_FULL;
+ int state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_OIT;
psl->transparent_accum_pass = DRW_pass_create("Transparent Accum", state);
}
-
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- /* Treansparecy Revealage */
- {
- int state = DRW_STATE_WRITE_COLOR | DRW_STATE_TRANSPARENT_REVEALAGE;
- psl->transparent_revealage_pass = DRW_pass_create("Transparent Revealage", state);
- grp = DRW_shgroup_create(e_data.transparent_revealage_sh, psl->transparent_revealage_pass);
- wpd->transparent_revealage_shgrp = grp;
- }
-#endif
-
/* Depth */
{
int state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
@@ -354,9 +342,7 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
grp = DRW_shgroup_create(wpd->composite_sh, psl->composite_pass);
DRW_shgroup_uniform_texture_ref(grp, "objectId", &e_data.object_id_tx);
DRW_shgroup_uniform_texture_ref(grp, "transparentAccum", &e_data.transparent_accum_tx);
-#ifdef WORKBENCH_REVEALAGE_ENABLED
DRW_shgroup_uniform_texture_ref(grp, "transparentRevealage", &e_data.transparent_revealage_tx);
-#endif
DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo);
DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
@@ -367,6 +353,7 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
psl->checker_depth_pass = DRW_pass_create("Checker Depth", state);
grp = DRW_shgroup_create(e_data.checker_depth_sh, psl->checker_depth_pass);
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
+ DRW_shgroup_uniform_float_copy(grp, "threshold", 0.75f - wpd->shading.xray_alpha * 0.5f);
}
}
@@ -376,10 +363,8 @@ void workbench_forward_engine_free()
DRW_SHADER_FREE_SAFE(e_data.composite_sh_cache[index]);
DRW_SHADER_FREE_SAFE(e_data.transparent_accum_sh_cache[index]);
}
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- DRW_SHADER_FREE_SAFE(e_data.transparent_revealage_sh);
-#endif
DRW_SHADER_FREE_SAFE(e_data.object_outline_sh);
+ DRW_SHADER_FREE_SAFE(e_data.object_outline_hair_sh);
DRW_SHADER_FREE_SAFE(e_data.checker_depth_sh);
}
@@ -389,35 +374,73 @@ void workbench_forward_cache_init(WORKBENCH_Data *UNUSED(vedata))
static void workbench_forward_cache_populate_particles(WORKBENCH_Data *vedata, Object *ob)
{
-#ifdef WORKBENCH_REVEALAGE_ENABLED
WORKBENCH_StorageList *stl = vedata->stl;
+ WORKBENCH_PassList *psl = vedata->psl;
WORKBENCH_PrivateData *wpd = stl->g_data;
-#endif
const DRWContextState *draw_ctx = DRW_context_state_get();
+
if (ob == draw_ctx->object_edit) {
return;
}
- for (ParticleSystem *psys = ob->particlesystem.first; psys != NULL; psys = psys->next) {
+ for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ if (md->type != eModifierType_ParticleSystem) {
+ continue;
+ }
+ ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
if (!psys_check_enabled(ob, psys, false)) {
continue;
}
if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
- return;
+ continue;
}
ParticleSettings *part = psys->part;
const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
- static float mat[4][4];
- unit_m4(mat);
-
if (draw_as == PART_DRAW_PATH) {
- struct Gwn_Batch *geom = DRW_cache_particles_get_hair(ob, psys, NULL);
- WORKBENCH_MaterialData *material = get_or_create_material_data(vedata, ob, NULL, NULL, OB_SOLID);
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- DRW_shgroup_call_add(wpd->transparent_revealage_shgrp, geom, mat);
-#endif
- DRW_shgroup_call_add(material->shgrp_object_outline, geom, mat);
- DRW_shgroup_call_add(material->shgrp, geom, mat);
+ Image *image = NULL;
+ Material *mat = give_current_material(ob, part->omat);
+ int mat_drawtype = OB_SOLID;
+
+ if (wpd->drawtype == OB_TEXTURE) {
+ ED_object_get_active_image(ob, part->omat, &image, NULL, NULL, NULL);
+ /* use OB_SOLID when no texture could be determined */
+ if (image) {
+ mat_drawtype = OB_TEXTURE;
+ }
+ }
+
+ WORKBENCH_MaterialData *material = get_or_create_material_data(vedata, ob, mat, image, mat_drawtype);
+
+ struct GPUShader *shader = (mat_drawtype == OB_SOLID)
+ ? wpd->transparent_accum_hair_sh
+ : wpd->transparent_accum_texture_hair_sh;
+ DRWShadingGroup *shgrp = DRW_shgroup_hair_create(
+ ob, psys, md,
+ psl->transparent_accum_pass,
+ shader);
+ workbench_material_set_normal_world_matrix(shgrp, wpd, e_data.normal_world_matrix);
+ DRW_shgroup_uniform_block(shgrp, "world_block", wpd->world_ubo);
+ DRW_shgroup_uniform_block(shgrp, "material_block", material->material_ubo);
+ DRW_shgroup_uniform_vec4(shgrp, "viewvecs[0]", (float *)wpd->viewvecs, 3);
+ /* Hairs have lots of layer and can rapidly become the most prominent surface.
+ * So lower their alpha artificially. */
+ float hair_alpha = wpd->shading.xray_alpha * 0.33f;
+ DRW_shgroup_uniform_float_copy(shgrp, "alpha", hair_alpha);
+ if (image) {
+ GPUTexture *tex = GPU_texture_from_blender(image, NULL, GL_TEXTURE_2D, false, false, false);
+ DRW_shgroup_uniform_texture(shgrp, "image", tex);
+ }
+ if (STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)) {
+ BKE_studiolight_ensure_flag(wpd->studio_light, STUDIOLIGHT_EQUIRECTANGULAR_RADIANCE_GPUTEXTURE);
+ DRW_shgroup_uniform_texture(shgrp, "matcapImage", wpd->studio_light->equirectangular_radiance_gputexture);
+ }
+ if (SPECULAR_HIGHLIGHT_ENABLED(wpd) || MATCAP_ENABLED(wpd)) {
+ DRW_shgroup_uniform_vec2(shgrp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
+ }
+ shgrp = DRW_shgroup_hair_create(ob, psys, md,
+ vedata->psl->object_outline_pass,
+ e_data.object_outline_hair_sh);
+ DRW_shgroup_uniform_int(shgrp, "object_id", &material->object_id, 1);
}
}
}
@@ -433,14 +456,19 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
if (ob->type == OB_MESH) {
workbench_forward_cache_populate_particles(vedata, ob);
}
- if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) {
+
+ if (!DRW_check_object_visible_within_active_context(ob)) {
+ return;
+ }
+
+ if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) {
const DRWContextState *draw_ctx = DRW_context_state_get();
const bool is_active = (ob == draw_ctx->obact);
const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
bool is_drawn = false;
WORKBENCH_MaterialData *material = get_or_create_material_data(vedata, ob, NULL, NULL, OB_SOLID);
- if (!is_sculpt_mode && wpd->drawtype == OB_TEXTURE && ob->type == OB_MESH) {
+ if (!is_sculpt_mode && wpd->drawtype == OB_TEXTURE && ELEM(ob->type, OB_MESH)) {
const Mesh *me = ob->data;
if (me->mloopuv) {
const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol));
@@ -448,6 +476,10 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
if (materials_len > 0 && geom_array) {
for (int i = 0; i < materials_len; i++) {
+ if(geom_array[i] == NULL) {
+ continue;
+ }
+
Material *mat = give_current_material(ob, i + 1);
Image *image;
ED_object_get_active_image(ob, i + 1, &image, NULL, NULL, NULL);
@@ -457,9 +489,6 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
mat_drawtype = OB_TEXTURE;
}
material = get_or_create_material_data(vedata, ob, mat, image, mat_drawtype);
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- DRW_shgroup_call_object_add(wpd->transparent_revealage_shgrp, geom_array[i], ob);
-#endif
DRW_shgroup_call_object_add(material->shgrp_object_outline, geom_array[i], ob);
DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob);
}
@@ -475,16 +504,10 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
if (geom) {
if (is_sculpt_mode) {
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- DRW_shgroup_call_sculpt_add(wpd->transparent_revealage_shgrp, ob, ob->obmat);
-#endif
DRW_shgroup_call_sculpt_add(material->shgrp_object_outline, ob, ob->obmat);
DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat);
}
else {
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- DRW_shgroup_call_object_add(wpd->transparent_revealage_shgrp, geom, ob);
-#endif
DRW_shgroup_call_object_add(material->shgrp_object_outline, geom, ob);
DRW_shgroup_call_object_add(material->shgrp, geom, ob);
}
@@ -501,11 +524,12 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
ob, gpumat_array, materials_len, NULL, NULL, NULL);
if (mat_geom) {
for (int i = 0; i < materials_len; ++i) {
+ if(mat_geom[i] == NULL) {
+ continue;
+ }
+
Material *mat = give_current_material(ob, i + 1);
material = get_or_create_material_data(vedata, ob, mat, NULL, OB_SOLID);
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- DRW_shgroup_call_object_add(wpd->transparent_revealage_shgrp, mat_geom[i], ob);
-#endif
DRW_shgroup_call_object_add(material->shgrp_object_outline, mat_geom[i], ob);
DRW_shgroup_call_object_add(material->shgrp, mat_geom[i], ob);
}
@@ -523,7 +547,7 @@ void workbench_forward_draw_background(WORKBENCH_Data *UNUSED(vedata))
{
const float clear_depth = 1.0f;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
- DRW_stats_group_start("Clear Background");
+ DRW_stats_group_start("Clear depth");
GPU_framebuffer_bind(dfbl->default_fb);
GPU_framebuffer_clear_depth(dfbl->default_fb, clear_depth);
DRW_stats_group_end();
@@ -538,16 +562,25 @@ void workbench_forward_draw_scene(WORKBENCH_Data *vedata)
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
/* Write Depth + Object ID */
+ const float clear_outline[4] = {0.0f};
GPU_framebuffer_bind(fbl->object_outline_fb);
+ GPU_framebuffer_clear_color(fbl->object_outline_fb, clear_outline);
DRW_draw_pass(psl->object_outline_pass);
- /* Shade */
- GPU_framebuffer_bind(fbl->transparent_accum_fb);
- DRW_draw_pass(psl->transparent_accum_pass);
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- GPU_framebuffer_bind(fbl->transparent_revealage_fb);
- DRW_draw_pass(psl->transparent_revealage_pass);
-#endif
+ if (wpd->shading.xray_alpha > 0.0) {
+ const float clear_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+ GPU_framebuffer_bind(fbl->transparent_accum_fb);
+ GPU_framebuffer_clear_color(fbl->transparent_accum_fb, clear_color);
+ DRW_draw_pass(psl->transparent_accum_pass);
+ }
+ else {
+ /* TODO(fclem): this is unecessary and takes up perf.
+ * Better change the composite frag shader to not use the tx. */
+ const float clear_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+ GPU_framebuffer_bind(fbl->transparent_accum_fb);
+ GPU_framebuffer_clear_color(fbl->transparent_accum_fb, clear_color);
+ }
+
/* Composite */
GPU_framebuffer_bind(fbl->composite_fb);
DRW_draw_pass(psl->composite_pass);
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
index 6028d3816d4..231d9a9582a 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -7,14 +7,18 @@
#define HSV_SATURATION 0.5
#define HSV_VALUE 0.9
-void workbench_material_get_solid_color(WORKBENCH_PrivateData *wpd, Object *ob, Material *mat, float *color)
+void workbench_material_update_data(WORKBENCH_PrivateData *wpd, Object *ob, Material *mat, WORKBENCH_MaterialData *data)
{
/* When in OB_TEXTURE always uyse V3D_SHADING_MATERIAL_COLOR as fallback when no texture could be determined */
int color_type = wpd->drawtype == OB_SOLID ? wpd->shading.color_type : V3D_SHADING_MATERIAL_COLOR;
- static float default_color[] = {0.8f, 0.8f, 0.8f, 1.0f};
- color[3] = 1.0f;
+ static float default_diffuse_color[] = {0.8f, 0.8f, 0.8f, 1.0f};
+ static float default_specular_color[] = {0.5f, 0.5f, 0.5f, 0.5f};
+ copy_v4_v4(data->material_data.diffuse_color, default_diffuse_color);
+ copy_v4_v4(data->material_data.specular_color, default_specular_color);
+ data->material_data.roughness = 0.5f;
+
if (DRW_object_is_paint_mode(ob) || color_type == V3D_SHADING_SINGLE_COLOR) {
- copy_v3_v3(color, wpd->shading.single_color);
+ copy_v3_v3(data->material_data.diffuse_color, wpd->shading.single_color);
}
else if (color_type == V3D_SHADING_RANDOM_COLOR) {
uint hash = BLI_ghashutil_strhash_p_murmur(ob->id.name);
@@ -24,23 +28,19 @@ void workbench_material_get_solid_color(WORKBENCH_PrivateData *wpd, Object *ob,
float offset = fmodf((hash / 100000.0) * M_GOLDEN_RATION_CONJUGATE, 1.0);
float hsv[3] = {offset, HSV_SATURATION, HSV_VALUE};
- hsv_to_rgb_v(hsv, color);
- }
- else if (color_type == V3D_SHADING_OBJECT_COLOR) {
- copy_v3_v3(color, ob->col);
+ hsv_to_rgb_v(hsv, data->material_data.diffuse_color);
}
else {
/* V3D_SHADING_MATERIAL_COLOR */
if (mat) {
- copy_v3_v3(color, &mat->r);
- }
- else {
- copy_v3_v3(color, default_color);
+ copy_v3_v3(data->material_data.diffuse_color, &mat->r);
+ copy_v3_v3(data->material_data.specular_color, &mat->specr);
+ data->material_data.roughness = mat->roughness;
}
}
}
-char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, int drawtype)
+char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, int drawtype, bool is_hair)
{
char *str = NULL;
@@ -52,14 +52,29 @@ char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, int drawtype)
if (wpd->shading.flag & V3D_SHADING_SHADOW) {
BLI_dynstr_appendf(ds, "#define V3D_SHADING_SHADOW\n");
}
- if (wpd->shading.light & V3D_LIGHTING_STUDIO) {
+ if (CAVITY_ENABLED(wpd)) {
+ BLI_dynstr_appendf(ds, "#define V3D_SHADING_CAVITY\n");
+ }
+ if (SPECULAR_HIGHLIGHT_ENABLED(wpd)) {
+ BLI_dynstr_appendf(ds, "#define V3D_SHADING_SPECULAR_HIGHLIGHT\n");
+ }
+ if (STUDIOLIGHT_ENABLED(wpd)) {
BLI_dynstr_appendf(ds, "#define V3D_LIGHTING_STUDIO\n");
- if (STUDIOLIGHT_ORIENTATION_WORLD_ENABLED(wpd)) {
- BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_ORIENTATION_WORLD\n");
- }
- else {
- BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_ORIENTATION_CAMERA\n");
- }
+ }
+ if (FLAT_ENABLED(wpd)) {
+ BLI_dynstr_appendf(ds, "#define V3D_LIGHTING_FLAT\n");
+ }
+ if (MATCAP_ENABLED(wpd)) {
+ BLI_dynstr_appendf(ds, "#define V3D_LIGHTING_MATCAP\n");
+ }
+ if (STUDIOLIGHT_ORIENTATION_WORLD_ENABLED(wpd)) {
+ BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_ORIENTATION_WORLD\n");
+ }
+ if (STUDIOLIGHT_ORIENTATION_CAMERA_ENABLED(wpd)) {
+ BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_ORIENTATION_CAMERA\n");
+ }
+ if (STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)) {
+ BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_ORIENTATION_VIEWNORMAL\n");
}
if (NORMAL_VIEWPORT_PASS_ENABLED(wpd)) {
BLI_dynstr_appendf(ds, "#define NORMAL_VIEWPORT_PASS_ENABLED\n");
@@ -76,10 +91,9 @@ char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, int drawtype)
if (NORMAL_ENCODING_ENABLED()) {
BLI_dynstr_appendf(ds, "#define WORKBENCH_ENCODE_NORMALS\n");
}
-
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- BLI_dynstr_appendf(ds, "#define WORKBENCH_REVEALAGE_ENABLED\n");
-#endif
+ if (is_hair) {
+ BLI_dynstr_appendf(ds, "#define HAIR_SHADER\n");
+ }
str = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
@@ -88,16 +102,22 @@ char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, int drawtype)
uint workbench_material_get_hash(WORKBENCH_MaterialData *material_template)
{
- /* TODO: make a C-string with settings and hash the string */
uint input[4];
uint result;
- float *color = material_template->color;
+ float *color = material_template->material_data.diffuse_color;
input[0] = (uint)(color[0] * 512);
input[1] = (uint)(color[1] * 512);
input[2] = (uint)(color[2] * 512);
input[3] = material_template->object_id;
result = BLI_ghashutil_uinthash_v4_murmur(input);
+ color = material_template->material_data.specular_color;
+ input[0] = (uint)(color[0] * 512);
+ input[1] = (uint)(color[1] * 512);
+ input[2] = (uint)(color[2] * 512);
+ input[3] = (uint)(material_template->material_data.roughness * 512);
+ result += BLI_ghashutil_uinthash_v4_murmur(input);
+
if (material_template->drawtype == OB_TEXTURE) {
/* add texture reference */
result += BLI_ghashutil_inthash_p_murmur(material_template->ima);
@@ -105,19 +125,24 @@ uint workbench_material_get_hash(WORKBENCH_MaterialData *material_template)
return result;
}
-int workbench_material_get_shader_index(WORKBENCH_PrivateData *wpd, int drawtype)
+int workbench_material_get_shader_index(WORKBENCH_PrivateData *wpd, int drawtype, bool is_hair)
{
- const int DRAWOPTIONS_MASK = V3D_SHADING_OBJECT_OUTLINE | V3D_SHADING_SHADOW;
- int index = (wpd->shading.flag & DRAWOPTIONS_MASK);
- index = (index << 2) + wpd->shading.light;
- index = (index << 2);
- /* set the drawtype flag
- 0 = OB_SOLID,
- 1 = OB_TEXTURE
- 2 = STUDIOLIGHT_ORIENTATION_WORLD
- */
- SET_FLAG_FROM_TEST(index, wpd->studio_light->flag & STUDIOLIGHT_ORIENTATION_WORLD, 2);
- SET_FLAG_FROM_TEST(index, drawtype == OB_TEXTURE, 1);
+ /* NOTE: change MAX_SHADERS accordingly when modifying this function. */
+ int index = 0;
+ /* 1 bit OB_SOLID and OB_TEXTURE */
+ SET_FLAG_FROM_TEST(index, drawtype == OB_TEXTURE, 1 << 0);
+ /* 2 bits FLAT/STUDIO/MATCAP/SCENE */
+ SET_FLAG_FROM_TEST(index, wpd->shading.light, wpd->shading.light << 1);
+ /* 1 bit V3D_SHADING_SPECULAR_HIGHLIGHT */
+ SET_FLAG_FROM_TEST(index, wpd->shading.flag & V3D_SHADING_SPECULAR_HIGHLIGHT, 1 << 3);
+ SET_FLAG_FROM_TEST(index, wpd->shading.flag & V3D_SHADING_SHADOW, 1 << 4);
+ SET_FLAG_FROM_TEST(index, wpd->shading.flag & V3D_SHADING_CAVITY, 1 << 5);
+ SET_FLAG_FROM_TEST(index, wpd->shading.flag & V3D_SHADING_OBJECT_OUTLINE, 1 << 6);
+ /* 2 bits STUDIOLIGHT_ORIENTATION */
+ SET_FLAG_FROM_TEST(index, wpd->studio_light->flag & STUDIOLIGHT_ORIENTATION_WORLD, 1 << 7);
+ SET_FLAG_FROM_TEST(index, wpd->studio_light->flag & STUDIOLIGHT_ORIENTATION_VIEWNORMAL, 1 << 8);
+ /* 1 bit for hair */
+ SET_FLAG_FROM_TEST(index, is_hair, 1 << 9);
return index;
}
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index bffac99c6d7..b17cc93d148 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -31,35 +31,41 @@
#include "DNA_image_types.h"
#include "DNA_view3d_types.h"
+#include "DNA_world_types.h"
#include "DRW_render.h"
#define WORKBENCH_ENGINE "BLENDER_WORKBENCH"
#define M_GOLDEN_RATION_CONJUGATE 0.618033988749895
-#define MAX_SHADERS 255
-
-
-#define OBJECT_ID_PASS_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_OBJECT_OUTLINE)
+#define MAX_SHADERS (1 << 10)
+
+#define OB_SOLID_ENABLED(wpd) (wpd->drawtype & OB_SOLID)
+#define OB_TEXTURE_ENABLED(wpd) (wpd->drawtype & OB_TEXTURE)
+#define FLAT_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_FLAT)
+#define STUDIOLIGHT_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_STUDIO)
+#define MATCAP_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_MATCAP && OB_SOLID_ENABLED(wpd))
+#define STUDIOLIGHT_ORIENTATION_WORLD_ENABLED(wpd) (STUDIOLIGHT_ENABLED(wpd) && (wpd->studio_light->flag & STUDIOLIGHT_ORIENTATION_WORLD))
+#define STUDIOLIGHT_ORIENTATION_CAMERA_ENABLED(wpd) (STUDIOLIGHT_ENABLED(wpd) && (wpd->studio_light->flag & STUDIOLIGHT_ORIENTATION_CAMERA))
+#define STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd) (MATCAP_ENABLED(wpd) && (wpd->studio_light->flag & STUDIOLIGHT_ORIENTATION_VIEWNORMAL))
+#define CAVITY_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_CAVITY)
#define SHADOW_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_SHADOW)
-#define NORMAL_VIEWPORT_PASS_ENABLED(wpd) (wpd->shading.light & V3D_LIGHTING_STUDIO || SHADOW_ENABLED(wpd))
+#define SPECULAR_HIGHLIGHT_ENABLED(wpd) ((wpd->shading.flag & V3D_SHADING_SPECULAR_HIGHLIGHT) && (!STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)))
+#define OBJECT_ID_PASS_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_OBJECT_OUTLINE)
+#define NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) (MATCAP_ENABLED(wpd) || STUDIOLIGHT_ENABLED(wpd) || SHADOW_ENABLED(wpd) || SPECULAR_HIGHLIGHT_ENABLED(wpd))
+#define NORMAL_VIEWPORT_PASS_ENABLED(wpd) (NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) || CAVITY_ENABLED(wpd))
#define NORMAL_ENCODING_ENABLED() (true)
-#define WORKBENCH_REVEALAGE_ENABLED
-#define STUDIOLIGHT_ORIENTATION_WORLD_ENABLED(wpd) (wpd->studio_light->flag & STUDIOLIGHT_ORIENTATION_WORLD)
-
typedef struct WORKBENCH_FramebufferList {
/* Deferred render buffers */
struct GPUFrameBuffer *prepass_fb;
+ struct GPUFrameBuffer *cavity_fb;
struct GPUFrameBuffer *composite_fb;
/* Forward render buffers */
struct GPUFrameBuffer *object_outline_fb;
struct GPUFrameBuffer *transparent_accum_fb;
-
-#ifdef WORKBENCH_REVEALAGE_ENABLED
struct GPUFrameBuffer *transparent_revealage_fb;
-#endif
} WORKBENCH_FramebufferList;
typedef struct WORKBENCH_StorageList {
@@ -69,6 +75,8 @@ typedef struct WORKBENCH_StorageList {
typedef struct WORKBENCH_PassList {
/* deferred rendering */
struct DRWPass *prepass_pass;
+ struct DRWPass *prepass_hair_pass;
+ struct DRWPass *cavity_pass;
struct DRWPass *shadow_depth_pass_pass;
struct DRWPass *shadow_depth_pass_mani_pass;
struct DRWPass *shadow_depth_fail_pass;
@@ -80,9 +88,6 @@ typedef struct WORKBENCH_PassList {
/* forward rendering */
struct DRWPass *transparent_accum_pass;
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- struct DRWPass *transparent_revealage_pass;
-#endif
struct DRWPass *object_outline_pass;
struct DRWPass *depth_pass;
struct DRWPass *checker_depth_pass;
@@ -96,6 +101,12 @@ typedef struct WORKBENCH_Data {
WORKBENCH_StorageList *stl;
} WORKBENCH_Data;
+typedef struct WORKBENCH_UBO_Light {
+ float light_direction_vs[4];
+ float specular_color[3];
+ float energy;
+} WORKBENCH_UBO_Light;
+
typedef struct WORKBENCH_UBO_World {
float diffuse_light_x_pos[4];
float diffuse_light_x_neg[4];
@@ -106,40 +117,63 @@ typedef struct WORKBENCH_UBO_World {
float background_color_low[4];
float background_color_high[4];
float object_outline_color[4];
+ float light_direction_vs[4];
+ WORKBENCH_UBO_Light lights[3];
+ int num_lights;
+ int matcap_orientation;
+ int pad[2];
} WORKBENCH_UBO_World;
BLI_STATIC_ASSERT_ALIGN(WORKBENCH_UBO_World, 16)
+typedef struct WORKBENCH_UBO_Material {
+ float diffuse_color[4];
+ float specular_color[4];
+ float roughness;
+ float pad[3];
+} WORKBENCH_UBO_Material;
+BLI_STATIC_ASSERT_ALIGN(WORKBENCH_UBO_Material, 16)
+
typedef struct WORKBENCH_PrivateData {
struct GHash *material_hash;
struct GPUShader *prepass_solid_sh;
+ struct GPUShader *prepass_solid_hair_sh;
struct GPUShader *prepass_texture_sh;
+ struct GPUShader *prepass_texture_hair_sh;
struct GPUShader *composite_sh;
struct GPUShader *transparent_accum_sh;
+ struct GPUShader *transparent_accum_hair_sh;
struct GPUShader *transparent_accum_texture_sh;
+ struct GPUShader *transparent_accum_texture_hair_sh;
View3DShading shading;
StudioLight *studio_light;
int drawtype;
struct GPUUniformBuffer *world_ubo;
struct DRWShadingGroup *shadow_shgrp;
struct DRWShadingGroup *depth_shgrp;
-#ifdef WORKBENCH_REVEALAGE_ENABLED
- struct DRWShadingGroup *transparent_revealage_shgrp;
-#endif
WORKBENCH_UBO_World world_data;
float shadow_multiplier;
float cached_shadow_direction[3];
float shadow_mat[4][4];
float shadow_inv[4][4];
+ float shadow_far_plane[4]; /* Far plane of the view frustum. */
float shadow_near_corners[4][3]; /* Near plane corners in shadow space. */
float shadow_near_min[3]; /* min and max of shadow_near_corners. allow fast test */
float shadow_near_max[3];
float shadow_near_sides[2][4]; /* This is a parallelogram, so only 2 normal and distance to the edges. */
bool shadow_changed;
+
+ /* Ssao */
+ float winmat[4][4];
+ float viewvecs[3][4];
+ float ssao_params[4];
+ float ssao_settings[4];
} WORKBENCH_PrivateData; /* Transient data */
typedef struct WORKBENCH_MaterialData {
/* Solid color */
- float color[4];
+ WORKBENCH_UBO_Material material_data;
+ struct GPUUniformBuffer *material_ubo;
+
int object_id;
int drawtype;
Image *ima;
@@ -158,7 +192,7 @@ typedef struct WORKBENCH_ObjectData {
/* Accumulated recalc flags, which corresponds to ID->recalc flags. */
int recalc;
/* Shadow direction in local object space. */
- float shadow_dir[3];
+ float shadow_dir[3], shadow_depth;
float shadow_min[3], shadow_max[3]; /* Min, max in shadow space */
BoundBox shadow_bbox;
bool shadow_bbox_dirty;
@@ -193,10 +227,10 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob);
void workbench_forward_cache_finish(WORKBENCH_Data *vedata);
/* workbench_materials.c */
-char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, int drawtype);
-void workbench_material_get_solid_color(WORKBENCH_PrivateData *wpd, Object *ob, Material *mat, float *color);
+char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, int drawtype, bool is_hair);
+void workbench_material_update_data(WORKBENCH_PrivateData *wpd, Object *ob, Material *mat, WORKBENCH_MaterialData *data);
uint workbench_material_get_hash(WORKBENCH_MaterialData *material_template);
-int workbench_material_get_shader_index(WORKBENCH_PrivateData *wpd, int drawtype);
+int workbench_material_get_shader_index(WORKBENCH_PrivateData *wpd, int drawtype, bool is_hair);
void workbench_material_set_normal_world_matrix(
DRWShadingGroup *grp, WORKBENCH_PrivateData *wpd, float persistent_matrix[3][3]);
@@ -204,11 +238,13 @@ void workbench_material_set_normal_world_matrix(
void studiolight_update_world(StudioLight *sl, WORKBENCH_UBO_World *wd);
void studiolight_update_light(WORKBENCH_PrivateData *wpd, const float light_direction[3]);
bool studiolight_object_cast_visible_shadow(WORKBENCH_PrivateData *wpd, Object *ob, WORKBENCH_ObjectData *oed);
+float studiolight_object_shadow_distance(WORKBENCH_PrivateData *wpd, Object *ob, WORKBENCH_ObjectData *oed);
bool studiolight_camera_in_object_shadow(WORKBENCH_PrivateData *wpd, Object *ob, WORKBENCH_ObjectData *oed);
/* workbench_data.c */
void workbench_private_data_init(WORKBENCH_PrivateData *wpd);
void workbench_private_data_free(WORKBENCH_PrivateData *wpd);
+void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, float light_direction[3]);
extern DrawEngineType draw_engine_workbench_solid;
extern DrawEngineType draw_engine_workbench_transparent;
diff --git a/source/blender/draw/engines/workbench/workbench_studiolight.c b/source/blender/draw/engines/workbench/workbench_studiolight.c
index 4db89717b2a..6451d1f57c8 100644
--- a/source/blender/draw/engines/workbench/workbench_studiolight.c
+++ b/source/blender/draw/engines/workbench/workbench_studiolight.c
@@ -76,9 +76,13 @@ void studiolight_update_light(WORKBENCH_PrivateData *wpd, const float light_dire
invert_m4_m4(wpd->shadow_inv, wpd->shadow_mat);
copy_v3_v3(wpd->cached_shadow_direction, light_direction);
-
}
+ float planes[6][4];
+ DRW_culling_frustum_planes_get(planes);
+ /* we only need the far plane. */
+ copy_v4_v4(wpd->shadow_far_plane, planes[2]);
+
BoundBox frustum_corners;
DRW_culling_frustum_corners_get(&frustum_corners);
@@ -112,8 +116,9 @@ static BoundBox *studiolight_object_shadow_bbox_get(WORKBENCH_PrivateData *wpd,
mul_v3_m4v3(corner, tmp_mat, bbox->vec[i]);
minmax_v3v3_v3(oed->shadow_min, oed->shadow_max, corner);
}
+ oed->shadow_depth = oed->shadow_max[2] - oed->shadow_min[2];
/* Extend towards infinity. */
- oed->shadow_max[2] += 1e4;
+ oed->shadow_max[2] += 1e4f;
/* Get extended AABB in world space. */
BKE_boundbox_init_from_minmax(&oed->shadow_bbox, oed->shadow_min, oed->shadow_max);
@@ -131,6 +136,30 @@ bool studiolight_object_cast_visible_shadow(WORKBENCH_PrivateData *wpd, Object *
return DRW_culling_box_test(shadow_bbox);
}
+float studiolight_object_shadow_distance(WORKBENCH_PrivateData *wpd, Object *ob, WORKBENCH_ObjectData *oed)
+{
+ BoundBox *shadow_bbox = studiolight_object_shadow_bbox_get(wpd, ob, oed);
+
+ int corners[4] = {0, 3, 4, 7};
+ float dist = 1e4f, dist_isect;
+ for (int i = 0; i < 4; ++i) {
+ if (isect_ray_plane_v3(shadow_bbox->vec[corners[i]],
+ wpd->cached_shadow_direction,
+ wpd->shadow_far_plane,
+ &dist_isect, true))
+ {
+ if (dist_isect < dist) {
+ dist = dist_isect;
+ }
+ }
+ else {
+ /* All rays are parallels. If one fails, the other will too. */
+ break;
+ }
+ }
+ return max_ii(dist - oed->shadow_depth, 0);
+}
+
bool studiolight_camera_in_object_shadow(WORKBENCH_PrivateData *wpd, Object *ob, WORKBENCH_ObjectData *oed)
{
/* Just to be sure the min, max are updated. */
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 25806062f68..f79a2405c3f 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -282,7 +282,7 @@ typedef enum {
DRW_STATE_BLEND_PREMUL = (1 << 21), /* Use that if color is already premult by alpha. */
DRW_STATE_WIRE_SMOOTH = (1 << 22),
DRW_STATE_TRANS_FEEDBACK = (1 << 23),
- DRW_STATE_TRANSPARENT_REVEALAGE = (1 << 24),
+ DRW_STATE_BLEND_OIT = (1 << 24),
DRW_STATE_WRITE_STENCIL = (1 << 27),
DRW_STATE_WRITE_STENCIL_SHADOW_PASS = (1 << 28),
@@ -329,6 +329,7 @@ DRWShadingGroup *DRW_shgroup_empty_tri_batch_create(
DRWShadingGroup *DRW_shgroup_transform_feedback_create(
struct GPUShader *shader, DRWPass *pass, struct Gwn_VertBuf *tf_target);
+
typedef void (DRWCallGenerateFn)(
DRWShadingGroup *shgroup,
void (*draw_fn)(DRWShadingGroup *shgroup, struct Gwn_Batch *geom),
@@ -343,7 +344,15 @@ void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Gwn_Batch *batc
void DRW_shgroup_free(struct DRWShadingGroup *shgroup);
void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4]);
-void DRW_shgroup_call_object_add(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob);
+void DRW_shgroup_call_range_add(
+ DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4], uint v_sta, uint v_count);
+void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, unsigned int point_count, float (*obmat)[4]);
+void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, unsigned int line_count, float (*obmat)[4]);
+void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, unsigned int tria_count, float (*obmat)[4]);
+void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup, uint tria_count, struct Object *ob);
+void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob, bool bypass_culling);
+#define DRW_shgroup_call_object_add(shgroup, geom, ob) DRW_shgroup_call_object_add_ex(shgroup, geom, ob, false)
+#define DRW_shgroup_call_object_add_no_cull(shgroup, geom, ob) DRW_shgroup_call_object_add_ex(shgroup, geom, ob, true)
void DRW_shgroup_call_object_add_with_callback(
DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob,
DRWCallVisibilityFn *callback, void *user_data);
@@ -438,10 +447,10 @@ struct DefaultTextureList *DRW_viewport_texture_list_get(void);
void DRW_viewport_request_redraw(void);
-void DRW_render_to_image(struct RenderEngine *engine, struct Depsgraph *graph);
+void DRW_render_to_image(struct RenderEngine *engine, struct Depsgraph *depsgraph);
void DRW_render_object_iter(
- void *vedata, struct RenderEngine *engine, struct Depsgraph *graph,
- void (*callback)(void *vedata, struct Object *ob, struct RenderEngine *engine, struct Depsgraph *graph));
+ void *vedata, struct RenderEngine *engine, struct Depsgraph *depsgraph,
+ void (*callback)(void *vedata, struct Object *ob, struct RenderEngine *engine, struct Depsgraph *depsgraph));
void DRW_render_instance_buffer_finish(void);
/* ViewLayers */
@@ -498,6 +507,7 @@ bool DRW_culling_box_test(BoundBox *bbox);
bool DRW_culling_plane_test(float plane[4]);
void DRW_culling_frustum_corners_get(BoundBox *corners);
+void DRW_culling_frustum_planes_get(float planes[6][4]);
/* Selection */
void DRW_select_load_id(uint id);
@@ -514,8 +524,6 @@ bool DRW_state_show_text(void);
bool DRW_state_draw_support(void);
bool DRW_state_draw_background(void);
-enum eDepsObjectIteratorMode DRW_iterator_mode_get(void);
-
struct DRWTextStore *DRW_state_text_cache_get(void);
/* Avoid too many lookups while drawing */
diff --git a/source/blender/draw/intern/draw_anim_viz.c b/source/blender/draw/intern/draw_anim_viz.c
new file mode 100644
index 00000000000..717b23775dc
--- /dev/null
+++ b/source/blender/draw/intern/draw_anim_viz.c
@@ -0,0 +1,351 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2009/2018 by the Blender Foundation.
+ *
+ * Contributor(s): Joshua Leung
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/draw/intern/draw_anim_viz.c
+ * \ingroup draw
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "BLI_sys_types.h"
+
+#include "DNA_anim_types.h"
+#include "DNA_armature_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_view3d_types.h"
+#include "DNA_object_types.h"
+
+#include "BLI_math.h"
+#include "BLI_dlrbTree.h"
+
+#include "BKE_animsys.h"
+#include "BKE_action.h"
+
+#include "ED_keyframes_draw.h"
+
+#include "UI_resources.h"
+
+#include "DEG_depsgraph_query.h"
+
+#include "DRW_engine.h"
+#include "DRW_render.h"
+
+#include "GPU_shader.h"
+#include "GPU_immediate.h"
+#include "GPU_matrix.h"
+
+#include "draw_common.h"
+#include "draw_manager_text.h"
+
+#include "draw_mode_engines.h"
+
+extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
+
+/* ********************************* Lists ************************************** */
+/* All lists are per viewport specific datas.
+ * They are all free when viewport changes engines
+ * or is free itself.
+ */
+
+/* XXX: How to show frame numbers, etc.? Currently only doing the dots and lines */
+typedef struct MPATH_PassList {
+ struct DRWPass *lines;
+ struct DRWPass *points;
+} MPATH_PassList;
+
+typedef struct MPATH_StorageList {
+ struct MPATH_PrivateData *g_data;
+} MPATH_StorageList;
+
+typedef struct MPATH_Data {
+ void *engine_type;
+ DRWViewportEmptyList *fbl;
+ DRWViewportEmptyList *txl;
+ MPATH_PassList *psl;
+ MPATH_StorageList *stl;
+} MPATH_Data;
+
+struct {
+ GPUShader *mpath_line_sh;
+ GPUShader *mpath_points_sh;
+} e_data = {0};
+
+/* *************************** Path Cache *********************************** */
+
+/* Just convert the CPU cache to GPU cache. */
+static Gwn_VertBuf *mpath_vbo_get(bMotionPath *mpath)
+{
+ if (!mpath->points_vbo) {
+ Gwn_VertFormat format = {0};
+ /* Match structure of bMotionPathVert. */
+ uint pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ GWN_vertformat_attr_add(&format, "flag", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ mpath->points_vbo = GWN_vertbuf_create_with_format(&format);
+ GWN_vertbuf_data_alloc(mpath->points_vbo, mpath->length);
+
+ /* meh... a useless memcpy. */
+ Gwn_VertBufRaw raw_data;
+ GWN_vertbuf_attr_get_raw_data(mpath->points_vbo, pos, &raw_data);
+ memcpy(GWN_vertbuf_raw_step(&raw_data), mpath->points, sizeof(bMotionPathVert) * mpath->length);
+ }
+ return mpath->points_vbo;
+}
+
+static Gwn_Batch *mpath_batch_line_get(bMotionPath *mpath)
+{
+ if (!mpath->batch_line) {
+ mpath->batch_line = GWN_batch_create(GWN_PRIM_LINE_STRIP, mpath_vbo_get(mpath), NULL);
+ }
+ return mpath->batch_line;
+}
+
+static Gwn_Batch *mpath_batch_points_get(bMotionPath *mpath)
+{
+ if (!mpath->batch_points) {
+ mpath->batch_points = GWN_batch_create(GWN_PRIM_POINTS, mpath_vbo_get(mpath), NULL);
+ }
+ return mpath->batch_points;
+}
+
+/* *************************** Draw Engine Entrypoints ************************** */
+
+static void MPATH_engine_init(void *UNUSED(vedata))
+{
+}
+
+static void MPATH_engine_free(void)
+{
+}
+
+/* Here init all passes and shading groups
+ * Assume that all Passes are NULL */
+static void MPATH_cache_init(void *vedata)
+{
+ MPATH_PassList *psl = ((MPATH_Data *)vedata)->psl;
+
+ {
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
+ psl->lines = DRW_pass_create("Motionpath Line Pass", state);
+ }
+
+ {
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_POINT;
+ psl->points = DRW_pass_create("Motionpath Point Pass", state);
+ }
+}
+
+static void MPATH_cache_motion_path(MPATH_PassList *psl,
+ Object *ob, bPoseChannel *pchan,
+ bAnimVizSettings *avs, bMotionPath *mpath)
+{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ struct DRWTextStore *dt = DRW_text_cache_ensure();
+ int txt_flag = DRW_TEXT_CACHE_GLOBALSPACE | DRW_TEXT_CACHE_ASCII;
+ int stepsize = avs->path_step;
+ int sfra, efra, sind, len;
+ int cfra = (int)DEG_get_ctime(draw_ctx->depsgraph);
+ bool sel = (pchan) ? (pchan->bone->flag & BONE_SELECTED) : (ob->flag & SELECT);
+ bool show_keyframes = (avs->path_viewflag & MOTIONPATH_VIEW_KFRAS) != 0;
+ bMotionPathVert *mpv, *mpv_start;
+
+ /* get frame ranges */
+ if (avs->path_type == MOTIONPATH_TYPE_ACFRA) {
+ /* With "Around Current", we only choose frames from around
+ * the current frame to draw.
+ */
+ sfra = cfra - avs->path_bc;
+ efra = cfra + avs->path_ac + 1;
+ }
+ else {
+ /* Use the current display range */
+ sfra = avs->path_sf;
+ efra = avs->path_ef;
+ }
+
+ /* no matter what, we can only show what is in the cache and no more
+ * - abort if whole range is past ends of path
+ * - otherwise clamp endpoints to extents of path
+ */
+ if (sfra < mpath->start_frame) {
+ /* start clamp */
+ sfra = mpath->start_frame;
+ }
+ if (efra > mpath->end_frame) {
+ /* end clamp */
+ efra = mpath->end_frame;
+ }
+
+ if ((sfra > mpath->end_frame) || (efra < mpath->start_frame)) {
+ /* whole path is out of bounds */
+ return;
+ }
+
+ len = efra - sfra;
+
+ if ((len <= 0) || (mpath->points == NULL)) {
+ return;
+ }
+
+ sind = sfra - mpath->start_frame;
+ mpv_start = (mpath->points + sind);
+
+ bool use_custom_col = (mpath->flag & MOTIONPATH_FLAG_CUSTOM) != 0;
+
+ /* draw curve-line of path */
+ /* Draw lines only if line drawing option is enabled */
+ if (mpath->flag & MOTIONPATH_FLAG_LINES) {
+ DRWShadingGroup *shgrp = DRW_shgroup_create(mpath_line_shader_get(), psl->lines);
+ DRW_shgroup_uniform_int_copy(shgrp, "frameCurrent", cfra);
+ DRW_shgroup_uniform_int_copy(shgrp, "frameStart", sfra);
+ DRW_shgroup_uniform_int_copy(shgrp, "frameEnd", efra);
+ DRW_shgroup_uniform_int_copy(shgrp, "cacheStart", mpath->start_frame);
+ DRW_shgroup_uniform_int_copy(shgrp, "lineThickness", mpath->line_thickness);
+ DRW_shgroup_uniform_bool_copy(shgrp, "selected", sel);
+ DRW_shgroup_uniform_bool_copy(shgrp, "useCustomColor", use_custom_col);
+ DRW_shgroup_uniform_vec2(shgrp, "viewportSize", DRW_viewport_size_get(), 1);
+ DRW_shgroup_uniform_block(shgrp, "globalsBlock", globals_ubo);
+ if (use_custom_col) {
+ DRW_shgroup_uniform_vec3(shgrp, "customColor", mpath->color, 1);
+ }
+ /* Only draw the required range. */
+ DRW_shgroup_call_range_add(shgrp, mpath_batch_line_get(mpath), NULL, sind, len);
+ }
+
+ /* Draw points. */
+ DRWShadingGroup *shgrp = DRW_shgroup_create(mpath_points_shader_get(), psl->points);
+ DRW_shgroup_uniform_int_copy(shgrp, "frameCurrent", cfra);
+ DRW_shgroup_uniform_int_copy(shgrp, "cacheStart", mpath->start_frame);
+ DRW_shgroup_uniform_int_copy(shgrp, "pointSize", mpath->line_thickness);
+ DRW_shgroup_uniform_int_copy(shgrp, "stepSize", stepsize);
+ DRW_shgroup_uniform_bool_copy(shgrp, "selected", sel);
+ DRW_shgroup_uniform_bool_copy(shgrp, "showKeyFrames", show_keyframes);
+ DRW_shgroup_uniform_bool_copy(shgrp, "useCustomColor", use_custom_col);
+ DRW_shgroup_uniform_block(shgrp, "globalsBlock", globals_ubo);
+ if (use_custom_col) {
+ DRW_shgroup_uniform_vec3(shgrp, "customColor", mpath->color, 1);
+ }
+ /* Only draw the required range. */
+ DRW_shgroup_call_range_add(shgrp, mpath_batch_points_get(mpath), NULL, sind, len);
+
+ /* Draw frame numbers at each framestep value */
+ bool show_kf_no = (avs->path_viewflag & MOTIONPATH_VIEW_KFNOS) != 0;
+ if ((avs->path_viewflag & (MOTIONPATH_VIEW_FNUMS)) || (show_kf_no && show_keyframes)) {
+ int i;
+ unsigned char col[4], col_kf[4];
+ UI_GetThemeColor3ubv(TH_TEXT_HI, col);
+ UI_GetThemeColor3ubv(TH_VERTEX_SELECT, col_kf);
+ col[3] = col_kf[3] = 255;
+
+ for (i = 0, mpv = mpv_start; i < len; i += stepsize, mpv += stepsize) {
+ int frame = sfra + i;
+ char numstr[32];
+ size_t numstr_len;
+ float co[3];
+ bool is_keyframe = (mpv->flag & MOTIONPATH_VERT_KEY) != 0;
+
+ if ((show_keyframes && show_kf_no && is_keyframe) ||
+ ((avs->path_viewflag & MOTIONPATH_VIEW_FNUMS) && (i == 0)))
+ {
+ numstr_len = sprintf(numstr, " %d", frame);
+ mul_v3_m4v3(co, ob->imat, mpv->co);
+ DRW_text_cache_add(dt, co, numstr, numstr_len, 0, txt_flag, (is_keyframe) ? col_kf : col);
+ }
+ else if (avs->path_viewflag & MOTIONPATH_VIEW_FNUMS) {
+ bMotionPathVert *mpvP = (mpv - stepsize);
+ bMotionPathVert *mpvN = (mpv + stepsize);
+ /* only draw framenum if several consecutive highlighted points don't occur on same point */
+ if ((equals_v3v3(mpv->co, mpvP->co) == 0) || (equals_v3v3(mpv->co, mpvN->co) == 0)) {
+ numstr_len = sprintf(numstr, " %d", frame);
+ mul_v3_m4v3(co, ob->imat, mpv->co);
+ DRW_text_cache_add(dt, co, numstr, numstr_len, 0, txt_flag, col);
+ }
+ }
+ }
+ }
+}
+
+/* Add geometry to shading groups. Execute for each objects */
+static void MPATH_cache_populate(void *vedata, Object *ob)
+{
+ MPATH_PassList *psl = ((MPATH_Data *)vedata)->psl;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+
+ if (draw_ctx->v3d->overlay.flag & V3D_OVERLAY_HIDE_MOTION_PATHS) {
+ return;
+ }
+
+ if (ob->type == OB_ARMATURE) {
+ if (DRW_pose_mode_armature(ob, draw_ctx->obact)) {
+ for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ if (pchan->mpath) {
+ MPATH_cache_motion_path(psl, ob, pchan, &ob->pose->avs, pchan->mpath);
+ }
+ }
+ }
+ }
+ else {
+ if (ob->mpath) {
+ MPATH_cache_motion_path(psl, ob, NULL, &ob->avs, ob->mpath);
+ }
+ }
+}
+
+/* Draw time! Control rendering pipeline from here */
+static void MPATH_draw_scene(void *vedata)
+{
+ MPATH_PassList *psl = ((MPATH_Data *)vedata)->psl;
+ DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
+ DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+
+ MULTISAMPLE_SYNC_ENABLE(dfbl, dtxl)
+
+ DRW_draw_pass(psl->lines);
+ DRW_draw_pass(psl->points);
+
+ MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl)
+}
+
+/* *************************** Draw Engine Defines ****************************** */
+
+static const DrawEngineDataSize MPATH_data_size = DRW_VIEWPORT_DATA_SIZE(MPATH_Data);
+
+DrawEngineType draw_engine_motion_path_type = {
+ NULL, NULL,
+ N_("MotionPath"),
+ &MPATH_data_size,
+ &MPATH_engine_init,
+ &MPATH_engine_free,
+ &MPATH_cache_init,
+ &MPATH_cache_populate,
+ NULL,
+ NULL,
+ &MPATH_draw_scene,
+ NULL,
+ NULL,
+};
+
diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c
index ed9bb6f8ca9..82662d77020 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -319,21 +319,32 @@ static void drw_shgroup_bone_custom_solid(
Object *custom)
{
/* grr, not re-using instances! */
- struct Gwn_Batch *geom = DRW_cache_object_surface_get(custom);
- if (geom) {
- DRWShadingGroup *shgrp_geom_solid = shgroup_instance_bone_shape_solid(g_data.passes.bone_solid, geom);
- float final_bonemat[4][4];
+ struct Gwn_Batch *surf = DRW_cache_object_surface_get(custom);
+ struct Gwn_Batch *edges = DRW_cache_object_edge_detection_get(custom, NULL);
+ struct Gwn_Batch *ledges = DRW_cache_object_loose_edges_get(custom);
+ float final_bonemat[4][4];
+
+ if (surf || edges || ledges) {
mul_m4_m4m4(final_bonemat, g_data.ob->obmat, bone_mat);
+ }
+
+ if (surf) {
+ DRWShadingGroup *shgrp_geom_solid = shgroup_instance_bone_shape_solid(g_data.passes.bone_solid, surf);
DRW_shgroup_call_dynamic_add(shgrp_geom_solid, final_bonemat, bone_color, hint_color);
}
- geom = DRW_cache_object_edge_detection_get(custom, NULL);
- if (geom && outline_color[3] > 0.0f) {
- DRWShadingGroup *shgrp_geom_wire = shgroup_instance_bone_shape_outline(g_data.passes.bone_outline, geom);
- float final_bonemat[4][4];
- mul_m4_m4m4(final_bonemat, g_data.ob->obmat, bone_mat);
+ if (edges && outline_color[3] > 0.0f) {
+ DRWShadingGroup *shgrp_geom_wire = shgroup_instance_bone_shape_outline(g_data.passes.bone_outline, edges);
DRW_shgroup_call_dynamic_add(shgrp_geom_wire, final_bonemat, outline_color);
}
+
+ if (ledges) {
+ DRWShadingGroup *shgrp_geom_ledges = shgroup_instance_wire(g_data.passes.bone_wire, ledges);
+ float final_color[4];
+ copy_v3_v3(final_color, outline_color);
+ final_color[3] = 1.0f; /* hack */
+ DRW_shgroup_call_dynamic_add(shgrp_geom_ledges, final_bonemat, final_color);
+ }
}
static void drw_shgroup_bone_custom_wire(
@@ -1451,6 +1462,10 @@ static void pchan_draw_ik_lines(bPoseChannel *pchan, const bool only_temp, const
bSplineIKConstraint *data = (bSplineIKConstraint *)con->data;
int segcount = 0;
+ /* don't draw if only_temp, as Spline IK chains cannot be temporary */
+ if (only_temp)
+ continue;
+
parchan = pchan;
line_start = parchan->pose_tail;
@@ -1478,17 +1493,24 @@ static void draw_bone_relations(
{
if (g_data.passes.relationship_lines) {
if (ebone && ebone->parent) {
- if ((boneflag & BONE_CONNECTED) == 0) {
- drw_shgroup_bone_relationship_lines(ebone->head, ebone->parent->tail);
+ if (do_relations) {
+ /* Always draw for unconnected bones, regardless of selection,
+ * since riggers will want to know about the links between bones
+ */
+ if ((boneflag & BONE_CONNECTED) == 0) {
+ drw_shgroup_bone_relationship_lines(ebone->head, ebone->parent->tail);
+ }
}
}
else if (pchan && pchan->parent) {
- /* Only draw if bone or its parent is selected - reduces viewport complexity with complex rigs */
- if ((boneflag & BONE_SELECTED) ||
- (pchan->parent->bone && (pchan->parent->bone->flag & BONE_SELECTED)))
- {
- if ((boneflag & BONE_CONNECTED) == 0) {
- drw_shgroup_bone_relationship_lines(pchan->pose_head, pchan->parent->pose_tail);
+ if (do_relations) {
+ /* Only draw if bone or its parent is selected - reduces viewport complexity with complex rigs */
+ if ((boneflag & BONE_SELECTED) ||
+ (pchan->parent->bone && (pchan->parent->bone->flag & BONE_SELECTED)))
+ {
+ if ((boneflag & BONE_CONNECTED) == 0) {
+ drw_shgroup_bone_relationship_lines(pchan->pose_head, pchan->parent->pose_tail);
+ }
}
}
@@ -1512,6 +1534,7 @@ static void draw_bone_relations(
static void draw_armature_edit(Object *ob)
{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
EditBone *eBone;
bArmature *arm = ob->data;
int index;
@@ -1520,7 +1543,7 @@ static void draw_armature_edit(Object *ob)
update_color(ob, NULL);
const bool show_text = DRW_state_show_text();
- const bool show_relations = true; /* TODO get value from overlays settings. */
+ const bool show_relations = ((draw_ctx->v3d->flag & V3D_HIDE_HELPLINES) == 0);
for (eBone = arm->edbo->first, index = ob->select_color; eBone; eBone = eBone->next, index += 0x10000) {
if (eBone->layer & arm->layer) {
@@ -1590,6 +1613,7 @@ static void draw_armature_edit(Object *ob)
/* if const_color is NULL do pose mode coloring */
static void draw_armature_pose(Object *ob, const float const_color[4])
{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
bArmature *arm = ob->data;
bPoseChannel *pchan;
int index = -1;
@@ -1604,8 +1628,6 @@ static void draw_armature_pose(Object *ob, const float const_color[4])
// if (!(base->flag & OB_FROMDUPLI)) // TODO
{
- const DRWContextState *draw_ctx = DRW_context_state_get();
-
if ((draw_ctx->object_mode & OB_MODE_POSE) || (ob == draw_ctx->object_pose)) {
arm->flag |= ARM_POSEMODE;
}
@@ -1617,7 +1639,7 @@ static void draw_armature_pose(Object *ob, const float const_color[4])
const bool is_pose_select = (arm->flag & ARM_POSEMODE) && DRW_state_is_select();
const bool show_text = DRW_state_show_text();
- const bool show_relations = true; /* TODO get value from overlays settings. */
+ const bool show_relations = ((draw_ctx->v3d->flag & V3D_HIDE_HELPLINES) == 0);
/* being set below */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index b08735860c9..a8d2c2a3642 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -26,6 +26,7 @@
#include "DNA_scene_types.h"
#include "DNA_mesh_types.h"
+#include "DNA_meta_types.h"
#include "DNA_curve_types.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
@@ -111,6 +112,17 @@ void DRW_shape_cache_free(void)
}
}
+void DRW_shape_cache_reset(void)
+{
+ uint i = sizeof(SHC) / sizeof(Gwn_Batch *);
+ Gwn_Batch **batch = (Gwn_Batch **)&SHC;
+ while (i--) {
+ if (*batch) {
+ gwn_batch_vao_cache_clear(*batch);
+ }
+ batch++;
+ }
+}
/* -------------------------------------------------------------------- */
@@ -502,7 +514,6 @@ Gwn_Batch *DRW_cache_object_wire_outline_get(Object *ob)
}
}
-/* Returns a buffer texture. */
Gwn_Batch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold)
{
switch (ob->type) {
@@ -515,6 +526,30 @@ Gwn_Batch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold)
}
}
+/* Returns a buffer texture. */
+void DRW_cache_object_face_wireframe_get(
+ Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count)
+{
+ switch (ob->type) {
+ case OB_MESH:
+ DRW_mesh_batch_cache_get_wireframes_face_texbuf((Mesh *)ob->data, r_vert_tx, r_faceid_tx, r_tri_count);
+
+ /* TODO, should match 'DRW_cache_object_surface_get' */
+ }
+}
+
+Gwn_Batch *DRW_cache_object_loose_edges_get(struct Object *ob)
+{
+ switch (ob->type) {
+ case OB_MESH:
+ return DRW_cache_mesh_loose_edges_get(ob);
+
+ /* TODO, should match 'DRW_cache_object_surface_get' */
+ default:
+ return NULL;
+ }
+}
+
Gwn_Batch *DRW_cache_object_surface_get(Object *ob)
{
switch (ob->type) {
@@ -553,6 +588,8 @@ Gwn_Batch **DRW_cache_object_surface_material_get(
return DRW_cache_surf_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
case OB_FONT:
return DRW_cache_text_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
+ case OB_MBALL:
+ return DRW_cache_mball_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
default:
return NULL;
}
@@ -2183,7 +2220,8 @@ Gwn_Batch *DRW_cache_bone_stick_get(void)
GWN_indexbuf_add_generic_vert(&elb, v++);
}
- SHC.drw_bone_stick = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, GWN_indexbuf_build(&elb), GWN_BATCH_OWNS_VBO);
+ SHC.drw_bone_stick = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, GWN_indexbuf_build(&elb),
+ GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
#undef CIRCLE_RESOL
}
return SHC.drw_bone_stick;
@@ -2601,6 +2639,14 @@ Gwn_Batch *DRW_cache_mesh_surface_get(Object *ob)
return DRW_mesh_batch_cache_get_triangles_with_normals(me);
}
+Gwn_Batch *DRW_cache_mesh_loose_edges_get(Object *ob)
+{
+ BLI_assert(ob->type == OB_MESH);
+
+ Mesh *me = ob->data;
+ return DRW_mesh_batch_cache_get_loose_edges_with_normals(me);
+}
+
Gwn_Batch *DRW_cache_mesh_surface_weights_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -2772,6 +2818,14 @@ Gwn_Batch *DRW_cache_mball_surface_get(Object *ob)
return DRW_metaball_batch_cache_get_triangles_with_normals(ob);
}
+Gwn_Batch **DRW_cache_mball_surface_shaded_get(
+ Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
+{
+ BLI_assert(ob->type == OB_MBALL);
+ MetaBall *mb = ob->data;
+ return DRW_metaball_batch_cache_get_surface_shaded(ob, mb, gpumat_array, gpumat_array_len);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index 1fd6b22c221..e7ab847d42e 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -33,6 +33,7 @@ struct Object;
struct PTCacheEdit;
void DRW_shape_cache_free(void);
+void DRW_shape_cache_reset(void);
/* 3D cursor */
struct Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines);
@@ -50,9 +51,12 @@ struct Gwn_Batch *DRW_cache_screenspace_circle_get(void);
struct Gwn_Batch *DRW_cache_object_wire_outline_get(struct Object *ob);
struct Gwn_Batch *DRW_cache_object_edge_detection_get(struct Object *ob, bool *r_is_manifold);
struct Gwn_Batch *DRW_cache_object_surface_get(struct Object *ob);
+struct Gwn_Batch *DRW_cache_object_loose_edges_get(struct Object *ob);
struct Gwn_Batch **DRW_cache_object_surface_material_get(
struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count);
+void DRW_cache_object_face_wireframe_get(
+ Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count);
/* Empties */
struct Gwn_Batch *DRW_cache_plain_axes_get(void);
@@ -122,6 +126,7 @@ struct Gwn_Batch *DRW_cache_face_centers_get(struct Object *ob);
struct Gwn_Batch *DRW_cache_mesh_wire_outline_get(struct Object *ob);
struct Gwn_Batch *DRW_cache_mesh_edge_detection_get(struct Object *ob, bool *r_is_manifold);
struct Gwn_Batch *DRW_cache_mesh_surface_get(struct Object *ob);
+struct Gwn_Batch *DRW_cache_mesh_loose_edges_get(struct Object *ob);
struct Gwn_Batch *DRW_cache_mesh_surface_weights_get(struct Object *ob);
struct Gwn_Batch *DRW_cache_mesh_surface_vert_colors_get(struct Object *ob);
struct Gwn_Batch *DRW_cache_mesh_surface_verts_get(struct Object *ob);
@@ -183,5 +188,6 @@ struct Gwn_Batch *DRW_cache_particles_get_prim(int type);
/* Metaball */
struct Gwn_Batch *DRW_cache_mball_surface_get(struct Object *ob);
+struct Gwn_Batch **DRW_cache_mball_surface_shaded_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
#endif /* __DRAW_CACHE_H__ */
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index f77dafc9b31..5773daf8e96 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -28,6 +28,7 @@
struct CurveCache;
struct GPUMaterial;
+struct GPUTexture;
struct Gwn_Batch;
struct Gwn_IndexBuf;
struct Gwn_VertBuf;
@@ -72,6 +73,7 @@ struct Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded(
/* Metaball */
struct Gwn_Batch *DRW_metaball_batch_cache_get_triangles_with_normals(struct Object *ob);
+struct Gwn_Batch **DRW_metaball_batch_cache_get_surface_shaded(struct Object *ob, struct MetaBall *mb, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
/* Curve (Font) */
struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_cursor(struct Curve *cu);
@@ -107,6 +109,7 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(st
struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(struct Mesh *me);
struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide, uint select_id_offset);
struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide);
+struct Gwn_Batch *DRW_mesh_batch_cache_get_loose_edges_with_normals(struct Mesh *me);
struct Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(struct Mesh *me);
struct Gwn_Batch *DRW_mesh_batch_cache_get_all_verts(struct Mesh *me);
struct Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(struct Mesh *me);
@@ -121,6 +124,9 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(struct Mesh *me);
struct Gwn_Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(struct Mesh *me, uint select_id_offset);
struct Gwn_Batch *DRW_mesh_batch_cache_get_edges_with_select_id(struct Mesh *me, uint select_id_offset);
struct Gwn_Batch *DRW_mesh_batch_cache_get_verts_with_select_id(struct Mesh *me, uint select_id_offset);
+/* Object mode Wireframe overlays */
+void DRW_mesh_batch_cache_get_wireframes_face_texbuf(
+ struct Mesh *me, struct GPUTexture **verts_data, struct GPUTexture **face_indices, int *tri_count);
void DRW_mesh_cache_sculpt_coords_ensure(struct Mesh *me);
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index cf972434ba5..8e45833026d 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -112,6 +112,10 @@ typedef struct EdgeAdjacentPolys {
int face_index[2];
} EdgeAdjacentPolys;
+typedef struct EdgeAdjacentVerts {
+ int vert_index[2]; /* -1 if none */
+} EdgeAdjacentVerts;
+
typedef struct EdgeDrawAttr {
unsigned char v_flag;
unsigned char e_flag;
@@ -139,6 +143,7 @@ typedef struct MeshRenderData {
MLoop *mloop;
MPoly *mpoly;
float (*orco)[3]; /* vertex coordinates normalized to bounding box */
+ bool is_orco_allocated;
MDeformVert *dvert;
MLoopUV *mloopuv;
MLoopCol *mloopcol;
@@ -564,10 +569,12 @@ static MeshRenderData *mesh_render_data_create_ex(
#undef CD_VALIDATE_ACTIVE_LAYER
+ rdata->is_orco_allocated = false;
if (cd_vused[CD_ORCO] & 1) {
rdata->orco = CustomData_get_layer(cd_vdata, CD_ORCO);
/* If orco is not available compute it ourselves */
if (!rdata->orco) {
+ rdata->is_orco_allocated = true;
if (me->edit_btmesh) {
BMesh *bm = me->edit_btmesh->bm;
rdata->orco = MEM_mallocN(sizeof(*rdata->orco) * rdata->vert_len, "orco mesh");
@@ -814,7 +821,9 @@ static MeshRenderData *mesh_render_data_create_ex(
static void mesh_render_data_free(MeshRenderData *rdata)
{
- MEM_SAFE_FREE(rdata->orco);
+ if (rdata->is_orco_allocated) {
+ MEM_SAFE_FREE(rdata->orco);
+ }
MEM_SAFE_FREE(rdata->cd.offset.uv);
MEM_SAFE_FREE(rdata->cd.offset.vcol);
MEM_SAFE_FREE(rdata->cd.uuid.auto_mix);
@@ -1536,10 +1545,12 @@ static void add_overlay_loose_vert(
typedef struct MeshBatchCache {
Gwn_VertBuf *pos_in_order;
- Gwn_VertBuf *nor_in_order;
Gwn_IndexBuf *edges_in_order;
Gwn_IndexBuf *edges_adjacency; /* Store edges with adjacent vertices. */
Gwn_IndexBuf *triangles_in_order;
+ Gwn_IndexBuf *ledges_in_order;
+
+ GPUTexture *pos_in_order_tx; /* Depending on pos_in_order */
Gwn_Batch *all_verts;
Gwn_Batch *all_edges;
@@ -1557,6 +1568,7 @@ typedef struct MeshBatchCache {
Gwn_VertBuf *ed_vert_pos;
Gwn_Batch *triangles_with_normals;
+ Gwn_Batch *ledges_with_normals;
/* Skip hidden (depending on paint select mode) */
Gwn_Batch *triangles_with_weights;
@@ -1579,6 +1591,10 @@ typedef struct MeshBatchCache {
Gwn_Batch *edge_detection;
+ Gwn_VertBuf *edges_face_overlay;
+ GPUTexture *edges_face_overlay_tx;
+ int edges_face_overlay_tri_count; /* Number of tri in edges_face_overlay(_adj)_tx */
+
/* Maybe have shaded_triangles_data split into pos_nor and uv_tangent
* to minimise data transfer for skinned mesh. */
Gwn_VertFormat shaded_triangles_format;
@@ -1778,6 +1794,7 @@ static void mesh_batch_cache_clear_selective(Mesh *me, Gwn_VertBuf *vert)
GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_id);
GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_mask);
GWN_BATCH_DISCARD_SAFE(cache->points_with_normals);
+ GWN_BATCH_DISCARD_SAFE(cache->ledges_with_normals);
if (cache->shaded_triangles) {
for (int i = 0; i < cache->mat_len; ++i) {
GWN_BATCH_DISCARD_SAFE(cache->shaded_triangles[i]);
@@ -1811,8 +1828,10 @@ static void mesh_batch_cache_clear(Mesh *me)
GWN_BATCH_DISCARD_SAFE(cache->all_triangles);
GWN_VERTBUF_DISCARD_SAFE(cache->pos_in_order);
+ DRW_TEXTURE_FREE_SAFE(cache->pos_in_order_tx);
GWN_INDEXBUF_DISCARD_SAFE(cache->edges_in_order);
GWN_INDEXBUF_DISCARD_SAFE(cache->triangles_in_order);
+ GWN_INDEXBUF_DISCARD_SAFE(cache->ledges_in_order);
GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_pos);
GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_nor);
@@ -1836,6 +1855,7 @@ static void mesh_batch_cache_clear(Mesh *me)
GWN_BATCH_DISCARD_SAFE(cache->triangles_with_normals);
GWN_BATCH_DISCARD_SAFE(cache->points_with_normals);
+ GWN_BATCH_DISCARD_SAFE(cache->ledges_with_normals);
GWN_VERTBUF_DISCARD_SAFE(cache->pos_with_normals);
GWN_BATCH_DISCARD_SAFE(cache->triangles_with_weights);
GWN_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors);
@@ -1854,6 +1874,9 @@ static void mesh_batch_cache_clear(Mesh *me)
GWN_INDEXBUF_DISCARD_SAFE(cache->edges_adjacency);
GWN_BATCH_DISCARD_SAFE(cache->edge_detection);
+ GWN_VERTBUF_DISCARD_SAFE(cache->edges_face_overlay);
+ DRW_TEXTURE_FREE_SAFE(cache->edges_face_overlay_tx);
+
GWN_VERTBUF_DISCARD_SAFE(cache->shaded_triangles_data);
if (cache->shaded_triangles_in_order) {
for (int i = 0; i < cache->mat_len; ++i) {
@@ -2821,8 +2844,9 @@ static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order(
static Gwn_VertFormat format = { 0 };
static struct { uint pos, nor; } attr_id;
if (format.attrib_ct == 0) {
+ /* Normal is padded so that the vbo can be used as a buffer texture */
attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I16, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I16, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
}
Gwn_VertBuf *vbo = cache->pos_in_order = GWN_vertbuf_create_with_format(&format);
@@ -2836,7 +2860,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order(
uint i;
BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
- static short no_short[3];
+ static short no_short[4];
normal_float_to_short_v3(no_short, eve->no);
GWN_vertbuf_attr_set(vbo, attr_id.pos, i, eve->co);
@@ -2847,7 +2871,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order(
else {
for (int i = 0; i < vbo_len_capacity; ++i) {
GWN_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->mvert[i].co);
- GWN_vertbuf_attr_set(vbo, attr_id.nor, i, rdata->mvert[i].no);
+ GWN_vertbuf_attr_set(vbo, attr_id.nor, i, rdata->mvert[i].no); /* XXX actually reading 4 shorts */
}
}
}
@@ -3247,7 +3271,7 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata,
/* Create edges for each pair of triangles sharing an edge. */
for (int i = 0; i < tri_len; i++) {
for (int e = 0; e < 3; ++e) {
- unsigned int v0, v1, v2;
+ uint v0, v1, v2;
if (rdata->edit_bmesh) {
const BMLoop **bm_looptri = (const BMLoop **)rdata->edit_bmesh->looptris[i];
if (BM_elem_flag_test(bm_looptri[0]->f, BM_ELEM_HIDDEN)) {
@@ -3278,7 +3302,7 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata,
/* HACK Tag as not used. Prevent overhead of BLI_edgehash_remove. */
*pval = SET_INT_IN_POINTER(NO_EDGE);
bool inv_opposite = (v_data < 0);
- unsigned int v_opposite = (unsigned int)abs(v_data) - 1;
+ uint v_opposite = (uint)abs(v_data) - 1;
if (inv_opposite == inv_indices) {
/* Don't share edge if triangles have non matching winding. */
@@ -3298,15 +3322,15 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata,
BLI_edgehashIterator_isDone(ehi) == false;
BLI_edgehashIterator_step(ehi))
{
- unsigned int v1, v2;
+ uint v1, v2;
int v_data = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi));
if (v_data == NO_EDGE) {
continue;
}
BLI_edgehashIterator_getKey(ehi, &v1, &v2);
- unsigned int v0 = (unsigned int)abs(v_data) - 1;
+ uint v0 = (uint)abs(v_data) - 1;
if (v_data < 0) { /* inv_opposite */
- SWAP(unsigned int, v1, v2);
+ SWAP(uint, v1, v2);
}
GWN_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0);
cache->is_manifold = false;
@@ -3318,10 +3342,150 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata,
}
return cache->edges_adjacency;
-
}
#undef NO_EDGE
+static EdgeHash *create_looptri_edge_adjacency_hash(MeshRenderData *rdata)
+{
+ const int tri_len = mesh_render_data_looptri_len_get(rdata);
+ /* Create adjacency info in looptri */
+ EdgeHash *eh = BLI_edgehash_new_ex(__func__, tri_len * 3);
+ /* Create edges for each pair of triangles sharing an edge. */
+ for (int i = 0; i < tri_len; i++) {
+ for (int e = 0; e < 3; ++e) {
+ uint v0, v1, v2;
+ if (rdata->edit_bmesh) {
+ const BMLoop **bm_looptri = (const BMLoop **)rdata->edit_bmesh->looptris[i];
+ if (BM_elem_flag_test(bm_looptri[0]->f, BM_ELEM_HIDDEN)) {
+ break;
+ }
+ v0 = BM_elem_index_get(bm_looptri[e]->v);
+ v1 = BM_elem_index_get(bm_looptri[(e + 1) % 3]->v);
+ v2 = BM_elem_index_get(bm_looptri[(e + 2) % 3]->v);
+ }
+ else {
+ MLoop *mloop = rdata->mloop;
+ MLoopTri *mlt = rdata->mlooptri + i;
+ v0 = mloop[mlt->tri[e]].v;
+ v1 = mloop[mlt->tri[(e + 1) % 3]].v;
+ v2 = mloop[mlt->tri[(e + 2) % 3]].v;
+ }
+
+ EdgeAdjacentVerts **eav;
+ bool value_is_init = BLI_edgehash_ensure_p(eh, v1, v2, (void ***)&eav);
+ if (!value_is_init) {
+ *eav = MEM_mallocN(sizeof(**eav), "EdgeAdjacentVerts");
+ (*eav)->vert_index[0] = v0;
+ (*eav)->vert_index[1] = -1;
+ }
+ else {
+ if ((*eav)->vert_index[1] == -1) {
+ (*eav)->vert_index[1] = v0;
+ }
+ else {
+ /* Not a manifold edge. */
+ }
+ }
+ }
+ }
+ return eh;
+}
+
+static Gwn_VertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRenderData *rdata)
+{
+ const int tri_len = mesh_render_data_looptri_len_get(rdata);
+
+ Gwn_VertFormat format = {0};
+ uint index_id = GWN_vertformat_attr_add(&format, "index", GWN_COMP_U32, 1, GWN_FETCH_INT);
+ Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
+
+ int vbo_len_capacity = tri_len * 3;
+ GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+
+ int vidx = 0;
+ EdgeHash *eh = NULL;
+ eh = create_looptri_edge_adjacency_hash(rdata);
+
+ for (int i = 0; i < tri_len; i++) {
+ bool edge_is_real[3] = {false, false, false};
+
+ MEdge *medge = rdata->medge;
+ MLoop *mloop = rdata->mloop;
+ MLoopTri *mlt = rdata->mlooptri + i;
+
+ int j, j_next;
+ for (j = 2, j_next = 0; j_next < 3; j = j_next++) {
+ MEdge *ed = &medge[mloop[mlt->tri[j]].e];
+ unsigned int tri_edge[2] = {mloop[mlt->tri[j]].v, mloop[mlt->tri[j_next]].v};
+
+ if (((ed->v1 == tri_edge[0]) && (ed->v2 == tri_edge[1])) ||
+ ((ed->v1 == tri_edge[1]) && (ed->v2 == tri_edge[0])))
+ {
+ edge_is_real[j] = true;
+ }
+ }
+
+ for (int e = 0; e < 3; ++e) {
+ int v0 = mloop[mlt->tri[e]].v;
+ int v1 = mloop[mlt->tri[(e + 1) % 3]].v;
+ EdgeAdjacentVerts *eav = BLI_edgehash_lookup(eh, v0, v1);
+ uint value = (uint)v0;
+ /* Real edge */
+ if (edge_is_real[e]) {
+ value |= (1 << 30);
+ }
+ /* Non-manifold edge */
+ if (eav->vert_index[1] == -1) {
+ value |= (1 << 31);
+ }
+ GWN_vertbuf_attr_set(vbo, index_id, vidx++, &value);
+ }
+ }
+
+ BLI_edgehash_free(eh, MEM_freeN);
+
+ int vbo_len_used = vidx;
+
+ if (vbo_len_capacity != vbo_len_used) {
+ GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ }
+
+ return vbo;
+}
+
+static GPUTexture *mesh_batch_cache_get_edges_overlay_texture_buf(MeshRenderData *rdata, MeshBatchCache *cache)
+{
+ BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI));
+
+ BLI_assert(rdata->edit_bmesh == NULL); /* Not supported in edit mode */
+
+ if (cache->edges_face_overlay_tx != NULL) {
+ return cache->edges_face_overlay_tx;
+ }
+
+ Gwn_VertBuf *vbo = cache->edges_face_overlay = mesh_batch_cache_create_edges_overlay_texture_buf(rdata);
+
+ /* Upload data early because we need to create the texture for it. */
+ GWN_vertbuf_use(vbo);
+ cache->edges_face_overlay_tx = GPU_texture_create_from_vertbuf(vbo);
+ cache->edges_face_overlay_tri_count = vbo->vertex_alloc / 3;
+
+ return cache->edges_face_overlay_tx;
+}
+
+static GPUTexture *mesh_batch_cache_get_vert_pos_and_nor_in_order_buf(MeshRenderData *rdata, MeshBatchCache *cache)
+{
+ BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI));
+
+ if (cache->pos_in_order_tx == NULL) {
+ Gwn_VertBuf *pos_in_order = mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache);
+ GWN_vertbuf_use(pos_in_order); /* Upload early for buffer texture creation. */
+ cache->pos_in_order_tx = GPU_texture_create_buffer(GPU_R32F, pos_in_order->vbo_id);
+ }
+
+ return cache->pos_in_order_tx;
+}
+
static Gwn_IndexBuf *mesh_batch_cache_get_triangles_in_order(MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI));
@@ -3357,6 +3521,45 @@ static Gwn_IndexBuf *mesh_batch_cache_get_triangles_in_order(MeshRenderData *rda
return cache->triangles_in_order;
}
+
+static Gwn_IndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, MeshBatchCache *cache)
+{
+ BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI));
+
+ if (cache->ledges_in_order == NULL) {
+ const int vert_len = mesh_render_data_verts_len_get(rdata);
+ const int edge_len = mesh_render_data_edges_len_get(rdata);
+
+ /* Alloc max (edge_len) and upload only needed range. */
+ Gwn_IndexBufBuilder elb;
+ GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len);
+
+ if (rdata->edit_bmesh) {
+ /* No need to support since edit mesh already draw them.
+ * But some engines may want them ... */
+ BMesh *bm = rdata->edit_bmesh->bm;
+ BMIter eiter;
+ BMEdge *eed;
+ BM_ITER_MESH(eed, &eiter, bm, BM_EDGES_OF_MESH) {
+ if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_edge_is_wire(eed)) {
+ GWN_indexbuf_add_line_verts(&elb, BM_elem_index_get(eed->v1), BM_elem_index_get(eed->v2));
+ }
+ }
+ }
+ else {
+ for (int i = 0; i < edge_len; ++i) {
+ const MEdge *medge = &rdata->medge[i];
+ if (medge->flag & ME_LOOSEEDGE) {
+ GWN_indexbuf_add_line_verts(&elb, medge->v1, medge->v2);
+ }
+ }
+ }
+ cache->ledges_in_order = GWN_indexbuf_build(&elb);
+ }
+
+ return cache->ledges_in_order;
+}
+
static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
MeshRenderData *rdata, MeshBatchCache *cache)
{
@@ -3582,7 +3785,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_edges(Mesh *me)
cache->all_edges = GWN_batch_create(
GWN_PRIM_LINES, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache),
- mesh_batch_cache_get_edges_in_order(rdata, cache));
+ mesh_batch_cache_get_edges_in_order(rdata, cache));
mesh_render_data_free(rdata);
}
@@ -3626,6 +3829,24 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me)
return cache->triangles_with_normals;
}
+Gwn_Batch *DRW_mesh_batch_cache_get_loose_edges_with_normals(Mesh *me)
+{
+ MeshBatchCache *cache = mesh_batch_cache_get(me);
+
+ if (cache->ledges_with_normals == NULL) {
+ const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY;
+ MeshRenderData *rdata = mesh_render_data_create(me, datatype);
+
+ cache->ledges_with_normals = GWN_batch_create(
+ GWN_PRIM_LINES, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache),
+ mesh_batch_cache_get_loose_edges(rdata, cache));
+
+ mesh_render_data_free(rdata);
+ }
+
+ return cache->ledges_with_normals;
+}
+
Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me, int defgroup)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -3852,6 +4073,27 @@ Gwn_Batch *DRW_mesh_batch_cache_get_edge_detection(Mesh *me, bool *r_is_manifold
return cache->edge_detection;
}
+void DRW_mesh_batch_cache_get_wireframes_face_texbuf(
+ Mesh *me, GPUTexture **verts_data, GPUTexture **face_indices, int *tri_count)
+{
+ MeshBatchCache *cache = mesh_batch_cache_get(me);
+
+ if (cache->edges_face_overlay_tx == NULL || cache->pos_in_order_tx == NULL) {
+ const int options = MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI;
+
+ MeshRenderData *rdata = mesh_render_data_create(me, options);
+
+ mesh_batch_cache_get_edges_overlay_texture_buf(rdata, cache);
+ mesh_batch_cache_get_vert_pos_and_nor_in_order_buf(rdata, cache);
+
+ mesh_render_data_free(rdata);
+ }
+
+ *tri_count = cache->edges_face_overlay_tri_count;
+ *face_indices = cache->edges_face_overlay_tx;
+ *verts_data = cache->pos_in_order_tx;
+}
+
static void mesh_batch_cache_create_overlay_batches(Mesh *me)
{
BLI_assert(me->edit_btmesh != NULL);
diff --git a/source/blender/draw/intern/draw_cache_impl_metaball.c b/source/blender/draw/intern/draw_cache_impl_metaball.c
index f01e7b929f8..24930921bee 100644
--- a/source/blender/draw/intern/draw_cache_impl_metaball.c
+++ b/source/blender/draw/intern/draw_cache_impl_metaball.c
@@ -49,7 +49,9 @@ static void metaball_batch_cache_clear(MetaBall *mb);
typedef struct MetaBallBatchCache {
Gwn_Batch *batch;
+ Gwn_Batch **shaded_triangles;
+ int mat_len;
/* settings to determine if cache is invalid */
bool is_dirty;
} MetaBallBatchCache;
@@ -75,6 +77,8 @@ static void metaball_batch_cache_init(MetaBall *mb)
cache = mb->batch_cache = MEM_mallocN(sizeof(*cache), __func__);
}
cache->batch = NULL;
+ cache->mat_len = 0;
+ cache->shaded_triangles = NULL;
cache->is_dirty = false;
}
@@ -110,6 +114,9 @@ static void metaball_batch_cache_clear(MetaBall *mb)
}
GWN_BATCH_DISCARD_SAFE(cache->batch);
+ /* Note: shaded_triangles[0] is already freed by cache->batch */
+ MEM_SAFE_FREE(cache->shaded_triangles);
+ cache->mat_len = 0;
}
void DRW_mball_batch_cache_free(MetaBall *mb)
@@ -125,8 +132,9 @@ void DRW_mball_batch_cache_free(MetaBall *mb)
Gwn_Batch *DRW_metaball_batch_cache_get_triangles_with_normals(Object *ob)
{
- if (!BKE_mball_is_basis(ob))
+ if (!BKE_mball_is_basis(ob)) {
return NULL;
+ }
MetaBall *mb = ob->data;
MetaBallBatchCache *cache = metaball_batch_cache_get(mb);
@@ -142,3 +150,22 @@ Gwn_Batch *DRW_metaball_batch_cache_get_triangles_with_normals(Object *ob)
return cache->batch;
}
+
+Gwn_Batch **DRW_metaball_batch_cache_get_surface_shaded(Object *ob, MetaBall *mb, struct GPUMaterial **UNUSED(gpumat_array), uint gpumat_array_len)
+{
+ if (!BKE_mball_is_basis(ob)) {
+ return NULL;
+ }
+
+ MetaBallBatchCache *cache = metaball_batch_cache_get(mb);
+ if (cache->shaded_triangles == NULL) {
+ cache->mat_len = gpumat_array_len;
+ cache->shaded_triangles = MEM_callocN(sizeof(*cache->shaded_triangles) * cache->mat_len, __func__);
+ cache->shaded_triangles[0] = DRW_metaball_batch_cache_get_triangles_with_normals(ob);
+ for (int i = 1; i < cache->mat_len; ++i) {
+ cache->shaded_triangles[i] = NULL;
+ }
+ }
+ return cache->shaded_triangles;
+
+}
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index c89ea67a39c..380cb089628 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -42,6 +42,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_particle_types.h"
+#include "DNA_customdata_types.h"
#include "BKE_mesh.h"
#include "BKE_particle.h"
@@ -54,6 +55,7 @@
#include "DEG_depsgraph_query.h"
#include "draw_cache_impl.h" /* own include */
+#include "draw_hair_private.h"
static void particle_batch_cache_clear(ParticleSystem *psys);
@@ -67,14 +69,6 @@ typedef struct ParticlePointCache {
int point_count;
} ParticlePointCache;
-typedef struct ParticleHairCache {
- Gwn_VertBuf *pos;
- Gwn_IndexBuf *indices;
- Gwn_Batch *hairs;
- int elems_count;
- int point_count;
-} ParticleHairCache;
-
typedef struct ParticleBatchCache {
/* Object mode strands for hair and points for particle,
* strands for paths when in edit mode.
@@ -169,6 +163,30 @@ static void particle_batch_cache_clear_point(ParticlePointCache *point_cache)
static void particle_batch_cache_clear_hair(ParticleHairCache *hair_cache)
{
+ /* TODO more granular update tagging. */
+ GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_point_buf);
+ DRW_TEXTURE_FREE_SAFE(hair_cache->point_tex);
+
+ GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_strand_buf);
+ DRW_TEXTURE_FREE_SAFE(hair_cache->strand_tex);
+
+ for (int i = 0; i < MAX_MTFACE; ++i) {
+ GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_uv_buf[i]);
+ DRW_TEXTURE_FREE_SAFE(hair_cache->uv_tex[i]);
+ }
+ for (int i = 0; i < MAX_MCOL; ++i) {
+ GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_col_buf[i]);
+ DRW_TEXTURE_FREE_SAFE(hair_cache->col_tex[i]);
+ }
+ for (int i = 0; i < MAX_HAIR_SUBDIV; ++i) {
+ GWN_VERTBUF_DISCARD_SAFE(hair_cache->final[i].proc_buf);
+ DRW_TEXTURE_FREE_SAFE(hair_cache->final[i].proc_tex);
+ for (int j = 0; j < MAX_THICKRES; ++j) {
+ GWN_BATCH_DISCARD_SAFE(hair_cache->final[i].proc_hairs[j]);
+ }
+ }
+
+ /* "Normal" legacy hairs */
GWN_BATCH_DISCARD_SAFE(hair_cache->hairs);
GWN_VERTBUF_DISCARD_SAFE(hair_cache->pos);
GWN_INDEXBUF_DISCARD_SAFE(hair_cache->indices);
@@ -185,6 +203,7 @@ static void particle_batch_cache_clear(ParticleSystem *psys)
particle_batch_cache_clear_hair(&cache->hair);
particle_batch_cache_clear_hair(&cache->edit_hair);
+
GWN_BATCH_DISCARD_SAFE(cache->edit_inner_points);
GWN_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos);
GWN_BATCH_DISCARD_SAFE(cache->edit_tip_points);
@@ -197,27 +216,33 @@ void DRW_particle_batch_cache_free(ParticleSystem *psys)
MEM_SAFE_FREE(psys->batch_cache);
}
-static void count_cache_segment_keys(ParticleCacheKey **pathcache,
- const int num_path_cache_keys,
- ParticleHairCache *hair_cache)
+static void count_cache_segment_keys(
+ ParticleCacheKey **pathcache,
+ const int num_path_cache_keys,
+ ParticleHairCache *hair_cache)
{
for (int i = 0; i < num_path_cache_keys; i++) {
ParticleCacheKey *path = pathcache[i];
if (path->segments > 0) {
+ hair_cache->strands_count++;
hair_cache->elems_count += path->segments + 2;
hair_cache->point_count += path->segments + 1;
}
}
}
-static void ensure_seg_pt_count(PTCacheEdit *edit,
- ParticleSystem *psys,
- ParticleHairCache *hair_cache)
+static void ensure_seg_pt_count(
+ PTCacheEdit *edit,
+ ParticleSystem *psys,
+ ParticleHairCache *hair_cache)
{
- if (hair_cache->pos != NULL && hair_cache->indices != NULL) {
+ if ((hair_cache->pos != NULL && hair_cache->indices != NULL) ||
+ (hair_cache->proc_point_buf != NULL))
+ {
return;
}
+ hair_cache->strands_count = 0;
hair_cache->elems_count = 0;
hair_cache->point_count = 0;
@@ -237,13 +262,56 @@ static void ensure_seg_pt_count(PTCacheEdit *edit,
}
}
+static void particle_pack_mcol(MCol *mcol, unsigned short r_scol[3])
+{
+ /* Convert to linear ushort and swizzle */
+ r_scol[0] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mcol->b]);
+ r_scol[1] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mcol->g]);
+ r_scol[2] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mcol->r]);
+}
+
/* Used by parent particles and simple children. */
-static void particle_calculate_parent_uvs(ParticleSystem *psys,
- ParticleSystemModifierData *psmd,
- const int num_uv_layers,
- const int parent_index,
- /*const*/ MTFace **mtfaces,
- float (*r_uv)[2])
+static void particle_calculate_parent_uvs(
+ ParticleSystem *psys,
+ ParticleSystemModifierData *psmd,
+ const int num_uv_layers,
+ const int parent_index,
+ /*const*/ MTFace **mtfaces,
+ float (*r_uv)[2])
+{
+ if (psmd == NULL) {
+ return;
+ }
+ const int emit_from = psmd->psys->part->from;
+ if (!ELEM(emit_from, PART_FROM_FACE, PART_FROM_VOLUME)) {
+ return;
+ }
+ ParticleData *particle = &psys->particles[parent_index];
+ int num = particle->num_dmcache;
+ if (num == DMCACHE_NOTFOUND) {
+ if (particle->num < psmd->mesh_final->totface) {
+ num = particle->num;
+ }
+ }
+ if (num != DMCACHE_NOTFOUND) {
+ MFace *mface = &psmd->mesh_final->mface[num];
+ for (int j = 0; j < num_uv_layers; j++) {
+ psys_interpolate_uvs(
+ mtfaces[j] + num,
+ mface->v4,
+ particle->fuv,
+ r_uv[j]);
+ }
+ }
+}
+
+static void particle_calculate_parent_mcol(
+ ParticleSystem *psys,
+ ParticleSystemModifierData *psmd,
+ const int num_uv_layers,
+ const int parent_index,
+ /*const*/ MCol **mcols,
+ MCol *r_mcol)
{
if (psmd == NULL) {
return;
@@ -262,21 +330,23 @@ static void particle_calculate_parent_uvs(ParticleSystem *psys,
if (num != DMCACHE_NOTFOUND) {
MFace *mface = &psmd->mesh_final->mface[num];
for (int j = 0; j < num_uv_layers; j++) {
- psys_interpolate_uvs(mtfaces[j] + num,
- mface->v4,
- particle->fuv,
- r_uv[j]);
+ psys_interpolate_mcol(
+ mcols[j] + num,
+ mface->v4,
+ particle->fuv,
+ &r_mcol[j]);
}
}
}
/* Used by interpolated children. */
-static void particle_interpolate_children_uvs(ParticleSystem *psys,
- ParticleSystemModifierData *psmd,
- const int num_uv_layers,
- const int child_index,
- /*const*/ MTFace **mtfaces,
- float (*r_uv)[2])
+static void particle_interpolate_children_uvs(
+ ParticleSystem *psys,
+ ParticleSystemModifierData *psmd,
+ const int num_uv_layers,
+ const int child_index,
+ /*const*/ MTFace **mtfaces,
+ float (*r_uv)[2])
{
if (psmd == NULL) {
return;
@@ -291,20 +361,53 @@ static void particle_interpolate_children_uvs(ParticleSystem *psys,
MFace *mface = &psmd->mesh_final->mface[num];
for (int j = 0; j < num_uv_layers; j++) {
psys_interpolate_uvs(
- mtfaces[j] + num, mface->v4, particle->fuv, r_uv[j]);
+ mtfaces[j] + num,
+ mface->v4,
+ particle->fuv,
+ r_uv[j]);
+ }
+ }
+}
+
+static void particle_interpolate_children_mcol(
+ ParticleSystem *psys,
+ ParticleSystemModifierData *psmd,
+ const int num_col_layers,
+ const int child_index,
+ /*const*/ MCol **mcols,
+ MCol *r_mcol)
+{
+ if (psmd == NULL) {
+ return;
+ }
+ const int emit_from = psmd->psys->part->from;
+ if (!ELEM(emit_from, PART_FROM_FACE, PART_FROM_VOLUME)) {
+ return;
+ }
+ ChildParticle *particle = &psys->child[child_index];
+ int num = particle->num;
+ if (num != DMCACHE_NOTFOUND) {
+ MFace *mface = &psmd->mesh_final->mface[num];
+ for (int j = 0; j < num_col_layers; j++) {
+ psys_interpolate_mcol(
+ mcols[j] + num,
+ mface->v4,
+ particle->fuv,
+ &r_mcol[j]);
}
}
}
-static void particle_calculate_uvs(ParticleSystem *psys,
- ParticleSystemModifierData *psmd,
- const bool is_simple,
- const int num_uv_layers,
- const int parent_index,
- const int child_index,
- /*const*/ MTFace **mtfaces,
- float (**r_parent_uvs)[2],
- float (**r_uv)[2])
+static void particle_calculate_uvs(
+ ParticleSystem *psys,
+ ParticleSystemModifierData *psmd,
+ const bool is_simple,
+ const int num_uv_layers,
+ const int parent_index,
+ const int child_index,
+ /*const*/ MTFace **mtfaces,
+ float (**r_parent_uvs)[2],
+ float (**r_uv)[2])
{
if (psmd == NULL) {
return;
@@ -342,6 +445,53 @@ static void particle_calculate_uvs(ParticleSystem *psys,
}
}
+static void particle_calculate_mcol(
+ ParticleSystem *psys,
+ ParticleSystemModifierData *psmd,
+ const bool is_simple,
+ const int num_col_layers,
+ const int parent_index,
+ const int child_index,
+ /*const*/ MCol **mcols,
+ MCol **r_parent_mcol,
+ MCol **r_mcol)
+{
+ if (psmd == NULL) {
+ return;
+ }
+ if (is_simple) {
+ if (r_parent_mcol[parent_index] != NULL) {
+ *r_mcol = r_parent_mcol[parent_index];
+ }
+ else {
+ *r_mcol = MEM_callocN(sizeof(**r_mcol) * num_col_layers, "Particle MCol");
+ }
+ }
+ else {
+ *r_mcol = MEM_callocN(sizeof(**r_mcol) * num_col_layers, "Particle MCol");
+ }
+ if (child_index == -1) {
+ /* Calculate MCols for parent particles. */
+ if (is_simple) {
+ r_parent_mcol[parent_index] = *r_mcol;
+ }
+ particle_calculate_parent_mcol(
+ psys, psmd, num_col_layers, parent_index, mcols, *r_mcol);
+ }
+ else {
+ /* Calculate MCols for child particles. */
+ if (!is_simple) {
+ particle_interpolate_children_mcol(
+ psys, psmd, num_col_layers, child_index, mcols, *r_mcol);
+ }
+ else if (!r_parent_mcol[psys->child[child_index].parent]) {
+ r_parent_mcol[psys->child[child_index].parent] = *r_mcol;
+ particle_calculate_parent_mcol(
+ psys, psmd, num_col_layers, parent_index, mcols, *r_mcol);
+ }
+ }
+}
+
/* Will return last filled index. */
typedef enum ParticleSource {
PARTICLE_SOURCE_PARENT,
@@ -356,9 +506,13 @@ static int particle_batch_cache_fill_segments(
const int start_index,
const int num_path_keys,
const int num_uv_layers,
+ const int num_col_layers,
/*const*/ MTFace **mtfaces,
+ /*const*/ MCol **mcols,
uint *uv_id,
+ uint *col_id,
float (***r_parent_uvs)[2],
+ MCol ***r_parent_mcol,
Gwn_IndexBufBuilder *elb,
HairAttributeID *attr_id,
ParticleHairCache *hair_cache)
@@ -367,8 +521,14 @@ static int particle_batch_cache_fill_segments(
const bool is_child = (particle_source == PARTICLE_SOURCE_CHILDREN);
if (is_simple && *r_parent_uvs == NULL) {
/* TODO(sergey): For edit mode it should be edit->totcached. */
- *r_parent_uvs = MEM_callocN(sizeof(*r_parent_uvs) * psys->totpart,
- "Parent particle UVs");
+ *r_parent_uvs = MEM_callocN(
+ sizeof(*r_parent_uvs) * psys->totpart,
+ "Parent particle UVs");
+ }
+ if (is_simple && *r_parent_mcol == NULL) {
+ *r_parent_mcol = MEM_callocN(
+ sizeof(*r_parent_mcol) * psys->totpart,
+ "Parent particle MCol");
}
int curr_point = start_index;
for (int i = 0; i < num_path_keys; i++) {
@@ -378,6 +538,14 @@ static int particle_batch_cache_fill_segments(
}
float tangent[3];
float (*uv)[2] = NULL;
+ MCol *mcol = NULL;
+ particle_calculate_mcol(
+ psys, psmd,
+ is_simple, num_col_layers,
+ is_child ? psys->child[i].parent : i,
+ is_child ? i : -1,
+ mcols,
+ *r_parent_mcol, &mcol);
particle_calculate_uvs(
psys, psmd,
is_simple, num_uv_layers,
@@ -399,9 +567,17 @@ static int particle_batch_cache_fill_segments(
for (int k = 0; k < num_uv_layers; k++) {
GWN_vertbuf_attr_set(
hair_cache->pos, uv_id[k], curr_point,
- (is_simple && is_child)
- ? (*r_parent_uvs)[psys->child[i].parent][k]
- : uv[k]);
+ (is_simple && is_child) ?
+ (*r_parent_uvs)[psys->child[i].parent][k] : uv[k]);
+ }
+ for (int k = 0; k < num_col_layers; k++) {
+ /* TODO Put the conversion outside the loop */
+ unsigned short scol[4];
+ particle_pack_mcol(
+ (is_simple && is_child) ?
+ &(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k],
+ scol);
+ GWN_vertbuf_attr_set(hair_cache->pos, col_id[k], curr_point, scol);
}
}
GWN_indexbuf_add_generic_vert(elb, curr_point);
@@ -419,11 +595,20 @@ static int particle_batch_cache_fill_segments(
GWN_vertbuf_attr_set(
hair_cache->pos, uv_id[k], curr_point,
(is_simple && is_child) ?
- (*r_parent_uvs)[psys->child[i].parent][k] :
- uv[k]);
+ (*r_parent_uvs)[psys->child[i].parent][k] : uv[k]);
+ }
+ for (int k = 0; k < num_col_layers; k++) {
+ /* TODO Put the conversion outside the loop */
+ unsigned short scol[4];
+ particle_pack_mcol(
+ (is_simple && is_child) ?
+ &(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k],
+ scol);
+ GWN_vertbuf_attr_set(hair_cache->pos, col_id[k], curr_point, scol);
}
if (!is_simple) {
MEM_freeN(uv);
+ MEM_freeN(mcol);
}
}
/* Finish the segment and add restart primitive. */
@@ -434,10 +619,423 @@ static int particle_batch_cache_fill_segments(
return curr_point;
}
-static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
- ParticleSystem *psys,
- ModifierData *md,
- ParticleHairCache *hair_cache)
+static void particle_batch_cache_fill_segments_proc_pos(
+ ParticleCacheKey **path_cache,
+ const int num_path_keys,
+ Gwn_VertBufRaw *attr_step)
+{
+ for (int i = 0; i < num_path_keys; i++) {
+ ParticleCacheKey *path = path_cache[i];
+ if (path->segments <= 0) {
+ continue;
+ }
+ float total_len = 0.0f;
+ float *co_prev = NULL, *seg_data_first;
+ for (int j = 0; j <= path->segments; j++) {
+ float *seg_data = (float *)GWN_vertbuf_raw_step(attr_step);
+ copy_v3_v3(seg_data, path[j].co);
+ if (co_prev) {
+ total_len += len_v3v3(co_prev, path[j].co);
+ }
+ else {
+ seg_data_first = seg_data;
+ }
+ seg_data[3] = total_len;
+ co_prev = path[j].co;
+ }
+ if (total_len > 0.0f) {
+ /* Divide by total length to have a [0-1] number. */
+ for (int j = 0; j <= path->segments; j++, seg_data_first += 4) {
+ seg_data_first[3] /= total_len;
+ }
+ }
+ }
+}
+
+static int particle_batch_cache_fill_segments_indices(
+ ParticleCacheKey **path_cache,
+ const int start_index,
+ const int num_path_keys,
+ const int res,
+ Gwn_IndexBufBuilder *elb)
+{
+ int curr_point = start_index;
+ for (int i = 0; i < num_path_keys; i++) {
+ ParticleCacheKey *path = path_cache[i];
+ if (path->segments <= 0) {
+ continue;
+ }
+ for (int k = 0; k < res; k++) {
+ GWN_indexbuf_add_generic_vert(elb, curr_point++);
+ }
+ GWN_indexbuf_add_primitive_restart(elb);
+ }
+ return curr_point;
+}
+
+static int particle_batch_cache_fill_strands_data(
+ ParticleSystem *psys,
+ ParticleSystemModifierData *psmd,
+ ParticleCacheKey **path_cache,
+ const ParticleSource particle_source,
+ const int start_index,
+ const int num_path_keys,
+ Gwn_VertBufRaw *data_step,
+ float (***r_parent_uvs)[2], Gwn_VertBufRaw *uv_step, MTFace **mtfaces, int num_uv_layers,
+ MCol ***r_parent_mcol, Gwn_VertBufRaw *col_step, MCol **mcols, int num_col_layers)
+{
+ const bool is_simple = (psys->part->childtype == PART_CHILD_PARTICLES);
+ const bool is_child = (particle_source == PARTICLE_SOURCE_CHILDREN);
+ if (is_simple && *r_parent_uvs == NULL) {
+ /* TODO(sergey): For edit mode it should be edit->totcached. */
+ *r_parent_uvs = MEM_callocN(
+ sizeof(*r_parent_uvs) * psys->totpart,
+ "Parent particle UVs");
+ }
+ if (is_simple && *r_parent_mcol == NULL) {
+ *r_parent_mcol = MEM_callocN(
+ sizeof(*r_parent_mcol) * psys->totpart,
+ "Parent particle MCol");
+ }
+ int curr_point = start_index;
+ for (int i = 0; i < num_path_keys; i++) {
+ ParticleCacheKey *path = path_cache[i];
+ if (path->segments <= 0) {
+ continue;
+ }
+
+ uint *seg_data = (uint *)GWN_vertbuf_raw_step(data_step);
+ *seg_data = (curr_point & 0xFFFFFF) | (path->segments << 24);
+ curr_point += path->segments + 1;
+
+ if (psmd != NULL) {
+ float (*uv)[2] = NULL;
+ MCol *mcol = NULL;
+
+ particle_calculate_uvs(
+ psys, psmd,
+ is_simple, num_uv_layers,
+ is_child ? psys->child[i].parent : i,
+ is_child ? i : -1,
+ mtfaces,
+ *r_parent_uvs, &uv);
+
+ particle_calculate_mcol(
+ psys, psmd,
+ is_simple, num_col_layers,
+ is_child ? psys->child[i].parent : i,
+ is_child ? i : -1,
+ mcols,
+ *r_parent_mcol, &mcol);
+
+ for (int k = 0; k < num_uv_layers; k++) {
+ float *t_uv = (float *)GWN_vertbuf_raw_step(uv_step + k);
+ copy_v2_v2(t_uv, uv[k]);
+ }
+ for (int k = 0; k < num_col_layers; k++) {
+ unsigned short *scol = (unsigned short *)GWN_vertbuf_raw_step(col_step + k);
+ particle_pack_mcol(
+ (is_simple && is_child) ?
+ &(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k],
+ scol);
+ }
+ if (!is_simple) {
+ MEM_freeN(uv);
+ MEM_freeN(mcol);
+ }
+ }
+ }
+ return curr_point;
+}
+
+static void particle_batch_cache_ensure_procedural_final_points(
+ ParticleHairCache *cache,
+ int subdiv)
+{
+ /* Same format as point_tex. */
+ Gwn_VertFormat format = { 0 };
+ GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+
+ cache->final[subdiv].proc_buf = GWN_vertbuf_create_with_format(&format);
+
+ /* Create a destination buffer for the tranform feedback. Sized appropriately */
+ /* Thoses are points! not line segments. */
+ GWN_vertbuf_data_alloc(cache->final[subdiv].proc_buf, cache->final[subdiv].strands_res * cache->strands_count);
+
+ /* Create vbo immediatly to bind to texture buffer. */
+ GWN_vertbuf_use(cache->final[subdiv].proc_buf);
+
+ cache->final[subdiv].proc_tex = GPU_texture_create_from_vertbuf(cache->final[subdiv].proc_buf);
+}
+
+static void particle_batch_cache_ensure_procedural_strand_data(
+ PTCacheEdit *edit,
+ ParticleSystem *psys,
+ ModifierData *md,
+ ParticleHairCache *cache)
+{
+ int active_uv = 0;
+ int active_col = 0;
+
+ ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
+
+ if (psmd != NULL && psmd->mesh_final != NULL) {
+ if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_MLOOPUV)) {
+ cache->num_uv_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, CD_MLOOPUV);
+ active_uv = CustomData_get_active_layer(&psmd->mesh_final->ldata, CD_MLOOPUV);
+ }
+ if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_MLOOPCOL)) {
+ cache->num_col_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, CD_MLOOPCOL);
+ active_col = CustomData_get_active_layer(&psmd->mesh_final->ldata, CD_MLOOPCOL);
+ }
+ }
+
+ Gwn_VertBufRaw data_step;
+ Gwn_VertBufRaw uv_step[MAX_MTFACE];
+ Gwn_VertBufRaw col_step[MAX_MCOL];
+
+ MTFace *mtfaces[MAX_MTFACE] = {NULL};
+ MCol *mcols[MAX_MCOL] = {NULL};
+ float (**parent_uvs)[2] = NULL;
+ MCol **parent_mcol = NULL;
+
+ Gwn_VertFormat format_data = {0};
+ uint data_id = GWN_vertformat_attr_add(&format_data, "data", GWN_COMP_U32, 1, GWN_FETCH_INT);
+
+ Gwn_VertFormat format_uv = {0};
+ uint uv_id = GWN_vertformat_attr_add(&format_uv, "uv", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+
+ Gwn_VertFormat format_col = {0};
+ uint col_id = GWN_vertformat_attr_add(&format_col, "col", GWN_COMP_U16, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+
+ memset(cache->uv_layer_names, 0, sizeof(cache->uv_layer_names));
+ memset(cache->col_layer_names, 0, sizeof(cache->col_layer_names));
+
+ /* Strand Data */
+ cache->proc_strand_buf = GWN_vertbuf_create_with_format(&format_data);
+ GWN_vertbuf_data_alloc(cache->proc_strand_buf, cache->strands_count);
+ GWN_vertbuf_attr_get_raw_data(cache->proc_strand_buf, data_id, &data_step);
+
+ /* UV layers */
+ for (int i = 0; i < cache->num_uv_layers; i++) {
+ cache->proc_uv_buf[i] = GWN_vertbuf_create_with_format(&format_uv);
+ GWN_vertbuf_data_alloc(cache->proc_uv_buf[i], cache->strands_count);
+ GWN_vertbuf_attr_get_raw_data(cache->proc_uv_buf[i], uv_id, &uv_step[i]);
+
+ const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i);
+ uint hash = BLI_ghashutil_strhash_p(name);
+ int n = 0;
+ BLI_snprintf(cache->uv_layer_names[i][n++], MAX_LAYER_NAME_LEN, "u%u", hash);
+ BLI_snprintf(cache->uv_layer_names[i][n++], MAX_LAYER_NAME_LEN, "a%u", hash);
+
+ if (i == active_uv) {
+ BLI_snprintf(cache->uv_layer_names[i][n], MAX_LAYER_NAME_LEN, "u");
+ }
+ }
+ /* Vertex colors */
+ for (int i = 0; i < cache->num_col_layers; i++) {
+ cache->proc_col_buf[i] = GWN_vertbuf_create_with_format(&format_col);
+ GWN_vertbuf_data_alloc(cache->proc_col_buf[i], cache->strands_count);
+ GWN_vertbuf_attr_get_raw_data(cache->proc_col_buf[i], col_id, &col_step[i]);
+
+ const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i);
+ uint hash = BLI_ghashutil_strhash_p(name);
+ int n = 0;
+ BLI_snprintf(cache->col_layer_names[i][n++], MAX_LAYER_NAME_LEN, "c%u", hash);
+
+ /* We only do vcols auto name that are not overridden by uvs */
+ if (CustomData_get_named_layer_index(&psmd->mesh_final->ldata, CD_MLOOPUV, name) == -1) {
+ BLI_snprintf(cache->col_layer_names[i][n++], MAX_LAYER_NAME_LEN, "a%u", hash);
+ }
+
+ if (i == active_col) {
+ BLI_snprintf(cache->col_layer_names[i][n], MAX_LAYER_NAME_LEN, "c");
+ }
+ }
+
+ if (cache->num_uv_layers || cache->num_col_layers) {
+ BKE_mesh_tessface_ensure(psmd->mesh_final);
+ if (cache->num_uv_layers) {
+ for (int j = 0; j < cache->num_uv_layers; j++) {
+ mtfaces[j] = (MTFace *)CustomData_get_layer_n(&psmd->mesh_final->fdata, CD_MTFACE, j);
+ }
+ }
+ if (cache->num_col_layers) {
+ for (int j = 0; j < cache->num_col_layers; j++) {
+ mcols[j] = (MCol *)CustomData_get_layer_n(&psmd->mesh_final->fdata, CD_MCOL, j);
+ }
+ }
+ }
+
+ if (edit != NULL && edit->pathcache != NULL) {
+ particle_batch_cache_fill_strands_data(
+ psys, psmd, edit->pathcache, PARTICLE_SOURCE_PARENT,
+ 0, edit->totcached,
+ &data_step,
+ &parent_uvs, uv_step, (MTFace **)mtfaces, cache->num_uv_layers,
+ &parent_mcol, col_step, (MCol **)mcols, cache->num_col_layers);
+ }
+ else {
+ int curr_point = 0;
+ if ((psys->pathcache != NULL) &&
+ (!psys->childcache || (psys->part->draw & PART_DRAW_PARENT)))
+ {
+ curr_point = particle_batch_cache_fill_strands_data(
+ psys, psmd, psys->pathcache, PARTICLE_SOURCE_PARENT,
+ 0, psys->totpart,
+ &data_step,
+ &parent_uvs, uv_step, (MTFace **)mtfaces, cache->num_uv_layers,
+ &parent_mcol, col_step, (MCol **)mcols, cache->num_col_layers);
+ }
+ if (psys->childcache) {
+ const int child_count = psys->totchild * psys->part->disp / 100;
+ curr_point = particle_batch_cache_fill_strands_data(
+ psys, psmd, psys->childcache, PARTICLE_SOURCE_CHILDREN,
+ curr_point, child_count,
+ &data_step,
+ &parent_uvs, uv_step, (MTFace **)mtfaces, cache->num_uv_layers,
+ &parent_mcol, col_step, (MCol **)mcols, cache->num_col_layers);
+ }
+ }
+ /* Cleanup. */
+ if (parent_uvs != NULL) {
+ /* TODO(sergey): For edit mode it should be edit->totcached. */
+ for (int i = 0; i < psys->totpart; i++) {
+ MEM_SAFE_FREE(parent_uvs[i]);
+ }
+ MEM_freeN(parent_uvs);
+ }
+ if (parent_mcol != NULL) {
+ for (int i = 0; i < psys->totpart; i++) {
+ MEM_SAFE_FREE(parent_mcol[i]);
+ }
+ MEM_freeN(parent_mcol);
+ }
+
+ /* Create vbo immediatly to bind to texture buffer. */
+ GWN_vertbuf_use(cache->proc_strand_buf);
+ cache->strand_tex = GPU_texture_create_from_vertbuf(cache->proc_strand_buf);
+
+ for (int i = 0; i < cache->num_uv_layers; i++) {
+ GWN_vertbuf_use(cache->proc_uv_buf[i]);
+ cache->uv_tex[i] = GPU_texture_create_from_vertbuf(cache->proc_uv_buf[i]);
+ }
+ for (int i = 0; i < cache->num_col_layers; i++) {
+ GWN_vertbuf_use(cache->proc_col_buf[i]);
+ cache->col_tex[i] = GPU_texture_create_from_vertbuf(cache->proc_col_buf[i]);
+ }
+}
+
+static void particle_batch_cache_ensure_procedural_indices(
+ PTCacheEdit *edit,
+ ParticleSystem *psys,
+ ParticleHairCache *cache,
+ int thickness_res,
+ int subdiv)
+{
+ BLI_assert(thickness_res <= MAX_THICKRES); /* Cylinder strip not currently supported. */
+
+ if (cache->final[subdiv].proc_hairs[thickness_res - 1] != NULL) {
+ return;
+ }
+
+ int verts_per_hair = cache->final[subdiv].strands_res * thickness_res;
+ /* +1 for primitive restart */
+ int element_count = (verts_per_hair + 1) * cache->strands_count;
+ Gwn_PrimType prim_type = (thickness_res == 1) ? GWN_PRIM_LINE_STRIP : GWN_PRIM_TRI_STRIP;
+
+ static Gwn_VertFormat format = { 0 };
+ GWN_vertformat_clear(&format);
+
+ /* initialize vertex format */
+ GWN_vertformat_attr_add(&format, "dummy", GWN_COMP_U8, 1, GWN_FETCH_INT_TO_FLOAT_UNIT);
+
+ Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
+ GWN_vertbuf_data_alloc(vbo, 1);
+
+ Gwn_IndexBufBuilder elb;
+ GWN_indexbuf_init_ex(&elb, prim_type, element_count, element_count, true);
+
+ if (edit != NULL && edit->pathcache != NULL) {
+ particle_batch_cache_fill_segments_indices(
+ edit->pathcache, 0, edit->totcached, verts_per_hair, &elb);
+ }
+ else {
+ int curr_point = 0;
+ if ((psys->pathcache != NULL) &&
+ (!psys->childcache || (psys->part->draw & PART_DRAW_PARENT)))
+ {
+ curr_point = particle_batch_cache_fill_segments_indices(
+ psys->pathcache, 0, psys->totpart, verts_per_hair, &elb);
+ }
+ if (psys->childcache) {
+ const int child_count = psys->totchild * psys->part->disp / 100;
+ curr_point = particle_batch_cache_fill_segments_indices(
+ psys->childcache, curr_point, child_count, verts_per_hair, &elb);
+ }
+ }
+
+ cache->final[subdiv].proc_hairs[thickness_res - 1] = GWN_batch_create_ex(
+ prim_type,
+ vbo,
+ GWN_indexbuf_build(&elb),
+ GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
+}
+
+static void particle_batch_cache_ensure_procedural_pos(
+ PTCacheEdit *edit,
+ ParticleSystem *psys,
+ ParticleHairCache *cache)
+{
+ if (cache->proc_point_buf != NULL) {
+ return;
+ }
+
+ /* initialize vertex format */
+ Gwn_VertFormat format = {0};
+ uint pos_id = GWN_vertformat_attr_add(&format, "posTime", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+
+ cache->proc_point_buf = GWN_vertbuf_create_with_format(&format);
+ GWN_vertbuf_data_alloc(cache->proc_point_buf, cache->point_count);
+
+ Gwn_VertBufRaw pos_step;
+ GWN_vertbuf_attr_get_raw_data(cache->proc_point_buf, pos_id, &pos_step);
+
+ if (edit != NULL && edit->pathcache != NULL) {
+ particle_batch_cache_fill_segments_proc_pos(
+ edit->pathcache,
+ edit->totcached,
+ &pos_step);
+ }
+ else {
+ if ((psys->pathcache != NULL) &&
+ (!psys->childcache || (psys->part->draw & PART_DRAW_PARENT)))
+ {
+ particle_batch_cache_fill_segments_proc_pos(
+ psys->pathcache,
+ psys->totpart,
+ &pos_step);
+ }
+ if (psys->childcache) {
+ const int child_count = psys->totchild * psys->part->disp / 100;
+ particle_batch_cache_fill_segments_proc_pos(
+ psys->childcache,
+ child_count,
+ &pos_step);
+ }
+ }
+
+ /* Create vbo immediatly to bind to texture buffer. */
+ GWN_vertbuf_use(cache->proc_point_buf);
+
+ cache->point_tex = GPU_texture_create_from_vertbuf(cache->proc_point_buf);
+}
+
+static void particle_batch_cache_ensure_pos_and_seg(
+ PTCacheEdit *edit,
+ ParticleSystem *psys,
+ ModifierData *md,
+ ParticleHairCache *hair_cache)
{
if (hair_cache->pos != NULL && hair_cache->indices != NULL) {
return;
@@ -450,15 +1048,26 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
GWN_INDEXBUF_DISCARD_SAFE(hair_cache->indices);
static Gwn_VertFormat format = { 0 };
- static HairAttributeID attr_id;
+ HairAttributeID attr_id;
uint *uv_id = NULL;
+ uint *col_id = NULL;
int num_uv_layers = 0;
+ int num_col_layers = 0;
+ int active_uv = 0;
+ int active_col = 0;
MTFace **mtfaces = NULL;
+ MCol **mcols = NULL;
float (**parent_uvs)[2] = NULL;
+ MCol **parent_mcol = NULL;
if (psmd != NULL) {
if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_MLOOPUV)) {
num_uv_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, CD_MLOOPUV);
+ active_uv = CustomData_get_active_layer(&psmd->mesh_final->ldata, CD_MLOOPUV);
+ }
+ if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_MLOOPCOL)) {
+ num_col_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, CD_MLOOPCOL);
+ active_col = CustomData_get_active_layer(&psmd->mesh_final->ldata, CD_MLOOPCOL);
}
}
@@ -471,6 +1080,7 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
if (psmd) {
uv_id = MEM_mallocN(sizeof(*uv_id) * num_uv_layers, "UV attrib format");
+ col_id = MEM_mallocN(sizeof(*col_id) * num_col_layers, "Col attrib format");
for (int i = 0; i < num_uv_layers; i++) {
const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i);
@@ -478,6 +1088,22 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
BLI_snprintf(uuid, sizeof(uuid), "u%u", BLI_ghashutil_strhash_p(name));
uv_id[i] = GWN_vertformat_attr_add(&format, uuid, GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+
+ if (i == active_uv) {
+ GWN_vertformat_alias_add(&format, "u");
+ }
+ }
+
+ for (int i = 0; i < num_uv_layers; i++) {
+ const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i);
+ char uuid[32];
+
+ BLI_snprintf(uuid, sizeof(uuid), "c%u", BLI_ghashutil_strhash_p(name));
+ col_id[i] = GWN_vertformat_attr_add(&format, uuid, GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+
+ if (i == active_col) {
+ GWN_vertformat_alias_add(&format, "c");
+ }
}
}
@@ -485,16 +1111,25 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
GWN_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_count);
Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init_ex(&elb,
- GWN_PRIM_LINE_STRIP,
- hair_cache->elems_count, hair_cache->point_count,
- true);
+ GWN_indexbuf_init_ex(
+ &elb,
+ GWN_PRIM_LINE_STRIP,
+ hair_cache->elems_count, hair_cache->point_count,
+ true);
- if (num_uv_layers) {
+ if (num_uv_layers || num_col_layers) {
BKE_mesh_tessface_ensure(psmd->mesh_final);
- mtfaces = MEM_mallocN(sizeof(*mtfaces) * num_uv_layers, "Faces UV layers");
- for (int i = 0; i < num_uv_layers; i++) {
- mtfaces[i] = (MTFace *)CustomData_get_layer_n(&psmd->mesh_final->fdata, CD_MTFACE, i);
+ if (num_uv_layers) {
+ mtfaces = MEM_mallocN(sizeof(*mtfaces) * num_uv_layers, "Faces UV layers");
+ for (int i = 0; i < num_uv_layers; i++) {
+ mtfaces[i] = (MTFace *)CustomData_get_layer_n(&psmd->mesh_final->fdata, CD_MTFACE, i);
+ }
+ }
+ if (num_col_layers) {
+ mcols = MEM_mallocN(sizeof(*mcols) * num_col_layers, "Color layers");
+ for (int i = 0; i < num_col_layers; i++) {
+ mcols[i] = (MCol *)CustomData_get_layer_n(&psmd->mesh_final->fdata, CD_MCOL, i);
+ }
}
}
@@ -502,7 +1137,7 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
curr_point = particle_batch_cache_fill_segments(
psys, psmd, edit->pathcache, PARTICLE_SOURCE_PARENT,
0, 0, edit->totcached,
- num_uv_layers, mtfaces, uv_id, &parent_uvs,
+ num_uv_layers, num_col_layers, mtfaces, mcols, uv_id, col_id, &parent_uvs, &parent_mcol,
&elb, &attr_id, hair_cache);
}
else {
@@ -512,7 +1147,7 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
curr_point = particle_batch_cache_fill_segments(
psys, psmd, psys->pathcache, PARTICLE_SOURCE_PARENT,
0, 0, psys->totpart,
- num_uv_layers, mtfaces, uv_id, &parent_uvs,
+ num_uv_layers, num_col_layers, mtfaces, mcols, uv_id, col_id, &parent_uvs, &parent_mcol,
&elb, &attr_id, hair_cache);
}
if (psys->childcache != NULL) {
@@ -520,7 +1155,7 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
curr_point = particle_batch_cache_fill_segments(
psys, psmd, psys->childcache, PARTICLE_SOURCE_CHILDREN,
psys->totpart, curr_point, child_count,
- num_uv_layers, mtfaces, uv_id, &parent_uvs,
+ num_uv_layers, num_col_layers, mtfaces, mcols, uv_id, col_id, &parent_uvs, &parent_mcol,
&elb, &attr_id, hair_cache);
}
}
@@ -532,18 +1167,28 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
}
MEM_freeN(parent_uvs);
}
+ if (parent_mcol != NULL) {
+ for (int i = 0; i < psys->totpart; i++) {
+ MEM_SAFE_FREE(parent_mcol[i]);
+ }
+ MEM_freeN(parent_mcol);
+ }
if (num_uv_layers) {
MEM_freeN(mtfaces);
}
+ if (num_col_layers) {
+ MEM_freeN(mcols);
+ }
if (psmd != NULL) {
MEM_freeN(uv_id);
}
hair_cache->indices = GWN_indexbuf_build(&elb);
}
-static void particle_batch_cache_ensure_pos(Object *object,
- ParticleSystem *psys,
- ParticlePointCache *point_cache)
+static void particle_batch_cache_ensure_pos(
+ Object *object,
+ ParticleSystem *psys,
+ ParticlePointCache *point_cache)
{
if (point_cache->pos != NULL) {
return;
@@ -575,7 +1220,7 @@ static void particle_batch_cache_ensure_pos(Object *object,
if (format.attrib_ct == 0) {
/* initialize vertex format */
- pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
rot_id = GWN_vertformat_attr_add(&format, "rot", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
val_id = GWN_vertformat_attr_add(&format, "val", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
}
@@ -618,9 +1263,10 @@ static void particle_batch_cache_ensure_pos(Object *object,
}
}
-static void drw_particle_update_ptcache_edit(Object *object_eval,
- ParticleSystem *psys,
- PTCacheEdit *edit)
+static void drw_particle_update_ptcache_edit(
+ Object *object_eval,
+ ParticleSystem *psys,
+ PTCacheEdit *edit)
{
if (edit->psys == NULL) {
return;
@@ -637,16 +1283,18 @@ static void drw_particle_update_ptcache_edit(Object *object_eval,
}
if (edit->pathcache == NULL) {
Depsgraph *depsgraph = draw_ctx->depsgraph;
- psys_cache_edit_paths(depsgraph,
- scene_orig, object_orig,
- edit,
- DEG_get_ctime(depsgraph),
- DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
+ psys_cache_edit_paths(
+ depsgraph,
+ scene_orig, object_orig,
+ edit,
+ DEG_get_ctime(depsgraph),
+ DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
}
}
-static void drw_particle_update_ptcache(Object *object_eval,
- ParticleSystem *psys)
+static void drw_particle_update_ptcache(
+ Object *object_eval,
+ ParticleSystem *psys)
{
if ((object_eval->mode & OB_MODE_PARTICLE_EDIT) == 0) {
return;
@@ -672,11 +1320,11 @@ Gwn_Batch *DRW_particles_batch_cache_get_hair(
drw_particle_update_ptcache(object, psys);
ensure_seg_pt_count(NULL, psys, &cache->hair);
particle_batch_cache_ensure_pos_and_seg(NULL, psys, md, &cache->hair);
- cache->hair.hairs = GWN_batch_create(GWN_PRIM_LINE_STRIP,
- cache->hair.pos,
- cache->hair.indices);
+ cache->hair.hairs = GWN_batch_create(
+ GWN_PRIM_LINE_STRIP,
+ cache->hair.pos,
+ cache->hair.indices);
}
-
return cache->hair.hairs;
}
@@ -704,14 +1352,16 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_strands(
drw_particle_update_ptcache_edit(object, psys, edit);
ensure_seg_pt_count(edit, psys, &cache->edit_hair);
particle_batch_cache_ensure_pos_and_seg(edit, psys, NULL, &cache->edit_hair);
- cache->edit_hair.hairs = GWN_batch_create(GWN_PRIM_LINE_STRIP,
- cache->edit_hair.pos,
- cache->edit_hair.indices);
+ cache->edit_hair.hairs = GWN_batch_create(
+ GWN_PRIM_LINE_STRIP,
+ cache->edit_hair.pos,
+ cache->edit_hair.indices);
return cache->edit_hair.hairs;
}
-static void ensure_edit_inner_points_count(const PTCacheEdit *edit,
- ParticleBatchCache *cache)
+static void ensure_edit_inner_points_count(
+ const PTCacheEdit *edit,
+ ParticleBatchCache *cache)
{
if (cache->edit_inner_pos != NULL) {
return;
@@ -724,9 +1374,10 @@ static void ensure_edit_inner_points_count(const PTCacheEdit *edit,
}
}
-static void edit_colors_get(PTCacheEdit *edit,
- float selected_color[4],
- float normal_color[4])
+static void edit_colors_get(
+ PTCacheEdit *edit,
+ float selected_color[4],
+ float normal_color[4])
{
rgb_uchar_to_float(selected_color, edit->sel_col);
rgb_uchar_to_float(normal_color, edit->nosel_col);
@@ -788,14 +1439,16 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points(
drw_particle_update_ptcache_edit(object, psys, edit);
ensure_edit_inner_points_count(edit, cache);
particle_batch_cache_ensure_edit_inner_pos(edit, cache);
- cache->edit_inner_points = GWN_batch_create(GWN_PRIM_POINTS,
- cache->edit_inner_pos,
- NULL);
+ cache->edit_inner_points = GWN_batch_create(
+ GWN_PRIM_POINTS,
+ cache->edit_inner_pos,
+ NULL);
return cache->edit_inner_points;
}
-static void ensure_edit_tip_points_count(const PTCacheEdit *edit,
- ParticleBatchCache *cache)
+static void ensure_edit_tip_points_count(
+ const PTCacheEdit *edit,
+ ParticleBatchCache *cache)
{
if (cache->edit_tip_pos != NULL) {
return;
@@ -853,8 +1506,51 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points(
drw_particle_update_ptcache_edit(object, psys, edit);
ensure_edit_tip_points_count(edit, cache);
particle_batch_cache_ensure_edit_tip_pos(edit, cache);
- cache->edit_tip_points = GWN_batch_create(GWN_PRIM_POINTS,
- cache->edit_tip_pos,
- NULL);
+ cache->edit_tip_points = GWN_batch_create(
+ GWN_PRIM_POINTS,
+ cache->edit_tip_pos,
+ NULL);
return cache->edit_tip_points;
}
+
+/* Ensure all textures and buffers needed for GPU accelerated drawing. */
+bool particles_ensure_procedural_data(
+ Object *UNUSED(object),
+ ParticleSystem *psys,
+ ModifierData *md,
+ ParticleHairCache **r_hair_cache,
+ int subdiv,
+ int thickness_res)
+{
+ bool need_ft_update = false;
+
+ ParticleSettings *part = psys->part;
+ ParticleBatchCache *cache = particle_batch_cache_get(psys);
+ *r_hair_cache = &cache->hair;
+
+ (*r_hair_cache)->final[subdiv].strands_res = 1 << (part->draw_step + subdiv);
+
+ /* Refreshed on combing and simulation. */
+ if ((*r_hair_cache)->proc_point_buf == NULL) {
+ ensure_seg_pt_count(NULL, psys, &cache->hair);
+ particle_batch_cache_ensure_procedural_pos(NULL, psys, &cache->hair);
+ need_ft_update = true;
+ }
+
+ /* Refreshed if active layer or custom data changes. */
+ if ((*r_hair_cache)->strand_tex == NULL) {
+ particle_batch_cache_ensure_procedural_strand_data(NULL, psys, md, &cache->hair);
+ }
+
+ /* Refreshed only on subdiv count change. */
+ if ((*r_hair_cache)->final[subdiv].proc_buf == NULL) {
+ particle_batch_cache_ensure_procedural_final_points(&cache->hair, subdiv);
+ need_ft_update = true;
+ }
+ if ((*r_hair_cache)->final[subdiv].proc_hairs[thickness_res - 1] == NULL) {
+ particle_batch_cache_ensure_procedural_indices(NULL, psys, &cache->hair, thickness_res, subdiv);
+ }
+
+
+ return need_ft_update;
+}
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c
index 11e04306143..fb8833f40c3 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -92,6 +92,10 @@ void DRW_globals_update(void)
UI_GetThemeColor4fv(TH_NURB_SEL_ULINE, ts.colorNurbSelUline);
UI_GetThemeColor4fv(TH_ACTIVE_SPLINE, ts.colorActiveSpline);
+ UI_GetThemeColor4fv(TH_BONE_POSE, ts.colorBonePose);
+
+ UI_GetThemeColor4fv(TH_CFRAME, ts.colorCurrentFrame);
+
/* Grid */
UI_GetThemeColorShade4fv(TH_GRID, 10, ts.colorGrid);
/* emphasise division lines lighter instead of darker, if background is darker than grid */
@@ -153,6 +157,10 @@ void DRW_globals_update(void)
/* ********************************* SHGROUP ************************************* */
+extern char datatoc_animviz_mpath_lines_vert_glsl[];
+extern char datatoc_animviz_mpath_lines_geom_glsl[];
+extern char datatoc_animviz_mpath_points_vert_glsl[];
+
extern char datatoc_armature_axes_vert_glsl[];
extern char datatoc_armature_sphere_solid_vert_glsl[];
extern char datatoc_armature_sphere_solid_frag_glsl[];
@@ -167,7 +175,12 @@ extern char datatoc_armature_shape_outline_vert_glsl[];
extern char datatoc_armature_shape_outline_geom_glsl[];
extern char datatoc_armature_stick_vert_glsl[];
extern char datatoc_armature_stick_frag_glsl[];
+
+extern char datatoc_common_globals_lib_glsl[];
+
extern char datatoc_gpu_shader_flat_color_frag_glsl[];
+extern char datatoc_gpu_shader_3D_smooth_color_frag_glsl[];
+extern char datatoc_gpu_shader_point_varying_color_frag_glsl[];
extern char datatoc_object_mball_handles_vert_glsl[];
@@ -182,6 +195,9 @@ static struct {
struct GPUShader *bone_sphere_outline;
struct GPUShader *bone_stick;
+ struct GPUShader *mpath_line_sh;
+ struct GPUShader *mpath_points_sh;
+
struct GPUShader *mball_handles;
} g_shaders = {NULL};
@@ -692,6 +708,33 @@ DRWShadingGroup *shgroup_instance_bone_stick(DRWPass *pass)
return grp;
}
+struct GPUShader *mpath_line_shader_get(void)
+{
+ if (g_shaders.mpath_line_sh == NULL) {
+ g_shaders.mpath_line_sh = DRW_shader_create_with_lib(
+ datatoc_animviz_mpath_lines_vert_glsl,
+ datatoc_animviz_mpath_lines_geom_glsl,
+ datatoc_gpu_shader_3D_smooth_color_frag_glsl,
+ datatoc_common_globals_lib_glsl,
+ NULL);
+ }
+ return g_shaders.mpath_line_sh;
+}
+
+
+struct GPUShader *mpath_points_shader_get(void)
+{
+ if (g_shaders.mpath_points_sh == NULL) {
+ g_shaders.mpath_points_sh = DRW_shader_create_with_lib(
+ datatoc_animviz_mpath_points_vert_glsl,
+ NULL,
+ datatoc_gpu_shader_point_varying_color_frag_glsl,
+ datatoc_common_globals_lib_glsl,
+ NULL);
+ }
+ return g_shaders.mpath_points_sh;
+}
+
/* ******************************************** COLOR UTILS *********************************************** */
/* TODO FINISH */
diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h
index 11cff02d6c9..6227130fb05 100644
--- a/source/blender/draw/intern/draw_common.h
+++ b/source/blender/draw/intern/draw_common.h
@@ -29,8 +29,12 @@
struct DRWPass;
struct DRWShadingGroup;
struct Gwn_Batch;
+struct GPUMaterial;
struct Object;
struct ViewLayer;
+struct ModifierData;
+struct ParticleSystem;
+struct PTCacheEdit;
/* Used as ubo but colors can be directly referenced as well */
/* Keep in sync with: common_globals_lib.glsl (globalsBlock) */
@@ -83,6 +87,10 @@ typedef struct GlobalsUboStorage {
float colorNurbSelUline[4];
float colorActiveSpline[4];
+ float colorBonePose[4];
+
+ float colorCurrentFrame[4];
+
float colorGrid[4];
float colorGridEmphasise[4];
float colorGridAxisX[4];
@@ -127,6 +135,9 @@ struct DRWShadingGroup *shgroup_instance_bone_sphere_outline(struct DRWPass *pas
struct DRWShadingGroup *shgroup_instance_bone_sphere_solid(struct DRWPass *pass);
struct DRWShadingGroup *shgroup_instance_bone_stick(struct DRWPass *pass);
+struct GPUShader *mpath_line_shader_get(void);
+struct GPUShader *mpath_points_shader_get(void);
+
int DRW_object_wire_theme_get(
struct Object *ob, struct ViewLayer *view_layer, float **r_color);
float *DRW_color_background_blend_get(int theme_id);
@@ -145,6 +156,24 @@ void DRW_shgroup_armature_object(struct Object *ob, struct ViewLayer *view_layer
void DRW_shgroup_armature_pose(struct Object *ob, struct DRWArmaturePasses passes);
void DRW_shgroup_armature_edit(struct Object *ob, struct DRWArmaturePasses passes);
+/* draw_hair.c */
+
+/* This creates a shading group with display hairs.
+ * The draw call is already added by this function, just add additional uniforms. */
+struct DRWShadingGroup *DRW_shgroup_hair_create(
+ struct Object *object, struct ParticleSystem *psys, struct ModifierData *md,
+ struct DRWPass *hair_pass,
+ struct GPUShader *shader);
+
+struct DRWShadingGroup *DRW_shgroup_material_hair_create(
+ struct Object *object, struct ParticleSystem *psys, struct ModifierData *md,
+ struct DRWPass *hair_pass,
+ struct GPUMaterial *material);
+
+void DRW_hair_init(void);
+void DRW_hair_update(void);
+void DRW_hair_free(void);
+
/* pose_mode.c */
bool DRW_pose_mode_armature(
struct Object *ob, struct Object *active_ob);
diff --git a/source/blender/draw/intern/draw_debug.c b/source/blender/draw/intern/draw_debug.c
index b30f7936758..0e4176f90a6 100644
--- a/source/blender/draw/intern/draw_debug.c
+++ b/source/blender/draw/intern/draw_debug.c
@@ -65,7 +65,7 @@ void DRW_debug_polygon_v3(const float (*v)[3], const int vert_len, const float c
BLI_assert(vert_len > 1);
for (int i = 0; i < vert_len; ++i) {
- DRW_debug_line_v3v3(v[i], v[(i+1)%vert_len], color);
+ DRW_debug_line_v3v3(v[i], v[(i + 1) % vert_len], color);
}
}
@@ -148,4 +148,4 @@ void drw_debug_draw(void)
void drw_debug_init(void)
{
DRW_debug_modelmat_reset();
-} \ No newline at end of file
+}
diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c
new file mode 100644
index 00000000000..d5923419b37
--- /dev/null
+++ b/source/blender/draw/intern/draw_hair.c
@@ -0,0 +1,179 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2017 by Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation, Mike Erwin, Dalai Felinto
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file draw_hair.c
+ * \ingroup draw
+ *
+ * \brief Contains procedural GPU hair drawing methods.
+ */
+
+#include "DRW_render.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_string_utils.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_particle_types.h"
+#include "DNA_customdata_types.h"
+
+#include "BKE_mesh.h"
+#include "BKE_particle.h"
+#include "BKE_pointcache.h"
+
+#include "ED_particle.h"
+
+#include "GPU_batch.h"
+#include "GPU_shader.h"
+
+#include "draw_hair_private.h"
+
+typedef enum ParticleRefineShader {
+ PART_REFINE_CATMULL_ROM = 0,
+ PART_REFINE_MAX_SHADER,
+} ParticleRefineShader;
+
+static GPUShader *g_refine_shaders[PART_REFINE_MAX_SHADER] = {NULL};
+static DRWPass *g_tf_pass; /* XXX can be a problem with mulitple DRWManager in the future */
+
+extern char datatoc_common_hair_lib_glsl[];
+extern char datatoc_common_hair_refine_vert_glsl[];
+
+static GPUShader *hair_refine_shader_get(ParticleRefineShader sh)
+{
+ if (g_refine_shaders[sh]) {
+ return g_refine_shaders[sh];
+ }
+
+ char *vert_with_lib = BLI_string_joinN(datatoc_common_hair_lib_glsl, datatoc_common_hair_refine_vert_glsl);
+
+ const char *var_names[1] = {"outData"};
+
+ g_refine_shaders[sh] = DRW_shader_create_with_transform_feedback(vert_with_lib, NULL, "#define HAIR_PHASE_SUBDIV\n",
+ GPU_SHADER_TFB_POINTS, var_names, 1);
+
+ MEM_freeN(vert_with_lib);
+
+ return g_refine_shaders[sh];
+}
+
+void DRW_hair_init(void)
+{
+ g_tf_pass = DRW_pass_create("Update Hair Pass", DRW_STATE_TRANS_FEEDBACK);
+}
+
+static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex(
+ Object *object, ParticleSystem *psys, ModifierData *md,
+ DRWPass *hair_pass,
+ struct GPUMaterial *gpu_mat, GPUShader *gpu_shader)
+{
+ /* TODO(fclem): Pass the scene as parameter */
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ Scene *scene = draw_ctx->scene;
+
+ int subdiv = scene->r.hair_subdiv;
+ int thickness_res = (scene->r.hair_type == SCE_HAIR_SHAPE_STRAND) ? 1 : 2;
+
+ ParticleHairCache *hair_cache;
+ ParticleSettings *part = psys->part;
+ bool need_ft_update = particles_ensure_procedural_data(object, psys, md, &hair_cache, subdiv, thickness_res);
+
+ DRWShadingGroup *shgrp;
+ if (gpu_mat) {
+ shgrp = DRW_shgroup_material_create(gpu_mat, hair_pass);
+ }
+ else if (gpu_shader) {
+ shgrp = DRW_shgroup_create(gpu_shader, hair_pass);
+ }
+ else {
+ shgrp = NULL;
+ BLI_assert(0);
+ }
+
+ /* TODO optimize this. Only bind the ones GPUMaterial needs. */
+ for (int i = 0; i < hair_cache->num_uv_layers; ++i) {
+ for (int n = 0; hair_cache->uv_layer_names[i][n][0] != '\0'; ++n) {
+ DRW_shgroup_uniform_texture(shgrp, hair_cache->uv_layer_names[i][n], hair_cache->uv_tex[i]);
+ }
+ }
+ for (int i = 0; i < hair_cache->num_col_layers; ++i) {
+ for (int n = 0; hair_cache->col_layer_names[i][n][0] != '\0'; ++n) {
+ DRW_shgroup_uniform_texture(shgrp, hair_cache->col_layer_names[i][n], hair_cache->col_tex[i]);
+ }
+ }
+
+ DRW_shgroup_uniform_texture(shgrp, "hairPointBuffer", hair_cache->final[subdiv].proc_tex);
+ DRW_shgroup_uniform_int(shgrp, "hairStrandsRes", &hair_cache->final[subdiv].strands_res, 1);
+ DRW_shgroup_uniform_int_copy(shgrp, "hairThicknessRes", thickness_res);
+ DRW_shgroup_uniform_float(shgrp, "hairRadShape", &part->shape, 1);
+ DRW_shgroup_uniform_float_copy(shgrp, "hairRadRoot", part->rad_root * part->rad_scale * 0.5f);
+ DRW_shgroup_uniform_float_copy(shgrp, "hairRadTip", part->rad_tip * part->rad_scale * 0.5f);
+ DRW_shgroup_uniform_bool_copy(shgrp, "hairCloseTip", (part->shape_flag & PART_SHAPE_CLOSE_TIP) != 0);
+ /* TODO(fclem): Until we have a better way to cull the hair and render with orco, bypass culling test. */
+ DRW_shgroup_call_object_add_no_cull(shgrp, hair_cache->final[subdiv].proc_hairs[thickness_res - 1], object);
+
+ /* Transform Feedback subdiv. */
+ if (need_ft_update) {
+ int final_points_ct = hair_cache->final[subdiv].strands_res * hair_cache->strands_count;
+ GPUShader *tf_shader = hair_refine_shader_get(PART_REFINE_CATMULL_ROM);
+ DRWShadingGroup *tf_shgrp = DRW_shgroup_transform_feedback_create(tf_shader, g_tf_pass,
+ hair_cache->final[subdiv].proc_buf);
+ DRW_shgroup_uniform_texture(tf_shgrp, "hairPointBuffer", hair_cache->point_tex);
+ DRW_shgroup_uniform_texture(tf_shgrp, "hairStrandBuffer", hair_cache->strand_tex);
+ DRW_shgroup_uniform_int(tf_shgrp, "hairStrandsRes", &hair_cache->final[subdiv].strands_res, 1);
+ DRW_shgroup_call_procedural_points_add(tf_shgrp, final_points_ct, NULL);
+ }
+
+ return shgrp;
+}
+
+DRWShadingGroup *DRW_shgroup_hair_create(
+ Object *object, ParticleSystem *psys, ModifierData *md,
+ DRWPass *hair_pass,
+ GPUShader *shader)
+{
+ return drw_shgroup_create_hair_procedural_ex(object, psys, md, hair_pass, NULL, shader);
+}
+
+DRWShadingGroup *DRW_shgroup_material_hair_create(
+ Object *object, ParticleSystem *psys, ModifierData *md,
+ DRWPass *hair_pass,
+ struct GPUMaterial *material)
+{
+ return drw_shgroup_create_hair_procedural_ex(object, psys, md, hair_pass, material, NULL);
+}
+
+void DRW_hair_update(void)
+{
+ DRW_draw_pass(g_tf_pass);
+}
+
+void DRW_hair_free(void)
+{
+ for (int i = 0; i < PART_REFINE_MAX_SHADER; ++i) {
+ DRW_SHADER_FREE_SAFE(g_refine_shaders[i]);
+ }
+}
diff --git a/source/blender/draw/intern/draw_hair_private.h b/source/blender/draw/intern/draw_hair_private.h
new file mode 100644
index 00000000000..2e6c9a0d3c1
--- /dev/null
+++ b/source/blender/draw/intern/draw_hair_private.h
@@ -0,0 +1,92 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2017 by Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation, Mike Erwin, Dalai Felinto
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file draw_hair_private.h
+ * \ingroup draw
+ */
+
+#ifndef __DRAW_HAIR_PRIVATE_H__
+#define __DRAW_HAIR_PRIVATE_H__
+
+#define MAX_LAYER_NAME_CT 3 /* u0123456789, u, a0123456789 */
+#define MAX_LAYER_NAME_LEN DECIMAL_DIGITS_BOUND(unsigned int) + 2
+#define MAX_THICKRES 2 /* see eHairType */
+#define MAX_HAIR_SUBDIV 4 /* see hair_subdiv rna */
+
+struct Object;
+struct ParticleSystem;
+struct ModifierData;
+struct ParticleHairCache;
+
+typedef struct ParticleHairFinalCache {
+ /* Output of the subdivision stage: vertex buff sized to subdiv level. */
+ Gwn_VertBuf *proc_buf;
+ GPUTexture *proc_tex;
+
+ /* Just contains a huge index buffer used to draw the final hair. */
+ Gwn_Batch *proc_hairs[MAX_THICKRES];
+
+ int strands_res; /* points per hair, at least 2 */
+} ParticleHairFinalCache;
+
+typedef struct ParticleHairCache {
+ Gwn_VertBuf *pos;
+ Gwn_IndexBuf *indices;
+ Gwn_Batch *hairs;
+
+ /* Hair Procedural display: Interpolation is done on the GPU. */
+ Gwn_VertBuf *proc_point_buf; /* Input control points */
+ GPUTexture *point_tex;
+
+ Gwn_VertBuf *proc_strand_buf; /* Infos of control points strands (segment count and base index) */
+ GPUTexture *strand_tex;
+
+ Gwn_VertBuf *proc_uv_buf[MAX_MTFACE];
+ GPUTexture *uv_tex[MAX_MTFACE];
+ char uv_layer_names[MAX_MTFACE][MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN];
+
+ Gwn_VertBuf *proc_col_buf[MAX_MCOL];
+ GPUTexture *col_tex[MAX_MCOL];
+ char col_layer_names[MAX_MCOL][MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN];
+
+ int num_uv_layers;
+ int num_col_layers;
+
+ ParticleHairFinalCache final[MAX_HAIR_SUBDIV];
+
+ int strands_count;
+ int elems_count;
+ int point_count;
+} ParticleHairCache;
+
+bool particles_ensure_procedural_data(
+ struct Object *object,
+ struct ParticleSystem *psys,
+ struct ModifierData *md,
+ struct ParticleHairCache **r_hair_cache,
+ int subdiv,
+ int thickness_res);
+
+#endif /* __DRAW_HAIR_PRIVATE_H__ */
diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c
index 6aa8da3badb..3e4f812af27 100644
--- a/source/blender/draw/intern/draw_instance_data.c
+++ b/source/blender/draw/intern/draw_instance_data.c
@@ -38,6 +38,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
+#include "BLI_mempool.h"
#define BUFFER_CHUNK_SIZE 32
#define BUFFER_VERTS_CHUNK 32
@@ -69,18 +70,13 @@ typedef struct DRWInstanceChunk {
struct DRWInstanceData {
struct DRWInstanceData *next;
bool used; /* If this data is used or not. */
- size_t chunk_size; /* Current size of the whole chunk. */
size_t data_size; /* Size of one instance data. */
- size_t instance_group; /* How many instance to allocate at a time. */
- size_t offset; /* Offset to the next instance data. */
- float *memchunk; /* Should be float no matter what. */
+ BLI_mempool *mempool;
};
struct DRWInstanceDataList {
struct DRWInstanceDataList *next, *prev;
/* Linked lists for all possible data pool size */
- /* Not entirely sure if we should separate them in the first place.
- * This is done to minimize the reattribution misses. */
DRWInstanceData *idata_head[MAX_INSTANCE_DATA_SIZE];
DRWInstanceData *idata_tail[MAX_INSTANCE_DATA_SIZE];
@@ -282,17 +278,13 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist)
/** \name Instance Data (DRWInstanceData)
* \{ */
-static DRWInstanceData *drw_instance_data_create(
- DRWInstanceDataList *idatalist, uint attrib_size, uint instance_group)
+static DRWInstanceData *drw_instance_data_create(DRWInstanceDataList *idatalist, uint attrib_size)
{
DRWInstanceData *idata = MEM_callocN(sizeof(DRWInstanceData), "DRWInstanceData");
idata->next = NULL;
idata->used = true;
idata->data_size = attrib_size;
- idata->instance_group = instance_group;
- idata->chunk_size = idata->data_size * instance_group;
- idata->offset = 0;
- idata->memchunk = MEM_mallocN(idata->chunk_size * sizeof(float), "DRWInstanceData memchunk");
+ idata->mempool = BLI_mempool_create(sizeof(float) * idata->data_size, 0, 16, 0);
BLI_assert(attrib_size > 0);
@@ -310,35 +302,18 @@ static DRWInstanceData *drw_instance_data_create(
static void DRW_instance_data_free(DRWInstanceData *idata)
{
- MEM_freeN(idata->memchunk);
+ BLI_mempool_destroy(idata->mempool);
}
/**
* Return a pointer to the next instance data space.
- * DO NOT SAVE/REUSE THIS POINTER after the next call
- * to this function since the chunk may have been
- * reallocated.
**/
void *DRW_instance_data_next(DRWInstanceData *idata)
{
- idata->offset += idata->data_size;
-
- /* Check if chunk is large enough. realloc otherwise. */
- if (idata->offset > idata->chunk_size) {
- idata->chunk_size += idata->data_size * idata->instance_group;
- idata->memchunk = MEM_reallocN(idata->memchunk, idata->chunk_size * sizeof(float));
- }
-
- return idata->memchunk + (idata->offset - idata->data_size);
+ return BLI_mempool_alloc(idata->mempool);
}
-void *DRW_instance_data_get(DRWInstanceData *idata)
-{
- return (void *)idata->memchunk;
-}
-
-DRWInstanceData *DRW_instance_data_request(
- DRWInstanceDataList *idatalist, uint attrib_size, uint instance_group)
+DRWInstanceData *DRW_instance_data_request(DRWInstanceDataList *idatalist, uint attrib_size)
{
BLI_assert(attrib_size > 0 && attrib_size <= MAX_INSTANCE_DATA_SIZE);
@@ -352,7 +327,7 @@ DRWInstanceData *DRW_instance_data_request(
}
}
- return drw_instance_data_create(idatalist, attrib_size, instance_group);
+ return drw_instance_data_create(idatalist, attrib_size);
}
/** \} */
@@ -413,7 +388,6 @@ void DRW_instance_data_list_reset(DRWInstanceDataList *idatalist)
for (int i = 0; i < MAX_INSTANCE_DATA_SIZE; ++i) {
for (idata = idatalist->idata_head[i]; idata; idata = idata->next) {
idata->used = false;
- idata->offset = 0;
}
}
}
@@ -454,14 +428,7 @@ void DRW_instance_data_list_resize(DRWInstanceDataList *idatalist)
for (int i = 0; i < MAX_INSTANCE_DATA_SIZE; ++i) {
for (idata = idatalist->idata_head[i]; idata; idata = idata->next) {
- /* Rounding up to nearest chunk size to compare. */
- size_t fac = idata->data_size * idata->instance_group;
- size_t tmp = idata->offset + fac - 1;
- size_t rounded_offset = tmp - tmp % fac;
- if (rounded_offset < idata->chunk_size) {
- idata->chunk_size = rounded_offset;
- idata->memchunk = MEM_reallocN(idata->memchunk, idata->chunk_size * sizeof(float));
- }
+ BLI_mempool_clear_ex(idata->mempool, BLI_mempool_len(idata->mempool));
}
}
}
diff --git a/source/blender/draw/intern/draw_instance_data.h b/source/blender/draw/intern/draw_instance_data.h
index bc3c0c2e04c..0ea40a50a6b 100644
--- a/source/blender/draw/intern/draw_instance_data.h
+++ b/source/blender/draw/intern/draw_instance_data.h
@@ -31,7 +31,7 @@
#include "GPU_batch.h"
-#define MAX_INSTANCE_DATA_SIZE 48 /* Can be adjusted for more */
+#define MAX_INSTANCE_DATA_SIZE 64 /* Can be adjusted for more */
typedef struct DRWInstanceData DRWInstanceData;
typedef struct DRWInstanceDataList DRWInstanceDataList;
@@ -39,9 +39,8 @@ typedef struct DRWInstanceDataList DRWInstanceDataList;
struct DRWShadingGroup;
void *DRW_instance_data_next(DRWInstanceData *idata);
-void *DRW_instance_data_get(DRWInstanceData *idata);
DRWInstanceData *DRW_instance_data_request(
- DRWInstanceDataList *idatalist, uint attrib_size, uint instance_group);
+ DRWInstanceDataList *idatalist, uint attrib_size);
void DRW_batching_buffer_request(
DRWInstanceDataList *idatalist, Gwn_VertFormat *format, Gwn_PrimType type, struct DRWShadingGroup *shgroup,
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index a57a91363eb..054d070bea1 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -100,7 +100,7 @@ extern struct GPUUniformBuffer *view_ubo; /* draw_manager_exec.c */
static void drw_state_prepare_clean_for_draw(DRWManager *dst)
{
- memset(dst, 0x0, offsetof(DRWManager, ogl_context));
+ memset(dst, 0x0, offsetof(DRWManager, gl_context));
}
/* This function is used to reset draw manager to a state
@@ -110,7 +110,7 @@ static void drw_state_prepare_clean_for_draw(DRWManager *dst)
#ifdef DEBUG
static void drw_state_ensure_not_reused(DRWManager *dst)
{
- memset(dst, 0xff, offsetof(DRWManager, ogl_context));
+ memset(dst, 0xff, offsetof(DRWManager, gl_context));
}
#endif
@@ -152,7 +152,7 @@ bool DRW_object_is_renderable(Object *ob)
BLI_assert(BKE_object_is_visible(ob, OB_VISIBILITY_CHECK_UNKNOWN_RENDER_MODE));
if (ob->type == OB_MESH) {
- if (ob == DST.draw_ctx.object_edit) {
+ if ((ob == DST.draw_ctx.object_edit) || BKE_object_is_in_editmode(ob)) {
View3D *v3d = DST.draw_ctx.v3d;
const int mask = (V3D_OVERLAY_EDIT_OCCLUDE_WIRE | V3D_OVERLAY_EDIT_WEIGHT);
@@ -581,7 +581,7 @@ static void drw_viewport_var_init(void)
DST.clipping.updated = false;
- memset(DST.common_instance_data, 0x0, sizeof(DST.common_instance_data));
+ memset(DST.object_instance_data, 0x0, sizeof(DST.object_instance_data));
}
void DRW_viewport_matrix_get(float mat[4][4], DRWViewportMatrixType type)
@@ -764,10 +764,11 @@ ObjectEngineData *DRW_object_engine_data_ensure(
const size_t t = sizeof(float) - 1;
size = (size + t) & ~t;
size_t fsize = size / sizeof(float);
- if (DST.common_instance_data[fsize] == NULL) {
- DST.common_instance_data[fsize] = DRW_instance_data_request(DST.idatalist, fsize, 16);
+ BLI_assert(fsize < MAX_INSTANCE_DATA_SIZE);
+ if (DST.object_instance_data[fsize] == NULL) {
+ DST.object_instance_data[fsize] = DRW_instance_data_request(DST.idatalist, fsize);
}
- oed = (ObjectEngineData *)DRW_instance_data_next(DST.common_instance_data[fsize]);
+ oed = (ObjectEngineData *)DRW_instance_data_next(DST.object_instance_data[fsize]);
memset(oed, 0, size);
}
else {
@@ -1051,6 +1052,8 @@ static void drw_engines_enable_from_engine(RenderEngineType *engine_type, int dr
static void drw_engines_enable_from_object_mode(void)
{
use_drw_engine(&draw_engine_object_type);
+ /* TODO(fclem) remove this, it does not belong to it's own engine. */
+ use_drw_engine(&draw_engine_motion_path_type);
}
static void drw_engines_enable_from_mode(int mode)
@@ -1177,7 +1180,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx)
/* XXX Really nasty locking. But else this could
* be executed by the material previews thread
* while rendering a viewport. */
- BLI_mutex_lock(&DST.ogl_context_mutex);
+ BLI_mutex_lock(&DST.gl_context_mutex);
/* Reset before using it. */
drw_state_prepare_clean_for_draw(&DST);
@@ -1205,7 +1208,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx)
drw_engines_disable();
- BLI_mutex_unlock(&DST.ogl_context_mutex);
+ BLI_mutex_unlock(&DST.gl_context_mutex);
}
}
@@ -1230,6 +1233,9 @@ void DRW_draw_view(const bContext *C)
/* Reset before using it. */
drw_state_prepare_clean_for_draw(&DST);
+ DST.options.draw_text = (
+ (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0 &&
+ (v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) != 0);
DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, viewport, C);
}
@@ -1276,6 +1282,7 @@ void DRW_draw_render_loop_ex(
DRW_globals_update();
drw_debug_init();
+ DRW_hair_init();
/* No framebuffer allowed before drawing. */
BLI_assert(GPU_framebuffer_current_get() == 0);
@@ -1288,7 +1295,7 @@ void DRW_draw_render_loop_ex(
PROFILE_START(stime);
drw_engines_cache_init();
- DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob, DRW_iterator_mode_get())
+ DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
{
drw_engines_cache_populate(ob);
}
@@ -1305,6 +1312,7 @@ void DRW_draw_render_loop_ex(
}
DRW_stats_begin();
+ DRW_hair_update();
GPU_framebuffer_bind(DST.default_framebuffer);
@@ -1346,7 +1354,9 @@ void DRW_draw_render_loop_ex(
drw_debug_draw();
+ glDisable(GL_DEPTH_TEST);
drw_engines_draw_text();
+ glEnable(GL_DEPTH_TEST);
if (DST.draw_ctx.evil_C) {
/* needed so manipulator isn't obscured */
@@ -1450,12 +1460,28 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
RenderData *r = &scene->r;
Render *render = engine->re;
- if (G.background && DST.ogl_context == NULL) {
+ if (G.background && DST.gl_context == NULL) {
WM_init_opengl();
}
+ void *re_gl_context = RE_gl_context_get(render);
+ void *re_gwn_context = NULL;
+
/* Changing Context */
- DRW_opengl_context_enable();
+ if (re_gl_context != NULL) {
+ /* TODO get rid of the blocking. Only here because of the static global DST. */
+ BLI_mutex_lock(&DST.gl_context_mutex);
+ WM_opengl_context_activate(re_gl_context);
+ re_gwn_context = RE_gwn_context_get(render);
+ if (GWN_context_active_get() == NULL) {
+ GWN_context_active_set(re_gwn_context);
+ }
+ DRW_shape_cache_reset(); /* XXX fix that too. */
+ }
+ else {
+ DRW_opengl_context_enable();
+ }
+
/* IMPORTANT: We dont support immediate mode in render mode!
* This shall remain in effect until immediate mode supports
* multiple threads. */
@@ -1523,7 +1549,17 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
GPU_framebuffer_restore();
/* Changing Context */
- DRW_opengl_context_disable();
+ if (re_gl_context != NULL) {
+ DRW_shape_cache_reset(); /* XXX fix that too. */
+ glFlush();
+ GWN_context_active_set(NULL);
+ WM_opengl_context_release(re_gl_context);
+ /* TODO get rid of the blocking. */
+ BLI_mutex_unlock(&DST.gl_context_mutex);
+ }
+ else {
+ DRW_opengl_context_disable();
+ }
#ifdef DEBUG
/* Avoid accidental reuse. */
@@ -1535,7 +1571,9 @@ void DRW_render_object_iter(
void *vedata, RenderEngine *engine, struct Depsgraph *depsgraph,
void (*callback)(void *vedata, Object *ob, RenderEngine *engine, struct Depsgraph *depsgraph))
{
- DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob, DRW_iterator_mode_get())
+ DRW_hair_init();
+
+ DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
{
DST.ob_state = NULL;
callback(vedata, ob, engine, depsgraph);
@@ -1617,8 +1655,8 @@ void DRW_draw_select_loop(
obedit_mode = CTX_MODE_EDIT_ARMATURE;
}
}
- if (v3d->overlay.flag &= V3D_OVERLAY_BONE_SELECTION) {
- if (!(v3d->flag2 &= V3D_RENDER_OVERRIDE)) {
+ if (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECTION) {
+ if (!(v3d->flag2 & V3D_RENDER_OVERRIDE)) {
Object *obpose = OBPOSE_FROM_OBACT(obact);
if (obpose) {
use_obedit = true;
@@ -1661,6 +1699,7 @@ void DRW_draw_select_loop(
/* Init engines */
drw_engines_init();
+ DRW_hair_init();
{
drw_engines_cache_init();
@@ -1677,13 +1716,17 @@ void DRW_draw_select_loop(
}
else {
DEG_OBJECT_ITER_BEGIN(
- depsgraph, ob, DRW_iterator_mode_get(),
+ depsgraph, ob,
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
DEG_ITER_OBJECT_FLAG_VISIBLE |
DEG_ITER_OBJECT_FLAG_DUPLI)
{
if ((ob->base_flag & BASE_SELECTABLED) != 0) {
- DRW_select_load_id(ob->select_color);
+ /* This relies on dupli instances being after their instancing object. */
+ if ((ob->base_flag & BASE_FROMDUPLI) == 0) {
+ Object *ob_orig = DEG_get_original_object(ob);
+ DRW_select_load_id(ob_orig->select_color);
+ }
drw_engines_cache_populate(ob);
}
}
@@ -1695,6 +1738,8 @@ void DRW_draw_select_loop(
DRW_render_instance_buffer_finish();
}
+ DRW_hair_update();
+
/* Setup framebuffer */
draw_select_framebuffer_setup(rect);
GPU_framebuffer_bind(g_select_buffer.framebuffer);
@@ -1834,6 +1879,7 @@ void DRW_draw_depth_loop(
/* Init engines */
drw_engines_init();
+ DRW_hair_init();
/* TODO : tag to refresh by the dependency graph */
/* ideally only refresh when objects are added/removed */
@@ -1841,7 +1887,7 @@ void DRW_draw_depth_loop(
if (cache_is_dirty) {
drw_engines_cache_init();
- DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob, DRW_iterator_mode_get())
+ DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
{
drw_engines_cache_populate(ob);
}
@@ -1852,6 +1898,8 @@ void DRW_draw_depth_loop(
DRW_render_instance_buffer_finish();
}
+ DRW_hair_update();
+
/* Start Drawing */
DRW_state_reset();
DRW_draw_callbacks_pre_scene();
@@ -1954,22 +2002,14 @@ bool DRW_state_is_opengl_render(void)
}
/**
- * Gives you the iterator mode to use for depsgraph.
- */
-eDepsObjectIteratorMode DRW_iterator_mode_get(void)
-{
- return DRW_state_is_scene_render() ? DEG_ITER_OBJECT_MODE_RENDER :
- DEG_ITER_OBJECT_MODE_VIEWPORT;
-}
-
-/**
* Should text draw in this mode?
*/
bool DRW_state_show_text(void)
{
return (DST.options.is_select) == 0 &&
(DST.options.is_depth) == 0 &&
- (DST.options.is_scene_render) == 0;
+ (DST.options.is_scene_render) == 0 &&
+ (DST.options.draw_text) == 0;
}
/**
@@ -2045,6 +2085,7 @@ void DRW_engines_register(void)
DRW_engine_register(&draw_engine_edit_metaball_type);
DRW_engine_register(&draw_engine_edit_surface_type);
DRW_engine_register(&draw_engine_edit_text_type);
+ DRW_engine_register(&draw_engine_motion_path_type);
DRW_engine_register(&draw_engine_overlay_type);
DRW_engine_register(&draw_engine_paint_texture_type);
DRW_engine_register(&draw_engine_paint_vertex_type);
@@ -2098,6 +2139,7 @@ void DRW_engines_free(void)
DRW_TEXTURE_FREE_SAFE(g_select_buffer.texture_depth);
GPU_FRAMEBUFFER_FREE_SAFE(g_select_buffer.framebuffer);
+ DRW_hair_free();
DRW_shape_cache_free();
DRW_stats_free();
DRW_globals_free();
@@ -2136,14 +2178,16 @@ void DRW_engines_free(void)
void DRW_opengl_context_create(void)
{
- BLI_assert(DST.ogl_context == NULL); /* Ensure it's called once */
+ BLI_assert(DST.gl_context == NULL); /* Ensure it's called once */
- BLI_mutex_init(&DST.ogl_context_mutex);
+ BLI_mutex_init(&DST.gl_context_mutex);
if (!G.background) {
immDeactivate();
}
/* This changes the active context. */
- DST.ogl_context = WM_opengl_context_create();
+ DST.gl_context = WM_opengl_context_create();
+ /* Make the context active for this thread (main thread) */
+ WM_opengl_context_activate(DST.gl_context);
/* Be sure to create gawain.context too. */
DST.gwn_context = GWN_context_create();
if (!G.background) {
@@ -2158,28 +2202,28 @@ void DRW_opengl_context_create(void)
void DRW_opengl_context_destroy(void)
{
BLI_assert(BLI_thread_is_main());
- if (DST.ogl_context != NULL) {
- WM_opengl_context_activate(DST.ogl_context);
+ if (DST.gl_context != NULL) {
+ WM_opengl_context_activate(DST.gl_context);
GWN_context_active_set(DST.gwn_context);
GWN_context_discard(DST.gwn_context);
- WM_opengl_context_dispose(DST.ogl_context);
- BLI_mutex_end(&DST.ogl_context_mutex);
+ WM_opengl_context_dispose(DST.gl_context);
+ BLI_mutex_end(&DST.gl_context_mutex);
}
}
void DRW_opengl_context_enable(void)
{
- if (DST.ogl_context != NULL) {
+ if (DST.gl_context != NULL) {
/* IMPORTANT: We dont support immediate mode in render mode!
* This shall remain in effect until immediate mode supports
* multiple threads. */
- BLI_mutex_lock(&DST.ogl_context_mutex);
+ BLI_mutex_lock(&DST.gl_context_mutex);
if (BLI_thread_is_main()) {
if (!G.background) {
immDeactivate();
}
}
- WM_opengl_context_activate(DST.ogl_context);
+ WM_opengl_context_activate(DST.gl_context);
GWN_context_active_set(DST.gwn_context);
if (BLI_thread_is_main()) {
if (!G.background) {
@@ -2192,7 +2236,7 @@ void DRW_opengl_context_enable(void)
void DRW_opengl_context_disable(void)
{
- if (DST.ogl_context != NULL) {
+ if (DST.gl_context != NULL) {
#ifdef __APPLE__
/* Need to flush before disabling draw context, otherwise it does not
* always finish drawing and viewport can be empty or partially drawn */
@@ -2203,11 +2247,11 @@ void DRW_opengl_context_disable(void)
wm_window_reset_drawable();
}
else {
- WM_opengl_context_release(DST.ogl_context);
+ WM_opengl_context_release(DST.gl_context);
GWN_context_active_set(NULL);
}
- BLI_mutex_unlock(&DST.ogl_context_mutex);
+ BLI_mutex_unlock(&DST.gl_context_mutex);
}
}
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index 267826d2d9a..e811e9ea8a9 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -87,6 +87,7 @@
enum {
DRW_CALL_CULLED = (1 << 0),
DRW_CALL_NEGSCALE = (1 << 1),
+ DRW_CALL_BYPASS_CULLING = (1 << 2),
};
/* Used by DRWCallState.matflag */
@@ -125,8 +126,10 @@ typedef struct DRWCallState {
typedef enum {
DRW_CALL_SINGLE, /* A single batch */
+ DRW_CALL_RANGE, /* Like single but only draw a range of vertices/indices. */
DRW_CALL_INSTANCES, /* Draw instances without any instancing attribs. */
DRW_CALL_GENERATE, /* Uses a callback to draw with any number of batches. */
+ DRW_CALL_PROCEDURAL, /* Generate a drawcall without any Gwn_Batch. */
} DRWCallType;
typedef struct DRWCall {
@@ -137,6 +140,10 @@ typedef struct DRWCall {
struct { /* type == DRW_CALL_SINGLE */
Gwn_Batch *geometry;
} single;
+ struct { /* type == DRW_CALL_RANGE */
+ Gwn_Batch *geometry;
+ uint start, count;
+ } range;
struct { /* type == DRW_CALL_INSTANCES */
Gwn_Batch *geometry;
/* Count can be adjusted between redraw. If needed, we can add fixed count. */
@@ -146,6 +153,10 @@ typedef struct DRWCall {
DRWCallGenerateFn *geometry_fn;
void *user_data;
} generate;
+ struct { /* type == DRW_CALL_PROCEDURAL */
+ uint vert_count;
+ Gwn_PrimType prim_type;
+ } procedural;
};
DRWCallType type;
@@ -171,6 +182,8 @@ typedef enum {
DRW_UNIFORM_BLOCK_PERSIST
} DRWUniformType;
+#define MAX_UNIFORM_NAME 13
+
struct DRWUniform {
DRWUniform *next; /* single-linked list */
union {
@@ -184,6 +197,9 @@ struct DRWUniform {
char type; /* DRWUniformType */
char length; /* cannot be more than 16 */
char arraysize; /* cannot be more than 16 too */
+#ifndef NDEBUG
+ char name[MAX_UNIFORM_NAME];
+#endif
};
typedef enum {
@@ -247,7 +263,7 @@ struct DRWShadingGroup {
#endif
#ifdef USE_GPU_SELECT
- DRWInstanceData *inst_selectid;
+ Gwn_VertBuf *inst_selectid;
DRWPass *pass_parent; /* backlink to pass we're in */
int override_selectid; /* Override for single object instances. */
#endif
@@ -289,7 +305,7 @@ typedef struct DRWManager {
/* Cache generation */
ViewportMemoryPool *vmempool;
DRWInstanceDataList *idatalist;
- DRWInstanceData *common_instance_data[MAX_INSTANCE_DATA_SIZE];
+ DRWInstanceData *object_instance_data[MAX_INSTANCE_DATA_SIZE];
/* State of the object being evaluated if already allocated. */
DRWCallState *ob_state;
unsigned char state_cache_id; /* Could be larger but 254 view changes is already a lot! */
@@ -318,6 +334,7 @@ typedef struct DRWManager {
uint is_image_render : 1;
uint is_scene_render : 1;
uint draw_background : 1;
+ uint draw_text : 1;
} options;
/* Current rendering context */
@@ -352,11 +369,11 @@ typedef struct DRWManager {
/* ---------- Nothing after this point is cleared after use ----------- */
- /* ogl_context serves as the offset for clearing only
+ /* gl_context serves as the offset for clearing only
* the top portion of the struct so DO NOT MOVE IT! */
- void *ogl_context; /* Unique ghost context used by the draw manager. */
+ void *gl_context; /* Unique ghost context used by the draw manager. */
Gwn_Context *gwn_context;
- ThreadMutex ogl_context_mutex; /* Mutex to lock the drw manager and avoid concurent context usage. */
+ ThreadMutex gl_context_mutex; /* Mutex to lock the drw manager and avoid concurent context usage. */
/** GPU Resource State: Memory storage between drawing. */
struct {
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index b4dce47413e..b49af47223f 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -132,6 +132,11 @@ static void drw_shgroup_uniform(DRWShadingGroup *shgroup, const char *name,
BLI_assert(length >= 0 && length <= 16);
drw_shgroup_uniform_create_ex(shgroup, location, type, value, length, arraysize);
+
+#ifndef NDEBUG
+ /* Save uniform name to easily identify it when debugging. */
+ BLI_strncpy(shgroup->uniforms->name, name, MAX_UNIFORM_NAME);
+#endif
}
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
@@ -366,11 +371,74 @@ void DRW_shgroup_call_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obm
BLI_LINKS_APPEND(&shgroup->calls, call);
}
+void DRW_shgroup_call_range_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obmat)[4], uint v_sta, uint v_count)
+{
+ BLI_assert(geom != NULL);
+ BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM));
+ BLI_assert(v_count);
+
+ DRWCall *call = BLI_mempool_alloc(DST.vmempool->calls);
+ call->state = drw_call_state_create(shgroup, obmat, NULL);
+ call->type = DRW_CALL_RANGE;
+ call->range.geometry = geom;
+ call->range.start = v_sta;
+ call->range.count = v_count;
+#ifdef USE_GPU_SELECT
+ call->select_id = DST.select_id;
+#endif
+
+ BLI_LINKS_APPEND(&shgroup->calls, call);
+}
+
+static void drw_shgroup_call_procedural_add_ex(
+ DRWShadingGroup *shgroup, Gwn_PrimType prim_type, uint vert_count, float (*obmat)[4], Object *ob)
+{
+ BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM));
+
+ DRWCall *call = BLI_mempool_alloc(DST.vmempool->calls);
+ if (ob) {
+ call->state = drw_call_state_object(shgroup, ob->obmat, ob);
+ }
+ else {
+ call->state = drw_call_state_create(shgroup, obmat, NULL);
+ }
+ call->type = DRW_CALL_PROCEDURAL;
+ call->procedural.prim_type = prim_type;
+ call->procedural.vert_count = vert_count;
+#ifdef USE_GPU_SELECT
+ call->select_id = DST.select_id;
+#endif
+
+ BLI_LINKS_APPEND(&shgroup->calls, call);
+}
+
+void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_count, float (*obmat)[4])
+{
+ drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_POINTS, point_count, obmat, NULL);
+}
+
+void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, uint line_count, float (*obmat)[4])
+{
+ drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_LINES, line_count * 2, obmat, NULL);
+}
+
+void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, uint tria_count, float (*obmat)[4])
+{
+ drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_TRIS, tria_count * 3, obmat, NULL);
+}
+
+/* TODO (fclem): this is a sign that the api is starting to be limiting.
+ * Maybe add special function that general purpose for special cases. */
+void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup, uint tria_count, Object *ob)
+{
+ drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_TRIS, tria_count * 3, NULL, ob);
+}
+
/* These calls can be culled and are optimized for redraw */
-void DRW_shgroup_call_object_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, Object *ob)
+void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, Gwn_Batch *geom, Object *ob, bool bypass_culling)
{
BLI_assert(geom != NULL);
- BLI_assert(shgroup->type == DRW_SHG_NORMAL);
+ BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM));
DRWCall *call = BLI_mempool_alloc(DST.vmempool->calls);
call->state = drw_call_state_object(shgroup, ob->obmat, ob);
@@ -380,6 +448,9 @@ void DRW_shgroup_call_object_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, Obje
call->select_id = DST.select_id;
#endif
+ /* NOTE this will disable culling for the whole object. */
+ call->state->flag |= (bypass_culling) ? DRW_CALL_BYPASS_CULLING : 0;
+
BLI_LINKS_APPEND(&shgroup->calls, call);
}
@@ -388,7 +459,7 @@ void DRW_shgroup_call_object_add_with_callback(
DRWCallVisibilityFn *callback, void *user_data)
{
BLI_assert(geom != NULL);
- BLI_assert(shgroup->type == DRW_SHG_NORMAL);
+ BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM));
DRWCall *call = BLI_mempool_alloc(DST.vmempool->calls);
call->state = drw_call_state_object(shgroup, ob->obmat, ob);
@@ -406,7 +477,7 @@ void DRW_shgroup_call_object_add_with_callback(
void DRW_shgroup_call_instances_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obmat)[4], uint *count)
{
BLI_assert(geom != NULL);
- BLI_assert(shgroup->type == DRW_SHG_NORMAL);
+ BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM));
DRWCall *call = BLI_mempool_alloc(DST.vmempool->calls);
call->state = drw_call_state_create(shgroup, obmat, NULL);
@@ -424,7 +495,7 @@ void DRW_shgroup_call_instances_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, f
void DRW_shgroup_call_object_instances_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, Object *ob, uint *count)
{
BLI_assert(geom != NULL);
- BLI_assert(shgroup->type == DRW_SHG_NORMAL);
+ BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM));
DRWCall *call = BLI_mempool_alloc(DST.vmempool->calls);
call->state = drw_call_state_object(shgroup, ob->obmat, ob);
@@ -444,7 +515,7 @@ void DRW_shgroup_call_generate_add(
float (*obmat)[4])
{
BLI_assert(geometry_fn != NULL);
- BLI_assert(shgroup->type == DRW_SHG_NORMAL);
+ BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM));
DRWCall *call = BLI_mempool_alloc(DST.vmempool->calls);
call->state = drw_call_state_create(shgroup, obmat, NULL);
@@ -482,12 +553,10 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at
{
#ifdef USE_GPU_SELECT
if (G.f & G_PICKSEL) {
- if (shgroup->inst_selectid == NULL) {
- shgroup->inst_selectid = DRW_instance_data_request(DST.idatalist, 1, 128);
+ if (shgroup->instance_count == shgroup->inst_selectid->vertex_ct) {
+ GWN_vertbuf_data_resize(shgroup->inst_selectid, shgroup->instance_count + 32);
}
-
- int *select_id = DRW_instance_data_next(shgroup->inst_selectid);
- *select_id = DST.select_id;
+ GWN_vertbuf_attr_set(shgroup->inst_selectid, 0, shgroup->instance_count, &DST.select_id);
}
#endif
@@ -587,6 +656,21 @@ static void drw_shgroup_instance_init(
DRW_instancing_buffer_request(DST.idatalist, format, batch, shgroup,
&shgroup->instance_geom, &shgroup->instance_vbo);
+
+#ifdef USE_GPU_SELECT
+ if (G.f & G_PICKSEL) {
+ /* Not actually used for rendering but alloced in one chunk.
+ * Plus we don't have to care about ownership. */
+ static Gwn_VertFormat inst_select_format = {0};
+ if (inst_select_format.attrib_ct == 0) {
+ GWN_vertformat_attr_add(&inst_select_format, "selectId", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ }
+ Gwn_Batch *batch_dummy; /* Not used */
+ DRW_batching_buffer_request(DST.idatalist, &inst_select_format,
+ GWN_PRIM_POINTS, shgroup,
+ &batch_dummy, &shgroup->inst_selectid);
+ }
+#endif
}
static void drw_shgroup_batching_init(
@@ -609,6 +693,20 @@ static void drw_shgroup_batching_init(
DRW_batching_buffer_request(DST.idatalist, format, type, shgroup,
&shgroup->batch_geom, &shgroup->batch_vbo);
+
+#ifdef USE_GPU_SELECT
+ if (G.f & G_PICKSEL) {
+ /* Not actually used for rendering but alloced in one chunk. */
+ static Gwn_VertFormat inst_select_format = {0};
+ if (inst_select_format.attrib_ct == 0) {
+ GWN_vertformat_attr_add(&inst_select_format, "selectId", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ }
+ Gwn_Batch *batch; /* Not used */
+ DRW_batching_buffer_request(DST.idatalist, &inst_select_format,
+ GWN_PRIM_POINTS, shgroup,
+ &batch, &shgroup->inst_selectid);
+ }
+#endif
}
static DRWShadingGroup *drw_shgroup_create_ex(struct GPUShader *shader, DRWPass *pass)
@@ -646,7 +744,14 @@ static DRWShadingGroup *drw_shgroup_material_create_ex(GPUPass *gpupass, DRWPass
return NULL;
}
- DRWShadingGroup *grp = drw_shgroup_create_ex(GPU_pass_shader(gpupass), pass);
+ GPUShader *sh = GPU_pass_shader_get(gpupass);
+
+ if (!sh) {
+ /* Shader not yet compiled */
+ return NULL;
+ }
+
+ DRWShadingGroup *grp = drw_shgroup_create_ex(sh, pass);
return grp;
}
@@ -694,7 +799,7 @@ static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp, struct
}
}
- GPUUniformBuffer *ubo = GPU_material_get_uniform_buffer(material);
+ GPUUniformBuffer *ubo = GPU_material_uniform_buffer_get(material);
if (ubo != NULL) {
DRW_shgroup_uniform_block(grp, GPU_UBO_BLOCK_NAME, ubo);
}
@@ -722,7 +827,7 @@ DRWShadingGroup *DRW_shgroup_material_create(
DRWShadingGroup *shgroup = drw_shgroup_material_create_ex(gpupass, pass);
if (shgroup) {
- drw_shgroup_init(shgroup, GPU_pass_shader(gpupass));
+ drw_shgroup_init(shgroup, GPU_pass_shader_get(gpupass));
drw_shgroup_material_inputs(shgroup, material);
}
@@ -739,7 +844,7 @@ DRWShadingGroup *DRW_shgroup_material_instance_create(
shgroup->type = DRW_SHG_INSTANCE;
shgroup->instance_geom = geom;
drw_call_calc_orco(ob, shgroup->instance_orcofac);
- drw_shgroup_instance_init(shgroup, GPU_pass_shader(gpupass), geom, format);
+ drw_shgroup_instance_init(shgroup, GPU_pass_shader_get(gpupass), geom, format);
drw_shgroup_material_inputs(shgroup, material);
}
@@ -757,7 +862,7 @@ DRWShadingGroup *DRW_shgroup_material_empty_tri_batch_create(
if (shgroup) {
/* Calling drw_shgroup_init will cause it to call GWN_draw_primitive(). */
- drw_shgroup_init(shgroup, GPU_pass_shader(gpupass));
+ drw_shgroup_init(shgroup, GPU_pass_shader_get(gpupass));
shgroup->type = DRW_SHG_TRIANGLE_BATCH;
shgroup->instance_count = tri_count * 3;
drw_shgroup_material_inputs(shgroup, material);
@@ -836,6 +941,7 @@ DRWShadingGroup *DRW_shgroup_empty_tri_batch_create(struct GPUShader *shader, DR
DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader, DRWPass *pass, Gwn_VertBuf *tf_target)
{
+ BLI_assert(tf_target != NULL);
DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass);
shgroup->type = DRW_SHG_FEEDBACK_TRANSFORM;
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 110691373ab..3b7d19ac361 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -222,7 +222,7 @@ void drw_state_set(DRWState state)
if (CHANGED_ANY_STORE_VAR(
DRW_STATE_BLEND | DRW_STATE_BLEND_PREMUL | DRW_STATE_ADDITIVE |
DRW_STATE_MULTIPLY | DRW_STATE_TRANSMISSION | DRW_STATE_ADDITIVE_FULL |
- DRW_STATE_TRANSPARENT_REVEALAGE,
+ DRW_STATE_BLEND_OIT,
test))
{
if (test) {
@@ -241,8 +241,9 @@ void drw_state_set(DRWState state)
else if ((state & DRW_STATE_TRANSMISSION) != 0) {
glBlendFunc(GL_ONE, GL_SRC_ALPHA);
}
- else if ((state & DRW_STATE_TRANSPARENT_REVEALAGE) != 0) {
- glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
+ else if ((state & DRW_STATE_BLEND_OIT) != 0) {
+ glBlendFuncSeparate(GL_ONE, GL_ONE, /* RGB */
+ GL_ZERO, GL_ONE_MINUS_SRC_ALPHA); /* Alpha */
}
else if ((state & DRW_STATE_ADDITIVE) != 0) {
/* Do not let alpha accumulate but premult the source RGB by it. */
@@ -516,12 +517,12 @@ static void draw_clipping_setup_from_view(void)
for (int p = 0; p < 6; p++) {
int q, r;
switch (p) {
- case 0: q = 1; r = 2; break;
- case 1: q = 0; r = 5; break;
- case 2: q = 1; r = 5; break;
- case 3: q = 2; r = 6; break;
- case 4: q = 0; r = 3; break;
- default: q = 4; r = 7; break;
+ case 0: q = 1; r = 2; break; /* -X */
+ case 1: q = 0; r = 5; break; /* -Y */
+ case 2: q = 1; r = 5; break; /* +Z (far) */
+ case 3: q = 2; r = 6; break; /* +Y */
+ case 4: q = 0; r = 3; break; /* -Z (near) */
+ default: q = 4; r = 7; break; /* +X */
}
if (DST.frontface == GL_CW) {
SWAP(int, q, r);
@@ -713,6 +714,13 @@ void DRW_culling_frustum_corners_get(BoundBox *corners)
memcpy(corners, &DST.clipping.frustum_corners, sizeof(BoundBox));
}
+/* See draw_clipping_setup_from_view() for the plane order. */
+void DRW_culling_frustum_planes_get(float planes[6][4])
+{
+ draw_clipping_setup_from_view();
+ memcpy(planes, &DST.clipping.frustum_planes, sizeof(DST.clipping.frustum_planes));
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -747,12 +755,14 @@ static void draw_matrices_model_prepare(DRWCallState *st)
}
/* No need to go further the call will not be used. */
- if (st->flag & DRW_CALL_CULLED)
+ if ((st->flag & DRW_CALL_CULLED) != 0 &&
+ (st->flag & DRW_CALL_BYPASS_CULLING) == 0)
+ {
return;
-
+ }
/* Order matters */
if (st->matflag & (DRW_CALL_MODELVIEW | DRW_CALL_MODELVIEWINVERSE |
- DRW_CALL_NORMALVIEW | DRW_CALL_EYEVEC))
+ DRW_CALL_NORMALVIEW | DRW_CALL_EYEVEC))
{
mul_m4_m4m4(st->modelview, DST.view_data.matstate.mat[DRW_MAT_VIEW], st->model);
}
@@ -820,6 +830,7 @@ static void draw_geometry_execute_ex(
DRWShadingGroup *shgroup, Gwn_Batch *geom, uint start, uint count, bool draw_instance)
{
/* Special case: empty drawcall, placement is done via shader, don't bind anything. */
+ /* TODO use DRW_CALL_PROCEDURAL instead */
if (geom == NULL) {
BLI_assert(shgroup->type == DRW_SHG_TRIANGLE_BATCH); /* Add other type if needed. */
/* Shader is already bound. */
@@ -1043,7 +1054,10 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
int *select_id = NULL; \
if (G.f & G_PICKSEL) { \
if (_shgroup->override_selectid == -1) { \
- select_id = DRW_instance_data_get(_shgroup->inst_selectid); \
+ /* Hack : get vbo data without actually drawing. */ \
+ Gwn_VertBufRaw raw; \
+ GWN_vertbuf_attr_get_raw_data(_shgroup->inst_selectid, 0, &raw); \
+ select_id = GWN_vertbuf_raw_step(&raw); \
switch (_shgroup->type) { \
case DRW_SHG_TRIANGLE_BATCH: _count = 3; break; \
case DRW_SHG_LINE_BATCH: _count = 2; break; \
@@ -1118,8 +1132,11 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
draw_visibility_eval(call->state);
draw_matrices_model_prepare(call->state);
- if ((call->state->flag & DRW_CALL_CULLED) != 0)
+ if ((call->state->flag & DRW_CALL_CULLED) != 0 &&
+ (call->state->flag & DRW_CALL_BYPASS_CULLING) == 0)
+ {
continue;
+ }
/* XXX small exception/optimisation for outline rendering. */
if (shgroup->callid != -1) {
@@ -1141,12 +1158,18 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
case DRW_CALL_SINGLE:
draw_geometry_execute(shgroup, call->single.geometry);
break;
+ case DRW_CALL_RANGE:
+ draw_geometry_execute_ex(shgroup, call->range.geometry, call->range.start, call->range.count, false);
+ break;
case DRW_CALL_INSTANCES:
draw_geometry_execute_ex(shgroup, call->instances.geometry, 0, *call->instances.count, true);
break;
case DRW_CALL_GENERATE:
call->generate.geometry_fn(shgroup, draw_geometry_execute, call->generate.user_data);
break;
+ case DRW_CALL_PROCEDURAL:
+ GWN_draw_primitive(call->procedural.prim_type, call->procedural.vert_count);
+ break;
default:
BLI_assert(0);
}
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c
index 77fcb766743..edc65afd465 100644
--- a/source/blender/draw/intern/draw_manager_shader.c
+++ b/source/blender/draw/intern/draw_manager_shader.c
@@ -47,6 +47,7 @@ extern char datatoc_gpu_shader_2D_vert_glsl[];
extern char datatoc_gpu_shader_3D_vert_glsl[];
extern char datatoc_common_fullscreen_vert_glsl[];
+#define USE_DEFERRED_COMPILATION 1
/* -------------------------------------------------------------------- */
@@ -61,7 +62,6 @@ typedef struct DRWDeferredShader {
struct DRWDeferredShader *prev, *next;
GPUMaterial *mat;
- char *vert, *geom, *frag, *defs;
} DRWDeferredShader;
typedef struct DRWShaderCompiler {
@@ -71,7 +71,7 @@ typedef struct DRWShaderCompiler {
DRWDeferredShader *mat_compiling;
ThreadMutex compilation_lock;
- void *ogl_context;
+ void *gl_context;
int shaders_done; /* To compute progress. */
} DRWShaderCompiler;
@@ -79,11 +79,6 @@ typedef struct DRWShaderCompiler {
static void drw_deferred_shader_free(DRWDeferredShader *dsh)
{
/* Make sure it is not queued before freeing. */
- MEM_SAFE_FREE(dsh->vert);
- MEM_SAFE_FREE(dsh->geom);
- MEM_SAFE_FREE(dsh->frag);
- MEM_SAFE_FREE(dsh->defs);
-
MEM_freeN(dsh);
}
@@ -98,9 +93,9 @@ static void drw_deferred_shader_queue_free(ListBase *queue)
static void drw_deferred_shader_compilation_exec(void *custom_data, short *stop, short *do_update, float *progress)
{
DRWShaderCompiler *comp = (DRWShaderCompiler *)custom_data;
- void *ogl_context = comp->ogl_context;
+ void *gl_context = comp->gl_context;
- WM_opengl_context_activate(ogl_context);
+ WM_opengl_context_activate(gl_context);
while (true) {
BLI_spin_lock(&comp->list_lock);
@@ -128,12 +123,7 @@ static void drw_deferred_shader_compilation_exec(void *custom_data, short *stop,
BLI_spin_unlock(&comp->list_lock);
/* Do the compilation. */
- GPU_material_generate_pass(
- comp->mat_compiling->mat,
- comp->mat_compiling->vert,
- comp->mat_compiling->geom,
- comp->mat_compiling->frag,
- comp->mat_compiling->defs);
+ GPU_material_compile(comp->mat_compiling->mat);
*progress = (float)comp->shaders_done / (float)total;
*do_update = true;
@@ -144,7 +134,7 @@ static void drw_deferred_shader_compilation_exec(void *custom_data, short *stop,
drw_deferred_shader_free(comp->mat_compiling);
}
- WM_opengl_context_release(ogl_context);
+ WM_opengl_context_release(gl_context);
}
static void drw_deferred_shader_compilation_free(void *custom_data)
@@ -156,33 +146,28 @@ static void drw_deferred_shader_compilation_free(void *custom_data)
BLI_spin_end(&comp->list_lock);
BLI_mutex_end(&comp->compilation_lock);
- if (comp->ogl_context) {
+ if (comp->gl_context) {
/* Only destroy if the job owns the context. */
- WM_opengl_context_dispose(comp->ogl_context);
+ WM_opengl_context_dispose(comp->gl_context);
}
MEM_freeN(comp);
}
-static void drw_deferred_shader_add(
- GPUMaterial *mat, const char *vert, const char *geom, const char *frag_lib, const char *defines)
+static void drw_deferred_shader_add(GPUMaterial *mat)
{
/* Do not deferre the compilation if we are rendering for image. */
- if (DRW_state_is_image_render()) {
+ if (DRW_state_is_image_render() || !USE_DEFERRED_COMPILATION) {
/* Double checking that this GPUMaterial is not going to be
* compiled by another thread. */
DRW_deferred_shader_remove(mat);
- GPU_material_generate_pass(mat, vert, geom, frag_lib, defines);
+ GPU_material_compile(mat);
return;
}
DRWDeferredShader *dsh = MEM_callocN(sizeof(DRWDeferredShader), "Deferred Shader");
dsh->mat = mat;
- if (vert) dsh->vert = BLI_strdup(vert);
- if (geom) dsh->geom = BLI_strdup(geom);
- if (frag_lib) dsh->frag = BLI_strdup(frag_lib);
- if (defines) dsh->defs = BLI_strdup(defines);
BLI_assert(DST.draw_ctx.evil_C);
wmWindowManager *wm = CTX_wm_manager(DST.draw_ctx.evil_C);
@@ -204,16 +189,16 @@ static void drw_deferred_shader_add(
BLI_movelisttolist(&comp->queue, &old_comp->queue);
BLI_spin_unlock(&old_comp->list_lock);
/* Do not recreate context, just pass ownership. */
- comp->ogl_context = old_comp->ogl_context;
- old_comp->ogl_context = NULL;
+ comp->gl_context = old_comp->gl_context;
+ old_comp->gl_context = NULL;
}
BLI_addtail(&comp->queue, dsh);
/* Create only one context. */
- if (comp->ogl_context == NULL) {
- comp->ogl_context = WM_opengl_context_create();
- WM_opengl_context_activate(DST.ogl_context);
+ if (comp->gl_context == NULL) {
+ comp->gl_context = WM_opengl_context_create();
+ WM_opengl_context_activate(DST.gl_context);
}
WM_jobs_customdata_set(wm_job, comp, drw_deferred_shader_compilation_free);
@@ -360,10 +345,13 @@ GPUMaterial *DRW_shader_create_from_world(
if (mat == NULL) {
mat = GPU_material_from_nodetree(
- scene, wo->nodetree, &wo->gpumaterial, engine_type, options);
+ scene, wo->nodetree, &wo->gpumaterial, engine_type, options,
+ vert, geom, frag_lib, defines);
}
- drw_deferred_shader_add(mat, vert, geom, frag_lib, defines);
+ if (GPU_material_status(mat) == GPU_MAT_QUEUED) {
+ drw_deferred_shader_add(mat);
+ }
return mat;
}
@@ -379,10 +367,13 @@ GPUMaterial *DRW_shader_create_from_material(
if (mat == NULL) {
mat = GPU_material_from_nodetree(
- scene, ma->nodetree, &ma->gpumaterial, engine_type, options);
+ scene, ma->nodetree, &ma->gpumaterial, engine_type, options,
+ vert, geom, frag_lib, defines);
}
- drw_deferred_shader_add(mat, vert, geom, frag_lib, defines);
+ if (GPU_material_status(mat) == GPU_MAT_QUEUED) {
+ drw_deferred_shader_add(mat);
+ }
return mat;
}
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index 726d77a9925..4bf2e65ce6f 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -28,6 +28,7 @@
#include "DNA_brush_types.h"
#include "DNA_screen_types.h"
#include "DNA_userdef_types.h"
+#include "DNA_world_types.h"
#include "DNA_view3d_types.h"
#include "ED_screen.h"
@@ -61,11 +62,13 @@ void DRW_draw_region_info(void)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
ARegion *ar = draw_ctx->ar;
- int offset;
+ int offset = 0;
DRW_draw_cursor();
- offset = DRW_draw_region_engine_info_offset();
+ if ((draw_ctx->v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) == 0) {
+ offset = DRW_draw_region_engine_info_offset();
+ }
view3d_draw_region_info(draw_ctx->evil_C, ar, offset);
@@ -558,12 +561,21 @@ void DRW_draw_grid(void)
void DRW_draw_background(void)
{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+
/* Just to make sure */
glDepthMask(GL_TRUE);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glStencilMask(0xFF);
- if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
+ if ((draw_ctx->v3d->flag3 & V3D_SHOW_WORLD) &&
+ (draw_ctx->scene->world != NULL))
+ {
+ const World *world = draw_ctx->scene->world;
+ glClearColor(world->horr, world->horg, world->horb, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+ }
+ else if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
float m[4][4];
unit_m4(m);
diff --git a/source/blender/draw/modes/draw_mode_engines.h b/source/blender/draw/modes/draw_mode_engines.h
index 9522e3cddc6..f88d49dfa96 100644
--- a/source/blender/draw/modes/draw_mode_engines.h
+++ b/source/blender/draw/modes/draw_mode_engines.h
@@ -34,6 +34,7 @@ extern DrawEngineType draw_engine_edit_mesh_type;
extern DrawEngineType draw_engine_edit_metaball_type;
extern DrawEngineType draw_engine_edit_surface_type;
extern DrawEngineType draw_engine_edit_text_type;
+extern DrawEngineType draw_engine_motion_path_type;
extern DrawEngineType draw_engine_paint_texture_type;
extern DrawEngineType draw_engine_paint_vertex_type;
extern DrawEngineType draw_engine_paint_weight_type;
diff --git a/source/blender/draw/modes/edit_curve_mode.c b/source/blender/draw/modes/edit_curve_mode.c
index 8e70de5dd9f..50ce29b7b1a 100644
--- a/source/blender/draw/modes/edit_curve_mode.c
+++ b/source/blender/draw/modes/edit_curve_mode.c
@@ -239,7 +239,7 @@ static void EDIT_CURVE_cache_populate(void *vedata, Object *ob)
#if 0
if (ob == draw_ctx->object_edit)
#else
- if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode_and_selected(ob))
+ if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode(ob))
#endif
{
Curve *cu = ob->data;
diff --git a/source/blender/draw/modes/edit_lattice_mode.c b/source/blender/draw/modes/edit_lattice_mode.c
index 77e648f1717..870dd14d677 100644
--- a/source/blender/draw/modes/edit_lattice_mode.c
+++ b/source/blender/draw/modes/edit_lattice_mode.c
@@ -194,7 +194,7 @@ static void EDIT_LATTICE_cache_populate(void *vedata, Object *ob)
UNUSED_VARS(psl);
if (ob->type == OB_LATTICE) {
- if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode_and_selected(ob)) {
+ if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode(ob)) {
/* Get geometry cache */
struct Gwn_Batch *geom;
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index f6e0267c25e..b50fb554a51 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -450,7 +450,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
struct Gwn_Batch *geom;
if (ob->type == OB_MESH) {
- if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode_and_selected(ob)) {
+ if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode(ob)) {
const Mesh *me = ob->data;
bool do_occlude_wire = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_OCCLUDE_WIRE) != 0;
bool do_show_weight = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_WEIGHT) != 0;
@@ -512,10 +512,13 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
if (me->drawflag & (ME_DRAWEXTRA_EDGELEN |
ME_DRAWEXTRA_FACEAREA |
ME_DRAWEXTRA_FACEANG |
- ME_DRAWEXTRA_EDGEANG))
+ ME_DRAWEXTRA_EDGEANG |
+ ME_DRAWEXTRA_INDICES))
{
- DRW_edit_mesh_mode_text_measure_stats(
- draw_ctx->ar, v3d, ob, &scene->unit);
+ if (DRW_state_show_text()) {
+ DRW_edit_mesh_mode_text_measure_stats(
+ draw_ctx->ar, v3d, ob, &scene->unit);
+ }
}
}
}
diff --git a/source/blender/draw/modes/edit_mesh_mode_text.c b/source/blender/draw/modes/edit_mesh_mode_text.c
index a832c61cab5..def96e79eba 100644
--- a/source/blender/draw/modes/edit_mesh_mode_text.c
+++ b/source/blender/draw/modes/edit_mesh_mode_text.c
@@ -84,7 +84,7 @@ void DRW_edit_mesh_mode_text_measure_stats(
else if (grid <= 10.0f) conv_float = "%.3g";
else conv_float = "%.2g";
- if (me->drawflag & (ME_DRAWEXTRA_EDGELEN | ME_DRAWEXTRA_EDGEANG)) {
+ if (me->drawflag & (ME_DRAWEXTRA_EDGELEN | ME_DRAWEXTRA_EDGEANG | ME_DRAWEXTRA_INDICES)) {
BoundBox bb;
const rcti rect = {0, ar->winx, 0, ar->winy};
@@ -298,4 +298,55 @@ void DRW_edit_mesh_mode_text_measure_stats(
}
}
}
+
+ /* This option is for mesh ops and addons debugging; only available in UI if Blender starts with --debug */
+ if (me->drawflag & ME_DRAWEXTRA_INDICES) {
+ int i;
+
+ /* For now, reuse an appropriate theme color */
+ UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
+
+ if (em->selectmode & SCE_SELECT_VERTEX) {
+ BMVert *v;
+
+ BM_ITER_MESH_INDEX(v, &iter, em->bm, BM_VERTS_OF_MESH, i) {
+ if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
+ numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
+ DRW_text_cache_add(dt, v->co, numstr, numstr_len, 0, txt_flag, col);
+ }
+ }
+ }
+
+ if (em->selectmode & SCE_SELECT_EDGE) {
+ BMEdge *e;
+
+ BM_ITER_MESH_INDEX(e, &iter, em->bm, BM_EDGES_OF_MESH, i) {
+ if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
+ float v1_clip[3], v2_clip[3];
+
+ copy_v3_v3(v1, e->v1->co);
+ copy_v3_v3(v2, e->v2->co);
+
+ if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4, v1_clip, v2_clip)) {
+ mid_v3_v3v3(vmid, v1_clip, v2_clip);
+ numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
+ DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, txt_flag, col);
+ }
+ }
+ }
+ }
+
+ if (em->selectmode & SCE_SELECT_FACE) {
+ BMFace *f;
+
+ BM_ITER_MESH_INDEX(f, &iter, em->bm, BM_FACES_OF_MESH, i) {
+ if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
+ BM_face_calc_center_mean(f, v1);
+
+ numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
+ DRW_text_cache_add(dt, v1, numstr, numstr_len, 0, txt_flag, col);
+ }
+ }
+ }
+ }
}
diff --git a/source/blender/draw/modes/edit_metaball_mode.c b/source/blender/draw/modes/edit_metaball_mode.c
index c0c4e7e4295..20539295fd2 100644
--- a/source/blender/draw/modes/edit_metaball_mode.c
+++ b/source/blender/draw/modes/edit_metaball_mode.c
@@ -136,7 +136,7 @@ static void EDIT_METABALL_cache_populate(void *vedata, Object *ob)
const DRWContextState *draw_ctx = DRW_context_state_get();
DRWShadingGroup *group = stl->g_data->group;
- if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode_and_selected(ob)) {
+ if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode(ob)) {
MetaBall *mb = ob->data;
const float *color;
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 52749a5429f..0b90b9276b4 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -47,6 +47,7 @@
#include "BKE_curve.h"
#include "BKE_global.h"
#include "BKE_mball.h"
+#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_image.h"
@@ -71,6 +72,8 @@ extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
extern struct GPUTexture *globals_ramp; /* draw_common.c */
extern GlobalsUboStorage ts;
+extern char datatoc_object_outline_prepass_vert_glsl[];
+extern char datatoc_object_outline_prepass_geom_glsl[];
extern char datatoc_object_outline_prepass_frag_glsl[];
extern char datatoc_object_outline_resolve_frag_glsl[];
extern char datatoc_object_outline_detect_frag_glsl[];
@@ -229,6 +232,9 @@ typedef struct OBJECT_PrivateData {
DRWShadingGroup *points_select;
DRWShadingGroup *points_transform;
+ /* Texture Space */
+ DRWShadingGroup *texspace;
+
/* Outlines id offset */
int id_ofs_active;
int id_ofs_select;
@@ -246,6 +252,7 @@ static struct {
/* fullscreen shaders */
GPUShader *outline_prepass_sh;
+ GPUShader *outline_prepass_wire_sh;
GPUShader *outline_resolve_sh;
GPUShader *outline_resolve_aa_sh;
GPUShader *outline_detect_sh;
@@ -337,6 +344,11 @@ static void OBJECT_engine_init(void *vedata)
/* Outline */
e_data.outline_prepass_sh = DRW_shader_create_3D(datatoc_object_outline_prepass_frag_glsl, NULL);
+ e_data.outline_prepass_wire_sh = DRW_shader_create(
+ datatoc_object_outline_prepass_vert_glsl,
+ datatoc_object_outline_prepass_geom_glsl,
+ datatoc_object_outline_prepass_frag_glsl, NULL);
+
e_data.outline_resolve_sh = DRW_shader_create_fullscreen(datatoc_object_outline_resolve_frag_glsl, NULL);
e_data.outline_resolve_aa_sh = DRW_shader_create_with_lib(
@@ -576,6 +588,7 @@ static void OBJECT_engine_free(void)
MEM_SAFE_FREE(e_data.empty_image_format);
MEM_SAFE_FREE(e_data.empty_image_wire_format);
DRW_SHADER_FREE_SAFE(e_data.outline_prepass_sh);
+ DRW_SHADER_FREE_SAFE(e_data.outline_prepass_wire_sh);
DRW_SHADER_FREE_SAFE(e_data.outline_resolve_sh);
DRW_SHADER_FREE_SAFE(e_data.outline_resolve_aa_sh);
DRW_SHADER_FREE_SAFE(e_data.outline_detect_sh);
@@ -850,6 +863,7 @@ static void OBJECT_cache_init(void *vedata)
OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl;
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
OBJECT_PrivateData *g_data;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
/* TODO : use dpi setting for enabling the second pass */
const bool do_outline_expand = false;
@@ -866,13 +880,12 @@ static void OBJECT_cache_init(void *vedata)
GPUShader *sh = e_data.outline_prepass_sh;
- /* Select */
- g_data->outlines_select = shgroup_outline(psl->outlines, &g_data->id_ofs_select, sh);
+ if (draw_ctx->v3d->shading.flag & V3D_SHADING_XRAY) {
+ sh = e_data.outline_prepass_wire_sh;
+ }
- /* Transform */
+ g_data->outlines_select = shgroup_outline(psl->outlines, &g_data->id_ofs_select, sh);
g_data->outlines_transform = shgroup_outline(psl->outlines, &g_data->id_ofs_transform, sh);
-
- /* Active */
g_data->outlines_active = shgroup_outline(psl->outlines, &g_data->id_ofs_active, sh);
g_data->id_ofs_select = 0;
@@ -1105,6 +1118,9 @@ static void OBJECT_cache_init(void *vedata)
stl->g_data->camera_clip_points = shgroup_distance_lines_instance(psl->non_meshes, geom);
stl->g_data->camera_mist_points = shgroup_distance_lines_instance(psl->non_meshes, geom);
+ /* Texture Space */
+ geom = DRW_cache_cube_get();
+ stl->g_data->texspace = shgroup_instance(psl->non_meshes, geom);
}
{
@@ -1888,8 +1904,13 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl
static void DRW_shgroup_relationship_lines(OBJECT_StorageList *stl, Object *ob)
{
if (ob->parent && DRW_check_object_visible_within_active_context(ob->parent)) {
- DRW_shgroup_call_dynamic_add(stl->g_data->relationship_lines, ob->parent->obmat[3]);
- DRW_shgroup_call_dynamic_add(stl->g_data->relationship_lines, ob->obmat[3]);
+ /* Only draw relationship lines when object or its parent are selected
+ * as a way of reducing visual clutter.
+ */
+ if ((ob->base_flag & BASE_SELECTED) || (ob->parent->base_flag & BASE_SELECTED)) {
+ DRW_shgroup_call_dynamic_add(stl->g_data->relationship_lines, ob->parent->obmat[3]);
+ DRW_shgroup_call_dynamic_add(stl->g_data->relationship_lines, ob->obmat[3]);
+ }
}
}
@@ -1924,6 +1945,59 @@ static void DRW_shgroup_object_center(OBJECT_StorageList *stl, Object *ob, ViewL
DRW_shgroup_call_dynamic_add(shgroup, ob->obmat[3]);
}
+static void DRW_shgroup_texture_space(OBJECT_StorageList *stl, Object *ob, int theme_id)
+{
+ if (ob->data == NULL) {
+ return;
+ }
+
+ ID *ob_data = ob->data;
+ float *texcoloc = NULL;
+ float *texcosize = NULL;
+ if (ob->data != NULL) {
+ switch (GS(ob_data->name)) {
+ case ID_ME:
+ BKE_mesh_texspace_get_reference((Mesh *)ob_data, NULL, &texcoloc, NULL, &texcosize);
+ break;
+ case ID_CU:
+ {
+ Curve *cu = (Curve *)ob_data;
+ if (cu->bb == NULL || (cu->bb->flag & BOUNDBOX_DIRTY)) {
+ BKE_curve_texspace_calc(cu);
+ }
+ texcoloc = cu->loc;
+ texcosize = cu->size;
+ break;
+ }
+ case ID_MB:
+ {
+ MetaBall *mb = (MetaBall *)ob_data;
+ texcoloc = mb->loc;
+ texcosize = mb->size;
+ break;
+ }
+ default:
+ BLI_assert(0);
+ }
+ }
+
+ float tmp[4][4] = {{0.0f}}, one = 1.0f;
+ tmp[0][0] = texcosize[0];
+ tmp[1][1] = texcosize[1];
+ tmp[2][2] = texcosize[2];
+ tmp[3][0] = texcoloc[0];
+ tmp[3][1] = texcoloc[1];
+ tmp[3][2] = texcoloc[2];
+ tmp[3][3] = 1.0f;
+
+ mul_m4_m4m4(tmp, ob->obmat, tmp);
+
+ float color[4];
+ UI_GetThemeColor4fv(theme_id, color);
+
+ DRW_shgroup_call_dynamic_add(stl->g_data->texspace, color, &one, tmp);
+}
+
static void OBJECT_cache_populate_particles(Object *ob,
OBJECT_PassList *psl)
{
@@ -1932,16 +2006,12 @@ static void OBJECT_cache_populate_particles(Object *ob,
continue;
}
if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
- return;
+ continue;
}
ParticleSettings *part = psys->part;
int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
- if (draw_as == PART_DRAW_PATH && !psys->pathcache && !psys->childcache) {
- draw_as = PART_DRAW_DOT;
- }
-
static float mat[4][4];
unit_m4(mat);
@@ -2022,10 +2092,17 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
}
bool do_outlines = ((ob->base_flag & BASE_SELECTED) != 0);
+ bool show_relations = ((draw_ctx->v3d->flag & V3D_HIDE_HELPLINES) == 0);
if (do_outlines) {
if ((ob != draw_ctx->object_edit) && !((ob == draw_ctx->obact) && (draw_ctx->object_mode & OB_MODE_ALL_PAINT))) {
- struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
+ struct Gwn_Batch *geom;
+ if (v3d->shading.flag & V3D_SHADING_XRAY) {
+ geom = DRW_cache_object_edge_detection_get(ob, NULL);
+ }
+ else {
+ geom = DRW_cache_object_surface_get(ob);
+ }
if (geom) {
theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
DRWShadingGroup *shgroup = shgroup_theme_id_to_outline_or(stl, theme_id, NULL);
@@ -2041,28 +2118,26 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
{
if (ob != draw_ctx->object_edit) {
Mesh *me = ob->data;
- if (me->totpoly == 0) {
- if (me->totedge == 0) {
- struct Gwn_Batch *geom = DRW_cache_mesh_verts_get(ob);
- if (geom) {
- if (theme_id == TH_UNDEFINED) {
- theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
- }
-
- DRWShadingGroup *shgroup = shgroup_theme_id_to_point_or(stl, theme_id, stl->g_data->points);
- DRW_shgroup_call_object_add(shgroup, geom, ob);
+ if (me->totedge == 0) {
+ struct Gwn_Batch *geom = DRW_cache_mesh_verts_get(ob);
+ if (geom) {
+ if (theme_id == TH_UNDEFINED) {
+ theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
}
+
+ DRWShadingGroup *shgroup = shgroup_theme_id_to_point_or(stl, theme_id, stl->g_data->points);
+ DRW_shgroup_call_object_add(shgroup, geom, ob);
}
- else {
- struct Gwn_Batch *geom = DRW_cache_mesh_edges_get(ob);
- if (geom) {
- if (theme_id == TH_UNDEFINED) {
- theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
- }
-
- DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(stl, theme_id, stl->g_data->wire);
- DRW_shgroup_call_object_add(shgroup, geom, ob);
+ }
+ else {
+ struct Gwn_Batch *geom = DRW_cache_mesh_loose_edges_get(ob);
+ if (geom) {
+ if (theme_id == TH_UNDEFINED) {
+ theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
}
+
+ DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(stl, theme_id, stl->g_data->wire);
+ DRW_shgroup_call_object_add(shgroup, geom, ob);
}
}
}
@@ -2149,13 +2224,16 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
DRW_shgroup_object_center(stl, ob, view_layer, v3d);
- DRW_shgroup_relationship_lines(stl, ob);
+ if (show_relations) {
+ DRW_shgroup_relationship_lines(stl, ob);
+ }
+
+ if ((ob->dtx != 0) && theme_id == TH_UNDEFINED) {
+ theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
+ }
if ((ob->dtx & OB_DRAWNAME) && DRW_state_show_text()) {
struct DRWTextStore *dt = DRW_text_cache_ensure();
- if (theme_id == TH_UNDEFINED) {
- theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
- }
unsigned char color[4];
UI_GetThemeColor4ubv(theme_id, color);
@@ -2165,6 +2243,10 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
ob->id.name + 2, strlen(ob->id.name + 2),
10, DRW_TEXT_CACHE_GLOBALSPACE | DRW_TEXT_CACHE_STRING_PTR, color);
}
+
+ if ((ob->dtx & OB_TEXSPACE) && ELEM(ob->type, OB_MESH, OB_CURVE, OB_MBALL)) {
+ DRW_shgroup_texture_space(stl, ob, theme_id);
+ }
}
}
diff --git a/source/blender/draw/modes/overlay_mode.c b/source/blender/draw/modes/overlay_mode.c
index c4b64e03c48..97403b14ac5 100644
--- a/source/blender/draw/modes/overlay_mode.c
+++ b/source/blender/draw/modes/overlay_mode.c
@@ -25,7 +25,10 @@
#include "DNA_view3d_types.h"
+#include "BKE_object.h"
+
#include "GPU_shader.h"
+#include "GPU_extensions.h"
#include "DRW_render.h"
#include "draw_mode_engines.h"
@@ -37,6 +40,7 @@ typedef struct OVERLAY_StorageList {
typedef struct OVERLAY_PassList {
struct DRWPass *face_orientation_pass;
+ struct DRWPass *face_wireframe_pass;
} OVERLAY_PassList;
typedef struct OVERLAY_Data {
@@ -48,20 +52,30 @@ typedef struct OVERLAY_Data {
} OVERLAY_Data;
typedef struct OVERLAY_PrivateData {
+ GPUShader *wire_sh; /* reference */
DRWShadingGroup *face_orientation_shgrp;
View3DOverlay overlay;
+ float wire_step_param[2];
} OVERLAY_PrivateData; /* Transient data */
/* *********** STATIC *********** */
static struct {
/* Face orientation shader */
struct GPUShader *face_orientation_sh;
+ /* Wireframe shader */
+ struct GPUShader *face_wireframe_sh;
+ struct GPUShader *face_wireframe_pretty_sh;
} e_data = {NULL};
/* Shaders */
extern char datatoc_overlay_face_orientation_frag_glsl[];
extern char datatoc_overlay_face_orientation_vert_glsl[];
+extern char datatoc_overlay_face_wireframe_vert_glsl[];
+extern char datatoc_overlay_face_wireframe_geom_glsl[];
+extern char datatoc_overlay_face_wireframe_frag_glsl[];
+
+extern struct GlobalsUboStorage ts; /* draw_common.c */
/* Functions */
static void overlay_engine_init(void *vedata)
@@ -77,7 +91,27 @@ static void overlay_engine_init(void *vedata)
if (!e_data.face_orientation_sh) {
/* Face orientation */
e_data.face_orientation_sh = DRW_shader_create(
- datatoc_overlay_face_orientation_vert_glsl, NULL, datatoc_overlay_face_orientation_frag_glsl, "\n");
+ datatoc_overlay_face_orientation_vert_glsl, NULL,
+ datatoc_overlay_face_orientation_frag_glsl, NULL);
+ }
+
+ if (!e_data.face_wireframe_sh) {
+ bool use_geom = GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY);
+
+ e_data.face_wireframe_sh = DRW_shader_create(
+ datatoc_overlay_face_wireframe_vert_glsl,
+ use_geom ? datatoc_overlay_face_wireframe_geom_glsl : NULL,
+ datatoc_overlay_face_wireframe_frag_glsl,
+ use_geom ? "#define USE_GEOM_SHADER\n"
+ : NULL);
+
+ e_data.face_wireframe_pretty_sh = DRW_shader_create(
+ datatoc_overlay_face_wireframe_vert_glsl,
+ use_geom ? datatoc_overlay_face_wireframe_geom_glsl : NULL,
+ datatoc_overlay_face_wireframe_frag_glsl,
+ use_geom ? "#define USE_GEOM_SHADER\n"
+ "#define LIGHT_EDGES\n"
+ : "#define LIGHT_EDGES\n");
}
}
@@ -99,11 +133,34 @@ static void overlay_cache_init(void *vedata)
/* Face Orientation Pass */
if (stl->g_data->overlay.flag & V3D_OVERLAY_FACE_ORIENTATION) {
- int state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND;
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND;
psl->face_orientation_pass = DRW_pass_create("Face Orientation", state);
stl->g_data->face_orientation_shgrp = DRW_shgroup_create(
e_data.face_orientation_sh, psl->face_orientation_pass);
}
+ if (stl->g_data->overlay.flag & V3D_OVERLAY_WIREFRAMES) {
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND;
+ psl->face_wireframe_pass = DRW_pass_create("Face Wires", state);
+ /* Sticky uniforms (don't need to respecify each time since shader does not change). */
+ stl->g_data->wire_sh = (stl->g_data->overlay.wireframe_threshold == 1.0f) ? e_data.face_wireframe_sh
+ : e_data.face_wireframe_pretty_sh;
+ DRWShadingGroup *shgrp = DRW_shgroup_create(stl->g_data->wire_sh, psl->face_wireframe_pass);
+ DRW_shgroup_uniform_vec2(shgrp, "viewportSize", DRW_viewport_size_get(), 1);
+ DRW_shgroup_uniform_vec2(shgrp, "wireStepParam", stl->g_data->wire_step_param, 1);
+
+ /**
+ * The wireframe threshold ranges from 0.0 to 1.0
+ * When 1.0 we show all the edges, when 0.5 we show as many as 2.7.
+ *
+ * If we wanted 0.0 to match 2.7, factor would need to be 0.003f.
+ * The range controls the falloff effect. If range was 0.0f we would get a hard cut (as in 2.7).
+ * That said we are using a different algorithm so the results will always differ.
+ */
+ const float factor = 0.0045f;
+ const float range = 0.00125f;
+ stl->g_data->wire_step_param[1] = (1.0f - factor) + stl->g_data->overlay.wireframe_threshold * factor;
+ stl->g_data->wire_step_param[0] = stl->g_data->wire_step_param[1] + range;
+ }
}
static void overlay_cache_populate(void *vedata, Object *ob)
@@ -111,17 +168,39 @@ static void overlay_cache_populate(void *vedata, Object *ob)
OVERLAY_Data * data = (OVERLAY_Data *)vedata;
OVERLAY_StorageList *stl = data->stl;
OVERLAY_PrivateData *pd = stl->g_data;
+ OVERLAY_PassList *psl = data->psl;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
if (!DRW_object_is_renderable(ob))
return;
- struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
- if (geom) {
- /* Face Orientation */
- if (stl->g_data->overlay.flag & V3D_OVERLAY_FACE_ORIENTATION) {
+ if (stl->g_data->overlay.flag & V3D_OVERLAY_FACE_ORIENTATION) {
+ struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
+ if (geom) {
DRW_shgroup_call_add(pd->face_orientation_shgrp, geom, ob->obmat);
}
}
+
+ if (stl->g_data->overlay.flag & V3D_OVERLAY_WIREFRAMES) {
+ /* Don't do that in edit mode. */
+ if ((ob != draw_ctx->object_edit) && !BKE_object_is_in_editmode(ob)) {
+ int tri_count;
+ GPUTexture *verts = NULL, *faceids;
+ DRW_cache_object_face_wireframe_get(ob, &verts, &faceids, &tri_count);
+ if (verts) {
+ float *rim_col = ts.colorWire;
+ if ((ob->base_flag & BASE_SELECTED) != 0) {
+ rim_col = (ob == draw_ctx->obact) ? ts.colorActive : ts.colorSelect;
+ }
+ DRWShadingGroup *shgrp = DRW_shgroup_create(stl->g_data->wire_sh, psl->face_wireframe_pass);
+ DRW_shgroup_uniform_texture(shgrp, "vertData", verts);
+ DRW_shgroup_uniform_texture(shgrp, "faceIds", faceids);
+ DRW_shgroup_uniform_vec3(shgrp, "wireColor", ts.colorWire, 1);
+ DRW_shgroup_uniform_vec3(shgrp, "rimColor", rim_col, 1);
+ DRW_shgroup_call_object_procedural_triangles_culled_add(shgrp, tri_count, ob);
+ }
+ }
+ }
}
static void overlay_cache_finish(void *UNUSED(vedata))
@@ -138,11 +217,16 @@ static void overlay_draw_scene(void *vedata)
if (pd->overlay.flag & V3D_OVERLAY_FACE_ORIENTATION) {
DRW_draw_pass(psl->face_orientation_pass);
}
+ if (pd->overlay.flag & V3D_OVERLAY_WIREFRAMES) {
+ DRW_draw_pass(psl->face_wireframe_pass);
+ }
}
static void overlay_engine_free(void)
{
DRW_SHADER_FREE_SAFE(e_data.face_orientation_sh);
+ DRW_SHADER_FREE_SAFE(e_data.face_wireframe_sh);
+ DRW_SHADER_FREE_SAFE(e_data.face_wireframe_pretty_sh);
}
static const DrawEngineDataSize overlay_data_size = DRW_VIEWPORT_DATA_SIZE(OVERLAY_Data);
diff --git a/source/blender/draw/modes/particle_mode.c b/source/blender/draw/modes/particle_mode.c
index dacd4b72834..19c3ddd4b50 100644
--- a/source/blender/draw/modes/particle_mode.c
+++ b/source/blender/draw/modes/particle_mode.c
@@ -183,6 +183,12 @@ static void particle_cache_populate(void *vedata, Object *object)
Object *object_orig = DEG_get_original_object(object);
PTCacheEdit *edit = PE_create_current(
draw_ctx->depsgraph, scene_orig, object_orig);
+ if (edit == NULL) {
+ /* Happens when trying to edit particles in EMITTER mode without
+ * having them cached.
+ */
+ return;
+ }
/* NOTE: We need to pass evaluated particle system, which we need
* to find first.
*/
diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c
index 1fe6549c73c..ad9567cd9c0 100644
--- a/source/blender/draw/modes/pose_mode.c
+++ b/source/blender/draw/modes/pose_mode.c
@@ -72,13 +72,15 @@ typedef struct POSE_Data {
typedef struct POSE_PrivateData {
DRWShadingGroup *bone_selection_shgrp;
+ DRWShadingGroup *bone_selection_invert_shgrp;
+ float blend_color[4];
+ float blend_color_invert[4];
} POSE_PrivateData; /* Transient data */
static struct {
struct GPUShader *bone_selection_sh;
} e_data = {NULL};
-static float blend_color[4] = {0.0, 0.0, 0.0, 0.5};
/* *********** FUNCTIONS *********** */
static bool POSE_is_bone_selection_overlay_active(void)
@@ -105,11 +107,14 @@ static void POSE_cache_init(void *vedata)
{
POSE_PassList *psl = ((POSE_Data *)vedata)->psl;
POSE_StorageList *stl = ((POSE_Data *)vedata)->stl;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ View3D *v3d = draw_ctx->v3d;
if (!stl->g_data) {
/* Alloc transient pointers */
stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
}
+ POSE_PrivateData *ppd = stl->g_data;
{
/* Solid bones */
@@ -150,13 +155,18 @@ static void POSE_cache_init(void *vedata)
{
if (POSE_is_bone_selection_overlay_active()) {
+ copy_v4_fl4(ppd->blend_color, 0.0f, 0.0f, 0.0f, v3d->overlay.bone_selection_alpha);
+ copy_v4_fl4(ppd->blend_color_invert, 0.0f, 0.0f, 0.0f, pow(v3d->overlay.bone_selection_alpha, 4));
DRWShadingGroup *grp;
psl->bone_selection = DRW_pass_create(
"Bone Selection",
DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND);
grp = DRW_shgroup_create(e_data.bone_selection_sh, psl->bone_selection);
- DRW_shgroup_uniform_vec4(grp, "color", blend_color, 1);
+ DRW_shgroup_uniform_vec4(grp, "color", ppd->blend_color, 1);
stl->g_data->bone_selection_shgrp = grp;
+ grp = DRW_shgroup_create(e_data.bone_selection_sh, psl->bone_selection);
+ DRW_shgroup_uniform_vec4(grp, "color", ppd->blend_color_invert, 1);
+ stl->g_data->bone_selection_invert_shgrp = grp;
}
}
}
@@ -206,12 +216,16 @@ static void POSE_cache_populate(void *vedata, Object *ob)
}
else if (ob->type == OB_MESH &&
!DRW_state_is_select() &&
- POSE_is_bone_selection_overlay_active() &&
- POSE_is_driven_by_active_armature(ob))
+ POSE_is_bone_selection_overlay_active())
{
struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
if (geom) {
- DRW_shgroup_call_object_add(stl->g_data->bone_selection_shgrp, geom, ob);
+ if (POSE_is_driven_by_active_armature(ob)) {
+ DRW_shgroup_call_object_add(stl->g_data->bone_selection_shgrp, geom, ob);
+ }
+ else {
+ DRW_shgroup_call_object_add(stl->g_data->bone_selection_invert_shgrp, geom, ob);
+ }
}
}
}
@@ -224,7 +238,7 @@ bool DRW_pose_mode_armature(Object *ob, Object *active_ob)
const DRWContextState *draw_ctx = DRW_context_state_get();
/* Pose armature is handled by pose mode engine. */
- if (((ob == active_ob) || (ob->base_flag & BASE_SELECTED)) &&
+ if (((ob == active_ob) || (ob->mode & OB_MODE_POSE)) &&
((draw_ctx->object_mode & OB_MODE_POSE) != 0))
{
return true;
diff --git a/source/blender/draw/modes/shaders/animviz_mpath_lines_geom.glsl b/source/blender/draw/modes/shaders/animviz_mpath_lines_geom.glsl
new file mode 100644
index 00000000000..d9d59880e99
--- /dev/null
+++ b/source/blender/draw/modes/shaders/animviz_mpath_lines_geom.glsl
@@ -0,0 +1,38 @@
+
+layout(lines) in;
+layout(triangle_strip, max_vertices = 4) out;
+
+uniform mat4 ProjectionMatrix;
+uniform vec2 viewportSize;
+uniform int lineThickness = 2;
+
+in vec4 finalColor_geom[];
+in vec2 ssPos[];
+
+out vec4 finalColor;
+
+vec2 compute_dir(vec2 v0, vec2 v1)
+{
+ vec2 dir = normalize(v1 - v0 + 1e-8);
+ dir = vec2(-dir.y, dir.x);
+ return dir;
+}
+
+void main(void)
+{
+ vec2 t;
+ vec2 edge_dir = compute_dir(ssPos[0], ssPos[1]) / viewportSize;
+
+ bool is_persp = (ProjectionMatrix[3][3] == 0.0);
+
+ finalColor = finalColor_geom[0];
+ t = edge_dir * (float(lineThickness) * (is_persp ? gl_in[0].gl_Position.w : 1.0));
+ gl_Position = gl_in[0].gl_Position + vec4(t, 0.0, 0.0); EmitVertex();
+ gl_Position = gl_in[0].gl_Position - vec4(t, 0.0, 0.0); EmitVertex();
+
+ finalColor = finalColor_geom[1];
+ t = edge_dir * (float(lineThickness) * (is_persp ? gl_in[1].gl_Position.w : 1.0));
+ gl_Position = gl_in[1].gl_Position + vec4(t, 0.0, 0.0); EmitVertex();
+ gl_Position = gl_in[1].gl_Position - vec4(t, 0.0, 0.0); EmitVertex();
+ EndPrimitive();
+}
diff --git a/source/blender/draw/modes/shaders/animviz_mpath_lines_vert.glsl b/source/blender/draw/modes/shaders/animviz_mpath_lines_vert.glsl
new file mode 100644
index 00000000000..276f4004fb6
--- /dev/null
+++ b/source/blender/draw/modes/shaders/animviz_mpath_lines_vert.glsl
@@ -0,0 +1,91 @@
+
+uniform mat4 ViewMatrix;
+uniform mat4 ViewProjectionMatrix;
+uniform vec2 viewportSize;
+
+uniform int frameCurrent;
+uniform int frameStart;
+uniform int frameEnd;
+uniform int cacheStart;
+uniform bool selected;
+uniform bool useCustomColor;
+uniform vec3 customColor;
+
+in vec3 pos;
+
+out vec2 ssPos;
+out vec4 finalColor_geom;
+
+/* project to screen space */
+vec2 proj(vec4 pos)
+{
+ return (0.5 * (pos.xy / pos.w) + 0.5) * viewportSize;
+}
+
+#define SET_INTENSITY(A, B, C, min, max) (((1.0 - (float(C - B) / float(C - A))) * (max - min)) + min)
+
+void main()
+{
+ gl_Position = ViewProjectionMatrix * vec4(pos, 1.0);
+
+ ssPos = proj(gl_Position);
+
+ int frame = gl_VertexID + cacheStart;
+
+ float intensity; /* how faint */
+
+ vec3 blend_base = (abs(frame - frameCurrent) == 1) ? colorCurrentFrame.rgb : colorBackground.rgb; /* "bleed" cframe color to ease color blending */
+
+ /* TODO: We might want something more consistent with custom color and standard colors. */
+ if (frame < frameCurrent) {
+ if (useCustomColor) {
+ /* Custom color: previous frames color is darker than current frame */
+ finalColor_geom.rgb = customColor * 0.25;
+ }
+ else {
+ /* black - before frameCurrent */
+ if (selected) {
+ intensity = SET_INTENSITY(frameStart, frame, frameCurrent, 0.25, 0.75);
+ }
+ else {
+ intensity = SET_INTENSITY(frameStart, frame, frameCurrent, 0.68, 0.92);
+ }
+ finalColor_geom.rgb = mix(colorWire.rgb, blend_base, intensity);
+ }
+ }
+ else if (frame > frameCurrent) {
+ if (useCustomColor) {
+ /* Custom color: next frames color is equal to user selected color */
+ finalColor_geom.rgb = customColor;
+ }
+ else {
+ /* blue - after frameCurrent */
+ if (selected) {
+ intensity = SET_INTENSITY(frameCurrent, frame, frameEnd, 0.25, 0.75);
+ }
+ else {
+ intensity = SET_INTENSITY(frameCurrent, frame, frameEnd, 0.68, 0.92);
+ }
+
+ finalColor_geom.rgb = mix(colorBonePose.rgb, blend_base, intensity);
+ }
+ }
+ else {
+ if (useCustomColor) {
+ /* Custom color: current frame color is slightly darker than user selected color */
+ finalColor_geom.rgb = customColor * 0.5;
+ }
+ else {
+ /* green - on frameCurrent */
+ if (selected) {
+ intensity = 0.5f;
+ }
+ else {
+ intensity = 0.99f;
+ }
+ finalColor_geom.rgb = clamp(mix(colorCurrentFrame.rgb, colorBackground.rgb, intensity) - 0.1, 0.0, 0.1);
+ }
+ }
+
+ finalColor_geom.a = 1.0;
+}
diff --git a/source/blender/draw/modes/shaders/animviz_mpath_points_vert.glsl b/source/blender/draw/modes/shaders/animviz_mpath_points_vert.glsl
new file mode 100644
index 00000000000..3b2f170ca22
--- /dev/null
+++ b/source/blender/draw/modes/shaders/animviz_mpath_points_vert.glsl
@@ -0,0 +1,47 @@
+
+uniform mat4 ViewProjectionMatrix;
+
+uniform int pointSize = 2;
+uniform int frameCurrent;
+uniform int cacheStart;
+uniform bool showKeyFrames = true;
+uniform bool useCustomColor;
+uniform vec3 customColor;
+
+in vec3 pos;
+in int flag;
+
+#define MOTIONPATH_VERT_SEL (1 << 0)
+#define MOTIONPATH_VERT_KEY (1 << 1)
+
+out vec4 finalColor;
+
+void main()
+{
+ gl_Position = ViewProjectionMatrix * vec4(pos, 1.0);
+ gl_PointSize = float(pointSize + 2);
+
+ int frame = gl_VertexID + cacheStart;
+ finalColor = (useCustomColor) ? vec4(customColor, 1.0) : vec4(1.0);
+
+ /* Bias to reduce z fighting with the path */
+ gl_Position.z -= 1e-4;
+
+ if (showKeyFrames) {
+ if ((flag & MOTIONPATH_VERT_KEY) != 0) {
+ gl_PointSize = float(pointSize + 5);
+ finalColor = colorVertexSelect;
+ /* Bias more to get these on top of regular points */
+ gl_Position.z -= 1e-4;
+ }
+ /* Draw big green dot where the current frame is.
+ * NOTE: this is only done when keyframes are shown, since this adds similar types of clutter
+ */
+ if (frame == frameCurrent) {
+ gl_PointSize = float(pointSize + 8);
+ finalColor = colorCurrentFrame;
+ /* Bias more to get these on top of keyframes */
+ gl_Position.z -= 1e-4;
+ }
+ }
+}
diff --git a/source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl b/source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl
index 11924b19cf8..4d6f3e94693 100644
--- a/source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl
+++ b/source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl
@@ -69,7 +69,7 @@ void main(void)
return;
/* Don't outline if concave edge. */
- if (dot(n0, v13) > 0.0)
+ if (dot(n0, v13) > 0.0001)
return;
vec2 thick = vColSize[0].w * (lineThickness / viewportSize);
diff --git a/source/blender/draw/modes/shaders/common_globals_lib.glsl b/source/blender/draw/modes/shaders/common_globals_lib.glsl
index 4a0104e2cf2..c55457bb6d2 100644
--- a/source/blender/draw/modes/shaders/common_globals_lib.glsl
+++ b/source/blender/draw/modes/shaders/common_globals_lib.glsl
@@ -48,6 +48,10 @@ layout(std140) uniform globalsBlock {
vec4 colorNurbSelUline;
vec4 colorActiveSpline;
+ vec4 colorBonePose;
+
+ vec4 colorCurrentFrame;
+
vec4 colorGrid;
vec4 colorGridEmphasise;
vec4 colorGridAxisX;
diff --git a/source/blender/draw/modes/shaders/common_hair_lib.glsl b/source/blender/draw/modes/shaders/common_hair_lib.glsl
new file mode 100644
index 00000000000..552690ba972
--- /dev/null
+++ b/source/blender/draw/modes/shaders/common_hair_lib.glsl
@@ -0,0 +1,190 @@
+/**
+ * Library to create hairs dynamically from control points.
+ * This is less bandwidth intensive than fetching the vertex attributes
+ * but does more ALU work per vertex. This also reduce the number
+ * of data the CPU has to precompute and transfert for each update.
+ **/
+
+/**
+ * hairStrandsRes: Number of points per hair strand.
+ * 2 - no subdivision
+ * 3+ - 1 or more interpolated points per hair.
+ **/
+uniform int hairStrandsRes = 8;
+
+/**
+ * hairThicknessRes : Subdiv around the hair.
+ * 1 - Wire Hair: Only one pixel thick, independant of view distance.
+ * 2 - Polystrip Hair: Correct width, flat if camera is parallel.
+ * 3+ - Cylinder Hair: Massive calculation but potentially perfect. Still need proper support.
+ **/
+uniform int hairThicknessRes = 1;
+
+/* Hair thickness shape. */
+uniform float hairRadRoot = 0.01;
+uniform float hairRadTip = 0.0;
+uniform float hairRadShape = 0.5;
+uniform bool hairCloseTip = true;
+
+/* -- Per control points -- */
+uniform samplerBuffer hairPointBuffer; /* RGBA32F */
+#define point_position xyz
+#define point_time w /* Position along the hair length */
+
+/* -- Per strands data -- */
+uniform usamplerBuffer hairStrandBuffer; /* R32UI */
+
+/* Not used, use one buffer per uv layer */
+//uniform samplerBuffer hairUVBuffer; /* RG32F */
+//uniform samplerBuffer hairColBuffer; /* RGBA16 linear color */
+
+void unpack_strand_data(uint data, out int strand_offset, out int strand_segments)
+{
+#if 0 /* Pack point count */
+ // strand_offset = (data & 0x1FFFFFFFu);
+ // strand_segments = 1u << (data >> 29u); /* We only need 3 bits to store subdivision level. */
+#else
+ strand_offset = int(data & 0x00FFFFFFu);
+ strand_segments = int(data >> 24u);
+#endif
+}
+
+/* -- Subdivision stage -- */
+/**
+ * We use a transform feedback to preprocess the strands and add more subdivision to it.
+ * For the moment theses are simple smooth interpolation but one could hope to see the full
+ * children particle modifiers being evaluated at this stage.
+ *
+ * If no more subdivision is needed, we can skip this step.
+ **/
+
+#ifdef HAIR_PHASE_SUBDIV
+int hair_get_base_id(float local_time, int strand_segments, out float interp_time)
+{
+ float time_per_strand_seg = 1.0 / float(strand_segments);
+
+ float ratio = local_time / time_per_strand_seg;
+ interp_time = fract(ratio);
+
+ return int(ratio);
+}
+
+void hair_get_interp_attribs(out vec4 data0, out vec4 data1, out vec4 data2, out vec4 data3, out float interp_time)
+{
+ float local_time = float(gl_VertexID % hairStrandsRes) / float(hairStrandsRes - 1);
+
+ int hair_id = gl_VertexID / hairStrandsRes;
+ uint strand_data = texelFetch(hairStrandBuffer, hair_id).x;
+
+ int strand_offset, strand_segments;
+ unpack_strand_data(strand_data, strand_offset, strand_segments);
+
+ int id = hair_get_base_id(local_time, strand_segments, interp_time);
+
+ int ofs_id = id + strand_offset;
+
+ data0 = texelFetch(hairPointBuffer, ofs_id - 1);
+ data1 = texelFetch(hairPointBuffer, ofs_id);
+ data2 = texelFetch(hairPointBuffer, ofs_id + 1);
+ data3 = texelFetch(hairPointBuffer, ofs_id + 2);
+
+ if (id <= 0) {
+ /* root points. Need to reconstruct previous data. */
+ data0 = data1 * 2.0 - data2;
+ }
+ if (id + 1 >= strand_segments) {
+ /* tip points. Need to reconstruct next data. */
+ data3 = data2 * 2.0 - data1;
+ }
+}
+#endif
+
+/* -- Drawing stage -- */
+/**
+ * For final drawing, the vertex index and the number of vertex per segment
+ **/
+
+#ifndef HAIR_PHASE_SUBDIV
+int hair_get_strand_id(void)
+{
+ return gl_VertexID / (hairStrandsRes * hairThicknessRes);
+}
+
+int hair_get_base_id(void)
+{
+ return gl_VertexID / hairThicknessRes;
+}
+
+/* Copied from cycles. */
+float hair_shaperadius(float shape, float root, float tip, float time)
+{
+ float radius = 1.0 - time;
+
+ if (shape < 0.0) {
+ radius = pow(radius, 1.0 + shape);
+ }
+ else {
+ radius = pow(radius, 1.0 / (1.0 - shape));
+ }
+
+ if (hairCloseTip && (time > 0.99)) {
+ return 0.0;
+ }
+
+ return (radius * (root - tip)) + tip;
+}
+
+void hair_get_pos_tan_binor_time(
+ bool is_persp, vec3 camera_pos, vec3 camera_z,
+ out vec3 wpos, out vec3 wtan, out vec3 wbinor, out float time, out float thickness, out float thick_time)
+{
+ int id = hair_get_base_id();
+ vec4 data = texelFetch(hairPointBuffer, id);
+ wpos = data.point_position;
+ time = data.point_time;
+ if (time == 0.0) {
+ /* Hair root */
+ wtan = texelFetch(hairPointBuffer, id + 1).point_position - wpos;
+ }
+ else {
+ wtan = wpos - texelFetch(hairPointBuffer, id - 1).point_position;
+ }
+
+ vec3 camera_vec = (is_persp) ? wpos - camera_pos : -camera_z;
+ wbinor = normalize(cross(camera_vec, wtan));
+
+ thickness = hair_shaperadius(hairRadShape, hairRadRoot, hairRadTip, time);
+
+ if (hairThicknessRes > 1) {
+ thick_time = float(gl_VertexID % hairThicknessRes) / float(hairThicknessRes - 1);
+ thick_time = thickness * (thick_time * 2.0 - 1.0);
+
+ wpos += wbinor * thick_time;
+ }
+}
+
+vec2 hair_get_customdata_vec2(const samplerBuffer cd_buf)
+{
+ int id = hair_get_strand_id();
+ return texelFetch(cd_buf, id).rg;
+}
+
+vec3 hair_get_customdata_vec3(const samplerBuffer cd_buf)
+{
+ int id = hair_get_strand_id();
+ return texelFetch(cd_buf, id).rgb;
+}
+
+vec4 hair_get_customdata_vec4(const samplerBuffer cd_buf)
+{
+ int id = hair_get_strand_id();
+ return texelFetch(cd_buf, id).rgba;
+}
+
+vec3 hair_get_strand_pos(void)
+{
+ int id = hair_get_strand_id() * hairStrandsRes;
+ return texelFetch(hairPointBuffer, id).point_position;
+}
+
+#endif
diff --git a/source/blender/draw/modes/shaders/common_hair_refine_vert.glsl b/source/blender/draw/modes/shaders/common_hair_refine_vert.glsl
new file mode 100644
index 00000000000..9f412c57db3
--- /dev/null
+++ b/source/blender/draw/modes/shaders/common_hair_refine_vert.glsl
@@ -0,0 +1,55 @@
+
+/* To be compiled with common_hair_lib.glsl */
+
+out vec4 outData;
+
+vec4 get_weights_cardinal(float t)
+{
+ float t2 = t * t;
+ float t3 = t2 * t;
+#if defined(CARDINAL)
+ float fc = 0.71;
+#else /* defined(CATMULL_ROM) */
+ float fc = 0.5;
+#endif
+
+ vec4 weights;
+ /* GLSL Optimized version of key_curve_position_weights() */
+ float fct = t * fc;
+ float fct2 = t2 * fc;
+ float fct3 = t3 * fc;
+ weights.x = ( fct2 * 2.0 - fct3) - fct;
+ weights.y = ( t3 * 2.0 - fct3) + (-t2 * 3.0 + fct2) + 1.0;
+ weights.z = (-t3 * 2.0 + fct3) + ( t2 * 3.0 - (2.0 * fct2)) + fct;
+ weights.w = fct3 - fct2;
+ return weights;
+}
+
+/* TODO(fclem): This one is buggy, find why. (it's not the optimization!!) */
+vec4 get_weights_bspline(float t)
+{
+ float t2 = t * t;
+ float t3 = t2 * t;
+
+ vec4 weights;
+ /* GLSL Optimized version of key_curve_position_weights() */
+ weights.xz = vec2(-0.16666666, -0.5) * t3 + (0.5 * t2 + 0.5 * vec2(-t, t) + 0.16666666);
+ weights.y = ( 0.5 * t3 - t2 + 0.66666666);
+ weights.w = ( 0.16666666 * t3);
+ return weights;
+}
+
+vec4 interp_data(vec4 v0, vec4 v1, vec4 v2, vec4 v3, vec4 w)
+{
+ return v0 * w.x + v1 * w.y + v2 * w.z + v3 * w.w;
+}
+
+void main(void)
+{
+ float interp_time;
+ vec4 data0, data1, data2, data3;
+ hair_get_interp_attribs(data0, data1, data2, data3, interp_time);
+
+ vec4 weights = get_weights_cardinal(interp_time);
+ outData = interp_data(data0, data1, data2, data3, weights);
+}
diff --git a/source/blender/draw/modes/shaders/object_outline_prepass_geom.glsl b/source/blender/draw/modes/shaders/object_outline_prepass_geom.glsl
new file mode 100644
index 00000000000..c90195e11fd
--- /dev/null
+++ b/source/blender/draw/modes/shaders/object_outline_prepass_geom.glsl
@@ -0,0 +1,40 @@
+
+layout(lines_adjacency) in;
+layout(line_strip, max_vertices = 2) out;
+
+uniform mat4 ProjectionMatrix;
+
+in vec4 pPos[];
+in vec3 vPos[];
+
+void main()
+{
+ bool is_persp = (ProjectionMatrix[3][3] == 0.0);
+
+ vec3 view_vec = (is_persp) ? normalize(vPos[1]) : vec3(0.0, 0.0, -1.0);
+
+ vec3 v10 = vPos[0] - vPos[1];
+ vec3 v12 = vPos[2] - vPos[1];
+ vec3 v13 = vPos[3] - vPos[1];
+
+ vec3 n0 = cross(v12, v10);
+ vec3 n3 = cross(v13, v12);
+
+ float fac0 = dot(view_vec, n0);
+ float fac3 = dot(view_vec, n3);
+
+ /* If both adjacent verts are facing the camera the same way,
+ * then it isn't an outline edge. */
+ if (sign(fac0) == sign(fac3))
+ return;
+
+ /* Don't outline if concave edge. */
+ /* That would hide a lot of non usefull edge but it flickers badly.
+ * TODO revisit later... */
+ // if (dot(n0, v13) > 0.01)
+ // return;
+
+ gl_Position = pPos[1]; EmitVertex();
+ gl_Position = pPos[2]; EmitVertex();
+ EndPrimitive();
+}
diff --git a/source/blender/draw/modes/shaders/object_outline_prepass_vert.glsl b/source/blender/draw/modes/shaders/object_outline_prepass_vert.glsl
new file mode 100644
index 00000000000..ba824a7c007
--- /dev/null
+++ b/source/blender/draw/modes/shaders/object_outline_prepass_vert.glsl
@@ -0,0 +1,16 @@
+
+uniform mat4 ModelViewMatrix;
+uniform mat4 ModelViewProjectionMatrix;
+
+in vec3 pos;
+
+out vec4 pPos;
+out vec3 vPos;
+
+void main()
+{
+ vPos = (ModelViewMatrix * vec4(pos, 1.0)).xyz;
+ pPos = ModelViewProjectionMatrix * vec4(pos, 1.0);
+ /* Small bias to always be on top of the geom. */
+ pPos.z -= 1e-3;
+}
diff --git a/source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl b/source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl
new file mode 100644
index 00000000000..00ababc624d
--- /dev/null
+++ b/source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl
@@ -0,0 +1,53 @@
+uniform vec3 wireColor;
+uniform vec3 rimColor;
+
+flat in vec3 ssVec0;
+flat in vec3 ssVec1;
+flat in vec3 ssVec2;
+in float facing;
+
+#ifdef LIGHT_EDGES
+in float edgeSharpness;
+#endif
+
+out vec4 fragColor;
+
+float min_v3(vec3 v) { return min(v.x, min(v.y, v.z)); }
+float max_v3(vec3 v) { return max(v.x, max(v.y, v.z)); }
+
+/* In pixels */
+const float wire_size = 0.0; /* Expands the core of the wire (part that is 100% wire color) */
+const float wire_smooth = 1.2; /* Smoothing distance after the 100% core. */
+
+/* Alpha constants could be exposed in the future. */
+const float front_alpha = 0.35;
+const float rim_alpha = 0.75;
+
+void main()
+{
+ vec3 ss_pos = vec3(gl_FragCoord.xy, 1.0);
+ vec3 dist_to_edge = vec3(
+ dot(ss_pos, ssVec0),
+ dot(ss_pos, ssVec1),
+ dot(ss_pos, ssVec2)
+ );
+
+#ifdef LIGHT_EDGES
+ vec3 fac = abs(dist_to_edge);
+#else
+ float fac = min_v3(abs(dist_to_edge));
+#endif
+
+ fac = smoothstep(wire_size + wire_smooth, wire_size, fac);
+
+ float facing_clamped = clamp((gl_FrontFacing) ? facing : -facing, 0.0, 1.0);
+
+ vec3 final_front_col = mix(rimColor, wireColor, 0.05);
+ fragColor = mix(vec4(rimColor, rim_alpha), vec4(final_front_col, front_alpha), facing_clamped);
+
+#ifdef LIGHT_EDGES
+ fragColor.a *= max_v3(fac * edgeSharpness);
+#else
+ fragColor.a *= fac;
+#endif
+}
diff --git a/source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl b/source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl
new file mode 100644
index 00000000000..6e833a4e16b
--- /dev/null
+++ b/source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl
@@ -0,0 +1,78 @@
+
+/* This shader is only used for intel GPU where the Geom shader is faster
+ * than doing everything thrice in the vertex shader. */
+
+layout(triangles) in;
+layout(triangle_strip, max_vertices = 3) out;
+
+uniform vec2 wireStepParam;
+
+in vec2 ssPos[];
+in float facingOut[];
+
+flat out vec3 ssVec0;
+flat out vec3 ssVec1;
+flat out vec3 ssVec2;
+out float facing;
+
+#ifdef LIGHT_EDGES
+in vec3 obPos[];
+in vec3 vNor[];
+in float forceEdge[];
+
+out float edgeSharpness;
+#endif
+
+#define NO_EDGE vec3(10000.0);
+
+/* TODO(fclem) remove code duplication. */
+vec3 compute_vec(vec2 v0, vec2 v1)
+{
+ vec2 v = normalize(v1 - v0);
+ v = vec2(-v.y, v.x);
+ return vec3(v, -dot(v, v0));
+}
+
+float get_edge_sharpness(vec3 fnor, vec3 vnor)
+{
+ float sharpness = abs(dot(fnor, vnor));
+ return smoothstep(wireStepParam.x, wireStepParam.y, sharpness);
+}
+
+void main(void)
+{
+ vec3 facings = vec3(facingOut[0], facingOut[1], facingOut[2]);
+ bvec3 do_edge = greaterThan(abs(facings), vec3(1.0));
+ facings = fract(facings) - clamp(-sign(facings), 0.0, 1.0);
+
+ ssVec0 = do_edge.x ? compute_vec(ssPos[0], ssPos[1]) : NO_EDGE;
+ ssVec1 = do_edge.y ? compute_vec(ssPos[1], ssPos[2]) : NO_EDGE;
+ ssVec2 = do_edge.z ? compute_vec(ssPos[2], ssPos[0]) : NO_EDGE;
+
+#ifdef LIGHT_EDGES
+ vec3 fnor = normalize(cross(obPos[1] - obPos[0], obPos[2] - obPos[0]));
+
+ edgeSharpness = get_edge_sharpness(fnor, vNor[0]);
+ edgeSharpness = (forceEdge[0] == 1.0 || forceEdge[2] == 1.0) ? 1.0 : edgeSharpness;
+#endif
+ gl_Position = gl_in[0].gl_Position;
+ facing = facings.x;
+ EmitVertex();
+
+#ifdef LIGHT_EDGES
+ edgeSharpness = get_edge_sharpness(fnor, vNor[1]);
+ edgeSharpness = (forceEdge[1] == 1.0 || forceEdge[0] == 1.0) ? 1.0 : edgeSharpness;
+#endif
+ gl_Position = gl_in[1].gl_Position;
+ facing = facings.y;
+ EmitVertex();
+
+#ifdef LIGHT_EDGES
+ edgeSharpness = get_edge_sharpness(fnor, vNor[2]);
+ edgeSharpness = (forceEdge[2] == 1.0 || forceEdge[1] == 1.0) ? 1.0 : edgeSharpness;
+#endif
+ gl_Position = gl_in[2].gl_Position;
+ facing = facings.z;
+ EmitVertex();
+ EndPrimitive();
+}
diff --git a/source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl b/source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl
new file mode 100644
index 00000000000..616cd5379e9
--- /dev/null
+++ b/source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl
@@ -0,0 +1,175 @@
+
+uniform mat4 ModelViewProjectionMatrix;
+uniform mat4 ModelViewMatrix;
+uniform mat4 ProjectionMatrix;
+uniform mat3 NormalMatrix;
+
+uniform vec2 wireStepParam;
+uniform vec2 viewportSize;
+uniform float nearDist;
+
+uniform samplerBuffer vertData;
+uniform usamplerBuffer faceIds;
+
+#ifdef USE_GEOM_SHADER
+out vec2 ssPos;
+out float facingOut; /* abs(facing) > 1.0 if we do edge */
+#else
+flat out vec3 ssVec0;
+flat out vec3 ssVec1;
+flat out vec3 ssVec2;
+out float facing;
+#endif
+
+#ifdef LIGHT_EDGES
+#ifdef USE_GEOM_SHADER
+out vec3 obPos;
+out vec3 vNor;
+out float forceEdge;
+#else
+out float edgeSharpness;
+#endif
+#endif
+
+/* project to screen space */
+vec2 proj(vec4 pos)
+{
+ return (0.5 * (pos.xy / pos.w) + 0.5) * viewportSize;
+}
+
+vec3 compute_vec(vec2 v0, vec2 v1)
+{
+ vec2 v = normalize(v1 - v0);
+ v = vec2(-v.y, v.x);
+ return vec3(v, -dot(v, v0));
+}
+
+float short_to_unit_float(uint s)
+{
+ int value = int(s) & 0x7FFF;
+ if ((s & 0x8000u) != 0u) {
+ value |= ~0x7FFF;
+ }
+ return float(value) / float(0x7FFF);
+}
+
+vec3 get_vertex_nor(uint id)
+{
+ int v_id = int(id) * 5; /* See vertex format for explanation. */
+ /* Fetch compressed normal as float and unpack them. */
+ vec2 data;
+ data.x = texelFetch(vertData, v_id + 3).r;
+ data.y = texelFetch(vertData, v_id + 4).r;
+
+ uvec2 udata = floatBitsToUint(data);
+
+ vec3 nor;
+ nor.x = short_to_unit_float(udata.x & 0xFFFFu);
+ nor.y = short_to_unit_float(udata.x >> 16u);
+ nor.z = short_to_unit_float(udata.y & 0xFFFFu);
+ return nor;
+}
+
+vec3 get_vertex_pos(uint id)
+{
+ int v_id = int(id) * 5; /* See vertex format for explanation. */
+ vec3 pos;
+ pos.x = texelFetch(vertData, v_id).r;
+ pos.y = texelFetch(vertData, v_id + 1).r;
+ pos.z = texelFetch(vertData, v_id + 2).r;
+ return pos;
+}
+
+float get_edge_sharpness(vec3 fnor, vec3 vnor)
+{
+ float sharpness = abs(dot(fnor, vnor));
+ return smoothstep(wireStepParam.x, wireStepParam.y, sharpness);
+}
+
+#define NO_EDGE vec3(10000.0);
+
+void main()
+{
+#ifdef USE_GEOM_SHADER
+ uint v_id = texelFetch(faceIds, gl_VertexID).r;
+
+ bool do_edge = (v_id & (1u << 30u)) != 0u;
+ bool force_edge = (v_id & (1u << 31u)) != 0u;
+ v_id = (v_id << 2u) >> 2u;
+
+ vec3 pos = get_vertex_pos(v_id);
+ vec3 nor = get_vertex_nor(v_id);
+ facingOut = normalize(NormalMatrix * nor).z;
+ facingOut += (do_edge) ? ((facingOut > 0.0) ? 2.0 : -2.0) : 0.0;
+
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+ ssPos = proj(gl_Position);
+
+# ifdef LIGHT_EDGES
+ obPos = pos;
+ vNor = nor;
+ forceEdge = float(force_edge); /* meh, could try to also encode it in facingOut */
+# endif
+
+#else
+ int v_0 = (gl_VertexID / 3) * 3;
+ int v_n = gl_VertexID % 3;
+
+ /* Getting the same positions for each of the 3 verts. */
+ uvec3 v_id;
+ v_id.x = texelFetch(faceIds, v_0).r;
+ v_id.y = texelFetch(faceIds, v_0 + 1).r;
+ v_id.z = texelFetch(faceIds, v_0 + 2).r;
+
+ bvec3 do_edge, force_edge;
+ do_edge.x = (v_id.x & (1u << 30u)) != 0u;
+ do_edge.y = (v_id.y & (1u << 30u)) != 0u;
+ do_edge.z = (v_id.z & (1u << 30u)) != 0u;
+ force_edge.x = (v_id.x & (1u << 31u)) != 0u;
+ force_edge.y = (v_id.y & (1u << 31u)) != 0u;
+ force_edge.z = (v_id.z & (1u << 31u)) != 0u;
+ v_id = (v_id << 2u) >> 2u;
+
+ vec3 pos[3];
+ pos[0] = get_vertex_pos(v_id.x);
+ pos[1] = get_vertex_pos(v_id.y);
+ pos[2] = get_vertex_pos(v_id.z);
+
+ vec4 p_pos[3];
+ p_pos[0] = ModelViewProjectionMatrix * vec4(pos[0], 1.0);
+ p_pos[1] = ModelViewProjectionMatrix * vec4(pos[1], 1.0);
+ p_pos[2] = ModelViewProjectionMatrix * vec4(pos[2], 1.0);
+
+ vec2 ss_pos[3];
+ ss_pos[0] = proj(p_pos[0]);
+ ss_pos[1] = proj(p_pos[1]);
+ ss_pos[2] = proj(p_pos[2]);
+
+ /* Compute the edges screen vectors */
+ ssVec0 = do_edge.x ? compute_vec(ss_pos[0], ss_pos[1]) : NO_EDGE;
+ ssVec1 = do_edge.y ? compute_vec(ss_pos[1], ss_pos[2]) : NO_EDGE;
+ ssVec2 = do_edge.z ? compute_vec(ss_pos[2], ss_pos[0]) : NO_EDGE;
+
+ gl_Position = p_pos[v_n];
+
+ vec3 nor = get_vertex_nor(v_id[v_n]);
+ facing = normalize(NormalMatrix * nor).z;
+
+# ifdef LIGHT_EDGES
+ vec3 fnor = normalize(cross(pos[1] - pos[0], pos[2] - pos[0]));
+ edgeSharpness = get_edge_sharpness(fnor, nor);
+
+ /* Fix disapearing edges. */
+ if (v_n == 0) {
+ force_edge.xy = force_edge.xz;
+ }
+ else if (v_n == 2) {
+ force_edge.xy = force_edge.yz;
+ }
+ if (any(force_edge.xy)) {
+ edgeSharpness = 1.0;
+ }
+# endif
+
+#endif
+}
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index e0bb9eebffb..e4213a8d907 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -65,6 +65,7 @@
#include "BKE_animsys.h"
#include "BKE_curve.h"
#include "BKE_key.h"
+#include "BKE_main.h"
#include "BKE_nla.h"
#include "BKE_context.h"
@@ -119,10 +120,10 @@ static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, floa
short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0;
short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
float color[3];
-
+
/* set backdrop drawing color */
acf->get_backdrop_color(ac, ale, color);
-
+
/* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
UI_draw_roundbox_corner_set((expanded) ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT));
UI_draw_roundbox_3fvAlpha(true, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f);
@@ -162,7 +163,7 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale
static bool acf_show_channel_colors(bAnimContext *ac)
{
bool showGroupColors = false;
-
+
if (ac->sl) {
switch (ac->spacetype) {
case SPACE_ACTION:
@@ -181,7 +182,7 @@ static bool acf_show_channel_colors(bAnimContext *ac)
}
}
}
-
+
return showGroupColors;
}
@@ -192,19 +193,19 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa
bActionGroup *grp = NULL;
short indent = (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0;
bool showGroupColors = acf_show_channel_colors(ac);
-
+
if (ale->type == ANIMTYPE_FCURVE) {
FCurve *fcu = (FCurve *)ale->data;
grp = fcu->grp;
}
-
- /* set color for normal channels
+
+ /* set color for normal channels
* - use 3 shades of color group/standard color for 3 indention level
* - only use group colors if allowed to, and if actually feasible
*/
if (showGroupColors && (grp) && (grp->customCol)) {
unsigned char cp[3];
-
+
if (indent == 2) {
copy_v3_v3_char((char *)cp, grp->cs.solid);
}
@@ -214,7 +215,7 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa
else {
copy_v3_v3_char((char *)cp, grp->cs.active);
}
-
+
/* copy the colors over, transforming from bytes to floats */
rgb_uchar_to_float(r_color, cp);
}
@@ -234,13 +235,13 @@ static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, f
float color[3];
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
-
+
/* set backdrop drawing color */
acf->get_backdrop_color(ac, ale, color);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3fv(color);
-
+
/* no rounded corners - just rectangular box */
immRectf(pos, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc);
@@ -269,16 +270,16 @@ static short acf_generic_indention_2(bAnimContext *ac, bAnimListElem *ale)
static short acf_generic_indention_flexible(bAnimContext *UNUSED(ac), bAnimListElem *ale)
{
short indent = 0;
-
+
/* grouped F-Curves need extra level of indention */
if (ale->type == ANIMTYPE_FCURVE) {
FCurve *fcu = (FCurve *)ale->data;
-
+
// TODO: we need some way of specifying that the indention color should be one less...
if (fcu->grp)
indent++;
}
-
+
/* no indention */
return indent;
}
@@ -287,7 +288,7 @@ static short acf_generic_indention_flexible(bAnimContext *UNUSED(ac), bAnimListE
static short acf_generic_basic_offset(bAnimContext *ac, bAnimListElem *ale)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
-
+
if (acf && acf->get_indent_level)
return acf->get_indent_level(ac, ale) * INDENT_STEP_SIZE;
else
@@ -300,21 +301,21 @@ static short acf_nodetree_rootType_offset(bNodeTree *ntree)
if (ntree) {
switch (ntree->type) {
case NTREE_SHADER:
- /* 1 additional level (i.e. is indented one level in from material,
- * so shift all right by one step)
+ /* 1 additional level (i.e. is indented one level in from material,
+ * so shift all right by one step)
*/
- return INDENT_STEP_SIZE;
-
+ return INDENT_STEP_SIZE;
+
case NTREE_COMPOSIT:
/* no additional levels needed */
- return 0;
-
+ return 0;
+
case NTREE_TEXTURE:
/* 2 additional levels */
return INDENT_STEP_SIZE * 2;
}
}
-
+
/* unknown */
return 0;
}
@@ -323,7 +324,7 @@ static short acf_nodetree_rootType_offset(bNodeTree *ntree)
static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale)
{
short offset = acf_generic_basic_offset(ac, ale);
-
+
if (ale->id) {
/* texture animdata */
if (GS(ale->id->name) == ID_TE) {
@@ -332,17 +333,17 @@ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale)
/* materials and particles animdata */
else if (ELEM(GS(ale->id->name), ID_MA, ID_PA))
offset += (short)(0.7f * U.widget_unit);
-
+
/* if not in Action Editor mode, action-groups (and their children) must carry some offset too... */
else if (ac->datatype != ANIMCONT_ACTION)
offset += (short)(0.7f * U.widget_unit);
-
+
/* nodetree animdata */
if (GS(ale->id->name) == ID_NT) {
offset += acf_nodetree_rootType_offset((bNodeTree *)ale->id);
}
}
-
+
/* offset is just the normal type - i.e. based on indention */
return offset;
}
@@ -353,7 +354,7 @@ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale)
static void acf_generic_idblock_name(bAnimListElem *ale, char *name)
{
ID *id = (ID *)ale->data; /* data pointed to should be an ID block */
-
+
/* just copy the name... */
if (id && name)
BLI_strncpy(name, id->name + 2, ANIM_CHAN_NAME_SIZE);
@@ -364,7 +365,7 @@ static bool acf_generic_idblock_name_prop(bAnimListElem *ale, PointerRNA *ptr, P
{
RNA_id_pointer_create(ale->data, ptr);
*prop = RNA_struct_name_property(ptr->type);
-
+
return (*prop != NULL);
}
@@ -375,7 +376,7 @@ static bool acf_generic_idfill_name_prop(bAnimListElem *ale, PointerRNA *ptr, Pr
/* actual ID we're representing is stored in ale->data not ale->id, as id gives the owner */
RNA_id_pointer_create(ale->data, ptr);
*prop = RNA_struct_name_property(ptr->type);
-
+
return (*prop != NULL);
}
@@ -396,11 +397,11 @@ static bool acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListElem
/* expand is always supported */
case ACHANNEL_SETTING_EXPAND:
return true;
-
+
/* mute is only supported for NLA */
case ACHANNEL_SETTING_MUTE:
return ((ac) && (ac->spacetype == SPACE_NLA));
-
+
/* select is ok for most "ds*" channels (e.g. dsmat) */
case ACHANNEL_SETTING_SELECT:
return true;
@@ -432,13 +433,13 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
View2D *v2d = &ac->ar->v2d;
float color[3];
-
+
/* set backdrop drawing color */
acf->get_backdrop_color(ac, ale, color);
-
- /* rounded corners on LHS only
- * - top and bottom
- * - special hack: make the top a bit higher, since we are first...
+
+ /* rounded corners on LHS only
+ * - top and bottom
+ * - special hack: make the top a bit higher, since we are first...
*/
UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT);
UI_draw_roundbox_3fvAlpha(true, 0, yminc - 2, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f);
@@ -483,14 +484,14 @@ static int acf_summary_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setti
static void *acf_summary_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
bAnimContext *ac = (bAnimContext *)ale->data;
-
- /* if data is valid, return pointer to active dopesheet's relevant flag
+
+ /* if data is valid, return pointer to active dopesheet's relevant flag
* - this is restricted to DopeSheet/Action Editor only
*/
if ((ac->sl) && (ac->spacetype == SPACE_ACTION) && (setting == ACHANNEL_SETTING_EXPAND)) {
SpaceAction *saction = (SpaceAction *)ac->sl;
bDopeSheet *ads = &saction->ads;
-
+
/* return pointer to DopeSheet's flag */
return GET_ACF_FLAG_PTR(ads->flag, type);
}
@@ -502,7 +503,7 @@ static void *acf_summary_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings s
}
/* all animation summary (DopeSheet only) type define */
-static bAnimChannelType ACF_SUMMARY =
+static bAnimChannelType ACF_SUMMARY =
{
"Summary", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
@@ -534,13 +535,13 @@ static bool acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale)
{
switch (setting) {
/* muted only in NLA */
- case ACHANNEL_SETTING_MUTE:
+ case ACHANNEL_SETTING_MUTE:
return ((ac) && (ac->spacetype == SPACE_NLA));
-
+
/* visible only in Graph Editor */
- case ACHANNEL_SETTING_VISIBLE:
+ case ACHANNEL_SETTING_VISIBLE:
return ((ac) && (ac->spacetype == SPACE_IPO));
-
+
/* only select and expand supported otherwise */
case ACHANNEL_SETTING_SELECT:
case ACHANNEL_SETTING_EXPAND:
@@ -559,18 +560,18 @@ static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
return SCE_DS_SELECTED;
-
+
case ACHANNEL_SETTING_EXPAND: /* expanded */
*neg = true;
return SCE_DS_COLLAPSED;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
@@ -584,30 +585,30 @@ static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
static void *acf_scene_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Scene *scene = (Scene *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
return GET_ACF_FLAG_PTR(scene->flag, type);
-
+
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(scene->flag, type);
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (scene->adt)
return GET_ACF_FLAG_PTR(scene->adt->flag, type);
return NULL;
-
+
default: /* unsupported */
return NULL;
}
}
/* scene type define */
-static bAnimChannelType ACF_SCENE =
+static bAnimChannelType ACF_SCENE =
{
"Scene", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
@@ -632,20 +633,20 @@ static int acf_object_icon(bAnimListElem *ale)
{
Base *base = (Base *)ale->data;
Object *ob = base->object;
-
+
/* icon depends on object-type */
switch (ob->type) {
case OB_LAMP:
return ICON_OUTLINER_OB_LAMP;
- case OB_MESH:
+ case OB_MESH:
return ICON_OUTLINER_OB_MESH;
- case OB_CAMERA:
+ case OB_CAMERA:
return ICON_OUTLINER_OB_CAMERA;
- case OB_CURVE:
+ case OB_CURVE:
return ICON_OUTLINER_OB_CURVE;
- case OB_MBALL:
+ case OB_MBALL:
return ICON_OUTLINER_OB_META;
- case OB_LATTICE:
+ case OB_LATTICE:
return ICON_OUTLINER_OB_LATTICE;
case OB_SPEAKER:
return ICON_OUTLINER_OB_SPEAKER;
@@ -653,11 +654,11 @@ static int acf_object_icon(bAnimListElem *ale)
return ICON_OUTLINER_OB_LIGHTPROBE;
case OB_ARMATURE:
return ICON_OUTLINER_OB_ARMATURE;
- case OB_FONT:
+ case OB_FONT:
return ICON_OUTLINER_OB_FONT;
- case OB_SURF:
+ case OB_SURF:
return ICON_OUTLINER_OB_SURFACE;
- case OB_EMPTY:
+ case OB_EMPTY:
return ICON_OUTLINER_OB_EMPTY;
default:
return ICON_OBJECT_DATA;
@@ -669,7 +670,7 @@ static void acf_object_name(bAnimListElem *ale, char *name)
{
Base *base = (Base *)ale->data;
Object *ob = base->object;
-
+
/* just copy the name... */
if (ob && name)
BLI_strncpy(name, ob->id.name + 2, ANIM_CHAN_NAME_SIZE);
@@ -680,7 +681,7 @@ static bool acf_object_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRN
{
RNA_id_pointer_create(ale->id, ptr);
*prop = RNA_struct_name_property(ptr->type);
-
+
return (*prop != NULL);
}
@@ -689,16 +690,16 @@ static bool acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnim
{
Base *base = (Base *)ale->data;
Object *ob = base->object;
-
+
switch (setting) {
/* muted only in NLA */
- case ACHANNEL_SETTING_MUTE:
+ case ACHANNEL_SETTING_MUTE:
return ((ac) && (ac->spacetype == SPACE_NLA));
-
+
/* visible only in Graph Editor */
- case ACHANNEL_SETTING_VISIBLE:
+ case ACHANNEL_SETTING_VISIBLE:
return ((ac) && (ac->spacetype == SPACE_IPO) && (ob->adt));
-
+
/* only select and expand supported otherwise */
case ACHANNEL_SETTING_SELECT:
case ACHANNEL_SETTING_EXPAND:
@@ -717,18 +718,18 @@ static int acf_object_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
return SELECT;
-
+
case ACHANNEL_SETTING_EXPAND: /* expanded */
*neg = 1;
return OB_ADS_COLLAPSED;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
@@ -746,17 +747,17 @@ static void *acf_object_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
{
Base *base = (Base *)ale->data;
Object *ob = base->object;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
return GET_ACF_FLAG_PTR(ob->flag, type);
-
+
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(ob->nlaflag, type); // xxx
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
case ACHANNEL_SETTING_ALWAYS_VISIBLE:
@@ -770,11 +771,11 @@ static void *acf_object_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
}
/* object type define */
-static bAnimChannelType ACF_OBJECT =
+static bAnimChannelType ACF_OBJECT =
{
"Object", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_root_color, /* backdrop color */
acf_generic_root_backdrop, /* backdrop */
acf_generic_indention_0, /* indent level */
@@ -796,16 +797,16 @@ static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[
{
bActionGroup *agrp = (bActionGroup *)ale->data;
bool showGroupColors = acf_show_channel_colors(ac);
-
+
if (showGroupColors && agrp->customCol) {
unsigned char cp[3];
-
+
/* highlight only for active */
if (ale->flag & AGRP_ACTIVE)
copy_v3_v3_char((char *)cp, agrp->cs.select);
else
copy_v3_v3_char((char *)cp, agrp->cs.solid);
-
+
/* copy the colors over, transforming from bytes to floats */
rgb_uchar_to_float(r_color, cp);
}
@@ -826,10 +827,10 @@ static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc
short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0;
short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
float color[3];
-
+
/* set backdrop drawing color */
acf->get_backdrop_color(ac, ale, color);
-
+
/* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
UI_draw_roundbox_corner_set(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT));
UI_draw_roundbox_3fvAlpha(true, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f);
@@ -839,7 +840,7 @@ static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc
static void acf_group_name(bAnimListElem *ale, char *name)
{
bActionGroup *agrp = (bActionGroup *)ale->data;
-
+
/* just copy the name... */
if (agrp && name)
BLI_strncpy(name, agrp->name, ANIM_CHAN_NAME_SIZE);
@@ -850,7 +851,7 @@ static bool acf_group_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA
{
RNA_pointer_create(ale->id, &RNA_ActionGroup, ale->data, ptr);
*prop = RNA_struct_name_property(ptr->type);
-
+
return (*prop != NULL);
}
@@ -862,7 +863,7 @@ static bool acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale)
/* unsupported */
case ACHANNEL_SETTING_SOLO: /* Only available in NLA Editor for tracks */
return false;
-
+
/* conditionally supported */
case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */
return (ac->spacetype == SPACE_IPO);
@@ -880,22 +881,22 @@ static int acf_group_setting_flag(bAnimContext *ac, eAnimChannel_Settings settin
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
return AGRP_SELECTED;
-
+
case ACHANNEL_SETTING_EXPAND: /* expanded */
{
/* NOTE: Graph Editor uses a different flag to everywhere else for this,
* allowing different collapsing of groups there, since sharing the flag
* proved to be a hazard for workflows...
*/
- return (ac->spacetype == SPACE_IPO) ?
+ return (ac->spacetype == SPACE_IPO) ?
AGRP_EXPANDED_G : /* Graph Editor case */
AGRP_EXPANDED; /* DopeSheet and elsewhere */
}
-
+
case ACHANNEL_SETTING_MUTE: /* muted */
return AGRP_MUTED;
@@ -905,7 +906,7 @@ static int acf_group_setting_flag(bAnimContext *ac, eAnimChannel_Settings settin
case ACHANNEL_SETTING_PROTECT: /* protected */
return AGRP_PROTECTED;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */
*neg = 1;
return AGRP_NOTVISIBLE;
@@ -923,17 +924,17 @@ static int acf_group_setting_flag(bAnimContext *ac, eAnimChannel_Settings settin
static void *acf_group_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
{
bActionGroup *agrp = (bActionGroup *)ale->data;
-
+
/* all flags are just in agrp->flag for now... */
return GET_ACF_FLAG_PTR(agrp->flag, type);
}
/* group type define */
-static bAnimChannelType ACF_GROUP =
+static bAnimChannelType ACF_GROUP =
{
"Group", /* type name */
ACHANNEL_ROLE_CHANNEL, /* role */
-
+
acf_group_color, /* backdrop color */
acf_group_backdrop, /* backdrop */
acf_generic_indention_0, /* indent level */
@@ -960,9 +961,9 @@ static void acf_fcurve_name(bAnimListElem *ale, char *name)
static bool acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
{
FCurve *fcu = (FCurve *)ale->data;
-
- /* Ctrl-Click Usability Convenience Hack:
- * For disabled F-Curves, allow access to the RNA Path
+
+ /* Ctrl-Click Usability Convenience Hack:
+ * For disabled F-Curves, allow access to the RNA Path
* as our "name" so that user can perform quick fixes
*/
if (fcu->flag & FCURVE_DISABLED) {
@@ -973,7 +974,7 @@ static bool acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRN
/* for "normal" F-Curves - no editable name, but *prop may not be set properly yet... */
*prop = NULL;
}
-
+
return (*prop != NULL);
}
@@ -981,21 +982,21 @@ static bool acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRN
static bool acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting)
{
FCurve *fcu = (FCurve *)ale->data;
-
+
switch (setting) {
/* unsupported */
case ACHANNEL_SETTING_SOLO: /* Solo Flag is only for NLA */
case ACHANNEL_SETTING_EXPAND: /* F-Curves are not containers */
case ACHANNEL_SETTING_PINNED: /* This is only for NLA Actions */
return false;
-
+
/* conditionally available */
case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */
if (fcu->bezt)
return true;
else
return false; // NOTE: in this special case, we need to draw ICON_ZOOMOUT
-
+
case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */
return (ac->spacetype == SPACE_IPO);
@@ -1013,20 +1014,20 @@ static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
return FCURVE_SELECTED;
-
+
case ACHANNEL_SETTING_MUTE: /* muted */
return FCURVE_MUTED;
-
+
case ACHANNEL_SETTING_PROTECT: /* protected */
return FCURVE_PROTECTED;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */
return FCURVE_VISIBLE;
-
+
case ACHANNEL_SETTING_MOD_OFF:
*neg = 1;
return FCURVE_MOD_OFF;
@@ -1040,17 +1041,17 @@ static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin
static void *acf_fcurve_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
{
FCurve *fcu = (FCurve *)ale->data;
-
+
/* all flags are just in agrp->flag for now... */
return GET_ACF_FLAG_PTR(fcu->flag, type);
}
/* fcurve type define */
-static bAnimChannelType ACF_FCURVE =
+static bAnimChannelType ACF_FCURVE =
{
"F-Curve", /* type name */
ACHANNEL_ROLE_CHANNEL, /* role */
-
+
acf_generic_channel_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
acf_generic_indention_flexible, /* indent level */ // xxx rename this to f-curves only?
@@ -1082,11 +1083,11 @@ static void acf_nla_controls_backdrop(bAnimContext *ac, bAnimListElem *ale, floa
short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0;
short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
float color[3];
-
+
/* set backdrop drawing color */
acf->get_backdrop_color(ac, ale, color);
-
- /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
+
+ /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
UI_draw_roundbox_corner_set(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT));
UI_draw_roundbox_3fvAlpha(true, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 5, color, 1.0f);
}
@@ -1105,9 +1106,9 @@ static bool acf_nla_controls_setting_valid(bAnimContext *UNUSED(ac), bAnimListEl
/* supported */
case ACHANNEL_SETTING_EXPAND:
return true;
-
+
// TOOD: selected?
-
+
default: /* unsupported */
return false;
}
@@ -1118,12 +1119,12 @@ static int acf_nla_controls_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
*neg = true;
return ADT_NLA_SKEYS_COLLAPSED;
-
+
default:
/* this shouldn't happen */
return 0;
@@ -1134,7 +1135,7 @@ static int acf_nla_controls_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_
static void *acf_nla_controls_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
{
AnimData *adt = (AnimData *)ale->data;
-
+
/* all flags are just in adt->flag for now... */
return GET_ACF_FLAG_PTR(adt->flag, type);
}
@@ -1145,11 +1146,11 @@ static int acf_nla_controls_icon(bAnimListElem *UNUSED(ale))
}
/* NLA Control FCurves Expander type define */
-static bAnimChannelType ACF_NLACONTROLS =
+static bAnimChannelType ACF_NLACONTROLS =
{
"NLA Controls Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_nla_controls_color, /* backdrop color */
acf_nla_controls_backdrop, /* backdrop */
acf_generic_indention_0, /* indent level */
@@ -1173,7 +1174,7 @@ static void acf_nla_curve_name(bAnimListElem *ale, char *name)
NlaStrip *strip = ale->owner;
FCurve *fcu = ale->data;
PropertyRNA *prop;
-
+
/* try to get RNA property that this shortened path (relative to the strip) refers to */
prop = RNA_struct_type_find_property(&RNA_NlaStrip, fcu->rna_path);
if (prop) {
@@ -1188,11 +1189,11 @@ static void acf_nla_curve_name(bAnimListElem *ale, char *name)
/* NLA Control F-Curve type define */
-static bAnimChannelType ACF_NLACURVE =
+static bAnimChannelType ACF_NLACURVE =
{
"NLA Control F-Curve", /* type name */
ACHANNEL_ROLE_CHANNEL, /* role */
-
+
acf_generic_channel_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -1223,7 +1224,7 @@ static bool acf_fillactd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *
case ACHANNEL_SETTING_SELECT:
case ACHANNEL_SETTING_EXPAND:
return true;
-
+
default:
return false;
}
@@ -1234,15 +1235,15 @@ static int acf_fillactd_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Sett
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
case ACHANNEL_SETTING_EXPAND: /* expanded */
*neg = true;
return ACT_COLLAPSED;
-
+
default: /* unsupported */
return 0;
}
@@ -1253,10 +1254,10 @@ static void *acf_fillactd_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings
{
bAction *act = (bAction *)ale->data;
AnimData *adt = ale->adt;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
if (adt) {
@@ -1266,18 +1267,18 @@ static void *acf_fillactd_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(act->flag, type);
-
+
default: /* unsupported */
return NULL;
}
}
/* object action expander type define */
-static bAnimChannelType ACF_FILLACTD =
+static bAnimChannelType ACF_FILLACTD =
{
"Ob-Action Filler", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -1313,7 +1314,7 @@ static bool acf_filldrivers_setting_valid(bAnimContext *UNUSED(ac), bAnimListEle
/* only expand supported */
case ACHANNEL_SETTING_EXPAND:
return true;
-
+
default:
return false;
}
@@ -1324,12 +1325,12 @@ static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_S
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
*neg = true;
return ADT_DRIVERS_COLLAPSED;
-
+
default: /* unsupported */
return 0;
}
@@ -1339,25 +1340,25 @@ static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_S
static void *acf_filldrivers_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
AnimData *adt = (AnimData *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(adt->flag, type);
-
+
default: /* unsupported */
return NULL;
}
}
/* drivers expander type define */
-static bAnimChannelType ACF_FILLDRIVERS =
+static bAnimChannelType ACF_FILLDRIVERS =
{
"Drivers Filler", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -1386,21 +1387,21 @@ static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return MA_DS_EXPAND;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
default: /* unsupported */
return 0;
}
@@ -1410,14 +1411,14 @@ static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
static void *acf_dsmat_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Material *ma = (Material *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(ma->flag, type);
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
@@ -1435,7 +1436,7 @@ static bAnimChannelType ACF_DSMAT =
{
"Material Data Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -1463,21 +1464,21 @@ static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return LA_DS_EXPAND;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
default: /* unsupported */
return 0;
}
@@ -1487,21 +1488,21 @@ static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
static void *acf_dslam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Lamp *la = (Lamp *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(la->flag, type);
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (la->adt)
return GET_ACF_FLAG_PTR(la->adt->flag, type);
return NULL;
-
+
default: /* unsupported */
return NULL;
}
@@ -1512,7 +1513,7 @@ static bAnimChannelType ACF_DSLAM =
{
"Lamp Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -1547,21 +1548,21 @@ static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return TEX_DS_EXPAND;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
default: /* unsupported */
return 0;
}
@@ -1571,21 +1572,21 @@ static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
static void *acf_dstex_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Tex *tex = (Tex *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(tex->flag, type);
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (tex->adt)
return GET_ACF_FLAG_PTR(tex->adt->flag, type);
return NULL;
-
+
default: /* unsupported */
return NULL;
}
@@ -1596,7 +1597,7 @@ static bAnimChannelType ACF_DSTEX =
{
"Texture Data Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -1706,18 +1707,18 @@ static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return CAM_DS_EXPAND;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
@@ -1733,14 +1734,14 @@ static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
static void *acf_dscam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Camera *ca = (Camera *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(ca->flag, type);
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
@@ -1748,7 +1749,7 @@ static void *acf_dscam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
if (ca->adt)
return GET_ACF_FLAG_PTR(ca->adt->flag, type);
return NULL;
-
+
default: /* unsupported */
return NULL;
}
@@ -1759,7 +1760,7 @@ static bAnimChannelType ACF_DSCAM =
{
"Camera Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -1781,7 +1782,7 @@ static int acf_dscur_icon(bAnimListElem *ale)
{
Curve *cu = (Curve *)ale->data;
short obtype = BKE_curve_type_get(cu);
-
+
switch (obtype) {
case OB_FONT:
return ICON_FONT_DATA;
@@ -1797,21 +1798,21 @@ static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return CU_DS_EXPAND;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
default: /* unsupported */
return 0;
}
@@ -1821,21 +1822,21 @@ static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
static void *acf_dscur_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Curve *cu = (Curve *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(cu->flag, type);
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (cu->adt)
return GET_ACF_FLAG_PTR(cu->adt->flag, type);
return NULL;
-
+
default: /* unsupported */
return NULL;
}
@@ -1846,7 +1847,7 @@ static bAnimChannelType ACF_DSCUR =
{
"Curve Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -1874,21 +1875,21 @@ static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return KEY_DS_EXPAND;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
default: /* unsupported */
return 0;
}
@@ -1898,21 +1899,21 @@ static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin
static void *acf_dsskey_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Key *key = (Key *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(key->flag, type);
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (key->adt)
return GET_ACF_FLAG_PTR(key->adt->flag, type);
return NULL;
-
+
default: /* unsupported */
return NULL;
}
@@ -1923,7 +1924,7 @@ static bAnimChannelType ACF_DSSKEY =
{
"Shape Key Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -1951,21 +1952,21 @@ static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return WO_DS_EXPAND;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
default: /* unsupported */
return 0;
}
@@ -1975,21 +1976,21 @@ static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
static void *acf_dswor_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
World *wo = (World *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(wo->flag, type);
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (wo->adt)
return GET_ACF_FLAG_PTR(wo->adt->flag, type);
return NULL;
-
+
default: /* unsupported */
return NULL;
}
@@ -2000,7 +2001,7 @@ static bAnimChannelType ACF_DSWOR =
{
"World Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -2028,21 +2029,21 @@ static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return 0;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
default: /* unsupported */
return 0;
}
@@ -2053,16 +2054,16 @@ static void *acf_dspart_setting_ptr(bAnimListElem *UNUSED(ale), eAnimChannel_Set
{
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return NULL;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
return NULL;
-
+
default: /* unsupported */
return NULL;
}
@@ -2073,7 +2074,7 @@ static bAnimChannelType ACF_DSPART =
{
"Particle Data Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -2101,21 +2102,21 @@ static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setti
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return MB_DS_EXPAND;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
default: /* unsupported */
return 0;
}
@@ -2125,21 +2126,21 @@ static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setti
static void *acf_dsmball_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
MetaBall *mb = (MetaBall *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(mb->flag2, type);
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (mb->adt)
return GET_ACF_FLAG_PTR(mb->adt->flag, type);
return NULL;
-
+
default: /* unsupported */
return NULL;
}
@@ -2150,7 +2151,7 @@ static bAnimChannelType ACF_DSMBALL =
{
"Metaball Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -2178,21 +2179,21 @@ static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return ARM_DS_EXPAND;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
default: /* unsupported */
return 0;
}
@@ -2202,21 +2203,21 @@ static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
static void *acf_dsarm_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
bArmature *arm = (bArmature *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(arm->flag, type);
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (arm->adt)
return GET_ACF_FLAG_PTR(arm->adt->flag, type);
return NULL;
-
+
default: /* unsupported */
return NULL;
}
@@ -2227,7 +2228,7 @@ static bAnimChannelType ACF_DSARM =
{
"Armature Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -2255,9 +2256,9 @@ static short acf_dsntree_offset(bAnimContext *ac, bAnimListElem *ale)
{
bNodeTree *ntree = (bNodeTree *)ale->data;
short offset = acf_generic_basic_offset(ac, ale);
-
- offset += acf_nodetree_rootType_offset(ntree);
-
+
+ offset += acf_nodetree_rootType_offset(ntree);
+
return offset;
}
@@ -2266,21 +2267,21 @@ static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setti
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return NTREE_DS_EXPAND;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
default: /* unsupported */
return 0;
}
@@ -2290,21 +2291,21 @@ static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setti
static void *acf_dsntree_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
bNodeTree *ntree = (bNodeTree *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(ntree->flag, type);
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (ntree->adt)
return GET_ACF_FLAG_PTR(ntree->adt->flag, type);
return NULL;
-
+
default: /* unsupported */
return NULL;
}
@@ -2315,7 +2316,7 @@ static bAnimChannelType ACF_DSNTREE =
{
"Node Tree Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -2343,21 +2344,21 @@ static int acf_dslinestyle_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_S
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return LS_DS_EXPAND;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
default: /* unsupported */
return 0;
}
@@ -2367,21 +2368,21 @@ static int acf_dslinestyle_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_S
static void *acf_dslinestyle_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(linestyle->flag, type);
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (linestyle->adt)
return GET_ACF_FLAG_PTR(linestyle->adt->flag, type);
return NULL;
-
+
default: /* unsupported */
return NULL;
}
@@ -2392,16 +2393,16 @@ static bAnimChannelType ACF_DSLINESTYLE =
{
"Line Style Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop,/* backdrop */
acf_generic_indention_1, /* indent level */
acf_generic_basic_offset, /* offset */
-
+
acf_generic_idblock_name, /* name */
acf_generic_idblock_name_prop, /* name prop */
acf_dslinestyle_icon, /* icon */
-
+
acf_generic_dataexpand_setting_valid, /* has setting */
acf_dslinestyle_setting_flag, /* flag for setting */
acf_dslinestyle_setting_ptr /* pointer for setting */
@@ -2420,21 +2421,21 @@ static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return ME_DS_EXPAND;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
default: /* unsupported */
return 0;
}
@@ -2444,21 +2445,21 @@ static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin
static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Mesh *me = (Mesh *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(me->flag, type);
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (me->adt)
return GET_ACF_FLAG_PTR(me->adt->flag, type);
return NULL;
-
+
default: /* unsupported */
return NULL;
}
@@ -2469,7 +2470,7 @@ static bAnimChannelType ACF_DSMESH =
{
"Mesh Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */ // XXX this only works for compositing
@@ -2497,21 +2498,21 @@ static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return LT_DS_EXPAND;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
default: /* unsupported */
return 0;
}
@@ -2521,21 +2522,21 @@ static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
static void *acf_dslat_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Lattice *lt = (Lattice *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(lt->flag, type);
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (lt->adt)
return GET_ACF_FLAG_PTR(lt->adt->flag, type);
return NULL;
-
+
default: /* unsupported */
return NULL;
}
@@ -2546,7 +2547,7 @@ static bAnimChannelType ACF_DSLAT =
{
"Lattice Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */ // XXX this only works for compositing
@@ -2574,21 +2575,21 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return SPK_DS_EXPAND;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
default: /* unsupported */
return 0;
}
@@ -2598,21 +2599,21 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting
static void *acf_dsspk_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Speaker *spk = (Speaker *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(spk->flag, type);
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (spk->adt)
return GET_ACF_FLAG_PTR(spk->adt->flag, type);
return NULL;
-
+
default: /* unsupported */
return NULL;
}
@@ -2623,7 +2624,7 @@ static bAnimChannelType ACF_DSSPK =
{
"Speaker Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -2651,21 +2652,21 @@ static int acf_dsgpencil_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Set
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GP_DATA_EXPAND;
-
+
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
-
+
default: /* unsupported */
return 0;
}
@@ -2675,21 +2676,21 @@ static int acf_dsgpencil_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Set
static void *acf_dsgpencil_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
bGPdata *gpd = (bGPdata *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(gpd->flag, type);
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (gpd->adt)
return GET_ACF_FLAG_PTR(gpd->adt->flag, type);
return NULL;
-
+
default: /* unsupported */
return NULL;
}
@@ -2700,7 +2701,7 @@ static bAnimChannelType ACF_DSGPENCIL =
{
"GPencil DS Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
@@ -2799,7 +2800,7 @@ static bAnimChannelType ACF_DSMCLIP =
static void acf_shapekey_name(bAnimListElem *ale, char *name)
{
KeyBlock *kb = (KeyBlock *)ale->data;
-
+
/* just copy the name... */
if (kb && name) {
/* if the KeyBlock had a name, use it, otherwise use the index */
@@ -2814,15 +2815,15 @@ static void acf_shapekey_name(bAnimListElem *ale, char *name)
static bool acf_shapekey_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
{
KeyBlock *kb = (KeyBlock *)ale->data;
-
+
/* if the KeyBlock had a name, use it, otherwise use the index */
if (kb && kb->name[0]) {
RNA_pointer_create(ale->id, &RNA_ShapeKey, kb, ptr);
*prop = RNA_struct_name_property(ptr->type);
-
+
return (*prop != NULL);
}
-
+
return false;
}
@@ -2834,7 +2835,7 @@ static bool acf_shapekey_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *
case ACHANNEL_SETTING_MUTE: /* muted */
case ACHANNEL_SETTING_PROTECT: /* protected */
return true;
-
+
/* nothing else is supported */
default:
return false;
@@ -2846,17 +2847,17 @@ static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Sett
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_MUTE: /* mute */
return KEYBLOCK_MUTE;
-
+
case ACHANNEL_SETTING_SELECT: /* selected */
return KEYBLOCK_SEL;
-
+
case ACHANNEL_SETTING_PROTECT: /* locked */
return KEYBLOCK_LOCKED;
-
+
default: /* unsupported */
return 0;
}
@@ -2866,16 +2867,16 @@ static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Sett
static void *acf_shapekey_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
KeyBlock *kb = (KeyBlock *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted */
case ACHANNEL_SETTING_PROTECT: /* protected */
return GET_ACF_FLAG_PTR(kb->flag, type);
-
+
default: /* unsupported */
return NULL;
}
@@ -2886,7 +2887,7 @@ static bAnimChannelType ACF_SHAPEKEY =
{
"Shape Key", /* type name */
ACHANNEL_ROLE_CHANNEL, /* role */
-
+
acf_generic_channel_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
acf_generic_indention_0, /* indent level */
@@ -2924,7 +2925,7 @@ static bool acf_gpd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSE
case ACHANNEL_SETTING_SELECT:
case ACHANNEL_SETTING_EXPAND:
return true;
-
+
default:
return false;
}
@@ -2935,14 +2936,14 @@ static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
return AGRP_SELECTED;
-
+
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GP_DATA_EXPAND;
-
+
default:
/* these shouldn't happen */
return 0;
@@ -2953,17 +2954,17 @@ static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings
static void *acf_gpd_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
{
bGPdata *gpd = (bGPdata *)ale->data;
-
+
/* all flags are just in gpd->flag for now... */
return GET_ACF_FLAG_PTR(gpd->flag, type);
}
/* gpencil datablock type define */
-static bAnimChannelType ACF_GPD =
+static bAnimChannelType ACF_GPD =
{
"GPencil Datablock", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_gpd_color, /* backdrop color */
acf_group_backdrop, /* backdrop */
acf_generic_indention_0, /* indent level */
@@ -2984,7 +2985,7 @@ static bAnimChannelType ACF_GPD =
static void acf_gpl_name(bAnimListElem *ale, char *name)
{
bGPDlayer *gpl = (bGPDlayer *)ale->data;
-
+
if (gpl && name)
BLI_strncpy(name, gpl->info, ANIM_CHAN_NAME_SIZE);
}
@@ -2995,10 +2996,10 @@ static bool acf_gpl_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA *
if (ale->data) {
RNA_pointer_create(ale->id, &RNA_GPencilLayer, ale->data, ptr);
*prop = RNA_struct_name_property(ptr->type);
-
+
return (*prop != NULL);
}
-
+
return false;
}
@@ -3010,7 +3011,7 @@ static bool acf_gpl_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSE
case ACHANNEL_SETTING_EXPAND: /* gpencil layers are more like F-Curves than groups */
case ACHANNEL_SETTING_SOLO: /* nla editor only */
return false;
-
+
/* always available */
default:
return true;
@@ -3022,21 +3023,21 @@ static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
return GP_LAYER_SELECT;
-
+
case ACHANNEL_SETTING_MUTE: /* animation muting - similar to frame lock... */
return GP_LAYER_FRAMELOCK;
-
+
case ACHANNEL_SETTING_VISIBLE: /* visiblity of the layers (NOT muting) */
*neg = true;
return GP_LAYER_HIDE;
-
+
case ACHANNEL_SETTING_PROTECT: /* protected */
return GP_LAYER_LOCKED;
-
+
default: /* unsupported */
return 0;
}
@@ -3046,26 +3047,26 @@ static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings
static void *acf_gpl_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
{
bGPDlayer *gpl = (bGPDlayer *)ale->data;
-
+
/* all flags are just in gpl->flag for now... */
return GET_ACF_FLAG_PTR(gpl->flag, type);
}
/* grease pencil layer type define */
-static bAnimChannelType ACF_GPL =
+static bAnimChannelType ACF_GPL =
{
"GPencil Layer", /* type name */
ACHANNEL_ROLE_CHANNEL, /* role */
-
+
acf_generic_channel_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
acf_generic_indention_flexible, /* indent level */
acf_generic_group_offset, /* offset */
-
+
acf_gpl_name, /* name */
acf_gpl_name_prop, /* name prop */
NULL, /* icon */
-
+
acf_gpl_setting_valid, /* has setting */
acf_gpl_setting_flag, /* flag for setting */
acf_gpl_setting_ptr /* pointer for setting */
@@ -3095,7 +3096,7 @@ static bool acf_mask_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUS
case ACHANNEL_SETTING_SELECT:
case ACHANNEL_SETTING_EXPAND:
return true;
-
+
default:
return false;
}
@@ -3106,15 +3107,15 @@ static int acf_mask_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
return AGRP_SELECTED;
-
+
case ACHANNEL_SETTING_EXPAND: /* expanded */
return MASK_ANIMF_EXPAND;
-
- default:
+
+ default:
/* this shouldn't happen */
return 0;
}
@@ -3124,7 +3125,7 @@ static int acf_mask_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings
static void *acf_mask_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
{
Mask *mask = (Mask *)ale->data;
-
+
/* all flags are just in mask->flag for now... */
return GET_ACF_FLAG_PTR(mask->flag, type);
}
@@ -3134,16 +3135,16 @@ static bAnimChannelType ACF_MASKDATA =
{
"Mask Datablock", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
-
+
acf_mask_color, /* backdrop color */
acf_group_backdrop, /* backdrop */
acf_generic_indention_0, /* indent level */
acf_generic_group_offset, /* offset */
-
+
acf_generic_idblock_name, /* name */
acf_generic_idfill_name_prop, /* name prop */
acf_mask_icon, /* icon */
-
+
acf_mask_setting_valid, /* has setting */
acf_mask_setting_flag, /* flag for setting */
acf_mask_setting_ptr /* pointer for setting */
@@ -3155,7 +3156,7 @@ static bAnimChannelType ACF_MASKDATA =
static void acf_masklay_name(bAnimListElem *ale, char *name)
{
MaskLayer *masklay = (MaskLayer *)ale->data;
-
+
if (masklay && name)
BLI_strncpy(name, masklay->name, ANIM_CHAN_NAME_SIZE);
}
@@ -3166,7 +3167,7 @@ static bool acf_masklay_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyR
if (ale->data) {
RNA_pointer_create(ale->id, &RNA_MaskLayer, ale->data, ptr);
*prop = RNA_struct_name_property(ptr->type);
-
+
return (*prop != NULL);
}
@@ -3182,7 +3183,7 @@ static bool acf_masklay_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *U
case ACHANNEL_SETTING_VISIBLE: /* graph editor only */
case ACHANNEL_SETTING_SOLO: /* nla editor only */
return false;
-
+
/* always available */
default:
return true;
@@ -3194,14 +3195,14 @@ static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setti
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
return MASK_LAYERFLAG_SELECT;
-
+
case ACHANNEL_SETTING_PROTECT: /* protected */
return MASK_LAYERFLAG_LOCKED;
-
+
default: /* unsupported */
return 0;
}
@@ -3211,7 +3212,7 @@ static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setti
static void *acf_masklay_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
{
MaskLayer *masklay = (MaskLayer *)ale->data;
-
+
/* all flags are just in masklay->flag for now... */
return GET_ACF_FLAG_PTR(masklay->flag, type);
}
@@ -3221,16 +3222,16 @@ static bAnimChannelType ACF_MASKLAYER =
{
"Mask Layer", /* type name */
ACHANNEL_ROLE_CHANNEL, /* role */
-
+
acf_generic_channel_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
acf_generic_indention_flexible, /* indent level */
acf_generic_group_offset, /* offset */
-
+
acf_masklay_name, /* name */
acf_masklay_name_prop, /* name prop */
NULL, /* icon */
-
+
acf_masklay_setting_valid, /* has setting */
acf_masklay_setting_flag, /* flag for setting */
acf_masklay_setting_ptr /* pointer for setting */
@@ -3244,7 +3245,7 @@ static void acf_nlatrack_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, flo
NlaTrack *nlt = (NlaTrack *)ale->data;
AnimData *adt = ale->adt;
bool nonSolo = false;
-
+
/* is track enabled for solo drawing? */
if ((adt) && (adt->flag & ADT_NLA_SOLO_TRACK)) {
if ((nlt->flag & NLATRACK_SOLO) == 0) {
@@ -3252,7 +3253,7 @@ static void acf_nlatrack_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, flo
nonSolo = true;
}
}
-
+
/* set color for nla track */
UI_GetThemeColorShade3fv(TH_HEADER, ((nonSolo == false) ? 20 : -20), r_color);
}
@@ -3261,7 +3262,7 @@ static void acf_nlatrack_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, flo
static void acf_nlatrack_name(bAnimListElem *ale, char *name)
{
NlaTrack *nlt = (NlaTrack *)ale->data;
-
+
if (nlt && name)
BLI_strncpy(name, nlt->name, ANIM_CHAN_NAME_SIZE);
}
@@ -3272,10 +3273,10 @@ static bool acf_nlatrack_name_prop(bAnimListElem *ale, PointerRNA *ptr, Property
if (ale->data) {
RNA_pointer_create(ale->id, &RNA_NlaTrack, ale->data, ptr);
*prop = RNA_struct_name_property(ptr->type);
-
+
return (*prop != NULL);
}
-
+
return false;
}
@@ -3284,14 +3285,14 @@ static bool acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *
{
NlaTrack *nlt = (NlaTrack *)ale->data;
AnimData *adt = ale->adt;
-
+
/* visibility of settings depends on various states... */
switch (setting) {
/* always supported */
case ACHANNEL_SETTING_SELECT:
case ACHANNEL_SETTING_SOLO:
return true;
-
+
/* conditionally supported... */
case ACHANNEL_SETTING_PROTECT:
case ACHANNEL_SETTING_MUTE:
@@ -3308,8 +3309,8 @@ static bool acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *
return false;
}
}
-
-
+
+
/* ok - no tracks are solo'd, and this isn't being tweaked */
return true;
}
@@ -3317,7 +3318,7 @@ static bool acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *
/* unsupported - this track is being tweaked */
return false;
}
-
+
/* unsupported */
default:
return false;
@@ -3329,20 +3330,20 @@ static int acf_nlatrack_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Sett
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
return NLATRACK_SELECTED;
-
+
case ACHANNEL_SETTING_MUTE: /* muted */
return NLATRACK_MUTED;
-
+
case ACHANNEL_SETTING_PROTECT: /* protected */
return NLATRACK_PROTECTED;
-
+
case ACHANNEL_SETTING_SOLO: /* solo */
return NLATRACK_SOLO;
-
+
default: /* unsupported */
return 0;
}
@@ -3356,20 +3357,20 @@ static void *acf_nlatrack_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings
}
/* nla track type define */
-static bAnimChannelType ACF_NLATRACK =
+static bAnimChannelType ACF_NLATRACK =
{
"NLA Track", /* type name */
ACHANNEL_ROLE_CHANNEL, /* role */
-
+
acf_nlatrack_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
acf_generic_indention_flexible, /* indent level */
acf_generic_group_offset, /* offset */ // XXX?
-
+
acf_nlatrack_name, /* name */
acf_nlatrack_name_prop, /* name prop */
NULL, /* icon */
-
+
acf_nlatrack_setting_valid, /* has setting */
acf_nlatrack_setting_flag, /* flag for setting */
acf_nlatrack_setting_ptr /* pointer for setting */
@@ -3381,7 +3382,7 @@ static bAnimChannelType ACF_NLATRACK =
static int acf_nlaaction_icon(bAnimListElem *ale)
{
AnimData *adt = ale->adt;
-
+
/* indicate tweaking-action state by changing the icon... */
if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) {
return ICON_ACTION_TWEAK;
@@ -3391,28 +3392,28 @@ static int acf_nlaaction_icon(bAnimListElem *ale)
}
}
-/* Backdrop color for nla action channel
+/* Backdrop color for nla action channel
* Although this can't be used directly for NLA Action drawing,
* it is still needed for use behind the RHS toggles
*/
static void acf_nlaaction_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, float r_color[3])
{
float color[4];
-
+
/* Action Line
- * The alpha values action_get_color returns are only useful for drawing
+ * The alpha values action_get_color returns are only useful for drawing
* strips backgrounds but here we're doing channel list backgrounds instead
* so we ignore that and use our own when needed
*/
nla_action_get_color(ale->adt, (bAction *)ale->data, color);
-
+
/* NOTE: since the return types only allow rgb, we cannot do the alpha-blending we'd
* like for the solo-drawing case. Hence, this method isn't actually used for drawing
* most of the channel...
*/
copy_v3_v3(r_color, color);
}
-
+
/* backdrop for nla action channel */
static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
{
@@ -3421,14 +3422,14 @@ static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float y
AnimData *adt = ale->adt;
short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
float color[4];
-
+
/* Action Line
- * The alpha values action_get_color returns are only useful for drawing
+ * The alpha values action_get_color returns are only useful for drawing
* strips backgrounds but here we're doing channel list backgrounds instead
* so we ignore that and use our own when needed
*/
nla_action_get_color(adt, (bAction *)ale->data, color);
-
+
if (adt && (adt->flag & ADT_NLA_EDIT_ON))
color[3] = 1.0f;
else
@@ -3449,7 +3450,7 @@ static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float y
static void acf_nlaaction_name(bAnimListElem *ale, char *name)
{
bAction *act = (bAction *)ale->data;
-
+
if (name) {
if (act) {
// TODO: add special decoration when doing this in tweaking mode?
@@ -3467,10 +3468,10 @@ static bool acf_nlaaction_name_prop(bAnimListElem *ale, PointerRNA *ptr, Propert
if (ale->data) {
RNA_pointer_create(ale->id, &RNA_Action, ale->data, ptr);
*prop = RNA_struct_name_property(ptr->type);
-
+
return (*prop != NULL);
}
-
+
return false;
}
@@ -3478,7 +3479,7 @@ static bool acf_nlaaction_name_prop(bAnimListElem *ale, PointerRNA *ptr, Propert
static bool acf_nlaaction_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *ale, eAnimChannel_Settings setting)
{
AnimData *adt = ale->adt;
-
+
/* visibility of settings depends on various states... */
switch (setting) {
/* conditionally supported */
@@ -3490,7 +3491,7 @@ static bool acf_nlaaction_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem
else {
return false;
}
-
+
/* unsupported */
default:
return false;
@@ -3502,12 +3503,12 @@ static int acf_nlaaction_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Set
{
/* clear extra return data first */
*neg = false;
-
+
switch (setting) {
case ACHANNEL_SETTING_PINNED: /* pinned - map/unmap */
*neg = true; // XXX
return ADT_NLA_EDIT_NOMAP;
-
+
default: /* unsupported */
return 0;
}
@@ -3521,20 +3522,20 @@ static void *acf_nlaaction_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings
}
/* nla action type define */
-static bAnimChannelType ACF_NLAACTION =
+static bAnimChannelType ACF_NLAACTION =
{
"NLA Active Action", /* type name */
ACHANNEL_ROLE_CHANNEL, /* role */
-
+
acf_nlaaction_color, /* backdrop color (NOTE: the backdrop handles this too, since it needs special hacks) */
acf_nlaaction_backdrop, /* backdrop */
acf_generic_indention_flexible, /* indent level */
acf_generic_group_offset, /* offset */ // XXX?
-
+
acf_nlaaction_name, /* name */
acf_nlaaction_name_prop, /* name prop */
acf_nlaaction_icon, /* icon */
-
+
acf_nlaaction_setting_valid, /* has setting */
acf_nlaaction_setting_flag, /* flag for setting */
acf_nlaaction_setting_ptr /* pointer for setting */
@@ -3552,31 +3553,31 @@ static short ACF_INIT = 1; /* when non-zero, the list needs to be updated */
static void ANIM_init_channel_typeinfo_data(void)
{
int type = 0;
-
+
/* start initializing if necessary... */
if (ACF_INIT) {
ACF_INIT = 0;
-
+
/* NOTE: need to keep the order of these synchronized with the definition of
* channel types (eAnim_ChannelType) in ED_anim_api.h
*/
animchannelTypeInfo[type++] = NULL; /* None */
animchannelTypeInfo[type++] = NULL; /* AnimData */
animchannelTypeInfo[type++] = NULL; /* Special */
-
+
animchannelTypeInfo[type++] = &ACF_SUMMARY; /* Motion Summary */
-
+
animchannelTypeInfo[type++] = &ACF_SCENE; /* Scene */
animchannelTypeInfo[type++] = &ACF_OBJECT; /* Object */
animchannelTypeInfo[type++] = &ACF_GROUP; /* Group */
animchannelTypeInfo[type++] = &ACF_FCURVE; /* F-Curve */
-
+
animchannelTypeInfo[type++] = &ACF_NLACONTROLS; /* NLA Control FCurve Expander */
animchannelTypeInfo[type++] = &ACF_NLACURVE; /* NLA Control FCurve Channel */
-
+
animchannelTypeInfo[type++] = &ACF_FILLACTD; /* Object Action Expander */
animchannelTypeInfo[type++] = &ACF_FILLDRIVERS; /* Drivers Expander */
-
+
animchannelTypeInfo[type++] = &ACF_DSMAT; /* Material Channel */
animchannelTypeInfo[type++] = &ACF_DSLAM; /* Lamp Channel */
animchannelTypeInfo[type++] = &ACF_DSCAM; /* Camera Channel */
@@ -3595,19 +3596,19 @@ static void ANIM_init_channel_typeinfo_data(void)
animchannelTypeInfo[type++] = &ACF_DSSPK; /* Speaker Channel */
animchannelTypeInfo[type++] = &ACF_DSGPENCIL; /* GreasePencil Channel */
animchannelTypeInfo[type++] = &ACF_DSMCLIP; /* MovieClip Channel */
-
+
animchannelTypeInfo[type++] = &ACF_SHAPEKEY; /* ShapeKey */
-
+
animchannelTypeInfo[type++] = &ACF_GPD; /* Grease Pencil Datablock */
animchannelTypeInfo[type++] = &ACF_GPL; /* Grease Pencil Layer */
-
+
animchannelTypeInfo[type++] = &ACF_MASKDATA; /* Mask Datablock */
animchannelTypeInfo[type++] = &ACF_MASKLAYER; /* Mask Layer */
-
+
animchannelTypeInfo[type++] = &ACF_NLATRACK; /* NLA Track */
animchannelTypeInfo[type++] = &ACF_NLAACTION; /* NLA Action */
}
-}
+}
/* Get type info from given channel type */
const bAnimChannelType *ANIM_channel_get_typeinfo(bAnimListElem *ale)
@@ -3615,10 +3616,10 @@ const bAnimChannelType *ANIM_channel_get_typeinfo(bAnimListElem *ale)
/* santiy checks */
if (ale == NULL)
return NULL;
-
+
/* init the typeinfo if not available yet... */
ANIM_init_channel_typeinfo_data();
-
+
/* check if type is in bounds... */
if ((ale->type >= 0) && (ale->type < ANIMTYPE_NUM_TYPES))
return animchannelTypeInfo[ale->type];
@@ -3632,21 +3633,21 @@ const bAnimChannelType *ANIM_channel_get_typeinfo(bAnimListElem *ale)
void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
-
+
/* print indents */
for (; indent_level > 0; indent_level--)
printf(" ");
-
+
/* print info */
if (acf) {
char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */
-
+
/* get UI name */
if (acf->name)
acf->name(ale, name);
else
BLI_strncpy(name, "<No name>", sizeof(name));
-
+
/* print type name + ui name */
printf("ChanType: <%s> Name: \"%s\"\n", acf->channel_type_name, name);
}
@@ -3658,13 +3659,13 @@ void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level)
/* --------------------------- */
-/* Check if some setting for a channel is enabled
+/* Check if some setting for a channel is enabled
* Returns: 1 = On, 0 = Off, -1 = Invalid
*/
short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
-
+
/* 1) check that the setting exists for the current context */
if ((acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting))) {
/* 2) get pointer to check for flag in, and the flag to check for */
@@ -3672,17 +3673,17 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChanne
bool negflag;
int flag;
void *ptr;
-
+
flag = acf->setting_flag(ac, setting, &negflag);
ptr = acf->setting_ptr(ale, setting, &ptrsize);
-
+
/* check if flag is enabled */
if (ptr && flag) {
switch (ptrsize) {
case sizeof(int): /* integer pointer for setting */
{
const int *val = (int *)ptr;
-
+
if (negflag)
return ((*val) & flag) == 0;
else
@@ -3691,7 +3692,7 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChanne
case sizeof(short): /* short pointer for setting */
{
const short *val = (short *)ptr;
-
+
if (negflag)
return ((*val) & flag) == 0;
else
@@ -3700,7 +3701,7 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChanne
case sizeof(char): /* char pointer for setting */
{
const char *val = (char *)ptr;
-
+
if (negflag)
return ((*val) & flag) == 0;
else
@@ -3709,10 +3710,10 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChanne
}
}
}
-
+
/* not found... */
return -1;
-}
+}
/* quick macro for use in ANIM_channel_setting_set - set flag for setting according the mode given */
@@ -3730,14 +3731,14 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChanne
} \
} (void)0
-/* Change value of some setting for a channel
+/* Change value of some setting for a channel
* - setting: eAnimChannel_Settings
* - mode: eAnimChannels_SetFlag
*/
void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting, eAnimChannels_SetFlag mode)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
-
+
/* 1) check that the setting exists for the current context */
if ((acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting))) {
/* 2) get pointer to check for flag in, and the flag to check for */
@@ -3745,10 +3746,10 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, eAnimChannel
bool negflag;
int flag;
void *ptr;
-
+
flag = acf->setting_flag(ac, setting, &negflag);
ptr = acf->setting_ptr(ale, setting, &ptrsize);
-
+
/* check if flag is enabled */
if (ptr && flag) {
switch (ptrsize) {
@@ -3794,7 +3795,7 @@ static bool achannel_is_being_renamed(const bAnimContext *ac, const bAnimChannel
return true;
}
}
-
+
/* not being renamed */
return false;
}
@@ -3807,52 +3808,52 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
View2D *v2d = &ac->ar->v2d;
short selected, offset;
float y, ymid, ytext;
-
+
/* sanity checks - don't draw anything */
if (ELEM(NULL, acf, ale))
return;
-
+
/* get initial offset */
if (acf->get_offset)
offset = acf->get_offset(ac, ale);
else
offset = 0;
-
+
/* calculate appropriate y-coordinates for icon buttons */
y = (ymaxc - yminc) / 2 + yminc;
ymid = y - 0.5f * ICON_WIDTH;
/* y-coordinates for text is only 4 down from middle */
ytext = y - 0.2f * U.widget_unit;
-
+
/* check if channel is selected */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT))
selected = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT);
else
selected = 0;
-
+
/* set blending again, as may not be set in previous step */
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
-
+
/* step 1) draw backdrop ........................................... */
if (acf->draw_backdrop)
acf->draw_backdrop(ac, ale, yminc, ymaxc);
-
+
/* step 2) draw expand widget ....................................... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_EXPAND)) {
/* just skip - drawn as widget now */
- offset += ICON_WIDTH;
+ offset += ICON_WIDTH;
}
-
+
/* step 3) draw icon ............................................... */
if (acf->icon) {
UI_icon_draw(offset, ymid, acf->icon(ale));
- offset += ICON_WIDTH;
+ offset += ICON_WIDTH;
}
-
+
/* turn off blending, since not needed anymore... */
glDisable(GL_BLEND);
-
+
/* step 4) draw special toggles .................................
* - in Graph Editor, checkboxes for visibility in curves area
* - in NLA Editor, glowing dots for solo/not solo...
@@ -3869,12 +3870,12 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever
- * color the curve has stored
+
+ /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever
+ * color the curve has stored
*/
immUniformColor3fv(fcu->color);
-
+
/* just a solid color rect
*/
immRectf(pos, offset, yminc, offset + ICON_WIDTH, ymaxc);
@@ -3891,7 +3892,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
}
else if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) {
/* just skip - drawn as widget now */
- offset += ICON_WIDTH;
+ offset += ICON_WIDTH;
}
else if (ale->type == ANIMTYPE_GPLAYER) {
/* just skip - drawn as a widget */
@@ -3900,7 +3901,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
}
/* step 5) draw name ............................................... */
- /* Don't draw this if renaming... */
+ /* Don't draw this if renaming... */
if (acf->name && !achannel_is_being_renamed(ac, acf, channel_index)) {
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */
@@ -3916,10 +3917,10 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
/* get name */
acf->name(ale, name);
-
+
offset += 3;
UI_fontstyle_draw_simple(fstyle, offset, ytext, name, col);
-
+
/* draw red underline if channel is disabled */
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE) && (ale->flag & FCURVE_DISABLED)) {
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -3953,11 +3954,11 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
+
/* get and set backdrop color */
acf->get_backdrop_color(ac, ale, color);
immUniformColor3fv(color);
-
+
/* check if we need to show the sliders */
if ((ac->sl) && ELEM(ac->spacetype, SPACE_ACTION, SPACE_IPO)) {
switch (ac->spacetype) {
@@ -3981,24 +3982,24 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
/* protect... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT))
offset += ICON_WIDTH;
-
+
/* mute... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE))
offset += ICON_WIDTH;
if (ale->type == ANIMTYPE_GPLAYER)
offset += ICON_WIDTH;
-
+
/* pinned... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PINNED))
offset += ICON_WIDTH;
-
+
/* NOTE: technically, NLA Action "pushdown" should be here too, but there are no sliders there */
-
+
/* NLA action channels have slightly different spacing requirements... */
if (ale->type == ANIMTYPE_NLAACTION)
ymin_ofs = NLACHANNEL_SKIP;
}
-
+
/* draw slider
* - even if we can draw sliders for this view, we must also check that the channel-type supports them
* (only only F-Curves really can support them for now)
@@ -4008,10 +4009,10 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
/* adjust offset */
offset += SLIDER_WIDTH;
}
-
-
+
+
/* finally draw a backdrop rect behind these
- * - starts from the point where the first toggle/slider starts,
+ * - starts from the point where the first toggle/slider starts,
* - ends past the space that might be reserved for a scroller
*/
immRectf(pos, v2d->cur.xmax - (float)offset, yminc + ymin_ofs, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc);
@@ -4037,7 +4038,7 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void
int filter;
int setting = GET_INT_FROM_POINTER(setting_wrap);
short on = 0;
-
+
/* send notifiers before doing anything else... */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
@@ -4048,11 +4049,20 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void
if (ale_setting->type == ANIMTYPE_GPLAYER)
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL);
-
+
+ /* tag copy-on-write flushing (so that the settings will have an effect) */
+ if (ale_setting->id) {
+ DEG_id_tag_update(ale_setting->id, DEG_TAG_COPY_ON_WRITE);
+ }
+ if (ale_setting->adt && ale_setting->adt->action) {
+ /* action is it's own datablock, so has to be tagged specifically... */
+ DEG_id_tag_update(&ale_setting->adt->action->id, DEG_TAG_COPY_ON_WRITE);
+ }
+
/* verify animation context */
if (ANIM_animdata_get_context(C, &ac) == 0)
return;
-
+
/* check if the setting is on... */
on = ANIM_channel_setting_get(&ac, ale_setting, setting);
@@ -4060,14 +4070,14 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void
if (on == -1) {
return;
}
-
+
/* get all channels that can possibly be chosen - but ignore hierarchy */
filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS;
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* call API method to flush the setting */
ANIM_flush_setting_anim_channels(&ac, &anim_data, ale_setting, setting, on);
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
}
@@ -4077,7 +4087,7 @@ static void achannel_nlatrack_solo_widget_cb(bContext *C, void *adt_poin, void *
{
AnimData *adt = adt_poin;
NlaTrack *nlt = nlt_poin;
-
+
/* Toggle 'solo' mode. There are several complications here which need explaining:
* - The method call is needed to perform a few additional validation operations
* to ensure that the mode is applied properly
@@ -4087,7 +4097,7 @@ static void achannel_nlatrack_solo_widget_cb(bContext *C, void *adt_poin, void *
*/
nlt->flag ^= NLATRACK_SOLO;
BKE_nlatrack_solo_toggle(adt, nlt);
-
+
/* send notifiers */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_RENAME, NULL);
}
@@ -4098,7 +4108,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi
ID *id = (ID *)id_poin;
AnimData *adt = BKE_animdata_from_id(id);
FCurve *fcu = (FCurve *)fcu_poin;
-
+
Depsgraph *depsgraph = CTX_data_depsgraph(C);
ReportList *reports = CTX_wm_reports(C);
Scene *scene = CTX_data_scene(C);
@@ -4108,25 +4118,25 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi
short flag = 0;
bool done = false;
float cfra;
-
+
/* get current frame and apply NLA-mapping to it (if applicable) */
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
-
+
/* get flags for keyframing */
flag = ANIM_get_keyframing_flags(scene, 1);
-
+
/* get RNA pointer, and resolve the path */
RNA_id_pointer_create(id, &id_ptr);
-
+
/* try to resolve the path stored in the F-Curve */
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
/* set the special 'replace' flag if on a keyframe */
if (fcurve_frame_has_keyframe(fcu, cfra, 0))
flag |= INSERTKEY_REPLACE;
-
+
/* insert a keyframe for this F-Curve */
done = insert_keyframe_direct(depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, flag);
-
+
if (done)
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
}
@@ -4135,10 +4145,11 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi
/* callback for shapekey widget sliders - insert keyframes */
static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, void *kb_poin)
{
+ Main *bmain = CTX_data_main(C);
Key *key = (Key *)key_poin;
KeyBlock *kb = (KeyBlock *)kb_poin;
char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb);
-
+
Depsgraph *depsgraph = CTX_data_depsgraph(C);
ReportList *reports = CTX_wm_reports(C);
Scene *scene = CTX_data_scene(C);
@@ -4148,34 +4159,34 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi
short flag = 0;
bool done = false;
float cfra;
-
+
/* get current frame and apply NLA-mapping to it (if applicable) */
cfra = BKE_nla_tweakedit_remap(key->adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
-
+
/* get flags for keyframing */
flag = ANIM_get_keyframing_flags(scene, 1);
-
+
/* get RNA pointer, and resolve the path */
RNA_id_pointer_create((ID *)key, &id_ptr);
-
+
/* try to resolve the path stored in the F-Curve */
if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop)) {
/* find or create new F-Curve */
// XXX is the group name for this ok?
- bAction *act = verify_adt_action((ID *)key, 1);
+ bAction *act = verify_adt_action(bmain, (ID *)key, 1);
FCurve *fcu = verify_fcurve(act, NULL, &ptr, rna_path, 0, 1);
-
+
/* set the special 'replace' flag if on a keyframe */
if (fcurve_frame_has_keyframe(fcu, cfra, 0))
flag |= INSERTKEY_REPLACE;
-
+
/* insert a keyframe for this F-Curve */
done = insert_keyframe_direct(depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, flag);
-
+
if (done)
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
}
-
+
/* free the path */
if (rna_path)
MEM_freeN(rna_path);
@@ -4186,11 +4197,11 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C, void *UNUSED(id_po
{
/* ID *id = (ID *)id_poin; */
FCurve *fcu = (FCurve *)fcu_poin;
-
+
PointerRNA ptr;
PropertyRNA *prop;
int index;
-
+
Depsgraph *depsgraph = CTX_data_depsgraph(C);
ReportList *reports = CTX_wm_reports(C);
Scene *scene = CTX_data_scene(C);
@@ -4198,24 +4209,24 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C, void *UNUSED(id_po
short flag = 0;
bool done = false;
float cfra;
-
+
/* get current frame - *no* NLA mapping should be done */
cfra = (float)CFRA;
-
+
/* get flags for keyframing */
flag = ANIM_get_keyframing_flags(scene, 1);
-
+
/* get pointer and property from the slider - this should all match up with the NlaStrip required... */
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
-
+
if (fcu && prop) {
/* set the special 'replace' flag if on a keyframe */
if (fcurve_frame_has_keyframe(fcu, cfra, 0))
flag |= INSERTKEY_REPLACE;
-
+
/* insert a keyframe for this F-Curve */
done = insert_keyframe_direct(depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, flag);
-
+
if (done)
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
}
@@ -4232,18 +4243,18 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni
void *ptr;
const char *tooltip;
uiBut *but = NULL;
-
+
/* get the flag and the pointer to that flag */
flag = acf->setting_flag(ac, setting, &negflag);
ptr = acf->setting_ptr(ale, setting, &ptrsize);
/* enabled = ANIM_channel_setting_get(ac, ale, setting); */ /* UNUSED */
-
+
/* get the base icon for the setting */
switch (setting) {
case ACHANNEL_SETTING_VISIBLE: /* visibility eyes */
//icon = ((enabled) ? ICON_VISIBLE_IPO_ON : ICON_VISIBLE_IPO_OFF);
icon = ICON_VISIBLE_IPO_OFF;
-
+
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE))
tooltip = TIP_("F-Curve is visible in Graph Editor for editing");
else if (ale->type == ANIMTYPE_GPLAYER)
@@ -4268,30 +4279,30 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni
icon = ICON_TRIA_RIGHT;
tooltip = TIP_("Make channels grouped under this channel visible");
break;
-
+
case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */
//icon = ((enabled) ? ICON_SOLO_OFF : ICON_SOLO_ON);
icon = ICON_SOLO_OFF;
tooltip = TIP_("NLA Track is the only one evaluated in this animation data-block, with all others muted");
break;
-
+
/* --- */
-
+
case ACHANNEL_SETTING_PROTECT: /* protected lock */
// TODO: what about when there's no protect needed?
//icon = ((enabled) ? ICON_LOCKED : ICON_UNLOCKED);
icon = ICON_UNLOCKED;
-
+
if (ale->datatype != ALE_NLASTRIP)
tooltip = TIP_("Editability of keyframes for this channel");
else
tooltip = TIP_("Editability of NLA Strips in this track");
break;
-
+
case ACHANNEL_SETTING_MUTE: /* muted speaker */
//icon = ((enabled) ? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF);
icon = ICON_MUTE_IPO_OFF;
-
+
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
tooltip = TIP_("Does F-Curve contribute to result");
}
@@ -4305,11 +4316,11 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni
tooltip = TIP_("Do channels contribute to result (toggle channel muting)");
}
break;
-
+
case ACHANNEL_SETTING_PINNED: /* pin icon */
//icon = ((enabled) ? ICON_PINNED : ICON_UNPINNED);
icon = ICON_UNPINNED;
-
+
if (ale->type == ANIMTYPE_NLAACTION) {
tooltip = TIP_("Display action without any time remapping (when unpinned)");
}
@@ -4318,13 +4329,13 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni
tooltip = NULL;
}
break;
-
+
default:
tooltip = NULL;
icon = 0;
break;
}
-
+
/* type of button */
if (usetoggle) {
if (negflag)
@@ -4342,21 +4353,21 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni
if (ptr && flag) {
switch (ptrsize) {
case sizeof(int): /* integer pointer for setting */
- but = uiDefIconButBitI(block, butType, flag, 0, icon,
+ but = uiDefIconButBitI(block, butType, flag, 0, icon,
xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip);
break;
-
+
case sizeof(short): /* short pointer for setting */
- but = uiDefIconButBitS(block, butType, flag, 0, icon,
+ but = uiDefIconButBitS(block, butType, flag, 0, icon,
xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip);
break;
-
+
case sizeof(char): /* char pointer for setting */
- but = uiDefIconButBitC(block, butType, flag, 0, icon,
+ but = uiDefIconButBitC(block, butType, flag, 0, icon,
xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip);
break;
}
-
+
/* set call to send relevant notifiers and/or perform type-specific updates */
if (but) {
switch (setting) {
@@ -4369,12 +4380,12 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni
case ACHANNEL_SETTING_ALWAYS_VISIBLE:
UI_but_funcN_set(but, achannel_setting_flush_widget_cb, MEM_dupallocN(ale), SET_INT_IN_POINTER(setting));
break;
-
+
/* settings needing special attention */
case ACHANNEL_SETTING_SOLO: /* NLA Tracks - Solo toggle */
UI_but_func_set(but, achannel_nlatrack_solo_widget_cb, ale->adt, ale->data);
break;
-
+
/* no flushing */
case ACHANNEL_SETTING_EXPAND: /* expanding - cannot flush, otherwise all would open/close at once */
default:
@@ -4393,37 +4404,37 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
float y, ymid /*, ytext*/;
short offset;
const bool is_being_renamed = achannel_is_being_renamed(ac, acf, channel_index);
-
+
/* sanity checks - don't draw anything */
if (ELEM(NULL, acf, ale, block))
return;
-
+
/* get initial offset */
if (acf->get_offset)
offset = acf->get_offset(ac, ale);
else
offset = 0;
-
- /* calculate appropriate y-coordinates for icon buttons
+
+ /* calculate appropriate y-coordinates for icon buttons
*/
y = (ymaxc - yminc) / 2 + yminc;
ymid = y - 0.5f * ICON_WIDTH;
-
+
/* no button backdrop behind icons */
UI_block_emboss_set(block, UI_EMBOSS_NONE);
-
+
/* step 1) draw expand widget ....................................... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_EXPAND)) {
draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_EXPAND);
- offset += ICON_WIDTH;
+ offset += ICON_WIDTH;
}
-
+
/* step 2) draw icon ............................................... */
if (acf->icon) {
/* icon is not drawn here (not a widget) */
- offset += ICON_WIDTH;
+ offset += ICON_WIDTH;
}
-
+
/* step 3) draw special toggles .................................
* - in Graph Editor, checkboxes for visibility in curves area
* - in NLA Editor, glowing dots for solo/not solo...
@@ -4448,7 +4459,7 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
else if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) {
/* 'solo' setting for NLA Tracks */
draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_SOLO);
- offset += ICON_WIDTH;
+ offset += ICON_WIDTH;
}
else if (ale->type == ANIMTYPE_GPLAYER) {
#if 0
@@ -4457,18 +4468,18 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
bGPDlayer *gpl = (bGPDlayer *)ale->data;
PointerRNA ptr;
float w = ICON_WIDTH / 2.0f;
-
+
RNA_pointer_create(ale->id, &RNA_GPencilLayer, ale->data, &ptr);
-
+
UI_block_align_begin(block);
UI_block_emboss_set(block, RNA_boolean_get(&ptr, "is_stroke_visible") ? UI_EMBOSS : UI_EMBOSS_NONE);
- uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset, yminc, w, ICON_WIDTH,
- &ptr, "color", -1,
+ uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset, yminc, w, ICON_WIDTH,
+ &ptr, "color", -1,
0, 0, 0, 0, gpl->info);
-
+
UI_block_emboss_set(block, RNA_boolean_get(&ptr, "is_fill_visible") ? UI_EMBOSS : UI_EMBOSS_NONE);
- uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset + w, yminc, w, ICON_WIDTH,
- &ptr, "fill_color", -1,
+ uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset + w, yminc, w, ICON_WIDTH,
+ &ptr, "fill_color", -1,
0, 0, 0, 0, gpl->info);
UI_block_emboss_set(block, UI_EMBOSS_NONE);
UI_block_align_end(block);
@@ -4477,14 +4488,14 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
#endif
}
}
-
+
/* step 4) draw text - check if renaming widget is in use... */
if (is_being_renamed) {
PointerRNA ptr = {{NULL}};
PropertyRNA *prop = NULL;
-
- /* draw renaming widget if we can get RNA pointer for it
- * NOTE: property may only be available in some cases, even if we have
+
+ /* draw renaming widget if we can get RNA pointer for it
+ * NOTE: property may only be available in some cases, even if we have
* a callback available (e.g. broken F-Curve rename)
*/
if (acf->name_prop(ale, &ptr, &prop)) {
@@ -4492,21 +4503,21 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
const short channel_height = round_fl_to_int(ymaxc - yminc);
const short width = ac->ar->winx - offset - (margin_x * 2);
uiBut *but;
-
+
UI_block_emboss_set(block, UI_EMBOSS);
-
+
but = uiDefButR(block, UI_BTYPE_TEXT, 1, "", offset + margin_x, yminc,
MAX2(width, RENAME_TEXT_MIN_WIDTH), channel_height,
&ptr, RNA_property_identifier(prop), -1, 0, 0, -1, -1, NULL);
-
+
/* copy what outliner does here, see outliner_buttons */
if (UI_but_active_only(C, ac->ar, block, but) == false) {
ac->ads->renameIndex = 0;
-
+
/* send notifiers */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_RENAME, NULL);
}
-
+
UI_block_emboss_set(block, UI_EMBOSS_NONE);
}
else {
@@ -4517,15 +4528,15 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL);
}
}
-
+
/* step 5) draw mute+protection toggles + (sliders) ....................... */
/* reset offset - now goes from RHS of panel */
offset = 0;
-
+
// TODO: when drawing sliders, make those draw instead of these toggles if not enough space
if (v2d && !is_being_renamed) {
short draw_sliders = 0;
-
+
/* check if we need to show the sliders */
if ((ac->sl) && ELEM(ac->spacetype, SPACE_ACTION, SPACE_IPO)) {
switch (ac->spacetype) {
@@ -4543,12 +4554,12 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
}
}
}
-
+
/* check if there's enough space for the toggles if the sliders are drawn too */
if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) {
/* protect... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) {
- offset += ICON_WIDTH;
+ offset += ICON_WIDTH;
draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_PROTECT);
}
/* mute... */
@@ -4561,43 +4572,43 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
offset += ICON_WIDTH;
draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_VISIBLE);
}
-
+
/* modifiers disable */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MOD_OFF)) {
offset += ICON_WIDTH * 1.2f; /* hack: extra spacing, to avoid touching the mute toggle */
draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_MOD_OFF);
}
-
+
/* ----------- */
-
+
/* pinned... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PINNED)) {
offset += ICON_WIDTH;
draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_PINNED);
}
-
+
/* NLA Action "pushdown" */
if ((ale->type == ANIMTYPE_NLAACTION) && (ale->adt && ale->adt->action) && !(ale->adt->flag & ADT_NLA_EDIT_ON)) {
uiBut *but;
PointerRNA *opptr_b;
-
+
UI_block_emboss_set(block, UI_EMBOSS);
-
+
offset += UI_UNIT_X;
- but = uiDefIconButO(block, UI_BTYPE_BUT, "NLA_OT_action_pushdown", WM_OP_INVOKE_DEFAULT, ICON_NLA_PUSHDOWN,
+ but = uiDefIconButO(block, UI_BTYPE_BUT, "NLA_OT_action_pushdown", WM_OP_INVOKE_DEFAULT, ICON_NLA_PUSHDOWN,
(int)v2d->cur.xmax - offset, ymid, UI_UNIT_X, UI_UNIT_X, NULL);
-
+
opptr_b = UI_but_operator_ptr_get(but);
RNA_int_set(opptr_b, "channel_index", channel_index);
-
+
UI_block_emboss_set(block, UI_EMBOSS_NONE);
}
}
-
+
/* draw slider
* - even if we can draw sliders for this view, we must also check that the channel-type supports them
* (only only F-Curves really can support them for now)
- * - to make things easier, we use RNA-autobuts for this so that changes are reflected immediately,
+ * - to make things easier, we use RNA-autobuts for this so that changes are reflected immediately,
* wherever they occurred. BUT, we don't use the layout engine, otherwise we'd get wrong alignment,
* and wouldn't be able to auto-keyframe...
* - slider should start before the toggles (if they're visible) to keep a clean line down the side
@@ -4606,25 +4617,25 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
/* adjust offset */
// TODO: make slider width dynamic, so that they can be easier to use when the view is wide enough
offset += SLIDER_WIDTH;
-
+
/* need backdrop behind sliders... */
UI_block_emboss_set(block, UI_EMBOSS);
-
+
if (ale->owner) { /* Slider using custom RNA Access ---------- */
if (ale->type == ANIMTYPE_NLACURVE) {
NlaStrip *strip = (NlaStrip *)ale->owner;
FCurve *fcu = (FCurve *)ale->data;
PointerRNA ptr;
PropertyRNA *prop;
-
+
/* create RNA pointers */
RNA_pointer_create(ale->id, &RNA_NlaStrip, strip, &ptr);
prop = RNA_struct_find_property(&ptr, fcu->rna_path);
-
+
/* create property slider */
if (prop) {
uiBut *but;
-
+
/* create the slider button, and assign relevant callback to ensure keyframes are inserted... */
but = uiDefAutoButR(block, &ptr, prop, fcu->array_index, "", ICON_NONE, (int)v2d->cur.xmax - offset, ymid, SLIDER_WIDTH, (int)ymaxc - yminc);
UI_but_func_set(but, achannel_setting_slider_nla_curve_cb, ale->id, ale->data);
@@ -4637,41 +4648,41 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
char *rna_path = NULL;
int array_index = 0;
short free_path = 0;
-
+
/* get destination info */
if (ale->type == ANIMTYPE_FCURVE) {
FCurve *fcu = (FCurve *)ale->data;
-
+
rna_path = fcu->rna_path;
array_index = fcu->array_index;
}
else if (ale->type == ANIMTYPE_SHAPEKEY) {
KeyBlock *kb = (KeyBlock *)ale->data;
Key *key = (Key *)ale->id;
-
+
rna_path = BKE_keyblock_curval_rnapath_get(key, kb);
free_path = 1;
}
-
+
/* only if RNA-Path found */
if (rna_path) {
/* get RNA pointer, and resolve the path */
RNA_id_pointer_create(ale->id, &id_ptr);
-
+
/* try to resolve the path */
if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop)) {
uiBut *but;
-
+
/* create the slider button, and assign relevant callback to ensure keyframes are inserted... */
but = uiDefAutoButR(block, &ptr, prop, array_index, "", ICON_NONE, (int)v2d->cur.xmax - offset, ymid, SLIDER_WIDTH, (int)ymaxc - yminc);
-
+
/* assign keyframing function according to slider type */
if (ale->type == ANIMTYPE_SHAPEKEY)
UI_but_func_set(but, achannel_setting_slider_shapekey_cb, ale->id, ale->data);
else
UI_but_func_set(but, achannel_setting_slider_cb, ale->id, ale->data);
}
-
+
/* free the path if necessary */
if (free_path)
MEM_freeN(rna_path);
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index 0163a7f68d6..ebe977420c6 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -30,7 +30,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
+#include <string.h>
#include "MEM_guardedalloc.h"
@@ -82,24 +82,24 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
-
+
/* try to build list of filtered items */
ANIM_animdata_filter(ac, &anim_data, filter, data, datatype);
if (BLI_listbase_is_empty(&anim_data))
return;
-
+
/* only clear the 'active' flag for the channels of the same type */
for (ale = anim_data.first; ale; ale = ale->next) {
/* skip if types don't match */
if (channel_type != ale->type)
continue;
-
+
/* flag to set depends on type */
switch (ale->type) {
case ANIMTYPE_GROUP:
{
bActionGroup *agrp = (bActionGroup *)ale->data;
-
+
ACHANNEL_SET_FLAG(agrp, ACHANNEL_SETFLAG_CLEAR, AGRP_ACTIVE);
break;
}
@@ -107,14 +107,14 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat
case ANIMTYPE_NLACURVE:
{
FCurve *fcu = (FCurve *)ale->data;
-
+
ACHANNEL_SET_FLAG(fcu, ACHANNEL_SETFLAG_CLEAR, FCURVE_ACTIVE);
break;
}
case ANIMTYPE_NLATRACK:
{
NlaTrack *nlt = (NlaTrack *)ale->data;
-
+
ACHANNEL_SET_FLAG(nlt, ACHANNEL_SETFLAG_CLEAR, NLATRACK_ACTIVE);
break;
}
@@ -146,13 +146,13 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat
case ANIMTYPE_GPLAYER:
{
bGPDlayer *gpl = (bGPDlayer *)ale->data;
-
+
ACHANNEL_SET_FLAG(gpl, ACHANNEL_SETFLAG_CLEAR, GP_LAYER_ACTIVE);
break;
}
}
}
-
+
/* set active flag */
if (channel_data) {
switch (channel_type) {
@@ -201,26 +201,26 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat
}
break;
}
-
+
case ANIMTYPE_GPLAYER:
{
bGPDlayer *gpl = (bGPDlayer *)channel_data;
gpl->flag |= GP_LAYER_ACTIVE;
break;
}
-
+
/* unhandled currently, but may be interesting */
case ANIMTYPE_MASKLAYER:
case ANIMTYPE_SHAPEKEY:
case ANIMTYPE_NLAACTION:
break;
-
+
/* other types */
default:
break;
}
}
-
+
/* clean up */
ANIM_animdata_freelist(&anim_data);
}
@@ -252,7 +252,7 @@ static void select_pchan_for_action_group(bAnimContext *ac, bActionGroup *agrp,
}
}
-/* Deselect all animation channels
+/* Deselect all animation channels
* - data: pointer to datatype, as contained in bAnimContext
* - datatype: the type of data that 'data' represents (eAnimCont_Types)
* - test: check if deselecting instead of selecting
@@ -263,18 +263,18 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
/* NOTE: no list visible, otherwise, we get dangling */
filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS;
ANIM_animdata_filter(ac, &anim_data, filter, data, datatype);
-
+
/* See if we should be selecting or deselecting */
if (test) {
for (ale = anim_data.first; ale; ale = ale->next) {
- if (sel == 0)
+ if (sel == 0)
break;
-
+
switch (ale->type) {
case ANIMTYPE_SCENE:
if (ale->flag & SCE_DS_SELECTED)
@@ -303,7 +303,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d
if (ale->flag & NLATRACK_SELECTED)
sel = ACHANNEL_SETFLAG_CLEAR;
break;
-
+
case ANIMTYPE_FILLACTD: /* Action Expander */
case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */
case ANIMTYPE_DSLAM:
@@ -339,16 +339,16 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d
}
}
}
-
+
/* Now set the flags */
for (ale = anim_data.first; ale; ale = ale->next) {
switch (ale->type) {
case ANIMTYPE_SCENE:
{
Scene *scene = (Scene *)ale->data;
-
+
ACHANNEL_SET_FLAG(scene, sel, SCE_DS_SELECTED);
-
+
if (scene->adt) {
ACHANNEL_SET_FLAG(scene, sel, ADT_UI_SELECTED);
}
@@ -381,7 +381,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d
case ANIMTYPE_NLACURVE:
{
FCurve *fcu = (FCurve *)ale->data;
-
+
ACHANNEL_SET_FLAG(fcu, sel, FCURVE_SELECTED);
fcu->flag &= ~FCURVE_ACTIVE;
break;
@@ -389,14 +389,14 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d
case ANIMTYPE_SHAPEKEY:
{
KeyBlock *kb = (KeyBlock *)ale->data;
-
+
ACHANNEL_SET_FLAG(kb, sel, KEYBLOCK_SEL);
break;
}
case ANIMTYPE_NLATRACK:
{
NlaTrack *nlt = (NlaTrack *)ale->data;
-
+
ACHANNEL_SET_FLAG(nlt, sel, NLATRACK_SELECTED);
nlt->flag &= ~NLATRACK_ACTIVE;
break;
@@ -431,40 +431,40 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d
case ANIMTYPE_GPLAYER:
{
bGPDlayer *gpl = (bGPDlayer *)ale->data;
-
+
ACHANNEL_SET_FLAG(gpl, sel, GP_LAYER_SELECT);
break;
}
case ANIMTYPE_MASKLAYER:
{
MaskLayer *masklay = (MaskLayer *)ale->data;
-
+
ACHANNEL_SET_FLAG(masklay, sel, MASK_LAYERFLAG_SELECT);
break;
}
}
}
-
+
/* Cleanup */
ANIM_animdata_freelist(&anim_data);
}
/* ---------------------------- Graph Editor ------------------------------------- */
-/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting
+/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting
* - anim_data: list of the all the anim channels that can be chosen
* -> filtered using ANIMFILTER_CHANNELS only, since if we took VISIBLE too,
* then the channels under closed expanders get ignored...
* - ale_setting: the anim channel (not in the anim_data list directly, though occurring there)
- * with the new state of the setting that we want flushed up/down the hierarchy
+ * with the new state of the setting that we want flushed up/down the hierarchy
* - setting: type of setting to set
- * - on: whether the visibility setting has been enabled or disabled
+ * - on: whether the visibility setting has been enabled or disabled
*/
void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAnimListElem *ale_setting, eAnimChannel_Settings setting, eAnimChannels_SetFlag mode)
{
bAnimListElem *ale, *match = NULL;
int prevLevel = 0, matchLevel = 0;
-
+
/* sanity check */
if (ELEM(NULL, anim_data, anim_data->first))
return;
@@ -491,23 +491,23 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn
}
else {
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale_setting);
-
+
if (acf == NULL) {
printf("ERROR: no channel info for the changed channel\n");
return;
}
-
+
/* get the level of the channel that was affected
* - we define the level as simply being the offset for the start of the channel
*/
matchLevel = (acf->get_offset) ? acf->get_offset(ac, ale_setting) : 0;
prevLevel = matchLevel;
}
-
- /* flush up?
+
+ /* flush up?
*
* For Visibility:
- * - only flush up if the current state is now enabled (positive 'on' state is default)
+ * - only flush up if the current state is now enabled (positive 'on' state is default)
* (otherwise, it's too much work to force the parents to be inactive too)
*
* For everything else:
@@ -521,25 +521,25 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn
for (ale = match->prev; ale; ale = ale->prev) {
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
int level;
-
+
/* if no channel info was found, skip, since this type might not have any useful info */
if (acf == NULL)
continue;
-
- /* get the level of the current channel traversed
+
+ /* get the level of the current channel traversed
* - we define the level as simply being the offset for the start of the channel
*/
level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
-
+
/* if the level is 'less than' (i.e. more important) the level we're matching
- * but also 'less than' the level just tried (i.e. only the 1st group above grouped F-Curves,
+ * but also 'less than' the level just tried (i.e. only the 1st group above grouped F-Curves,
* when toggling visibility of F-Curves, gets flushed, which should happen if we don't let prevLevel
* get updated below once the first 1st group is found)...
*/
if (level < prevLevel) {
/* flush the new status... */
ANIM_channel_setting_set(ac, ale, setting, mode);
-
+
/* store this level as the 'old' level now */
prevLevel = level;
}
@@ -551,31 +551,31 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn
if (prevLevel == 0)
break;
/* otherwise, this level weaves into another sibling hierarchy to the previous one just
- * finished, so skip until we get to the parent of this level
+ * finished, so skip until we get to the parent of this level
*/
else
continue;
}
}
}
-
+
/* flush down (always) */
{
/* go forwards in the list, until the lowest-ranking element (by indention has been covered) */
for (ale = match->next; ale; ale = ale->next) {
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
int level;
-
+
/* if no channel info was found, skip, since this type might not have any useful info */
if (acf == NULL)
continue;
-
- /* get the level of the current channel traversed
+
+ /* get the level of the current channel traversed
* - we define the level as simply being the offset for the start of the channel
*/
level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
-
- /* if the level is 'greater than' (i.e. less important) the channel that was changed,
+
+ /* if the level is 'greater than' (i.e. less important) the channel that was changed,
* flush the new status...
*/
if (level > matchLevel)
@@ -586,7 +586,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn
*/
else
break;
-
+
/* store this level as the 'old' level now */
// prevLevel = level; // XXX: prevLevel is unused
}
@@ -598,13 +598,13 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn
/* Delete the given F-Curve from its AnimData block */
void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *fcu)
{
- /* - if no AnimData, we've got nowhere to remove the F-Curve from
+ /* - if no AnimData, we've got nowhere to remove the F-Curve from
* (this doesn't guarantee that the F-Curve is in there, but at least we tried
* - if no F-Curve, there is nothing to remove
*/
if (ELEM(NULL, adt, fcu))
return;
-
+
/* remove from whatever list it came from
* - Action Group
* - Action
@@ -617,15 +617,15 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f
}
else if (adt->action) {
bAction *act = adt->action;
-
+
/* remove from group or action, whichever one "owns" the F-Curve */
if (fcu->grp) {
bActionGroup *agrp = fcu->grp;
-
+
/* remove F-Curve from group+action */
action_groups_remove_channel(act, fcu);
-
- /* if group has no more channels, remove it too,
+
+ /* if group has no more channels, remove it too,
* otherwise can have many dangling groups [#33541]
*/
if (BLI_listbase_is_empty(&agrp->channels)) {
@@ -635,7 +635,7 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f
else {
BLI_remlink(&act->curves, fcu);
}
-
+
/* if action has no more F-Curves as a result of this, unlink it from
* AnimData if it did not come from a NLA Strip being tweaked.
*
@@ -648,7 +648,7 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f
adt->action = NULL;
}
}
-
+
/* free the F-Curve itself */
free_fcurve(fcu);
}
@@ -662,7 +662,7 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f
static int animedit_poll_channels_active(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
-
+
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
if (ELEM(NULL, sa, CTX_wm_region(C)))
@@ -687,13 +687,13 @@ static int animedit_poll_channels_nla_tweakmode_off(bContext *C)
/* animation editor test */
if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA) == 0)
return 0;
-
+
/* NLA TweakMode test */
if (sa->spacetype == SPACE_NLA) {
if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON))
return 0;
}
-
+
return 1;
}
@@ -722,7 +722,7 @@ static const EnumPropertyItem prop_animchannel_rearrange_types[] = {
/* Island definition - just a listbase container */
typedef struct tReorderChannelIsland {
struct tReorderChannelIsland *next, *prev;
-
+
ListBase channels; /* channels within this region with the same state */
int flag; /* eReorderIslandFlag */
} tReorderChannelIsland;
@@ -743,7 +743,7 @@ static bool rearrange_island_ok(tReorderChannelIsland *island)
/* island must not be untouchable */
if (island->flag & REORDER_ISLAND_UNTOUCHABLE)
return 0;
-
+
/* island should be selected to be moved */
return (island->flag & REORDER_ISLAND_SELECTED) && !(island->flag & REORDER_ISLAND_MOVED);
}
@@ -755,13 +755,13 @@ static bool rearrange_island_top(ListBase *list, tReorderChannelIsland *island)
if (rearrange_island_ok(island)) {
/* remove from current position */
BLI_remlink(list, island);
-
+
/* make it first element */
BLI_insertlinkbefore(list, list->first, island);
-
+
return 1;
}
-
+
return 0;
}
@@ -779,14 +779,14 @@ static bool rearrange_island_up(ListBase *list, tReorderChannelIsland *island)
if (prev) {
/* remove from current position */
BLI_remlink(list, island);
-
+
/* push it up */
BLI_insertlinkbefore(list, prev, island);
-
+
return 1;
}
}
-
+
return 0;
}
@@ -806,16 +806,16 @@ static bool rearrange_island_down(ListBase *list, tReorderChannelIsland *island)
if ((next->flag & REORDER_ISLAND_UNTOUCHABLE) == 0) {
/* remove from current position */
BLI_remlink(list, island);
-
+
/* push it down */
BLI_insertlinkafter(list, next, island);
-
+
return true;
}
}
/* else: no next channel, so we're at the bottom already, so can't move */
}
-
+
return false;
}
@@ -823,10 +823,10 @@ static bool rearrange_island_bottom(ListBase *list, tReorderChannelIsland *islan
{
if (rearrange_island_ok(island)) {
tReorderChannelIsland *last = list->last;
-
+
/* remove island from current position */
BLI_remlink(list, island);
-
+
/* add before or after the last channel? */
if ((last->flag & REORDER_ISLAND_UNTOUCHABLE) == 0) {
/* can add after it */
@@ -835,12 +835,12 @@ static bool rearrange_island_bottom(ListBase *list, tReorderChannelIsland *islan
else {
/* can at most go just before it, since last cannot be moved */
BLI_insertlinkbefore(list, last, island);
-
+
}
-
+
return true;
}
-
+
return false;
}
@@ -881,13 +881,13 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr
{
tReorderChannelIsland *island = islands->last; /* always try to add to last island if possible */
bool is_sel = false, is_untouchable = false;
-
+
/* get flags - selected and untouchable from the channel */
switch (type) {
case ANIMTYPE_GROUP:
{
bActionGroup *agrp = (bActionGroup *)channel;
-
+
is_sel = SEL_AGRP(agrp);
is_untouchable = (agrp->flag & AGRP_TEMP) != 0;
break;
@@ -896,21 +896,21 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr
case ANIMTYPE_NLACURVE:
{
FCurve *fcu = (FCurve *)channel;
-
+
is_sel = SEL_FCU(fcu);
break;
}
case ANIMTYPE_NLATRACK:
{
NlaTrack *nlt = (NlaTrack *)channel;
-
+
is_sel = SEL_NLT(nlt);
break;
}
case ANIMTYPE_GPLAYER:
{
bGPDlayer *gpl = (bGPDlayer *)channel;
-
+
is_sel = SEL_GPL(gpl);
break;
}
@@ -918,7 +918,7 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr
printf("rearrange_animchannel_add_to_islands(): don't know how to handle channels of type %u\n", type);
return;
}
-
+
/* do we need to add to a new island? */
if (/* 1) no islands yet */
(island == NULL) ||
@@ -933,7 +933,7 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr
/* create a new island now */
island = MEM_callocN(sizeof(tReorderChannelIsland), "tReorderChannelIsland");
BLI_addtail(islands, island);
-
+
if (is_sel)
island->flag |= REORDER_ISLAND_SELECTED;
if (is_untouchable)
@@ -951,14 +951,14 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr
static void rearrange_animchannel_flatten_islands(ListBase *islands, ListBase *srcList)
{
tReorderChannelIsland *island, *isn = NULL;
-
+
/* make sure srcList is empty now */
BLI_assert(BLI_listbase_is_empty(srcList));
-
+
/* go through merging islands */
for (island = islands->first; island; island = isn) {
isn = island->next;
-
+
/* merge island channels back to main list, then delete the island */
BLI_movelisttolist(srcList, &island->channels);
BLI_freelinkN(islands, island);
@@ -973,19 +973,19 @@ static void rearrange_animchannels_filter_visible(ListBase *anim_data_visible, b
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale, *ale_next;
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
-
+
/* get all visible channels */
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* now, only keep the ones that are of the types we are interested in */
for (ale = anim_data.first; ale; ale = ale_next) {
ale_next = ale->next;
-
+
if (ale->type != type) {
BLI_freelinkN(&anim_data, ale);
}
}
-
+
/* return cleaned up list */
*anim_data_visible = anim_data;
}
@@ -998,11 +998,11 @@ static bool rearrange_animchannel_islands(ListBase *list, AnimChanRearrangeFp re
ListBase islands = {NULL, NULL};
Link *channel, *chanNext = NULL;
bool done = false;
-
+
/* don't waste effort on an empty list */
if (BLI_listbase_is_empty(list))
return 0;
-
+
/* group channels into islands */
for (channel = list->first; channel; channel = chanNext) {
/* find out whether this channel is present in anim_data_visible or not! */
@@ -1010,18 +1010,18 @@ static bool rearrange_animchannel_islands(ListBase *list, AnimChanRearrangeFp re
chanNext = channel->next;
rearrange_animchannel_add_to_islands(&islands, list, channel, type, is_hidden);
}
-
- /* perform moving of selected islands now, but only if there is more than one of 'em so that something will happen
- * - scanning of the list is performed in the opposite direction to the direction we're moving things, so that we
+
+ /* perform moving of selected islands now, but only if there is more than one of 'em so that something will happen
+ * - scanning of the list is performed in the opposite direction to the direction we're moving things, so that we
* shouldn't need to encounter items we've moved already
*/
if (islands.first != islands.last) {
tReorderChannelIsland *first = (mode > 0) ? islands.last : islands.first;
tReorderChannelIsland *island, *isn = NULL;
-
+
for (island = first; island; island = isn) {
isn = (mode > 0) ? island->prev : island->next;
-
+
/* perform rearranging */
if (rearrange_func(&islands, island)) {
island->flag |= REORDER_ISLAND_MOVED;
@@ -1029,10 +1029,10 @@ static bool rearrange_animchannel_islands(ListBase *list, AnimChanRearrangeFp re
}
}
}
-
+
/* ungroup islands */
rearrange_animchannel_flatten_islands(&islands, list);
-
+
/* did we do anything? */
return done;
}
@@ -1041,27 +1041,27 @@ static bool rearrange_animchannel_islands(ListBase *list, AnimChanRearrangeFp re
/* Change the order NLA Tracks within NLA Stack
* ! NLA tracks are displayed in opposite order, so directions need care
- * mode: REARRANGE_ANIMCHAN_*
+ * mode: REARRANGE_ANIMCHAN_*
*/
static void rearrange_nla_channels(bAnimContext *ac, AnimData *adt, eRearrangeAnimChan_Mode mode)
{
AnimChanRearrangeFp rearrange_func;
ListBase anim_data_visible = {NULL, NULL};
-
+
/* hack: invert mode so that functions will work in right order */
mode *= -1;
-
+
/* get rearranging function */
rearrange_func = rearrange_get_mode_func(mode);
if (rearrange_func == NULL)
return;
-
+
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_NLATRACK);
-
+
/* perform rearranging on tracks list */
rearrange_animchannel_islands(&adt->nla_tracks, rearrange_func, mode, ANIMTYPE_NLATRACK, &anim_data_visible);
-
+
/* free temp data */
BLI_freelistN(&anim_data_visible);
}
@@ -1069,27 +1069,27 @@ static void rearrange_nla_channels(bAnimContext *ac, AnimData *adt, eRearrangeAn
/* Drivers Specific Stuff ------------------------------------------------- */
/* Change the order drivers within AnimData block
- * mode: REARRANGE_ANIMCHAN_*
+ * mode: REARRANGE_ANIMCHAN_*
*/
static void rearrange_driver_channels(bAnimContext *ac, AnimData *adt, eRearrangeAnimChan_Mode mode)
{
/* get rearranging function */
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
ListBase anim_data_visible = {NULL, NULL};
-
+
if (rearrange_func == NULL)
return;
-
+
/* only consider drivers if they're accessible */
if (EXPANDED_DRVD(adt) == 0)
return;
-
+
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_FCURVE);
-
+
/* perform rearranging on drivers list (drivers are really just F-Curves) */
rearrange_animchannel_islands(&adt->drivers, rearrange_func, mode, ANIMTYPE_FCURVE, &anim_data_visible);
-
+
/* free temp data */
BLI_freelistN(&anim_data_visible);
}
@@ -1101,29 +1101,29 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp)
{
bActionGroup *agrp;
FCurve *fcu;
-
+
if (act == NULL)
return;
-
+
/* Separate F-Curves into lists per group */
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
if (agrp->channels.first) {
fcu = agrp->channels.last;
act->curves.first = fcu->next;
-
+
fcu = agrp->channels.first;
fcu->prev = NULL;
-
+
fcu = agrp->channels.last;
fcu->next = NULL;
}
}
-
+
/* Initialize memory for temp-group */
memset(tgrp, 0, sizeof(bActionGroup));
tgrp->flag |= (AGRP_EXPANDED | AGRP_TEMP);
BLI_strncpy(tgrp->name, "#TempGroup", sizeof(tgrp->name));
-
+
/* Move any action-channels not already moved, to the temp group */
if (act->curves.first) {
/* start of list */
@@ -1131,21 +1131,21 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp)
fcu->prev = NULL;
tgrp->channels.first = fcu;
act->curves.first = NULL;
-
+
/* end of list */
fcu = act->curves.last;
fcu->next = NULL;
tgrp->channels.last = fcu;
act->curves.last = NULL;
-
- /* ensure that all of these get their group set to this temp group
+
+ /* ensure that all of these get their group set to this temp group
* (so that visibility filtering works)
*/
for (fcu = tgrp->channels.first; fcu; fcu = fcu->next) {
fcu->grp = tgrp;
}
}
-
+
/* Add temp-group to list */
BLI_addtail(&act->groups, tgrp);
}
@@ -1154,72 +1154,72 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp)
static void join_groups_action_temp(bAction *act)
{
bActionGroup *agrp;
-
+
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
ListBase tempGroup;
-
+
/* add list of channels to action's channels */
tempGroup = agrp->channels;
BLI_movelisttolist(&act->curves, &agrp->channels);
agrp->channels = tempGroup;
-
+
/* clear moved flag */
agrp->flag &= ~AGRP_MOVED;
-
+
/* if group was temporary one:
* - unassign all FCurves which were temporarily added to it
* - remove from list (but don't free as it's on the stack!)
*/
if (agrp->flag & AGRP_TEMP) {
FCurve *fcu;
-
+
for (fcu = agrp->channels.first; fcu; fcu = fcu->next) {
fcu->grp = NULL;
}
-
+
BLI_remlink(&act->groups, agrp);
break;
}
}
}
-/* Change the order of anim-channels within action
- * mode: REARRANGE_ANIMCHAN_*
+/* Change the order of anim-channels within action
+ * mode: REARRANGE_ANIMCHAN_*
*/
static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrangeAnimChan_Mode mode)
{
bActionGroup tgrp;
ListBase anim_data_visible = {NULL, NULL};
bool do_channels;
-
+
/* get rearranging function */
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
-
+
if (rearrange_func == NULL)
return;
-
+
/* make sure we're only operating with groups (vs a mixture of groups+curves) */
split_groups_action_temp(act, &tgrp);
-
+
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_GROUP);
-
- /* rearrange groups first
+
+ /* rearrange groups first
* - the group's channels will only get considered if nothing happened when rearranging the groups
* i.e. the rearrange function returned 0
*/
do_channels = (rearrange_animchannel_islands(&act->groups, rearrange_func, mode, ANIMTYPE_GROUP,
&anim_data_visible) == 0);
-
+
/* free temp data */
BLI_freelistN(&anim_data_visible);
-
+
if (do_channels) {
bActionGroup *agrp;
-
+
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_FCURVE);
-
+
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
/* only consider F-Curves if they're visible (group expanded) */
if (EXPANDED_AGRP(ac, agrp)) {
@@ -1227,11 +1227,11 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange
&anim_data_visible);
}
}
-
+
/* free temp data */
BLI_freelistN(&anim_data_visible);
}
-
+
/* assemble lists into one list (and clear moved tags) */
join_groups_action_temp(act);
}
@@ -1241,23 +1241,23 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange
static void rearrange_nla_control_channels(bAnimContext *ac, AnimData *adt, eRearrangeAnimChan_Mode mode)
{
ListBase anim_data_visible = {NULL, NULL};
-
+
NlaTrack *nlt;
NlaStrip *strip;
-
+
/* get rearranging function */
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
-
+
if (rearrange_func == NULL)
return;
-
+
/* skip if these curves aren't being shown */
if (adt->flag & ADT_NLA_SKEYS_COLLAPSED)
return;
-
+
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_NLACURVE);
-
+
/* we cannot rearrange between strips, but within each strip, we can rearrange those curves */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (strip = nlt->strips.first; strip; strip = strip->next) {
@@ -1265,7 +1265,7 @@ static void rearrange_nla_control_channels(bAnimContext *ac, AnimData *adt, eRea
&anim_data_visible);
}
}
-
+
/* free temp data */
BLI_freelistN(&anim_data_visible);
}
@@ -1277,36 +1277,36 @@ static void rearrange_gpencil_channels(bAnimContext *ac, eRearrangeAnimChan_Mode
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get rearranging function */
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
-
+
if (rearrange_func == NULL)
return;
-
+
/* get Grease Pencil datablocks */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
ListBase anim_data_visible = {NULL, NULL};
bGPdata *gpd = ale->data;
-
+
/* only consider layers if this datablock is open */
BLI_assert(ale->type == ANIMTYPE_GPDATABLOCK);
if ((gpd->flag & GP_DATA_EXPAND) == 0)
continue;
-
+
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_GPLAYER);
-
+
/* rearrange datablock's layers */
rearrange_animchannel_islands(&gpd->layers, rearrange_func, mode, ANIMTYPE_GPLAYER, &anim_data_visible);
-
+
/* free visible layers data */
BLI_freelistN(&anim_data_visible);
}
-
+
/* free GPD channel data */
ANIM_animdata_freelist(&anim_data);
}
@@ -1317,14 +1317,14 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
eRearrangeAnimChan_Mode mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get mode */
mode = RNA_enum_get(op->ptr, "direction");
-
+
/* method to move channels depends on the editor */
if (ac.datatype == ANIMCONT_GPENCIL) {
/* Grease Pencil channels */
@@ -1342,23 +1342,23 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get animdata blocks */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ale->data;
-
+
switch (ac.datatype) {
case ANIMCONT_NLA: /* NLA-tracks only */
rearrange_nla_channels(&ac, adt, mode);
break;
-
+
case ANIMCONT_DRIVERS: /* Drivers list only */
rearrange_driver_channels(&ac, adt, mode);
break;
-
+
case ANIMCONT_ACTION: /* Single Action only... */
case ANIMCONT_SHAPEKEY: // DOUBLE CHECK ME...
{
@@ -1368,13 +1368,13 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
printf("Animdata has no action\n");
break;
}
-
+
default: /* DopeSheet/Graph Editor - Some Actions + NLA Control Curves */
{
/* NLA Control Curves */
if (adt->nla_tracks.first)
rearrange_nla_control_channels(&ac, adt, mode);
-
+
/* Action */
if (adt->action)
rearrange_action_channels(&ac, adt->action, mode);
@@ -1384,14 +1384,14 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
}
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
}
-
+
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1401,14 +1401,14 @@ static void ANIM_OT_channels_move(wmOperatorType *ot)
ot->name = "Move Channels";
ot->idname = "ANIM_OT_channels_move";
ot->description = "Rearrange selected animation channels";
-
+
/* api callbacks */
ot->exec = animchannels_rearrange_exec;
ot->poll = animedit_poll_channels_nla_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
ot->prop = RNA_def_enum(ot->srna, "direction", prop_animchannel_rearrange_types, REARRANGE_ANIMCHAN_DOWN, "Direction", "");
}
@@ -1424,16 +1424,16 @@ static int animchannels_grouping_poll(bContext *C)
/* TODO: could enhance with actually testing if channels region? */
if (ELEM(NULL, sa, CTX_wm_region(C)))
return 0;
-
+
/* animation editor test - must be suitable modes only */
sl = CTX_wm_space_data(C);
-
+
switch (sa->spacetype) {
/* supported... */
case SPACE_ACTION:
{
SpaceAction *saction = (SpaceAction *)sl;
-
+
/* dopesheet and action only - all others are for other datatypes or have no groups */
if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_DOPESHEET) == 0)
return 0;
@@ -1443,7 +1443,7 @@ static int animchannels_grouping_poll(bContext *C)
case SPACE_IPO:
{
SpaceIpo *sipo = (SpaceIpo *)sl;
-
+
/* drivers can't have groups... */
if (sipo->mode != SIPO_MODE_ANIMATION)
return 0;
@@ -1454,50 +1454,50 @@ static int animchannels_grouping_poll(bContext *C)
default:
return 0;
}
-
+
return 1;
}
/* ----------------------------------------------------------- */
static void animchannels_group_channels(bAnimContext *ac, bAnimListElem *adt_ref, const char name[])
-{
+{
AnimData *adt = adt_ref->adt;
bAction *act = adt->action;
-
+
if (act) {
ListBase anim_data = {NULL, NULL};
int filter;
-
+
/* find selected F-Curves to re-group */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL);
ANIM_animdata_filter(ac, &anim_data, filter, adt_ref, ANIMCONT_CHANNEL);
-
+
if (anim_data.first) {
bActionGroup *agrp;
bAnimListElem *ale;
-
+
/* create new group, which should now be part of the action */
agrp = action_groups_add_new(act, name);
BLI_assert(agrp != NULL);
-
+
/* transfer selected F-Curves across to new group */
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
bActionGroup *grp = fcu->grp;
-
+
/* remove F-Curve from group, then group too if it is now empty */
action_groups_remove_channel(act, fcu);
-
+
if ((grp) && BLI_listbase_is_empty(&grp->channels)) {
BLI_freelinkN(&act->groups, grp);
}
-
+
/* add F-Curve to group */
action_groups_add_channel(act, agrp, fcu);
}
}
-
+
/* cleanup */
ANIM_animdata_freelist(&anim_data);
}
@@ -1507,35 +1507,35 @@ static int animchannels_group_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
char name[MAX_NAME];
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get name for new group */
RNA_string_get(op->ptr, "name", name);
-
+
/* XXX: name for group should never be empty... */
if (name[0]) {
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* handle each animdata block separately, so that the regrouping doesn't flow into blocks */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
animchannels_group_channels(&ac, ale, name);
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* updatss */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
}
-
+
return OPERATOR_FINISHED;
}
@@ -1545,18 +1545,18 @@ static void ANIM_OT_channels_group(wmOperatorType *ot)
ot->name = "Group Channels";
ot->idname = "ANIM_OT_channels_group";
ot->description = "Add selected F-Curves to a new group";
-
+
/* callbacks */
ot->invoke = WM_operator_props_popup;
ot->exec = animchannels_group_exec;
ot->poll = animchannels_grouping_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
- ot->prop = RNA_def_string(ot->srna, "name", "New Group",
- sizeof(((bActionGroup *)NULL)->name),
+ ot->prop = RNA_def_string(ot->srna, "name", "New Group",
+ sizeof(((bActionGroup *)NULL)->name),
"Name", "Name of newly created group");
/* RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); */ /* XXX: still not too sure about this - keeping same text is confusing... */
}
@@ -1566,33 +1566,33 @@ static void ANIM_OT_channels_group(wmOperatorType *ot)
static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* just selected F-Curves... */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
/* find action for this F-Curve... */
if (ale->adt && ale->adt->action) {
FCurve *fcu = (FCurve *)ale->data;
bAction *act = ale->adt->action;
-
+
/* only proceed to remove if F-Curve is in a group... */
- if (fcu->grp) {
+ if (fcu->grp) {
bActionGroup *agrp = fcu->grp;
-
+
/* remove F-Curve from group and add at tail (ungrouped) */
action_groups_remove_channel(act, fcu);
BLI_addtail(&act->curves, fcu);
-
+
/* delete group if it is now empty */
if (BLI_listbase_is_empty(&agrp->channels)) {
BLI_freelinkN(&act->groups, agrp);
@@ -1600,13 +1600,13 @@ static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op))
}
}
}
-
+
/* cleanup */
ANIM_animdata_freelist(&anim_data);
-
+
/* updates */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1616,11 +1616,11 @@ static void ANIM_OT_channels_ungroup(wmOperatorType *ot)
ot->name = "Ungroup Channels";
ot->idname = "ANIM_OT_channels_ungroup";
ot->description = "Remove selected F-Curves from their current groups";
-
+
/* callbacks */
ot->exec = animchannels_ungroup_exec;
ot->poll = animchannels_grouping_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1633,22 +1633,22 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* cannot delete in shapekey */
- if (ac.datatype == ANIMCONT_SHAPEKEY)
+ if (ac.datatype == ANIMCONT_SHAPEKEY)
return OPERATOR_CANCELLED;
-
-
+
+
/* do groups only first (unless in Drivers mode, where there are none) */
if (ac.datatype != ANIMCONT_DRIVERS) {
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* delete selected groups and their associated channels */
for (ale = anim_data.first; ale; ale = ale->next) {
/* only groups - don't check other types yet, since they may no-longer exist */
@@ -1656,20 +1656,20 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
bActionGroup *agrp = (bActionGroup *)ale->data;
AnimData *adt = ale->adt;
FCurve *fcu, *fcn;
-
+
/* skip this group if no AnimData available, as we can't safely remove the F-Curves */
if (adt == NULL)
continue;
-
+
/* delete all of the Group's F-Curves, but no others */
for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcn) {
fcn = fcu->next;
-
+
/* remove from group and action, then free */
action_groups_remove_channel(adt->action, fcu);
free_fcurve(fcu);
}
-
+
/* free the group itself */
if (adt->action)
BLI_freelinkN(&adt->action->groups, agrp);
@@ -1677,24 +1677,24 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
MEM_freeN(agrp);
}
}
-
+
/* cleanup */
ANIM_animdata_freelist(&anim_data);
}
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* delete selected data channels */
for (ale = anim_data.first; ale; ale = ale->next) {
switch (ale->type) {
- case ANIMTYPE_FCURVE:
+ case ANIMTYPE_FCURVE:
{
/* F-Curves if we can identify its parent */
AnimData *adt = ale->adt;
FCurve *fcu = (FCurve *)ale->data;
-
+
/* try to free F-Curve */
ANIM_fcurve_delete_from_animdata(&ac, adt, fcu);
break;
@@ -1704,7 +1704,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
/* NLA Control Curve - Deleting it should disable the corresponding setting... */
NlaStrip *strip = (NlaStrip *)ale->owner;
FCurve *fcu = (FCurve *)ale->data;
-
+
if (STREQ(fcu->rna_path, "strip_time")) {
strip->flag &= ~NLASTRIP_FLAG_USR_TIME;
}
@@ -1714,7 +1714,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
else {
printf("ERROR: Trying to delete NLA Control Curve for unknown property '%s'\n", fcu->rna_path);
}
-
+
/* unlink and free the F-Curve */
BLI_remlink(&strip->fcurves, fcu);
free_fcurve(fcu);
@@ -1725,7 +1725,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
/* Grease Pencil layer */
bGPdata *gpd = (bGPdata *)ale->id;
bGPDlayer *gpl = (bGPDlayer *)ale->data;
-
+
/* try to delete the layer's data and the layer itself */
BKE_gpencil_free_frames(gpl);
BLI_freelinkN(&gpd->layers, gpl);
@@ -1736,35 +1736,35 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
/* Mask layer */
Mask *mask = (Mask *)ale->id;
MaskLayer *masklay = (MaskLayer *)ale->data;
-
+
/* try to delete the layer's data and the layer itself */
BKE_mask_layer_remove(mask, masklay);
break;
}
}
}
-
+
/* cleanup */
ANIM_animdata_freelist(&anim_data);
-
+
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
DEG_relations_tag_update(CTX_data_main(C));
return OPERATOR_FINISHED;
}
-
+
static void ANIM_OT_channels_delete(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Delete Channels";
ot->idname = "ANIM_OT_channels_delete";
ot->description = "Delete all selected animation channels";
-
+
/* api callbacks */
ot->exec = animchannels_delete_exec;
ot->poll = animedit_poll_channels_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1791,7 +1791,7 @@ static const EnumPropertyItem prop_animchannel_settings_types[] = {
/* ------------------- */
-/* Set/clear a particular flag (setting) for all selected + visible channels
+/* Set/clear a particular flag (setting) for all selected + visible channels
* setting: the setting to modify
* mode: eAnimChannels_SetFlag
* onlysel: only selected channels get the flag set
@@ -1803,20 +1803,20 @@ static void setflag_anim_channels(bAnimContext *ac, eAnimChannel_Settings settin
ListBase all_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data that we need if flush is on */
if (flush) {
- /* get list of all channels that selection may need to be flushed to
+ /* get list of all channels that selection may need to be flushed to
* - hierarchy visibility needs to be ignored so that settings can get flushed
* "down" inside closed containers
*/
filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS;
ANIM_animdata_filter(ac, &all_data, filter, ac->data, ac->datatype);
}
-
- /* filter data that we're working on
+
+ /* filter data that we're working on
* - hierarchy matters if we're doing this from the channels region
- * since we only want to apply this to channels we can "see",
+ * since we only want to apply this to channels we can "see",
* and have these affect their relatives
* - but for Graph Editor, this gets used also from main region
* where hierarchy doesn't apply [#21276]
@@ -1831,12 +1831,12 @@ static void setflag_anim_channels(bAnimContext *ac, eAnimChannel_Settings settin
}
if (onlysel) filter |= ANIMFILTER_SEL;
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* if toggling, check if disable or enable */
if (mode == ACHANNEL_SETFLAG_TOGGLE) {
/* default to turn all on, unless we encounter one that's on... */
mode = ACHANNEL_SETFLAG_ADD;
-
+
/* see if we should turn off instead... */
for (ale = anim_data.first; ale; ale = ale->next) {
/* set the setting in the appropriate way (if available) */
@@ -1846,21 +1846,21 @@ static void setflag_anim_channels(bAnimContext *ac, eAnimChannel_Settings settin
}
}
}
-
+
/* apply the setting */
for (ale = anim_data.first; ale; ale = ale->next) {
/* skip channel if setting is not available */
if (ANIM_channel_setting_get(ac, ale, setting) == -1)
continue;
-
+
/* set the setting in the appropriate way */
ANIM_channel_setting_set(ac, ale, setting, mode);
-
+
/* if flush status... */
if (flush)
ANIM_flush_setting_anim_channels(ac, &all_data, ale, setting, mode);
}
-
+
ANIM_animdata_freelist(&anim_data);
BLI_freelistN(&all_data);
}
@@ -1873,27 +1873,27 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op)
eAnimChannel_Settings setting;
eAnimChannels_SetFlag mode;
bool flush = true;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* mode (eAnimChannels_SetFlag), setting (eAnimChannel_Settings) */
mode = RNA_enum_get(op->ptr, "mode");
setting = RNA_enum_get(op->ptr, "type");
-
+
/* check if setting is flushable */
if (setting == ACHANNEL_SETTING_EXPAND)
flush = false;
-
- /* modify setting
+
+ /* modify setting
* - only selected channels are affected
*/
setflag_anim_channels(&ac, setting, mode, true, flush);
-
+
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1901,20 +1901,20 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op)
static void ANIM_OT_channels_setting_enable(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Enable Channel Setting";
ot->idname = "ANIM_OT_channels_setting_enable";
ot->description = "Enable specified setting on all selected animation channels";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = animchannels_setflag_exec;
ot->poll = animedit_poll_channels_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
/* flag-setting mode */
prop = RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_ADD, "Mode", "");
@@ -1926,20 +1926,20 @@ static void ANIM_OT_channels_setting_enable(wmOperatorType *ot)
static void ANIM_OT_channels_setting_disable(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Disable Channel Setting";
ot->idname = "ANIM_OT_channels_setting_disable";
ot->description = "Disable specified setting on all selected animation channels";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = animchannels_setflag_exec;
ot->poll = animedit_poll_channels_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
/* flag-setting mode */
prop = RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_CLEAR, "Mode", "");
@@ -1951,20 +1951,20 @@ static void ANIM_OT_channels_setting_disable(wmOperatorType *ot)
static void ANIM_OT_channels_setting_toggle(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Toggle Channel Setting";
ot->idname = "ANIM_OT_channels_setting_toggle";
ot->description = "Toggle specified setting on all selected animation channels";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = animchannels_setflag_exec;
ot->poll = animedit_poll_channels_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
/* flag-setting mode */
prop = RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", "");
@@ -1976,19 +1976,19 @@ static void ANIM_OT_channels_setting_toggle(wmOperatorType *ot)
static void ANIM_OT_channels_editable_toggle(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Toggle Channel Editability";
ot->idname = "ANIM_OT_channels_editable_toggle";
ot->description = "Toggle editability of selected channels";
-
+
/* api callbacks */
ot->exec = animchannels_setflag_exec;
ot->poll = animedit_poll_channels_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
/* flag-setting mode */
RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", "");
@@ -2003,21 +2003,21 @@ static int animchannels_expand_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
bool onlysel = true;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* only affect selected channels? */
if (RNA_boolean_get(op->ptr, "all"))
onlysel = false;
-
+
/* modify setting */
setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_ADD, onlysel, false);
-
+
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -2027,14 +2027,14 @@ static void ANIM_OT_channels_expand(wmOperatorType *ot)
ot->name = "Expand Channels";
ot->idname = "ANIM_OT_channels_expand";
ot->description = "Expand (i.e. open) all selected expandable animation channels";
-
+
/* api callbacks */
ot->exec = animchannels_expand_exec;
ot->poll = animedit_poll_channels_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All", "Expand all channels (not just selected ones)");
}
@@ -2045,21 +2045,21 @@ static int animchannels_collapse_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
bool onlysel = true;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* only affect selected channels? */
if (RNA_boolean_get(op->ptr, "all"))
onlysel = false;
-
+
/* modify setting */
setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_CLEAR, onlysel, false);
-
+
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -2069,14 +2069,14 @@ static void ANIM_OT_channels_collapse(wmOperatorType *ot)
ot->name = "Collapse Channels";
ot->idname = "ANIM_OT_channels_collapse";
ot->description = "Collapse (i.e. close) all selected expandable animation channels";
-
+
/* api callbacks */
ot->exec = animchannels_collapse_exec;
ot->poll = animedit_poll_channels_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
ot->prop = RNA_def_boolean(ot->srna, "all", true, "All", "Collapse all channels (not just selected ones)");
}
@@ -2092,37 +2092,37 @@ static void ANIM_OT_channels_collapse(wmOperatorType *ot)
* or are no longer wanted
* 3) No drivers
*/
-
+
static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get animdata blocks */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
ID *id = ale->id;
AnimData *adt = ale->data;
-
+
bool action_empty = false;
bool nla_empty = false;
bool drivers_empty = false;
-
+
/* sanity checks */
BLI_assert((id != NULL) && (adt != NULL));
-
+
/* check if this is "empty" and can be deleted */
/* (For now, there are only these 3 criteria) */
-
+
/* 1) Active Action is missing or empty */
if (ELEM(NULL, adt->action, adt->action->curves.first)) {
action_empty = true;
@@ -2130,18 +2130,18 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op))
else {
/* TODO: check for keyframe + fmodifier data on these too */
}
-
+
/* 2) No NLA Tracks and/or NLA Strips */
if (adt->nla_tracks.first == NULL) {
nla_empty = true;
}
else {
NlaTrack *nlt;
-
+
/* empty tracks? */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
if (nlt->strips.first) {
- /* stop searching, as we found one that actually had stuff we don't want lost
+ /* stop searching, as we found one that actually had stuff we don't want lost
* NOTE: nla_empty gets reset to false, as a previous track may have been empty
*/
nla_empty = false;
@@ -2153,23 +2153,23 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op))
}
}
}
-
+
/* 3) Drivers */
drivers_empty = (adt->drivers.first == NULL);
-
-
+
+
/* remove AnimData? */
if (action_empty && nla_empty && drivers_empty) {
BKE_animdata_free(id, true);
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -2179,11 +2179,11 @@ static void ANIM_OT_channels_clean_empty(wmOperatorType *ot)
ot->name = "Remove Empty Animation Data";
ot->idname = "ANIM_OT_channels_clean_empty";
ot->description = "Delete all empty animation data containers from visible data-blocks";
-
+
/* api callbacks */
ot->exec = animchannels_clean_empty_exec;
ot->poll = animedit_poll_channels_nla_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2193,56 +2193,56 @@ static void ANIM_OT_channels_clean_empty(wmOperatorType *ot)
static int animchannels_enable_poll(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
-
+
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
if (ELEM(NULL, sa, CTX_wm_region(C)))
return 0;
-
+
/* animation editor test - Action/Dopesheet/etc. and Graph only */
if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_IPO) == 0)
return 0;
-
+
return 1;
}
static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* loop through filtered data and clean curves */
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
-
+
/* remove disabled flags from F-Curves */
fcu->flag &= ~FCURVE_DISABLED;
-
+
/* for drivers, let's do the same too */
if (fcu->driver)
fcu->driver->flag &= ~DRIVER_FLAG_INVALID;
-
+
/* tag everything for updates - in particular, this is needed to get drivers working again */
ale->update |= ANIM_UPDATE_DEPS;
}
-
+
ANIM_animdata_update(&ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
-
+
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -2252,11 +2252,11 @@ static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot)
ot->name = "Revive Disabled F-Curves";
ot->idname = "ANIM_OT_channels_fcurves_enable";
ot->description = "Clears 'disabled' tag from all F-Curves to get broken F-Curves working again";
-
+
/* api callbacks */
ot->exec = animchannels_enable_exec;
ot->poll = animchannels_enable_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2267,10 +2267,10 @@ static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot)
static int animchannels_find_poll(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
-
+
if (sa == NULL)
return 0;
-
+
/* animation editor with dopesheet */
return ELEM(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA);
}
@@ -2279,14 +2279,14 @@ static int animchannels_find_poll(bContext *C)
static int animchannels_find_invoke(bContext *C, wmOperator *op, const wmEvent *evt)
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* set initial filter text, and enable filter */
RNA_string_set(op->ptr, "query", ac.ads->searchstr);
-
+
/* defer to popup */
return WM_operator_props_popup(C, op, evt);
}
@@ -2295,26 +2295,26 @@ static int animchannels_find_invoke(bContext *C, wmOperator *op, const wmEvent *
static int animchannels_find_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* update filter text, and ensure that filter is enabled if there's something there
* NOTE: we turn the filter off if there's nothing (this is a quick shortcut for dismissing)
*/
RNA_string_get(op->ptr, "query", ac.ads->searchstr);
-
+
if (ac.ads->searchstr[0]) {
ac.ads->filterflag |= ADS_FILTER_BY_FCU_NAME;
}
else {
ac.ads->filterflag &= ~ADS_FILTER_BY_FCU_NAME;
}
-
+
/* redraw */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -2324,15 +2324,15 @@ static void ANIM_OT_channels_find(wmOperatorType *ot)
ot->name = "Find Channels";
ot->idname = "ANIM_OT_channels_find";
ot->description = "Filter the set of channels shown to only include those with matching names";
-
+
/* callbacks */
ot->invoke = animchannels_find_invoke;
ot->exec = animchannels_find_exec;
ot->poll = animchannels_find_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_string(ot->srna, "query", "Query", sizeof(((bDopeSheet *)NULL)->searchstr), "", "Text to search for in channel names");
}
@@ -2342,37 +2342,37 @@ static void ANIM_OT_channels_find(wmOperatorType *ot)
static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* 'standard' behavior - check if selected, then apply relevant selection */
if (RNA_boolean_get(op->ptr, "invert"))
ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_INVERT);
else
ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, true, ACHANNEL_SETFLAG_ADD);
-
+
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
static void ANIM_OT_channels_select_all_toggle(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Select All";
ot->idname = "ANIM_OT_channels_select_all_toggle";
ot->description = "Toggle selection of all animation channels";
-
+
/* api callbacks */
ot->exec = animchannels_deselectall_exec;
ot->poll = animedit_poll_channels_nla_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
ot->prop = RNA_def_boolean(ot->srna, "invert", false, "Invert", "");
}
@@ -2384,12 +2384,12 @@ static void borderselect_anim_channels(bAnimContext *ac, rcti *rect, short selec
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
SpaceNla *snla = (SpaceNla *)ac->sl;
View2D *v2d = &ac->ar->v2d;
rctf rectf;
float ymin, ymax;
-
+
/* set initial y extents */
if (ac->datatype == ANIMCONT_NLA) {
ymin = (float)(-NLACHANNEL_HEIGHT(snla));
@@ -2399,27 +2399,27 @@ static void borderselect_anim_channels(bAnimContext *ac, rcti *rect, short selec
ymin = 0.0f;
ymax = (float)(-ACHANNEL_HEIGHT(ac));
}
-
+
/* convert border-region to view coordinates */
UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin + 2, &rectf.xmin, &rectf.ymin);
UI_view2d_region_to_view(v2d, rect->xmax, rect->ymax - 2, &rectf.xmax, &rectf.ymax);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop over data, doing border select */
for (ale = anim_data.first; ale; ale = ale->next) {
if (ac->datatype == ANIMCONT_NLA)
ymin = ymax - NLACHANNEL_STEP(snla);
else
ymin = ymax - ACHANNEL_STEP(ac);
-
+
/* if channel is within border-select region, alter it */
if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) {
/* set selection flags only */
ANIM_channel_setting_set(ac, ale, ACHANNEL_SETTING_SELECT, selectmode);
-
+
/* type specific actions */
switch (ale->type) {
case ANIMTYPE_GROUP:
@@ -2433,20 +2433,20 @@ static void borderselect_anim_channels(bAnimContext *ac, rcti *rect, short selec
case ANIMTYPE_NLATRACK:
{
NlaTrack *nlt = (NlaTrack *)ale->data;
-
- /* for now, it's easier just to do this here manually, as defining a new type
- * currently adds complications when doing other stuff
+
+ /* for now, it's easier just to do this here manually, as defining a new type
+ * currently adds complications when doing other stuff
*/
ACHANNEL_SET_FLAG(nlt, selectmode, NLATRACK_SELECTED);
break;
}
}
}
-
+
/* set minimum extent to be the maximum of the next channel */
ymax = ymin;
}
-
+
/* cleanup */
ANIM_animdata_freelist(&anim_data);
}
@@ -2460,11 +2460,11 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op)
short selectmode = 0;
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get settings from operator */
WM_operator_properties_border_to_rcti(op, &rect);
@@ -2478,15 +2478,15 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op)
else {
selectmode = ACHANNEL_SETFLAG_CLEAR;
}
-
+
/* apply borderselect animation channels */
borderselect_anim_channels(&ac, &rect, selectmode);
-
+
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
-}
+}
static void ANIM_OT_channels_select_border(wmOperatorType *ot)
{
@@ -2494,18 +2494,18 @@ static void ANIM_OT_channels_select_border(wmOperatorType *ot)
ot->name = "Border Select";
ot->idname = "ANIM_OT_channels_select_border";
ot->description = "Select all animation channels within the specified region";
-
+
/* api callbacks */
ot->invoke = WM_gesture_border_invoke;
ot->exec = animchannels_borderselect_exec;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
-
+
ot->poll = animedit_poll_channels_nla_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* rna */
WM_operator_properties_gesture_border_select(ot);
}
@@ -2520,33 +2520,33 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index)
bAnimListElem *ale;
int filter;
bool success = false;
-
+
/* get the channel that was clicked on */
/* filter channels */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* get channel from index */
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
/* channel not found */
if (G.debug & G_DEBUG)
printf("Error: animation channel (index = %d) not found in rename_anim_channels()\n", channel_index);
-
+
ANIM_animdata_freelist(&anim_data);
return false;
}
-
+
/* check that channel can be renamed */
acf = ANIM_channel_get_typeinfo(ale);
if (acf && acf->name_prop) {
PointerRNA ptr;
PropertyRNA *prop;
-
+
/* ok if we can get name property to edit from this channel */
if (acf->name_prop(ale, &ptr, &prop)) {
/* actually showing the rename textfield is done on redraw,
- * so here we just store the index of this channel in the
+ * so here we just store the index of this channel in the
* dopesheet data, which will get utilized when drawing the
* channel...
*
@@ -2558,7 +2558,7 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index)
}
}
}
-
+
/* free temp data and tag for refresh */
ANIM_animdata_freelist(&anim_data);
ED_region_tag_redraw(ac->ar);
@@ -2571,18 +2571,18 @@ static int animchannels_channel_get(bAnimContext *ac, const int mval[2])
View2D *v2d;
int channel_index;
float x, y;
-
+
/* get useful pointers from animation context data */
ar = ac->ar;
v2d = &ar->v2d;
-
- /* figure out which channel user clicked in
+
+ /* figure out which channel user clicked in
* Note: although channels technically start at (y = ACHANNEL_FIRST), we need to adjust by half a channel's height
* so that the tops of channels get caught ok. Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use
* ACHANNEL_HEIGHT_HALF.
*/
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
-
+
if (ac->datatype == ANIMCONT_NLA) {
SpaceNla *snla = (SpaceNla *)ac->sl;
UI_view2d_listview_view_to_cell(v2d, NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP(snla), 0, (float)NLACHANNEL_HEIGHT_HALF(snla), x, y, NULL, &channel_index);
@@ -2619,7 +2619,7 @@ static void ANIM_OT_channels_rename(wmOperatorType *ot)
ot->name = "Rename Channels";
ot->idname = "ANIM_OT_channels_rename";
ot->description = "Rename animation channel under mouse";
-
+
/* api callbacks */
ot->invoke = animchannels_rename_invoke;
ot->poll = animedit_poll_channels_active;
@@ -2634,19 +2634,19 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
bAnimListElem *ale;
int filter;
int notifierFlags = 0;
-
+
/* get the channel that was clicked on */
/* filter channels */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* get channel from index */
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
/* channel not found */
if (G.debug & G_DEBUG)
printf("Error: animation channel (index = %d) not found in mouse_anim_channels()\n", channel_index);
-
+
ANIM_animdata_freelist(&anim_data);
return 0;
}
@@ -2666,7 +2666,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
{
Scene *sce = (Scene *)ale->data;
AnimData *adt = sce->adt;
-
+
/* set selection status */
if (selectmode == SELECT_INVERT) {
/* swap select */
@@ -2677,7 +2677,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
sce->flag |= SCE_DS_SELECTED;
if (adt) adt->flag |= ADT_UI_SELECTED;
}
-
+
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
break;
}
@@ -2691,7 +2691,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
Base *base = (Base *)ale->data;
Object *ob = base->object;
AnimData *adt = ob->adt;
-
+
/* set selection status */
if (base->flag & BASE_SELECTABLED) {
if (selectmode == SELECT_INVERT) {
@@ -2765,28 +2765,28 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
ale->adt->flag |= ADT_UI_SELECTED;
}
-
+
/* set active? */
if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
ale->adt->flag |= ADT_UI_ACTIVE;
}
-
+
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
break;
}
- case ANIMTYPE_GROUP:
+ case ANIMTYPE_GROUP:
{
bActionGroup *agrp = (bActionGroup *)ale->data;
-
+
Object *ob = NULL;
bPoseChannel *pchan = NULL;
-
-
+
+
/* Armatures-Specific Feature:
* Since groups are used to collect F-Curves of the same Bone by default
* (via Keying Sets) so that they can be managed better, we try to make
* things here easier for animators by mapping group selection to bone
- * selection.
+ * selection.
*
* Only do this if "Only Selected" dopesheet filter is not active, or else it
* becomes too unpredictable/tricky to manage
@@ -2794,7 +2794,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
if ((ac->ads->filterflag & ADS_FILTER_ONLYSEL) == 0) {
if ((ale->id) && (GS(ale->id->name) == ID_OB)) {
ob = (Object *)ale->id;
-
+
if (ob->type == OB_ARMATURE) {
/* Assume for now that any group with corresponding name is what we want
* (i.e. for an armature whose location is animated, things would break
@@ -2803,10 +2803,10 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
* TODO: check the first F-Curve or so to be sure...
*/
pchan = BKE_pose_channel_find_name(ob->pose, agrp->name);
- }
+ }
}
}
-
+
/* select/deselect group */
if (selectmode == SELECT_INVERT) {
/* inverse selection status of this group only */
@@ -2815,11 +2815,11 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
else if (selectmode == -1) {
/* select all in group (and deselect everthing else) */
FCurve *fcu;
-
+
/* deselect all other channels */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
if (pchan) ED_pose_deselect_all(ob, SEL_DESELECT, false);
-
+
/* only select channels in group and group itself */
for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next)
fcu->flag |= FCURVE_SELECTED;
@@ -2829,10 +2829,10 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
/* select group by itself */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
if (pchan) ED_pose_deselect_all(ob, SEL_DESELECT, false);
-
+
agrp->flag |= AGRP_SELECTED;
}
-
+
/* if group is selected now, make group the 'active' one in the visible list */
if (agrp->flag & AGRP_SELECTED) {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
@@ -2842,7 +2842,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, NULL, ANIMTYPE_GROUP);
if (pchan) ED_pose_bone_select(ob, pchan, false);
}
-
+
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
break;
}
@@ -2850,7 +2850,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
case ANIMTYPE_NLACURVE:
{
FCurve *fcu = (FCurve *)ale->data;
-
+
/* select/deselect */
if (selectmode == SELECT_INVERT) {
/* inverse selection status of this F-Curve only */
@@ -2861,18 +2861,18 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
fcu->flag |= FCURVE_SELECTED;
}
-
+
/* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */
if (fcu->flag & FCURVE_SELECTED)
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ale->type);
-
+
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
break;
}
- case ANIMTYPE_SHAPEKEY:
+ case ANIMTYPE_SHAPEKEY:
{
KeyBlock *kb = (KeyBlock *)ale->data;
-
+
/* select/deselect */
if (selectmode == SELECT_INVERT) {
/* inverse selection status of this ShapeKey only */
@@ -2883,39 +2883,39 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
kb->flag |= KEYBLOCK_SEL;
}
-
+
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
break;
}
case ANIMTYPE_NLACONTROLS:
{
AnimData *adt = (AnimData *)ale->data;
-
+
/* toggle expand
* - Although the triangle widget already allows this, since there's nothing else that can be done here now,
* let's just use it for easier expand/collapse for now
*/
adt->flag ^= ADT_NLA_SKEYS_COLLAPSED;
-
+
notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
break;
}
case ANIMTYPE_GPDATABLOCK:
{
bGPdata *gpd = (bGPdata *)ale->data;
-
- /* toggle expand
+
+ /* toggle expand
* - although the triangle widget already allows this, the whole channel can also be used for this purpose
*/
gpd->flag ^= GP_DATA_EXPAND;
-
+
notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
break;
}
case ANIMTYPE_GPLAYER:
{
bGPDlayer *gpl = (bGPDlayer *)ale->data;
-
+
/* select/deselect */
if (selectmode == SELECT_INVERT) {
/* invert selection status of this layer only */
@@ -2926,12 +2926,12 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
gpl->flag |= GP_LAYER_SELECT;
}
-
+
/* change active layer, if this is selected (since we must always have an active layer) */
if (gpl->flag & GP_LAYER_SELECT) {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, gpl, ANIMTYPE_GPLAYER);
}
-
+
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); /* Grease Pencil updates */
notifierFlags |= (ND_ANIMCHAN | NA_EDITED); /* Animation Ediotrs updates */
break;
@@ -2939,19 +2939,19 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
case ANIMTYPE_MASKDATABLOCK:
{
Mask *mask = (Mask *)ale->data;
-
+
/* toggle expand
* - although the triangle widget already allows this, the whole channel can also be used for this purpose
*/
mask->flag ^= MASK_ANIMF_EXPAND;
-
+
notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
break;
}
case ANIMTYPE_MASKLAYER:
{
MaskLayer *masklay = (MaskLayer *)ale->data;
-
+
/* select/deselect */
if (selectmode == SELECT_INVERT) {
/* invert selection status of this layer only */
@@ -2962,7 +2962,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
masklay->flag |= MASK_LAYERFLAG_SELECT;
}
-
+
notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
break;
}
@@ -2971,10 +2971,10 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
printf("Error: Invalid channel type in mouse_anim_channels()\n");
break;
}
-
+
/* free channels */
ANIM_animdata_freelist(&anim_data);
-
+
/* return notifier flags */
return notifierFlags;
}
@@ -2991,16 +2991,16 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmE
int notifierFlags = 0;
short selectmode;
float x, y;
-
-
+
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get useful pointers from animation context data */
ar = ac.ar;
v2d = &ar->v2d;
-
+
/* select mode is either replace (deselect all, then add) or add/extend */
if (RNA_boolean_get(op->ptr, "extend"))
selectmode = SELECT_INVERT;
@@ -3008,45 +3008,45 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmE
selectmode = -1; /* this is a bit of a special case for ActionGroups only... should it be removed or extended to all instead? */
else
selectmode = SELECT_REPLACE;
-
- /* figure out which channel user clicked in
+
+ /* figure out which channel user clicked in
* Note: although channels technically start at (y = ACHANNEL_FIRST), we need to adjust by half a channel's height
* so that the tops of channels get caught ok. Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use
* ACHANNEL_HEIGHT_HALF.
*/
UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y);
UI_view2d_listview_view_to_cell(v2d, ACHANNEL_NAMEWIDTH, ACHANNEL_STEP(&ac), 0, (float)ACHANNEL_HEIGHT_HALF(&ac), x, y, NULL, &channel_index);
-
+
/* handle mouse-click in the relevant channel then */
notifierFlags = mouse_anim_channels(C, &ac, channel_index, selectmode);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
static void ANIM_OT_channels_click(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Mouse Click on Channels";
ot->idname = "ANIM_OT_channels_click";
ot->description = "Handle mouse-clicks over animation channels";
-
+
/* api callbacks */
ot->invoke = animchannels_mouseclick_invoke;
ot->poll = animedit_poll_channels_active;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
-
+
/* properties */
/* NOTE: don't save settings, otherwise, can end up with some weird behaviour (sticky extend) */
prop = RNA_def_boolean(ot->srna, "extend", false, "Extend Select", ""); // SHIFTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-
+
prop = RNA_def_boolean(ot->srna, "children_only", false, "Select Children Only", ""); // CTRLKEY|SHIFTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
@@ -3157,13 +3157,13 @@ void ED_operatortypes_animchannels(void)
{
WM_operatortype_append(ANIM_OT_channels_select_all_toggle);
WM_operatortype_append(ANIM_OT_channels_select_border);
-
+
WM_operatortype_append(ANIM_OT_channels_click);
WM_operatortype_append(ANIM_OT_channel_select_keys);
WM_operatortype_append(ANIM_OT_channels_rename);
WM_operatortype_append(ANIM_OT_channels_find);
-
+
WM_operatortype_append(ANIM_OT_channels_setting_enable);
WM_operatortype_append(ANIM_OT_channels_setting_disable);
WM_operatortype_append(ANIM_OT_channels_setting_toggle);
@@ -3172,16 +3172,16 @@ void ED_operatortypes_animchannels(void)
/* XXX does this need to be a separate operator? */
WM_operatortype_append(ANIM_OT_channels_editable_toggle);
-
+
WM_operatortype_append(ANIM_OT_channels_move);
-
+
WM_operatortype_append(ANIM_OT_channels_expand);
WM_operatortype_append(ANIM_OT_channels_collapse);
-
+
WM_operatortype_append(ANIM_OT_channels_fcurves_enable);
-
+
WM_operatortype_append(ANIM_OT_channels_clean_empty);
-
+
WM_operatortype_append(ANIM_OT_channels_group);
WM_operatortype_append(ANIM_OT_channels_ungroup);
}
@@ -3191,7 +3191,7 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_find(keyconf, "Animation Channels", 0, 0);
wmKeyMapItem *kmi;
-
+
/* click-select */
/* XXX for now, only leftmouse.... */
WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, 0, 0);
@@ -3206,31 +3206,31 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf)
/* find (i.e. a shortcut for setting the name filter) */
WM_keymap_add_item(keymap, "ANIM_OT_channels_find", FKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* deselect all */
WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", AKEY, KM_PRESS, 0, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", true);
-
+
/* borderselect */
WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", BKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", EVT_TWEAK_L, KM_ANY, 0, 0);
-
+
/* delete */
WM_keymap_add_item(keymap, "ANIM_OT_channels_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ANIM_OT_channels_delete", DELKEY, KM_PRESS, 0, 0);
-
+
/* settings */
WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_toggle", WKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_disable", WKEY, KM_PRESS, KM_ALT, 0);
-
+
/* settings - specialized hotkeys */
WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0);
-
+
/* expand/collapse */
WM_keymap_add_item(keymap, "ANIM_OT_channels_expand", PADPLUSKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ANIM_OT_channels_collapse", PADMINUS, KM_PRESS, 0, 0);
-
+
kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_expand", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "all", false);
kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_collapse", PADMINUS, KM_PRESS, KM_CTRL, 0);
@@ -3241,7 +3241,7 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf)
RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEDOWNKEY, KM_PRESS, 0, 0)->ptr, "direction", REARRANGE_ANIMCHAN_DOWN);
RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEUPKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "direction", REARRANGE_ANIMCHAN_TOP);
RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "direction", REARRANGE_ANIMCHAN_BOTTOM);
-
+
/* grouping */
WM_keymap_add_item(keymap, "ANIM_OT_channels_group", GKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ANIM_OT_channels_ungroup", GKEY, KM_PRESS, KM_ALT, 0);
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index 9169df1407b..adb5a10c19d 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation, Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
@@ -46,10 +46,10 @@
#include "BKE_animsys.h"
#include "BKE_action.h"
+#include "BKE_context.h"
#include "BKE_fcurve.h"
#include "BKE_gpencil.h"
-#include "BKE_context.h"
-#include "BKE_global.h"
+#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_sequencer.h"
@@ -62,9 +62,9 @@
/* **************************** depsgraph tagging ******************************** */
/* tags the given anim list element for refreshes (if applicable)
- * due to Animation Editor editing
+ * due to Animation Editor editing
*/
-void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale)
+void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale)
{
ID *id;
FCurve *fcu;
@@ -73,7 +73,7 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale)
id = ale->id;
if (!id)
return;
-
+
/* tag AnimData for refresh so that other views will update in realtime with these changes */
adt = BKE_animdata_from_id(id);
if (adt) {
@@ -86,18 +86,18 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale)
/* update data */
fcu = (ale->datatype == ALE_FCURVE) ? ale->key_data : NULL;
-
+
if (fcu && fcu->rna_path) {
/* if we have an fcurve, call the update for the property we
* are editing, this is then expected to do the proper redraws
* and depsgraph updates */
PointerRNA id_ptr, ptr;
PropertyRNA *prop;
-
+
RNA_id_pointer_create(id, &id_ptr);
-
+
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop))
- RNA_property_update_main(G.main, scene, &ptr, prop);
+ RNA_property_update_main(bmain, scene, &ptr, prop);
}
else {
/* in other case we do standard depsgraph update, ideally
@@ -106,17 +106,17 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale)
}
}
-/* tags the given ID block for refreshes (if applicable) due to
+/* tags the given ID block for refreshes (if applicable) due to
* Animation Editor editing */
void ANIM_id_update(Scene *UNUSED(scene), ID *id)
{
if (id) {
AnimData *adt = BKE_animdata_from_id(id);
-
+
/* tag AnimData for refresh so that other views will update in realtime with these changes */
if (adt)
adt->recalc |= ADT_RECALC_ANIM;
-
+
/* set recalc flags */
DEG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); // XXX or do we want something more restrictive?
}
@@ -125,10 +125,10 @@ void ANIM_id_update(Scene *UNUSED(scene), ID *id)
/* **************************** animation data <-> data syncing ******************************** */
/* This code here is used to synchronize the
* - selection (to find selected data easier)
- * - ... (insert other relevant items here later)
+ * - ... (insert other relevant items here later)
* status in relevant Blender data with the status stored in animation channels.
*
- * This should be called in the refresh() callbacks for various editors in
+ * This should be called in the refresh() callbacks for various editors in
* response to appropriate notifiers.
*/
@@ -137,33 +137,33 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro
{
bActionGroup *agrp = (bActionGroup *)ale->data;
ID *owner_id = ale->id;
-
+
/* major priority is selection status
* so we need both a group and an owner
*/
if (ELEM(NULL, agrp, owner_id))
return;
-
+
/* for standard Objects, check if group is the name of some bone */
if (GS(owner_id->name) == ID_OB) {
Object *ob = (Object *)owner_id;
-
- /* check if there are bones, and whether the name matches any
+
+ /* check if there are bones, and whether the name matches any
* NOTE: this feature will only really work if groups by default contain the F-Curves for a single bone
*/
if (ob->pose) {
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, agrp->name);
bArmature *arm = ob->data;
-
+
if (pchan) {
bActionGroup *bgrp;
-
+
/* if one matches, sync the selection status */
if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED))
agrp->flag |= AGRP_SELECTED;
else
agrp->flag &= ~AGRP_SELECTED;
-
+
/* also sync active group status */
if ((ob == ac->obact) && (pchan->bone == arm->act_bone)) {
/* if no previous F-Curve has active flag, then we're the first and only one to get it */
@@ -180,7 +180,7 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro
/* this can't possibly be active now */
agrp->flag &= ~AGRP_ACTIVE;
}
-
+
/* sync group colors */
bgrp = (bActionGroup *)BLI_findlink(&ob->pose->agroups, (pchan->agrp_index - 1));
if (bgrp) {
@@ -191,33 +191,33 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro
}
}
}
-
+
/* perform syncing updates for F-Curves */
static void animchan_sync_fcurve(bAnimContext *ac, bAnimListElem *ale, FCurve **active_fcurve)
{
FCurve *fcu = (FCurve *)ale->data;
ID *owner_id = ale->id;
-
- /* major priority is selection status, so refer to the checks done in anim_filter.c
+
+ /* major priority is selection status, so refer to the checks done in anim_filter.c
* skip_fcurve_selected_data() for reference about what's going on here...
*/
if (ELEM(NULL, fcu, fcu->rna_path, owner_id))
return;
-
+
if (GS(owner_id->name) == ID_OB) {
Object *ob = (Object *)owner_id;
-
+
/* only affect if F-Curve involves pose.bones */
if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones")) {
bArmature *arm = (bArmature *)ob->data;
bPoseChannel *pchan;
char *bone_name;
-
+
/* get bone-name, and check if this bone is selected */
bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
if (bone_name) MEM_freeN(bone_name);
-
+
/* F-Curve selection depends on whether the bone is selected */
if ((pchan) && (pchan->bone)) {
/* F-Curve selection */
@@ -225,8 +225,8 @@ static void animchan_sync_fcurve(bAnimContext *ac, bAnimListElem *ale, FCurve **
fcu->flag |= FCURVE_SELECTED;
else
fcu->flag &= ~FCURVE_SELECTED;
-
- /* Active F-Curve - it should be the first one for this bone on the
+
+ /* Active F-Curve - it should be the first one for this bone on the
* active object to be considered as active
*/
if ((ob == ac->obact) && (pchan->bone == arm->act_bone)) {
@@ -249,18 +249,18 @@ static void animchan_sync_fcurve(bAnimContext *ac, bAnimListElem *ale, FCurve **
}
else if (GS(owner_id->name) == ID_SCE) {
Scene *scene = (Scene *)owner_id;
-
+
/* only affect if F-Curve involves sequence_editor.sequences */
if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) {
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq;
char *seq_name;
-
+
/* get strip name, and check if this strip is selected */
seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false);
if (seq_name) MEM_freeN(seq_name);
-
+
/* update selection status */
if (seq) {
if (seq->flag & SELECT)
@@ -272,17 +272,17 @@ static void animchan_sync_fcurve(bAnimContext *ac, bAnimListElem *ale, FCurve **
}
else if (GS(owner_id->name) == ID_NT) {
bNodeTree *ntree = (bNodeTree *)owner_id;
-
+
/* check for selected nodes */
if ((fcu->rna_path) && strstr(fcu->rna_path, "nodes")) {
bNode *node;
char *node_name;
-
+
/* get strip name, and check if this strip is selected */
node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
node = nodeFindNodebyName(ntree, node_name);
if (node_name) MEM_freeN(node_name);
-
+
/* update selection/active status */
if (node) {
/* update selection status */
@@ -290,7 +290,7 @@ static void animchan_sync_fcurve(bAnimContext *ac, bAnimListElem *ale, FCurve **
fcu->flag |= FCURVE_SELECTED;
else
fcu->flag &= ~FCURVE_SELECTED;
-
+
/* update active status */
/* XXX: this may interfere with setting bones as active if both exist at once;
* then again, if that's the case, production setups aren't likely to be animating
@@ -317,7 +317,7 @@ static void animchan_sync_fcurve(bAnimContext *ac, bAnimListElem *ale, FCurve **
static void animchan_sync_gplayer(bAnimContext *UNUSED(ac), bAnimListElem *ale)
{
bGPDlayer *gpl = (bGPDlayer *)ale->data;
-
+
/* Make sure the selection flags agree with the "active" flag.
* The selection flags are used in the Dopesheet only, whereas
* the active flag is used everywhere else. Hence, we try to
@@ -336,7 +336,7 @@ static void animchan_sync_gplayer(bAnimContext *UNUSED(ac), bAnimListElem *ale)
}
/* ---------------- */
-
+
/* Main call to be exported to animation editors */
void ANIM_sync_animchannels_to_data(const bContext *C)
{
@@ -344,38 +344,38 @@ void ANIM_sync_animchannels_to_data(const bContext *C)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
bActionGroup *active_agrp = NULL;
FCurve *active_fcurve = NULL;
-
+
/* get animation context info for filtering the channels */
if (ANIM_animdata_get_context(C, &ac) == 0)
return;
-
+
/* filter data */
- /* NOTE: we want all channels, since we want to be able to set selection status on some of them even when collapsed
+ /* NOTE: we want all channels, since we want to be able to set selection status on some of them even when collapsed
* However, don't include duplicates so that selection statuses don't override each other
*/
filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS;
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* flush settings as appropriate depending on the types of the channels */
for (ale = anim_data.first; ale; ale = ale->next) {
switch (ale->type) {
case ANIMTYPE_GROUP:
animchan_sync_group(&ac, ale, &active_agrp);
break;
-
+
case ANIMTYPE_FCURVE:
animchan_sync_fcurve(&ac, ale, &active_fcurve);
break;
-
+
case ANIMTYPE_GPLAYER:
animchan_sync_gplayer(&ac, ale);
break;
}
}
-
+
ANIM_animdata_freelist(&anim_data);
}
@@ -396,43 +396,43 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data)
for (ale = anim_data->first; ale; ale = ale->next) {
if (ale->type == ANIMTYPE_GPLAYER) {
bGPDlayer *gpl = ale->data;
-
+
if (ale->update & ANIM_UPDATE_ORDER) {
ale->update &= ~ANIM_UPDATE_ORDER;
if (gpl) {
//gpencil_sort_frames(gpl);
}
}
-
+
if (ale->update & ANIM_UPDATE_DEPS) {
ale->update &= ~ANIM_UPDATE_DEPS;
- ANIM_list_elem_update(ac->scene, ale);
+ ANIM_list_elem_update(ac->bmain, ac->scene, ale);
}
}
else if (ale->datatype == ALE_FCURVE) {
FCurve *fcu = ale->key_data;
-
+
if (ale->update & ANIM_UPDATE_ORDER) {
ale->update &= ~ANIM_UPDATE_ORDER;
if (fcu)
sort_time_fcurve(fcu);
}
-
+
if (ale->update & ANIM_UPDATE_HANDLES) {
ale->update &= ~ANIM_UPDATE_HANDLES;
if (fcu)
calchandles_fcurve(fcu);
}
-
+
if (ale->update & ANIM_UPDATE_DEPS) {
ale->update &= ~ANIM_UPDATE_DEPS;
- ANIM_list_elem_update(ac->scene, ale);
+ ANIM_list_elem_update(ac->bmain, ac->scene, ale);
}
}
else if (ale->datatype == ALE_NLASTRIP) {
if (ale->update & ANIM_UPDATE_DEPS) {
ale->update &= ~ANIM_UPDATE_DEPS;
- ANIM_list_elem_update(ac->scene, ale);
+ ANIM_list_elem_update(ac->bmain, ac->scene, ale);
}
}
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 475623b1048..c2cfb877745 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
@@ -75,7 +75,7 @@ void ANIM_draw_cfra_number(const bContext *C, View2D *v2d, short flag)
const float time = scene->r.cfra + scene->r.subframe;
const float cfra = (float)(time * scene->r.framelen);
const bool show_time = (flag & DRAWCFRA_UNIT_SECONDS) != 0;
-
+
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
unsigned char col[4];
float color[4];
@@ -83,13 +83,13 @@ void ANIM_draw_cfra_number(const bContext *C, View2D *v2d, short flag)
char numstr[32] = " t "; /* t is the character to start replacing from */
float hlen;
int slen;
-
+
/* because the frame number text is subject to the same scaling as the contents of the view */
UI_view2d_scale_get(v2d, &xscale, NULL);
gpuPushMatrix();
gpuScale2f(1.0f / xscale, 1.0f);
-
- /* get timecode string
+
+ /* get timecode string
* - padding on str-buf passed so that it doesn't sit on the frame indicator
*/
if (show_time) {
@@ -101,7 +101,7 @@ void ANIM_draw_cfra_number(const bContext *C, View2D *v2d, short flag)
slen = UI_fontstyle_string_width(fstyle, numstr) - 1;
hlen = slen * 0.5f;
-
+
/* get starting coordinates for drawing */
x = cfra * xscale;
y = -0.1f * U.widget_unit;
@@ -163,7 +163,7 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
{
Scene *scene = CTX_data_scene(C);
-
+
/* only draw this if preview range is set */
if (PRVRANGEON) {
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
@@ -243,10 +243,10 @@ AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
/* sanity checks */
if (ac == NULL)
return NULL;
-
+
/* abort if rendering - we may get some race condition issues... */
if (G.is_rendering) return NULL;
-
+
/* apart from strictly keyframe-related contexts, this shouldn't even happen */
// XXX: nla and channel here may not be necessary...
if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_SHAPEKEY, ANIMCONT_DOPESHEET,
@@ -259,7 +259,7 @@ AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
return ale->adt;
}
}
-
+
/* cannot handle... */
return NULL;
}
@@ -272,15 +272,15 @@ static short bezt_nlamapping_restore(KeyframeEditData *ked, BezTriple *bezt)
/* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */
AnimData *adt = (AnimData *)ked->data;
short only_keys = (short)ked->i1;
-
+
/* adjust BezTriple handles only if allowed to */
if (only_keys == 0) {
bezt->vec[0][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], NLATIME_CONVERT_UNMAP);
bezt->vec[2][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], NLATIME_CONVERT_UNMAP);
}
-
+
bezt->vec[1][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], NLATIME_CONVERT_UNMAP);
-
+
return 0;
}
@@ -290,41 +290,41 @@ static short bezt_nlamapping_apply(KeyframeEditData *ked, BezTriple *bezt)
/* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */
AnimData *adt = (AnimData *)ked->data;
short only_keys = (short)ked->i1;
-
+
/* adjust BezTriple handles only if allowed to */
if (only_keys == 0) {
bezt->vec[0][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], NLATIME_CONVERT_MAP);
bezt->vec[2][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], NLATIME_CONVERT_MAP);
}
-
+
bezt->vec[1][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], NLATIME_CONVERT_MAP);
-
+
return 0;
}
-/* Apply/Unapply NLA mapping to all keyframes in the nominated F-Curve
- * - restore = whether to map points back to non-mapped time
+/* Apply/Unapply NLA mapping to all keyframes in the nominated F-Curve
+ * - restore = whether to map points back to non-mapped time
* - only_keys = whether to only adjust the location of the center point of beztriples
*/
void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, bool restore, bool only_keys)
{
KeyframeEditData ked = {{NULL}};
KeyframeEditFunc map_cb;
-
- /* init edit data
+
+ /* init edit data
* - AnimData is stored in 'data'
* - only_keys is stored in 'i1'
*/
ked.data = (void *)adt;
ked.i1 = (int)only_keys;
-
+
/* get editing callback */
if (restore)
map_cb = bezt_nlamapping_restore;
else
map_cb = bezt_nlamapping_apply;
-
+
/* apply to F-Curve */
ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, map_cb, NULL);
}
@@ -503,7 +503,7 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag
if (id && fcu && fcu->rna_path) {
PointerRNA ptr, id_ptr;
PropertyRNA *prop;
-
+
/* get RNA property that F-Curve affects */
RNA_id_pointer_create(id, &id_ptr);
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
@@ -517,7 +517,7 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag
return RAD2DEGF(1.0f); /* radians to degrees */
}
}
-
+
/* TODO: other rotation types here as necessary */
}
}
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index d8dc4af52f3..8892fed025a 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation, Joshua Leung
* All rights reserved.
*
- *
+ *
* Contributor(s): Joshua Leung (original author)
*
* ***** END GPL LICENSE BLOCK *****
@@ -30,10 +30,10 @@
/* This file contains a system used to provide a layer of abstraction between sources
- * of animation data and tools in Animation Editors. The method used here involves
- * generating a list of edit structures which enable tools to naively perform the actions
- * they require without all the boiler-plate associated with loops within loops and checking
- * for cases to ignore.
+ * of animation data and tools in Animation Editors. The method used here involves
+ * generating a list of edit structures which enable tools to naively perform the actions
+ * they require without all the boiler-plate associated with loops within loops and checking
+ * for cases to ignore.
*
* While this is primarily used for the Action/Dopesheet Editor (and its accessory modes),
* the Graph Editor also uses this for its channel list and for determining which curves
@@ -42,7 +42,7 @@
*
* Note: much of the original system this was based on was built before the creation of the RNA
* system. In future, it would be interesting to replace some parts of this code with RNA queries,
- * however, RNA does not eliminate some of the boiler-plate reduction benefits presented by this
+ * however, RNA does not eliminate some of the boiler-plate reduction benefits presented by this
* system, so if any such work does occur, it should only be used for the internals used here...
*
* -- Joshua Leung, Dec 2008 (Last revision July 2009)
@@ -113,13 +113,13 @@
static void animedit_get_yscale_factor(bAnimContext *ac)
{
bTheme *btheme = UI_GetTheme();
-
+
/* grab scale factor directly from action editor setting
* NOTE: This theme setting doesn't have an ID, as it cannot be accessed normally
* since it is a float, and the theme settings methods can only handle chars.
*/
ac->yscale_fac = btheme->tact.keyframe_scale_fac;
-
+
/* clamp to avoid problems with uninitialised values... */
if (ac->yscale_fac < 0.1f)
ac->yscale_fac = 1.0f;
@@ -135,22 +135,22 @@ static Key *actedit_get_shapekeys(bAnimContext *ac)
ViewLayer *view_layer = ac->view_layer;
Object *ob;
Key *key;
-
+
ob = OBACT(view_layer);
- if (ob == NULL)
+ if (ob == NULL)
return NULL;
-
+
/* XXX pinning is not available in 'ShapeKey' mode... */
//if (saction->pin) return NULL;
-
+
/* shapekey data is stored with geometry data */
key = BKE_key_from_object(ob);
-
+
if (key) {
if (key->type == KEY_RELATIVE)
return key;
}
-
+
return NULL;
}
@@ -159,7 +159,7 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
{
/* get dopesheet */
ac->ads = &saction->ads;
-
+
/* sync settings with current view status, then return appropriate data */
switch (saction->mode) {
case SACTCONT_ACTION: /* 'Action Editor' */
@@ -170,37 +170,37 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
else
saction->action = NULL;
}
-
+
ac->datatype = ANIMCONT_ACTION;
ac->data = saction->action;
-
+
ac->mode = saction->mode;
return true;
-
+
case SACTCONT_SHAPEKEY: /* 'ShapeKey Editor' */
ac->datatype = ANIMCONT_SHAPEKEY;
ac->data = actedit_get_shapekeys(ac);
-
+
/* if not pinned, sync with active object */
if (/*saction->pin == 0*/ true) {
Key *key = (Key *)ac->data;
-
+
if (key && key->adt)
saction->action = key->adt->action;
else
saction->action = NULL;
}
-
+
ac->mode = saction->mode;
return true;
-
+
case SACTCONT_GPENCIL: /* Grease Pencil */ /* XXX review how this mode is handled... */
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
saction->ads.source = (ID *)ac->scene;
-
+
ac->datatype = ANIMCONT_GPENCIL;
ac->data = &saction->ads;
-
+
ac->mode = saction->mode;
return true;
@@ -213,48 +213,48 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
ac->mode = saction->mode;
return true;
-
+
case SACTCONT_MASK: /* Mask */ /* XXX review how this mode is handled... */
{
/* TODO, other methods to get the mask */
// Sequence *seq = BKE_sequencer_active_get(ac->scene);
//MovieClip *clip = ac->scene->clip;
// struct Mask *mask = seq ? seq->mask : NULL;
-
+
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
saction->ads.source = (ID *)ac->scene;
-
+
ac->datatype = ANIMCONT_MASK;
ac->data = &saction->ads;
-
+
ac->mode = saction->mode;
return true;
}
-
+
case SACTCONT_DOPESHEET: /* DopeSheet */
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
saction->ads.source = (ID *)ac->scene;
-
+
ac->datatype = ANIMCONT_DOPESHEET;
ac->data = &saction->ads;
-
+
ac->mode = saction->mode;
return true;
-
+
case SACTCONT_TIMELINE: /* Timeline */
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
saction->ads.source = (ID *)ac->scene;
-
+
ac->datatype = ANIMCONT_TIMELINE;
ac->data = &saction->ads;
-
+
ac->mode = saction->mode;
return true;
-
+
default: /* unhandled yet */
ac->datatype = ANIMCONT_NONE;
ac->data = NULL;
-
+
ac->mode = -1;
return false;
}
@@ -271,41 +271,41 @@ static bool graphedit_get_context(bAnimContext *ac, SpaceIpo *sipo)
sipo->ads->source = (ID *)ac->scene;
}
ac->ads = sipo->ads;
-
+
/* set settings for Graph Editor - "Selected = Editable" */
if (sipo->flag & SIPO_SELCUVERTSONLY)
sipo->ads->filterflag |= ADS_FILTER_SELEDIT;
else
sipo->ads->filterflag &= ~ADS_FILTER_SELEDIT;
-
+
/* sync settings with current view status, then return appropriate data */
switch (sipo->mode) {
case SIPO_MODE_ANIMATION: /* Animation F-Curve Editor */
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
sipo->ads->source = (ID *)ac->scene;
sipo->ads->filterflag &= ~ADS_FILTER_ONLYDRIVERS;
-
+
ac->datatype = ANIMCONT_FCURVES;
ac->data = sipo->ads;
-
+
ac->mode = sipo->mode;
return true;
-
+
case SIPO_MODE_DRIVERS: /* Driver F-Curve Editor */
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
sipo->ads->source = (ID *)ac->scene;
sipo->ads->filterflag |= ADS_FILTER_ONLYDRIVERS;
-
+
ac->datatype = ANIMCONT_DRIVERS;
ac->data = sipo->ads;
-
+
ac->mode = sipo->mode;
return true;
-
+
default: /* unhandled yet */
ac->datatype = ANIMCONT_NONE;
ac->data = NULL;
-
+
ac->mode = -1;
return false;
}
@@ -320,21 +320,21 @@ static bool nlaedit_get_context(bAnimContext *ac, SpaceNla *snla)
if (snla->ads == NULL)
snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet");
ac->ads = snla->ads;
-
+
/* sync settings with current view status, then return appropriate data */
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
snla->ads->source = (ID *)ac->scene;
snla->ads->filterflag |= ADS_FILTER_ONLYNLA;
-
+
ac->datatype = ANIMCONT_NLA;
ac->data = snla->ads;
-
+
return true;
}
/* ----------- Public API --------------- */
-/* Obtain current anim-data context, given that context info from Blender context has already been set
+/* Obtain current anim-data context, given that context info from Blender context has already been set
* - AnimContext to write to is provided as pointer to var on stack so that we don't have
* allocation/freeing costs (which are not that avoidable with channels).
*/
@@ -342,7 +342,7 @@ bool ANIM_animdata_context_getdata(bAnimContext *ac)
{
SpaceLink *sl = ac->sl;
bool ok = false;
-
+
/* context depends on editor we are currently in */
if (sl) {
switch (ac->spacetype) {
@@ -366,28 +366,30 @@ bool ANIM_animdata_context_getdata(bAnimContext *ac)
}
}
}
-
+
/* check if there's any valid data */
return (ok && ac->data);
}
-/* Obtain current anim-data context from Blender Context info
+/* Obtain current anim-data context from Blender Context info
* - AnimContext to write to is provided as pointer to var on stack so that we don't have
* allocation/freeing costs (which are not that avoidable with channels).
* - Clears data and sets the information from Blender Context which is useful
*/
bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
{
+ Main *bmain = CTX_data_main(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
SpaceLink *sl = CTX_wm_space_data(C);
Scene *scene = CTX_data_scene(C);
-
+
/* clear old context info */
if (ac == NULL) return false;
memset(ac, 0, sizeof(bAnimContext));
-
+
/* get useful default context settings from context */
+ ac->bmain = bmain;
ac->scene = scene;
if (scene) {
ac->markers = ED_context_get_markers(C);
@@ -400,10 +402,10 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
ac->sl = sl;
ac->spacetype = (sa) ? sa->spacetype : 0;
ac->regiontype = (ar) ? ar->regiontype : 0;
-
+
/* initialise default y-scale factor */
animedit_get_yscale_factor(ac);
-
+
/* get data context info */
// XXX: if the below fails, try to grab this info from context instead... (to allow for scripting)
return ANIM_animdata_context_getdata(ac);
@@ -418,8 +420,8 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
* cases:
* 1) Graph Edit main area (just data) OR channels visible in Channel List
* 2) If not showing channels, we're only interested in the data (Action Editor's editing)
- * 3) We don't care what data, we just care there is some (so that a collapsed
- * channel can be kept around). No need to clear channels-flag in order to
+ * 3) We don't care what data, we just care there is some (so that a collapsed
+ * channel can be kept around). No need to clear channels-flag in order to
* keep expander channels with no sub-data out, as those cases should get
* dealt with by the recursive detection idiom in place.
*
@@ -461,13 +463,13 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
/* quick macro to test if AnimData is usable for NLA */
#define ANIMDATA_HAS_NLA(id) ((id)->adt && (id)->adt->nla_tracks.first)
-/* Quick macro to test for all three above usability tests, performing the appropriate provided
- * action for each when the AnimData context is appropriate.
+/* Quick macro to test for all three above usability tests, performing the appropriate provided
+ * action for each when the AnimData context is appropriate.
*
* Priority order for this goes (most important, to least): AnimData blocks, NLA, Drivers, Keyframes.
*
* For this to work correctly, a standard set of data needs to be available within the scope that this
- * gets called in:
+ * gets called in:
* - ListBase anim_data;
* - bDopeSheet *ads;
* - bAnimListElem *ale;
@@ -484,7 +486,7 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
* 0) top level: checks for animdata and also that all the F-Curves for the block will be visible
* 1) animdata check: for filtering animdata blocks only
* 2A) nla tracks: include animdata block's data as there are NLA tracks+strips there
- * 2B) actions to convert to nla: include animdata block's data as there is an action that can be
+ * 2B) actions to convert to nla: include animdata block's data as there is an action that can be
* converted to a new NLA strip, and the filtering options allow this
* 2C) allow non-animated datablocks to be included so that datablocks can be added
* 3) drivers: include drivers from animdata block (for Drivers mode in Graph Editor)
@@ -525,7 +527,7 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
/* ............................... */
-/* Add a new animation channel, taking into account the "peek" flag, which is used to just check
+/* Add a new animation channel, taking into account the "peek" flag, which is used to just check
* whether any channels will be added (but without needing them to actually get created).
*
* ! This causes the calling function to return early if we're only "peeking" for channels
@@ -542,12 +544,12 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
ale_statement \
} \
} (void)0
-
+
#define ANIMCHANNEL_NEW_CHANNEL(channel_data, channel_type, owner_id) \
ANIMCHANNEL_NEW_CHANNEL_FULL(channel_data, channel_type, owner_id, {})
-
+
/* ............................... */
-
+
/* quick macro to test if an anim-channel representing an AnimData block is suitably active */
#define ANIMCHANNEL_ACTIVEOK(ale) \
(!(filter_mode & ANIMFILTER_ACTIVE) || !(ale->adt) || (ale->adt->flag & ADT_UI_ACTIVE) )
@@ -557,8 +559,8 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
(!(filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL)) || \
((filter_mode & ANIMFILTER_SEL) && test_func) || \
((filter_mode & ANIMFILTER_UNSEL) && test_func == 0) )
-
-/* quick macro to test if an anim-channel (F-Curve) is selected ok for editing purposes
+
+/* quick macro to test if an anim-channel (F-Curve) is selected ok for editing purposes
* - _SELEDIT means that only selected curves will have visible+editable keyframes
*
* checks here work as follows:
@@ -573,29 +575,29 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
/* ----------- 'Private' Stuff --------------- */
-/* this function allocates memory for a new bAnimListElem struct for the
- * provided animation channel-data.
+/* this function allocates memory for a new bAnimListElem struct for the
+ * provided animation channel-data.
*/
static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owner_id)
{
bAnimListElem *ale = NULL;
-
+
/* only allocate memory if there is data to convert */
if (data) {
/* allocate and set generic data */
ale = MEM_callocN(sizeof(bAnimListElem), "bAnimListElem");
-
+
ale->data = data;
ale->type = datatype;
-
+
ale->id = owner_id;
ale->adt = BKE_animdata_from_id(owner_id);
-
+
/* do specifics */
switch (datatype) {
case ANIMTYPE_SUMMARY:
{
- /* nothing to include for now... this is just a dummy wrappy around all the other channels
+ /* nothing to include for now... this is just a dummy wrappy around all the other channels
* in the DopeSheet, and gets included at the start of the list
*/
ale->key_data = NULL;
@@ -605,12 +607,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
case ANIMTYPE_SCENE:
{
Scene *sce = (Scene *)data;
-
+
ale->flag = sce->flag;
-
+
ale->key_data = sce;
ale->datatype = ALE_SCE;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -618,21 +620,21 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
Base *base = (Base *)data;
Object *ob = base->object;
-
+
ale->flag = ob->flag;
-
+
ale->key_data = ob;
ale->datatype = ALE_OB;
-
+
ale->adt = BKE_animdata_from_id(&ob->id);
break;
}
case ANIMTYPE_FILLACTD:
{
bAction *act = (bAction *)data;
-
+
ale->flag = act->flag;
-
+
ale->key_data = act;
ale->datatype = ALE_ACT;
break;
@@ -640,9 +642,9 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
case ANIMTYPE_FILLDRIVERS:
{
AnimData *adt = (AnimData *)data;
-
+
ale->flag = adt->flag;
-
+
// XXX... drivers don't show summary for now
ale->key_data = NULL;
ale->datatype = ALE_NONE;
@@ -652,12 +654,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
Material *ma = (Material *)data;
AnimData *adt = ma->adt;
-
+
ale->flag = FILTER_MAT_OBJD(ma);
-
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -665,12 +667,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
Lamp *la = (Lamp *)data;
AnimData *adt = la->adt;
-
+
ale->flag = FILTER_LAM_OBJD(la);
-
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -678,12 +680,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
Camera *ca = (Camera *)data;
AnimData *adt = ca->adt;
-
+
ale->flag = FILTER_CAM_OBJD(ca);
-
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -704,12 +706,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
Curve *cu = (Curve *)data;
AnimData *adt = cu->adt;
-
+
ale->flag = FILTER_CUR_OBJD(cu);
-
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -717,12 +719,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
bArmature *arm = (bArmature *)data;
AnimData *adt = arm->adt;
-
+
ale->flag = FILTER_ARM_OBJD(arm);
-
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -730,12 +732,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
Mesh *me = (Mesh *)data;
AnimData *adt = me->adt;
-
+
ale->flag = FILTER_MESH_OBJD(me);
-
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -743,12 +745,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
Lattice *lt = (Lattice *)data;
AnimData *adt = lt->adt;
-
+
ale->flag = FILTER_LATTICE_OBJD(lt);
-
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -756,12 +758,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
Speaker *spk = (Speaker *)data;
AnimData *adt = spk->adt;
-
+
ale->flag = FILTER_SPK_OBJD(spk);
-
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -769,12 +771,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
Key *key = (Key *)data;
AnimData *adt = key->adt;
-
+
ale->flag = FILTER_SKE_OBJD(key);
-
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -782,12 +784,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
World *wo = (World *)data;
AnimData *adt = wo->adt;
-
+
ale->flag = FILTER_WOR_SCED(wo);
-
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -795,12 +797,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
bNodeTree *ntree = (bNodeTree *)data;
AnimData *adt = ntree->adt;
-
+
ale->flag = FILTER_NTREE_DATA(ntree);
-
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -808,12 +810,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
FreestyleLineStyle *linestyle = (FreestyleLineStyle *)data;
AnimData *adt = linestyle->adt;
-
- ale->flag = FILTER_LS_SCED(linestyle);
-
+
+ ale->flag = FILTER_LS_SCED(linestyle);
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -821,12 +823,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
ParticleSettings *part = (ParticleSettings *)ale->data;
AnimData *adt = part->adt;
-
+
ale->flag = FILTER_PART_OBJD(part);
-
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -834,12 +836,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
Tex *tex = (Tex *)data;
AnimData *adt = tex->adt;
-
+
ale->flag = FILTER_TEX_DATA(tex);
-
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -847,14 +849,14 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
bGPdata *gpd = (bGPdata *)data;
AnimData *adt = gpd->adt;
-
+
/* NOTE: we just reuse the same expand filter for this case */
ale->flag = EXPANDED_GPD(gpd);
-
+
// XXX: currently, this is only used for access to its animation data
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
break;
}
@@ -874,9 +876,9 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
case ANIMTYPE_NLACONTROLS:
{
AnimData *adt = (AnimData *)data;
-
+
ale->flag = adt->flag;
-
+
ale->key_data = NULL;
ale->datatype = ALE_NONE;
break;
@@ -884,9 +886,9 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
case ANIMTYPE_GROUP:
{
bActionGroup *agrp = (bActionGroup *)data;
-
+
ale->flag = agrp->flag;
-
+
ale->key_data = NULL;
ale->datatype = ALE_GROUP;
break;
@@ -895,9 +897,9 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
case ANIMTYPE_NLACURVE: /* practically the same as ANIMTYPE_FCURVE. Differences are applied post-creation */
{
FCurve *fcu = (FCurve *)data;
-
+
ale->flag = fcu->flag;
-
+
ale->key_data = fcu;
ale->datatype = ALE_FCURVE;
break;
@@ -906,19 +908,19 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
KeyBlock *kb = (KeyBlock *)data;
Key *key = (Key *)ale->id;
-
+
ale->flag = kb->flag;
-
+
/* whether we have keyframes depends on whether there is a Key block to find it from */
if (key) {
/* index of shapekey is defined by place in key's list */
ale->index = BLI_findindex(&key->block, kb);
-
+
/* the corresponding keyframes are from the animdata */
if (ale->adt && ale->adt->action) {
bAction *act = ale->adt->action;
char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb);
-
+
/* try to find the F-Curve which corresponds to this exactly,
* then free the MEM_alloc'd string
*/
@@ -934,9 +936,9 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
case ANIMTYPE_GPLAYER:
{
bGPDlayer *gpl = (bGPDlayer *)data;
-
+
ale->flag = gpl->flag;
-
+
ale->key_data = NULL;
ale->datatype = ALE_GPFRAME;
break;
@@ -944,9 +946,9 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
case ANIMTYPE_MASKLAYER:
{
MaskLayer *masklay = (MaskLayer *)data;
-
+
ale->flag = masklay->flag;
-
+
ale->key_data = NULL;
ale->datatype = ALE_MASKLAY;
break;
@@ -954,9 +956,9 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
case ANIMTYPE_NLATRACK:
{
NlaTrack *nlt = (NlaTrack *)data;
-
+
ale->flag = nlt->flag;
-
+
ale->key_data = &nlt->strips;
ale->datatype = ALE_NLASTRIP;
break;
@@ -970,15 +972,15 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
}
}
}
-
+
/* return created datatype */
return ale;
}
-
+
/* ----------------------------------------- */
/* 'Only Selected' selected data and/or 'Include Hidden' filtering
- * NOTE: when this function returns true, the F-Curve is to be skipped
+ * NOTE: when this function returns true, the F-Curve is to be skipped
*/
static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id, int filter_mode)
{
@@ -987,26 +989,26 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
}
/* hidden items should be skipped if we only care about visible data, but we aren't interested in hidden stuff */
const bool skip_hidden = (filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN);
-
+
if (GS(owner_id->name) == ID_OB) {
Object *ob = (Object *)owner_id;
-
+
/* only consider if F-Curve involves pose.bones */
if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones")) {
bPoseChannel *pchan;
char *bone_name;
-
+
/* get bone-name, and check if this bone is selected */
bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
if (bone_name) MEM_freeN(bone_name);
-
+
/* check whether to continue or skip */
if ((pchan) && (pchan->bone)) {
/* if only visible channels, skip if bone not visible unless user wants channels from hidden data too */
if (skip_hidden) {
bArmature *arm = (bArmature *)ob->data;
-
+
/* skipping - not visible on currently visible layers */
if ((arm->layer & pchan->bone->layer) == 0)
return true;
@@ -1014,7 +1016,7 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
if (pchan->bone->flag & BONE_HIDDEN_P)
return true;
}
-
+
/* can only add this F-Curve if it is selected */
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
if ((pchan->bone->flag & BONE_SELECTED) == 0)
@@ -1025,20 +1027,20 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
}
else if (GS(owner_id->name) == ID_SCE) {
Scene *scene = (Scene *)owner_id;
-
+
/* only consider if F-Curve involves sequence_editor.sequences */
if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) {
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq = NULL;
char *seq_name;
-
+
if (ed) {
/* get strip name, and check if this strip is selected */
seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false);
if (seq_name) MEM_freeN(seq_name);
}
-
+
/* can only add this F-Curve if it is selected */
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
if ((seq == NULL) || (seq->flag & SELECT) == 0)
@@ -1048,17 +1050,17 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
}
else if (GS(owner_id->name) == ID_NT) {
bNodeTree *ntree = (bNodeTree *)owner_id;
-
+
/* check for selected nodes */
if ((fcu->rna_path) && strstr(fcu->rna_path, "nodes")) {
bNode *node;
char *node_name;
-
+
/* get strip name, and check if this strip is selected */
node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
node = nodeFindNodebyName(ntree, node_name);
if (node_name) MEM_freeN(node_name);
-
+
/* can only add this F-Curve if it is selected */
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
if ((node) && (node->flag & NODE_SELECT) == 0)
@@ -1066,7 +1068,7 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
}
}
}
-
+
return false;
}
@@ -1077,11 +1079,11 @@ static bool name_matches_dopesheet_filter(bDopeSheet *ads, char *name)
/* full fuzzy, multi-word, case insensitive matches */
const size_t str_len = strlen(ads->searchstr);
const int words_max = (str_len / 2) + 1;
-
+
int (*words)[2] = BLI_array_alloca(words, words_max);
const int words_len = BLI_string_find_split_words(ads->searchstr, str_len, ' ', words, words_max);
bool found = false;
-
+
/* match name against all search words */
for (int index = 0; index < words_len; index++) {
if (BLI_strncasestr(name, ads->searchstr + words[index][0], words[index][1])) {
@@ -1089,7 +1091,7 @@ static bool name_matches_dopesheet_filter(bDopeSheet *ads, char *name)
break;
}
}
-
+
/* if we have a match somewhere, this returns true */
return found;
}
@@ -1100,33 +1102,33 @@ static bool name_matches_dopesheet_filter(bDopeSheet *ads, char *name)
}
/* (Display-)Name-based F-Curve filtering
- * NOTE: when this function returns true, the F-Curve is to be skipped
+ * NOTE: when this function returns true, the F-Curve is to be skipped
*/
static bool skip_fcurve_with_name(bDopeSheet *ads, FCurve *fcu, eAnim_ChannelType channel_type, void *owner, ID *owner_id)
{
bAnimListElem ale_dummy = {NULL};
const bAnimChannelType *acf;
-
+
/* create a dummy wrapper for the F-Curve, so we can get typeinfo for it */
ale_dummy.type = channel_type;
ale_dummy.owner = owner;
ale_dummy.id = owner_id;
ale_dummy.data = fcu;
-
+
/* get type info for channel */
acf = ANIM_channel_get_typeinfo(&ale_dummy);
if (acf && acf->name) {
char name[256]; /* hopefully this will be enough! */
-
+
/* get name */
acf->name(&ale_dummy, name);
-
- /* check for partial match with the match string, assuming case insensitive filtering
+
+ /* check for partial match with the match string, assuming case insensitive filtering
* if match, this channel shouldn't be ignored!
*/
return !name_matches_dopesheet_filter(ads, name);
}
-
+
/* just let this go... */
return true;
}
@@ -1142,19 +1144,19 @@ static bool fcurve_has_errors(FCurve *fcu)
if (fcu->flag & FCURVE_DISABLED) {
return true;
}
-
+
/* driver? */
if (fcu->driver) {
ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
-
+
/* error flag on driver usually means that there is an error
* BUT this may not hold with PyDrivers as this flag gets cleared
* if no critical errors prevent the driver from working...
*/
if (driver->flag & DRIVER_FLAG_INVALID)
return true;
-
+
/* check variables for other things that need linting... */
// TODO: maybe it would be more efficient just to have a quick flag for this?
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
@@ -1166,7 +1168,7 @@ static bool fcurve_has_errors(FCurve *fcu)
DRIVER_TARGETS_LOOPER_END
}
}
-
+
/* no errors found */
return false;
}
@@ -1176,8 +1178,8 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, eAnim_Chan
{
bActionGroup *grp = (channel_type == ANIMTYPE_FCURVE) ? owner : NULL;
FCurve *fcu = NULL;
-
- /* loop over F-Curves - assume that the caller of this has already checked that these should be included
+
+ /* loop over F-Curves - assume that the caller of this has already checked that these should be included
* NOTE: we need to check if the F-Curves belong to the same group, as this gets called for groups too...
*/
for (fcu = first; ((fcu) && (fcu->grp == grp)); fcu = fcu->next) {
@@ -1197,7 +1199,7 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, eAnim_Chan
}
}
}
-
+
/* only include if visible (Graph Editor check, not channels check) */
if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || (fcu->flag & FCURVE_VISIBLE)) {
/* only work with this channel and its subchannels if it is editable */
@@ -1211,14 +1213,14 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, eAnim_Chan
if (skip_fcurve_with_name(ads, fcu, channel_type, owner, owner_id))
continue;
}
-
+
/* error-based filtering... */
if ((ads) && (ads->filterflag & ADS_FILTER_ONLY_ERRORS)) {
/* skip if no errors... */
if (fcurve_has_errors(fcu) == false)
continue;
}
-
+
/* this F-Curve can be used, so return it */
return fcu;
}
@@ -1226,7 +1228,7 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, eAnim_Chan
}
}
}
-
+
/* no (more) F-Curves from the list are suitable... */
return NULL;
}
@@ -1238,14 +1240,14 @@ static size_t animfilter_fcurves(ListBase *anim_data, bDopeSheet *ads,
{
FCurve *fcu;
size_t items = 0;
-
- /* loop over every F-Curve able to be included
- * - this for-loop works like this:
+
+ /* loop over every F-Curve able to be included
+ * - this for-loop works like this:
* 1) the starting F-Curve is assigned to the fcu pointer so that we have a starting point to search from
- * 2) the first valid F-Curve to start from (which may include the one given as 'first') in the remaining
+ * 2) the first valid F-Curve to start from (which may include the one given as 'first') in the remaining
* list of F-Curves is found, and verified to be non-null
* 3) the F-Curve referenced by fcu pointer is added to the list
- * 4) the fcu pointer is set to the F-Curve after the one we just added, so that we can keep going through
+ * 4) the fcu pointer is set to the F-Curve after the one we just added, so that we can keep going through
* the rest of the F-Curve list without an eternal loop. Back to step 2 :)
*/
for (fcu = first; ( (fcu = animfilter_fcurve_next(ads, fcu, fcurve_type, filter_mode, owner, owner_id)) ); fcu = fcu->next) {
@@ -1261,7 +1263,7 @@ static size_t animfilter_fcurves(ListBase *anim_data, bDopeSheet *ads,
ANIMCHANNEL_NEW_CHANNEL(fcu, ANIMTYPE_FCURVE, owner_id);
}
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -1272,8 +1274,8 @@ static size_t animfilter_act_group(bAnimContext *ac, ListBase *anim_data, bDopeS
size_t tmp_items = 0;
size_t items = 0;
//int ofilter = filter_mode;
-
- /* if we care about the selection status of the channels,
+
+ /* if we care about the selection status of the channels,
* but the group isn't expanded (1)...
* (1) this only matters if we actually care about the hierarchy though.
* - Hierarchy matters: this hack should be applied
@@ -1285,7 +1287,7 @@ static size_t animfilter_act_group(bAnimContext *ac, ListBase *anim_data, bDopeS
/* if the group itself isn't selected appropriately, we shouldn't consider it's children either */
if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) == 0)
return 0;
-
+
/* if we're still here, then the selection status of the curves within this group should not matter,
* since this creates too much overhead for animators (i.e. making a slow workflow)
*
@@ -1296,14 +1298,14 @@ static size_t animfilter_act_group(bAnimContext *ac, ListBase *anim_data, bDopeS
*/
filter_mode &= ~(ANIMFILTER_SEL | ANIMFILTER_UNSEL | ANIMFILTER_LIST_VISIBLE);
}
-
+
/* add grouped F-Curves */
BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_AGRP(ac, agrp))
{
/* special filter so that we can get just the F-Curves within the active group */
if (!(filter_mode & ANIMFILTER_ACTGROUPED) || (agrp->flag & AGRP_ACTIVE)) {
/* for the Graph Editor, curves may be set to not be visible in the view to lessen clutter,
- * but to do this, we need to check that the group doesn't have it's not-visible flag set preventing
+ * but to do this, we need to check that the group doesn't have it's not-visible flag set preventing
* all its sub-curves to be shown
*/
if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || !(agrp->flag & AGRP_NOTVISIBLE)) {
@@ -1311,7 +1313,7 @@ static size_t animfilter_act_group(bAnimContext *ac, ListBase *anim_data, bDopeS
if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_AGRP(agrp)) {
/* get first F-Curve which can be used here */
FCurve *first_fcu = animfilter_fcurve_next(ads, agrp->channels.first, ANIMTYPE_FCURVE, filter_mode, agrp, owner_id);
-
+
/* filter list, starting from this F-Curve */
tmp_items += animfilter_fcurves(&tmp_data, ads, first_fcu, ANIMTYPE_FCURVE, filter_mode, agrp, owner_id);
}
@@ -1319,26 +1321,26 @@ static size_t animfilter_act_group(bAnimContext *ac, ListBase *anim_data, bDopeS
}
}
END_ANIMFILTER_SUBCHANNELS;
-
+
/* did we find anything? */
if (tmp_items) {
/* add this group as a channel first */
if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
/* restore original filter mode so that this next step works ok... */
//filter_mode = ofilter;
-
+
/* filter selection of channel specially here again, since may be open and not subject to previous test */
if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) ) {
ANIMCHANNEL_NEW_CHANNEL(agrp, ANIMTYPE_GROUP, owner_id);
}
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -1348,30 +1350,30 @@ static size_t animfilter_action(bAnimContext *ac, ListBase *anim_data, bDopeShee
bActionGroup *agrp;
FCurve *lastchan = NULL;
size_t items = 0;
-
+
/* don't include anything from this action if it is linked in from another file,
* and we're getting stuff for editing...
*/
if ((filter_mode & ANIMFILTER_FOREDIT) && ID_IS_LINKED(act))
return 0;
-
+
/* do groups */
// TODO: do nested groups?
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
/* store reference to last channel of group */
- if (agrp->channels.last)
+ if (agrp->channels.last)
lastchan = agrp->channels.last;
-
+
/* action group's channels */
items += animfilter_act_group(ac, anim_data, ads, act, agrp, filter_mode, owner_id);
}
-
+
/* un-grouped F-Curves (only if we're not only considering those channels in the active group) */
if (!(filter_mode & ANIMFILTER_ACTGROUPED)) {
FCurve *firstfcu = (lastchan) ? (lastchan->next) : (act->curves.first);
items += animfilter_fcurves(anim_data, ads, firstfcu, ANIMTYPE_FCURVE, filter_mode, NULL, owner_id);
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -1379,7 +1381,7 @@ static size_t animfilter_action(bAnimContext *ac, ListBase *anim_data, bDopeShee
/* Include NLA-Data for NLA-Editor:
* - when ANIMFILTER_LIST_CHANNELS is used, that means we should be filtering the list for display
* Although the evaluation order is from the first track to the last and then apply the Action on top,
- * we present this in the UI as the Active Action followed by the last track to the first so that we
+ * we present this in the UI as the Active Action followed by the last track to the first so that we
* get the evaluation order presented as per a stack.
* - for normal filtering (i.e. for editing), we only need the NLA-tracks but they can be in 'normal' evaluation
* order, i.e. first to last. Otherwise, some tools may get screwed up.
@@ -1389,10 +1391,10 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop
NlaTrack *nlt;
NlaTrack *first = NULL, *next = NULL;
size_t items = 0;
-
+
/* if showing channels, include active action */
if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
- /* if NLA action-line filtering is off, don't show unless there are keyframes,
+ /* if NLA action-line filtering is off, don't show unless there are keyframes,
* in order to keep things more compact for doing transforms
*/
if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) || (adt->action)) {
@@ -1402,13 +1404,13 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop
* - as AnimData may not have an action, we pass a dummy pointer just to get the list elem created, then
* overwrite this with the real value - REVIEW THIS...
*/
- ANIMCHANNEL_NEW_CHANNEL_FULL((void *)(&adt->action), ANIMTYPE_NLAACTION, owner_id,
+ ANIMCHANNEL_NEW_CHANNEL_FULL((void *)(&adt->action), ANIMTYPE_NLAACTION, owner_id,
{
- ale->data = adt->action ? adt->action : NULL;
+ ale->data = adt->action ? adt->action : NULL;
});
}
}
-
+
/* first track to include will be the last one if we're filtering by channels */
first = adt->nla_tracks.last;
}
@@ -1416,22 +1418,22 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop
/* first track to include will the first one (as per normal) */
first = adt->nla_tracks.first;
}
-
+
/* loop over NLA Tracks - assume that the caller of this has already checked that these should be included */
for (nlt = first; nlt; nlt = next) {
/* 'next' NLA-Track to use depends on whether we're filtering for drawing or not */
- if (filter_mode & ANIMFILTER_LIST_CHANNELS)
+ if (filter_mode & ANIMFILTER_LIST_CHANNELS)
next = nlt->prev;
else
next = nlt->next;
-
- /* if we're in NLA-tweakmode, don't show this track if it was disabled (due to tweaking) for now
+
+ /* if we're in NLA-tweakmode, don't show this track if it was disabled (due to tweaking) for now
* - active track should still get shown though (even though it has disabled flag set)
*/
// FIXME: the channels after should still get drawn, just 'differently', and after an active-action channel
if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED) && (adt->act_track != nlt))
continue;
-
+
/* only work with this channel and its subchannels if it is editable */
if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_NLT(nlt)) {
/* only include this track if selected in a way consistent with the filtering requirements */
@@ -1441,10 +1443,10 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop
/* name based filtering... */
if (((ads) && (ads->filterflag & ADS_FILTER_BY_FCU_NAME)) && (owner_id)) {
bool track_ok = false, strip_ok = false;
-
+
/* check if the name of the track, or the strips it has are ok... */
track_ok = name_matches_dopesheet_filter(ads, nlt->name);
-
+
if (track_ok == false) {
NlaStrip *strip;
for (strip = nlt->strips.first; strip; strip = strip->next) {
@@ -1454,20 +1456,20 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop
}
}
}
-
+
/* skip if both fail this test... */
if (!track_ok && !strip_ok) {
continue;
}
}
-
+
/* add the track now that it has passed all our tests */
ANIMCHANNEL_NEW_CHANNEL(nlt, ANIMTYPE_NLATRACK, owner_id);
}
}
}
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -1480,14 +1482,14 @@ static size_t animfilter_nla_controls(ListBase *anim_data, bDopeSheet *ads, Anim
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
size_t items = 0;
-
+
/* add control curves from each NLA strip... */
/* NOTE: ANIMTYPE_FCURVES are created here, to avoid duplicating the code needed */
BEGIN_ANIMFILTER_SUBCHANNELS(((adt->flag & ADT_NLA_SKEYS_COLLAPSED) == 0))
{
NlaTrack *nlt;
NlaStrip *strip;
-
+
/* for now, we only go one level deep - so controls on grouped FCurves are not handled */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (strip = nlt->strips.first; strip; strip = strip->next) {
@@ -1497,7 +1499,7 @@ static size_t animfilter_nla_controls(ListBase *anim_data, bDopeSheet *ads, Anim
}
}
END_ANIMFILTER_SUBCHANNELS;
-
+
/* did we find anything? */
if (tmp_items) {
/* add the expander as a channel first */
@@ -1507,13 +1509,13 @@ static size_t animfilter_nla_controls(ListBase *anim_data, bDopeSheet *ads, Anim
ANIMCHANNEL_NEW_CHANNEL(adt, ANIMTYPE_NLACONTROLS, owner_id);
}
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
-
+
/* return the numebr of items added to the list */
return items;
}
@@ -1523,11 +1525,11 @@ static size_t animfilter_block_data(bAnimContext *ac, ListBase *anim_data, bDope
{
AnimData *adt = BKE_animdata_from_id(id);
size_t items = 0;
-
+
/* image object datablocks have no anim-data so check for NULL */
if (adt) {
IdAdtTemplate *iat = (IdAdtTemplate *)id;
-
+
/* NOTE: this macro is used instead of inlining the logic here, since this sort of filtering is still needed
* in a few places in the rest of the code still - notably for the few cases where special mode-based
* different types of data expanders are required.
@@ -1553,7 +1555,7 @@ static size_t animfilter_block_data(bAnimContext *ac, ListBase *anim_data, bDope
}
);
}
-
+
return items;
}
@@ -1563,22 +1565,22 @@ static size_t animfilter_block_data(bAnimContext *ac, ListBase *anim_data, bDope
static size_t animdata_filter_shapekey(bAnimContext *ac, ListBase *anim_data, Key *key, int filter_mode)
{
size_t items = 0;
-
+
/* check if channels or only F-Curves */
if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
KeyBlock *kb;
-
+
/* loop through the channels adding ShapeKeys as appropriate */
for (kb = key->block.first; kb; kb = kb->next) {
/* skip the first one, since that's the non-animatable basis */
if (kb == key->block.first) continue;
-
+
/* only work with this channel and its subchannels if it is editable */
if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_SHAPEKEY(kb)) {
/* only include this track if selected in a way consistent with the filtering requirements */
if (ANIMCHANNEL_SELOK(SEL_SHAPEKEY(kb)) ) {
// TODO: consider 'active' too?
-
+
/* owner-id here must be key so that the F-Curve can be resolved... */
ANIMCHANNEL_NEW_CHANNEL(kb, ANIMTYPE_SHAPEKEY, key);
}
@@ -1599,7 +1601,7 @@ static size_t animdata_filter_shapekey(bAnimContext *ac, ListBase *anim_data, Ke
}
}
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -1609,7 +1611,7 @@ static size_t animdata_filter_gpencil_layers_data(ListBase *anim_data, bDopeShee
{
bGPDlayer *gpl;
size_t items = 0;
-
+
/* loop over layers as the conditions are acceptable */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* only if selected */
@@ -1623,15 +1625,15 @@ static size_t animdata_filter_gpencil_layers_data(ListBase *anim_data, bDopeShee
if (name_matches_dopesheet_filter(ads, gpl->info) == false)
continue;
}
-
-
+
+
/* add to list */
ANIMCHANNEL_NEW_CHANNEL(gpl, ANIMTYPE_GPLAYER, gpd);
}
}
}
}
-
+
return items;
}
@@ -1639,7 +1641,7 @@ static size_t animdata_filter_gpencil_layers_data(ListBase *anim_data, bDopeShee
static size_t animdata_filter_gpencil_data(ListBase *anim_data, bDopeSheet *ads, bGPdata *gpd, int filter_mode)
{
size_t items = 0;
-
+
/* When asked from "AnimData" blocks (i.e. the top-level containers for normal animation),
* for convenience, this will return GP Datablocks instead. This may cause issues down
* the track, but for now, this will do...
@@ -1651,14 +1653,14 @@ static size_t animdata_filter_gpencil_data(ListBase *anim_data, bDopeSheet *ads,
else {
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
-
+
/* add gpencil animation channels */
BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_GPD(gpd))
{
tmp_items += animdata_filter_gpencil_layers_data(&tmp_data, ads, gpd, filter_mode);
}
END_ANIMFILTER_SUBCHANNELS;
-
+
/* did we find anything? */
if (tmp_items) {
/* include data-expand widget first */
@@ -1666,14 +1668,14 @@ static size_t animdata_filter_gpencil_data(ListBase *anim_data, bDopeSheet *ads,
/* add gpd as channel too (if for drawing, and it has layers) */
ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_GPDATABLOCK, NULL);
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
}
-
+
return items;
}
@@ -1683,7 +1685,7 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, ListBase *anim_data, voi
{
bDopeSheet *ads = ac->ads;
size_t items = 0;
-
+
if (ads->filterflag & ADS_FILTER_GP_3DONLY) {
Scene *scene = (Scene *)ads->source;
ViewLayer *view_layer = (ViewLayer *)ac->view_layer;
@@ -1693,37 +1695,37 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, ListBase *anim_data, voi
if (scene->gpd) {
items += animdata_filter_gpencil_data(anim_data, ads, scene->gpd, filter_mode);
}
-
+
/* Objects in the scene */
for (base = view_layer->object_bases.first; base; base = base->next) {
/* Only consider this object if it has got some GP data (saving on all the other tests) */
if (base->object && base->object->gpd) {
Object *ob = base->object;
-
+
/* firstly, check if object can be included, by the following factors:
* - if only visible, must check for layer and also viewport visibility
* --> while tools may demand only visible, user setting takes priority
* as user option controls whether sets of channels get included while
* tool-flag takes into account collapsed/open channels too
- * - if only selected, must check if object is selected
- * - there must be animation data to edit (this is done recursively as we
+ * - if only selected, must check if object is selected
+ * - there must be animation data to edit (this is done recursively as we
* try to add the channels)
*/
if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) {
/* layer visibility - we check both object and base, since these may not be in sync yet */
if ((base->flag & BASE_VISIBLED) == 0) continue;
-
+
/* outliner restrict-flag */
if (ob->restrictflag & OB_RESTRICT_VIEW) continue;
}
-
+
/* check selection and object type filters */
if ( (ads->filterflag & ADS_FILTER_ONLYSEL) && !((base->flag & BASE_SELECTED) /*|| (base == scene->basact)*/) ) {
/* only selected should be shown */
continue;
}
-
- /* check if object belongs to the filtering group if option to filter
+
+ /* check if object belongs to the filtering group if option to filter
* objects by the grouped status is on
* - used to ease the process of doing multiple-character choreographies
*/
@@ -1731,7 +1733,7 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, ListBase *anim_data, voi
if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0)
continue;
}
-
+
/* finally, include this object's grease pencil datablock */
/* XXX: Should we store these under expanders per item? */
items += animdata_filter_gpencil_data(anim_data, ads, ob->gpd, filter_mode);
@@ -1740,18 +1742,18 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, ListBase *anim_data, voi
}
else {
bGPdata *gpd;
-
+
/* Grab all Grease Pencil datablocks directly from main, but only those that seem to be useful somewhere */
- for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) {
+ for (gpd = ac->bmain->gpencil.first; gpd; gpd = gpd->id.next) {
/* only show if gpd is used by something... */
if (ID_REAL_USERS(gpd) < 1)
continue;
-
+
/* add GP frames from this datablock */
items += animdata_filter_gpencil_data(anim_data, ads, gpd, filter_mode);
}
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -1762,19 +1764,19 @@ static size_t animdata_filter_ds_gpencil(bAnimContext *ac, ListBase *anim_data,
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
size_t items = 0;
-
+
/* add relevant animation channels for Grease Pencil */
BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_GPD(gpd))
{
/* add animation channels */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, &gpd->id, filter_mode);
-
+
/* add Grease Pencil layers */
// TODO: do these need a separate expander?
// XXX: what order should these go in?
}
END_ANIMFILTER_SUBCHANNELS;
-
+
/* did we find anything? */
if (tmp_items) {
/* include data-expand widget first */
@@ -1785,13 +1787,13 @@ static size_t animdata_filter_ds_gpencil(bAnimContext *ac, ListBase *anim_data,
ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_DSGPENCIL, gpd);
}
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -1858,28 +1860,28 @@ static size_t animdata_filter_mask_data(ListBase *anim_data, Mask *mask, const i
}
/* Grab all mask data */
-static size_t animdata_filter_mask(ListBase *anim_data, void *UNUSED(data), int filter_mode)
+static size_t animdata_filter_mask(Main *bmain, ListBase *anim_data, void *UNUSED(data), int filter_mode)
{
Mask *mask;
size_t items = 0;
-
+
/* for now, grab mask datablocks directly from main */
// XXX: this is not good...
- for (mask = G.main->mask.first; mask; mask = mask->id.next) {
+ for (mask = bmain->mask.first; mask; mask = mask->id.next) {
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
-
+
/* only show if mask is used by something... */
if (ID_REAL_USERS(mask) < 1)
continue;
-
+
/* add mask animation channels */
BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_MASK(mask))
{
tmp_items += animdata_filter_mask_data(&tmp_data, mask, filter_mode);
}
END_ANIMFILTER_SUBCHANNELS;
-
+
/* did we find anything? */
if (tmp_items) {
/* include data-expand widget first */
@@ -1887,14 +1889,14 @@ static size_t animdata_filter_mask(ListBase *anim_data, void *UNUSED(data), int
/* add gpd as channel too (if for drawing, and it has layers) */
ANIMCHANNEL_NEW_CHANNEL(mask, ANIMTYPE_MASKDATABLOCK, NULL);
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -1905,7 +1907,7 @@ static size_t animdata_filter_ds_nodetree_group(bAnimContext *ac, ListBase *anim
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
size_t items = 0;
-
+
/* add nodetree animation channels */
BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_NTREE_DATA(ntree))
{
@@ -1913,7 +1915,7 @@ static size_t animdata_filter_ds_nodetree_group(bAnimContext *ac, ListBase *anim
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ntree, filter_mode);
}
END_ANIMFILTER_SUBCHANNELS;
-
+
/* did we find anything? */
if (tmp_items) {
/* include data-expand widget first */
@@ -1923,13 +1925,13 @@ static size_t animdata_filter_ds_nodetree_group(bAnimContext *ac, ListBase *anim
ANIMCHANNEL_NEW_CHANNEL(ntree, ANIMTYPE_DSNTREE, owner_id);
}
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -1938,9 +1940,9 @@ static size_t animdata_filter_ds_nodetree(bAnimContext *ac, ListBase *anim_data,
{
bNode *node;
size_t items = 0;
-
+
items += animdata_filter_ds_nodetree_group(ac, anim_data, ads, owner_id, ntree, filter_mode);
-
+
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP) {
if (node->id) {
@@ -1961,7 +1963,7 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data
ViewLayer *view_layer;
FreestyleLineSet *lineset;
size_t items = 0;
-
+
for (view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
for (lineset = view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) {
if (lineset->linestyle) {
@@ -1969,7 +1971,7 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data
}
}
}
-
+
for (view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
/* skip render layers without Freestyle enabled */
if ((view_layer->flag & VIEW_LAYER_FREESTYLE) == 0) {
@@ -1988,7 +1990,7 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data
continue;
}
linestyle->id.tag &= ~LIB_TAG_DOIT;
-
+
/* add scene-level animation channels */
BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_LS_SCED(linestyle))
{
@@ -1996,7 +1998,7 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)linestyle, filter_mode);
}
END_ANIMFILTER_SUBCHANNELS;
-
+
/* did we find anything? */
if (tmp_items) {
/* include anim-expand widget first */
@@ -2006,7 +2008,7 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data
ANIMCHANNEL_NEW_CHANNEL(linestyle, ANIMTYPE_DSLINESTYLE, sce);
}
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
@@ -2014,24 +2016,24 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data
}
}
}
-
+
/* return the number of items added to the list */
return items;
}
-static size_t animdata_filter_ds_texture(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads,
+static size_t animdata_filter_ds_texture(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads,
Tex *tex, ID *owner_id, int filter_mode)
{
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
size_t items = 0;
-
+
/* add texture's animation data to temp collection */
- BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_TEX_DATA(tex))
+ BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_TEX_DATA(tex))
{
/* texture animdata */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)tex, filter_mode);
-
+
/* nodes */
if ((tex->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
/* owner_id as id instead of texture, since it'll otherwise be impossible to track the depth */
@@ -2041,7 +2043,7 @@ static size_t animdata_filter_ds_texture(bAnimContext *ac, ListBase *anim_data,
}
}
END_ANIMFILTER_SUBCHANNELS;
-
+
/* did we find anything? */
if (tmp_items) {
/* include texture-expand widget? */
@@ -2051,13 +2053,13 @@ static size_t animdata_filter_ds_texture(bAnimContext *ac, ListBase *anim_data,
ANIMCHANNEL_NEW_CHANNEL(tex, ANIMTYPE_DSTEX, owner_id);
}
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -2070,11 +2072,11 @@ static size_t animdata_filter_ds_textures(bAnimContext *ac, ListBase *anim_data,
MTex **mtex = NULL;
size_t items = 0;
int a = 0;
-
+
/* get datatype specific data first */
if (owner_id == NULL)
return 0;
-
+
switch (GS(owner_id->name)) {
case ID_PA:
{
@@ -2082,7 +2084,7 @@ static size_t animdata_filter_ds_textures(bAnimContext *ac, ListBase *anim_data,
mtex = (MTex **)(&part->mtex);
break;
}
- default:
+ default:
{
/* invalid/unsupported option */
if (G.debug & G_DEBUG)
@@ -2090,19 +2092,19 @@ static size_t animdata_filter_ds_textures(bAnimContext *ac, ListBase *anim_data,
return 0;
}
}
-
+
/* firstly check that we actuallly have some textures, by gathering all textures in a temp list */
for (a = 0; a < MAX_MTEX; a++) {
Tex *tex = (mtex[a]) ? mtex[a]->tex : NULL;
-
+
/* for now, if no texture returned, skip (this shouldn't confuse the user I hope) */
- if (tex == NULL)
+ if (tex == NULL)
continue;
-
+
/* add texture's anim channels */
items += animdata_filter_ds_texture(ac, anim_data, ads, tex, owner_id, filter_mode);
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -2113,19 +2115,19 @@ static size_t animdata_filter_ds_material(bAnimContext *ac, ListBase *anim_data,
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
size_t items = 0;
-
+
/* add material's animation data to temp collection */
BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_MAT_OBJD(ma))
{
/* material's animation data */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ma, filter_mode);
-
+
/* nodes */
- if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE))
+ if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE))
tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)ma, ma->nodetree, filter_mode);
}
END_ANIMFILTER_SUBCHANNELS;
-
+
/* did we find anything? */
if (tmp_items) {
/* include material-expand widget first */
@@ -2135,13 +2137,13 @@ static size_t animdata_filter_ds_material(bAnimContext *ac, ListBase *anim_data,
ANIMCHANNEL_NEW_CHANNEL(ma, ANIMTYPE_DSMAT, ma);
}
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
-
+
return items;
}
@@ -2150,23 +2152,23 @@ static size_t animdata_filter_ds_materials(bAnimContext *ac, ListBase *anim_data
bool has_nested = false;
size_t items = 0;
int a = 0;
-
+
/* first pass: take the materials referenced via the Material slots of the object */
for (a = 1; a <= ob->totcol; a++) {
Material *ma = give_current_material(ob, a);
-
+
/* if material is valid, try to add relevant contents from here */
if (ma) {
/* add channels */
items += animdata_filter_ds_material(ac, anim_data, ads, ma, filter_mode);
-
+
/* for optimising second pass - check if there's a nested material here to come back for */
if (has_nested == false) {
has_nested = (give_node_material(ma) != NULL);
}
}
}
-
+
/* second pass: go through a second time looking for "nested" materials (material.material references)
*
* NOTE: here we ignore the expanded status of the parent, as it could be too confusing as to why these are
@@ -2176,7 +2178,7 @@ static size_t animdata_filter_ds_materials(bAnimContext *ac, ListBase *anim_data
for (a = 1; a <= ob->totcol; a++) {
Material *base = give_current_material(ob, a);
Material *ma = give_node_material(base);
-
+
/* add channels from the nested material if it exists
* - skip if the same material is referenced in its node tree
* (which is common for BI materials) as that results in
@@ -2187,7 +2189,7 @@ static size_t animdata_filter_ds_materials(bAnimContext *ac, ListBase *anim_data
}
}
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -2199,10 +2201,10 @@ static size_t animdata_filter_ds_materials(bAnimContext *ac, ListBase *anim_data
typedef struct tAnimFilterModifiersContext {
bAnimContext *ac; /* anim editor context */
bDopeSheet *ads; /* dopesheet filtering settings */
-
+
ListBase tmp_data; /* list of channels created (but not yet added to the main list) */
size_t items; /* number of channels created */
-
+
int filter_mode; /* flags for stuff we want to filter */
} tAnimFilterModifiersContext;
@@ -2213,31 +2215,31 @@ static void animfilter_modifier_idpoin_cb(void *afm_ptr, Object *ob, ID **idpoin
tAnimFilterModifiersContext *afm = (tAnimFilterModifiersContext *)afm_ptr;
ID *owner_id = &ob->id;
ID *id = *idpoin;
-
- /* NOTE: the walker only guarantees to give us all the ID-ptr *slots*,
+
+ /* NOTE: the walker only guarantees to give us all the ID-ptr *slots*,
* not just the ones which are actually used, so be careful!
*/
if (id == NULL)
return;
-
+
/* check if this is something we're interested in... */
switch (GS(id->name)) {
case ID_TE: /* Textures */
{
Tex *tex = (Tex *)id;
- if (!(afm->ads->filterflag & ADS_FILTER_NOTEX)) {
+ if (!(afm->ads->filterflag & ADS_FILTER_NOTEX)) {
afm->items += animdata_filter_ds_texture(afm->ac, &afm->tmp_data, afm->ads, tex, owner_id, afm->filter_mode);
}
break;
}
-
+
/* TODO: images? */
default:
break;
}
}
-/* animation linked to data used by modifiers
+/* animation linked to data used by modifiers
* NOTE: strictly speaking, modifier animation is already included under Object level
* but for some modifiers (e.g. Displace), there can be linked data that has settings
* which would be nice to animate (i.e. texture parameters) but which are not actually
@@ -2248,8 +2250,8 @@ static size_t animdata_filter_ds_modifiers(bAnimContext *ac, ListBase *anim_data
{
tAnimFilterModifiersContext afm = {NULL};
size_t items = 0;
-
- /* 1) create a temporary "context" containing all the info we have here to pass to the callback
+
+ /* 1) create a temporary "context" containing all the info we have here to pass to the callback
* use to walk through the dependencies of the modifiers
*
* ! Assumes that all other unspecified values (i.e. accumulation buffers) are zero'd out properly
@@ -2257,10 +2259,10 @@ static size_t animdata_filter_ds_modifiers(bAnimContext *ac, ListBase *anim_data
afm.ac = ac;
afm.ads = ads;
afm.filter_mode = filter_mode;
-
+
/* 2) walk over dependencies */
modifiers_foreachIDLink(ob, animfilter_modifier_idpoin_cb, &afm);
-
+
/* 3) extract data from the context, merging it back into the standard list */
if (afm.items) {
/* now add the list of collected channels */
@@ -2268,7 +2270,7 @@ static size_t animdata_filter_ds_modifiers(bAnimContext *ac, ListBase *anim_data
BLI_assert(BLI_listbase_is_empty(&afm.tmp_data));
items += afm.items;
}
-
+
return items;
}
@@ -2283,23 +2285,23 @@ static size_t animdata_filter_ds_particles(bAnimContext *ac, ListBase *anim_data
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
-
+
/* if no material returned, skip - so that we don't get weird blank entries... */
if (ELEM(NULL, psys->part, psys->part->adt))
continue;
-
+
/* add particle-system's animation data to temp collection */
BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_PART_OBJD(psys->part))
{
/* particle system's animation data */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)psys->part, filter_mode);
-
+
/* textures */
if (!(ads->filterflag & ADS_FILTER_NOTEX))
tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, (ID *)psys->part, filter_mode);
}
END_ANIMFILTER_SUBCHANNELS;
-
+
/* did we find anything? */
if (tmp_items) {
/* include particle-expand widget first */
@@ -2309,14 +2311,14 @@ static size_t animdata_filter_ds_particles(bAnimContext *ac, ListBase *anim_data
ANIMCHANNEL_NEW_CHANNEL(psys->part, ANIMTYPE_DSPART, psys->part);
}
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -2327,19 +2329,19 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
size_t items = 0;
-
+
IdAdtTemplate *iat = ob->data;
short type = 0, expanded = 0;
-
+
/* get settings based on data type */
switch (ob->type) {
case OB_CAMERA: /* ------- Camera ------------ */
{
Camera *ca = (Camera *)ob->data;
-
+
if (ads->filterflag & ADS_FILTER_NOCAM)
return 0;
-
+
type = ANIMTYPE_DSCAM;
expanded = FILTER_CAM_OBJD(ca);
break;
@@ -2347,10 +2349,10 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b
case OB_LAMP: /* ---------- Lamp ----------- */
{
Lamp *la = (Lamp *)ob->data;
-
+
if (ads->filterflag & ADS_FILTER_NOLAM)
return 0;
-
+
type = ANIMTYPE_DSLAM;
expanded = FILTER_LAM_OBJD(la);
break;
@@ -2360,10 +2362,10 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b
case OB_FONT: /* ------- Text Curve ---------- */
{
Curve *cu = (Curve *)ob->data;
-
+
if (ads->filterflag & ADS_FILTER_NOCUR)
return 0;
-
+
type = ANIMTYPE_DSCUR;
expanded = FILTER_CUR_OBJD(cu);
break;
@@ -2371,10 +2373,10 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b
case OB_MBALL: /* ------- MetaBall ---------- */
{
MetaBall *mb = (MetaBall *)ob->data;
-
+
if (ads->filterflag & ADS_FILTER_NOMBA)
return 0;
-
+
type = ANIMTYPE_DSMBALL;
expanded = FILTER_MBALL_OBJD(mb);
break;
@@ -2382,10 +2384,10 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b
case OB_ARMATURE: /* ------- Armature ---------- */
{
bArmature *arm = (bArmature *)ob->data;
-
+
if (ads->filterflag & ADS_FILTER_NOARM)
return 0;
-
+
type = ANIMTYPE_DSARM;
expanded = FILTER_ARM_OBJD(arm);
break;
@@ -2393,10 +2395,10 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b
case OB_MESH: /* ------- Mesh ---------- */
{
Mesh *me = (Mesh *)ob->data;
-
+
if (ads->filterflag & ADS_FILTER_NOMESH)
return 0;
-
+
type = ANIMTYPE_DSMESH;
expanded = FILTER_MESH_OBJD(me);
break;
@@ -2404,10 +2406,10 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b
case OB_LATTICE: /* ---- Lattice ---- */
{
Lattice *lt = (Lattice *)ob->data;
-
+
if (ads->filterflag & ADS_FILTER_NOLAT)
return 0;
-
+
type = ANIMTYPE_DSLAT;
expanded = FILTER_LATTICE_OBJD(lt);
break;
@@ -2415,26 +2417,26 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b
case OB_SPEAKER: /* ---------- Speaker ----------- */
{
Speaker *spk = (Speaker *)ob->data;
-
+
type = ANIMTYPE_DSSPK;
expanded = FILTER_SPK_OBJD(spk);
break;
}
}
-
+
/* add object data animation channels */
BEGIN_ANIMFILTER_SUBCHANNELS(expanded)
{
/* animation data filtering */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)iat, filter_mode);
-
+
/* sub-data filtering... */
switch (ob->type) {
case OB_LAMP: /* lamp - textures + nodetree */
{
Lamp *la = ob->data;
bNodeTree *ntree = la->nodetree;
-
+
/* nodetree */
if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE))
tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, &la->id, ntree, filter_mode);
@@ -2443,7 +2445,7 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b
}
}
END_ANIMFILTER_SUBCHANNELS;
-
+
/* did we find anything? */
if (tmp_items) {
/* include data-expand widget first */
@@ -2453,13 +2455,13 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b
ANIMCHANNEL_NEW_CHANNEL(iat, type, iat);
}
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -2470,7 +2472,7 @@ static size_t animdata_filter_ds_keyanim(bAnimContext *ac, ListBase *anim_data,
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
size_t items = 0;
-
+
/* add shapekey-level animation channels */
BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_SKE_OBJD(key))
{
@@ -2478,7 +2480,7 @@ static size_t animdata_filter_ds_keyanim(bAnimContext *ac, ListBase *anim_data,
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)key, filter_mode);
}
END_ANIMFILTER_SUBCHANNELS;
-
+
/* did we find anything? */
if (tmp_items) {
/* include key-expand widget first */
@@ -2487,13 +2489,13 @@ static size_t animdata_filter_ds_keyanim(bAnimContext *ac, ListBase *anim_data,
ANIMCHANNEL_NEW_CHANNEL(key, ANIMTYPE_DSSKEY, ob);
}
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -2505,7 +2507,7 @@ static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBase *anim_data, b
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
size_t items = 0;
-
+
AnimData *adt = ob->adt;
short type = 0, expanded = 1;
void *cdata = NULL;
@@ -2526,7 +2528,7 @@ static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBase *anim_data, b
cdata = adt->action;
expanded = EXPANDED_ACTC(adt->action);
});
-
+
/* add object-level animation channels */
BEGIN_ANIMFILTER_SUBCHANNELS(expanded)
{
@@ -2534,7 +2536,7 @@ static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBase *anim_data, b
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ob, filter_mode);
}
END_ANIMFILTER_SUBCHANNELS;
-
+
/* did we find anything? */
if (tmp_items) {
/* include anim-expand widget first */
@@ -2544,13 +2546,13 @@ static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBase *anim_data, b
ANIMCHANNEL_NEW_CHANNEL(cdata, type, ob);
}
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -2562,50 +2564,50 @@ static size_t animdata_filter_dopesheet_ob(bAnimContext *ac, ListBase *anim_data
Object *ob = base->object;
size_t tmp_items = 0;
size_t items = 0;
-
+
/* filter data contained under object first */
BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_OBJC(ob))
{
Key *key = BKE_key_from_object(ob);
-
+
/* object-level animation */
if ((ob->adt) && !(ads->filterflag & ADS_FILTER_NOOBJ)) {
tmp_items += animdata_filter_ds_obanim(ac, &tmp_data, ads, ob, filter_mode);
}
-
+
/* shape-key */
if ((key && key->adt) && !(ads->filterflag & ADS_FILTER_NOSHAPEKEYS)) {
tmp_items += animdata_filter_ds_keyanim(ac, &tmp_data, ads, ob, key, filter_mode);
}
-
+
/* modifiers */
if ((ob->modifiers.first) && !(ads->filterflag & ADS_FILTER_NOMODIFIERS)) {
tmp_items += animdata_filter_ds_modifiers(ac, &tmp_data, ads, ob, filter_mode);
}
-
+
/* materials */
if ((ob->totcol) && !(ads->filterflag & ADS_FILTER_NOMAT)) {
tmp_items += animdata_filter_ds_materials(ac, &tmp_data, ads, ob, filter_mode);
}
-
+
/* object data */
if (ob->data) {
tmp_items += animdata_filter_ds_obdata(ac, &tmp_data, ads, ob, filter_mode);
}
-
+
/* particles */
if ((ob->particlesystem.first) && !(ads->filterflag & ADS_FILTER_NOPART)) {
tmp_items += animdata_filter_ds_particles(ac, &tmp_data, ads, ob, filter_mode);
}
-
+
/* grease pencil */
if ((ob->gpd) && !(ads->filterflag & ADS_FILTER_NOGPENCIL)) {
tmp_items += animdata_filter_ds_gpencil(ac, &tmp_data, ads, ob->gpd, filter_mode);
}
}
END_ANIMFILTER_SUBCHANNELS;
-
-
+
+
/* if we collected some channels, add these to the new list... */
if (tmp_items) {
/* firstly add object expander if required */
@@ -2619,13 +2621,13 @@ static size_t animdata_filter_dopesheet_ob(bAnimContext *ac, ListBase *anim_data
}
}
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
-
+
/* return the number of items added */
return items;
}
@@ -2635,19 +2637,19 @@ static size_t animdata_filter_ds_world(bAnimContext *ac, ListBase *anim_data, bD
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
size_t items = 0;
-
+
/* add world animation channels */
BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_WOR_SCED(wo))
{
/* animation data filtering */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)wo, filter_mode);
-
+
/* nodes */
- if ((wo->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE))
+ if ((wo->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE))
tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)wo, wo->nodetree, filter_mode);
}
END_ANIMFILTER_SUBCHANNELS;
-
+
/* did we find anything? */
if (tmp_items) {
/* include data-expand widget first */
@@ -2657,13 +2659,13 @@ static size_t animdata_filter_ds_world(bAnimContext *ac, ListBase *anim_data, bD
ANIMCHANNEL_NEW_CHANNEL(wo, ANIMTYPE_DSWOR, sce);
}
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -2673,11 +2675,11 @@ static size_t animdata_filter_ds_scene(bAnimContext *ac, ListBase *anim_data, bD
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
size_t items = 0;
-
+
AnimData *adt = sce->adt;
short type = 0, expanded = 1;
void *cdata = NULL;
-
+
/* determine the type of expander channels to use */
// this is the best way to do this for now...
ANIMDATA_FILTER_CASES(sce,
@@ -2694,7 +2696,7 @@ static size_t animdata_filter_ds_scene(bAnimContext *ac, ListBase *anim_data, bD
cdata = adt->action;
expanded = EXPANDED_ACTC(adt->action);
});
-
+
/* add scene-level animation channels */
BEGIN_ANIMFILTER_SUBCHANNELS(expanded)
{
@@ -2702,7 +2704,7 @@ static size_t animdata_filter_ds_scene(bAnimContext *ac, ListBase *anim_data, bD
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)sce, filter_mode);
}
END_ANIMFILTER_SUBCHANNELS;
-
+
/* did we find anything? */
if (tmp_items) {
/* include anim-expand widget first */
@@ -2712,13 +2714,13 @@ static size_t animdata_filter_ds_scene(bAnimContext *ac, ListBase *anim_data, bD
ANIMCHANNEL_NEW_CHANNEL(cdata, type, sce);
}
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
-
+
/* return the number of items added to the list */
return items;
}
@@ -2728,39 +2730,39 @@ static size_t animdata_filter_dopesheet_scene(bAnimContext *ac, ListBase *anim_d
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
size_t items = 0;
-
+
/* filter data contained under object first */
BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_SCEC(sce))
{
bNodeTree *ntree = sce->nodetree;
bGPdata *gpd = sce->gpd;
World *wo = sce->world;
-
+
/* Action, Drivers, or NLA for Scene */
if ((ads->filterflag & ADS_FILTER_NOSCE) == 0) {
tmp_items += animdata_filter_ds_scene(ac, &tmp_data, ads, sce, filter_mode);
}
-
+
/* world */
if ((wo) && !(ads->filterflag & ADS_FILTER_NOWOR)) {
tmp_items += animdata_filter_ds_world(ac, &tmp_data, ads, sce, wo, filter_mode);
}
-
+
/* nodetree */
if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)sce, ntree, filter_mode);
}
-
+
/* line styles */
if ((ads->filterflag & ADS_FILTER_NOLINESTYLE) == 0) {
tmp_items += animdata_filter_ds_linestyle(ac, &tmp_data, ads, sce, filter_mode);
}
-
+
/* grease pencil */
if ((gpd) && !(ads->filterflag & ADS_FILTER_NOGPENCIL)) {
tmp_items += animdata_filter_ds_gpencil(ac, &tmp_data, ads, gpd, filter_mode);
}
-
+
/* TODO: one day, when sequencer becomes its own datatype, perhaps it should be included here */
}
END_ANIMFILTER_SUBCHANNELS;
@@ -2775,13 +2777,13 @@ static size_t animdata_filter_dopesheet_scene(bAnimContext *ac, ListBase *anim_d
ANIMCHANNEL_NEW_CHANNEL(sce, ANIMTYPE_SCENE, sce);
}
}
-
+
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
-
+
/* return the number of items added */
return items;
}
@@ -2820,7 +2822,7 @@ static size_t animdata_filter_dopesheet_movieclips(bAnimContext *ac, ListBase *a
{
size_t items = 0;
MovieClip *clip;
- for (clip = G.main->movieclip.first; clip != NULL; clip = clip->id.next) {
+ for (clip = ac->bmain->movieclip.first; clip != NULL; clip = clip->id.next) {
/* only show if gpd is used by something... */
if (ID_REAL_USERS(clip) < 1) {
continue;
@@ -2835,31 +2837,31 @@ static size_t animdata_filter_dopesheet_movieclips(bAnimContext *ac, ListBase *a
static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_mode)
{
Object *ob = base->object;
-
+
if (base->object == NULL)
return false;
-
+
/* firstly, check if object can be included, by the following factors:
* - if only visible, must check for layer and also viewport visibility
* --> while tools may demand only visible, user setting takes priority
* as user option controls whether sets of channels get included while
* tool-flag takes into account collapsed/open channels too
- * - if only selected, must check if object is selected
- * - there must be animation data to edit (this is done recursively as we
+ * - if only selected, must check if object is selected
+ * - there must be animation data to edit (this is done recursively as we
* try to add the channels)
*/
if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) {
/* layer visibility - we check both object and base, since these may not be in sync yet */
if ((base->flag & BASE_VISIBLED) == 0)
return false;
-
+
/* outliner restrict-flag */
if (ob->restrictflag & OB_RESTRICT_VIEW)
return false;
}
-
- /* if only F-Curves with visible flags set can be shown, check that
- * datablock hasn't been set to invisible
+
+ /* if only F-Curves with visible flags set can be shown, check that
+ * datablock hasn't been set to invisible
*/
if (filter_mode & ANIMFILTER_CURVE_VISIBLE) {
if ((ob->adt) && (ob->adt->flag & ADT_CURVES_NOT_VISIBLE))
@@ -2889,8 +2891,8 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m
/* only selected should be shown */
return false;
}
-
- /* check if object belongs to the filtering group if option to filter
+
+ /* check if object belongs to the filtering group if option to filter
* objects by the grouped status is on
* - used to ease the process of doing multiple-character choreographies
*/
@@ -2898,7 +2900,7 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m
if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0)
return false;
}
-
+
/* no reason to exclude this object... */
return true;
}
@@ -2908,7 +2910,7 @@ static int ds_base_sorting_cmp(const void *base1_ptr, const void *base2_ptr)
{
const Base *b1 = *((const Base **)base1_ptr);
const Base *b2 = *((const Base **)base2_ptr);
-
+
return strcmp(b1->object->id.name + 2, b2->object->id.name + 2);
}
@@ -2918,17 +2920,17 @@ static Base **animdata_filter_ds_sorted_bases(bDopeSheet *ads, ViewLayer *view_l
/* Create an array with space for all the bases, but only containing the usable ones */
size_t tot_bases = BLI_listbase_count(&view_layer->object_bases);
size_t num_bases = 0;
-
+
Base **sorted_bases = MEM_mallocN(sizeof(Base *) * tot_bases, "Dopesheet Usable Sorted Bases");
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
if (animdata_filter_base_is_ok(ads, base, filter_mode)) {
sorted_bases[num_bases++] = base;
}
}
-
+
/* Sort this list of pointers (based on the names) */
qsort(sorted_bases, num_bases, sizeof(Base *), ds_base_sorting_cmp);
-
+
/* Return list of sorted bases */
*r_usable_bases = num_bases;
return sorted_bases;
@@ -2949,17 +2951,17 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBase *anim_data, b
printf("\tPointer = %p, Name = '%s'\n", (void *)ads->source, (ads->source) ? ads->source->name : NULL);
return 0;
}
-
- /* augment the filter-flags with settings based on the dopesheet filterflags
+
+ /* augment the filter-flags with settings based on the dopesheet filterflags
* so that some temp settings can get added automagically...
*/
if (ads->filterflag & ADS_FILTER_SELEDIT) {
/* only selected F-Curves should get their keyframes considered for editability */
filter_mode |= ANIMFILTER_SELEDIT;
}
-
+
/* Cache files level animations (frame duration and such). */
- CacheFile *cache_file = G.main->cachefiles.first;
+ CacheFile *cache_file = ac->bmain->cachefiles.first;
for (; cache_file; cache_file = cache_file->id.next) {
items += animdata_filter_ds_cachefile(ac, anim_data, ads, cache_file, filter_mode);
}
@@ -2984,16 +2986,16 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBase *anim_data, b
// TODO: Cache the old sorted order - if the set of bases hasn't changed, don't re-sort...
Base **sorted_bases;
size_t num_bases;
-
+
sorted_bases = animdata_filter_ds_sorted_bases(ads, view_layer, filter_mode, &num_bases);
if (sorted_bases) {
/* Add the necessary channels for these bases... */
for (size_t i = 0; i < num_bases; i++) {
items += animdata_filter_dopesheet_ob(ac, anim_data, ads, sorted_bases[i], filter_mode);
}
-
+
// TODO: store something to validate whether any changes are needed?
-
+
/* free temporary data */
MEM_freeN(sorted_bases);
}
@@ -3009,20 +3011,20 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBase *anim_data, b
}
}
}
-
+
/* return the number of items in the list */
return items;
}
-/* Summary track for DopeSheet/Action Editor
+/* Summary track for DopeSheet/Action Editor
* - return code is whether the summary lets the other channels get drawn
*/
static short animdata_filter_dopesheet_summary(bAnimContext *ac, ListBase *anim_data, int filter_mode, size_t *items)
{
bDopeSheet *ads = NULL;
-
- /* get the DopeSheet information to use
- * - we should only need to deal with the DopeSheet/Action Editor,
+
+ /* get the DopeSheet information to use
+ * - we should only need to deal with the DopeSheet/Action Editor,
* since all the other Animation Editors won't have this concept
* being applicable.
*/
@@ -3034,9 +3036,9 @@ static short animdata_filter_dopesheet_summary(bAnimContext *ac, ListBase *anim_
/* invalid space type - skip this summary channels */
return 1;
}
-
- /* dopesheet summary
- * - only for drawing and/or selecting keyframes in channels, but not for real editing
+
+ /* dopesheet summary
+ * - only for drawing and/or selecting keyframes in channels, but not for real editing
* - only useful for DopeSheet/Action/etc. editors where it is actually useful
*/
if ((filter_mode & ANIMFILTER_LIST_CHANNELS) && (ads->filterflag & ADS_FILTER_SUMMARY)) {
@@ -3045,17 +3047,17 @@ static short animdata_filter_dopesheet_summary(bAnimContext *ac, ListBase *anim_
BLI_addtail(anim_data, ale);
(*items)++;
}
-
- /* if summary is collapsed, don't show other channels beneath this
+
+ /* if summary is collapsed, don't show other channels beneath this
* - this check is put inside the summary check so that it doesn't interfere with normal operation
- */
+ */
if (ads->flag & ADS_FLAG_SUMMARY_COLLAPSED)
return 0;
}
-
+
/* the other channels beneath this can be shown */
return 1;
-}
+}
/* ......................... */
@@ -3063,18 +3065,18 @@ static short animdata_filter_dopesheet_summary(bAnimContext *ac, ListBase *anim_
static size_t animdata_filter_animchan(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAnimListElem *channel, int filter_mode)
{
size_t items = 0;
-
+
/* data to filter depends on channel type */
/* NOTE: only common channel-types have been handled for now. More can be added as necessary */
switch (channel->type) {
case ANIMTYPE_SUMMARY:
items += animdata_filter_dopesheet(ac, anim_data, ads, filter_mode);
break;
-
+
case ANIMTYPE_SCENE:
items += animdata_filter_dopesheet_scene(ac, anim_data, ads, channel->data, filter_mode);
break;
-
+
case ANIMTYPE_OBJECT:
items += animdata_filter_dopesheet_ob(ac, anim_data, ads, channel->data, filter_mode);
break;
@@ -3086,12 +3088,12 @@ static size_t animdata_filter_animchan(bAnimContext *ac, ListBase *anim_data, bD
case ANIMTYPE_ANIMDATA:
items += animfilter_block_data(ac, anim_data, ads, channel->id, filter_mode);
break;
-
+
default:
printf("ERROR: Unsupported channel type (%d) in animdata_filter_animchan()\n", channel->type);
break;
}
-
+
return items;
}
@@ -3102,17 +3104,17 @@ static size_t animdata_filter_remove_invalid(ListBase *anim_data)
{
bAnimListElem *ale, *next;
size_t items = 0;
-
+
/* only keep entries with valid types */
for (ale = anim_data->first; ale; ale = next) {
next = ale->next;
-
+
if (ale->type == ANIMTYPE_NONE)
BLI_freelinkN(anim_data, ale);
else
items++;
}
-
+
return items;
}
@@ -3122,18 +3124,18 @@ static size_t animdata_filter_remove_duplis(ListBase *anim_data)
bAnimListElem *ale, *next;
GSet *gs;
size_t items = 0;
-
- /* build new hashtable to efficiently store and retrieve which entries have been
+
+ /* build new hashtable to efficiently store and retrieve which entries have been
* encountered already while searching
*/
gs = BLI_gset_ptr_new(__func__);
-
+
/* loop through items, removing them from the list if a similar item occurs already */
for (ale = anim_data->first; ale; ale = next) {
next = ale->next;
-
- /* check if hash has any record of an entry like this
- * - just use ale->data for now, though it would be nicer to involve
+
+ /* check if hash has any record of an entry like this
+ * - just use ale->data for now, though it would be nicer to involve
* ale->type in combination too to capture corner cases (where same data performs differently)
*/
if (BLI_gset_add(gs, ale->data)) {
@@ -3145,10 +3147,10 @@ static size_t animdata_filter_remove_duplis(ListBase *anim_data)
BLI_freelinkN(anim_data, ale);
}
}
-
+
/* free the hash... */
BLI_gset_free(gs, NULL);
-
+
/* return the number of items still in the list */
return items;
}
@@ -3156,8 +3158,8 @@ static size_t animdata_filter_remove_duplis(ListBase *anim_data)
/* ----------- Public API --------------- */
/* This function filters the active data source to leave only animation channels suitable for
- * usage by the caller. It will return the length of the list
- *
+ * usage by the caller. It will return the length of the list
+ *
* *anim_data: is a pointer to a ListBase, to which the filtered animation channels
* will be placed for use.
* filter_mode: how should the data be filtered - bitmapping accessed flags
@@ -3165,7 +3167,7 @@ static size_t animdata_filter_remove_duplis(ListBase *anim_data)
size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_Flags filter_mode, void *data, eAnimCont_Types datatype)
{
size_t items = 0;
-
+
/* only filter data if there's somewhere to put it */
if (data && anim_data) {
/* firstly filter the data */
@@ -3176,7 +3178,7 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F
Object *obact = ac->obact;
SpaceAction *saction = (SpaceAction *)ac->sl;
bDopeSheet *ads = (saction) ? &saction->ads : NULL;
-
+
/* specially check for AnimData filter... [#36687] */
if (UNLIKELY(filter_mode & ANIMFILTER_ANIMDATA)) {
/* all channels here are within the same AnimData block, hence this special case */
@@ -3189,13 +3191,13 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F
if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
items += animfilter_action(ac, anim_data, ads, data, filter_mode, (ID *)obact);
}
-
+
break;
}
case ANIMCONT_SHAPEKEY: /* 'ShapeKey Editor' */
{
Key *key = (Key *)data;
-
+
/* specially check for AnimData filter... [#36687] */
if (UNLIKELY(filter_mode & ANIMFILTER_ANIMDATA)) {
/* all channels here are within the same AnimData block, hence this special case */
@@ -3208,11 +3210,11 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F
if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
items = animdata_filter_shapekey(ac, anim_data, key, filter_mode);
}
-
+
break;
}
-
-
+
+
/* Modes for Specialty Data Types (i.e. not keyframes) */
case ANIMCONT_GPENCIL:
{
@@ -3223,11 +3225,11 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F
case ANIMCONT_MASK:
{
if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
- items = animdata_filter_mask(anim_data, data, filter_mode);
+ items = animdata_filter_mask(ac->bmain, anim_data, data, filter_mode);
break;
}
-
-
+
+
/* DopeSheet Based Modes */
case ANIMCONT_DOPESHEET: /* 'DopeSheet Editor' */
{
@@ -3244,8 +3246,8 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F
items = animdata_filter_dopesheet(ac, anim_data, data, filter_mode);
break;
}
-
-
+
+
/* Timeline Mode - Basically the same as dopesheet, except we only have the summary for now */
case ANIMCONT_TIMELINE:
{
@@ -3254,17 +3256,17 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F
items += animdata_filter_dopesheet(ac, anim_data, data, filter_mode);
break;
}
-
+
/* Special/Internal Use */
case ANIMCONT_CHANNEL: /* animation channel */
{
bDopeSheet *ads = ac->ads;
-
+
/* based on the channel type, filter relevant data for this */
items = animdata_filter_animchan(ac, anim_data, ads, data, filter_mode);
break;
}
-
+
/* unhandled */
default:
{
@@ -3275,12 +3277,12 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F
/* remove any 'weedy' entries */
items = animdata_filter_remove_invalid(anim_data);
-
+
/* remove duplicates (if required) */
if (filter_mode & ANIMFILTER_NODUPLIS)
items = animdata_filter_remove_duplis(anim_data);
}
-
+
/* return the number of items in the list */
return items;
}
diff --git a/source/blender/editors/animation/anim_intern.h b/source/blender/editors/animation/anim_intern.h
index 824c1d58f44..de91ce06c8b 100644
--- a/source/blender/editors/animation/anim_intern.h
+++ b/source/blender/editors/animation/anim_intern.h
@@ -27,7 +27,7 @@
* \ingroup edanimation
*/
-
+
#ifndef __ANIM_INTERN_H__
#define __ANIM_INTERN_H__
@@ -38,15 +38,15 @@ extern ListBase builtin_keyingsets;
/* Operator Define Prototypes ------------------- */
-/* Main Keyframe Management operators:
+/* Main Keyframe Management operators:
* These handle keyframes management from various spaces. They only make use of
* Keying Sets.
*/
void ANIM_OT_keyframe_insert(struct wmOperatorType *ot);
void ANIM_OT_keyframe_delete(struct wmOperatorType *ot);
-/* Main Keyframe Management operators:
- * These handle keyframes management from various spaces. They will handle the menus
+/* Main Keyframe Management operators:
+ * These handle keyframes management from various spaces. They will handle the menus
* required for each space.
*/
void ANIM_OT_keyframe_insert_menu(struct wmOperatorType *ot);
diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c
index fc6f4036d02..4e0993152f7 100644
--- a/source/blender/editors/animation/anim_ipo_utils.c
+++ b/source/blender/editors/animation/anim_ipo_utils.c
@@ -53,13 +53,13 @@
/* ----------------------- Getter functions ----------------------- */
/* Write into "name" buffer, the name of the property (retrieved using RNA from the curve's settings),
- * and return the icon used for the struct that this property refers to
+ * and return the icon used for the struct that this property refers to
* WARNING: name buffer we're writing to cannot exceed 256 chars (check anim_channels_defines.c for details)
*/
int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
{
int icon = 0;
-
+
/* sanity checks */
if (name == NULL)
return icon;
@@ -74,17 +74,17 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
else {
PointerRNA id_ptr, ptr;
PropertyRNA *prop;
-
+
/* get RNA pointer, and resolve the path */
RNA_id_pointer_create(id, &id_ptr);
-
+
/* try to resolve the path */
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
const char *structname = NULL, *propname = NULL;
char arrayindbuf[16];
const char *arrayname = NULL;
short free_structname = 0;
-
+
/* For now, name will consist of 3 parts: struct-name, property name, array index
* There are several options possible:
* 1) <struct-name>.<property-name>.<array-index>
@@ -93,12 +93,12 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
* i.e. X Location (Bone1), or X Location (Object)
*
* Currently, option 2 is in use, to try and make it easier to quickly identify F-Curves (it does have
- * problems with looking rather odd though). Option 1 is better in terms of revealing a consistent sense of
+ * problems with looking rather odd though). Option 1 is better in terms of revealing a consistent sense of
* hierarchy though, which isn't so clear with option 2.
*/
-
+
/* for structname
- * - as base, we use a custom name from the structs if one is available
+ * - as base, we use a custom name from the structs if one is available
* - however, if we're showing subdata of bones (probably there will be other exceptions later)
* need to include that info too since it gets confusing otherwise
* - if a pointer just refers to the ID-block, then don't repeat this info
@@ -108,11 +108,11 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
/* perform string 'chopping' to get "Bone Name : Constraint Name" */
char *pchanName = BLI_str_quoted_substrN(fcu->rna_path, "bones[");
char *constName = BLI_str_quoted_substrN(fcu->rna_path, "constraints[");
-
+
/* assemble the string to display in the UI... */
structname = BLI_sprintfN("%s : %s", pchanName, constName);
free_structname = 1;
-
+
/* free the temp names */
if (pchanName) MEM_freeN(pchanName);
if (constName) MEM_freeN(constName);
@@ -127,25 +127,25 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
else
structname = RNA_struct_ui_name(ptr.type);
}
-
+
/* Property Name is straightforward */
propname = RNA_property_ui_name(prop);
-
+
/* Array Index - only if applicable */
if (RNA_property_array_check(prop)) {
char c = RNA_property_array_item_char(prop, fcu->array_index);
-
+
/* we need to write the index to a temp buffer (in py syntax) */
if (c) BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "%c ", c);
else BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "[%d]", fcu->array_index);
-
+
arrayname = &arrayindbuf[0];
}
else {
/* no array index */
arrayname = "";
}
-
+
/* putting this all together into the buffer */
/* XXX we need to check for invalid names...
* XXX the name length limit needs to be passed in or as some define */
@@ -153,17 +153,17 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
BLI_snprintf(name, 256, "%s%s (%s)", arrayname, propname, structname);
else
BLI_snprintf(name, 256, "%s%s", arrayname, propname);
-
+
/* free temp name if nameprop is set */
if (free_structname)
MEM_freeN((void *)structname);
-
-
+
+
/* Icon for this property's owner:
* use the struct's icon if it is set
*/
icon = RNA_struct_ui_icon(ptr.type);
-
+
/* valid path - remove the invalid tag since we now know how to use it saving
* users manual effort to reenable using "Revive Disabled FCurves" [#29629]
*/
@@ -172,16 +172,16 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
else {
/* invalid path */
BLI_snprintf(name, 256, "\"%s[%d]\"", fcu->rna_path, fcu->array_index);
-
+
/* icon for this should be the icon for the base ID */
/* TODO: or should we just use the error icon? */
icon = RNA_struct_ui_icon(id_ptr.type);
-
+
/* tag F-Curve as disabled - as not usable path */
fcu->flag |= FCURVE_DISABLED;
}
}
-
+
/* return the icon that the active data had */
return icon;
}
@@ -197,7 +197,7 @@ void getcolor_fcurve_rainbow(int cur, int tot, float out[3])
{
float hsv[3], fac;
int grouping;
-
+
/* we try to divide the color into groupings of n colors,
* where n is:
* 3 - for 'odd' numbers of curves - there should be a majority of triplets of curves
@@ -206,24 +206,24 @@ void getcolor_fcurve_rainbow(int cur, int tot, float out[3])
*/
grouping = (4 - (tot % 2));
hsv[0] = HSV_BANDWIDTH * (float)(cur % grouping);
-
- /* 'Value' (i.e. darkness) needs to vary so that larger sets of three will be
+
+ /* 'Value' (i.e. darkness) needs to vary so that larger sets of three will be
* 'darker' (i.e. smaller value), so that they don't look that similar to previous ones.
* However, only a range of 0.3 to 1.0 is really usable to avoid clashing
- * with some other stuff
+ * with some other stuff
*/
fac = ((float)cur / (float)tot) * 0.7f;
-
+
/* the base color can get offset a bit so that the colors aren't so identical */
hsv[0] += fac * HSV_BANDWIDTH;
if (hsv[0] > 1.0f) hsv[0] = fmod(hsv[0], 1.0f);
-
+
/* saturation adjustments for more visible range */
hsv[1] = ((hsv[0] > 0.5f) && (hsv[0] < 0.8f)) ? 0.5f : 0.6f;
-
+
/* value is fixed at 1.0f, otherwise we cannot clearly see the curves... */
hsv[2] = 1.0f;
-
+
/* finally, conver this to RGB colors */
hsv_to_rgb_v(hsv, out);
}
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 091346921dc..624c6e9f5de 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -85,8 +85,8 @@ static ListBase *context_get_markers(Scene *scene, ScrArea *sa)
if (sa) {
if (sa->spacetype == SPACE_ACTION) {
SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
-
- /* local markers can only be shown when there's only a single active action to grab them from
+
+ /* local markers can only be shown when there's only a single active action to grab them from
* - flag only takes effect when there's an action, otherwise it can get too confusing?
*/
if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) && (saction->action)) {
@@ -96,7 +96,7 @@ static ListBase *context_get_markers(Scene *scene, ScrArea *sa)
}
}
}
-
+
/* default to using the scene's markers */
return &scene->markers;
}
@@ -135,7 +135,7 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f
TimeMarker *marker;
float cfra = (float)CFRA;
int changed_tot = 0;
-
+
/* sanity check - no markers, or locked markers */
if ((scene->toolsettings->lock_markers) ||
(markers == NULL))
@@ -170,7 +170,7 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f
}
}
}
-
+
return changed_tot;
}
@@ -182,18 +182,18 @@ TimeMarker *ED_markers_find_nearest_marker(ListBase *markers, float x)
{
TimeMarker *marker, *nearest = NULL;
float dist, min_dist = 1000000;
-
+
if (markers) {
for (marker = markers->first; marker; marker = marker->next) {
dist = fabsf((float)marker->frame - x);
-
+
if (dist < min_dist) {
min_dist = dist;
nearest = marker;
}
}
}
-
+
return nearest;
}
@@ -209,7 +209,7 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la
{
TimeMarker *marker;
float min, max;
-
+
/* sanity check */
//printf("markers = %p - %p, %p\n", markers, markers->first, markers->last);
if (ELEM(NULL, markers, markers->first, markers->last)) {
@@ -228,7 +228,7 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la
max = (float)marker->frame;
}
}
-
+
/* set the min/max values */
*first = min;
*last = max;
@@ -240,16 +240,16 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la
static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only_sel)
{
CfraElem *ce, *cen;
-
+
/* should this one only be considered if it is selected? */
if ((only_sel) && ((marker->flag & SELECT) == 0))
return;
-
+
/* insertion sort - try to find a previous cfra elem */
for (ce = lb->first; ce; ce = ce->next) {
if (ce->cfra == marker->frame) {
/* do because of double keys */
- if (marker->flag & SELECT)
+ if (marker->flag & SELECT)
ce->sel = marker->flag;
return;
}
@@ -257,7 +257,7 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only
break;
}
}
-
+
cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
if (ce) BLI_insertlinkbefore(lb, ce, cen);
else BLI_addtail(lb, cen);
@@ -273,7 +273,7 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only
void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
{
TimeMarker *marker;
-
+
if (lb) {
/* Clear the list first, since callers have no way of knowing
* whether this terminated early otherwise. This may lead
@@ -284,11 +284,11 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
else {
return;
}
-
+
if (markers == NULL) {
return;
}
-
+
for (marker = markers->first; marker; marker = marker->next)
add_marker_to_cfra_elem(lb, marker, only_sel);
}
@@ -299,37 +299,37 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
TimeMarker *ED_markers_get_first_selected(ListBase *markers)
{
TimeMarker *marker;
-
+
if (markers) {
for (marker = markers->first; marker; marker = marker->next) {
if (marker->flag & SELECT)
return marker;
}
}
-
+
return NULL;
}
/* --------------------------------- */
-/* Print debugging prints of list of markers
+/* Print debugging prints of list of markers
* BSI's: do NOT make static or put in if-defs as "unused code". That's too much trouble when we need to use for quick debugging!
*/
void debug_markers_print_list(ListBase *markers)
{
TimeMarker *marker;
-
+
if (markers == NULL) {
printf("No markers list to print debug for\n");
return;
}
-
+
printf("List of markers follows: -----\n");
-
+
for (marker = markers->first; marker; marker = marker->next) {
printf("\t'%s' on %d at %p with %u\n", marker->name, marker->frame, (void *)marker, marker->flag);
}
-
+
printf("End of list ------------------\n");
}
@@ -344,7 +344,7 @@ static void draw_marker_name(
/* minimal y coordinate which wouldn't be occluded by scroll */
int min_y = 17.0f * UI_DPI_FAC;
-
+
if (marker->flag & SELECT) {
UI_GetThemeColor4ubv(TH_TEXT_HI, text_col);
x = xpos + 4.0f * UI_DPI_FAC;
@@ -422,7 +422,7 @@ static void draw_marker(
immUnbindProgram();
}
-
+
/* 5 px to offset icon to align properly, space / pixels corrects for zoom */
if (flag & DRAW_MARKERS_LOCAL) {
icon_id = (marker->flag & ACTIVE) ? ICON_PMARKER_ACT :
@@ -439,11 +439,11 @@ static void draw_marker(
icon_id = (marker->flag & SELECT) ? ICON_MARKER_HLT :
ICON_MARKER;
}
-
+
UI_icon_draw(xpos - 0.45f * UI_DPI_ICON_SIZE, yoffs + UI_DPI_ICON_SIZE, icon_id);
-
+
glDisable(GL_BLEND);
-
+
/* and the marker name too, shifted slightly to the top-right */
#ifdef DURIAN_CAMERA_SWITCH
if (marker->camera) {
@@ -530,8 +530,8 @@ void ED_markers_draw(const bContext *C, int flag)
}
/* ************************ Marker Wrappers API ********************* */
-/* These wrappers allow marker operators to function within the confines
- * of standard animation editors, such that they can coexist with the
+/* These wrappers allow marker operators to function within the confines
+ * of standard animation editors, such that they can coexist with the
* primary operations of those editors.
*/
@@ -541,11 +541,11 @@ void ED_markers_draw(const bContext *C, int flag)
static int ed_markers_poll_selected_markers(bContext *C)
{
ListBase *markers = ED_context_get_markers(C);
-
+
/* first things first: markers can only exist in timeline views */
if (ED_operator_animview_active(C) == 0)
return 0;
-
+
/* check if some marker is selected */
return ED_markers_get_first_selected(markers) != NULL;
}
@@ -572,19 +572,19 @@ static int ed_markers_poll_markers_exist(bContext *C)
{
ListBase *markers = ED_context_get_markers(C);
ToolSettings *ts = CTX_data_tool_settings(C);
-
+
if (ts->lock_markers)
return 0;
/* first things first: markers can only exist in timeline views */
if (ED_operator_animview_active(C) == 0)
return 0;
-
+
/* list of markers must exist, as well as some markers in it! */
return (markers && markers->first);
}
-
-/* ------------------------ */
+
+/* ------------------------ */
/**
* Second-tier invoke() callback that performs context validation before running the
@@ -637,30 +637,30 @@ static int ed_marker_add_exec(bContext *C, wmOperator *UNUSED(op))
ListBase *markers = ED_context_get_markers(C);
TimeMarker *marker;
int frame = CTX_data_scene(C)->r.cfra;
-
+
if (markers == NULL)
return OPERATOR_CANCELLED;
-
+
/* prefer not having 2 markers at the same place,
* though the user can move them to overlap once added */
for (marker = markers->first; marker; marker = marker->next) {
- if (marker->frame == frame)
+ if (marker->frame == frame)
return OPERATOR_CANCELLED;
}
-
+
/* deselect all */
for (marker = markers->first; marker; marker = marker->next)
marker->flag &= ~SELECT;
-
+
marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
marker->flag = SELECT;
marker->frame = frame;
BLI_snprintf(marker->name, sizeof(marker->name), "F_%02d", frame); // XXX - temp code only
BLI_addtail(markers, marker);
-
+
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -670,39 +670,39 @@ static void MARKER_OT_add(wmOperatorType *ot)
ot->name = "Add Time Marker";
ot->description = "Add a new time marker";
ot->idname = "MARKER_OT_add";
-
+
/* api callbacks */
ot->exec = ed_marker_add_exec;
ot->invoke = ed_markers_opwrap_invoke;
ot->poll = ED_operator_animview_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* ************************** transform markers *************************** */
-/* operator state vars used:
+/* operator state vars used:
* frs: delta movement
- *
+ *
* functions:
- *
+ *
* init() check selection, add customdata with old values and some lookups
- *
+ *
* apply() do the actual movement
- *
+ *
* exit() cleanup, send notifier
- *
+ *
* cancel() to escape from modal
- *
+ *
* callbacks:
- *
- * exec() calls init, apply, exit
- *
+ *
+ * exec() calls init, apply, exit
+ *
* invoke() calls init, adds modal handler
- *
+ *
* modal() accept modal events while doing it, ends with apply and exit, or cancel
- *
+ *
*/
typedef struct MarkerMove {
@@ -820,12 +820,12 @@ static bool ed_marker_move_init(bContext *C, wmOperator *op)
static void ed_marker_move_exit(bContext *C, wmOperator *op)
{
MarkerMove *mm = op->customdata;
-
+
/* free data */
MEM_freeN(mm->oldframe);
MEM_freeN(op->customdata);
op->customdata = NULL;
-
+
/* clear custom header prints */
ED_area_headerprint(CTX_wm_area(C), NULL);
}
@@ -834,14 +834,14 @@ static int ed_marker_move_invoke(bContext *C, wmOperator *op, const wmEvent *eve
{
if (ed_marker_move_init(C, op)) {
MarkerMove *mm = op->customdata;
-
+
mm->evtx = event->x;
mm->firstx = event->x;
mm->event_type = event->type;
-
+
/* add temp handler */
WM_event_add_modal_handler(C, op);
-
+
/* reset frs delta */
RNA_int_set(op->ptr, "frames", 0);
@@ -849,7 +849,7 @@ static int ed_marker_move_invoke(bContext *C, wmOperator *op, const wmEvent *eve
return OPERATOR_RUNNING_MODAL;
}
-
+
return OPERATOR_CANCELLED;
}
@@ -869,7 +869,7 @@ static void ed_marker_move_apply(bContext *C, wmOperator *op)
MarkerMove *mm = op->customdata;
TimeMarker *marker;
int a, offs;
-
+
offs = RNA_int_get(op->ptr, "frames");
for (a = 0, marker = mm->markers->first; marker; marker = marker->next) {
if (marker->flag & SELECT) {
@@ -880,7 +880,7 @@ static void ed_marker_move_apply(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
-
+
#ifdef DURIAN_CAMERA_SWITCH
/* so we get view3d redraws */
BKE_scene_camera_switch_update(scene);
@@ -1002,17 +1002,17 @@ static void MARKER_OT_move(wmOperatorType *ot)
ot->name = "Move Time Marker";
ot->description = "Move selected time marker(s)";
ot->idname = "MARKER_OT_move";
-
+
/* api callbacks */
ot->exec = ed_marker_move_exec;
ot->invoke = ed_marker_move_invoke_wrapper;
ot->modal = ed_marker_move_modal;
ot->poll = ed_markers_poll_selected_no_locked_markers;
ot->cancel = ed_marker_move_cancel;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR;
-
+
/* rna storage */
RNA_def_int(ot->srna, "frames", 0, INT_MIN, INT_MAX, "Frames", "", INT_MIN, INT_MAX);
}
@@ -1040,8 +1040,8 @@ static void ed_marker_duplicate_apply(bContext *C)
{
ListBase *markers = ED_context_get_markers(C);
TimeMarker *marker, *newmarker;
-
- if (markers == NULL)
+
+ if (markers == NULL)
return;
/* go through the list of markers, duplicate selected markers and add duplicated copies
@@ -1051,13 +1051,13 @@ static void ed_marker_duplicate_apply(bContext *C)
if (marker->flag & SELECT) {
/* unselect selected marker */
marker->flag &= ~SELECT;
-
+
/* create and set up new marker */
newmarker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
newmarker->flag = SELECT;
newmarker->frame = marker->frame;
BLI_strncpy(newmarker->name, marker->name, sizeof(marker->name));
-
+
#ifdef DURIAN_CAMERA_SWITCH
newmarker->camera = marker->camera;
#endif
@@ -1073,9 +1073,9 @@ static int ed_marker_duplicate_exec(bContext *C, wmOperator *op)
{
ed_marker_duplicate_apply(C);
ed_marker_move_exec(C, op); /* assumes frs delta set */
-
+
return OPERATOR_FINISHED;
-
+
}
static int ed_marker_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -1095,17 +1095,17 @@ static void MARKER_OT_duplicate(wmOperatorType *ot)
ot->name = "Duplicate Time Marker";
ot->description = "Duplicate selected time marker(s)";
ot->idname = "MARKER_OT_duplicate";
-
+
/* api callbacks */
ot->exec = ed_marker_duplicate_exec;
ot->invoke = ed_marker_duplicate_invoke_wrapper;
ot->modal = ed_marker_move_modal;
ot->poll = ed_markers_poll_selected_no_locked_markers;
ot->cancel = ed_marker_move_cancel;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* rna storage */
RNA_def_int(ot->srna, "frames", 0, INT_MIN, INT_MAX, "Frames", "", INT_MIN, INT_MAX);
}
@@ -1152,18 +1152,18 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
View2D *v2d = UI_view2d_fromcontext(C);
float viewx;
int x, cfra;
-
+
if (markers == NULL)
return OPERATOR_PASS_THROUGH;
x = event->x - ar->winrct.xmin;
-
+
viewx = UI_view2d_region_to_view_x(v2d, x);
-
+
cfra = ED_markers_find_nearest_marker_time(markers, viewx);
-
+
select_timeline_marker_frame(markers, cfra, extend);
-
+
#ifdef DURIAN_CAMERA_SWITCH
if (camera) {
@@ -1172,17 +1172,17 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
Base *base;
TimeMarker *marker;
int sel = 0;
-
+
if (!extend)
BKE_view_layer_base_deselect_all(view_layer);
-
+
for (marker = markers->first; marker; marker = marker->next) {
if (marker->frame == cfra) {
sel = (marker->flag & SELECT);
break;
}
}
-
+
for (marker = markers->first; marker; marker = marker->next) {
if (marker->camera) {
if (marker->frame == cfra) {
@@ -1195,7 +1195,7 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
}
}
}
-
+
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
#else
@@ -1232,11 +1232,11 @@ static void MARKER_OT_select(wmOperatorType *ot)
ot->name = "Select Time Marker";
ot->description = "Select time marker(s)";
ot->idname = "MARKER_OT_select";
-
+
/* api callbacks */
ot->invoke = ed_marker_select_invoke_wrapper;
ot->poll = ed_markers_poll_markers_exist;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1250,7 +1250,7 @@ static void MARKER_OT_select(wmOperatorType *ot)
/* *************************** border select markers **************** */
-/* operator state vars used: (added by default WM callbacks)
+/* operator state vars used: (added by default WM callbacks)
* xmin, ymin
* xmax, ymax
*
@@ -1277,13 +1277,13 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
bool select = !RNA_boolean_get(op->ptr, "deselect");
bool extend = RNA_boolean_get(op->ptr, "extend");
rctf rect;
-
+
WM_operator_properties_border_to_rctf(op, &rect);
UI_view2d_region_to_view_rctf(v2d, &rect, &rect);
-
+
if (markers == NULL)
return 0;
-
+
/* XXX marker context */
for (marker = markers->first; marker; marker = marker->next) {
if (BLI_rctf_isect_x(&rect, marker->frame)) {
@@ -1298,7 +1298,7 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
marker->flag &= ~SELECT;
}
}
-
+
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
@@ -1316,18 +1316,18 @@ static void MARKER_OT_select_border(wmOperatorType *ot)
ot->name = "Marker Border Select";
ot->description = "Select all time markers using border selection";
ot->idname = "MARKER_OT_select_border";
-
+
/* api callbacks */
ot->exec = ed_marker_border_select_exec;
ot->invoke = ed_marker_select_border_invoke_wrapper;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
-
+
ot->poll = ed_markers_poll_markers_exist;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* rna */
WM_operator_properties_gesture_border_select(ot);
}
@@ -1346,7 +1346,7 @@ static int ed_marker_select_all_exec(bContext *C, wmOperator *op)
if (action == SEL_TOGGLE) {
action = (ED_markers_get_first_selected(markers) != NULL) ? SEL_DESELECT : SEL_SELECT;
}
-
+
for (marker = markers->first; marker; marker = marker->next) {
switch (action) {
case SEL_SELECT:
@@ -1360,7 +1360,7 @@ static int ed_marker_select_all_exec(bContext *C, wmOperator *op)
break;
}
}
-
+
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
@@ -1373,15 +1373,15 @@ static void MARKER_OT_select_all(wmOperatorType *ot)
ot->name = "(De)select all Markers";
ot->description = "Change selection of all time markers";
ot->idname = "MARKER_OT_select_all";
-
+
/* api callbacks */
ot->exec = ed_marker_select_all_exec;
ot->invoke = ed_markers_opwrap_invoke;
ot->poll = ed_markers_poll_markers_exist;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* rna */
WM_operator_properties_select_all(ot);
}
@@ -1394,10 +1394,10 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op))
ListBase *markers = ED_context_get_markers(C);
TimeMarker *marker, *nmarker;
bool changed = false;
-
+
if (markers == NULL)
return OPERATOR_CANCELLED;
-
+
for (marker = markers->first; marker; marker = nmarker) {
nmarker = marker->next;
if (marker->flag & SELECT) {
@@ -1405,12 +1405,12 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op))
changed = true;
}
}
-
+
if (changed) {
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
}
-
+
return OPERATOR_FINISHED;
}
@@ -1426,12 +1426,12 @@ static void MARKER_OT_delete(wmOperatorType *ot)
ot->name = "Delete Markers";
ot->description = "Delete selected time marker(s)";
ot->idname = "MARKER_OT_delete";
-
+
/* api callbacks */
ot->invoke = ed_marker_delete_invoke_wrapper;
ot->exec = ed_marker_delete_exec;
ot->poll = ed_markers_poll_selected_no_locked_markers;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1446,10 +1446,10 @@ static int ed_marker_rename_exec(bContext *C, wmOperator *op)
if (marker) {
RNA_string_get(op->ptr, "name", marker->name);
-
+
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
-
+
return OPERATOR_FINISHED;
}
else {
@@ -1463,7 +1463,7 @@ static int ed_marker_rename_invoke_wrapper(bContext *C, wmOperator *op, const wm
TimeMarker *marker = ED_markers_get_first_selected(ED_context_get_markers(C));
if (marker)
RNA_string_set(op->ptr, "name", marker->name);
-
+
/* now see if the operator is usable */
return ed_markers_opwrap_invoke_custom(C, op, event, WM_operator_props_popup_confirm);
}
@@ -1474,15 +1474,15 @@ static void MARKER_OT_rename(wmOperatorType *ot)
ot->name = "Rename Marker";
ot->description = "Rename first selected time marker";
ot->idname = "MARKER_OT_rename";
-
+
/* api callbacks */
ot->invoke = ed_marker_rename_invoke_wrapper;
ot->exec = ed_marker_rename_exec;
ot->poll = ed_markers_poll_selected_no_locked_markers;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_string(ot->srna, "name", "RenamedMarker", sizeof(((TimeMarker *)NULL)->name), "Name", "New name for marker");
//RNA_def_boolean(ot->srna, "ensure_unique", 0, "Ensure Unique", "Ensure that new name is unique within collection of markers");
@@ -1516,7 +1516,7 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
if (marker->flag & SELECT) {
marker_new = MEM_dupallocN(marker);
marker_new->prev = marker_new->next = NULL;
-
+
BLI_addtail(&scene_to->markers, marker_new);
}
}
@@ -1645,7 +1645,7 @@ void ED_keymap_marker(wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_find(keyconf, "Markers", 0, 0);
wmKeyMapItem *kmi;
-
+
WM_keymap_verify_item(keymap, "MARKER_OT_add", MKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "MARKER_OT_move", EVT_TWEAK_S, KM_ANY, 0, 0);
WM_keymap_verify_item(keymap, "MARKER_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
@@ -1664,13 +1664,13 @@ void ED_keymap_marker(wmKeyConfig *keyconf)
#else
(void)kmi;
#endif
-
+
WM_keymap_verify_item(keymap, "MARKER_OT_select_border", BKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "MARKER_OT_select_all", AKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MARKER_OT_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MARKER_OT_delete", DELKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "MARKER_OT_rename", MKEY, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "MARKER_OT_move", GKEY, KM_PRESS, 0, 0);
#ifdef DURIAN_CAMERA_SWITCH
WM_keymap_add_item(keymap, "MARKER_OT_camera_bind", BKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index 1136dcd129e..23563e7f15f 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation, Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
@@ -67,10 +67,10 @@
static int change_frame_poll(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
-
+
/* XXX temp? prevent changes during render */
if (G.is_rendering) return false;
-
+
/* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
*/
@@ -85,7 +85,7 @@ static int change_frame_poll(bContext *C)
return false;
}
}
-
+
CTX_wm_operator_poll_msg_set(C, "Expected an animation area to be active");
return false;
}
@@ -139,12 +139,12 @@ static float frame_from_event(bContext *C, const wmEvent *event)
/* convert from region coordinates to View2D 'tot' space */
frame = UI_view2d_region_to_view_x(&region->v2d, event->mval[0]);
-
+
/* respect preview range restrictions (if only allowed to move around within that range) */
if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) {
CLAMP(frame, PSFRA, PEFRA);
}
-
+
return frame;
}
@@ -195,7 +195,7 @@ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event
change_frame_seq_preview_begin(C, event);
change_frame_apply(C, op);
-
+
/* add temp handler */
WM_event_add_modal_handler(C, op);
@@ -221,11 +221,11 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
RNA_float_set(op->ptr, "frame", frame_from_event(C, event));
change_frame_apply(C, op);
break;
-
- case LEFTMOUSE:
+
+ case LEFTMOUSE:
case RIGHTMOUSE:
case MIDDLEMOUSE:
- /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init
+ /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init
* the modal op) doesn't work for some reason
*/
if (event->val == KM_RELEASE)
@@ -258,14 +258,14 @@ static void ANIM_OT_change_frame(wmOperatorType *ot)
ot->name = "Change Frame";
ot->idname = "ANIM_OT_change_frame";
ot->description = "Interactively change the current frame number";
-
+
/* api callbacks */
ot->exec = change_frame_exec;
ot->invoke = change_frame_invoke;
ot->cancel = change_frame_cancel;
ot->modal = change_frame_modal;
ot->poll = change_frame_poll;
-
+
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR | OPTYPE_UNDO_GROUPED;
ot->undo_group = "FRAME_CHANGE";
@@ -282,10 +282,10 @@ static void ANIM_OT_change_frame(wmOperatorType *ot)
static int anim_set_end_frames_poll(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
-
+
/* XXX temp? prevent changes during render */
if (G.is_rendering) return false;
-
+
/* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
*/
@@ -294,7 +294,7 @@ static int anim_set_end_frames_poll(bContext *C)
return true;
}
}
-
+
CTX_wm_operator_poll_msg_set(C, "Expected an animation area to be active");
return false;
}
@@ -314,16 +314,16 @@ static int anim_set_sfra_exec(bContext *C, wmOperator *UNUSED(op))
scene->r.psfra = frame;
else
scene->r.sfra = frame;
-
+
if (PEFRA < frame) {
if (PRVRANGEON)
scene->r.pefra = frame;
else
scene->r.efra = frame;
}
-
+
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -333,14 +333,14 @@ static void ANIM_OT_start_frame_set(wmOperatorType *ot)
ot->name = "Set Start Frame";
ot->idname = "ANIM_OT_start_frame_set";
ot->description = "Set the start frame";
-
+
/* api callbacks */
ot->exec = anim_set_sfra_exec;
ot->poll = anim_set_end_frames_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
+}
static int anim_set_efra_exec(bContext *C, wmOperator *UNUSED(op))
@@ -365,9 +365,9 @@ static int anim_set_efra_exec(bContext *C, wmOperator *UNUSED(op))
else
scene->r.sfra = frame;
}
-
+
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -377,11 +377,11 @@ static void ANIM_OT_end_frame_set(wmOperatorType *ot)
ot->name = "Set End Frame";
ot->idname = "ANIM_OT_end_frame_set";
ot->description = "Set the end frame";
-
+
/* api callbacks */
ot->exec = anim_set_efra_exec;
ot->poll = anim_set_end_frames_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -394,31 +394,31 @@ static int previewrange_define_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
float sfra, efra;
rcti rect;
-
+
/* get min/max values from border select rect (already in region coordinates, not screen) */
WM_operator_properties_border_to_rcti(op, &rect);
-
+
/* convert min/max values to frames (i.e. region to 'tot' rect) */
sfra = UI_view2d_region_to_view_x(&ar->v2d, rect.xmin);
efra = UI_view2d_region_to_view_x(&ar->v2d, rect.xmax);
-
- /* set start/end frames for preview-range
+
+ /* set start/end frames for preview-range
* - must clamp within allowable limits
* - end must not be before start (though this won't occur most of the time)
*/
FRAMENUMBER_MIN_CLAMP(sfra);
FRAMENUMBER_MIN_CLAMP(efra);
if (efra < sfra) efra = sfra;
-
+
scene->r.flag |= SCER_PRV_RANGE;
scene->r.psfra = round_fl_to_int(sfra);
scene->r.pefra = round_fl_to_int(efra);
-
+
/* send notifiers */
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
-
+
return OPERATOR_FINISHED;
-}
+}
static void ANIM_OT_previewrange_set(wmOperatorType *ot)
{
@@ -426,18 +426,18 @@ static void ANIM_OT_previewrange_set(wmOperatorType *ot)
ot->name = "Set Preview Range";
ot->idname = "ANIM_OT_previewrange_set";
ot->description = "Interactively define frame range used for playback";
-
+
/* api callbacks */
ot->invoke = WM_gesture_border_invoke;
ot->exec = previewrange_define_exec;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
-
+
ot->poll = ED_operator_animview_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* rna */
/* used to define frame range.
*
@@ -452,23 +452,23 @@ static int previewrange_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
ScrArea *curarea = CTX_wm_area(C);
-
+
/* sanity checks */
if (ELEM(NULL, scene, curarea))
return OPERATOR_CANCELLED;
-
+
/* simply clear values */
scene->r.flag &= ~SCER_PRV_RANGE;
scene->r.psfra = 0;
scene->r.pefra = 0;
-
+
ED_area_tag_redraw(curarea);
-
+
/* send notifiers */
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
-
+
return OPERATOR_FINISHED;
-}
+}
static void ANIM_OT_previewrange_clear(wmOperatorType *ot)
{
@@ -476,12 +476,12 @@ static void ANIM_OT_previewrange_clear(wmOperatorType *ot)
ot->name = "Clear Preview Range";
ot->idname = "ANIM_OT_previewrange_clear";
ot->description = "Clear Preview Range";
-
+
/* api callbacks */
ot->exec = previewrange_clear_exec;
-
+
ot->poll = ED_operator_animview_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -492,13 +492,13 @@ void ED_operatortypes_anim(void)
{
/* Animation Editors only -------------------------- */
WM_operatortype_append(ANIM_OT_change_frame);
-
+
WM_operatortype_append(ANIM_OT_start_frame_set);
WM_operatortype_append(ANIM_OT_end_frame_set);
-
+
WM_operatortype_append(ANIM_OT_previewrange_set);
WM_operatortype_append(ANIM_OT_previewrange_clear);
-
+
/* Entire UI --------------------------------------- */
WM_operatortype_append(ANIM_OT_keyframe_insert);
WM_operatortype_append(ANIM_OT_keyframe_delete);
@@ -508,23 +508,23 @@ void ED_operatortypes_anim(void)
WM_operatortype_append(ANIM_OT_keyframe_insert_button);
WM_operatortype_append(ANIM_OT_keyframe_delete_button);
WM_operatortype_append(ANIM_OT_keyframe_clear_button);
-
-
+
+
WM_operatortype_append(ANIM_OT_driver_button_add);
WM_operatortype_append(ANIM_OT_driver_button_remove);
WM_operatortype_append(ANIM_OT_driver_button_edit);
WM_operatortype_append(ANIM_OT_copy_driver_button);
WM_operatortype_append(ANIM_OT_paste_driver_button);
-
+
WM_operatortype_append(ANIM_OT_keyingset_button_add);
WM_operatortype_append(ANIM_OT_keyingset_button_remove);
-
+
WM_operatortype_append(ANIM_OT_keying_set_add);
WM_operatortype_append(ANIM_OT_keying_set_remove);
WM_operatortype_append(ANIM_OT_keying_set_path_add);
WM_operatortype_append(ANIM_OT_keying_set_path_remove);
-
+
WM_operatortype_append(ANIM_OT_keying_set_active_set);
}
@@ -532,14 +532,14 @@ void ED_keymap_anim(wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_find(keyconf, "Animation", 0, 0);
wmKeyMapItem *kmi;
-
+
/* frame management */
/* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons */
WM_keymap_add_item(keymap, "ANIM_OT_change_frame", ACTIONMOUSE, KM_PRESS, 0, 0);
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TKEY, KM_PRESS, KM_CTRL, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.show_seconds");
-
+
/* preview range */
WM_keymap_verify_item(keymap, "ANIM_OT_previewrange_set", PKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_previewrange_clear", PKEY, KM_PRESS, KM_ALT, 0);
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 2c28ecfac5d..294cff43c56 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -29,7 +29,7 @@
* \ingroup edanimation
*/
-
+
#include <stdio.h>
#include <string.h>
@@ -68,10 +68,10 @@
/* ************************************************** */
/* Animation Data Validation */
-/* Get (or add relevant data to be able to do so) F-Curve from the driver stack,
+/* Get (or add relevant data to be able to do so) F-Curve from the driver stack,
* for the given Animation Data block. This assumes that all the destinations are valid.
- *
- * - add: 0 - don't add anything if not found,
+ *
+ * - add: 0 - don't add anything if not found,
* 1 - add new Driver FCurve (with keyframes for visual tweaking),
* 2 - add new Driver FCurve (with generator, for script backwards compatibility)
* -1 - add new Driver FCurve without driver stuff (for pasting)
@@ -80,11 +80,11 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde
{
AnimData *adt;
FCurve *fcu;
-
+
/* sanity checks */
if (ELEM(NULL, id, rna_path))
return NULL;
-
+
/* init animdata if none available yet */
adt = BKE_animdata_from_id(id);
if ((adt == NULL) && (add))
@@ -93,32 +93,32 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde
/* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */
return NULL;
}
-
- /* try to find f-curve matching for this setting
+
+ /* try to find f-curve matching for this setting
* - add if not found and allowed to add one
* TODO: add auto-grouping support? how this works will need to be resolved
*/
fcu = list_find_fcurve(&adt->drivers, rna_path, array_index);
-
+
if ((fcu == NULL) && (add)) {
/* use default settings to make a F-Curve */
fcu = MEM_callocN(sizeof(FCurve), "FCurve");
-
+
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL;
-
+
/* store path - make copy, and store that */
fcu->rna_path = BLI_strdup(rna_path);
fcu->array_index = array_index;
-
+
/* if add is negative, don't init this data yet, since it will be filled in by the pasted driver */
if (add > 0) {
BezTriple *bezt;
size_t i;
-
+
/* add some new driver data */
fcu->driver = MEM_callocN(sizeof(ChannelDriver), "ChannelDriver");
-
+
/* F-Modifier or Keyframes? */
// FIXME: replace these magic numbers with defines
if (add == 2) {
@@ -129,27 +129,27 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde
add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu);
}
else {
- /* add 2 keyframes so that user has something to work with
+ /* add 2 keyframes so that user has something to work with
* - These are configured to 0,0 and 1,1 to give a 1-1 mapping
* which can be easily tweaked from there.
*/
insert_vert_fcurve(fcu, 0.0f, 0.0f, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST);
insert_vert_fcurve(fcu, 1.0f, 1.0f, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST);
-
+
/* configure this curve to extrapolate */
for (i = 0, bezt = fcu->bezt; (i < fcu->totvert) && bezt; i++, bezt++) {
bezt->h1 = bezt->h2 = HD_VECT;
}
-
+
fcu->extend = FCURVE_EXTRAPOLATE_LINEAR;
calchandles_fcurve(fcu);
}
}
-
+
/* just add F-Curve to end of driver list */
BLI_addtail(&adt->drivers, fcu);
}
-
+
/* return the F-Curve */
return fcu;
}
@@ -169,17 +169,17 @@ static int add_driver_with_target(
FCurve *fcu;
short add_mode = (flag & CREATEDRIVER_WITH_FMODIFIER) ? 2 : 1;
const char *prop_name = RNA_property_identifier(src_prop);
-
+
/* Create F-Curve with Driver */
fcu = verify_driver_fcurve(dst_id, dst_path, dst_index, add_mode);
-
+
if (fcu && fcu->driver) {
ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
-
+
/* Set the type of the driver */
driver->type = driver_type;
-
+
/* Set driver expression, so that the driver works out of the box
*
* The following checks define a bit of "autodetection magic" we use
@@ -187,7 +187,7 @@ static int add_driver_with_target(
* when faced with properties with different units.
*/
/* XXX: if we have N-1 mapping, should we include all those in the expression? */
- if ((RNA_property_unit(dst_prop) == PROP_UNIT_ROTATION) &&
+ if ((RNA_property_unit(dst_prop) == PROP_UNIT_ROTATION) &&
(RNA_property_unit(src_prop) != PROP_UNIT_ROTATION))
{
/* Rotation Destination: normal -> radians, so convert src to radians
@@ -207,7 +207,7 @@ static int add_driver_with_target(
/* Just a normal property without any unit problems */
BLI_strncpy(driver->expression, "var", sizeof(driver->expression));
}
-
+
/* Create a driver variable for the target
* - For transform properties, we want to automatically use "transform channel" instead
* (The only issue is with quat rotations vs euler channels...)
@@ -216,25 +216,25 @@ static int add_driver_with_target(
* when both the source and destinations are in same places.
*/
dvar = driver_add_new_variable(driver);
-
- if (ELEM(src_ptr->type, &RNA_Object, &RNA_PoseBone) &&
+
+ if (ELEM(src_ptr->type, &RNA_Object, &RNA_PoseBone) &&
(STREQ(prop_name, "location") || STREQ(prop_name, "scale") || STRPREFIX(prop_name, "rotation_")) &&
(src_ptr->data != dst_ptr->data))
{
/* Transform Channel */
DriverTarget *dtar;
-
+
driver_change_variable_type(dvar, DVAR_TYPE_TRANSFORM_CHAN);
dtar = &dvar->targets[0];
-
+
/* Bone or Object target? */
dtar->id = src_id;
dtar->idtype = GS(src_id->name);
-
+
if (src_ptr->type == &RNA_PoseBone) {
RNA_string_get(src_ptr, "name", dtar->pchan_name);
}
-
+
/* Transform channel depends on type */
if (STREQ(prop_name, "location")) {
if (src_index == 2)
@@ -267,11 +267,11 @@ static int add_driver_with_target(
else {
/* Single RNA Property */
DriverTarget *dtar = &dvar->targets[0];
-
+
/* ID is as-is */
dtar->id = src_id;
dtar->idtype = GS(src_id->name);
-
+
/* Need to make a copy of the path (or build one with array index built in) */
if (RNA_property_array_check(src_prop)) {
dtar->rna_path = BLI_sprintfN("%s[%d]", src_path, src_index);
@@ -281,7 +281,7 @@ static int add_driver_with_target(
}
}
}
-
+
/* set the done status */
return (fcu != NULL);
}
@@ -298,35 +298,35 @@ static int add_driver_with_target(
* - mapping_type: eCreateDriver_MappingTypes
*/
int ANIM_add_driver_with_target(
- ReportList *reports,
+ ReportList *reports,
ID *dst_id, const char dst_path[], int dst_index,
ID *src_id, const char src_path[], int src_index,
short flag, int driver_type, short mapping_type)
{
PointerRNA id_ptr, ptr;
PropertyRNA *prop;
-
+
PointerRNA id_ptr2, ptr2;
PropertyRNA *prop2;
int done_tot = 0;
-
+
/* validate pointers first - exit if failure */
RNA_id_pointer_create(dst_id, &id_ptr);
if (RNA_path_resolve_property(&id_ptr, dst_path, &ptr, &prop) == false) {
- BKE_reportf(reports, RPT_ERROR,
+ BKE_reportf(reports, RPT_ERROR,
"Could not add driver, as RNA path is invalid for the given ID (ID = %s, path = %s)",
dst_id->name, dst_path);
return 0;
}
-
+
RNA_id_pointer_create(src_id, &id_ptr2);
- if ((RNA_path_resolve_property(&id_ptr2, src_path, &ptr2, &prop2) == false) ||
+ if ((RNA_path_resolve_property(&id_ptr2, src_path, &ptr2, &prop2) == false) ||
(mapping_type == CREATEDRIVER_MAPPING_NONE))
{
/* No target - So, fall back to default method for adding a "simple" driver normally */
return ANIM_add_driver(reports, dst_id, dst_path, dst_index, flag | CREATEDRIVER_WITH_DEFAULT_DVAR, driver_type);
}
-
+
/* handle curve-property mappings based on mapping_type */
switch (mapping_type) {
case CREATEDRIVER_MAPPING_N_N: /* N-N - Try to match as much as possible, then use the first one */
@@ -334,35 +334,35 @@ int ANIM_add_driver_with_target(
/* Use the shorter of the two (to avoid out of bounds access) */
int dst_len = (RNA_property_array_check(prop)) ? RNA_property_array_length(&ptr, prop) : 1;
int src_len = (RNA_property_array_check(prop)) ? RNA_property_array_length(&ptr2, prop2) : 1;
-
+
int len = MIN2(dst_len, src_len);
int i;
-
+
for (i = 0; i < len; i++) {
done_tot += add_driver_with_target(reports, dst_id, dst_path, i, src_id, src_path, i, &ptr, prop, &ptr2, prop2, flag, driver_type);
}
break;
}
-
+
case CREATEDRIVER_MAPPING_1_N: /* 1-N - Specified target index for all */
default:
{
int len = (RNA_property_array_check(prop)) ? RNA_property_array_length(&ptr, prop) : 1;
int i;
-
+
for (i = 0; i < len; i++) {
done_tot += add_driver_with_target(reports, dst_id, dst_path, i, src_id, src_path, src_index, &ptr, prop, &ptr2, prop2, flag, driver_type);
}
break;
}
-
+
case CREATEDRIVER_MAPPING_1_1: /* 1-1 - Use the specified index (unless -1) */
{
done_tot = add_driver_with_target(reports, dst_id, dst_path, dst_index, src_id, src_path, src_index, &ptr, prop, &ptr2, prop2, flag, driver_type);
break;
}
}
-
+
/* done */
return done_tot;
}
@@ -373,22 +373,22 @@ int ANIM_add_driver_with_target(
* Add a new driver for the specified property on the given ID block
*/
int ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short flag, int type)
-{
+{
PointerRNA id_ptr, ptr;
PropertyRNA *prop;
FCurve *fcu;
int array_index_max;
int done_tot = 0;
-
+
/* validate pointer first - exit if failure */
RNA_id_pointer_create(id, &id_ptr);
if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop) == false) {
- BKE_reportf(reports, RPT_ERROR,
+ BKE_reportf(reports, RPT_ERROR,
"Could not add driver, as RNA path is invalid for the given ID (ID = %s, path = %s)",
id->name, rna_path);
return 0;
}
-
+
/* key entire array convenience method */
if (array_index == -1) {
array_index_max = RNA_property_array_length(&ptr, prop);
@@ -396,56 +396,66 @@ int ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int arra
}
else
array_index_max = array_index;
-
+
/* maximum index should be greater than the start index */
if (array_index == array_index_max)
array_index_max += 1;
-
+
/* will only loop once unless the array index was -1 */
for (; array_index < array_index_max; array_index++) {
short add_mode = (flag & CREATEDRIVER_WITH_FMODIFIER) ? 2 : 1;
-
+
/* create F-Curve with Driver */
fcu = verify_driver_fcurve(id, rna_path, array_index, add_mode);
-
+
if (fcu && fcu->driver) {
ChannelDriver *driver = fcu->driver;
-
+
/* set the type of the driver */
driver->type = type;
-
- /* creating drivers for buttons will create the driver(s) with type
+
+ /* Creating drivers for buttons will create the driver(s) with type
* "scripted expression" so that their values won't be lost immediately,
* so here we copy those values over to the driver's expression
+ *
+ * If the "default dvar" option (for easier UI setup of drivers) is provided,
+ * include "var" in the expressions too, so that the user doesn't have to edit
+ * it to get something to happen. It should be fine to just add it to the default
+ * value, so that we get both in the expression, even if it's a bit more confusing
+ * that way...
*/
if (type == DRIVER_TYPE_PYTHON) {
PropertyType proptype = RNA_property_type(prop);
int array = RNA_property_array_length(&ptr, prop);
+ const char *dvar_prefix = (flag & CREATEDRIVER_WITH_DEFAULT_DVAR) ? "var + " : "";
char *expression = driver->expression;
int val, maxlen = sizeof(driver->expression);
float fval;
-
+
if (proptype == PROP_BOOLEAN) {
if (!array) val = RNA_property_boolean_get(&ptr, prop);
else val = RNA_property_boolean_get_index(&ptr, prop, array_index);
-
- BLI_strncpy(expression, (val) ? "True" : "False", maxlen);
+
+ BLI_snprintf(expression, maxlen, "%s%s", dvar_prefix, (val) ? "True" : "False");
}
else if (proptype == PROP_INT) {
if (!array) val = RNA_property_int_get(&ptr, prop);
else val = RNA_property_int_get_index(&ptr, prop, array_index);
-
- BLI_snprintf(expression, maxlen, "%d", val);
+
+ BLI_snprintf(expression, maxlen, "%s%d", dvar_prefix, val);
}
else if (proptype == PROP_FLOAT) {
if (!array) fval = RNA_property_float_get(&ptr, prop);
else fval = RNA_property_float_get_index(&ptr, prop, array_index);
-
- BLI_snprintf(expression, maxlen, "%.3f", fval);
+
+ BLI_snprintf(expression, maxlen, "%s%.3f", dvar_prefix, fval);
+ }
+ else if (flag & CREATEDRIVER_WITH_DEFAULT_DVAR) {
+ BLI_strncpy(expression, "var", maxlen);
}
}
-
- /* for easier setup of drivers from UI, a driver variable should be
+
+ /* for easier setup of drivers from UI, a driver variable should be
* added if flag is set (UI calls only)
*/
if (flag & CREATEDRIVER_WITH_DEFAULT_DVAR) {
@@ -456,11 +466,11 @@ int ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int arra
driver_change_variable_type(dvar, DVAR_TYPE_TRANSFORM_CHAN);
}
}
-
+
/* set the done status */
done_tot += (fcu != NULL);
}
-
+
/* done */
return done_tot;
}
@@ -473,29 +483,29 @@ bool ANIM_remove_driver(ReportList *UNUSED(reports), ID *id, const char rna_path
AnimData *adt;
FCurve *fcu;
bool success = false;
-
+
/* we don't check the validity of the path here yet, but it should be ok... */
adt = BKE_animdata_from_id(id);
-
+
if (adt) {
if (array_index == -1) {
/* step through all drivers, removing all of those with the same base path */
FCurve *fcu_iter = adt->drivers.first;
-
+
while ((fcu = iter_step_fcurve(fcu_iter, rna_path)) != NULL) {
/* store the next fcurve for looping */
fcu_iter = fcu->next;
-
+
/* remove F-Curve from driver stack, then free it */
BLI_remlink(&adt->drivers, fcu);
free_fcurve(fcu);
-
+
/* done successfully */
success = true;
}
}
else {
- /* find the matching driver and remove it only
+ /* find the matching driver and remove it only
* Note: here is one of the places where we don't want new F-Curve + Driver added!
* so 'add' var must be 0
*/
@@ -503,7 +513,7 @@ bool ANIM_remove_driver(ReportList *UNUSED(reports), ID *id, const char rna_path
if (fcu) {
BLI_remlink(&adt->drivers, fcu);
free_fcurve(fcu);
-
+
success = true;
}
}
@@ -543,7 +553,7 @@ bool ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int ar
PointerRNA id_ptr, ptr;
PropertyRNA *prop;
FCurve *fcu;
-
+
/* validate pointer first - exit if failure */
RNA_id_pointer_create(id, &id_ptr);
if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop) == false) {
@@ -552,13 +562,13 @@ bool ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int ar
id->name, rna_path);
return 0;
}
-
+
/* try to get F-Curve with Driver */
fcu = verify_driver_fcurve(id, rna_path, array_index, 0);
-
+
/* clear copy/paste buffer first (for consistency with other copy/paste buffers) */
ANIM_drivers_copybuf_free();
-
+
/* copy this to the copy/paste buf if it exists */
if (fcu && fcu->driver) {
/* make copies of some info such as the rna_path, then clear this info from the F-Curve temporarily
@@ -566,31 +576,31 @@ bool ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int ar
*/
char *tmp_path = fcu->rna_path;
fcu->rna_path = NULL;
-
+
/* make a copy of the F-Curve with */
channeldriver_copypaste_buf = copy_fcurve(fcu);
-
+
/* restore the path */
fcu->rna_path = tmp_path;
-
+
/* copied... */
return 1;
}
-
+
/* done */
return 0;
}
/* Main Driver Management API calls:
* Add a new driver for the specified property on the given ID block or replace an existing one
- * with the driver + driver-curve data from the buffer
+ * with the driver + driver-curve data from the buffer
*/
bool ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag))
-{
+{
PointerRNA id_ptr, ptr;
PropertyRNA *prop;
FCurve *fcu;
-
+
/* validate pointer first - exit if failure */
RNA_id_pointer_create(id, &id_ptr);
if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop) == false) {
@@ -599,35 +609,35 @@ bool ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int a
id->name, rna_path);
return 0;
}
-
+
/* if the buffer is empty, cannot paste... */
if (channeldriver_copypaste_buf == NULL) {
BKE_report(reports, RPT_ERROR, "Paste driver: no driver to paste");
return 0;
}
-
+
/* create Driver F-Curve, but without data which will be copied across... */
fcu = verify_driver_fcurve(id, rna_path, array_index, -1);
-
+
if (fcu) {
- /* copy across the curve data from the buffer curve
+ /* copy across the curve data from the buffer curve
* NOTE: this step needs care to not miss new settings
*/
/* keyframes/samples */
fcu->bezt = MEM_dupallocN(channeldriver_copypaste_buf->bezt);
fcu->fpt = MEM_dupallocN(channeldriver_copypaste_buf->fpt);
fcu->totvert = channeldriver_copypaste_buf->totvert;
-
+
/* modifiers */
copy_fmodifiers(&fcu->modifiers, &channeldriver_copypaste_buf->modifiers);
-
+
/* extrapolation mode */
fcu->extend = channeldriver_copypaste_buf->extend;
-
+
/* the 'juicy' stuff - the driver */
fcu->driver = fcurve_copy_driver(channeldriver_copypaste_buf->driver);
}
-
+
/* done */
return (fcu != NULL);
}
@@ -644,14 +654,14 @@ void ANIM_driver_vars_copybuf_free(void)
/* Free the driver variables kept in the buffer */
if (driver_vars_copybuf.first) {
DriverVar *dvar, *dvarn;
-
+
/* Free variables (and any data they use) */
for (dvar = driver_vars_copybuf.first; dvar; dvar = dvarn) {
dvarn = dvar->next;
driver_free_variable(&driver_vars_copybuf, dvar);
}
}
-
+
BLI_listbase_clear(&driver_vars_copybuf);
}
@@ -671,18 +681,18 @@ bool ANIM_driver_vars_copy(ReportList *reports, FCurve *fcu)
BKE_report(reports, RPT_ERROR, "No driver to copy variables from");
return false;
}
-
+
if (BLI_listbase_is_empty(&fcu->driver->variables)) {
BKE_report(reports, RPT_ERROR, "Driver has no variables to copy");
return false;
}
-
+
/* clear buffer */
ANIM_driver_vars_copybuf_free();
-
+
/* copy over the variables */
driver_variables_copy(&driver_vars_copybuf, &fcu->driver->variables);
-
+
return (BLI_listbase_is_empty(&driver_vars_copybuf) == false);
}
@@ -691,55 +701,55 @@ bool ANIM_driver_vars_paste(ReportList *reports, FCurve *fcu, bool replace)
{
ChannelDriver *driver = (fcu) ? fcu->driver : NULL;
ListBase tmp_list = {NULL, NULL};
-
+
/* sanity checks */
if (BLI_listbase_is_empty(&driver_vars_copybuf)) {
BKE_report(reports, RPT_ERROR, "No driver variables in clipboard to paste");
return false;
}
-
+
if (ELEM(NULL, fcu, fcu->driver)) {
BKE_report(reports, RPT_ERROR, "Cannot paste driver variables without a driver");
return false;
}
-
+
/* 1) Make a new copy of the variables in the buffer - these will get pasted later... */
driver_variables_copy(&tmp_list, &driver_vars_copybuf);
-
+
/* 2) Prepare destination array */
if (replace) {
DriverVar *dvar, *dvarn;
-
+
/* Free all existing vars first - We aren't retaining anything */
for (dvar = driver->variables.first; dvar; dvar = dvarn) {
dvarn = dvar->next;
driver_free_variable_ex(driver, dvar);
}
-
+
BLI_listbase_clear(&driver->variables);
}
-
+
/* 3) Add new vars */
if (driver->variables.last) {
DriverVar *last = driver->variables.last;
DriverVar *first = tmp_list.first;
-
+
last->next = first;
first->prev = last;
-
+
driver->variables.last = tmp_list.last;
}
else {
driver->variables.first = tmp_list.first;
driver->variables.last = tmp_list.last;
}
-
+
#ifdef WITH_PYTHON
/* since driver variables are cached, the expression needs re-compiling too */
if (driver->type == DRIVER_TYPE_PYTHON)
driver->flag |= DRIVER_FLAG_RENAMEVAR;
#endif
-
+
return true;
}
@@ -756,10 +766,10 @@ EnumPropertyItem prop_driver_create_mapping_types[] = {
"Drive all components of this property using the target picked"},
{CREATEDRIVER_MAPPING_1_1, "DIRECT", 0, "Single from Target",
"Drive this component of this property using the target picked"},
-
+
{CREATEDRIVER_MAPPING_N_N, "MATCH", ICON_COLOR, "Match Indices",
"Create drivers for each pair of corresponding elements"},
-
+
{CREATEDRIVER_MAPPING_NONE_ALL, "NONE_ALL", ICON_HAND, "Manually Create Later",
"Create drivers for all properties without assigning any targets yet"},
{CREATEDRIVER_MAPPING_NONE, "NONE_SINGLE", 0, "Manually Create Later (Single)",
@@ -772,21 +782,21 @@ static const EnumPropertyItem *driver_mapping_type_itemsf(bContext *C, PointerRN
{
EnumPropertyItem *input = prop_driver_create_mapping_types;
EnumPropertyItem *item = NULL;
-
+
PointerRNA ptr = {{NULL}};
PropertyRNA *prop = NULL;
int index;
-
+
int totitem = 0;
-
+
if (!C) /* needed for docs */
return prop_driver_create_mapping_types;
-
+
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
-
+
if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
const bool is_array = RNA_property_array_check(prop);
-
+
while (input->identifier) {
if (ELEM(input->value, CREATEDRIVER_MAPPING_1_1, CREATEDRIVER_MAPPING_NONE) || (is_array)) {
RNA_enum_item_add(&item, &totitem, input);
@@ -798,22 +808,22 @@ static const EnumPropertyItem *driver_mapping_type_itemsf(bContext *C, PointerRN
/* We need at least this one! */
RNA_enum_items_add_value(&item, &totitem, input, CREATEDRIVER_MAPPING_NONE);
}
-
+
RNA_enum_item_end(&item, &totitem);
-
+
*r_free = true;
return item;
}
-/* Add Driver Button Operator ------------------------ */
+/* Add Driver (With Menu) Button Operator ------------------------ */
static int add_driver_button_poll(bContext *C)
{
PointerRNA ptr = {{NULL}};
PropertyRNA *prop = NULL;
int index;
-
+
/* this operator can only run if there's a property button active, and it can be animated */
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
return (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop));
@@ -826,28 +836,28 @@ static int add_driver_button_none(bContext *C, wmOperator *op, short mapping_typ
PropertyRNA *prop = NULL;
int index;
int success = 0;
-
+
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
-
+
if (mapping_type == CREATEDRIVER_MAPPING_NONE_ALL)
index = -1;
-
+
if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL);
short flags = CREATEDRIVER_WITH_DEFAULT_DVAR;
-
+
if (path) {
success += ANIM_add_driver(op->reports, ptr.id.data, path, index, flags, DRIVER_TYPE_PYTHON);
MEM_freeN(path);
}
}
-
+
if (success) {
/* send updates */
UI_context_update_anim_flag(C);
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX
-
+
return OPERATOR_FINISHED;
}
else {
@@ -855,7 +865,7 @@ static int add_driver_button_none(bContext *C, wmOperator *op, short mapping_typ
}
}
-static int add_driver_button_exec(bContext *C, wmOperator *op)
+static int add_driver_button_menu_exec(bContext *C, wmOperator *op)
{
short mapping_type = RNA_enum_get(op->ptr, "mapping_type");
if (ELEM(mapping_type, CREATEDRIVER_MAPPING_NONE, CREATEDRIVER_MAPPING_NONE_ALL)) {
@@ -865,22 +875,22 @@ static int add_driver_button_exec(bContext *C, wmOperator *op)
else {
/* Create Driver using Eyedropper */
wmOperatorType *ot = WM_operatortype_find("UI_OT_eyedropper_driver", true);
-
+
/* XXX: We assume that it's fine to use the same set of properties, since they're actually the same... */
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, op->ptr);
-
+
return OPERATOR_FINISHED;
}
}
/* Show menu or create drivers */
-static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+static int add_driver_button_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
PropertyRNA *prop;
-
+
if ((prop = RNA_struct_find_property(op->ptr, "mapping_type")) && RNA_property_is_set(op->ptr, prop)) {
/* Mapping Type is Set - Directly go into creating drivers */
- return add_driver_button_exec(C, op);
+ return add_driver_button_menu_exec(C, op);
}
else {
/* Show menu */
@@ -890,30 +900,80 @@ static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent *
}
}
-void ANIM_OT_driver_button_add(wmOperatorType *ot)
+static void UNUSED_FUNCTION(ANIM_OT_driver_button_add_menu)(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Add Driver";
- ot->idname = "ANIM_OT_driver_button_add";
+ ot->name = "Add Driver Menu";
+ ot->idname = "ANIM_OT_driver_button_add_menu";
ot->description = "Add driver(s) for the property(s) represented by the highlighted button";
-
+
/* callbacks */
- /* NOTE: No exec, as we need all these to use the current context info
- * (especially the eyedropper, which is interactive)
- */
- ot->invoke = add_driver_button_invoke;
- ot->exec = add_driver_button_exec;
+ ot->invoke = add_driver_button_menu_invoke;
+ ot->exec = add_driver_button_menu_exec;
ot->poll = add_driver_button_poll;
-
+
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "mapping_type", prop_driver_create_mapping_types, 0,
"Mapping Type", "Method used to match target and driven properties");
RNA_def_enum_funcs(ot->prop, driver_mapping_type_itemsf);
}
+/* Add Driver Button Operator ------------------------ */
+
+static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ PointerRNA ptr = {{NULL}};
+ PropertyRNA *prop = NULL;
+ int index;
+
+ /* try to find driver using property retrieved from UI */
+ UI_context_active_but_prop_get(C, &ptr, &prop, &index);
+
+ if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
+ /* 1) Create a new "empty" driver for this property */
+ char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL);
+ short flags = CREATEDRIVER_WITH_DEFAULT_DVAR;
+ short success = 0;
+
+ if (path) {
+ success += ANIM_add_driver(op->reports, ptr.id.data, path, index, flags, DRIVER_TYPE_PYTHON);
+ MEM_freeN(path);
+ }
+
+ if (success) {
+ /* send updates */
+ UI_context_update_anim_flag(C);
+ DEG_relations_tag_update(CTX_data_main(C));
+ WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL);
+ }
+
+ /* 2) Show editing panel for setting up this driver */
+ /* TODO: Use a different one from the editing popever, so we can have the single/all toggle? */
+ UI_popover_panel_invoke(C, SPACE_IPO, RGN_TYPE_UI, "GRAPH_PT_drivers_popover", true, op->reports);
+ }
+
+ return OPERATOR_INTERFACE;
+}
+
+void ANIM_OT_driver_button_add(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Add Driver";
+ ot->idname = "ANIM_OT_driver_button_add";
+ ot->description = "Add driver for the property under the cursor";
+
+ /* callbacks */
+ /* NOTE: No exec, as we need all these to use the current context info */
+ ot->invoke = add_driver_button_invoke;
+ ot->poll = add_driver_button_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
+}
+
/* Remove Driver Button Operator ------------------------ */
static int remove_driver_button_exec(bContext *C, wmOperator *op)
@@ -923,30 +983,30 @@ static int remove_driver_button_exec(bContext *C, wmOperator *op)
short success = 0;
int index;
const bool all = RNA_boolean_get(op->ptr, "all");
-
+
/* try to find driver using property retrieved from UI */
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
-
+
if (all)
index = -1;
-
+
if (ptr.id.data && ptr.data && prop) {
char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL);
-
+
if (path) {
success = ANIM_remove_driver(op->reports, ptr.id.data, path, index, 0);
MEM_freeN(path);
}
}
-
+
if (success) {
/* send updates */
UI_context_update_anim_flag(C);
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX
}
-
+
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -956,11 +1016,11 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot)
ot->name = "Remove Driver";
ot->idname = "ANIM_OT_driver_button_remove";
ot->description = "Remove the driver(s) for the property(s) connected represented by the highlighted button";
-
+
/* callbacks */
- ot->exec = remove_driver_button_exec;
+ ot->exec = remove_driver_button_exec;
//op->poll = ??? // TODO: need to have some driver to be able to do this...
-
+
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -975,14 +1035,10 @@ static int edit_driver_button_exec(bContext *C, wmOperator *op)
PointerRNA ptr = {{NULL}};
PropertyRNA *prop = NULL;
int index;
- const bool all = 0; // RNA_boolean_get(op->ptr, "all");
/* try to find driver using property retrieved from UI */
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
- if (all)
- index = -1;
-
if (ptr.id.data && ptr.data && prop) {
UI_popover_panel_invoke(C, SPACE_IPO, RGN_TYPE_UI, "GRAPH_PT_drivers_popover", true, op->reports);
}
@@ -996,16 +1052,13 @@ void ANIM_OT_driver_button_edit(wmOperatorType *ot)
ot->name = "Edit Driver";
ot->idname = "ANIM_OT_driver_button_edit";
ot->description = "Edit the drivers for the property connected represented by the highlighted button";
-
+
/* callbacks */
ot->exec = edit_driver_button_exec;
//op->poll = ??? // TODO: need to have some driver to be able to do this...
-
+
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
-
- /* properties */
- //RNA_def_boolean(ot->srna, "all", 1, "All", "Edit drivers for all elements of the array");
}
/* Copy Driver Button Operator ------------------------ */
@@ -1016,23 +1069,23 @@ static int copy_driver_button_exec(bContext *C, wmOperator *op)
PropertyRNA *prop = NULL;
short success = 0;
int index;
-
+
/* try to create driver using property retrieved from UI */
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
-
+
if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL);
-
+
if (path) {
/* only copy the driver for the button that this was involved for */
success = ANIM_copy_driver(op->reports, ptr.id.data, path, index, 0);
-
+
UI_context_update_anim_flag(C);
-
+
MEM_freeN(path);
}
}
-
+
/* since we're just copying, we don't really need to do anything else...*/
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -1043,11 +1096,11 @@ void ANIM_OT_copy_driver_button(wmOperatorType *ot)
ot->name = "Copy Driver";
ot->idname = "ANIM_OT_copy_driver_button";
ot->description = "Copy the driver for the highlighted button";
-
+
/* callbacks */
- ot->exec = copy_driver_button_exec;
+ ot->exec = copy_driver_button_exec;
//op->poll = ??? // TODO: need to have some driver to be able to do this...
-
+
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
}
@@ -1060,28 +1113,28 @@ static int paste_driver_button_exec(bContext *C, wmOperator *op)
PropertyRNA *prop = NULL;
short success = 0;
int index;
-
+
/* try to create driver using property retrieved from UI */
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
-
+
if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL);
-
+
if (path) {
/* only copy the driver for the button that this was involved for */
success = ANIM_paste_driver(op->reports, ptr.id.data, path, index, 0);
-
+
UI_context_update_anim_flag(C);
-
+
DEG_relations_tag_update(CTX_data_main(C));
DEG_id_tag_update(ptr.id.data, OB_RECALC_OB | OB_RECALC_DATA);
-
+
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); // XXX
-
+
MEM_freeN(path);
}
}
-
+
/* since we're just copying, we don't really need to do anything else...*/
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -1092,11 +1145,11 @@ void ANIM_OT_paste_driver_button(wmOperatorType *ot)
ot->name = "Paste Driver";
ot->idname = "ANIM_OT_paste_driver_button";
ot->description = "Paste the driver in the copy/paste buffer for the highlighted button";
-
+
/* callbacks */
- ot->exec = paste_driver_button_exec;
+ ot->exec = paste_driver_button_exec;
//op->poll = ??? // TODO: need to have some driver to be able to do this...
-
+
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
}
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index 8106be79521..951dcc2dddf 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation, Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
@@ -30,14 +30,14 @@
/* User-Interface Stuff for F-Modifiers:
- * This file defines the (C-Coded) templates + editing callbacks needed
+ * This file defines the (C-Coded) templates + editing callbacks needed
* by the interface stuff or F-Modifiers, as used by F-Curves in the Graph Editor,
* and NLA-Strips in the NLA Editor.
*
* Copy/Paste Buffer for F-Modifiers:
- * For now, this is also defined in this file so that it can be shared between the
+ * For now, this is also defined in this file so that it can be shared between the
*/
-
+
#include <string.h>
#include "DNA_anim_types.h"
@@ -79,7 +79,7 @@ static void validate_fmodifier_cb(bContext *UNUSED(C), void *fcm_v, void *UNUSED
{
FModifier *fcm = (FModifier *)fcm_v;
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
-
+
/* call the verify callback on the modifier if applicable */
if (fmi && fmi->verify_data)
fmi->verify_data(fcm);
@@ -90,19 +90,19 @@ static void delete_fmodifier_cb(bContext *C, void *fmods_v, void *fcm_v)
{
ListBase *modifiers = (ListBase *)fmods_v;
FModifier *fcm = (FModifier *)fcm_v;
-
+
/* remove the given F-Modifier from the active modifier-stack */
remove_fmodifier(modifiers, fcm);
ED_undo_push(C, "Delete F-Curve Modifier");
-
+
/* send notifiers */
- // XXX for now, this is the only way to get updates in all the right places... but would be nice to have a special one in this case
+ // XXX for now, this is the only way to get updates in all the right places... but would be nice to have a special one in this case
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
/* --------------- */
-
+
/* draw settings for generator modifier */
static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, short width)
{
@@ -112,20 +112,20 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s
uiBut *but;
PointerRNA ptr;
short bwidth = width - 1.5 * UI_UNIT_X; /* max button width */
-
+
/* init the RNA-pointer */
RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr);
-
+
/* basic settings (backdrop + mode selector + some padding) */
/* col = uiLayoutColumn(layout, true); */ /* UNUSED */
block = uiLayoutGetBlock(layout);
UI_block_align_begin(block);
but = uiDefButR(block, UI_BTYPE_MENU, B_FMODIFIER_REDRAW, NULL, 0, 0, bwidth, UI_UNIT_Y, &ptr, "mode", -1, 0, 0, -1, -1, NULL);
UI_but_func_set(but, validate_fmodifier_cb, fcm, NULL);
-
+
uiDefButR(block, UI_BTYPE_TOGGLE, B_FMODIFIER_REDRAW, NULL, 0, 0, bwidth, UI_UNIT_Y, &ptr, "use_additive", -1, 0, 0, -1, -1, NULL);
UI_block_align_end(block);
-
+
/* now add settings for individual modes */
switch (data->mode) {
case FCM_GENERATOR_POLYNOMIAL: /* polynomial expression */
@@ -135,7 +135,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s
char xval[32];
unsigned int i;
int maxXWidth;
-
+
/* draw polynomial order selector */
row = uiLayoutRow(layout, false);
block = uiLayoutGetBlock(row);
@@ -143,8 +143,8 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s
&data->poly_order, 1, 100, 0, 0,
TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)"));
UI_but_func_set(but, validate_fmodifier_cb, fcm, NULL);
-
-
+
+
/* calculate maximum width of label for "x^n" labels */
if (data->arraysize > 2) {
BLI_snprintf(xval, sizeof(xval), "x^%u", data->arraysize);
@@ -155,11 +155,11 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s
/* basic size (just "x") */
maxXWidth = UI_fontstyle_string_width(fstyle, "x") + 0.5 * UI_UNIT_X;
}
-
+
/* draw controls for each coefficient and a + sign at end of row */
row = uiLayoutRow(layout, true);
block = uiLayoutGetBlock(row);
-
+
cp = data->coefficients;
for (i = 0; (i < data->arraysize) && (cp); i++, cp++) {
/* To align with first line... */
@@ -167,11 +167,11 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s
uiDefBut(block, UI_BTYPE_LABEL, 1, " ", 0, 0, 2 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
else
uiDefBut(block, UI_BTYPE_LABEL, 1, "y =", 0, 0, 2 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
-
+
/* coefficient */
uiDefButF(block, UI_BTYPE_NUM, B_FMODIFIER_REDRAW, "", 0, 0, bwidth / 2, UI_UNIT_Y, cp, -UI_FLT_MAX, UI_FLT_MAX,
10, 3, TIP_("Coefficient for polynomial"));
-
+
/* 'x' param (and '+' if necessary) */
if (i == 0)
BLI_strncpy(xval, "", sizeof(xval));
@@ -180,10 +180,10 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s
else
BLI_snprintf(xval, sizeof(xval), "x^%u", i);
uiDefBut(block, UI_BTYPE_LABEL, 1, xval, 0, 0, maxXWidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, TIP_("Power of x"));
-
+
if ( (i != (data->arraysize - 1)) || ((i == 0) && data->arraysize == 2) ) {
uiDefBut(block, UI_BTYPE_LABEL, 1, "+", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
-
+
/* next coefficient on a new row */
row = uiLayoutRow(layout, true);
block = uiLayoutGetBlock(row);
@@ -195,12 +195,12 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s
}
break;
}
-
+
case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* Factorized polynomial expression */
{
float *cp = NULL;
unsigned int i;
-
+
/* draw polynomial order selector */
row = uiLayoutRow(layout, false);
block = uiLayoutGetBlock(row);
@@ -208,12 +208,12 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s
&data->poly_order, 1, 100, 0, 0,
TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)"));
UI_but_func_set(but, validate_fmodifier_cb, fcm, NULL);
-
-
+
+
/* draw controls for each pair of coefficients */
row = uiLayoutRow(layout, true);
block = uiLayoutGetBlock(row);
-
+
cp = data->coefficients;
for (i = 0; (i < data->poly_order) && (cp); i++, cp += 2) {
/* To align with first line */
@@ -223,25 +223,25 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s
uiDefBut(block, UI_BTYPE_LABEL, 1, "y =", 0, 0, 2.5 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
/* opening bracket */
uiDefBut(block, UI_BTYPE_LABEL, 1, "(", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
-
+
/* coefficients */
uiDefButF(block, UI_BTYPE_NUM, B_FMODIFIER_REDRAW, "", 0, 0, 5 * UI_UNIT_X, UI_UNIT_Y, cp, -UI_FLT_MAX, UI_FLT_MAX,
10, 3, TIP_("Coefficient of x"));
-
+
uiDefBut(block, UI_BTYPE_LABEL, 1, "x +", 0, 0, 2 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
-
+
uiDefButF(block, UI_BTYPE_NUM, B_FMODIFIER_REDRAW, "", 0, 0, 5 * UI_UNIT_X, UI_UNIT_Y, cp + 1, -UI_FLT_MAX, UI_FLT_MAX,
10, 3, TIP_("Second coefficient"));
-
+
/* closing bracket and multiplication sign */
if ( (i != (data->poly_order - 1)) || ((i == 0) && data->poly_order == 2) ) {
uiDefBut(block, UI_BTYPE_LABEL, 1, ") \xc3\x97", 0, 0, 2 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
-
+
/* set up new row for the next pair of coefficients */
row = uiLayoutRow(layout, true);
block = uiLayoutGetBlock(row);
}
- else
+ else
uiDefBut(block, UI_BTYPE_LABEL, 1, ") ", 0, 0, 2 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
}
break;
@@ -256,10 +256,10 @@ static void draw_modifier__fn_generator(uiLayout *layout, ID *id, FModifier *fcm
{
uiLayout *col;
PointerRNA ptr;
-
+
/* init the RNA-pointer */
RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr);
-
+
/* add the settings */
col = uiLayoutColumn(layout, true);
uiItemR(col, &ptr, "function_type", 0, "", ICON_NONE);
@@ -279,21 +279,21 @@ static void draw_modifier__cycles(uiLayout *layout, ID *id, FModifier *fcm, shor
{
uiLayout *split, *col;
PointerRNA ptr;
-
+
/* init the RNA-pointer */
RNA_pointer_create(id, &RNA_FModifierCycles, fcm, &ptr);
-
- /* split into 2 columns
+
+ /* split into 2 columns
* NOTE: the mode comboboxes shouldn't get labels, otherwise there isn't enough room
*/
split = uiLayoutSplit(layout, 0.5f, false);
-
+
/* before range */
col = uiLayoutColumn(split, true);
uiItemL(col, IFACE_("Before:"), ICON_NONE);
uiItemR(col, &ptr, "mode_before", 0, "", ICON_NONE);
uiItemR(col, &ptr, "cycles_before", 0, NULL, ICON_NONE);
-
+
/* after range */
col = uiLayoutColumn(split, true);
uiItemL(col, IFACE_("After:"), ICON_NONE);
@@ -308,22 +308,22 @@ static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short
{
uiLayout *split, *col;
PointerRNA ptr;
-
+
/* init the RNA-pointer */
RNA_pointer_create(id, &RNA_FModifierNoise, fcm, &ptr);
-
+
/* blending mode */
uiItemR(layout, &ptr, "blend_type", 0, NULL, ICON_NONE);
-
+
/* split into 2 columns */
split = uiLayoutSplit(layout, 0.5f, false);
-
+
/* col 1 */
col = uiLayoutColumn(split, false);
uiItemR(col, &ptr, "scale", 0, NULL, ICON_NONE);
uiItemR(col, &ptr, "strength", 0, NULL, ICON_NONE);
uiItemR(col, &ptr, "offset", 0, NULL, ICON_NONE);
-
+
/* col 2 */
col = uiLayoutColumn(split, false);
uiItemR(col, &ptr, "phase", 0, NULL, ICON_NONE);
@@ -337,46 +337,46 @@ static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void *UNUSED(ar
FMod_Envelope *env = (FMod_Envelope *)fcm_dv;
FCM_EnvelopeData *fedn;
FCM_EnvelopeData fed;
-
+
/* init template data */
fed.min = -1.0f;
fed.max = 1.0f;
fed.time = (float)scene->r.cfra; // XXX make this int for ease of use?
fed.f1 = fed.f2 = 0;
-
+
/* check that no data exists for the current frame... */
if (env->data) {
bool exists;
int i = BKE_fcm_envelope_find_index(env->data, (float)(scene->r.cfra), env->totvert, &exists);
-
+
/* binarysearch_...() will set exists by default to 0, so if it is non-zero, that means that the point exists already */
if (exists)
return;
-
+
/* add new */
fedn = MEM_callocN((env->totvert + 1) * sizeof(FCM_EnvelopeData), "FCM_EnvelopeData");
-
+
/* add the points that should occur before the point to be pasted */
if (i > 0)
memcpy(fedn, env->data, i * sizeof(FCM_EnvelopeData));
-
+
/* add point to paste at index i */
*(fedn + i) = fed;
-
+
/* add the points that occur after the point to be pasted */
- if (i < env->totvert)
+ if (i < env->totvert)
memcpy(fedn + i + 1, env->data + i, (env->totvert - i) * sizeof(FCM_EnvelopeData));
-
+
/* replace (+ free) old with new */
MEM_freeN(env->data);
env->data = fedn;
-
+
env->totvert++;
}
else {
env->data = MEM_callocN(sizeof(FCM_EnvelopeData), "FCM_EnvelopeData");
*(env->data) = fed;
-
+
env->totvert = 1;
}
}
@@ -388,7 +388,7 @@ static void fmod_envelope_deletepoint_cb(bContext *UNUSED(C), void *fcm_dv, void
FMod_Envelope *env = (FMod_Envelope *)fcm_dv;
FCM_EnvelopeData *fedn;
int index = GET_INT_FROM_POINTER(ind_v);
-
+
/* check that no data exists for the current frame... */
if (env->totvert > 1) {
/* allocate a new smaller array */
@@ -396,7 +396,7 @@ static void fmod_envelope_deletepoint_cb(bContext *UNUSED(C), void *fcm_dv, void
memcpy(fedn, env->data, sizeof(FCM_EnvelopeData) * (index));
memcpy(fedn + index, env->data + (index + 1), sizeof(FCM_EnvelopeData) * ((env->totvert - index) - 1));
-
+
/* free old array, and set the new */
MEM_freeN(env->data);
env->data = fedn;
@@ -422,10 +422,10 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh
uiBut *but;
PointerRNA ptr;
int i;
-
+
/* init the RNA-pointer */
RNA_pointer_create(id, &RNA_FModifierEnvelope, fcm, &ptr);
-
+
/* general settings */
col = uiLayoutColumn(layout, true);
uiItemL(col, IFACE_("Envelope:"), ICON_NONE);
@@ -440,24 +440,24 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh
* the current way is far too cramped */
row = uiLayoutRow(layout, false);
block = uiLayoutGetBlock(row);
-
+
uiDefBut(block, UI_BTYPE_LABEL, 1, IFACE_("Control Points:"), 0, 0, 7.5 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
-
+
but = uiDefBut(block, UI_BTYPE_BUT, B_FMODIFIER_REDRAW, IFACE_("Add Point"), 0, 0, 7.5 * UI_UNIT_X, UI_UNIT_Y,
NULL, 0, 0, 0, 0, TIP_("Add a new control-point to the envelope on the current frame"));
UI_but_func_set(but, fmod_envelope_addpoint_cb, env, NULL);
-
+
/* control points list */
for (i = 0, fed = env->data; i < env->totvert; i++, fed++) {
/* get a new row to operate on */
row = uiLayoutRow(layout, true);
block = uiLayoutGetBlock(row);
-
+
UI_block_align_begin(block);
but = uiDefButF(block, UI_BTYPE_NUM, B_FMODIFIER_REDRAW, IFACE_("Fra:"), 0, 0, 4.5 * UI_UNIT_X, UI_UNIT_Y,
&fed->time, -MAXFRAMEF, MAXFRAMEF, 10, 1, TIP_("Frame that envelope point occurs"));
UI_but_func_set(but, validate_fmodifier_cb, fcm, NULL);
-
+
uiDefButF(block, UI_BTYPE_NUM, B_FMODIFIER_REDRAW, IFACE_("Min:"), 0, 0, 5 * UI_UNIT_X, UI_UNIT_Y,
&fed->min, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, TIP_("Minimum bound of envelope at this point"));
uiDefButF(block, UI_BTYPE_NUM, B_FMODIFIER_REDRAW, IFACE_("Max:"), 0, 0, 5 * UI_UNIT_X, UI_UNIT_Y,
@@ -477,40 +477,40 @@ static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, shor
{
uiLayout *split, *col /* , *row */ /* UNUSED */;
PointerRNA ptr;
-
+
/* init the RNA-pointer */
RNA_pointer_create(id, &RNA_FModifierLimits, fcm, &ptr);
-
+
/* row 1: minimum */
{
/* row = uiLayoutRow(layout, false); */ /* UNUSED */
-
+
/* split into 2 columns */
split = uiLayoutSplit(layout, 0.5f, false);
-
+
/* x-minimum */
col = uiLayoutColumn(split, true);
uiItemR(col, &ptr, "use_min_x", 0, NULL, ICON_NONE);
uiItemR(col, &ptr, "min_x", 0, NULL, ICON_NONE);
-
+
/* y-minimum*/
col = uiLayoutColumn(split, true);
uiItemR(col, &ptr, "use_min_y", 0, NULL, ICON_NONE);
uiItemR(col, &ptr, "min_y", 0, NULL, ICON_NONE);
}
-
+
/* row 2: maximum */
{
/* row = uiLayoutRow(layout, false); */ /* UNUSED */
-
+
/* split into 2 columns */
split = uiLayoutSplit(layout, 0.5f, false);
-
+
/* x-minimum */
col = uiLayoutColumn(split, true);
uiItemR(col, &ptr, "use_max_x", 0, NULL, ICON_NONE);
uiItemR(col, &ptr, "max_x", 0, NULL, ICON_NONE);
-
+
/* y-minimum*/
col = uiLayoutColumn(split, true);
uiItemR(col, &ptr, "use_max_y", 0, NULL, ICON_NONE);
@@ -525,27 +525,27 @@ static void draw_modifier__stepped(uiLayout *layout, ID *id, FModifier *fcm, sho
{
uiLayout *col, *sub;
PointerRNA ptr;
-
+
/* init the RNA-pointer */
RNA_pointer_create(id, &RNA_FModifierStepped, fcm, &ptr);
-
+
/* block 1: "stepping" settings */
col = uiLayoutColumn(layout, false);
uiItemR(col, &ptr, "frame_step", 0, NULL, ICON_NONE);
uiItemR(col, &ptr, "frame_offset", 0, NULL, ICON_NONE);
-
+
/* block 2: start range settings */
col = uiLayoutColumn(layout, true);
uiItemR(col, &ptr, "use_frame_start", 0, NULL, ICON_NONE);
-
+
sub = uiLayoutColumn(col, true);
uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_start"));
uiItemR(sub, &ptr, "frame_start", 0, NULL, ICON_NONE);
-
+
/* block 3: end range settings */
col = uiLayoutColumn(layout, true);
uiItemR(col, &ptr, "use_frame_end", 0, NULL, ICON_NONE);
-
+
sub = uiLayoutColumn(col, true);
uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_end"));
uiItemR(sub, &ptr, "frame_end", 0, NULL, ICON_NONE);
@@ -561,125 +561,125 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier
uiBut *but;
short width = 314;
PointerRNA ptr;
-
+
/* init the RNA-pointer */
RNA_pointer_create(id, &RNA_FModifier, fcm, &ptr);
-
+
/* draw header */
{
/* get layout-row + UI-block for this */
box = uiLayoutBox(layout);
-
+
row = uiLayoutRow(box, false);
block = uiLayoutGetBlock(row); // err...
-
+
/* left-align -------------------------------------------- */
sub = uiLayoutRow(row, true);
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT);
-
+
UI_block_emboss_set(block, UI_EMBOSS_NONE);
-
+
/* expand */
uiItemR(sub, &ptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
-
+
/* checkbox for 'active' status (for now) */
uiItemR(sub, &ptr, "active", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
-
+
/* name */
if (fmi)
uiItemL(sub, IFACE_(fmi->name), ICON_NONE);
else
uiItemL(sub, IFACE_("<Unknown Modifier>"), ICON_NONE);
-
+
/* right-align ------------------------------------------- */
sub = uiLayoutRow(row, true);
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT);
-
-
+
+
/* 'mute' button */
uiItemR(sub, &ptr, "mute", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
-
+
UI_block_emboss_set(block, UI_EMBOSS_NONE);
-
+
/* delete button */
but = uiDefIconBut(block, UI_BTYPE_BUT, B_REDR, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y,
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete F-Curve Modifier"));
UI_but_func_set(but, delete_fmodifier_cb, modifiers, fcm);
-
+
UI_block_emboss_set(block, UI_EMBOSS);
}
-
+
/* when modifier is expanded, draw settings */
if (fcm->flag & FMODIFIER_FLAG_EXPANDED) {
/* set up the flexible-box layout which acts as the backdrop for the modifier settings */
box = uiLayoutBox(layout);
-
+
/* draw settings for individual modifiers */
switch (fcm->type) {
case FMODIFIER_TYPE_GENERATOR: /* Generator */
draw_modifier__generator(box, id, fcm, width);
break;
-
+
case FMODIFIER_TYPE_FN_GENERATOR: /* Built-In Function Generator */
draw_modifier__fn_generator(box, id, fcm, width);
break;
-
+
case FMODIFIER_TYPE_CYCLES: /* Cycles */
draw_modifier__cycles(box, id, fcm, width);
break;
-
+
case FMODIFIER_TYPE_ENVELOPE: /* Envelope */
draw_modifier__envelope(box, id, fcm, width);
break;
-
+
case FMODIFIER_TYPE_LIMITS: /* Limits */
draw_modifier__limits(box, id, fcm, width);
break;
-
+
case FMODIFIER_TYPE_NOISE: /* Noise */
draw_modifier__noise(box, id, fcm, width);
break;
-
+
case FMODIFIER_TYPE_STEPPED: /* Stepped */
draw_modifier__stepped(box, id, fcm, width);
break;
-
+
default: /* unknown type */
break;
}
-
+
/* one last panel below this: FModifier range */
// TODO: experiment with placement of this
{
box = uiLayoutBox(layout);
-
+
/* restricted range ----------------------------------------------------- */
col = uiLayoutColumn(box, true);
-
+
/* top row: use restricted range */
row = uiLayoutRow(col, true);
uiItemR(row, &ptr, "use_restricted_range", 0, NULL, ICON_NONE);
-
+
if (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) {
/* second row: settings */
row = uiLayoutRow(col, true);
-
+
uiItemR(row, &ptr, "frame_start", 0, IFACE_("Start"), ICON_NONE);
uiItemR(row, &ptr, "frame_end", 0, IFACE_("End"), ICON_NONE);
-
+
/* third row: blending influence */
row = uiLayoutRow(col, true);
-
+
uiItemR(row, &ptr, "blend_in", 0, IFACE_("In"), ICON_NONE);
uiItemR(row, &ptr, "blend_out", 0, IFACE_("Out"), ICON_NONE);
}
-
+
/* influence -------------------------------------------------------------- */
col = uiLayoutColumn(box, true);
-
+
/* top row: use influence */
uiItemR(col, &ptr, "use_influence", 0, NULL, ICON_NONE);
-
+
if (fcm->flag & FMODIFIER_FLAG_USEINFLUENCE) {
/* second row: influence value */
uiItemR(col, &ptr, "influence", 0, NULL, ICON_NONE);
@@ -710,15 +710,15 @@ void ANIM_fmodifiers_copybuf_free(void)
bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active)
{
bool ok = true;
-
+
/* sanity checks */
if (ELEM(NULL, modifiers, modifiers->first))
return 0;
-
+
/* copy the whole list, or just the active one? */
if (active) {
FModifier *fcm = find_active_fmodifier(modifiers);
-
+
if (fcm) {
FModifier *fcmN = copy_fmodifier(fcm);
BLI_addtail(&fmodifier_copypaste_buf, fcmN);
@@ -728,44 +728,44 @@ bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active)
}
else
copy_fmodifiers(&fmodifier_copypaste_buf, modifiers);
-
+
/* did we succeed? */
return ok;
}
-/* 'Paste' the F-Modifier(s) from the buffer to the specified list
- * - replace: free all the existing modifiers to leave only the pasted ones
+/* 'Paste' the F-Modifier(s) from the buffer to the specified list
+ * - replace: free all the existing modifiers to leave only the pasted ones
*/
bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *curve)
{
FModifier *fcm;
bool ok = false;
-
+
/* sanity checks */
if (modifiers == NULL)
return 0;
-
+
bool was_cyclic = curve && BKE_fcurve_is_cyclic(curve);
/* if replacing the list, free the existing modifiers */
if (replace)
free_fmodifiers(modifiers);
-
+
/* now copy over all the modifiers in the buffer to the end of the list */
for (fcm = fmodifier_copypaste_buf.first; fcm; fcm = fcm->next) {
/* make a copy of it */
FModifier *fcmN = copy_fmodifier(fcm);
fcmN->curve = curve;
-
+
/* make sure the new one isn't active, otherwise the list may get several actives */
fcmN->flag &= ~FMODIFIER_FLAG_ACTIVE;
-
+
/* now add it to the end of the list */
BLI_addtail(modifiers, fcmN);
ok = 1;
}
-
+
/* adding or removing the Cycles modifier requires an update to handles */
if (curve && BKE_fcurve_is_cyclic(curve) != was_cyclic)
calchandles_fcurve(curve);
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 98ad2041018..d1377703949 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -72,10 +72,10 @@ short compare_ak_cfraPtr(void *node, void *data)
ActKeyColumn *ak = (ActKeyColumn *)node;
const float *cframe = data;
float val = *cframe;
-
+
if (IS_EQT(val, ak->cfra, BEZT_BINARYSEARCH_THRESH))
return 0;
-
+
if (val < ak->cfra)
return -1;
else if (val > ak->cfra)
@@ -91,7 +91,7 @@ static short compare_ak_bezt(void *node, void *data)
{
ActKeyColumn *ak = (ActKeyColumn *)node;
BezTriple *bezt = (BezTriple *)data;
-
+
if (bezt->vec[1][0] < ak->cfra)
return -1;
else if (bezt->vec[1][0] > ak->cfra)
@@ -105,15 +105,15 @@ static DLRBT_Node *nalloc_ak_bezt(void *data)
{
ActKeyColumn *ak = MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumn");
BezTriple *bezt = (BezTriple *)data;
-
+
/* store settings based on state of BezTriple */
ak->cfra = bezt->vec[1][0];
ak->sel = BEZT_ISSEL_ANY(bezt) ? SELECT : 0;
ak->key_type = BEZKEYTYPE(bezt);
-
+
/* set 'modified', since this is used to identify long keyframes */
ak->modified = 1;
-
+
return (DLRBT_Node *)ak;
}
@@ -122,11 +122,11 @@ static void nupdate_ak_bezt(void *node, void *data)
{
ActKeyColumn *ak = (ActKeyColumn *)node;
BezTriple *bezt = (BezTriple *)data;
-
+
/* set selection status and 'touched' status */
if (BEZT_ISSEL_ANY(bezt)) ak->sel = SELECT;
ak->modified += 1;
-
+
/* for keyframe type, 'proper' keyframes have priority over breakdowns (and other types for now) */
if (BEZKEYTYPE(bezt) == BEZT_KEYTYPE_KEYFRAME)
ak->key_type = BEZT_KEYTYPE_KEYFRAME;
@@ -139,7 +139,7 @@ static short compare_ak_gpframe(void *node, void *data)
{
ActKeyColumn *ak = (ActKeyColumn *)node;
bGPDframe *gpf = (bGPDframe *)data;
-
+
if (gpf->framenum < ak->cfra)
return -1;
else if (gpf->framenum > ak->cfra)
@@ -153,15 +153,15 @@ static DLRBT_Node *nalloc_ak_gpframe(void *data)
{
ActKeyColumn *ak = MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumnGPF");
bGPDframe *gpf = (bGPDframe *)data;
-
+
/* store settings based on state of BezTriple */
ak->cfra = gpf->framenum;
ak->sel = (gpf->flag & GP_FRAME_SELECT) ? SELECT : 0;
ak->key_type = gpf->key_type;
-
+
/* set 'modified', since this is used to identify long keyframes */
ak->modified = 1;
-
+
return (DLRBT_Node *)ak;
}
@@ -170,11 +170,11 @@ static void nupdate_ak_gpframe(void *node, void *data)
{
ActKeyColumn *ak = (ActKeyColumn *)node;
bGPDframe *gpf = (bGPDframe *)data;
-
+
/* set selection status and 'touched' status */
if (gpf->flag & GP_FRAME_SELECT) ak->sel = SELECT;
ak->modified += 1;
-
+
/* for keyframe type, 'proper' keyframes have priority over breakdowns (and other types for now) */
if (gpf->key_type == BEZT_KEYTYPE_KEYFRAME)
ak->key_type = BEZT_KEYTYPE_KEYFRAME;
@@ -262,7 +262,7 @@ short compare_ab_cfraPtr(void *node, void *data)
ActKeyBlock *ab = (ActKeyBlock *)node;
const float *cframe = data;
float val = *cframe;
-
+
if (val < ab->start)
return -1;
else if (val > ab->start)
@@ -277,17 +277,17 @@ short compare_ab_cfraPtr(void *node, void *data)
static ActKeyBlock *bezts_to_new_actkeyblock(BezTriple *prev, BezTriple *beztn)
{
ActKeyBlock *ab = MEM_callocN(sizeof(ActKeyBlock), "ActKeyBlock");
-
+
ab->start = prev->vec[1][0];
ab->end = beztn->vec[1][0];
ab->val = beztn->vec[1][1];
-
+
ab->sel = (BEZT_ISSEL_ANY(prev) || BEZT_ISSEL_ANY(beztn)) ? SELECT : 0;
ab->modified = 1;
-
+
if (BEZKEYTYPE(beztn) == BEZT_KEYTYPE_MOVEHOLD)
ab->flag |= ACTKEYBLOCK_FLAG_MOVING_HOLD;
-
+
return ab;
}
@@ -295,25 +295,25 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, BezTriple *first_bezt
{
ActKeyBlock *new_ab = NULL;
BezTriple *prev = NULL;
-
+
/* get the BezTriple immediately before the given one which has the same value */
if (beztn != first_bezt) {
- /* XXX: Unless I'm overlooking some details from the past, this should be sufficient?
+ /* XXX: Unless I'm overlooking some details from the past, this should be sufficient?
* The old code did some elaborate stuff trying to find keyframe columns for
* the given BezTriple, then step backwards to the column before that, and find
* an appropriate BezTriple with matching values there. Maybe that was warranted
- * in the past, but now, that list is only ever filled with keyframes from the
+ * in the past, but now, that list is only ever filled with keyframes from the
* current FCurve.
*
* -- Aligorith (20140415)
*/
prev = beztn - 1;
}
-
-
+
+
/* check if block needed */
if (prev == NULL) return;
-
+
if (BEZKEYTYPE(beztn) == BEZT_KEYTYPE_MOVEHOLD) {
/* Animator tagged a "moving hold"
* - Previous key must also be tagged as a moving hold, otherwise
@@ -329,11 +329,11 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, BezTriple *first_bezt
* - Handles which control that section of the curve must be constant
*/
if (IS_EQF(beztn->vec[1][1], prev->vec[1][1]) == 0) return;
-
+
if (IS_EQF(beztn->vec[1][1], beztn->vec[0][1]) == 0) return;
if (IS_EQF(prev->vec[1][1], prev->vec[2][1]) == 0) return;
}
-
+
/* if there are no blocks already, just add as root */
if (blocks->root == NULL) {
/* just add this as the root, then call the tree-balancing functions to validate */
@@ -342,7 +342,7 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, BezTriple *first_bezt
}
else {
ActKeyBlock *ab, *abn = NULL;
-
+
/* try to find a keyblock that starts on the previous beztriple, and add a new one if none start there
* Note: we perform a tree traversal here NOT a standard linked-list traversal...
* Note: we can't search from end to try to optimize this as it causes errors there's
@@ -353,32 +353,32 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, BezTriple *first_bezt
// A|------------------------------------------------|A
// A|----|A|---|A|-----------------------------------|A
for (ab = blocks->root; ab; ab = abn) {
- /* check if this is a match, or whether we go left or right
+ /* check if this is a match, or whether we go left or right
* NOTE: we now use a float threshold to prevent precision errors causing problems with summaries
*/
if (IS_EQT(ab->start, prev->vec[1][0], BEZT_BINARYSEARCH_THRESH)) {
/* set selection status and 'touched' status */
if (BEZT_ISSEL_ANY(beztn))
ab->sel = SELECT;
-
+
/* XXX: only when the first one was a moving hold? */
if (BEZKEYTYPE(beztn) == BEZT_KEYTYPE_MOVEHOLD)
ab->flag |= ACTKEYBLOCK_FLAG_MOVING_HOLD;
-
+
ab->modified++;
-
+
/* done... no need to insert */
return;
}
else {
ActKeyBlock **abnp = NULL; /* branch to go down - used to hook new blocks to parents */
-
+
/* check if go left or right, but if not available, add new node */
- if (ab->start < prev->vec[1][0])
+ if (ab->start < prev->vec[1][0])
abnp = &ab->right;
else
abnp = &ab->left;
-
+
/* if this does not exist, add a new node, otherwise continue... */
if (*abnp == NULL) {
/* add a new node representing this, and attach it to the relevant place */
@@ -392,7 +392,7 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, BezTriple *first_bezt
}
}
}
-
+
/* now, balance the tree taking into account this newly added node */
BLI_dlrbTree_insert(blocks, (DLRBT_Node *)new_ab);
}
@@ -405,13 +405,13 @@ static void set_touched_actkeycolumn(ActKeyColumn *ak)
/* sanity check */
if (ak == NULL)
return;
-
+
/* deal with self first */
if (ak->modified) {
ak->modified = 0;
ak->totcurve++;
}
-
+
/* children */
set_touched_actkeycolumn(ak->left);
set_touched_actkeycolumn(ak->right);
@@ -423,13 +423,13 @@ static void set_touched_actkeyblock(ActKeyBlock *ab)
/* sanity check */
if (ab == NULL)
return;
-
+
/* deal with self first */
if (ab->modified) {
ab->modified = 0;
ab->totcurve++;
}
-
+
/* children */
set_touched_actkeyblock(ab->left);
set_touched_actkeyblock(ab->right);
@@ -442,22 +442,22 @@ bool actkeyblock_is_valid(ActKeyBlock *ab, DLRBT_Tree *keys)
{
ActKeyColumn *ak;
short startCurves, endCurves, totCurves;
-
+
/* check that block is valid */
if (ab == NULL)
return 0;
-
+
/* find out how many curves occur at each keyframe */
ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start);
startCurves = (ak) ? ak->totcurve : 0;
-
+
ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end);
endCurves = (ak) ? ak->totcurve : 0;
-
+
/* only draw keyblock if it appears in at all of the keyframes at lowest end */
- if (!startCurves && !endCurves)
+ if (!startCurves && !endCurves)
return 0;
-
+
totCurves = (startCurves > endCurves) ? endCurves : startCurves;
return (ab->totcurve >= totCurves);
}
@@ -478,19 +478,19 @@ void draw_keyframe_shape(float x, float y, float size, bool sel, short key_type,
switch (key_type) {
case BEZT_KEYTYPE_KEYFRAME: /* must be full size */
break;
-
+
case BEZT_KEYTYPE_BREAKDOWN: /* slightly smaller than normal keyframe */
size *= 0.85f;
break;
-
+
case BEZT_KEYTYPE_MOVEHOLD: /* slightly smaller than normal keyframes (but by less than for breakdowns) */
size *= 0.925f;
break;
-
+
case BEZT_KEYTYPE_EXTREME: /* slightly larger */
size *= 1.2f;
break;
-
+
default:
size -= 0.8f * key_type;
}
@@ -521,8 +521,8 @@ void draw_keyframe_shape(float x, float y, float size, bool sel, short key_type,
default:
UI_GetThemeColor4ubv(sel ? TH_KEYTYPE_KEYFRAME_SELECT : TH_KEYTYPE_KEYFRAME, fill_col);
}
-
- /* NOTE: we don't use the straight alpha from the theme, or else effects such as
+
+ /* NOTE: we don't use the straight alpha from the theme, or else effects such as
* graying out protected/muted channels doesn't work correctly!
*/
fill_col[3] *= alpha;
@@ -560,25 +560,25 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
{
const float icon_sz = U.widget_unit * 0.5f * yscale_fac;
const float half_icon_sz = 0.5f * icon_sz;
-
+
glEnable(GL_BLEND);
-
+
/* locked channels are less strongly shown, as feedback for locked channels in DopeSheet */
/* TODO: allow this opacity factor to be themed? */
float alpha = channelLocked ? 0.25f : 1.0f;
-
+
/* draw keyblocks */
if (blocks) {
float sel_color[4], unsel_color[4];
float sel_mhcol[4], unsel_mhcol[4];
-
+
/* cache colours first */
UI_GetThemeColor4fv(TH_STRIP_SELECT, sel_color);
UI_GetThemeColor4fv(TH_STRIP, unsel_color);
-
+
sel_color[3] *= alpha;
unsel_color[3] *= alpha;
-
+
copy_v4_v4(sel_mhcol, sel_color);
sel_mhcol[3] *= 0.8f;
copy_v4_v4(unsel_mhcol, unsel_color);
@@ -618,7 +618,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
immUnbindProgram();
}
}
-
+
if (keys) {
/* count keys */
unsigned int key_ct = 0;
@@ -662,17 +662,17 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
void draw_summary_channel(View2D *v2d, bAnimContext *ac, float ypos, float yscale_fac)
{
DLRBT_Tree keys, blocks;
-
+
BLI_dlrbTree_init(&keys);
BLI_dlrbTree_init(&blocks);
-
+
summary_to_keylist(ac, &keys, &blocks);
-
+
BLI_dlrbTree_linkedlist_sync(&keys);
BLI_dlrbTree_linkedlist_sync(&blocks);
-
+
draw_keylist(v2d, &keys, &blocks, ypos, yscale_fac, false);
-
+
BLI_dlrbTree_free(&keys);
BLI_dlrbTree_free(&blocks);
}
@@ -680,17 +680,17 @@ void draw_summary_channel(View2D *v2d, bAnimContext *ac, float ypos, float yscal
void draw_scene_channel(View2D *v2d, bDopeSheet *ads, Scene *sce, float ypos, float yscale_fac)
{
DLRBT_Tree keys, blocks;
-
+
BLI_dlrbTree_init(&keys);
BLI_dlrbTree_init(&blocks);
-
+
scene_to_keylist(ads, sce, &keys, &blocks);
-
+
BLI_dlrbTree_linkedlist_sync(&keys);
BLI_dlrbTree_linkedlist_sync(&blocks);
-
+
draw_keylist(v2d, &keys, &blocks, ypos, yscale_fac, false);
-
+
BLI_dlrbTree_free(&keys);
BLI_dlrbTree_free(&blocks);
}
@@ -698,17 +698,17 @@ void draw_scene_channel(View2D *v2d, bDopeSheet *ads, Scene *sce, float ypos, fl
void draw_object_channel(View2D *v2d, bDopeSheet *ads, Object *ob, float ypos, float yscale_fac)
{
DLRBT_Tree keys, blocks;
-
+
BLI_dlrbTree_init(&keys);
BLI_dlrbTree_init(&blocks);
-
+
ob_to_keylist(ads, ob, &keys, &blocks);
-
+
BLI_dlrbTree_linkedlist_sync(&keys);
BLI_dlrbTree_linkedlist_sync(&blocks);
-
+
draw_keylist(v2d, &keys, &blocks, ypos, yscale_fac, false);
-
+
BLI_dlrbTree_free(&keys);
BLI_dlrbTree_free(&blocks);
}
@@ -716,21 +716,21 @@ void draw_object_channel(View2D *v2d, bDopeSheet *ads, Object *ob, float ypos, f
void draw_fcurve_channel(View2D *v2d, AnimData *adt, FCurve *fcu, float ypos, float yscale_fac)
{
DLRBT_Tree keys, blocks;
-
+
bool locked = (fcu->flag & FCURVE_PROTECTED) ||
((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ||
((adt && adt->action) && ID_IS_LINKED(adt->action));
-
+
BLI_dlrbTree_init(&keys);
BLI_dlrbTree_init(&blocks);
-
+
fcurve_to_keylist(adt, fcu, &keys, &blocks);
-
+
BLI_dlrbTree_linkedlist_sync(&keys);
BLI_dlrbTree_linkedlist_sync(&blocks);
-
+
draw_keylist(v2d, &keys, &blocks, ypos, yscale_fac, locked);
-
+
BLI_dlrbTree_free(&keys);
BLI_dlrbTree_free(&blocks);
}
@@ -738,20 +738,20 @@ void draw_fcurve_channel(View2D *v2d, AnimData *adt, FCurve *fcu, float ypos, fl
void draw_agroup_channel(View2D *v2d, AnimData *adt, bActionGroup *agrp, float ypos, float yscale_fac)
{
DLRBT_Tree keys, blocks;
-
+
bool locked = (agrp->flag & AGRP_PROTECTED) ||
((adt && adt->action) && ID_IS_LINKED(adt->action));
-
+
BLI_dlrbTree_init(&keys);
BLI_dlrbTree_init(&blocks);
-
+
agroup_to_keylist(adt, agrp, &keys, &blocks);
-
+
BLI_dlrbTree_linkedlist_sync(&keys);
BLI_dlrbTree_linkedlist_sync(&blocks);
-
+
draw_keylist(v2d, &keys, &blocks, ypos, yscale_fac, locked);
-
+
BLI_dlrbTree_free(&keys);
BLI_dlrbTree_free(&blocks);
}
@@ -759,19 +759,19 @@ void draw_agroup_channel(View2D *v2d, AnimData *adt, bActionGroup *agrp, float y
void draw_action_channel(View2D *v2d, AnimData *adt, bAction *act, float ypos, float yscale_fac)
{
DLRBT_Tree keys, blocks;
-
+
bool locked = (act && ID_IS_LINKED(act));
-
+
BLI_dlrbTree_init(&keys);
BLI_dlrbTree_init(&blocks);
-
+
action_to_keylist(adt, act, &keys, &blocks);
-
+
BLI_dlrbTree_linkedlist_sync(&keys);
BLI_dlrbTree_linkedlist_sync(&blocks);
-
+
draw_keylist(v2d, &keys, &blocks, ypos, yscale_fac, locked);
-
+
BLI_dlrbTree_free(&keys);
BLI_dlrbTree_free(&blocks);
}
@@ -779,49 +779,49 @@ void draw_action_channel(View2D *v2d, AnimData *adt, bAction *act, float ypos, f
void draw_gpencil_channel(View2D *v2d, bDopeSheet *ads, bGPdata *gpd, float ypos, float yscale_fac)
{
DLRBT_Tree keys;
-
+
BLI_dlrbTree_init(&keys);
-
+
gpencil_to_keylist(ads, gpd, &keys);
-
+
BLI_dlrbTree_linkedlist_sync(&keys);
-
+
draw_keylist(v2d, &keys, NULL, ypos, yscale_fac, false);
-
+
BLI_dlrbTree_free(&keys);
}
void draw_gpl_channel(View2D *v2d, bDopeSheet *ads, bGPDlayer *gpl, float ypos, float yscale_fac)
{
DLRBT_Tree keys;
-
+
bool locked = (gpl->flag & GP_LAYER_LOCKED) != 0;
-
+
BLI_dlrbTree_init(&keys);
-
+
gpl_to_keylist(ads, gpl, &keys);
-
+
BLI_dlrbTree_linkedlist_sync(&keys);
-
+
draw_keylist(v2d, &keys, NULL, ypos, yscale_fac, locked);
-
+
BLI_dlrbTree_free(&keys);
}
void draw_masklay_channel(View2D *v2d, bDopeSheet *ads, MaskLayer *masklay, float ypos, float yscale_fac)
{
DLRBT_Tree keys;
-
+
bool locked = (masklay->flag & MASK_LAYERFLAG_LOCKED) != 0;
-
+
BLI_dlrbTree_init(&keys);
-
+
mask_to_keylist(ads, masklay, &keys);
-
+
BLI_dlrbTree_linkedlist_sync(&keys);
-
+
draw_keylist(v2d, &keys, NULL, ypos, yscale_fac, locked);
-
+
BLI_dlrbTree_free(&keys);
}
@@ -833,11 +833,11 @@ void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get F-Curves to take keyframes from */
filter = ANIMFILTER_DATA_VISIBLE;
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through each F-Curve, grabbing the keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
/* Why not use all #eAnim_KeyType here?
@@ -860,7 +860,7 @@ void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks)
break;
}
}
-
+
ANIM_animdata_freelist(&anim_data);
}
}
@@ -871,66 +871,66 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, DLRBT_Tree
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
bAnimListElem dummychan = {NULL};
-
+
if (sce == NULL)
return;
-
+
/* create a dummy wrapper data to work with */
dummychan.type = ANIMTYPE_SCENE;
dummychan.data = sce;
dummychan.id = &sce->id;
dummychan.adt = sce->adt;
-
+
ac.ads = ads;
ac.data = &dummychan;
ac.datatype = ANIMCONT_CHANNEL;
-
+
/* get F-Curves to take keyframes from */
filter = ANIMFILTER_DATA_VISIBLE; // curves only
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* loop through each F-Curve, grabbing the keyframes */
for (ale = anim_data.first; ale; ale = ale->next)
fcurve_to_keylist(ale->adt, ale->data, keys, blocks);
-
+
ANIM_animdata_freelist(&anim_data);
}
void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, DLRBT_Tree *blocks)
-{
+{
bAnimContext ac = {NULL};
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
bAnimListElem dummychan = {NULL};
Base dummybase = {NULL};
-
+
if (ob == NULL)
return;
-
+
/* create a dummy wrapper data to work with */
dummybase.object = ob;
-
+
dummychan.type = ANIMTYPE_OBJECT;
dummychan.data = &dummybase;
dummychan.id = &ob->id;
dummychan.adt = ob->adt;
-
+
ac.ads = ads;
ac.data = &dummychan;
ac.datatype = ANIMCONT_CHANNEL;
-
+
/* get F-Curves to take keyframes from */
filter = ANIMFILTER_DATA_VISIBLE; // curves only
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* loop through each F-Curve, grabbing the keyframes */
for (ale = anim_data.first; ale; ale = ale->next)
fcurve_to_keylist(ale->adt, ale->data, keys, blocks);
-
+
ANIM_animdata_freelist(&anim_data);
}
@@ -974,19 +974,19 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree
/* apply NLA-mapping (if applicable) */
if (adt)
ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 0);
-
+
/* loop through beztriples, making ActKeysColumns and ActKeyBlocks */
for (v = 0, bezt = fcu->bezt; v < fcu->totvert; v++, bezt++) {
add_bezt_to_keycolumns_list(keys, bezt);
if (blocks) add_bezt_to_keyblocks_list(blocks, fcu->bezt, bezt);
}
-
+
/* update the number of curves that elements have appeared in */
if (keys)
set_touched_actkeycolumn(keys->root);
if (blocks)
set_touched_actkeyblock(blocks->root);
-
+
/* unapply NLA-mapping if applicable */
if (adt)
ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0);
@@ -1021,7 +1021,7 @@ void action_to_keylist(AnimData *adt, bAction *act, DLRBT_Tree *keys, DLRBT_Tree
void gpencil_to_keylist(bDopeSheet *ads, bGPdata *gpd, DLRBT_Tree *keys)
{
bGPDlayer *gpl;
-
+
if (gpd && keys) {
/* for now, just aggregate out all the frames, but only for visible layers */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -1035,7 +1035,7 @@ void gpencil_to_keylist(bDopeSheet *ads, bGPdata *gpd, DLRBT_Tree *keys)
void gpl_to_keylist(bDopeSheet *UNUSED(ads), bGPDlayer *gpl, DLRBT_Tree *keys)
{
bGPDframe *gpf;
-
+
if (gpl && keys) {
/* although the frames should already be in an ordered list, they are not suitable for displaying yet */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next)
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index 0ef6aa4bd4a..6b24008c4d8 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -56,15 +56,15 @@
* ANIM_fcurve_keyframes_loop()
* which take the data they operate on, a few callbacks defining what operations to perform.
*
- * As operators which work on keyframes usually apply the same operation on all BezTriples in
- * every channel, the code has been optimized providing a set of functions which will get the
+ * As operators which work on keyframes usually apply the same operation on all BezTriples in
+ * every channel, the code has been optimized providing a set of functions which will get the
* appropriate bezier-modify function to set. These functions (ANIM_editkeyframes_*) will need
* to be called before getting any channels.
- *
+ *
* A set of 'validation' callbacks are provided for checking if a BezTriple should be operated on.
- * These should only be used when using a 'general' BezTriple editor (i.e. selection setters which
+ * These should only be used when using a 'general' BezTriple editor (i.e. selection setters which
* don't check existing selection status).
- *
+ *
* - Joshua Leung, Dec 2008
*/
@@ -73,11 +73,11 @@
/* --------------------------- Base Functions ------------------------------------ */
-/* This function is used to loop over BezTriples in the given F-Curve, applying a given
+/* This function is used to loop over BezTriples in the given F-Curve, applying a given
* operation on them, and optionally applies an F-Curve validation function afterwards.
*/
// TODO: make this function work on samples too...
-short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
+short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
{
BezTriple *bezt;
short ok = 0;
@@ -96,7 +96,7 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi
/* if function to apply to bezier curves is set, then loop through executing it on beztriples */
if (key_cb) {
- /* if there's a validation func, include that check in the loop
+ /* if there's a validation func, include that check in the loop
* (this is should be more efficient than checking for it in every loop)
*/
if (key_ok) {
@@ -106,11 +106,11 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi
ked->curIndex = i;
ked->curflags = 0;
}
-
+
/* Only operate on this BezTriple if it fullfills the criteria of the validation func */
if ((ok = key_ok(ked, bezt))) {
if (ked) ked->curflags = ok;
-
+
/* Exit with return-code '1' if function returns positive
* This is useful if finding if some BezTriple satisfies a condition.
*/
@@ -121,7 +121,7 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi
else {
for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) {
if (ked) ked->curIndex = i;
-
+
/* Exit with return-code '1' if function returns positive
* This is useful if finding if some BezTriple satisfies a condition.
*/
@@ -129,7 +129,7 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi
}
}
}
-
+
/* unset the F-Curve from the editdata now that it's done */
if (ked) {
ked->fcu = NULL;
@@ -140,7 +140,7 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi
/* if fcu_cb (F-Curve post-editing callback) has been specified then execute it */
if (fcu_cb)
fcu_cb(fcu);
-
+
/* done */
return 0;
}
@@ -151,17 +151,17 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi
static short agrp_keyframes_loop(KeyframeEditData *ked, bActionGroup *agrp, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
{
FCurve *fcu;
-
+
/* sanity check */
if (agrp == NULL)
return 0;
-
+
/* only iterate over the F-Curves that are in this group */
for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) {
if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb))
return 1;
}
-
+
return 0;
}
@@ -169,17 +169,17 @@ static short agrp_keyframes_loop(KeyframeEditData *ked, bActionGroup *agrp, Keyf
static short act_keyframes_loop(KeyframeEditData *ked, bAction *act, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
{
FCurve *fcu;
-
+
/* sanity check */
if (act == NULL)
return 0;
-
+
/* just loop through all F-Curves */
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb))
return 1;
}
-
+
return 0;
}
@@ -191,29 +191,29 @@ static short ob_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Object *o
bAnimListElem *ale;
int filter;
int ret = 0;
-
+
bAnimListElem dummychan = {NULL};
Base dummybase = {NULL};
-
+
if (ob == NULL)
return 0;
-
+
/* create a dummy wrapper data to work with */
dummybase.object = ob;
-
+
dummychan.type = ANIMTYPE_OBJECT;
dummychan.data = &dummybase;
dummychan.id = &ob->id;
dummychan.adt = ob->adt;
-
+
ac.ads = ads;
ac.data = &dummychan;
ac.datatype = ANIMCONT_CHANNEL;
-
+
/* get F-Curves to take keyframes from */
filter = ANIMFILTER_DATA_VISIBLE; // curves only
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* loop through each F-Curve, applying the operation as required, but stopping on the first one */
for (ale = anim_data.first; ale; ale = ale->next) {
if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) {
@@ -221,9 +221,9 @@ static short ob_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Object *o
break;
}
}
-
+
ANIM_animdata_freelist(&anim_data);
-
+
/* return return code - defaults to zero if nothing happened */
return ret;
}
@@ -236,26 +236,26 @@ static short scene_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Scene
bAnimListElem *ale;
int filter;
int ret = 0;
-
+
bAnimListElem dummychan = {NULL};
-
+
if (sce == NULL)
return 0;
-
+
/* create a dummy wrapper data to work with */
dummychan.type = ANIMTYPE_SCENE;
dummychan.data = sce;
dummychan.id = &sce->id;
dummychan.adt = sce->adt;
-
+
ac.ads = ads;
ac.data = &dummychan;
ac.datatype = ANIMCONT_CHANNEL;
-
+
/* get F-Curves to take keyframes from */
filter = ANIMFILTER_DATA_VISIBLE; // curves only
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* loop through each F-Curve, applying the operation as required, but stopping on the first one */
for (ale = anim_data.first; ale; ale = ale->next) {
if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) {
@@ -263,9 +263,9 @@ static short scene_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Scene
break;
}
}
-
+
ANIM_animdata_freelist(&anim_data);
-
+
/* return return code - defaults to zero if nothing happened */
return ret;
}
@@ -276,22 +276,22 @@ static short summary_keyframes_loop(KeyframeEditData *ked, bAnimContext *ac, Key
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter, ret_code = 0;
-
+
/* sanity check */
if (ac == NULL)
return 0;
-
+
/* get F-Curves to take keyframes from */
filter = ANIMFILTER_DATA_VISIBLE;
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through each F-Curve, working on the keyframes until the first curve aborts */
for (ale = anim_data.first; ale; ale = ale->next) {
switch (ale->datatype) {
case ALE_MASKLAY:
case ALE_GPFRAME:
break;
-
+
case ALE_FCURVE:
default:
{
@@ -301,19 +301,19 @@ static short summary_keyframes_loop(KeyframeEditData *ked, bAnimContext *ac, Key
*/
float f1 = ked->f1;
float f2 = ked->f2;
-
+
if (ked->iterflags & (KED_F1_NLA_UNMAP | KED_F2_NLA_UNMAP)) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
if (ked->iterflags & KED_F1_NLA_UNMAP)
ked->f1 = BKE_nla_tweakedit_remap(adt, f1, NLATIME_CONVERT_UNMAP);
if (ked->iterflags & KED_F2_NLA_UNMAP)
ked->f2 = BKE_nla_tweakedit_remap(adt, f2, NLATIME_CONVERT_UNMAP);
}
-
+
/* now operate on the channel as per normal */
ret_code = ANIM_fcurve_keyframes_loop(ked, ale->data, key_ok, key_cb, fcu_cb);
-
+
/* reset */
ked->f1 = f1;
ked->f2 = f2;
@@ -325,13 +325,13 @@ static short summary_keyframes_loop(KeyframeEditData *ked, bAnimContext *ac, Key
break;
}
}
-
+
if (ret_code)
break;
}
-
+
ANIM_animdata_freelist(&anim_data);
-
+
return ret_code;
}
@@ -343,21 +343,21 @@ short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, bA
/* sanity checks */
if (ale == NULL)
return 0;
-
+
/* method to use depends on the type of keyframe data */
switch (ale->datatype) {
/* direct keyframe data (these loops are exposed) */
case ALE_FCURVE: /* F-Curve */
return ANIM_fcurve_keyframes_loop(ked, ale->key_data, key_ok, key_cb, fcu_cb);
-
- /* indirect 'summaries' (these are not exposed directly)
+
+ /* indirect 'summaries' (these are not exposed directly)
* NOTE: must keep this code in sync with the drawing code and also the filtering code!
*/
case ALE_GROUP: /* action group */
return agrp_keyframes_loop(ked, (bActionGroup *)ale->data, key_ok, key_cb, fcu_cb);
case ALE_ACT: /* action */
return act_keyframes_loop(ked, (bAction *)ale->key_data, key_ok, key_cb, fcu_cb);
-
+
case ALE_OB: /* object */
return ob_keyframes_loop(ked, ads, (Object *)ale->key_data, key_ok, key_cb, fcu_cb);
case ALE_SCE: /* scene */
@@ -365,7 +365,7 @@ short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, bA
case ALE_ALL: /* 'all' (DopeSheet summary) */
return summary_keyframes_loop(ked, (bAnimContext *)ale->data, key_ok, key_cb, fcu_cb);
}
-
+
return 0;
}
@@ -375,21 +375,21 @@ short ANIM_animchanneldata_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads
/* sanity checks */
if (data == NULL)
return 0;
-
+
/* method to use depends on the type of keyframe data */
switch (keytype) {
/* direct keyframe data (these loops are exposed) */
case ALE_FCURVE: /* F-Curve */
return ANIM_fcurve_keyframes_loop(ked, data, key_ok, key_cb, fcu_cb);
-
- /* indirect 'summaries' (these are not exposed directly)
+
+ /* indirect 'summaries' (these are not exposed directly)
* NOTE: must keep this code in sync with the drawing code and also the filtering code!
*/
case ALE_GROUP: /* action group */
return agrp_keyframes_loop(ked, (bActionGroup *)data, key_ok, key_cb, fcu_cb);
case ALE_ACT: /* action */
return act_keyframes_loop(ked, (bAction *)data, key_ok, key_cb, fcu_cb);
-
+
case ALE_OB: /* object */
return ob_keyframes_loop(ked, ads, (Object *)data, key_ok, key_cb, fcu_cb);
case ALE_SCE: /* scene */
@@ -397,7 +397,7 @@ short ANIM_animchanneldata_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads
case ALE_ALL: /* 'all' (DopeSheet summary) */
return summary_keyframes_loop(ked, (bAnimContext *)data, key_ok, key_cb, fcu_cb);
}
-
+
return 0;
}
@@ -411,20 +411,20 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter animation data */
filter = ANIMFILTER_DATA_VISIBLE;
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop over F-Curves that are likely to have been edited, and check them */
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = ale->key_data;
-
+
/* make sure keyframes in F-Curve are all in order, and handles are in valid positions */
sort_time_fcurve(fcu);
calchandles_fcurve(fcu);
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
}
@@ -435,7 +435,7 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac)
/* ------------------------ */
/* Some macros to make this easier... */
-/* run the given check on the 3 handles
+/* run the given check on the 3 handles
* - check should be a macro, which takes the handle index as its single arg, which it substitutes later
* - requires that a var, of type short, is named 'ok', and has been initialized to 0
*/
@@ -454,16 +454,16 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac)
} (void)0
/* ------------------------ */
-
+
static short ok_bezier_frame(KeyframeEditData *ked, BezTriple *bezt)
{
short ok = 0;
-
+
/* frame is stored in f1 property (this float accuracy check may need to be dropped?) */
#define KEY_CHECK_OK(_index) IS_EQF(bezt->vec[_index][0], ked->f1)
KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
#undef KEY_CHECK_OK
-
+
/* return ok flags */
return ok;
}
@@ -471,19 +471,19 @@ static short ok_bezier_frame(KeyframeEditData *ked, BezTriple *bezt)
static short ok_bezier_framerange(KeyframeEditData *ked, BezTriple *bezt)
{
short ok = 0;
-
+
/* frame range is stored in float properties */
#define KEY_CHECK_OK(_index) ((bezt->vec[_index][0] > ked->f1) && (bezt->vec[_index][0] < ked->f2))
KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
#undef KEY_CHECK_OK
-
+
/* return ok flags */
return ok;
}
static short ok_bezier_selected(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- /* this macro checks all beztriple handles for selection...
+ /* this macro checks all beztriple handles for selection...
* only one of the verts has to be selected for this to be ok...
*/
if (BEZT_ISSEL_ANY(bezt))
@@ -493,17 +493,17 @@ static short ok_bezier_selected(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
}
static short ok_bezier_value(KeyframeEditData *ked, BezTriple *bezt)
-{
+{
short ok = 0;
-
- /* value is stored in f1 property
+
+ /* value is stored in f1 property
* - this float accuracy check may need to be dropped?
* - should value be stored in f2 instead so that we won't have conflicts when using f1 for frames too?
*/
#define KEY_CHECK_OK(_index) IS_EQF(bezt->vec[_index][1], ked->f1)
KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
#undef KEY_CHECK_OK
-
+
/* return ok flags */
return ok;
}
@@ -511,12 +511,12 @@ static short ok_bezier_value(KeyframeEditData *ked, BezTriple *bezt)
static short ok_bezier_valuerange(KeyframeEditData *ked, BezTriple *bezt)
{
short ok = 0;
-
+
/* value range is stored in float properties */
#define KEY_CHECK_OK(_index) ((bezt->vec[_index][1] > ked->f1) && (bezt->vec[_index][1] < ked->f2))
KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
#undef KEY_CHECK_OK
-
+
/* return ok flags */
return ok;
}
@@ -526,15 +526,15 @@ static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt)
/* rect is stored in data property (it's of type rectf, but may not be set) */
if (ked->data) {
short ok = 0;
-
+
#define KEY_CHECK_OK(_index) BLI_rctf_isect_pt_v(ked->data, bezt->vec[_index])
KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
#undef KEY_CHECK_OK
-
+
/* return ok flags */
return ok;
}
- else
+ else
return 0;
}
@@ -547,9 +547,9 @@ bool keyframe_region_lasso_test(
{
if (BLI_rctf_isect_pt_v(data_lasso->rectf_scaled, xy)) {
float xy_view[2];
-
+
BLI_rctf_transform_pt_v(data_lasso->rectf_view, data_lasso->rectf_scaled, xy_view, xy);
-
+
if (BLI_lasso_is_point_inside(data_lasso->mcords, data_lasso->mcords_tot, xy_view[0], xy_view[1], INT_MAX)) {
return true;
}
@@ -563,11 +563,11 @@ static short ok_bezier_region_lasso(KeyframeEditData *ked, BezTriple *bezt)
/* check for lasso customdata (KeyframeEdit_LassoData) */
if (ked->data) {
short ok = 0;
-
+
#define KEY_CHECK_OK(_index) keyframe_region_lasso_test(ked->data, bezt->vec[_index])
KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
#undef KEY_CHECK_OK
-
+
/* return ok flags */
return ok;
}
@@ -581,7 +581,7 @@ static short ok_bezier_channel_lasso(KeyframeEditData *ked, BezTriple *bezt)
if (ked->data) {
KeyframeEdit_LassoData *data = ked->data;
float pt[2];
-
+
/* late-binding remap of the x values (for summary channels) */
/* XXX: Ideally we reset, but it should be fine just leaving it as-is
* as the next channel will reset it properly, while the next summary-channel
@@ -591,11 +591,11 @@ static short ok_bezier_channel_lasso(KeyframeEditData *ked, BezTriple *bezt)
data->rectf_scaled->xmin = ked->f1;
data->rectf_scaled->xmax = ked->f2;
}
-
+
/* only use the x-coordinate of the point; the y is the channel range... */
pt[0] = bezt->vec[1][0];
pt[1] = ked->channel_y;
-
+
if (keyframe_region_lasso_test(data, pt))
return KEYFRAME_OK_KEY;
}
@@ -611,14 +611,14 @@ bool keyframe_region_circle_test(
{
if (BLI_rctf_isect_pt_v(data_circle->rectf_scaled, xy)) {
float xy_view[2];
-
+
BLI_rctf_transform_pt_v(data_circle->rectf_view, data_circle->rectf_scaled, xy_view, xy);
-
+
xy_view[0] = xy_view[0] - data_circle->mval[0];
xy_view[1] = xy_view[1] - data_circle->mval[1];
return len_squared_v2(xy_view) < data_circle->radius_squared;
}
-
+
return false;
}
@@ -628,11 +628,11 @@ static short ok_bezier_region_circle(KeyframeEditData *ked, BezTriple *bezt)
/* check for circle select customdata (KeyframeEdit_CircleData) */
if (ked->data) {
short ok = 0;
-
+
#define KEY_CHECK_OK(_index) keyframe_region_circle_test(ked->data, bezt->vec[_index])
KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
#undef KEY_CHECK_OK
-
+
/* return ok flags */
return ok;
}
@@ -646,7 +646,7 @@ static short ok_bezier_channel_circle(KeyframeEditData *ked, BezTriple *bezt)
if (ked->data) {
KeyframeEdit_CircleData *data = ked->data;
float pt[2];
-
+
/* late-binding remap of the x values (for summary channels) */
/* XXX: Ideally we reset, but it should be fine just leaving it as-is
* as the next channel will reset it properly, while the next summary-channel
@@ -656,11 +656,11 @@ static short ok_bezier_channel_circle(KeyframeEditData *ked, BezTriple *bezt)
data->rectf_scaled->xmin = ked->f1;
data->rectf_scaled->xmax = ked->f2;
}
-
+
/* only use the x-coordinate of the point; the y is the channel range... */
pt[0] = bezt->vec[1][0];
pt[1] = ked->channel_y;
-
+
if (keyframe_region_circle_test(data, pt))
return KEYFRAME_OK_KEY;
}
@@ -707,16 +707,16 @@ short bezt_calc_average(KeyframeEditData *ked, BezTriple *bezt)
if (bezt->f2 & SELECT) {
/* store average time in float 1 (only do rounding at last step) */
ked->f1 += bezt->vec[1][0];
-
- /* store average value in float 2 (only do rounding at last step)
+
+ /* store average value in float 2 (only do rounding at last step)
* - this isn't always needed, but some operators may also require this
*/
ked->f2 += bezt->vec[1][1];
-
+
/* increment number of items */
ked->i1++;
}
-
+
return 0;
}
@@ -727,24 +727,24 @@ short bezt_to_cfraelem(KeyframeEditData *ked, BezTriple *bezt)
if (bezt->f2 & SELECT) {
CfraElem *ce = MEM_callocN(sizeof(CfraElem), "cfraElem");
BLI_addtail(&ked->list, ce);
-
+
ce->cfra = bezt->vec[1][0];
}
-
+
return 0;
}
/* used to remap times from one range to another
- * requires: ked->data = KeyframeEditCD_Remap
+ * requires: ked->data = KeyframeEditCD_Remap
*/
void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt)
{
KeyframeEditCD_Remap *rmap = (KeyframeEditCD_Remap *)ked->data;
const float scale = (rmap->newMax - rmap->newMin) / (rmap->oldMax - rmap->oldMin);
-
+
/* perform transform on all three handles unless indicated otherwise */
// TODO: need to include some checks for that
-
+
bezt->vec[0][0] = scale * (bezt->vec[0][0] - rmap->oldMin) + rmap->newMin;
bezt->vec[1][0] = scale * (bezt->vec[1][0] - rmap->oldMin) + rmap->newMin;
bezt->vec[2][0] = scale * (bezt->vec[2][0] - rmap->oldMin) + rmap->newMin;
@@ -766,7 +766,7 @@ static short snap_bezier_nearestsec(KeyframeEditData *ked, BezTriple *bezt)
{
const Scene *scene = ked->scene;
const float secf = (float)FPS;
-
+
if (bezt->f2 & SELECT)
bezt->vec[1][0] = (floorf(bezt->vec[1][0] / secf + 0.5f) * secf);
return 0;
@@ -794,7 +794,7 @@ static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *be
{
if (bezt->f2 & SELECT) {
bezt->vec[0][1] = bezt->vec[2][1] = bezt->vec[1][1];
-
+
if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h1 = HD_ALIGN;
if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h2 = HD_ALIGN;
}
@@ -871,11 +871,11 @@ static void mirror_bezier_yaxis_ex(BezTriple *bezt, const float center)
static short mirror_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt)
{
const Scene *scene = ked->scene;
-
+
if (bezt->f2 & SELECT) {
mirror_bezier_xaxis_ex(bezt, CFRA);
}
-
+
return 0;
}
@@ -885,7 +885,7 @@ static short mirror_bezier_yaxis(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
/* Yes, names are inverted, we are mirroring accross y axis, hence along x axis... */
mirror_bezier_xaxis_ex(bezt, 0.0f);
}
-
+
return 0;
}
@@ -895,7 +895,7 @@ static short mirror_bezier_xaxis(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
/* Yes, names are inverted, we are mirroring accross x axis, hence along y axis... */
mirror_bezier_yaxis_ex(bezt, 0.0f);
}
-
+
return 0;
}
@@ -905,7 +905,7 @@ static short mirror_bezier_marker(KeyframeEditData *ked, BezTriple *bezt)
if (bezt->f2 & SELECT) {
mirror_bezier_xaxis_ex(bezt, ked->f1);
}
-
+
return 0;
}
@@ -915,7 +915,7 @@ static short mirror_bezier_time(KeyframeEditData *ked, BezTriple *bezt)
if (bezt->f2 & SELECT) {
mirror_bezier_xaxis_ex(bezt, ked->f1);
}
-
+
return 0;
}
@@ -925,7 +925,7 @@ static short mirror_bezier_value(KeyframeEditData *ked, BezTriple *bezt)
if (bezt->f2 & SELECT) {
mirror_bezier_yaxis_ex(bezt, ked->f1);
}
-
+
return 0;
}
@@ -941,7 +941,7 @@ KeyframeEditFunc ANIM_editkeyframes_mirror(short type)
case MIRROR_KEYS_XAXIS: /* mirror over value 0 */
return mirror_bezier_xaxis;
case MIRROR_KEYS_MARKER: /* mirror over marker */
- return mirror_bezier_marker;
+ return mirror_bezier_marker;
case MIRROR_KEYS_TIME: /* mirror over frame/time */
return mirror_bezier_time;
case MIRROR_KEYS_VALUE: /* mirror over given value */
@@ -966,12 +966,12 @@ KeyframeEditFunc ANIM_editkeyframes_mirror(short type)
} (void)0
/* Sets the selected bezier handles to type 'auto' */
-static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
if (bezt->f1 & SELECT) bezt->h1 = HD_AUTO;
if (bezt->f3 & SELECT) bezt->h2 = HD_AUTO;
-
+
ENSURE_HANDLES_MATCH(bezt);
}
return 0;
@@ -980,19 +980,19 @@ static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
/* Sets the selected bezier handles to type 'auto-clamped'
* NOTE: this is like auto above, but they're handled a bit different
*/
-static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
if (bezt->f1 & SELECT) bezt->h1 = HD_AUTO_ANIM;
if (bezt->f3 & SELECT) bezt->h2 = HD_AUTO_ANIM;
-
+
ENSURE_HANDLES_MATCH(bezt);
}
return 0;
}
/* Sets the selected bezier handles to type 'vector' */
-static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
if (bezt->f1 & SELECT) bezt->h1 = HD_VECT;
if (bezt->f3 & SELECT) bezt->h2 = HD_VECT;
@@ -1002,7 +1002,7 @@ static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
/* Queries if the handle should be set to 'free' or 'align' */
// NOTE: this was used for the 'toggle free/align' option
// currently this isn't used, but may be restored later
-static short bezier_isfree(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+static short bezier_isfree(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
if ((bezt->f1 & SELECT) && (bezt->h1)) return 1;
if ((bezt->f3 & SELECT) && (bezt->h2)) return 1;
@@ -1010,15 +1010,15 @@ static short bezier_isfree(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
}
/* Sets selected bezier handles to type 'align' */
-static short set_bezier_align(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
-{
+static short set_bezier_align(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+{
if (bezt->f1 & SELECT) bezt->h1 = HD_ALIGN;
if (bezt->f3 & SELECT) bezt->h2 = HD_ALIGN;
return 0;
}
/* Sets selected bezier handles to type 'free' */
-static short set_bezier_free(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+static short set_bezier_free(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
if (bezt->f1 & SELECT) bezt->h1 = HD_FREE;
if (bezt->f3 & SELECT) bezt->h2 = HD_FREE;
@@ -1034,14 +1034,14 @@ KeyframeEditFunc ANIM_editkeyframes_handles(short code)
return set_bezier_auto;
case HD_AUTO_ANIM: /* auto clamped */
return set_bezier_auto_clamped;
-
+
case HD_VECT: /* vector */
return set_bezier_vector;
case HD_FREE: /* free */
return set_bezier_free;
case HD_ALIGN: /* align */
return set_bezier_align;
-
+
default: /* check for toggle free or align? */
return bezier_isfree;
}
@@ -1049,23 +1049,23 @@ KeyframeEditFunc ANIM_editkeyframes_handles(short code)
/* ------- */
-static short set_bezt_constant(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+static short set_bezt_constant(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT)
bezt->ipo = BEZT_IPO_CONST;
return 0;
}
-static short set_bezt_linear(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+static short set_bezt_linear(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT)
bezt->ipo = BEZT_IPO_LIN;
return 0;
}
-static short set_bezt_bezier(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+static short set_bezt_bezier(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT)
bezt->ipo = BEZT_IPO_BEZ;
return 0;
}
@@ -1150,7 +1150,7 @@ KeyframeEditFunc ANIM_editkeyframes_ipo(short code)
return set_bezt_constant;
case BEZT_IPO_LIN: /* linear */
return set_bezt_linear;
-
+
/* easing */
case BEZT_IPO_BACK:
return set_bezt_back;
@@ -1172,7 +1172,7 @@ KeyframeEditFunc ANIM_editkeyframes_ipo(short code)
return set_bezt_quint;
case BEZT_IPO_SINE:
return set_bezt_sine;
-
+
default: /* bezier */
return set_bezt_bezier;
}
@@ -1180,37 +1180,37 @@ KeyframeEditFunc ANIM_editkeyframes_ipo(short code)
/* ------- */
-static short set_keytype_keyframe(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+static short set_keytype_keyframe(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT)
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_KEYFRAME;
return 0;
}
-static short set_keytype_breakdown(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+static short set_keytype_breakdown(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT)
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_BREAKDOWN;
return 0;
}
-static short set_keytype_extreme(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+static short set_keytype_extreme(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT)
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_EXTREME;
return 0;
}
-static short set_keytype_jitter(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+static short set_keytype_jitter(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT)
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_JITTER;
return 0;
}
-static short set_keytype_moving_hold(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+static short set_keytype_moving_hold(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT)
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_MOVEHOLD;
return 0;
}
@@ -1221,16 +1221,16 @@ KeyframeEditFunc ANIM_editkeyframes_keytype(short code)
switch (code) {
case BEZT_KEYTYPE_BREAKDOWN: /* breakdown */
return set_keytype_breakdown;
-
+
case BEZT_KEYTYPE_EXTREME: /* extreme keyframe */
return set_keytype_extreme;
-
+
case BEZT_KEYTYPE_JITTER: /* jitter keyframe */
return set_keytype_jitter;
-
+
case BEZT_KEYTYPE_MOVEHOLD: /* moving hold */
return set_keytype_moving_hold;
-
+
case BEZT_KEYTYPE_KEYFRAME: /* proper keyframe */
default:
return set_keytype_keyframe;
@@ -1273,13 +1273,13 @@ KeyframeEditFunc ANIM_editkeyframes_easing(short mode)
switch (mode) {
case BEZT_IPO_EASE_IN: /* ease in */
return set_easingtype_easein;
-
+
case BEZT_IPO_EASE_OUT: /* ease out */
return set_easingtype_easeout;
-
+
case BEZT_IPO_EASE_IN_OUT: /* both */
return set_easingtype_easeinout;
-
+
default: /* auto */
return set_easingtype_easeauto;
}
@@ -1288,7 +1288,7 @@ KeyframeEditFunc ANIM_editkeyframes_easing(short mode)
/* ******************************************* */
/* Selection */
-static short select_bezier_add(KeyframeEditData *ked, BezTriple *bezt)
+static short select_bezier_add(KeyframeEditData *ked, BezTriple *bezt)
{
/* if we've got info on what to select, use it, otherwise select all */
if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) {
@@ -1302,11 +1302,11 @@ static short select_bezier_add(KeyframeEditData *ked, BezTriple *bezt)
else {
BEZT_SEL_ALL(bezt);
}
-
+
return 0;
}
-static short select_bezier_subtract(KeyframeEditData *ked, BezTriple *bezt)
+static short select_bezier_subtract(KeyframeEditData *ked, BezTriple *bezt)
{
/* if we've got info on what to deselect, use it, otherwise deselect all */
if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) {
@@ -1320,11 +1320,11 @@ static short select_bezier_subtract(KeyframeEditData *ked, BezTriple *bezt)
else {
BEZT_DESEL_ALL(bezt);
}
-
+
return 0;
}
-static short select_bezier_invert(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+static short select_bezier_invert(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
/* Invert the selection for the whole bezier triple */
bezt->f2 ^= SELECT;
@@ -1369,33 +1369,33 @@ static short selmap_build_bezier_more(KeyframeEditData *ked, BezTriple *bezt)
FCurve *fcu = ked->fcu;
char *map = ked->data;
int i = ked->curIndex;
-
+
/* if current is selected, just make sure it stays this way */
if (BEZT_ISSEL_ANY(bezt)) {
map[i] = 1;
return 0;
}
-
+
/* if previous is selected, that means that selection should extend across */
if (i > 0) {
BezTriple *prev = bezt - 1;
-
+
if (BEZT_ISSEL_ANY(prev)) {
map[i] = 1;
return 0;
}
}
-
+
/* if next is selected, that means that selection should extend across */
if (i < (fcu->totvert - 1)) {
BezTriple *next = bezt + 1;
-
+
if (BEZT_ISSEL_ANY(next)) {
map[i] = 1;
return 0;
}
}
-
+
return 0;
}
@@ -1404,7 +1404,7 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt)
FCurve *fcu = ked->fcu;
char *map = ked->data;
int i = ked->curIndex;
-
+
/* if current is selected, check the left/right keyframes
* since it might need to be deselected (but otherwise no)
*/
@@ -1412,7 +1412,7 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt)
/* if previous is not selected, we're on the tip of an iceberg */
if (i > 0) {
BezTriple *prev = bezt - 1;
-
+
if (BEZT_ISSEL_ANY(prev) == 0)
return 0;
}
@@ -1420,11 +1420,11 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt)
/* current keyframe is selected at an endpoint, so should get deselected */
return 0;
}
-
+
/* if next is not selected, we're on the tip of an iceberg */
if (i < (fcu->totvert - 1)) {
BezTriple *next = bezt + 1;
-
+
if (BEZT_ISSEL_ANY(next) == 0)
return 0;
}
@@ -1432,11 +1432,11 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt)
/* current keyframe is selected at an endpoint, so should get deselected */
return 0;
}
-
+
/* if we're still here, that means that keyframe should remain untouched */
map[i] = 1;
}
-
+
return 0;
}
@@ -1446,7 +1446,7 @@ KeyframeEditFunc ANIM_editkeyframes_buildselmap(short mode)
switch (mode) {
case SELMAP_LESS: /* less */
return selmap_build_bezier_less;
-
+
case SELMAP_MORE: /* more */
default:
return selmap_build_bezier_more;
@@ -1460,7 +1460,7 @@ short bezt_selmap_flush(KeyframeEditData *ked, BezTriple *bezt)
{
const char *map = ked->data;
short on = map[ked->curIndex];
-
+
/* select or deselect based on whether the map allows it or not */
if (on) {
BEZT_SEL_ALL(bezt);
@@ -1468,7 +1468,7 @@ short bezt_selmap_flush(KeyframeEditData *ked, BezTriple *bezt)
else {
BEZT_DESEL_ALL(bezt);
}
-
+
return 0;
}
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index bf5d4ec0300..a6ed6643257 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -48,6 +48,7 @@
#include "BKE_fcurve.h"
#include "BKE_report.h"
#include "BKE_library.h"
+#include "BKE_main.h"
#include "BKE_global.h"
#include "BKE_deform.h"
@@ -62,25 +63,25 @@
* (i.e. they will modify the order of the keyframes, and change the size of the array).
* While some of these tools may eventually be moved out into blenkernel, for now, it is
* fine to have these calls here.
- *
+ *
* There are also a few tools here which cannot be easily coded for in the other system (yet).
* These may also be moved around at some point, but for now, they are best added here.
*
* - Joshua Leung, Dec 2008
*/
-
+
/* **************************************************** */
-/* Only delete the nominated keyframe from provided F-Curve.
+/* Only delete the nominated keyframe from provided F-Curve.
* Not recommended to be used many times successively. For that
- * there is delete_fcurve_keys().
+ * there is delete_fcurve_keys().
*/
void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc)
{
/* sanity check */
- if (fcu == NULL)
+ if (fcu == NULL)
return;
-
+
/* verify the index:
* 1) cannot be greater than the number of available keyframes
* 2) negative indices are for specifying a value from the end of the array
@@ -89,7 +90,7 @@ void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc)
return;
else if (index < 0)
index += fcu->totvert;
-
+
/* Delete this keyframe */
memmove(&fcu->bezt[index], &fcu->bezt[index + 1], sizeof(BezTriple) * (fcu->totvert - index - 1));
fcu->totvert--;
@@ -99,7 +100,7 @@ void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc)
MEM_freeN(fcu->bezt);
fcu->bezt = NULL;
}
-
+
/* recalc handles - only if it won't cause problems */
if (do_recalc)
calchandles_fcurve(fcu);
@@ -110,7 +111,7 @@ bool delete_fcurve_keys(FCurve *fcu)
{
int i;
bool changed = false;
-
+
if (fcu->bezt == NULL) /* ignore baked curves */
return false;
@@ -123,7 +124,7 @@ bool delete_fcurve_keys(FCurve *fcu)
changed = true;
}
}
-
+
/* Free the array of BezTriples if there are not keyframes */
if (fcu->totvert == 0)
clear_fcurve_keys(fcu);
@@ -148,30 +149,30 @@ void duplicate_fcurve_keys(FCurve *fcu)
{
BezTriple *newbezt;
int i;
-
+
/* this can only work when there is an F-Curve, and also when there are some BezTriples */
if (ELEM(NULL, fcu, fcu->bezt))
return;
-
+
for (i = 0; i < fcu->totvert; i++) {
/* If a key is selected */
if (fcu->bezt[i].f2 & SELECT) {
/* Expand the list */
newbezt = MEM_callocN(sizeof(BezTriple) * (fcu->totvert + 1), "beztriple");
-
+
memcpy(newbezt, fcu->bezt, sizeof(BezTriple) * (i + 1));
memcpy(newbezt + i + 1, fcu->bezt + i, sizeof(BezTriple));
memcpy(newbezt + i + 2, fcu->bezt + i + 1, sizeof(BezTriple) * (fcu->totvert - (i + 1)));
fcu->totvert++;
-
+
/* reassign pointers... (free old, and add new) */
MEM_freeN(fcu->bezt);
fcu->bezt = newbezt;
-
+
/* Unselect the current key */
BEZT_DESEL_ALL(&fcu->bezt[i]);
i++;
-
+
/* Select the copied key */
BEZT_SEL_ALL(&fcu->bezt[i]);
}
@@ -189,7 +190,7 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
BezTriple *old_bezts, *bezt, *beztn;
BezTriple *lastb;
int totCount, i;
-
+
/* check if any points */
if ((fcu == NULL) || (fcu->bezt == NULL) || (fcu->totvert == 0) ||
(!cleardefault && fcu->totvert == 1))
@@ -202,7 +203,7 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
totCount = fcu->totvert;
fcu->bezt = NULL;
fcu->totvert = 0;
-
+
/* now insert first keyframe, as it should be ok */
bezt = old_bezts;
insert_vert_fcurve(fcu, bezt->vec[1][0], bezt->vec[1][1], BEZKEYTYPE(bezt), 0);
@@ -210,8 +211,8 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
lastb = fcu->bezt;
lastb->f1 = lastb->f2 = lastb->f3 = 0;
}
-
- /* Loop through BezTriples, comparing them. Skip any that do
+
+ /* Loop through BezTriples, comparing them. Skip any that do
* not fit the criteria for "ok" points.
*/
for (i = 1; i < totCount; i++) {
@@ -228,22 +229,22 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
}
lastb = (fcu->bezt + (fcu->totvert - 1));
bezt = (old_bezts + i);
-
+
/* get references for quicker access */
prev[0] = lastb->vec[1][0]; prev[1] = lastb->vec[1][1];
cur[0] = bezt->vec[1][0]; cur[1] = bezt->vec[1][1];
-
+
if (!(bezt->f2 & SELECT)) {
insert_vert_fcurve(fcu, cur[0], cur[1], BEZKEYTYPE(bezt), 0);
lastb = (fcu->bezt + (fcu->totvert - 1));
lastb->f1 = lastb->f2 = lastb->f3 = 0;
continue;
}
-
+
/* check if current bezt occurs at same time as last ok */
if (IS_EQT(cur[0], prev[0], thresh)) {
- /* If there is a next beztriple, and if occurs at the same time, only insert
- * if there is a considerable distance between the points, and also if the
+ /* If there is a next beztriple, and if occurs at the same time, only insert
+ * if there is a considerable distance between the points, and also if the
* current is further away than the next one is to the previous.
*/
if (beztn && (IS_EQT(cur[0], next[0], thresh)) &&
@@ -287,7 +288,7 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
}
}
}
-
+
/* now free the memory used by the old BezTriples */
if (old_bezts)
MEM_freeN(old_bezts);
@@ -346,14 +347,14 @@ void smooth_fcurve(FCurve *fcu)
if (BEZT_ISSEL_ANY(bezt))
totSel++;
}
-
+
/* if any points were selected, allocate tSmooth_Bezt points to work on */
if (totSel >= 3) {
tSmooth_Bezt *tarray, *tsb;
-
+
/* allocate memory in one go */
tsb = tarray = MEM_callocN(totSel * sizeof(tSmooth_Bezt), "tSmooth_Bezt Array");
-
+
/* populate tarray with data of selected points */
bezt = fcu->bezt;
for (i = 0, x = 0; (i < fcu->totvert) && (x < totSel); i++, bezt++) {
@@ -362,7 +363,7 @@ void smooth_fcurve(FCurve *fcu)
tsb->h1 = &bezt->vec[0][1];
tsb->h2 = &bezt->vec[1][1];
tsb->h3 = &bezt->vec[2][1];
-
+
/* advance to the next tsb to populate */
if (x < totSel - 1)
tsb++;
@@ -370,15 +371,15 @@ void smooth_fcurve(FCurve *fcu)
break;
}
}
-
+
/* calculate the new smoothed F-Curve's with weighted averages:
* - this is done with two passes to avoid progressive corruption errors
* - uses 5 points for each operation (which stores in the relevant handles)
* - previous: w/a ratio = 3:5:2:1:1
* - next: w/a ratio = 1:1:2:5:3
*/
-
- /* round 1: calculate smoothing deltas and new values */
+
+ /* round 1: calculate smoothing deltas and new values */
tsb = tarray;
for (i = 0; i < totSel; i++, tsb++) {
/* don't touch end points (otherwise, curves slowly explode, as we don't have enough data there) */
@@ -387,21 +388,21 @@ void smooth_fcurve(FCurve *fcu)
const tSmooth_Bezt *tP2 = (i - 2 > 0) ? (tsb - 2) : (NULL);
const tSmooth_Bezt *tN1 = tsb + 1;
const tSmooth_Bezt *tN2 = (i + 2 < totSel) ? (tsb + 2) : (NULL);
-
+
const float p1 = *tP1->h2;
const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2);
const float c1 = *tsb->h2;
const float n1 = *tN1->h2;
const float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2);
-
+
/* calculate previous and next, then new position by averaging these */
tsb->y1 = (3 * p2 + 5 * p1 + 2 * c1 + n1 + n2) / 12;
tsb->y3 = (p2 + p1 + 2 * c1 + 5 * n1 + 3 * n2) / 12;
-
+
tsb->y2 = (tsb->y1 + tsb->y3) / 2;
}
}
-
+
/* round 2: apply new values */
tsb = tarray;
for (i = 0; i < totSel; i++, tsb++) {
@@ -409,17 +410,17 @@ void smooth_fcurve(FCurve *fcu)
if (ELEM(i, 0, (totSel - 1)) == 0) {
/* y2 takes the average of the 2 points */
*tsb->h2 = tsb->y2;
-
+
/* handles are weighted between their original values and the averaged values */
- *tsb->h1 = ((*tsb->h1) * 0.7f) + (tsb->y1 * 0.3f);
+ *tsb->h1 = ((*tsb->h1) * 0.7f) + (tsb->y1 * 0.3f);
*tsb->h3 = ((*tsb->h3) * 0.7f) + (tsb->y3 * 0.3f);
}
}
-
+
/* free memory required for tarray */
MEM_freeN(tarray);
}
-
+
/* recalculate handles */
calchandles_fcurve(fcu);
}
@@ -442,7 +443,7 @@ void sample_fcurve(FCurve *fcu)
if (fcu->bezt == NULL) /* ignore baked */
return;
-
+
/* find selected keyframes... once pair has been found, add keyframes */
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
/* check if selected, and which end this is */
@@ -459,39 +460,39 @@ void sample_fcurve(FCurve *fcu)
continue;
}
}
-
+
/* set end */
end = bezt;
-
+
/* cache values then add keyframes using these values, as adding
* keyframes while sampling will affect the outcome...
* - only start sampling+adding from index=1, so that we don't overwrite original keyframe
*/
range = (int)(ceil(end->vec[1][0] - start->vec[1][0]));
sfra = (int)(floor(start->vec[1][0]));
-
+
if (range) {
value_cache = MEM_callocN(sizeof(TempFrameValCache) * range, "IcuFrameValCache");
-
+
/* sample values */
for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
fp->frame = (float)(sfra + n);
fp->val = evaluate_fcurve(fcu, fp->frame);
}
-
+
/* add keyframes with these, tagging as 'breakdowns' */
for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
insert_vert_fcurve(fcu, fp->frame, fp->val, BEZT_KEYTYPE_BREAKDOWN, 1);
}
-
+
/* free temp cache */
MEM_freeN(value_cache);
-
+
/* as we added keyframes, we need to compensate so that bezt is at the right place */
bezt = fcu->bezt + i + range - 1;
i += (range - 1);
}
-
+
/* the current selection island has ended, so start again from scratch */
start = NULL;
end = NULL;
@@ -503,14 +504,14 @@ void sample_fcurve(FCurve *fcu)
}
}
}
-
+
/* recalculate channel's handles? */
calchandles_fcurve(fcu);
}
/* **************************************************** */
/* Copy/Paste Tools */
-/* - The copy/paste buffer currently stores a set of temporary F-Curves containing only the keyframes
+/* - The copy/paste buffer currently stores a set of temporary F-Curves containing only the keyframes
* that were selected in each of the original F-Curves
* - All pasted frames are offset by the same amount. This is calculated as the difference in the times of
* the current frame and the 'first keyframe' (i.e. the earliest one in all channels).
@@ -526,12 +527,12 @@ static float animcopy_cfra = 0.0;
/* datatype for use in copy/paste buffer */
typedef struct tAnimCopybufItem {
struct tAnimCopybufItem *next, *prev;
-
+
ID *id; /* ID which owns the curve */
bActionGroup *grp; /* Action Group */
char *rna_path; /* RNA-Path */
int array_index; /* array index */
-
+
int totvert; /* number of keyframes stored for this channel */
BezTriple *bezt; /* keyframes in buffer */
@@ -544,23 +545,23 @@ typedef struct tAnimCopybufItem {
void ANIM_fcurves_copybuf_free(void)
{
tAnimCopybufItem *aci, *acn;
-
+
/* free each buffer element */
for (aci = animcopybuf.first; aci; aci = acn) {
acn = aci->next;
-
+
/* free keyframes */
- if (aci->bezt)
+ if (aci->bezt)
MEM_freeN(aci->bezt);
-
+
/* free RNA-path */
if (aci->rna_path)
MEM_freeN(aci->rna_path);
-
+
/* free ourself */
BLI_freelinkN(&animcopybuf, aci);
}
-
+
/* restore initial state */
BLI_listbase_clear(&animcopybuf);
animcopy_firstframe = 999999999.0f;
@@ -571,27 +572,27 @@ void ANIM_fcurves_copybuf_free(void)
/* This function adds data to the keyframes copy/paste buffer, freeing existing data first */
short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
-{
+{
bAnimListElem *ale;
Scene *scene = ac->scene;
-
+
/* clear buffer first */
ANIM_fcurves_copybuf_free();
-
+
/* assume that each of these is an F-Curve */
for (ale = anim_data->first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
tAnimCopybufItem *aci;
BezTriple *bezt, *nbezt, *newbuf;
int i;
-
+
/* firstly, check if F-Curve has any selected keyframes
* - skip if no selected keyframes found (so no need to create unnecessary copy-buffer data)
* - this check should also eliminate any problems associated with using sample-data
*/
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ANIM_editkeyframes_ok(BEZT_OK_SELECTED), NULL) == 0)
continue;
-
+
/* init copybuf item info */
aci = MEM_callocN(sizeof(tAnimCopybufItem), "AnimCopybufItem");
aci->id = ale->id;
@@ -599,7 +600,7 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
aci->grp = fcu->grp;
aci->rna_path = MEM_dupallocN(fcu->rna_path);
aci->array_index = fcu->array_index;
-
+
/* detect if this is a bone. We do that here rather than during pasting because ID pointers will get invalidated if we undo.
* storing the relevant information here helps avoiding crashes if we undo-repaste */
if ((aci->id_type == ID_OB) && (((Object *)aci->id)->type == OB_ARMATURE) && aci->rna_path) {
@@ -614,9 +615,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
}
if (bone_name) MEM_freeN(bone_name);
}
-
+
BLI_addtail(&animcopybuf, aci);
-
+
/* add selected keyframes to buffer */
/* TODO: currently, we resize array every time we add a new vert -
* this works ok as long as it is assumed only a few keys are copied */
@@ -624,23 +625,23 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
if (BEZT_ISSEL_ANY(bezt)) {
/* add to buffer */
newbuf = MEM_callocN(sizeof(BezTriple) * (aci->totvert + 1), "copybuf beztriple");
-
+
/* assume that since we are just re-sizing the array, just copy all existing data across */
if (aci->bezt)
memcpy(newbuf, aci->bezt, sizeof(BezTriple) * (aci->totvert));
-
+
/* copy current beztriple across too */
nbezt = &newbuf[aci->totvert];
*nbezt = *bezt;
-
+
/* ensure copy buffer is selected so pasted keys are selected */
BEZT_SEL_ALL(nbezt);
-
+
/* free old array and set the new */
if (aci->bezt) MEM_freeN(aci->bezt);
aci->bezt = newbuf;
aci->totvert++;
-
+
/* check if this is the earliest frame encountered so far */
if (bezt->vec[1][0] < animcopy_firstframe)
animcopy_firstframe = bezt->vec[1][0];
@@ -648,9 +649,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
animcopy_lastframe = bezt->vec[1][0];
}
}
-
+
}
-
+
/* check if anything ended up in the buffer */
if (ELEM(NULL, animcopybuf.first, animcopybuf.last))
return -1;
@@ -729,7 +730,8 @@ static tAnimCopybufItem *pastebuf_match_path_full(FCurve *fcu, const short from_
}
/* medium match strictness: path match only (i.e. ignore ID) */
-static tAnimCopybufItem *pastebuf_match_path_property(FCurve *fcu, const short from_single, const short UNUSED(to_simple))
+static tAnimCopybufItem *pastebuf_match_path_property(
+ Main *bmain, FCurve *fcu, const short from_single, const short UNUSED(to_simple))
{
tAnimCopybufItem *aci;
@@ -740,18 +742,18 @@ static tAnimCopybufItem *pastebuf_match_path_property(FCurve *fcu, const short f
* more involved since it needs to to path lookups.
* This is not 100% reliable since the user could be editing the curves on a path that wont
* resolve, or a bone could be renamed after copying for eg. but in normal copy & paste
- * this should work out ok.
+ * this should work out ok.
*/
- if (BLI_findindex(which_libbase(G.main, aci->id_type), aci->id) == -1) {
+ if (BLI_findindex(which_libbase(bmain, aci->id_type), aci->id) == -1) {
/* pedantic but the ID could have been removed, and beats crashing! */
printf("paste_animedit_keys: error ID has been removed!\n");
}
else {
PointerRNA id_ptr, rptr;
PropertyRNA *prop;
-
+
RNA_id_pointer_create(aci->id, &id_ptr);
-
+
if (RNA_path_resolve_property(&id_ptr, aci->rna_path, &rptr, &prop)) {
const char *identifier = RNA_property_identifier(prop);
int len_id = strlen(identifier);
@@ -804,7 +806,7 @@ static void do_curve_mirror_flippping(tAnimCopybufItem *aci, BezTriple *bezt)
flip = true;
else if (BLI_strn_endswith(aci->rna_path, "rotation_axis_angle", slength) && ELEM(aci->array_index, 2, 3))
flip = true;
-
+
if (flip) {
bezt->vec[0][1] = -bezt->vec[0][1];
bezt->vec[1][1] = -bezt->vec[1][1];
@@ -829,18 +831,18 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float
case KEYFRAME_PASTE_MERGE_MIX:
/* do-nothing */
break;
-
+
case KEYFRAME_PASTE_MERGE_OVER:
/* remove all keys */
clear_fcurve_keys(fcu);
break;
-
+
case KEYFRAME_PASTE_MERGE_OVER_RANGE:
case KEYFRAME_PASTE_MERGE_OVER_RANGE_ALL:
{
float f_min;
float f_max;
-
+
if (merge_mode == KEYFRAME_PASTE_MERGE_OVER_RANGE) {
f_min = aci->bezt[0].vec[1][0] + offset;
f_max = aci->bezt[aci->totvert - 1].vec[1][0] + offset;
@@ -849,7 +851,7 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float
f_min = animcopy_firstframe + offset;
f_max = animcopy_lastframe + offset;
}
-
+
/* remove keys in range */
if (f_min < f_max) {
/* select verts in range for removal */
@@ -858,39 +860,39 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float
bezt->f2 |= SELECT;
}
}
-
+
/* remove frames in the range */
delete_fcurve_keys(fcu);
}
break;
}
}
-
+
/* just start pasting, with the first keyframe on the current frame, and so on */
for (i = 0, bezt = aci->bezt; i < aci->totvert; i++, bezt++) {
/* temporarily apply offset to src beztriple while copying */
if (flip)
do_curve_mirror_flippping(aci, bezt);
-
+
bezt->vec[0][0] += offset;
bezt->vec[1][0] += offset;
bezt->vec[2][0] += offset;
-
+
/* insert the keyframe
* NOTE: we do not want to inherit handles from existing keyframes in this case!
*/
-
+
insert_bezt_fcurve(fcu, bezt, INSERTKEY_OVERWRITE_FULL);
-
+
/* un-apply offset from src beztriple after copying */
bezt->vec[0][0] -= offset;
bezt->vec[1][0] -= offset;
bezt->vec[2][0] -= offset;
-
+
if (flip)
do_curve_mirror_flippping(aci, bezt);
}
-
+
/* recalculate F-Curve's handles? */
calchandles_fcurve(fcu);
}
@@ -921,12 +923,12 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data,
const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode, bool flip)
{
bAnimListElem *ale;
-
+
const Scene *scene = (ac->scene);
-
+
const bool from_single = BLI_listbase_is_single(&animcopybuf);
const bool to_simple = BLI_listbase_is_single(anim_data);
-
+
float offset = 0.0f;
int pass;
@@ -940,7 +942,7 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data,
BKE_report(ac->reports, RPT_ERROR, "No selected F-Curves to paste into");
return -1;
}
-
+
/* methods of offset */
switch (offset_mode) {
case KEYFRAME_PASTE_OFFSET_CFRA_START:
@@ -961,25 +963,25 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data,
/* 1:1 match, no tricky checking, just paste */
FCurve *fcu;
tAnimCopybufItem *aci;
-
+
ale = anim_data->first;
fcu = (FCurve *)ale->data; /* destination F-Curve */
aci = animcopybuf.first;
-
+
paste_animedit_keys_fcurve(fcu, aci, offset, merge_mode, false);
ale->update |= ANIM_UPDATE_DEFAULT;
}
else {
- /* from selected channels
+ /* from selected channels
* This "passes" system aims to try to find "matching" channels to paste keyframes
* into with increasingly loose matching heuristics. The process finishes when at least
* one F-Curve has been pasted into.
*/
for (pass = 0; pass < 3; pass++) {
unsigned int totmatch = 0;
-
+
for (ale = anim_data->first; ale; ale = ale->next) {
- /* find buffer item to paste from
+ /* find buffer item to paste from
* - if names don't matter (i.e. only 1 channel in buffer), don't check id/group
* - if names do matter, only check if id-type is ok for now (group check is not that important)
* - most importantly, rna-paths should match (array indices are unimportant for now)
@@ -987,28 +989,28 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data,
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
FCurve *fcu = (FCurve *)ale->data; /* destination F-Curve */
tAnimCopybufItem *aci = NULL;
-
+
switch (pass) {
case 0:
/* most strict, must be exact path match data_path & index */
aci = pastebuf_match_path_full(fcu, from_single, to_simple, flip);
break;
-
+
case 1:
/* less strict, just compare property names */
- aci = pastebuf_match_path_property(fcu, from_single, to_simple);
+ aci = pastebuf_match_path_property(ac->bmain, fcu, from_single, to_simple);
break;
-
+
case 2:
/* Comparing properties gave no results, so just do index comparisons */
aci = pastebuf_match_index_only(fcu, from_single, to_simple);
break;
}
-
+
/* copy the relevant data from the matching buffer curve */
if (aci) {
totmatch++;
-
+
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
paste_animedit_keys_fcurve(fcu, aci, offset, merge_mode, flip);
@@ -1018,16 +1020,16 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data,
paste_animedit_keys_fcurve(fcu, aci, offset, merge_mode, flip);
}
}
-
+
ale->update |= ANIM_UPDATE_DEFAULT;
}
-
+
/* don't continue if some fcurves were pasted */
if (totmatch)
break;
}
}
-
+
ANIM_animdata_update(ac, anim_data);
return 0;
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 67f5aef2517..1913eb944d9 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -29,7 +29,7 @@
* \ingroup edanimation
*/
-
+
#include <stdio.h>
#include <stddef.h>
#include <string.h>
@@ -53,17 +53,18 @@
#include "DNA_object_types.h"
#include "DNA_rigidbody_types.h"
-#include "BKE_animsys.h"
#include "BKE_action.h"
+#include "BKE_animsys.h"
#include "BKE_armature.h"
+#include "BKE_context.h"
#include "BKE_fcurve.h"
-#include "BKE_idcode.h"
-#include "BKE_nla.h"
#include "BKE_global.h"
-#include "BKE_context.h"
-#include "BKE_report.h"
+#include "BKE_idcode.h"
#include "BKE_key.h"
+#include "BKE_main.h"
#include "BKE_material.h"
+#include "BKE_nla.h"
+#include "BKE_report.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@@ -94,42 +95,42 @@
short ANIM_get_keyframing_flags(Scene *scene, short incl_mode)
{
eInsertKeyFlags flag = INSERTKEY_NOFLAGS;
-
+
/* standard flags */
{
/* visual keying */
- if (IS_AUTOKEY_FLAG(scene, AUTOMATKEY))
+ if (IS_AUTOKEY_FLAG(scene, AUTOMATKEY))
flag |= INSERTKEY_MATRIX;
-
+
/* only needed */
- if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED))
+ if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED))
flag |= INSERTKEY_NEEDED;
-
+
/* default F-Curve color mode - RGB from XYZ indices */
- if (IS_AUTOKEY_FLAG(scene, XYZ2RGB))
+ if (IS_AUTOKEY_FLAG(scene, XYZ2RGB))
flag |= INSERTKEY_XYZ2RGB;
}
-
+
/* only if including settings from the autokeying mode... */
if (incl_mode) {
/* keyframing mode - only replace existing keyframes */
- if (IS_AUTOKEY_MODE(scene, EDITKEYS))
+ if (IS_AUTOKEY_MODE(scene, EDITKEYS))
flag |= INSERTKEY_REPLACE;
}
-
+
return flag;
}
/* ******************************************* */
/* Animation Data Validation */
-/* Get (or add relevant data to be able to do so) the Active Action for the given
+/* Get (or add relevant data to be able to do so) the Active Action for the given
* Animation Data block, given an ID block where the Animation Data should reside.
*/
-bAction *verify_adt_action(ID *id, short add)
+bAction *verify_adt_action(Main *bmain, ID *id, short add)
{
AnimData *adt;
-
+
/* init animdata if none available yet */
adt = BKE_animdata_from_id(id);
if ((adt == NULL) && (add))
@@ -146,10 +147,10 @@ bAction *verify_adt_action(ID *id, short add)
/* init action name from name of ID block */
char actname[sizeof(id->name) - 2];
BLI_snprintf(actname, sizeof(actname), "%sAction", id->name + 2);
-
+
/* create action */
- adt->action = BKE_action_add(G.main, actname);
-
+ adt->action = BKE_action_add(bmain, actname);
+
/* set ID-type from ID-block that this is going to be assigned to
* so that users can't accidentally break actions by assigning them
* to the wrong places
@@ -158,7 +159,7 @@ bAction *verify_adt_action(ID *id, short add)
/* tag depsgraph to be rebuilt to include time dependency */
/* XXX: we probably should have bmain passed down, but that involves altering too many API's */
- DEG_relations_tag_update(G.main);
+ DEG_relations_tag_update(bmain);
}
DEG_id_tag_update(&adt->action->id, DEG_TAG_COPY_ON_WRITE);
@@ -167,54 +168,54 @@ bAction *verify_adt_action(ID *id, short add)
return adt->action;
}
-/* Get (or add relevant data to be able to do so) F-Curve from the Active Action,
+/* Get (or add relevant data to be able to do so) F-Curve from the Active Action,
* for the given Animation Data block. This assumes that all the destinations are valid.
*/
-FCurve *verify_fcurve(bAction *act, const char group[], PointerRNA *ptr,
+FCurve *verify_fcurve(bAction *act, const char group[], PointerRNA *ptr,
const char rna_path[], const int array_index, short add)
{
bActionGroup *agrp;
FCurve *fcu;
-
+
/* sanity checks */
if (ELEM(NULL, act, rna_path))
return NULL;
-
- /* try to find f-curve matching for this setting
+
+ /* try to find f-curve matching for this setting
* - add if not found and allowed to add one
* TODO: add auto-grouping support? how this works will need to be resolved
*/
fcu = list_find_fcurve(&act->curves, rna_path, array_index);
-
+
if ((fcu == NULL) && (add)) {
/* use default settings to make a F-Curve */
fcu = MEM_callocN(sizeof(FCurve), "FCurve");
-
+
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL;
if (BLI_listbase_is_empty(&act->curves))
fcu->flag |= FCURVE_ACTIVE; /* first one added active */
-
+
/* store path - make copy, and store that */
fcu->rna_path = BLI_strdup(rna_path);
fcu->array_index = array_index;
-
+
/* if a group name has been provided, try to add or find a group, then add F-Curve to it */
if (group) {
/* try to find group */
agrp = BKE_action_group_find_name(act, group);
-
+
/* no matching groups, so add one */
if (agrp == NULL) {
agrp = action_groups_add_new(act, group);
-
+
/* sync bone group colors if applicable */
if (ptr && (ptr->type == &RNA_PoseBone)) {
Object *ob = (Object *)ptr->id.data;
bPoseChannel *pchan = (bPoseChannel *)ptr->data;
bPose *pose = ob->pose;
bActionGroup *grp;
-
+
/* find bone group (if present), and use the color from that */
grp = (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1));
if (grp) {
@@ -223,7 +224,7 @@ FCurve *verify_fcurve(bAction *act, const char group[], PointerRNA *ptr,
}
}
}
-
+
/* add F-Curve to group */
action_groups_add_channel(act, agrp, fcu);
}
@@ -232,7 +233,7 @@ FCurve *verify_fcurve(bAction *act, const char group[], PointerRNA *ptr,
BLI_addtail(&act->curves, fcu);
}
}
-
+
/* return the F-Curve */
return fcu;
}
@@ -285,10 +286,10 @@ void update_autoflags_fcurve(FCurve *fcu, bContext *C, ReportList *reports, Poin
idname, fcu->rna_path);
return;
}
-
+
/* update F-Curve flags */
update_autoflags_fcurve_direct(fcu, prop);
-
+
if (old_flag != fcu->flag) {
/* Same as if keyframes had been changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
@@ -300,22 +301,22 @@ void update_autoflags_fcurve(FCurve *fcu, bContext *C, ReportList *reports, Poin
/* -------------- BezTriple Insertion -------------------- */
-/* This function adds a given BezTriple to an F-Curve. It will allocate
+/* This function adds a given BezTriple to an F-Curve. It will allocate
* memory for the array if needed, and will insert the BezTriple into a
* suitable place in chronological order.
- *
- * NOTE: any recalculate of the F-Curve that needs to be done will need to
+ *
+ * NOTE: any recalculate of the F-Curve that needs to be done will need to
* be done by the caller.
*/
int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
{
int i = 0;
-
+
/* are there already keyframes? */
if (fcu->bezt) {
bool replace;
i = binarysearch_bezt_index(fcu->bezt, bezt->vec[1][0], fcu->totvert, &replace);
-
+
/* replace an existing keyframe? */
if (replace) {
/* sanity check: 'i' may in rare cases exceed arraylen */
@@ -327,16 +328,16 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
/* just change the values when replacing, so as to not overwrite handles */
BezTriple *dst = (fcu->bezt + i);
float dy = bezt->vec[1][1] - dst->vec[1][1];
-
+
/* just apply delta value change to the handle values */
dst->vec[0][1] += dy;
dst->vec[1][1] += dy;
dst->vec[2][1] += dy;
-
+
dst->f1 = bezt->f1;
dst->f2 = bezt->f2;
dst->f3 = bezt->f3;
-
+
/* TODO: perform some other operations? */
}
}
@@ -345,29 +346,29 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
else if ((flag & INSERTKEY_REPLACE) == 0) {
/* insert new - if we're not restricted to replacing keyframes only */
BezTriple *newb = MEM_callocN((fcu->totvert + 1) * sizeof(BezTriple), "beztriple");
-
+
/* add the beztriples that should occur before the beztriple to be pasted (originally in fcu) */
if (i > 0)
memcpy(newb, fcu->bezt, i * sizeof(BezTriple));
-
+
/* add beztriple to paste at index i */
*(newb + i) = *bezt;
-
+
/* add the beztriples that occur after the beztriple to be pasted (originally in fcu) */
- if (i < fcu->totvert)
+ if (i < fcu->totvert)
memcpy(newb + i + 1, fcu->bezt + i, (fcu->totvert - i) * sizeof(BezTriple));
-
+
/* replace (+ free) old with new, only if necessary to do so */
MEM_freeN(fcu->bezt);
fcu->bezt = newb;
-
+
fcu->totvert++;
}
}
/* no keyframes already, but can only add if...
* 1) keyframing modes say that keyframes can only be replaced, so adding new ones won't know
* 2) there are no samples on the curve
- * // NOTE: maybe we may want to allow this later when doing samples -> bezt conversions,
+ * // NOTE: maybe we may want to allow this later when doing samples -> bezt conversions,
* // but for now, having both is asking for trouble
*/
else if ((flag & INSERTKEY_REPLACE) == 0 && (fcu->fpt == NULL)) {
@@ -381,9 +382,9 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
/* return error code -1 to prevent any misunderstandings */
return -1;
}
-
-
- /* we need to return the index, so that some tools which do post-processing can
+
+
+ /* we need to return the index, so that some tools which do post-processing can
* detect where we added the BezTriple in the array
*/
return i;
@@ -391,11 +392,11 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
/**
* This function is a wrapper for insert_bezt_fcurve_internal(), and should be used when
- * adding a new keyframe to a curve, when the keyframe doesn't exist anywhere else yet.
+ * adding a new keyframe to a curve, when the keyframe doesn't exist anywhere else yet.
* It returns the index at which the keyframe was added.
*
* \param keyframe_type: The type of keyframe (eBezTriple_KeyframeType)
- * \param flag: Optional flags (eInsertKeyFlags) for controlling how keys get added
+ * \param flag: Optional flags (eInsertKeyFlags) for controlling how keys get added
* and/or whether updates get done
*/
int insert_vert_fcurve(FCurve *fcu, float x, float y, eBezTriple_KeyframeType keyframe_type, eInsertKeyFlags flag)
@@ -403,8 +404,8 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, eBezTriple_KeyframeType ke
BezTriple beztr = {{{0}}};
unsigned int oldTot = fcu->totvert;
int a;
-
- /* set all three points, for nicer start position
+
+ /* set all three points, for nicer start position
* NOTE: +/- 1 on vec.x for left and right handles is so that 'free' handles work ok...
*/
beztr.vec[0][0] = x - 1.0f;
@@ -414,7 +415,7 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, eBezTriple_KeyframeType ke
beztr.vec[2][0] = x + 1.0f;
beztr.vec[2][1] = y;
beztr.f1 = beztr.f2 = beztr.f3 = SELECT;
-
+
/* set default handle types and interpolation mode */
if (flag & INSERTKEY_NO_USERPREF) {
/* for Py-API, we want scripts to have predictable behaviour,
@@ -426,11 +427,11 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, eBezTriple_KeyframeType ke
else {
/* for UI usage - defaults should come from the userprefs and/or toolsettings */
beztr.h1 = beztr.h2 = U.keyhandles_new; /* use default handle type here */
-
+
/* use default interpolation mode, with exceptions for int/discrete values */
beztr.ipo = U.ipo_new;
}
-
+
/* interpolation type used is constrained by the type of values the curve can take */
if (fcu->flag & FCURVE_DISCRETE_VALUES) {
beztr.ipo = BEZT_IPO_CONST;
@@ -438,10 +439,10 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, eBezTriple_KeyframeType ke
else if ((beztr.ipo == BEZT_IPO_BEZ) && (fcu->flag & FCURVE_INT_VALUES)) {
beztr.ipo = BEZT_IPO_LIN;
}
-
+
/* set keyframe type value (supplied), which should come from the scene settings in most cases */
BEZKEYTYPE(&beztr) = keyframe_type;
-
+
/* set default values for "easing" interpolation mode settings
* NOTE: Even if these modes aren't currently used, if users switch
* to these later, we want these to work in a sane way out of
@@ -449,48 +450,48 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, eBezTriple_KeyframeType ke
*/
beztr.back = 1.70158f; /* "back" easing - this value used to be used when overshoot=0, but that */
/* introduced discontinuities in how the param worked */
-
+
beztr.amplitude = 0.8f; /* "elastic" easing - values here were hand-optimised for a default duration of */
beztr.period = 4.1f; /* ~10 frames (typical mograph motion length) */
-
+
/* add temp beztriple to keyframes */
a = insert_bezt_fcurve(fcu, &beztr, flag);
-
- /* what if 'a' is a negative index?
+
+ /* what if 'a' is a negative index?
* for now, just exit to prevent any segfaults
*/
if (a < 0) return -1;
-
+
/* don't recalculate handles if fast is set
* - this is a hack to make importers faster
* - we may calculate twice (due to autohandle needing to be calculated twice)
*/
- if ((flag & INSERTKEY_FAST) == 0)
+ if ((flag & INSERTKEY_FAST) == 0)
calchandles_fcurve(fcu);
-
+
/* set handletype and interpolation */
if ((fcu->totvert > 2) && (flag & INSERTKEY_REPLACE) == 0) {
BezTriple *bezt = (fcu->bezt + a);
-
- /* set interpolation from previous (if available), but only if we didn't just replace some keyframe
+
+ /* set interpolation from previous (if available), but only if we didn't just replace some keyframe
* - replacement is indicated by no-change in number of verts
* - when replacing, the user may have specified some interpolation that should be kept
*/
if (fcu->totvert > oldTot) {
- if (a > 0)
+ if (a > 0)
bezt->ipo = (bezt - 1)->ipo;
else if (a < fcu->totvert - 1)
bezt->ipo = (bezt + 1)->ipo;
}
-
+
/* don't recalculate handles if fast is set
* - this is a hack to make importers faster
* - we may calculate twice (due to autohandle needing to be calculated twice)
*/
- if ((flag & INSERTKEY_FAST) == 0)
+ if ((flag & INSERTKEY_FAST) == 0)
calchandles_fcurve(fcu);
}
-
+
/* return the index at which the keyframe was added */
return a;
}
@@ -515,34 +516,34 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
BezTriple *bezt = NULL, *prev = NULL;
int totCount, i;
float valA = 0.0f, valB = 0.0f;
-
+
/* safety checking */
if (fcu == NULL) return KEYNEEDED_JUSTADD;
totCount = fcu->totvert;
if (totCount == 0) return KEYNEEDED_JUSTADD;
-
+
/* loop through checking if any are the same */
bezt = fcu->bezt;
for (i = 0; i < totCount; i++) {
float prevPosi = 0.0f, prevVal = 0.0f;
float beztPosi = 0.0f, beztVal = 0.0f;
-
+
/* get current time+value */
beztPosi = bezt->vec[1][0];
beztVal = bezt->vec[1][1];
-
+
if (prev) {
/* there is a keyframe before the one currently being examined */
-
+
/* get previous time+value */
prevPosi = prev->vec[1][0];
prevVal = prev->vec[1][1];
-
+
/* keyframe to be added at point where there are already two similar points? */
if (IS_EQF(prevPosi, cFrame) && IS_EQF(beztPosi, cFrame) && IS_EQF(beztPosi, prevPosi)) {
return KEYNEEDED_DONTADD;
}
-
+
/* keyframe between prev+current points ? */
if ((prevPosi <= cFrame) && (cFrame <= beztPosi)) {
/* is the value of keyframe to be added the same as keyframes on either side ? */
@@ -551,18 +552,18 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
}
else {
float realVal;
-
+
/* get real value of curve at that point */
realVal = evaluate_fcurve(fcu, cFrame);
-
+
/* compare whether it's the same as proposed */
if (IS_EQF(realVal, nValue))
return KEYNEEDED_DONTADD;
- else
+ else
return KEYNEEDED_JUSTADD;
}
}
-
+
/* new keyframe before prev beztriple? */
if (cFrame < prevPosi) {
/* A new keyframe will be added. However, whether the previous beztriple
@@ -571,18 +572,18 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
*/
if (IS_EQF(prevVal, nValue) && IS_EQF(beztVal, nValue) && IS_EQF(prevVal, beztVal))
return KEYNEEDED_DELNEXT;
- else
+ else
return KEYNEEDED_JUSTADD;
}
}
else {
- /* just add a keyframe if there's only one keyframe
+ /* just add a keyframe if there's only one keyframe
* and the new one occurs before the existing one does.
*/
if ((cFrame < beztPosi) && (totCount == 1))
return KEYNEEDED_JUSTADD;
}
-
+
/* continue. frame to do not yet passed (or other conditions not met) */
if (i < (totCount - 1)) {
prev = bezt;
@@ -591,7 +592,7 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
else
break;
}
-
+
/* Frame in which to add a new-keyframe occurs after all other keys
* -> If there are at least two existing keyframes, then if the values of the
* last two keyframes and the new-keyframe match, the last existing keyframe
@@ -601,28 +602,30 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
*/
bezt = (fcu->bezt + (fcu->totvert - 1));
valA = bezt->vec[1][1];
-
+
if (prev)
valB = prev->vec[1][1];
- else
+ else
valB = bezt->vec[1][1] + 1.0f;
-
+
if (IS_EQF(valA, nValue) && IS_EQF(valA, valB))
return KEYNEEDED_DELPREV;
- else
+ else
return KEYNEEDED_JUSTADD;
}
/* ------------------ RNA Data-Access Functions ------------------ */
/* Try to read value using RNA-properties obtained already */
-static float setting_get_rna_value(Depsgraph *depsgraph, PointerRNA *ptr, PropertyRNA *prop, int index)
+static float setting_get_rna_value(Depsgraph *depsgraph, PointerRNA *ptr, PropertyRNA *prop, int index, const bool get_evaluated)
{
- PointerRNA ptr_eval;
+ PointerRNA ptr_eval = *ptr;
float value = 0.0f;
-
- DEG_get_evaluated_rna_pointer(depsgraph, ptr, &ptr_eval);
-
+
+ if (get_evaluated) {
+ DEG_get_evaluated_rna_pointer(depsgraph, ptr, &ptr_eval);
+ }
+
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
if (RNA_property_array_check(prop))
@@ -648,7 +651,7 @@ static float setting_get_rna_value(Depsgraph *depsgraph, PointerRNA *ptr, Proper
default:
break;
}
-
+
return value;
}
@@ -662,10 +665,10 @@ enum {
VISUALKEY_SCA,
};
-/* This helper function determines if visual-keyframing should be used when
+/* This helper function determines if visual-keyframing should be used when
* inserting keyframes for the given channel. As visual-keyframing only works
- * on Object and Pose-Channel blocks, this should only get called for those
- * blocktypes, when using "standard" keying but 'Visual Keying' option in Auto-Keying
+ * on Object and Pose-Channel blocks, this should only get called for those
+ * blocktypes, when using "standard" keying but 'Visual Keying' option in Auto-Keying
* settings is on.
*/
static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
@@ -675,12 +678,12 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
bool has_rigidbody = false;
bool has_parent = false;
const char *identifier = NULL;
-
+
/* validate data */
if (ELEM(NULL, ptr, ptr->data, prop))
return false;
-
- /* get first constraint and determine type of keyframe constraints to check for
+
+ /* get first constraint and determine type of keyframe constraints to check for
* - constraints can be on either Objects or PoseChannels, so we only check if the
* ptr->type is RNA_Object or RNA_PoseBone, which are the RNA wrapping-info for
* those structs, allowing us to identify the owner of the data
@@ -689,27 +692,27 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
/* Object */
Object *ob = (Object *)ptr->data;
RigidBodyOb *rbo = ob->rigidbody_object;
-
+
con = ob->constraints.first;
identifier = RNA_property_identifier(prop);
has_parent = (ob->parent != NULL);
-
+
/* active rigidbody objects only, as only those are affected by sim */
has_rigidbody = ((rbo) && (rbo->type == RBO_TYPE_ACTIVE));
}
else if (ptr->type == &RNA_PoseBone) {
/* Pose Channel */
bPoseChannel *pchan = (bPoseChannel *)ptr->data;
-
+
con = pchan->constraints.first;
identifier = RNA_property_identifier(prop);
has_parent = (pchan->parent != NULL);
}
-
+
/* check if any data to search using */
if (ELEM(NULL, con, identifier) && (has_parent == false) && (has_rigidbody == false))
return false;
-
+
/* location or rotation identifiers only... */
if (identifier == NULL) {
printf("%s failed: NULL identifier\n", __func__);
@@ -728,20 +731,20 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
printf("%s failed: identifier - '%s'\n", __func__, identifier);
return false;
}
-
-
+
+
/* only search if a searchtype and initial constraint are available */
if (searchtype) {
/* parent or rigidbody are always matching */
if (has_parent || has_rigidbody)
return true;
-
+
/* constraints */
for (; con; con = con->next) {
/* only consider constraint if it is not disabled, and has influence */
if (con->flag & CONSTRAINT_DISABLE) continue;
if (con->enforce == 0.0f) continue;
-
+
/* some constraints may alter these transforms */
switch (con->type) {
/* multi-transform constraints */
@@ -754,7 +757,7 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
return true;
case CONSTRAINT_TYPE_KINEMATIC:
return true;
-
+
/* single-transform constraits */
case CONSTRAINT_TYPE_TRACKTO:
if (searchtype == VISUALKEY_ROT) return true;
@@ -789,18 +792,18 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
case CONSTRAINT_TYPE_MINMAX:
if (searchtype == VISUALKEY_LOC) return true;
break;
-
+
default:
break;
}
}
}
-
+
/* when some condition is met, this function returns, so that means we've got nothing */
return false;
}
-/* This helper function extracts the value to use for visual-keyframing
+/* This helper function extracts the value to use for visual-keyframing
* In the event that it is not possible to perform visual keying, try to fall-back
* to using the default method. Assumes that all data it has been passed is valid.
*/
@@ -809,8 +812,8 @@ static float visualkey_get_value(Depsgraph *depsgraph, PointerRNA *ptr, Property
const char *identifier = RNA_property_identifier(prop);
float tmat[4][4];
int rotmode;
-
- /* handle for Objects or PoseChannels only
+
+ /* handle for Objects or PoseChannels only
* - only Location, Rotation or Scale keyframes are supported currently
* - constraints can be on either Objects or PoseChannels, so we only check if the
* ptr->type is RNA_Object or RNA_PoseBone, which are the RNA wrapping-info for
@@ -820,25 +823,25 @@ static float visualkey_get_value(Depsgraph *depsgraph, PointerRNA *ptr, Property
if (ptr->type == &RNA_Object) {
Object *ob = (Object *)ptr->data;
const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
-
+
/* Loc code is specific... */
if (strstr(identifier, "location")) {
return ob_eval->obmat[3][array_index];
}
-
+
copy_m4_m4(tmat, ob_eval->obmat);
rotmode = ob_eval->rotmode;
}
else if (ptr->type == &RNA_PoseBone) {
Object *ob = (Object *)ptr->id.data;
bPoseChannel *pchan = (bPoseChannel *)ptr->data;
-
+
const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name);
-
+
BKE_armature_mat_pose_to_bone(pchan_eval, pchan_eval->pose_mat, tmat);
rotmode = pchan_eval->rotmode;
-
+
/* Loc code is specific... */
if (strstr(identifier, "location")) {
/* only use for non-connected bones */
@@ -847,29 +850,29 @@ static float visualkey_get_value(Depsgraph *depsgraph, PointerRNA *ptr, Property
}
}
else {
- return setting_get_rna_value(depsgraph, ptr, prop, array_index);
+ return setting_get_rna_value(depsgraph, ptr, prop, array_index, true);
}
-
+
/* Rot/Scale code are common! */
if (strstr(identifier, "rotation_euler")) {
float eul[3];
-
+
mat4_to_eulO(eul, rotmode, tmat);
return eul[array_index];
}
else if (strstr(identifier, "rotation_quaternion")) {
float mat3[3][3], quat[4];
-
+
copy_m3_m4(mat3, tmat);
mat3_to_quat_is_ok(quat, mat3);
-
+
return quat[array_index];
}
else if (strstr(identifier, "rotation_axis_angle")) {
float axis[3], angle;
-
+
mat4_to_axis_angle(axis, &angle, tmat);
-
+
/* w = 0, x,y,z = 1,2,3 */
if (array_index == 0)
return angle;
@@ -878,19 +881,19 @@ static float visualkey_get_value(Depsgraph *depsgraph, PointerRNA *ptr, Property
}
else if (strstr(identifier, "scale")) {
float scale[3];
-
+
mat4_to_size(scale, tmat);
-
+
return scale[array_index];
}
-
+
/* as the function hasn't returned yet, read value from system in the default way */
- return setting_get_rna_value(depsgraph, ptr, prop, array_index);
+ return setting_get_rna_value(depsgraph, ptr, prop, array_index, true);
}
/* ------------------------- Insert Key API ------------------------- */
-/* Secondary Keyframing API call:
+/* Secondary Keyframing API call:
* Use this when validation of necessary animation data is not necessary, since an RNA-pointer to the necessary
* data being keyframed, and a pointer to the F-Curve to use have both been provided.
*
@@ -903,7 +906,7 @@ static float visualkey_get_value(Depsgraph *depsgraph, PointerRNA *ptr, Property
bool insert_keyframe_direct(Depsgraph *depsgraph, ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag)
{
float curval = 0.0f;
-
+
/* no F-Curve to add keyframe to? */
if (fcu == NULL) {
BKE_report(reports, RPT_ERROR, "No F-Curve to add keyframes to");
@@ -911,13 +914,13 @@ bool insert_keyframe_direct(Depsgraph *depsgraph, ReportList *reports, PointerRN
}
/* F-Curve not editable? */
if (fcurve_is_keyframable(fcu) == 0) {
- BKE_reportf(reports, RPT_ERROR,
+ BKE_reportf(reports, RPT_ERROR,
"F-Curve with path '%s[%d]' cannot be keyframed, ensure that it is not locked or sampled, "
"and try removing F-Modifiers",
fcu->rna_path, fcu->array_index);
return false;
}
-
+
/* if no property given yet, try to validate from F-Curve info */
if ((ptr.id.data == NULL) && (ptr.data == NULL)) {
BKE_report(reports, RPT_ERROR, "No RNA pointer available to retrieve values for keyframing from");
@@ -925,12 +928,12 @@ bool insert_keyframe_direct(Depsgraph *depsgraph, ReportList *reports, PointerRN
}
if (prop == NULL) {
PointerRNA tmp_ptr;
-
+
/* try to get property we should be affecting */
if (RNA_path_resolve_property(&ptr, fcu->rna_path, &tmp_ptr, &prop) == false) {
/* property not found... */
const char *idname = (ptr.id.data) ? ((ID *)ptr.id.data)->name : TIP_("<No ID pointer>");
-
+
BKE_reportf(reports, RPT_ERROR,
"Could not insert keyframe, as RNA path is invalid for the given ID (ID = %s, path = %s)",
idname, fcu->rna_path);
@@ -941,7 +944,7 @@ bool insert_keyframe_direct(Depsgraph *depsgraph, ReportList *reports, PointerRN
ptr = tmp_ptr;
}
}
-
+
/* update F-Curve flags to ensure proper behaviour for property type */
update_autoflags_fcurve_direct(fcu, prop);
@@ -957,33 +960,33 @@ bool insert_keyframe_direct(Depsgraph *depsgraph, ReportList *reports, PointerRN
cfra = 0.0f;
}
}
-
+
/* obtain value to give keyframe */
- if ( (flag & INSERTKEY_MATRIX) &&
+ if ( (flag & INSERTKEY_MATRIX) &&
(visualkey_can_use(&ptr, prop)) )
{
- /* visual-keying is only available for object and pchan datablocks, as
- * it works by keyframing using a value extracted from the final matrix
+ /* visual-keying is only available for object and pchan datablocks, as
+ * it works by keyframing using a value extracted from the final matrix
* instead of using the kt system to extract a value.
*/
curval = visualkey_get_value(depsgraph, &ptr, prop, fcu->array_index);
}
else {
/* read value from system */
- curval = setting_get_rna_value(depsgraph, &ptr, prop, fcu->array_index);
+ curval = setting_get_rna_value(depsgraph, &ptr, prop, fcu->array_index, false);
}
-
+
/* only insert keyframes where they are needed */
if (flag & INSERTKEY_NEEDED) {
short insert_mode;
-
+
/* check whether this curve really needs a new keyframe */
insert_mode = new_key_needed(fcu, cfra, curval);
-
+
/* insert new keyframe at current frame */
if (insert_mode)
insert_vert_fcurve(fcu, cfra, curval, keytype, flag);
-
+
/* delete keyframe immediately before/after newly added */
switch (insert_mode) {
case KEYNEEDED_DELPREV:
@@ -993,7 +996,7 @@ bool insert_keyframe_direct(Depsgraph *depsgraph, ReportList *reports, PointerRN
delete_fcurve_key(fcu, 1, 1);
break;
}
-
+
/* only return success if keyframe added */
if (insert_mode)
return true;
@@ -1001,39 +1004,41 @@ bool insert_keyframe_direct(Depsgraph *depsgraph, ReportList *reports, PointerRN
else {
/* just insert keyframe */
insert_vert_fcurve(fcu, cfra, curval, keytype, flag);
-
+
/* return success */
return true;
}
-
+
/* failed */
return false;
}
/* Main Keyframing API call:
* Use this when validation of necessary animation data is necessary, since it may not exist yet.
- *
+ *
* The flag argument is used for special settings that alter the behavior of
* the keyframe insertion. These include the 'visual' keyframing modes, quick refresh,
* and extra keyframe filtering.
*
* index of -1 keys all array indices
*/
-short insert_keyframe(Depsgraph *depsgraph, ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag)
-{
+short insert_keyframe(
+ Main *bmain, Depsgraph *depsgraph, ReportList *reports, ID *id, bAction *act,
+ const char group[], const char rna_path[], int array_index, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag)
+{
PointerRNA id_ptr, ptr;
PropertyRNA *prop = NULL;
AnimData *adt;
FCurve *fcu;
int array_index_max = array_index + 1;
int ret = 0;
-
+
/* validate pointer first - exit if failure */
if (id == NULL) {
BKE_reportf(reports, RPT_ERROR, "No ID block to insert keyframe in (path = %s)", rna_path);
return 0;
}
-
+
RNA_id_pointer_create(id, &id_ptr);
if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop) == false) {
BKE_reportf(reports, RPT_ERROR,
@@ -1041,45 +1046,45 @@ short insert_keyframe(Depsgraph *depsgraph, ReportList *reports, ID *id, bAction
(id) ? id->name : TIP_("<Missing ID block>"), rna_path);
return 0;
}
-
+
/* if no action is provided, keyframe to the default one attached to this ID-block */
if (act == NULL) {
/* get action to add F-Curve+keyframe to */
- act = verify_adt_action(id, 1);
-
+ act = verify_adt_action(bmain, id, 1);
+
if (act == NULL) {
- BKE_reportf(reports, RPT_ERROR,
+ BKE_reportf(reports, RPT_ERROR,
"Could not insert keyframe, as this type does not support animation data (ID = %s, path = %s)",
id->name, rna_path);
return 0;
}
}
-
+
/* apply NLA-mapping to frame to use (if applicable) */
adt = BKE_animdata_from_id(id);
cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
-
+
/* key entire array convenience method */
if (array_index == -1) {
array_index = 0;
array_index_max = RNA_property_array_length(&ptr, prop);
-
+
/* for single properties, increase max_index so that the property itself gets included,
- * but don't do this for standard arrays since that can cause corruption issues
+ * but don't do this for standard arrays since that can cause corruption issues
* (extra unused curves)
*/
if (array_index_max == array_index)
array_index_max++;
}
-
+
/* will only loop once unless the array index was -1 */
for (; array_index < array_index_max; array_index++) {
- /* make sure the F-Curve exists
+ /* make sure the F-Curve exists
* - if we're replacing keyframes only, DO NOT create new F-Curves if they do not exist yet
* but still try to get the F-Curve if it exists...
*/
fcu = verify_fcurve(act, group, &ptr, rna_path, array_index, (flag & INSERTKEY_REPLACE) == 0);
-
+
/* we may not have a F-Curve when we're replacing only... */
if (fcu) {
/* set color mode if the F-Curve is new (i.e. without any keyframes) */
@@ -1095,12 +1100,16 @@ short insert_keyframe(Depsgraph *depsgraph, ReportList *reports, ID *id, bAction
fcu->color_mode = FCURVE_COLOR_AUTO_YRGB;
}
}
-
+
/* insert keyframe */
ret += insert_keyframe_direct(depsgraph, reports, ptr, prop, fcu, cfra, keytype, flag);
}
}
-
+
+ if (ret) {
+ DEG_id_tag_update(&adt->action->id, DEG_TAG_COPY_ON_WRITE);
+ }
+
return ret;
}
@@ -1110,7 +1119,7 @@ short insert_keyframe(Depsgraph *depsgraph, ReportList *reports, ID *id, bAction
/* Main Keyframing API call:
* Use this when validation of necessary animation data isn't necessary as it
* already exists. It will delete a keyframe at the current frame.
- *
+ *
* The flag argument is used for special settings that alter the behavior of
* the keyframe deletion. These include the quick refresh options.
*/
@@ -1149,13 +1158,13 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
PropertyRNA *prop;
int array_index_max = array_index + 1;
int ret = 0;
-
+
/* sanity checks */
if (ELEM(NULL, id, adt)) {
BKE_report(reports, RPT_ERROR, "No ID block and/or AnimData to delete keyframe from");
return 0;
}
-
+
/* validate pointer first - exit if failure */
RNA_id_pointer_create(id, &id_ptr);
if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop) == false) {
@@ -1164,18 +1173,18 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
id->name, rna_path);
return 0;
}
-
+
/* get F-Curve
* Note: here is one of the places where we don't want new Action + F-Curve added!
* so 'add' var must be 0
*/
if (act == NULL) {
- /* if no action is provided, use the default one attached to this ID-block
+ /* if no action is provided, use the default one attached to this ID-block
* - if it doesn't exist, then we're out of options...
*/
if (adt->action) {
act = adt->action;
-
+
/* apply NLA-mapping to frame to use (if applicable) */
cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
}
@@ -1184,20 +1193,20 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
return 0;
}
}
-
+
/* key entire array convenience method */
if (array_index == -1) {
array_index = 0;
array_index_max = RNA_property_array_length(&ptr, prop);
-
+
/* for single properties, increase max_index so that the property itself gets included,
- * but don't do this for standard arrays since that can cause corruption issues
+ * but don't do this for standard arrays since that can cause corruption issues
* (extra unused curves)
*/
if (array_index_max == array_index)
array_index_max++;
}
-
+
/* will only loop once unless the array index was -1 */
for (; array_index < array_index_max; array_index++) {
FCurve *fcu = verify_fcurve(act, group, &ptr, rna_path, array_index, 0);
@@ -1216,7 +1225,7 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
ret += delete_keyframe_fcurve(adt, fcu, cfra);
}
-
+
/* return success/failure */
return ret;
}
@@ -1326,11 +1335,11 @@ static int modify_key_op_poll(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
Scene *scene = CTX_data_scene(C);
-
+
/* if no area or active scene */
- if (ELEM(NULL, sa, scene))
+ if (ELEM(NULL, sa, scene))
return false;
-
+
/* should be fine */
return true;
}
@@ -1346,19 +1355,19 @@ static int insert_key_exec(bContext *C, wmOperator *op)
int type = RNA_enum_get(op->ptr, "type");
float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
short success;
-
+
/* type is the Keying Set the user specified to use when calling the operator:
* - type == 0: use scene's active Keying Set
* - type > 0: use a user-defined Keying Set from the active scene
* - type < 0: use a builtin Keying Set
*/
- if (type == 0)
+ if (type == 0)
type = scene->active_keyingset;
if (type > 0)
ks = BLI_findlink(&scene->keyingsets, type - 1);
else
ks = BLI_findlink(&builtin_keyingsets, -type - 1);
-
+
/* report failures */
if (ks == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active keying set");
@@ -1372,12 +1381,12 @@ static int insert_key_exec(bContext *C, wmOperator *op)
ED_object_mode_toggle(C, OB_MODE_EDIT);
ob_edit_mode = true;
}
-
+
/* try to insert keyframes for the channels specified by KeyingSet */
success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
if (G.debug & G_DEBUG)
BKE_reportf(op->reports, RPT_INFO, "Keying set '%s' - successfully added %d keyframes", ks->name, success);
-
+
/* restore the edit mode if necessary */
if (ob_edit_mode) {
ED_object_mode_toggle(C, OB_MODE_EDIT);
@@ -1392,39 +1401,39 @@ static int insert_key_exec(bContext *C, wmOperator *op)
/* if the appropriate properties have been set, make a note that we've inserted something */
if (RNA_boolean_get(op->ptr, "confirm_success"))
BKE_reportf(op->reports, RPT_INFO, "Successfully added %d keyframes for keying set '%s'", success, ks->name);
-
+
/* send notifiers that keyframes have been changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
}
else
BKE_report(op->reports, RPT_WARNING, "Keying set failed to insert any keyframes");
-
+
return OPERATOR_FINISHED;
}
void ANIM_OT_keyframe_insert(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Insert Keyframe";
ot->idname = "ANIM_OT_keyframe_insert";
ot->description = "Insert keyframes on the current frame for all properties in the specified Keying Set";
-
+
/* callbacks */
- ot->exec = insert_key_exec;
+ ot->exec = insert_key_exec;
ot->poll = modify_key_op_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* keyingset to use (dynamic enum) */
prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use");
RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf);
RNA_def_property_flag(prop, PROP_HIDDEN);
ot->prop = prop;
-
- /* confirm whether a keyframe was added by showing a popup
+
+ /* confirm whether a keyframe was added by showing a popup
* - by default, this is enabled, since this operator is assumed to be called independently
*/
prop = RNA_def_boolean(ot->srna, "confirm_success", 1, "Confirm Successful Insert",
@@ -1433,68 +1442,68 @@ void ANIM_OT_keyframe_insert(wmOperatorType *ot)
}
/* Insert Key Operator (With Menu) ------------------------ */
-/* This operator checks if a menu should be shown for choosing the KeyingSet to use,
- * then calls the menu if necessary before
+/* This operator checks if a menu should be shown for choosing the KeyingSet to use,
+ * then calls the menu if necessary before
*/
static int insert_key_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
Scene *scene = CTX_data_scene(C);
-
+
/* if prompting or no active Keying Set, show the menu */
if ((scene->active_keyingset == 0) || RNA_boolean_get(op->ptr, "always_prompt")) {
uiPopupMenu *pup;
uiLayout *layout;
-
+
/* call the menu, which will call this operator again, hence the canceled */
pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE);
layout = UI_popup_menu_layout(pup);
uiItemsEnumO(layout, "ANIM_OT_keyframe_insert_menu", "type");
UI_popup_menu_end(C, pup);
-
+
return OPERATOR_INTERFACE;
}
else {
/* just call the exec() on the active keyingset */
RNA_enum_set(op->ptr, "type", 0);
RNA_boolean_set(op->ptr, "confirm_success", true);
-
+
return op->type->exec(C, op);
}
}
-
+
void ANIM_OT_keyframe_insert_menu(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Insert Keyframe Menu";
ot->idname = "ANIM_OT_keyframe_insert_menu";
ot->description = "Insert Keyframes for specified Keying Set, with menu of available Keying Sets if undefined";
-
+
/* callbacks */
ot->invoke = insert_key_menu_invoke;
- ot->exec = insert_key_exec;
+ ot->exec = insert_key_exec;
ot->poll = ED_operator_areaactive;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* keyingset to use (dynamic enum) */
prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use");
RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf);
RNA_def_property_flag(prop, PROP_HIDDEN);
ot->prop = prop;
-
- /* confirm whether a keyframe was added by showing a popup
+
+ /* confirm whether a keyframe was added by showing a popup
* - by default, this is disabled so that if a menu is shown, this doesn't come up too
*/
// XXX should this just be always on?
prop = RNA_def_boolean(ot->srna, "confirm_success", 0, "Confirm Successful Insert",
"Show a popup when the keyframes get successfully added");
RNA_def_property_flag(prop, PROP_HIDDEN);
-
- /* whether the menu should always be shown
+
+ /* whether the menu should always be shown
* - by default, the menu should only be shown when there is no active Keying Set (2.5 behavior),
* although in some cases it might be useful to always shown (pre 2.5 behavior)
*/
@@ -1511,30 +1520,30 @@ static int delete_key_exec(bContext *C, wmOperator *op)
int type = RNA_enum_get(op->ptr, "type");
float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
short success;
-
+
/* type is the Keying Set the user specified to use when calling the operator:
* - type == 0: use scene's active Keying Set
* - type > 0: use a user-defined Keying Set from the active scene
* - type < 0: use a builtin Keying Set
*/
- if (type == 0)
+ if (type == 0)
type = scene->active_keyingset;
if (type > 0)
ks = BLI_findlink(&scene->keyingsets, type - 1);
else
ks = BLI_findlink(&builtin_keyingsets, -type - 1);
-
+
/* report failure */
if (ks == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active Keying Set");
return OPERATOR_CANCELLED;
}
-
+
/* try to delete keyframes for the channels specified by KeyingSet */
success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_DELETE, cfra);
if (G.debug & G_DEBUG)
printf("KeyingSet '%s' - Successfully removed %d Keyframes\n", ks->name, success);
-
+
/* report failure or do updates? */
if (success == MODIFYKEY_INVALID_CONTEXT) {
BKE_report(op->reports, RPT_ERROR, "No suitable context info for active keying set");
@@ -1544,39 +1553,39 @@ static int delete_key_exec(bContext *C, wmOperator *op)
/* if the appropriate properties have been set, make a note that we've inserted something */
if (RNA_boolean_get(op->ptr, "confirm_success"))
BKE_reportf(op->reports, RPT_INFO, "Successfully removed %d keyframes for keying set '%s'", success, ks->name);
-
+
/* send notifiers that keyframes have been changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
}
else
BKE_report(op->reports, RPT_WARNING, "Keying set failed to remove any keyframes");
-
+
return OPERATOR_FINISHED;
}
void ANIM_OT_keyframe_delete(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Delete Keying-Set Keyframe";
ot->idname = "ANIM_OT_keyframe_delete";
ot->description = "Delete keyframes on the current frame for all properties in the specified Keying Set";
-
+
/* callbacks */
- ot->exec = delete_key_exec;
+ ot->exec = delete_key_exec;
ot->poll = modify_key_op_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* keyingset to use (dynamic enum) */
prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use");
RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf);
RNA_def_property_flag(prop, PROP_HIDDEN);
ot->prop = prop;
-
- /* confirm whether a keyframe was added by showing a popup
+
+ /* confirm whether a keyframe was added by showing a popup
* - by default, this is enabled, since this operator is assumed to be called independently
*/
RNA_def_boolean(ot->srna, "confirm_success", 1, "Confirm Successful Delete",
@@ -1587,7 +1596,7 @@ void ANIM_OT_keyframe_delete(wmOperatorType *ot)
/* NOTE: Although this version is simpler than the more generic version for KeyingSets,
* it is more useful for animators working in the 3D view.
*/
-
+
static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
{
bool changed = false;
@@ -1599,23 +1608,23 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
AnimData *adt = ob->adt;
bAction *act = adt->action;
FCurve *fcu, *fcn;
-
+
for (fcu = act->curves.first; fcu; fcu = fcn) {
bool can_delete = false;
-
+
fcn = fcu->next;
-
+
/* in pose mode, only delete the F-Curve if it belongs to a selected bone */
if (ob->mode & OB_MODE_POSE) {
if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones[")) {
bPoseChannel *pchan;
char *bone_name;
-
+
/* get bone-name, and check if this bone is selected */
bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
if (bone_name) MEM_freeN(bone_name);
-
+
/* delete if bone is selected*/
if ((pchan) && (pchan->bone)) {
if (pchan->bone->flag & BONE_SELECTED)
@@ -1627,7 +1636,7 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
/* object mode - all of Object's F-Curves are affected */
can_delete = true;
}
-
+
/* delete F-Curve completely */
if (can_delete) {
ANIM_fcurve_delete_from_animdata(NULL, adt, fcu);
@@ -1645,7 +1654,7 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
/* send updates */
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1655,13 +1664,13 @@ void ANIM_OT_keyframe_clear_v3d(wmOperatorType *ot)
ot->name = "Remove Animation";
ot->description = "Remove all keyframe animation for selected objects";
ot->idname = "ANIM_OT_keyframe_clear_v3d";
-
+
/* callbacks */
ot->invoke = WM_operator_confirm;
- ot->exec = clear_anim_v3d_exec;
-
+ ot->exec = clear_anim_v3d_exec;
+
ot->poll = ED_operator_areaactive;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1671,22 +1680,22 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
float cfra = (float)CFRA;
-
+
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
{
ID *id = &ob->id;
int success = 0;
-
+
/* just those in active action... */
if ((ob->adt) && (ob->adt->action)) {
AnimData *adt = ob->adt;
bAction *act = adt->action;
FCurve *fcu, *fcn;
const float cfra_unmap = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
-
+
for (fcu = act->curves.first; fcu; fcu = fcn) {
fcn = fcu->next;
-
+
/* don't touch protected F-Curves */
if (BKE_fcurve_is_protected(fcu)) {
BKE_reportf(op->reports, RPT_WARNING,
@@ -1694,57 +1703,57 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
fcu->rna_path, id->name + 2);
continue;
}
-
+
/* special exception for bones, as this makes this operator more convenient to use
* NOTE: This is only done in pose mode. In object mode, we're dealign with the entire object.
*/
if ((ob->mode & OB_MODE_POSE) && strstr(fcu->rna_path, "pose.bones[\"")) {
bPoseChannel *pchan;
char *bone_name;
-
+
/* get bone-name, and check if this bone is selected */
bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
if (bone_name) MEM_freeN(bone_name);
-
+
/* skip if bone is not selected */
if ((pchan) && (pchan->bone)) {
/* bones are only selected/editable if visible... */
bArmature *arm = (bArmature *)ob->data;
-
+
/* skipping - not visible on currently visible layers */
if ((arm->layer & pchan->bone->layer) == 0)
continue;
/* skipping - is currently hidden */
if (pchan->bone->flag & BONE_HIDDEN_P)
continue;
-
+
/* selection flag... */
if ((pchan->bone->flag & BONE_SELECTED) == 0)
continue;
}
}
-
- /* delete keyframes on current frame
+
+ /* delete keyframes on current frame
* WARNING: this can delete the next F-Curve, hence the "fcn" copying
*/
success += delete_keyframe_fcurve(adt, fcu, cfra_unmap);
}
}
-
+
/* report success (or failure) */
if (success)
BKE_reportf(op->reports, RPT_INFO, "Object '%s' successfully had %d keyframes removed", id->name + 2, success);
else
BKE_reportf(op->reports, RPT_ERROR, "No keyframes removed from Object '%s'", id->name + 2);
-
+
DEG_id_tag_update(&ob->id, OB_RECALC_OB);
}
CTX_DATA_END;
-
+
/* send updates */
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1754,13 +1763,13 @@ void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot)
ot->name = "Delete Keyframe";
ot->description = "Remove keyframes on current frame for selected objects and bones";
ot->idname = "ANIM_OT_keyframe_delete_v3d";
-
+
/* callbacks */
ot->invoke = WM_operator_confirm;
- ot->exec = delete_key_v3d_exec;
-
+ ot->exec = delete_key_v3d_exec;
+
ot->poll = ED_operator_areaactive;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1771,6 +1780,7 @@ void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot)
static int insert_key_button_exec(bContext *C, wmOperator *op)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
PointerRNA ptr = {{NULL}};
@@ -1783,16 +1793,16 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
const bool all = RNA_boolean_get(op->ptr, "all");
eInsertKeyFlags flag = INSERTKEY_NOFLAGS;
-
+
/* flags for inserting keyframes */
flag = ANIM_get_keyframing_flags(scene, 1);
-
+
/* try to insert keyframe using property retrieved from UI */
if (!(but = UI_context_active_but_prop_get(C, &ptr, &prop, &index))) {
/* pass event on if no active button found */
return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
}
-
+
if ((ptr.id.data && ptr.data && prop) && RNA_property_animateable(&ptr, prop)) {
if (ptr.type == &RNA_NlaStrip) {
/* Handle special properties for NLA Strips, whose F-Curves are stored on the
@@ -1801,7 +1811,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
*/
NlaStrip *strip = (NlaStrip *)ptr.data;
FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), index);
-
+
if (fcu) {
success = insert_keyframe_direct(depsgraph, op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, 0);
}
@@ -1814,9 +1824,9 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
/* Driven property - Find driver */
FCurve *fcu;
bool driven, special;
-
+
fcu = rna_get_fcurve_context_ui(C, &ptr, prop, index, NULL, NULL, &driven, &special);
-
+
if (fcu && driven) {
success = insert_keyframe_direct(depsgraph, op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, INSERTKEY_DRIVER);
}
@@ -1824,19 +1834,42 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
else {
/* standard properties */
path = RNA_path_from_ID_to_property(&ptr, prop);
-
+
if (path) {
+ const char *identifier = RNA_property_identifier(prop);
+ const char *group = NULL;
+
+ /* Special exception for keyframing transforms:
+ * Set "group" for this manually, instead of having them appearing at the bottom (ungrouped)
+ * part of the channels list. Leaving these ungrouped is not a nice user behaviour in this case.
+ *
+ * TODO: Perhaps we can extend this behaviour in future for other properties...
+ */
+ if (ptr.type == &RNA_PoseBone) {
+ bPoseChannel *pchan = (bPoseChannel *)ptr.data;
+ group = pchan->name;
+ }
+ else if ((ptr.type == &RNA_Object) &&
+ (strstr(identifier, "location") || strstr(identifier, "rotation") || strstr(identifier, "scale")))
+ {
+ /* NOTE: Keep this label in sync with the "ID" case in
+ * keyingsets_utils.py :: get_transform_generators_base_info()
+ */
+ group = "Object Transforms";
+ }
+
+
if (all) {
/* -1 indicates operating on the entire array (or the property itself otherwise) */
index = -1;
}
-
- success = insert_keyframe(depsgraph, op->reports, ptr.id.data, NULL, NULL, path, index, cfra, ts->keyframe_type, flag);
-
+
+ success = insert_keyframe(bmain, depsgraph, op->reports, ptr.id.data, NULL, group, path, index, cfra, ts->keyframe_type, flag);
+
MEM_freeN(path);
}
else {
- BKE_report(op->reports, RPT_WARNING,
+ BKE_report(op->reports, RPT_WARNING,
"Failed to resolve path to property, "
"try manually specifying this using a Keying Set instead");
}
@@ -1844,7 +1877,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
}
else {
if (prop && !RNA_property_animateable(&ptr, prop)) {
- BKE_reportf(op->reports, RPT_WARNING,
+ BKE_reportf(op->reports, RPT_WARNING,
"\"%s\" property cannot be animated",
RNA_property_identifier(prop));
}
@@ -1854,15 +1887,15 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
(void *)ptr.data, (void *)prop);
}
}
-
+
if (success) {
/* send updates */
UI_context_update_anim_flag(C);
-
+
/* send notifiers that keyframes have been changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
}
-
+
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -1872,11 +1905,11 @@ void ANIM_OT_keyframe_insert_button(wmOperatorType *ot)
ot->name = "Insert Keyframe (Buttons)";
ot->idname = "ANIM_OT_keyframe_insert_button";
ot->description = "Insert a keyframe for current UI-active property";
-
+
/* callbacks */
- ot->exec = insert_key_button_exec;
+ ot->exec = insert_key_button_exec;
ot->poll = modify_key_op_poll;
-
+
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -1896,7 +1929,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
short success = 0;
int index;
const bool all = RNA_boolean_get(op->ptr, "all");
-
+
/* try to insert keyframe using property retrieved from UI */
if (!UI_context_active_but_prop_get(C, &ptr, &prop, &index)) {
/* pass event on if no active button found */
@@ -1912,7 +1945,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
ID *id = ptr.id.data;
NlaStrip *strip = (NlaStrip *)ptr.data;
FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), 0);
-
+
if (fcu) {
if (BKE_fcurve_is_protected(fcu)) {
BKE_reportf(op->reports, RPT_WARNING,
@@ -1926,7 +1959,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
*/
bool found = false;
int i;
-
+
/* try to find index of beztriple to get rid of */
i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found);
if (found) {
@@ -1940,13 +1973,13 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
else {
/* standard properties */
path = RNA_path_from_ID_to_property(&ptr, prop);
-
+
if (path) {
if (all) {
/* -1 indicates operating on the entire array (or the property itself otherwise) */
index = -1;
}
-
+
success = delete_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index, cfra, 0);
MEM_freeN(path);
}
@@ -1957,16 +1990,16 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
else if (G.debug & G_DEBUG) {
printf("ptr.data = %p, prop = %p\n", (void *)ptr.data, (void *)prop);
}
-
-
+
+
if (success) {
/* send updates */
UI_context_update_anim_flag(C);
-
+
/* send notifiers that keyframes have been changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
}
-
+
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -1976,11 +2009,11 @@ void ANIM_OT_keyframe_delete_button(wmOperatorType *ot)
ot->name = "Delete Keyframe (Buttons)";
ot->idname = "ANIM_OT_keyframe_delete_button";
ot->description = "Delete current keyframe of current UI-active property";
-
+
/* callbacks */
- ot->exec = delete_key_button_exec;
+ ot->exec = delete_key_button_exec;
ot->poll = modify_key_op_poll;
-
+
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -2008,13 +2041,13 @@ static int clear_key_button_exec(bContext *C, wmOperator *op)
if (ptr.id.data && ptr.data && prop) {
path = RNA_path_from_ID_to_property(&ptr, prop);
-
+
if (path) {
if (all) {
/* -1 indicates operating on the entire array (or the property itself otherwise) */
index = -1;
}
-
+
success += clear_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index, 0);
MEM_freeN(path);
}
@@ -2029,7 +2062,7 @@ static int clear_key_button_exec(bContext *C, wmOperator *op)
if (success) {
/* send updates */
UI_context_update_anim_flag(C);
-
+
/* send notifiers that keyframes have been changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
}
@@ -2061,11 +2094,11 @@ void ANIM_OT_keyframe_clear_button(wmOperatorType *ot)
bool autokeyframe_cfra_can_key(Scene *scene, ID *id)
{
float cfra = (float)CFRA; // XXX for now, this will do
-
+
/* only filter if auto-key mode requires this */
if (IS_AUTOKEY_ON(scene) == 0)
return false;
-
+
if (IS_AUTOKEY_MODE(scene, EDITKEYS)) {
/* Replace Mode:
* For whole block, only key if there's a keyframe on that frame already
@@ -2080,7 +2113,7 @@ bool autokeyframe_cfra_can_key(Scene *scene, ID *id)
* let's set the "normal" flag too, so that it will all be sane everywhere...
*/
scene->toolsettings->autokey_mode = AUTOKEY_MODE_NORMAL;
-
+
/* Can insert anytime we like... */
return true;
}
@@ -2097,12 +2130,12 @@ bool fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter)
/* quick sanity check */
if (ELEM(NULL, fcu, fcu->bezt))
return false;
-
+
/* we either include all regardless of muting, or only non-muted */
if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED) == 0) {
bool replace;
int i = binarysearch_bezt_index(fcu->bezt, frame, fcu->totvert, &replace);
-
+
/* binarysearch_bezt_index will set replace to be 0 or 1
* - obviously, 1 represents a match
*/
@@ -2112,26 +2145,26 @@ bool fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter)
return true;
}
}
-
+
return false;
}
-/* Checks whether an Action has a keyframe for a given frame
+/* Checks whether an Action has a keyframe for a given frame
* Since we're only concerned whether a keyframe exists, we can simply loop until a match is found...
*/
static bool action_frame_has_keyframe(bAction *act, float frame, short filter)
{
FCurve *fcu;
-
+
/* can only find if there is data */
if (act == NULL)
return false;
-
+
/* if only check non-muted, check if muted */
if ((filter & ANIMFILTER_KEYS_MUTED) || (act->flag & ACT_MUTED))
return false;
-
- /* loop over F-Curves, using binary-search to try to find matches
+
+ /* loop over F-Curves, using binary-search to try to find matches
* - this assumes that keyframes are only beztriples
*/
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
@@ -2141,7 +2174,7 @@ static bool action_frame_has_keyframe(bAction *act, float frame, short filter)
return true;
}
}
-
+
/* nothing found */
return false;
}
@@ -2152,27 +2185,27 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
/* error checking */
if (ob == NULL)
return false;
-
+
/* check own animation data - specifically, the action it contains */
if ((ob->adt) && (ob->adt->action)) {
- /* T41525 - When the active action is a NLA strip being edited,
+ /* T41525 - When the active action is a NLA strip being edited,
* we need to correct the frame number to "look inside" the
* remapped action
*/
float ob_frame = BKE_nla_tweakedit_remap(ob->adt, frame, NLATIME_CONVERT_UNMAP);
-
+
if (action_frame_has_keyframe(ob->adt->action, ob_frame, filter))
return true;
}
-
+
/* try shapekey keyframes (if available, and allowed by filter) */
if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOSKEY)) {
Key *key = BKE_key_from_object(ob);
-
- /* shapekeys can have keyframes ('Relative Shape Keys')
- * or depend on time (old 'Absolute Shape Keys')
+
+ /* shapekeys can have keyframes ('Relative Shape Keys')
+ * or depend on time (old 'Absolute Shape Keys')
*/
-
+
/* 1. test for relative (with keyframes) */
if (id_frame_has_keyframe((ID *)key, frame, filter))
return true;
@@ -2186,24 +2219,24 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
/* if only active, then we can skip a lot of looping */
if (filter & ANIMFILTER_KEYS_ACTIVE) {
Material *ma = give_current_material(ob, (ob->actcol + 1));
-
+
/* we only retrieve the active material... */
if (id_frame_has_keyframe((ID *)ma, frame, filter))
return true;
}
else {
int a;
-
+
/* loop over materials */
for (a = 0; a < ob->totcol; a++) {
Material *ma = give_current_material(ob, a + 1);
-
+
if (id_frame_has_keyframe((ID *)ma, frame, filter))
return true;
}
}
}
-
+
/* nothing found */
return false;
}
@@ -2216,7 +2249,7 @@ bool id_frame_has_keyframe(ID *id, float frame, short filter)
/* sanity checks */
if (id == NULL)
return false;
-
+
/* perform special checks for 'macro' types */
switch (GS(id->name)) {
case ID_OB: /* object */
@@ -2229,15 +2262,15 @@ bool id_frame_has_keyframe(ID *id, float frame, short filter)
default: /* 'normal type' */
{
AnimData *adt = BKE_animdata_from_id(id);
-
+
/* only check keyframes in active action */
if (adt)
return action_frame_has_keyframe(adt->action, frame, filter);
break;
}
}
-
-
+
+
/* no keyframe found */
return false;
}
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index c2b28f85b82..5bf23a53819 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -29,7 +29,7 @@
* \ingroup edanimation
*/
-
+
#include <stdio.h>
#include <stddef.h>
#include <string.h>
@@ -84,10 +84,10 @@ static int keyingset_poll_default_add(bContext *C)
static int keyingset_poll_active_edit(bContext *C)
{
Scene *scene = CTX_data_scene(C);
-
+
if (scene == NULL)
return 0;
-
+
/* there must be an active KeyingSet (and KeyingSets) */
return ((scene->active_keyingset > 0) && (scene->keyingsets.first));
}
@@ -97,42 +97,42 @@ static int keyingset_poll_activePath_edit(bContext *C)
{
Scene *scene = CTX_data_scene(C);
KeyingSet *ks;
-
+
if (scene == NULL)
return 0;
if (scene->active_keyingset <= 0)
return 0;
else
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
-
+
/* there must be an active KeyingSet and an active path */
return ((ks) && (ks->paths.first) && (ks->active_path > 0));
}
-
+
/* Add a Default (Empty) Keying Set ------------------------- */
static int add_default_keyingset_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
short flag = 0, keyingflag = 0;
-
- /* validate flags
+
+ /* validate flags
* - absolute KeyingSets should be created by default
*/
flag |= KEYINGSET_ABSOLUTE;
-
+
/* 2nd arg is 0 to indicate that we don't want to include autokeying mode related settings */
keyingflag = ANIM_get_keyframing_flags(scene, 0);
-
+
/* call the API func, and set the active keyingset index */
BKE_keyingset_add(&scene->keyingsets, NULL, NULL, flag, keyingflag);
-
+
scene->active_keyingset = BLI_listbase_count(&scene->keyingsets);
-
+
/* send notifiers */
WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -142,7 +142,7 @@ void ANIM_OT_keying_set_add(wmOperatorType *ot)
ot->name = "Add Empty Keying Set";
ot->idname = "ANIM_OT_keying_set_add";
ot->description = "Add a new (empty) Keying Set to the active Scene";
-
+
/* callbacks */
ot->exec = add_default_keyingset_exec;
ot->poll = keyingset_poll_default_add;
@@ -154,7 +154,7 @@ static int remove_active_keyingset_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
KeyingSet *ks;
-
+
/* verify the Keying Set to use:
* - use the active one
* - return error if it doesn't exist
@@ -169,17 +169,17 @@ static int remove_active_keyingset_exec(bContext *C, wmOperator *op)
}
else
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
-
+
/* free KeyingSet's data, then remove it from the scene */
BKE_keyingset_free(ks);
BLI_freelinkN(&scene->keyingsets, ks);
-
+
/* the active one should now be the previously second-to-last one */
scene->active_keyingset--;
-
+
/* send notifiers */
WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -189,7 +189,7 @@ void ANIM_OT_keying_set_remove(wmOperatorType *ot)
ot->name = "Remove Active Keying Set";
ot->idname = "ANIM_OT_keying_set_remove";
ot->description = "Remove the active Keying Set";
-
+
/* callbacks */
ot->exec = remove_active_keyingset_exec;
ot->poll = keyingset_poll_active_edit;
@@ -202,7 +202,7 @@ static int add_empty_ks_path_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
KeyingSet *ks;
KS_Path *ksp;
-
+
/* verify the Keying Set to use:
* - use the active one
* - return error if it doesn't exist
@@ -213,16 +213,16 @@ static int add_empty_ks_path_exec(bContext *C, wmOperator *op)
}
else
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
-
+
/* don't use the API method for this, since that checks on values... */
ksp = MEM_callocN(sizeof(KS_Path), "KeyingSetPath Empty");
BLI_addtail(&ks->paths, ksp);
ks->active_path = BLI_listbase_count(&ks->paths);
-
+
ksp->groupmode = KSP_GROUP_KSNAME; // XXX?
ksp->idtype = ID_OB;
ksp->flag = KSP_FLAG_WHOLE_ARRAY;
-
+
return OPERATOR_FINISHED;
}
@@ -232,7 +232,7 @@ void ANIM_OT_keying_set_path_add(wmOperatorType *ot)
ot->name = "Add Empty Keying Set Path";
ot->idname = "ANIM_OT_keying_set_path_add";
ot->description = "Add empty path to active Keying Set";
-
+
/* callbacks */
ot->exec = add_empty_ks_path_exec;
ot->poll = keyingset_poll_active_edit;
@@ -244,15 +244,15 @@ static int remove_active_ks_path_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
KeyingSet *ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
-
+
/* if there is a KeyingSet, find the nominated path to remove */
if (ks) {
KS_Path *ksp = BLI_findlink(&ks->paths, ks->active_path - 1);
-
+
if (ksp) {
/* remove the active path from the KeyingSet */
BKE_keyingset_free_path(ks, ksp);
-
+
/* the active path should now be the previously second-to-last active one */
ks->active_path--;
}
@@ -265,7 +265,7 @@ static int remove_active_ks_path_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active keying set to remove a path from");
return OPERATOR_CANCELLED;
}
-
+
return OPERATOR_FINISHED;
}
@@ -275,7 +275,7 @@ void ANIM_OT_keying_set_path_remove(wmOperatorType *ot)
ot->name = "Remove Active Keying Set Path";
ot->idname = "ANIM_OT_keying_set_path_remove";
ot->description = "Remove active Path from active Keying Set";
-
+
/* callbacks */
ot->exec = remove_active_ks_path_exec;
ot->poll = keyingset_poll_activePath_edit;
@@ -296,33 +296,33 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op)
short success = 0;
int index = 0, pflag = 0;
const bool all = RNA_boolean_get(op->ptr, "all");
-
+
/* try to add to keyingset using property retrieved from UI */
if (!UI_context_active_but_prop_get(C, &ptr, &prop, &index)) {
/* pass event on if no active button found */
return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
}
-
+
/* verify the Keying Set to use:
* - use the active one for now (more control over this can be added later)
- * - add a new one if it doesn't exist
+ * - add a new one if it doesn't exist
*/
if (scene->active_keyingset == 0) {
short flag = 0, keyingflag = 0;
-
- /* validate flags
+
+ /* validate flags
* - absolute KeyingSets should be created by default
*/
flag |= KEYINGSET_ABSOLUTE;
-
+
keyingflag |= ANIM_get_keyframing_flags(scene, 0);
-
- if (IS_AUTOKEY_FLAG(scene, XYZ2RGB))
+
+ if (IS_AUTOKEY_FLAG(scene, XYZ2RGB))
keyingflag |= INSERTKEY_XYZ2RGB;
-
+
/* call the API func, and set the active keyingset index */
ks = BKE_keyingset_add(&scene->keyingsets, "ButtonKeyingSet", "Button Keying Set", flag, keyingflag);
-
+
scene->active_keyingset = BLI_listbase_count(&scene->keyingsets);
}
else if (scene->active_keyingset < 0) {
@@ -332,41 +332,41 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op)
else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
}
-
+
/* check if property is able to be added */
if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
path = RNA_path_from_ID_to_property(&ptr, prop);
-
+
if (path) {
/* set flags */
if (all) {
pflag |= KSP_FLAG_WHOLE_ARRAY;
-
- /* we need to set the index for this to 0, even though it may break in some cases, this is
+
+ /* we need to set the index for this to 0, even though it may break in some cases, this is
* necessary if we want the entire array for most cases to get included without the user
* having to worry about where they clicked
*/
index = 0;
}
-
+
/* add path to this setting */
BKE_keyingset_add_path(ks, ptr.id.data, NULL, path, index, pflag, KSP_GROUP_KSNAME);
ks->active_path = BLI_listbase_count(&ks->paths);
success = 1;
-
+
/* free the temp path created */
MEM_freeN(path);
}
}
-
+
if (success) {
/* send updates */
WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL);
-
+
/* show notification/report header, so that users notice that something changed */
BKE_reportf(op->reports, RPT_INFO, "Property added to Keying Set: '%s'", ks->name);
}
-
+
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -376,11 +376,11 @@ void ANIM_OT_keyingset_button_add(wmOperatorType *ot)
ot->name = "Add to Keying Set";
ot->idname = "ANIM_OT_keyingset_button_add";
ot->description = "Add current UI-active property to current keying set";
-
+
/* callbacks */
- ot->exec = add_keyingset_button_exec;
+ ot->exec = add_keyingset_button_exec;
//op->poll = ???
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -399,13 +399,13 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op)
char *path = NULL;
short success = 0;
int index = 0;
-
+
/* try to add to keyingset using property retrieved from UI */
if (UI_context_active_but_prop_get(C, &ptr, &prop, &index)) {
/* pass event on if no active button found */
return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
}
-
+
/* verify the Keying Set to use:
* - use the active one for now (more control over this can be added later)
* - return error if it doesn't exist
@@ -421,35 +421,35 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op)
else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
}
-
+
if (ptr.id.data && ptr.data && prop) {
path = RNA_path_from_ID_to_property(&ptr, prop);
-
+
if (path) {
KS_Path *ksp;
-
+
/* try to find a path matching this description */
ksp = BKE_keyingset_find_path(ks, ptr.id.data, ks->name, path, index, KSP_GROUP_KSNAME);
-
+
if (ksp) {
BKE_keyingset_free_path(ks, ksp);
success = 1;
}
-
+
/* free temp path used */
MEM_freeN(path);
}
}
-
-
+
+
if (success) {
/* send updates */
WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL);
-
+
/* show warning */
BKE_report(op->reports, RPT_INFO, "Property removed from Keying Set");
}
-
+
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -459,11 +459,11 @@ void ANIM_OT_keyingset_button_remove(wmOperatorType *ot)
ot->name = "Remove from Keying Set";
ot->idname = "ANIM_OT_keyingset_button_remove";
ot->description = "Remove current UI-active property from current keying set";
-
+
/* callbacks */
- ot->exec = remove_keyingset_button_exec;
+ ot->exec = remove_keyingset_button_exec;
//op->poll = ???
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -477,13 +477,13 @@ static int keyingset_active_menu_invoke(bContext *C, wmOperator *op, const wmEve
{
uiPopupMenu *pup;
uiLayout *layout;
-
+
/* call the menu, which will call this operator again, hence the canceled */
pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE);
layout = UI_popup_menu_layout(pup);
uiItemsEnumO(layout, "ANIM_OT_keying_set_active_set", "type");
UI_popup_menu_end(C, pup);
-
+
return OPERATOR_INTERFACE;
}
@@ -491,33 +491,33 @@ static int keyingset_active_menu_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
int type = RNA_enum_get(op->ptr, "type");
-
+
/* If type == 0, it will deselect any active keying set. */
scene->active_keyingset = type;
-
+
/* send notifiers */
WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ANIM_OT_keying_set_active_set(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Set Active Keying Set";
ot->idname = "ANIM_OT_keying_set_active_set";
ot->description = "Select a new keying set as the active one";
-
+
/* callbacks */
ot->invoke = keyingset_active_menu_invoke;
- ot->exec = keyingset_active_menu_exec;
+ ot->exec = keyingset_active_menu_exec;
ot->poll = ED_operator_areaactive;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* keyingset to use (dynamic enum) */
prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use");
RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf);
@@ -541,7 +541,7 @@ KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[])
/* sanity checks */
if ((name == NULL) || (name[0] == 0))
return NULL;
-
+
/* search by comparing names */
return BLI_findstring(&keyingset_type_infos, name, offsetof(KeyingSetInfo, idname));
}
@@ -550,17 +550,17 @@ KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[])
KeyingSet *ANIM_builtin_keyingset_get_named(KeyingSet *prevKS, const char name[])
{
KeyingSet *ks, *first = NULL;
-
+
/* sanity checks any name to check? */
if (name[0] == 0)
return NULL;
-
+
/* get first KeyingSet to use */
if (prevKS && prevKS->next)
first = prevKS->next;
else
first = builtin_keyingsets.first;
-
+
/* loop over KeyingSets checking names */
for (ks = first; ks; ks = ks->next) {
if (STREQ(name, ks->idname))
@@ -582,18 +582,18 @@ KeyingSet *ANIM_builtin_keyingset_get_named(KeyingSet *prevKS, const char name[]
void ANIM_keyingset_info_register(KeyingSetInfo *ksi)
{
KeyingSet *ks;
-
- /* create a new KeyingSet
+
+ /* create a new KeyingSet
* - inherit name and keyframing settings from the typeinfo
*/
ks = BKE_keyingset_add(&builtin_keyingsets, ksi->idname, ksi->name, 1, ksi->keyingflag);
-
+
/* link this KeyingSet with its typeinfo */
memcpy(&ks->typeinfo, ksi->idname, sizeof(ks->typeinfo));
-
+
/* Copy description... */
BLI_strncpy(ks->description, ksi->description, sizeof(ks->description));
-
+
/* add type-info to the list */
BLI_addtail(&keyingset_type_infos, ksi);
}
@@ -621,7 +621,7 @@ void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi)
MEM_freeN(ks);
}
}
-
+
/* free the type info */
BLI_freelinkN(&keyingset_type_infos, ksi);
}
@@ -631,17 +631,17 @@ void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi)
void ANIM_keyingset_infos_exit(void)
{
KeyingSetInfo *ksi, *next;
-
+
/* free type infos */
for (ksi = keyingset_type_infos.first; ksi; ksi = next) {
next = ksi->next;
-
+
/* free extra RNA data, and remove from list */
if (ksi->ext.free)
ksi->ext.free(ksi->ext.data);
BLI_freelinkN(&keyingset_type_infos, ksi);
}
-
+
/* free builtin sets */
BKE_keyingsets_free(&builtin_keyingsets);
}
@@ -667,7 +667,7 @@ KeyingSet *ANIM_scene_get_active_keyingset(Scene *scene)
/* if no scene, we've got no hope of finding the Keying Set */
if (scene == NULL)
return NULL;
-
+
/* currently, there are several possibilities here:
* - 0: no active keying set
* - > 0: one of the user-defined Keying Sets, but indices start from 0 (hence the -1)
@@ -683,22 +683,22 @@ KeyingSet *ANIM_scene_get_active_keyingset(Scene *scene)
int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks)
{
int index;
-
+
/* if no KeyingSet provided, have none */
if (ks == NULL)
return 0;
-
+
/* check if the KeyingSet exists in scene list */
if (scene) {
- /* get index and if valid, return
+ /* get index and if valid, return
* - (absolute) Scene KeyingSets are from (>= 1)
*/
index = BLI_findindex(&scene->keyingsets, ks);
if (index != -1)
return (index + 1);
}
-
- /* still here, so try builtins list too
+
+ /* still here, so try builtins list too
* - builtins are from (<= -1)
* - none/invalid is (= 0)
*/
@@ -712,15 +712,15 @@ int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks)
/* Get Keying Set to use for Auto-Keyframing some transforms */
KeyingSet *ANIM_get_keyingset_for_autokeying(Scene *scene, const char *tranformKSName)
{
- /* get KeyingSet to use
- * - use the active KeyingSet if defined (and user wants to use it for all autokeying),
+ /* get KeyingSet to use
+ * - use the active KeyingSet if defined (and user wants to use it for all autokeying),
* or otherwise key transforms only
*/
if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (scene->active_keyingset))
return ANIM_scene_get_active_keyingset(scene);
else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL))
return ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_AVAILABLE_ID);
- else
+ else
return ANIM_builtin_keyingset_get_named(NULL, tranformKSName);
}
@@ -738,8 +738,8 @@ const EnumPropertyItem *ANIM_keying_sets_enum_itemf(bContext *C, PointerRNA *UNU
if (C == NULL) {
return DummyRNA_DEFAULT_items;
}
-
- /* active Keying Set
+
+ /* active Keying Set
* - only include entry if it exists
*/
if (scene->active_keyingset) {
@@ -748,14 +748,14 @@ const EnumPropertyItem *ANIM_keying_sets_enum_itemf(bContext *C, PointerRNA *UNU
item_tmp.name = "Active Keying Set";
item_tmp.value = i;
RNA_enum_item_add(&item, &totitem, &item_tmp);
-
+
/* separator */
RNA_enum_item_add_separator(&item, &totitem);
}
-
+
i++;
-
- /* user-defined Keying Sets
+
+ /* user-defined Keying Sets
* - these are listed in the order in which they were defined for the active scene
*/
if (scene->keyingsets.first) {
@@ -768,11 +768,11 @@ const EnumPropertyItem *ANIM_keying_sets_enum_itemf(bContext *C, PointerRNA *UNU
RNA_enum_item_add(&item, &totitem, &item_tmp);
}
}
-
+
/* separator */
RNA_enum_item_add_separator(&item, &totitem);
}
-
+
/* builtin Keying Sets */
i = -1;
for (ks = builtin_keyingsets.first; ks; ks = ks->next, i--) {
@@ -802,7 +802,7 @@ bool ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks)
{
if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) {
KeyingSetInfo *ksi = ANIM_keyingset_info_find_name(ks->typeinfo);
-
+
/* get the associated 'type info' for this KeyingSet */
if (ksi == NULL)
return 0;
@@ -811,13 +811,13 @@ bool ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks)
/* check if it can be used in the current context */
return (ksi->poll(ksi, C));
}
-
+
return true;
}
/* Special 'Overrides' Iterator for Relative KeyingSets ------ */
-/* 'Data Sources' for relative Keying Set 'overrides'
+/* 'Data Sources' for relative Keying Set 'overrides'
* - this is basically a wrapper for PointerRNA's in a linked list
* - do not allow this to be accessed from outside for now
*/
@@ -827,14 +827,14 @@ typedef struct tRKS_DSource {
} tRKS_DSource;
-/* Iterator used for overriding the behavior of iterators defined for
- * relative Keying Sets, with the main usage of this being operators
+/* Iterator used for overriding the behavior of iterators defined for
+ * relative Keying Sets, with the main usage of this being operators
* requiring Auto Keyframing. Internal Use Only!
*/
static void RKS_ITER_overrides_list(KeyingSetInfo *ksi, bContext *C, KeyingSet *ks, ListBase *dsources)
{
tRKS_DSource *ds;
-
+
for (ds = dsources->first; ds; ds = ds->next) {
/* run generate callback on this data */
ksi->generate(ksi, C, ks, &ds->ptr);
@@ -845,8 +845,8 @@ static void RKS_ITER_overrides_list(KeyingSetInfo *ksi, bContext *C, KeyingSet *
void ANIM_relative_keyingset_add_source(ListBase *dsources, ID *id, StructRNA *srna, void *data)
{
tRKS_DSource *ds;
-
- /* sanity checks
+
+ /* sanity checks
* - we must have somewhere to output the data
* - we must have both srna+data (and with id too optionally), or id by itself only
*/
@@ -854,11 +854,11 @@ void ANIM_relative_keyingset_add_source(ListBase *dsources, ID *id, StructRNA *s
return;
if (ELEM(NULL, srna, data) && (id == NULL))
return;
-
+
/* allocate new elem, and add to the list */
ds = MEM_callocN(sizeof(tRKS_DSource), "tRKS_DSource");
BLI_addtail(dsources, ds);
-
+
/* depending on what data we have, create using ID or full pointer call */
if (srna && data)
RNA_pointer_create(id, srna, data, &ds->ptr);
@@ -880,31 +880,31 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks)
/* sanity check */
if (ks == NULL)
return 0;
-
+
/* if relative Keying Sets, poll and build up the paths */
if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) {
KeyingSetInfo *ksi = ANIM_keyingset_info_find_name(ks->typeinfo);
-
- /* clear all existing paths
+
+ /* clear all existing paths
* NOTE: BKE_keyingset_free() frees all of the paths for the KeyingSet, but not the set itself
*/
BKE_keyingset_free(ks);
-
+
/* get the associated 'type info' for this KeyingSet */
if (ksi == NULL)
return MODIFYKEY_MISSING_TYPEINFO;
/* TODO: check for missing callbacks! */
-
+
/* check if it can be used in the current context */
if (ksi->poll(ksi, C)) {
/* if a list of data sources are provided, run a special iterator over them,
* otherwise, just continue per normal
*/
- if (dsources)
+ if (dsources)
RKS_ITER_overrides_list(ksi, C, ks, dsources);
else
ksi->iter(ksi, C, ks);
-
+
/* if we don't have any paths now, then this still qualifies as invalid context */
// FIXME: we need some error conditions (to be retrieved from the iterator why this failed!)
if (BLI_listbase_is_empty(&ks->paths))
@@ -916,16 +916,16 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks)
return MODIFYKEY_INVALID_CONTEXT;
}
}
-
+
/* succeeded; return 0 to tag error free */
return 0;
-}
+}
/* Determine which keying flags apply based on the override flags */
static short keyingset_apply_keying_flags(const short base_flags, const short overrides, const short own_flags)
{
short result = 0;
-
+
/* The logic for whether a keying flag applies is as follows:
* - If the flag in question is set in "overrides", that means that the
* status of that flag in "own_flags" is used
@@ -939,14 +939,14 @@ static short keyingset_apply_keying_flags(const short base_flags, const short ov
else { \
result |= (base_flags & kflag); \
}
-
- /* Apply the flags one by one...
+
+ /* Apply the flags one by one...
* (See rna_def_common_keying_flags() for the supported flags)
*/
APPLY_KEYINGFLAG_OVERRIDE(INSERTKEY_NEEDED)
APPLY_KEYINGFLAG_OVERRIDE(INSERTKEY_MATRIX)
APPLY_KEYINGFLAG_OVERRIDE(INSERTKEY_XYZ2RGB)
-
+
#undef APPLY_KEYINGFLAG_OVERRIDE
return result;
@@ -959,6 +959,7 @@ static short keyingset_apply_keying_flags(const short base_flags, const short ov
int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ReportList *reports = CTX_wm_reports(C);
KS_Path *ksp;
@@ -966,11 +967,11 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe
const char *groupname = NULL;
short kflag = 0, success = 0;
char keytype = scene->toolsettings->keyframe_type;
-
+
/* sanity checks */
if (ks == NULL)
return 0;
-
+
/* get flags to use */
if (mode == MODIFYKEY_MODE_INSERT) {
/* use context settings as base */
@@ -978,20 +979,20 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe
}
else if (mode == MODIFYKEY_MODE_DELETE)
kflag = 0;
-
+
/* if relative Keying Sets, poll and build up the paths */
success = ANIM_validate_keyingset(C, dsources, ks);
-
+
if (success != 0) {
/* return error code if failed */
return success;
}
-
+
/* apply the paths as specified in the KeyingSet now */
for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
int arraylen, i;
short kflag2;
-
+
/* skip path if no ID pointer is specified */
if (ksp->id == NULL) {
BKE_reportf(reports, RPT_WARNING,
@@ -999,10 +1000,10 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe
ks->name, ksp->rna_path, ksp->array_index);
continue;
}
-
+
/* since keying settings can be defined on the paths too, apply the settings for this path first */
kflag2 = keyingset_apply_keying_flags(kflag, ksp->keyingoverride, ksp->keyingflag);
-
+
/* get pointer to name of group to add channels to */
if (ksp->groupmode == KSP_GROUP_NONE)
groupname = NULL;
@@ -1010,59 +1011,59 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe
groupname = ks->name;
else
groupname = ksp->group;
-
+
/* init arraylen and i - arraylen should be greater than i so that
* normal non-array entries get keyframed correctly
*/
i = ksp->array_index;
arraylen = i;
-
+
/* get length of array if whole array option is enabled */
if (ksp->flag & KSP_FLAG_WHOLE_ARRAY) {
PointerRNA id_ptr, ptr;
PropertyRNA *prop;
-
+
RNA_id_pointer_create(ksp->id, &id_ptr);
if (RNA_path_resolve_property(&id_ptr, ksp->rna_path, &ptr, &prop)) {
arraylen = RNA_property_array_length(&ptr, prop);
i = 0; /* start from start of array, instead of the previously specified index - T48020 */
}
}
-
+
/* we should do at least one step */
if (arraylen == i)
arraylen++;
-
- /* for each possible index, perform operation
+
+ /* for each possible index, perform operation
* - assume that arraylen is greater than index
*/
for (; i < arraylen; i++) {
/* action to take depends on mode */
if (mode == MODIFYKEY_MODE_INSERT)
- success += insert_keyframe(depsgraph, reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, keytype, kflag2);
+ success += insert_keyframe(bmain, depsgraph, reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, keytype, kflag2);
else if (mode == MODIFYKEY_MODE_DELETE)
success += delete_keyframe(reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag2);
}
-
+
/* set recalc-flags */
switch (GS(ksp->id->name)) {
case ID_OB: /* Object (or Object-Related) Keyframes */
{
Object *ob = (Object *)ksp->id;
-
+
// XXX: only object transforms?
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
break;
}
default:
DEG_id_tag_update(ksp->id, DEG_TAG_COPY_ON_WRITE);
break;
}
-
+
/* send notifiers for updates (this doesn't require context to work!) */
WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
}
-
+
/* return the number of channels successfully affected */
return success;
}
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c
index 07c9225c443..c1fb1dcf82f 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -66,12 +66,12 @@
EditBone *ED_armature_ebone_add(bArmature *arm, const char *name)
{
EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone");
-
+
BLI_strncpy(bone->name, name, sizeof(bone->name));
ED_armature_ebone_unique_name(arm->edbo, bone->name, NULL);
-
+
BLI_addtail(arm->edbo, bone);
-
+
bone->flag |= BONE_TIPSEL;
bone->weight = 1.0f;
bone->dist = 0.25f;
@@ -81,7 +81,7 @@ EditBone *ED_armature_ebone_add(bArmature *arm, const char *name)
bone->rad_tail = 0.05f;
bone->segments = 1;
bone->layer = arm->layer;
-
+
/* Bendy-Bone parameters */
bone->roll1 = 0.0f;
bone->roll2 = 0.0f;
@@ -103,7 +103,7 @@ EditBone *ED_armature_ebone_add_primitive(Object *obedit_arm, float length, bool
EditBone *bone;
ED_armature_edit_deselect_all(obedit_arm);
-
+
/* Create a bone */
bone = ED_armature_ebone_add(arm, "Bone");
@@ -134,7 +134,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
v3d = CTX_wm_view3d(C);
obedit = CTX_data_edit_object(C);
arm = obedit->data;
-
+
/* find the active or selected bone */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
@@ -142,7 +142,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
-
+
if (ebone == NULL) {
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
@@ -150,14 +150,14 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
- if (ebone == NULL)
+ if (ebone == NULL)
return OPERATOR_CANCELLED;
-
+
to_root = 1;
}
-
+
ED_armature_edit_deselect_all(obedit);
-
+
/* we re-use code for mirror editing... */
flipbone = NULL;
if (arm->flag & ARM_MIRROR_EDIT)
@@ -171,10 +171,10 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
SWAP(EditBone *, flipbone, ebone);
}
}
-
+
newbone = ED_armature_ebone_add(arm, ebone->name);
arm->act_edbone = newbone;
-
+
if (to_root) {
copy_v3_v3(newbone->head, ebone->head);
newbone->rad_head = ebone->rad_tail;
@@ -186,28 +186,28 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
newbone->parent = ebone;
newbone->flag |= BONE_CONNECTED;
}
-
+
const View3DCursor *curs = ED_view3d_cursor3d_get(scene, v3d);
copy_v3_v3(newbone->tail, curs->location);
sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]);
-
+
if (a == 1)
newbone->tail[0] = -newbone->tail[0];
-
+
copy_m3_m4(mat, obedit->obmat);
invert_m3_m3(imat, mat);
mul_m3_v3(imat, newbone->tail);
-
+
newbone->length = len_v3v3(newbone->head, newbone->tail);
newbone->rad_tail = newbone->length * 0.05f;
newbone->dist = newbone->length * 0.25f;
-
+
}
-
+
ED_armature_edit_sync_selection(arm->edbo);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
-
+
return OPERATOR_FINISHED;
}
@@ -226,9 +226,9 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, const wmEv
scene = CTX_data_scene(C);
ar = CTX_wm_region(C);
v3d = CTX_wm_view3d(C);
-
+
View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
-
+
copy_v3_v3(oldcurs, cursor->location);
VECCOPY2D(mval_f, event->mval);
@@ -250,12 +250,12 @@ void ARMATURE_OT_click_extrude(wmOperatorType *ot)
ot->name = "Click-Extrude";
ot->idname = "ARMATURE_OT_click_extrude";
ot->description = "Create a new bone going from the last selected joint to the mouse position";
-
+
/* api callbacks */
ot->invoke = armature_click_extrude_invoke;
ot->exec = armature_click_extrude_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -266,12 +266,12 @@ void ARMATURE_OT_click_extrude(wmOperatorType *ot)
EditBone *add_points_bone(Object *obedit, float head[3], float tail[3])
{
EditBone *ebo;
-
+
ebo = ED_armature_ebone_add(obedit->data, "Bone");
-
+
copy_v3_v3(ebo->head, head);
copy_v3_v3(ebo->tail, tail);
-
+
return ebo;
}
@@ -377,7 +377,7 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj
bPoseChannel *pchan;
bConstraint *curcon;
ListBase *conlist;
-
+
if ((pchan = BKE_pose_channel_verify(dst_ob->pose, dupBone->name))) {
if ((conlist = &pchan->constraints)) {
for (curcon = conlist->first; curcon; curcon = curcon->next) {
@@ -387,17 +387,17 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
-
+
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(curcon, &targets);
-
+
for (ct = targets.first; ct; ct = ct->next) {
if ((ct->tar == src_ob) && (ct->subtarget[0])) {
- ct->tar = dst_ob; /* update target */
+ ct->tar = dst_ob; /* update target */
oldtarget = get_named_editbone(editbones, ct->subtarget);
if (oldtarget) {
/* was the subtarget bone duplicated too? If
- * so, update the constraint to point at the
+ * so, update the constraint to point at the
* duplicate of the old subtarget.
*/
if (oldtarget->temp.ebone) {
@@ -407,7 +407,7 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj
}
}
}
-
+
if (cti->flush_constraint_targets)
cti->flush_constraint_targets(curcon, &targets, 0);
}
@@ -426,20 +426,20 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase
Object *src_ob, Object *dst_ob)
{
EditBone *eBone = MEM_mallocN(sizeof(EditBone), "addup_editbone");
-
+
/* Copy data from old bone to new bone */
memcpy(eBone, curBone, sizeof(EditBone));
-
+
curBone->temp.ebone = eBone;
eBone->temp.ebone = curBone;
-
+
if (name != NULL) {
BLI_strncpy(eBone->name, name, sizeof(eBone->name));
}
ED_armature_ebone_unique_name(editbones, eBone->name, NULL);
BLI_addtail(editbones, eBone);
-
+
/* copy the ID property */
if (curBone->prop)
eBone->prop = IDP_CopyProperty(curBone->prop);
@@ -449,7 +449,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase
*/
if (src_ob->pose) {
bPoseChannel *chanold, *channew;
-
+
chanold = BKE_pose_channel_verify(src_ob->pose, curBone->name);
if (chanold) {
/* WARNING: this creates a new posechannel, but there will not be an attached bone
@@ -462,7 +462,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase
}
}
}
-
+
return eBone;
}
@@ -506,7 +506,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
}
}
-
+
/* Find the selected bones and duplicate them as needed */
for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; ebone_iter = ebone_iter->next) {
if (EBONE_VISIBLE(arm, ebone_iter) &&
@@ -567,7 +567,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
updateDuplicateSubtarget(ebone, arm->edbo, obedit);
}
}
-
+
/* correct the active bone */
if (arm->act_edbone && arm->act_edbone->temp.ebone) {
arm->act_edbone = arm->act_edbone->temp.ebone;
@@ -585,7 +585,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
ED_armature_edit_validate_active(arm);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
-
+
return OPERATOR_FINISHED;
}
@@ -596,11 +596,11 @@ void ARMATURE_OT_duplicate(wmOperatorType *ot)
ot->name = "Duplicate Selected Bone(s)";
ot->idname = "ARMATURE_OT_duplicate";
ot->description = "Make copies of the selected bones within the same armature";
-
+
/* api callbacks */
ot->exec = armature_duplicate_selected_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -846,7 +846,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
}
}
}
-
+
/* Duplicate the necessary bones */
for (ebone = arm->edbo->first; ((ebone) && (ebone != first)); ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
@@ -864,7 +864,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
do_extrude = 2;
}
}
-
+
if (do_extrude) {
/* we re-use code for mirror editing... */
flipbone = NULL;
@@ -879,7 +879,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
if ((flipbone == NULL) && (forked))
flipbone = ebone;
}
-
+
for (a = 0; a < 2; a++) {
if (a == 1) {
if (flipbone == NULL)
@@ -888,31 +888,31 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
SWAP(EditBone *, flipbone, ebone);
}
}
-
+
totbone++;
newbone = MEM_callocN(sizeof(EditBone), "extrudebone");
-
+
if (do_extrude == true) {
copy_v3_v3(newbone->head, ebone->tail);
copy_v3_v3(newbone->tail, newbone->head);
newbone->parent = ebone;
-
+
newbone->flag = ebone->flag & (BONE_TIPSEL | BONE_RELATIVE_PARENTING); // copies it, in case mirrored bone
-
+
if (newbone->parent) newbone->flag |= BONE_CONNECTED;
}
else {
copy_v3_v3(newbone->head, ebone->head);
copy_v3_v3(newbone->tail, ebone->head);
newbone->parent = ebone->parent;
-
+
newbone->flag = BONE_TIPSEL;
-
+
if (newbone->parent && (ebone->flag & BONE_CONNECTED)) {
newbone->flag |= BONE_CONNECTED;
}
}
-
+
newbone->weight = ebone->weight;
newbone->dist = ebone->dist;
newbone->xwidth = ebone->xwidth;
@@ -921,7 +921,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
newbone->rad_tail = ebone->rad_tail;
newbone->segments = 1;
newbone->layer = ebone->layer;
-
+
/* Bendy-Bone parameters */
newbone->roll1 = ebone->roll1;
newbone->roll2 = ebone->roll2;
@@ -936,7 +936,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
BLI_strncpy(newbone->name, ebone->name, sizeof(newbone->name));
-
+
if (flipbone && forked) { // only set if mirror edit
if (strlen(newbone->name) < (MAXBONENAME - 2)) {
if (a == 0) strcat(newbone->name, "_L");
@@ -944,18 +944,18 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
}
}
ED_armature_ebone_unique_name(arm->edbo, newbone->name, NULL);
-
+
/* Add the new bone to the list */
BLI_addtail(arm->edbo, newbone);
if (!first)
first = newbone;
-
+
/* restore ebone if we were flipping */
if (a == 1 && flipbone)
SWAP(EditBone *, flipbone, ebone);
}
}
-
+
/* Deselect the old bone */
ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
}
@@ -986,14 +986,14 @@ void ARMATURE_OT_extrude(wmOperatorType *ot)
ot->name = "Extrude";
ot->idname = "ARMATURE_OT_extrude";
ot->description = "Create new bones from the selected joints";
-
+
/* api callbacks */
ot->exec = armature_extrude_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
RNA_def_boolean(ot->srna, "forked", 0, "Forked", "");
}
@@ -1002,16 +1002,16 @@ void ARMATURE_OT_extrude(wmOperatorType *ot)
/*op makes a new bone and returns it with its tip selected */
-static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
+static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
{
RegionView3D *rv3d = CTX_wm_region_view3d(C);
Object *obedit = CTX_data_edit_object(C);
EditBone *bone;
float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3];
char name[MAXBONENAME];
-
+
RNA_string_get(op->ptr, "name", name);
-
+
copy_v3_v3(curs, ED_view3d_cursor3d_get(CTX_data_scene(C), CTX_wm_view3d(C))->location);
/* Get inverse point for head and orientation for tail */
@@ -1021,18 +1021,18 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
copy_m3_m4(obmat, rv3d->viewmat);
else unit_m3(obmat);
-
+
copy_m3_m4(viewmat, obedit->obmat);
mul_m3_m3m3(totmat, obmat, viewmat);
invert_m3_m3(imat, totmat);
-
+
ED_armature_edit_deselect_all(obedit);
-
+
/* Create a bone */
bone = ED_armature_ebone_add(obedit->data, name);
copy_v3_v3(bone->head, curs);
-
+
if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
else
@@ -1050,23 +1050,23 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot)
ot->name = "Add Bone";
ot->idname = "ARMATURE_OT_bone_primitive_add";
ot->description = "Add a new bone located at the 3D-Cursor";
-
+
/* api callbacks */
ot->exec = armature_bone_primitive_add_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_string(ot->srna, "name", "Bone", MAXBONENAME, "Name", "Name of the newly created bone");
-
+
}
/* ********************** Subdivide *******************************/
/* Subdivide Operators:
* This group of operators all use the same 'exec' callback, but they are called
- * through several different operators - a combined menu (which just calls the exec in the
+ * through several different operators - a combined menu (which just calls the exec in the
* appropriate ways), and two separate ones.
*/
@@ -1075,10 +1075,10 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
EditBone *newbone, *tbone;
int cuts, i;
-
+
/* there may not be a number_cuts property defined (for 'simple' subdivide) */
cuts = RNA_int_get(op->ptr, "number_cuts");
-
+
/* loop over all editable bones */
// XXX the old code did this in reverse order though!
CTX_DATA_BEGIN_WITH_ID(C, EditBone *, ebone, selected_editable_bones, bArmature *, arm)
@@ -1087,37 +1087,37 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
/* compute cut ratio first */
float cutratio = 1.0f / (float)i;
float cutratioI = 1.0f - cutratio;
-
+
float val1[3];
float val2[3];
float val3[3];
-
+
newbone = MEM_mallocN(sizeof(EditBone), "ebone subdiv");
*newbone = *ebone;
BLI_addtail(arm->edbo, newbone);
-
+
/* calculate location of newbone->head */
copy_v3_v3(val1, ebone->head);
copy_v3_v3(val2, ebone->tail);
copy_v3_v3(val3, newbone->head);
-
+
val3[0] = val1[0] * cutratio + val2[0] * cutratioI;
val3[1] = val1[1] * cutratio + val2[1] * cutratioI;
val3[2] = val1[2] * cutratio + val2[2] * cutratioI;
-
+
copy_v3_v3(newbone->head, val3);
copy_v3_v3(newbone->tail, ebone->tail);
copy_v3_v3(ebone->tail, newbone->head);
-
+
newbone->rad_head = ((ebone->rad_head * cutratio) + (ebone->rad_tail * cutratioI));
ebone->rad_tail = newbone->rad_head;
-
+
newbone->flag |= BONE_CONNECTED;
newbone->prop = NULL;
ED_armature_ebone_unique_name(arm->edbo, newbone->name, NULL);
-
+
/* correct parent bones */
for (tbone = arm->edbo->first; tbone; tbone = tbone->next) {
if (tbone->parent == ebone)
@@ -1127,10 +1127,10 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_END;
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
-
+
return OPERATOR_FINISHED;
}
@@ -1142,14 +1142,14 @@ void ARMATURE_OT_subdivide(wmOperatorType *ot)
ot->name = "Subdivide Multi";
ot->idname = "ARMATURE_OT_subdivide";
ot->description = "Break selected bones into chains of smaller bones";
-
+
/* api callbacks */
ot->exec = armature_subdivide_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* Properties */
prop = RNA_def_int(ot->srna, "number_cuts", 1, 1, 1000, "Number of Cuts", "", 1, 10);
/* avoid re-using last var because it can cause _very_ high poly meshes and annoy users (or worse crash) */
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index fe0722470cd..ccc1eefd9dc 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -29,7 +29,7 @@
* \ingroup edarmature
*/
-#include <assert.h>
+#include <assert.h>
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
@@ -50,6 +50,7 @@
#include "BKE_context.h"
#include "BKE_layer.h"
#include "BKE_global.h"
+#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_object.h"
@@ -68,7 +69,7 @@
/* ************************** Object Tools Exports ******************************* */
/* NOTE: these functions are exported to the Object module to be called from the tools there */
-void ED_armature_transform_apply(Object *ob, float mat[4][4], const bool do_props)
+void ED_armature_transform_apply(Main *bmain, Object *ob, float mat[4][4], const bool do_props)
{
bArmature *arm = ob->data;
@@ -79,7 +80,7 @@ void ED_armature_transform_apply(Object *ob, float mat[4][4], const bool do_prop
ED_armature_transform_bones(arm, mat, do_props);
/* Turn the list into an armature */
- ED_armature_from_edit(arm);
+ ED_armature_from_edit(bmain, arm);
ED_armature_edit_free(arm);
}
@@ -94,20 +95,20 @@ void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const b
/* Do the rotations */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
float tmat[3][3];
-
+
/* find the current bone's roll matrix */
ED_armature_ebone_to_mat3(ebone, tmat);
-
+
/* transform the roll matrix */
mul_m3_m3m3(tmat, mat3, tmat);
-
+
/* transform the bone */
mul_m4_v3(mat, ebone->head);
mul_m4_v3(mat, ebone->tail);
/* apply the transformed roll back */
mat3_to_vec_roll(tmat, NULL, &ebone->roll);
-
+
if (do_props) {
ebone->rad_head *= scale;
ebone->rad_tail *= scale;
@@ -120,7 +121,7 @@ void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const b
}
}
-void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do_props)
+void ED_armature_transform(Main *bmain, bArmature *arm, float mat[4][4], const bool do_props)
{
if (arm->edbo) {
ED_armature_transform_bones(arm, mat, do_props);
@@ -133,14 +134,14 @@ void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do
ED_armature_transform_bones(arm, mat, do_props);
/* Go back to object mode*/
- ED_armature_from_edit(arm);
+ ED_armature_from_edit(bmain, arm);
ED_armature_edit_free(arm);
}
}
/* exported for use in editors/object/ */
/* 0 == do center, 1 == center new, 2 == center cursor */
-void ED_armature_origin_set(Object *ob, float cursor[3], int centermode, int around)
+void ED_armature_origin_set(Main *bmain, Object *ob, float cursor[3], int centermode, int around)
{
const bool is_editmode = BKE_object_is_in_editmode(ob);
EditBone *ebone;
@@ -181,16 +182,16 @@ void ED_armature_origin_set(Object *ob, float cursor[3], int centermode, int aro
mid_v3_v3v3(cent, min, max);
}
}
-
+
/* Do the adjustments */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
sub_v3_v3(ebone->head, cent);
sub_v3_v3(ebone->tail, cent);
}
-
+
/* Turn the list into an armature */
if (is_editmode == false) {
- ED_armature_from_edit(arm);
+ ED_armature_from_edit(bmain, arm);
ED_armature_edit_free(arm);
}
@@ -292,7 +293,7 @@ static const EnumPropertyItem prop_calc_roll_types[] = {
};
-static int armature_calc_roll_exec(bContext *C, wmOperator *op)
+static int armature_calc_roll_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_edit_object(C);
eCalcRollTypes type = RNA_enum_get(op->ptr, "type");
@@ -319,12 +320,12 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
float cursor_local[3];
const View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
-
+
invert_m4_m4(ob->imat, ob->obmat);
copy_v3_v3(cursor_local, cursor->location);
mul_m4_v3(ob->imat, cursor_local);
-
+
/* cursor */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
@@ -393,7 +394,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No region view3d available");
return OPERATOR_CANCELLED;
}
-
+
copy_v3_v3(vec, rv3d->viewinv[2]);
mul_m3_v3(imat, vec);
}
@@ -404,7 +405,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active bone set");
return OPERATOR_CANCELLED;
}
-
+
ED_armature_ebone_to_mat3(ebone, mat);
copy_v3_v3(vec, mat[2]);
}
@@ -415,9 +416,9 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
mul_m3_v3(imat, vec);
normalize_v3(vec);
}
-
+
if (axis_flip) negate_v3(vec);
-
+
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
/* roll func is a callback which assumes that all is well */
@@ -425,7 +426,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
}
}
}
-
+
if (arm->flag & ARM_MIRROR_EDIT) {
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) {
@@ -436,10 +437,10 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
}
}
}
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -449,12 +450,12 @@ void ARMATURE_OT_calculate_roll(wmOperatorType *ot)
ot->name = "Recalculate Roll";
ot->idname = "ARMATURE_OT_calculate_roll";
ot->description = "Automatically fix alignment of select bones' axes";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = armature_calc_roll_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -521,10 +522,10 @@ void ARMATURE_OT_roll_clear(wmOperatorType *ot)
/* temporary data-structure for merge/fill bones */
typedef struct EditBonePoint {
struct EditBonePoint *next, *prev;
-
+
EditBone *head_owner; /* EditBone which uses this point as a 'head' point */
EditBone *tail_owner; /* EditBone which uses this point as a 'tail' point */
-
+
float vec[3]; /* the actual location of the point in local/EditMode space */
} EditBonePoint;
@@ -533,11 +534,11 @@ static void chains_find_tips(ListBase *edbo, ListBase *list)
{
EditBone *curBone, *ebo;
LinkData *ld;
-
+
/* note: this is potentially very slow ... there's got to be a better way */
for (curBone = edbo->first; curBone; curBone = curBone->next) {
short stop = 0;
-
+
/* is this bone contained within any existing chain? (skip if so) */
for (ld = list->first; ld; ld = ld->next) {
for (ebo = ld->data; ebo; ebo = ebo->parent) {
@@ -546,12 +547,12 @@ static void chains_find_tips(ListBase *edbo, ListBase *list)
break;
}
}
-
+
if (stop) break;
}
/* skip current bone if it is part of an existing chain */
if (stop) continue;
-
+
/* is any existing chain part of the chain formed by this bone? */
stop = 0;
for (ebo = curBone->parent; ebo; ebo = ebo->parent) {
@@ -562,12 +563,12 @@ static void chains_find_tips(ListBase *edbo, ListBase *list)
break;
}
}
-
+
if (stop) break;
}
/* current bone has already been added to a chain? */
if (stop) continue;
-
+
/* add current bone to a new chain */
ld = MEM_callocN(sizeof(LinkData), "BoneChain");
ld->data = curBone;
@@ -582,14 +583,14 @@ static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points)
EditBonePoint *ebp;
float vec[3];
short found = 0;
-
+
if (eb_tail) {
copy_v3_v3(vec, ebo->tail);
}
else {
copy_v3_v3(vec, ebo->head);
}
-
+
for (ebp = points->first; ebp; ebp = ebp->next) {
if (equals_v3v3(ebp->vec, vec)) {
if (eb_tail) {
@@ -610,11 +611,11 @@ static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points)
}
}
}
-
+
/* allocate a new point if no existing point was related */
if (found == 0) {
ebp = MEM_callocN(sizeof(EditBonePoint), "EditBonePoint");
-
+
if (eb_tail) {
copy_v3_v3(ebp->vec, ebo->tail);
ebp->tail_owner = ebo;
@@ -623,7 +624,7 @@ static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points)
copy_v3_v3(ebp->vec, ebo->head);
ebp->head_owner = ebo;
}
-
+
BLI_addtail(points, ebp);
}
}
@@ -666,7 +667,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_END;
-
+
/* the number of joints determines how we fill:
* 1) between joint and cursor (joint=head, cursor=tail)
* 2) between the two joints (order is dependent on active-bone/hierarchy)
@@ -699,14 +700,14 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
if (count == 1) {
EditBonePoint *ebp;
float curs[3];
-
+
/* Get Points - selected joint */
ebp = points.first;
-
+
/* Get points - cursor (tail) */
invert_m4_m4(obedit->imat, obedit->obmat);
mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d)->location);
-
+
/* Create a bone */
newbone = add_points_bone(obedit, ebp->vec, curs);
}
@@ -714,11 +715,11 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
EditBonePoint *ebp_a, *ebp_b;
float head[3], tail[3];
short headtail = 0;
-
+
/* check that the points don't belong to the same bone */
ebp_a = (EditBonePoint *)points.first;
ebp_b = ebp_a->next;
-
+
if (((ebp_a->head_owner == ebp_b->tail_owner) && (ebp_a->head_owner != NULL)) ||
((ebp_a->tail_owner == ebp_b->head_owner) && (ebp_a->tail_owner != NULL)))
{
@@ -726,7 +727,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
BLI_freelistN(&points);
return OPERATOR_CANCELLED;
}
-
+
/* find which one should be the 'head' */
if ((ebp_a->head_owner && ebp_b->head_owner) || (ebp_a->tail_owner && ebp_b->tail_owner)) {
/* use active, nice predictable */
@@ -759,7 +760,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
else if (ebp_b->head_owner) {
headtail = 2;
}
-
+
/* assign head/tail combinations */
if (headtail == 2) {
copy_v3_v3(head, ebp_a->vec);
@@ -769,11 +770,11 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
copy_v3_v3(head, ebp_b->vec);
copy_v3_v3(tail, ebp_a->vec);
}
-
+
/* add new bone and parent it to the appropriate end */
if (headtail) {
newbone = add_points_bone(obedit, head, tail);
-
+
/* do parenting (will need to set connected flag too) */
if (headtail == 2) {
/* ebp tail or head - tail gets priority */
@@ -808,13 +809,13 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
arm->act_edbone = newbone;
newbone->flag |= BONE_TIPSEL;
}
-
+
/* updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit);
-
+
/* free points */
BLI_freelistN(&points);
-
+
return OPERATOR_FINISHED;
}
@@ -824,18 +825,18 @@ void ARMATURE_OT_fill(wmOperatorType *ot)
ot->name = "Fill Between Joints";
ot->idname = "ARMATURE_OT_fill";
ot->description = "Add bone between selected joint(s) and/or 3D-Cursor";
-
+
/* callbacks */
ot->exec = armature_fill_bones_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* --------------------- */
-/* this function merges between two bones, removes them and those in-between,
+/* this function merges between two bones, removes them and those in-between,
* and adjusts the parent relationships for those in-between
*/
static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone *endchild, ListBase *chains)
@@ -844,7 +845,7 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
EditBone *ebo, *ebone, *newbone;
LinkData *chain;
float head[3], tail[3];
-
+
/* check if same bone */
if (start == end) {
if (G.debug & G_DEBUG) {
@@ -852,7 +853,7 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
printf("\tstart = %s, end = %s\n", start->name, end->name);
}
}
-
+
/* step 1: add a new bone
* - head = head/tail of start (default head)
* - tail = head/tail of end (default tail)
@@ -876,17 +877,17 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
/* TODO, copy more things to the new bone */
newbone->flag = start->flag & (BONE_HINGE | BONE_NO_DEFORM | BONE_NO_SCALE |
BONE_NO_CYCLICOFFSET | BONE_NO_LOCAL_LOCATION | BONE_DONE);
-
- /* step 2a: reparent any side chains which may be parented to any bone in the chain of bones to merge
+
+ /* step 2a: reparent any side chains which may be parented to any bone in the chain of bones to merge
* - potentially several tips for side chains leading to some tree exist...
*/
for (chain = chains->first; chain; chain = chain->next) {
- /* traverse down chain until we hit the bottom or if we run into the tip of the chain of bones we're
- * merging (need to stop in this case to avoid corrupting this chain too!)
+ /* traverse down chain until we hit the bottom or if we run into the tip of the chain of bones we're
+ * merging (need to stop in this case to avoid corrupting this chain too!)
*/
for (ebone = chain->data; (ebone) && (ebone != end); ebone = ebone->parent) {
short found = 0;
-
+
/* check if this bone is parented to one in the merging chain
* ! WATCHIT: must only go check until end of checking chain
*/
@@ -898,23 +899,23 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
break;
}
}
-
+
/* carry on to the next tip now */
- if (found)
+ if (found)
break;
}
}
-
+
/* step 2b: parent child of end to newbone (child from this chain) */
if (endchild)
endchild->parent = newbone;
-
+
/* step 3: delete all bones between and including start and end */
for (ebo = end; ebo; ebo = ebone) {
ebone = (ebo == start) ? (NULL) : (ebo->parent);
bone_free(arm, ebo);
}
-
+
newbone->flag |= (BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED);
ED_armature_edit_sync_selection(arm->edbo);
}
@@ -925,33 +926,33 @@ static int armature_merge_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
bArmature *arm = (obedit) ? obedit->data : NULL;
short type = RNA_enum_get(op->ptr, "type");
-
+
/* sanity checks */
if (ELEM(NULL, obedit, arm))
return OPERATOR_CANCELLED;
-
+
/* for now, there's only really one type of merging that's performed... */
if (type == 1) {
/* go down chains, merging bones */
ListBase chains = {NULL, NULL};
LinkData *chain, *nchain;
EditBone *ebo;
-
+
armature_tag_select_mirrored(arm);
-
+
/* get chains (ends on chains) */
chains_find_tips(arm->edbo, &chains);
if (BLI_listbase_is_empty(&chains)) return OPERATOR_CANCELLED;
-
+
/* each 'chain' is the last bone in the chain (with no children) */
for (chain = chains.first; chain; chain = nchain) {
EditBone *bstart = NULL, *bend = NULL;
EditBone *bchild = NULL, *child = NULL;
-
+
/* temporarily remove chain from list of chains */
nchain = chain->next;
BLI_remlink(&chains, chain);
-
+
/* only consider bones that are visible and selected */
for (ebo = chain->data; ebo; child = ebo, ebo = ebo->parent) {
/* check if visible + selected */
@@ -964,37 +965,37 @@ static int armature_merge_exec(bContext *C, wmOperator *op)
bend = ebo;
bchild = child;
}
- else
+ else
bstart = ebo;
}
else {
/* chain is broken... merge any continous segments then clear */
if (bstart && bend)
bones_merge(obedit, bstart, bend, bchild, &chains);
-
+
bstart = NULL;
bend = NULL;
bchild = NULL;
}
}
-
+
/* merge from bstart to bend if something not merged */
if (bstart && bend)
bones_merge(obedit, bstart, bend, bchild, &chains);
-
+
/* put back link */
BLI_insertlinkbefore(&chains, nchain, chain);
}
-
+
armature_tag_unselect(arm);
-
+
BLI_freelistN(&chains);
}
-
+
/* updates */
ED_armature_edit_sync_selection(arm->edbo);
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit);
-
+
return OPERATOR_FINISHED;
}
@@ -1009,15 +1010,15 @@ void ARMATURE_OT_merge(wmOperatorType *ot)
ot->name = "Merge Bones";
ot->idname = "ARMATURE_OT_merge";
ot->description = "Merge continuous chains of selected bones";
-
+
/* callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = armature_merge_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", merge_types, 0, "Type", "");
}
@@ -1029,41 +1030,41 @@ void ARMATURE_OT_merge(wmOperatorType *ot)
* easy to retrieve any hierarchical/chain relationships which are necessary for
* this to be done easily.
*/
-
+
/* helper to clear BONE_TRANSFORM flags */
static void armature_clear_swap_done_flags(bArmature *arm)
{
EditBone *ebone;
-
+
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
ebone->flag &= ~BONE_TRANSFORM;
}
}
-static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
+static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = CTX_data_edit_object(C);
bArmature *arm = (bArmature *)ob->data;
ListBase chains = {NULL, NULL};
LinkData *chain;
-
+
/* get chains of bones (ends on chains) */
chains_find_tips(arm->edbo, &chains);
if (BLI_listbase_is_empty(&chains)) return OPERATOR_CANCELLED;
-
+
/* ensure that mirror bones will also be operated on */
armature_tag_select_mirrored(arm);
-
- /* clear BONE_TRANSFORM flags
+
+ /* clear BONE_TRANSFORM flags
* - used to prevent duplicate/canceling operations from occurring [#34123]
* - BONE_DONE cannot be used here as that's already used for mirroring
*/
armature_clear_swap_done_flags(arm);
-
+
/* loop over chains, only considering selected and visible bones */
for (chain = chains.first; chain; chain = chain->next) {
EditBone *ebo, *child = NULL, *parent = NULL;
-
+
/* loop over bones in chain */
for (ebo = chain->data; ebo; ebo = parent) {
/* parent is this bone's original parent
@@ -1071,14 +1072,14 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
* but the value of ebo->parent may change here...
*/
parent = ebo->parent;
-
+
/* skip bone if already handled... [#34123] */
if ((ebo->flag & BONE_TRANSFORM) == 0) {
/* only if selected and editable */
if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) {
/* swap head and tail coordinates */
swap_v3_v3(ebo->head, ebo->tail);
-
+
/* do parent swapping:
* - use 'child' as new parent
* - connected flag is only set if points are coincidental
@@ -1088,44 +1089,44 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
ebo->flag |= BONE_CONNECTED;
else
ebo->flag &= ~BONE_CONNECTED;
-
- /* get next bones
+
+ /* get next bones
* - child will become the new parent of next bone
*/
child = ebo;
}
else {
- /* not swapping this bone, however, if its 'parent' got swapped, unparent us from it
+ /* not swapping this bone, however, if its 'parent' got swapped, unparent us from it
* as it will be facing in opposite direction
*/
if ((parent) && (EBONE_VISIBLE(arm, parent) && EBONE_EDITABLE(parent))) {
ebo->parent = NULL;
ebo->flag &= ~BONE_CONNECTED;
}
-
+
/* get next bones
- * - child will become new parent of next bone (not swapping occurred,
+ * - child will become new parent of next bone (not swapping occurred,
* so set to NULL to prevent infinite-loop)
*/
child = NULL;
}
-
+
/* tag as done (to prevent double-swaps) */
ebo->flag |= BONE_TRANSFORM;
}
}
}
-
+
/* free chains */
BLI_freelistN(&chains);
-
+
/* clear temp flags */
armature_clear_swap_done_flags(arm);
armature_tag_unselect(arm);
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1135,11 +1136,11 @@ void ARMATURE_OT_switch_direction(wmOperatorType *ot)
ot->name = "Switch Direction";
ot->idname = "ARMATURE_OT_switch_direction";
ot->description = "Change the direction that a chain of bones points in (head <-> tail swap)";
-
+
/* api callbacks */
ot->exec = armature_switch_direction_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1150,10 +1151,10 @@ void ARMATURE_OT_switch_direction(wmOperatorType *ot)
static void fix_connected_bone(EditBone *ebone)
{
float diff[3];
-
+
if (!(ebone->parent) || !(ebone->flag & BONE_CONNECTED) || equals_v3v3(ebone->parent->tail, ebone->head))
return;
-
+
/* if the parent has moved we translate child's head and tail accordingly */
sub_v3_v3v3(diff, ebone->parent->tail, ebone->head);
add_v3_v3(ebone->head, diff);
@@ -1164,14 +1165,14 @@ static void fix_connected_bone(EditBone *ebone)
static void fix_editbone_connected_children(ListBase *edbo, EditBone *ebone)
{
EditBone *selbone;
-
+
for (selbone = edbo->first; selbone; selbone = selbone->next) {
if ((selbone->parent) && (selbone->parent == ebone) && (selbone->flag & BONE_CONNECTED)) {
fix_connected_bone(selbone);
fix_editbone_connected_children(edbo, selbone);
}
}
-}
+}
static void bone_align_to_bone(ListBase *edbo, EditBone *selbone, EditBone *actbone)
{
@@ -1186,21 +1187,21 @@ static void bone_align_to_bone(ListBase *edbo, EditBone *selbone, EditBone *actb
mul_v3_fl(actboneaxis, length);
add_v3_v3v3(selbone->tail, selbone->head, actboneaxis);
selbone->roll = actbone->roll;
-
+
/* if the bone being aligned has connected descendants they must be moved
* according to their parent new position, otherwise they would be left
* in an inconsistent state: connected but away from the parent*/
fix_editbone_connected_children(edbo, selbone);
}
-static int armature_align_bones_exec(bContext *C, wmOperator *op)
+static int armature_align_bones_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_edit_object(C);
bArmature *arm = (bArmature *)ob->data;
EditBone *actbone = CTX_data_active_bone(C);
EditBone *actmirb = NULL;
int num_selected_bones;
-
+
/* there must be an active bone */
if (actbone == NULL) {
BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone");
@@ -1208,28 +1209,28 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
}
else if (arm->flag & ARM_MIRROR_EDIT) {
/* For X-Axis Mirror Editing option, we may need a mirror copy of actbone
- * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone
+ * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone
* (i.e. selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R").
* This is useful for arm-chains, for example parenting lower arm to upper arm
* - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
* then just use actbone. Useful when doing upper arm to spine.
*/
actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone);
- if (actmirb == NULL)
+ if (actmirb == NULL)
actmirb = actbone;
}
-
- /* if there is only 1 selected bone, we assume that that is the active bone,
+
+ /* if there is only 1 selected bone, we assume that that is the active bone,
* since a user will need to have clicked on a bone (thus selecting it) to make it active
*/
num_selected_bones = CTX_DATA_COUNT(C, selected_editable_bones);
if (num_selected_bones <= 1) {
/* When only the active bone is selected, and it has a parent,
- * align it to the parent, as that is the only possible outcome.
+ * align it to the parent, as that is the only possible outcome.
*/
if (actbone->parent) {
bone_align_to_bone(arm->edbo, actbone, actbone->parent);
-
+
if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent))
bone_align_to_bone(arm->edbo, actmirb, actmirb->parent);
@@ -1240,11 +1241,11 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
/* Align 'selected' bones to the active one
* - the context iterator contains both selected bones and their mirrored copies,
* so we assume that unselected bones are mirrored copies of some selected bone
- * - since the active one (and/or its mirror) will also be selected, we also need
+ * - since the active one (and/or its mirror) will also be selected, we also need
* to check that we are not trying to operate on them, since such an operation
* would cause errors
*/
-
+
/* align selected bones to the active one */
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
{
@@ -1262,7 +1263,7 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1272,11 +1273,11 @@ void ARMATURE_OT_align(wmOperatorType *ot)
ot->name = "Align Bones";
ot->idname = "ARMATURE_OT_align";
ot->description = "Align selected bones to the active bone (or to their parent)";
-
+
/* api callbacks */
ot->exec = armature_align_bones_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1388,12 +1389,12 @@ void ARMATURE_OT_delete(wmOperatorType *ot)
ot->name = "Delete Selected Bone(s)";
ot->idname = "ARMATURE_OT_delete";
ot->description = "Remove selected bones from the armature";
-
+
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = armature_delete_selected_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1597,11 +1598,11 @@ void ARMATURE_OT_hide(wmOperatorType *ot)
ot->name = "Hide Selected Bones";
ot->idname = "ARMATURE_OT_hide";
ot->description = "Tag selected bones to not be visible in Edit Mode";
-
+
/* api callbacks */
ot->exec = armature_hide_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1615,7 +1616,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *op)
bArmature *arm = obedit->data;
EditBone *ebone;
const bool select = RNA_boolean_get(op->ptr, "select");
-
+
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (arm->layer & ebone->layer) {
if (ebone->flag & BONE_HIDDEN_A) {
@@ -1640,11 +1641,11 @@ void ARMATURE_OT_reveal(wmOperatorType *ot)
ot->name = "Reveal Bones";
ot->idname = "ARMATURE_OT_reveal";
ot->description = "Reveal all bones hidden in Edit Mode";
-
+
/* api callbacks */
ot->exec = armature_reveal_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index c40872cbd3a..1fe729b7c4b 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -146,25 +146,25 @@ void POSE_OT_toggle_bone_selection_overlay(struct wmOperatorType *ot);
/* Temporary data linking PoseChannels with the F-Curves they affect */
typedef struct tPChanFCurveLink {
struct tPChanFCurveLink *next, *prev;
-
+
ListBase fcurves; /* F-Curves for this PoseChannel (wrapped with LinkData) */
struct bPoseChannel *pchan; /* Pose Channel which data is attached to */
-
+
char *pchan_path; /* RNA Path to this Pose Channel (needs to be freed when we're done) */
-
+
float oldloc[3]; /* transform values at start of operator (to be restored before each modal step) */
float oldrot[3];
float oldscale[3];
float oldquat[4];
float oldangle;
float oldaxis[3];
-
+
float roll1, roll2; /* old bbone values (to be restored along with the transform properties) */
float curveInX, curveInY; /* (NOTE: we haven't renamed these this time, as their names are already long enough) */
float curveOutX, curveOutY;
float ease1, ease2;
float scaleIn, scaleOut;
-
+
struct IDProperty *oldprops; /* copy of custom properties at start of operator (to be restored before each modal step) */
} tPChanFCurveLink;
diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c
index e8d45f72f89..a73e64af0ee 100644
--- a/source/blender/editors/armature/armature_naming.c
+++ b/source/blender/editors/armature/armature_naming.c
@@ -105,15 +105,15 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, const char *
{
bConstraint *curcon;
bConstraintTarget *ct;
-
+
for (curcon = conlist->first; curcon; curcon = curcon->next) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon);
ListBase targets = {NULL, NULL};
-
+
/* constraint targets */
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(curcon, &targets);
-
+
for (ct = targets.first; ct; ct = ct->next) {
if (ct->tar == ob) {
if (STREQ(ct->subtarget, oldname)) {
@@ -121,11 +121,11 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, const char *
}
}
}
-
+
if (cti->flush_constraint_targets)
cti->flush_constraint_targets(curcon, &targets, 0);
}
-
+
/* action constraints */
if (curcon->type == CONSTRAINT_TYPE_ACTION) {
bActionConstraint *actcon = (bActionConstraint *)curcon->data;
@@ -137,24 +137,24 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, const char *
/* called by UI for renaming a bone */
/* warning: make sure the original bone was not renamed yet! */
/* seems messy, but thats what you get with not using pointers but channel names :) */
-void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *newnamep)
+void ED_armature_bone_rename(Main *bmain, bArmature *arm, const char *oldnamep, const char *newnamep)
{
Object *ob;
char newname[MAXBONENAME];
char oldname[MAXBONENAME];
-
+
/* names better differ! */
if (!STREQLEN(oldnamep, newnamep, MAXBONENAME)) {
-
+
/* we alter newname string... so make copy */
BLI_strncpy(newname, newnamep, MAXBONENAME);
/* we use oldname for search... so make copy */
BLI_strncpy(oldname, oldnamep, MAXBONENAME);
-
+
/* now check if we're in editmode, we need to find the unique name */
if (arm->edbo) {
EditBone *eBone = ED_armature_ebone_find_name(arm->edbo, oldname);
-
+
if (eBone) {
ED_armature_ebone_unique_name(arm->edbo, newname, NULL);
BLI_strncpy(eBone->name, newname, MAXBONENAME);
@@ -165,7 +165,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
}
else {
Bone *bone = BKE_armature_find_bone_name(arm, oldname);
-
+
if (bone) {
unique_bone_name(arm, newname);
BLI_strncpy(bone->name, newname, MAXBONENAME);
@@ -174,15 +174,15 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
return;
}
}
-
+
/* do entire dbase - objects */
- for (ob = G.main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
ModifierData *md;
-
+
/* we have the object using the armature */
if (arm == ob->data) {
Object *cob;
-
+
/* Rename the pose channel, if it exists */
if (ob->pose) {
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, oldname);
@@ -204,9 +204,9 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
BLI_assert(BKE_pose_channels_is_valid(ob->pose) == true);
}
-
+
/* Update any object constraints to use the new bone name */
- for (cob = G.main->object.first; cob; cob = cob->id.next) {
+ for (cob = bmain->object.first; cob; cob = cob->id.next) {
if (cob->constraints.first)
constraint_bone_name_fix(ob, &cob->constraints, oldname, newname);
if (cob->pose) {
@@ -217,7 +217,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
}
}
}
-
+
/* See if an object is parented to this armature */
if (ob->parent && (ob->parent->data == arm)) {
if (ob->partype == PARBONE) {
@@ -226,14 +226,14 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
BLI_strncpy(ob->parsubstr, newname, MAXBONENAME);
}
}
-
+
if (modifiers_usesArmature(ob, arm)) {
bDeformGroup *dg = defgroup_find_name(ob, oldname);
if (dg) {
BLI_strncpy(dg->name, newname, MAXBONENAME);
}
}
-
+
/* fix modifiers that might be using this name */
for (md = ob->modifiers.first; md; md = md->next) {
switch (md->type) {
@@ -266,20 +266,20 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
}
}
}
-
+
/* Fix all animdata that may refer to this bone - we can't just do the ones attached to objects, since
* other ID-blocks may have drivers referring to this bone [#29822]
*/
// XXX: the ID here is for armatures, but most bone drivers are actually on the object instead...
{
-
+
BKE_animdata_fix_paths_rename_all(&arm->id, "pose.bones", oldname, newname);
}
-
+
/* correct view locking */
{
bScreen *screen;
- for (screen = G.main->screen.first; screen; screen = screen->id.next) {
+ for (screen = bmain->screen.first; screen; screen = screen->id.next) {
ScrArea *sa;
/* add regions */
for (sa = screen->areabase.first; sa; sa = sa->next) {
@@ -316,7 +316,7 @@ typedef struct BoneFlipNameData {
* \param bones_names: List of BoneConflict elems.
* \param do_strip_numbers: if set, try to get rid of dot-numbers at end of bone names.
*/
-void ED_armature_bones_flip_names(bArmature *arm, ListBase *bones_names, const bool do_strip_numbers)
+void ED_armature_bones_flip_names(Main *bmain, bArmature *arm, ListBase *bones_names, const bool do_strip_numbers)
{
ListBase bones_names_conflicts = {NULL};
BoneFlipNameData *bfn;
@@ -332,7 +332,7 @@ void ED_armature_bones_flip_names(bArmature *arm, ListBase *bones_names, const b
* Bone.R, Bone.R.001, Bone.R.002, etc. */
BLI_string_flip_side_name(name_flip, name, do_strip_numbers, sizeof(name_flip));
- ED_armature_bone_rename(arm, name, name_flip);
+ ED_armature_bone_rename(bmain, arm, name, name_flip);
if (!STREQ(name, name_flip)) {
bfn = alloca(sizeof(BoneFlipNameData));
@@ -346,7 +346,7 @@ void ED_armature_bones_flip_names(bArmature *arm, ListBase *bones_names, const b
* Note that if the other bone was not selected, its name was not flipped, so conflict remains and that second
* rename simply generates a new numbered alternative name. */
for (bfn = bones_names_conflicts.first; bfn; bfn = bfn->next) {
- ED_armature_bone_rename(arm, bfn->name, bfn->name_flip);
+ ED_armature_bone_rename(bmain, arm, bfn->name, bfn->name_flip);
}
}
@@ -355,6 +355,7 @@ void ED_armature_bones_flip_names(bArmature *arm, ListBase *bones_names, const b
static int armature_flip_names_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Object *ob = CTX_data_edit_object(C);
bArmature *arm;
@@ -374,10 +375,10 @@ static int armature_flip_names_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- ED_armature_bones_flip_names(arm, &bones_names, do_strip_numbers);
+ ED_armature_bones_flip_names(bmain, arm, &bones_names, do_strip_numbers);
BLI_freelistN(&bones_names);
-
+
/* since we renamed stuff... */
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -397,11 +398,11 @@ void ARMATURE_OT_flip_names(wmOperatorType *ot)
ot->name = "Flip Names";
ot->idname = "ARMATURE_OT_flip_names";
ot->description = "Flips (and corrects) the axis suffixes of the names of selected bones";
-
+
/* api callbacks */
ot->exec = armature_flip_names_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -413,31 +414,32 @@ void ARMATURE_OT_flip_names(wmOperatorType *ot)
static int armature_autoside_names_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Object *ob = CTX_data_edit_object(C);
bArmature *arm;
char newname[MAXBONENAME];
short axis = RNA_enum_get(op->ptr, "type");
-
+
/* paranoia checks */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
arm = ob->data;
-
+
/* loop through selected bones, auto-naming them */
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
{
BLI_strncpy(newname, ebone->name, sizeof(newname));
if (bone_autoside_name(newname, 1, axis, ebone->head[axis], ebone->tail[axis]))
- ED_armature_bone_rename(arm, ebone->name, newname);
+ ED_armature_bone_rename(bmain, arm, ebone->name, newname);
}
CTX_DATA_END;
-
+
/* since we renamed stuff... */
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -449,20 +451,20 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot)
{2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "AutoName by Axis";
ot->idname = "ARMATURE_OT_autoside_names";
ot->description = "Automatically renames the selected bones according to which side of the target axis they fall on";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = armature_autoside_names_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* settings */
ot->prop = RNA_def_enum(ot->srna, "type", axis_items, 0, "Axis", "Axis tag names with");
}
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index 8dfc11aea19..cee99c3b8f8 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -46,16 +46,16 @@ void ED_operatortypes_armature(void)
{
/* EDIT ARMATURE */
WM_operatortype_append(ARMATURE_OT_bone_primitive_add);
-
+
WM_operatortype_append(ARMATURE_OT_align);
WM_operatortype_append(ARMATURE_OT_calculate_roll);
WM_operatortype_append(ARMATURE_OT_roll_clear);
WM_operatortype_append(ARMATURE_OT_switch_direction);
WM_operatortype_append(ARMATURE_OT_subdivide);
-
+
WM_operatortype_append(ARMATURE_OT_parent_set);
WM_operatortype_append(ARMATURE_OT_parent_clear);
-
+
WM_operatortype_append(ARMATURE_OT_select_all);
WM_operatortype_append(ARMATURE_OT_select_mirror);
WM_operatortype_append(ARMATURE_OT_select_more);
@@ -77,10 +77,10 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(ARMATURE_OT_merge);
WM_operatortype_append(ARMATURE_OT_separate);
WM_operatortype_append(ARMATURE_OT_split);
-
+
WM_operatortype_append(ARMATURE_OT_autoside_names);
WM_operatortype_append(ARMATURE_OT_flip_names);
-
+
WM_operatortype_append(ARMATURE_OT_layers_show_all);
WM_operatortype_append(ARMATURE_OT_armature_layers);
WM_operatortype_append(ARMATURE_OT_bone_layers);
@@ -88,19 +88,19 @@ void ED_operatortypes_armature(void)
/* POSE */
WM_operatortype_append(POSE_OT_hide);
WM_operatortype_append(POSE_OT_reveal);
-
+
WM_operatortype_append(POSE_OT_armature_apply);
WM_operatortype_append(POSE_OT_visual_transform_apply);
-
+
WM_operatortype_append(POSE_OT_rot_clear);
WM_operatortype_append(POSE_OT_loc_clear);
WM_operatortype_append(POSE_OT_scale_clear);
WM_operatortype_append(POSE_OT_transforms_clear);
WM_operatortype_append(POSE_OT_user_transforms_clear);
-
+
WM_operatortype_append(POSE_OT_copy);
WM_operatortype_append(POSE_OT_paste);
-
+
WM_operatortype_append(POSE_OT_select_all);
WM_operatortype_append(POSE_OT_select_parent);
@@ -109,7 +109,7 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(POSE_OT_select_constraint_target);
WM_operatortype_append(POSE_OT_select_grouped);
WM_operatortype_append(POSE_OT_select_mirror);
-
+
WM_operatortype_append(POSE_OT_group_add);
WM_operatortype_append(POSE_OT_group_remove);
WM_operatortype_append(POSE_OT_group_move);
@@ -118,38 +118,38 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(POSE_OT_group_unassign);
WM_operatortype_append(POSE_OT_group_select);
WM_operatortype_append(POSE_OT_group_deselect);
-
+
WM_operatortype_append(POSE_OT_paths_calculate);
WM_operatortype_append(POSE_OT_paths_update);
WM_operatortype_append(POSE_OT_paths_clear);
-
+
WM_operatortype_append(POSE_OT_autoside_names);
WM_operatortype_append(POSE_OT_flip_names);
-
+
WM_operatortype_append(POSE_OT_rotation_mode_set);
WM_operatortype_append(POSE_OT_quaternions_flip);
-
+
WM_operatortype_append(POSE_OT_bone_layers);
WM_operatortype_append(POSE_OT_toggle_bone_selection_overlay);
-
+
WM_operatortype_append(POSE_OT_propagate);
-
+
/* POSELIB */
WM_operatortype_append(POSELIB_OT_browse_interactive);
WM_operatortype_append(POSELIB_OT_apply_pose);
-
+
WM_operatortype_append(POSELIB_OT_pose_add);
WM_operatortype_append(POSELIB_OT_pose_remove);
WM_operatortype_append(POSELIB_OT_pose_rename);
WM_operatortype_append(POSELIB_OT_pose_move);
-
+
WM_operatortype_append(POSELIB_OT_new);
WM_operatortype_append(POSELIB_OT_unlink);
-
+
WM_operatortype_append(POSELIB_OT_action_sanitize);
-
+
/* POSE SLIDING */
WM_operatortype_append(POSE_OT_push);
WM_operatortype_append(POSE_OT_relax);
@@ -191,7 +191,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
{
wmKeyMap *keymap;
wmKeyMapItem *kmi;
-
+
/* Armature ------------------------ */
keymap = WM_keymap_find(keyconf, "Armature", 0, 0);
keymap->poll = ED_operator_editarmature;
@@ -206,14 +206,14 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "ARMATURE_OT_align", AKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_calculate_roll", NKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_roll_clear", RKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_item(keymap, "ARMATURE_OT_switch_direction", FKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_item(keymap, "ARMATURE_OT_bone_primitive_add", AKEY, KM_PRESS, KM_SHIFT, 0);
-
+
WM_keymap_add_item(keymap, "ARMATURE_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0);
-
+
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", AKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
@@ -221,14 +221,14 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", false);
-
+
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
RNA_boolean_set(kmi->ptr, "extend", false);
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
RNA_boolean_set(kmi->ptr, "extend", true);
-
+
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
RNA_boolean_set(kmi->ptr, "extend", false);
@@ -244,7 +244,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "ARMATURE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_shortest_path_pick", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_armature_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_armature_delete", DELKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_dissolve", XKEY, KM_PRESS, KM_CTRL, 0);
@@ -255,19 +255,19 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "ARMATURE_OT_fill", FKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_merge", MKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_split", YKEY, KM_PRESS, 0, 0);
-
+
WM_keymap_add_item(keymap, "ARMATURE_OT_separate", PKEY, KM_PRESS, 0, 0);
-
+
/* set flags */
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_toggle", WKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_disable", WKEY, KM_PRESS, KM_ALT, 0);
-
+
/* armature/bone layers */
WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_bone_layers", MKEY, KM_PRESS, 0, 0);
-
+
/* special transforms: */
/* 1) envelope/b-bone size */
kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
@@ -278,7 +278,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
/* 3) set roll */
kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", RKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "mode", TFM_BONE_ROLL);
-
+
/* menus */
WM_keymap_add_menu(keymap, "VIEW3D_MT_armature_specials", WKEY, KM_PRESS, 0, 0);
@@ -286,36 +286,36 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
/* only set in posemode, by space_view3d listener */
keymap = WM_keymap_find(keyconf, "Pose", 0, 0);
keymap->poll = ED_operator_posemode;
-
+
/* set parent and add object are object-based operators, but we make them
* available here because it's useful to do in pose mode too */
WM_keymap_add_item(keymap, "OBJECT_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_menu(keymap, "INFO_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
-
+
kmi = WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "unselected", false);
kmi = WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "unselected", true);
WM_keymap_add_item(keymap, "POSE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_apply", AKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* TODO: clear pose */
WM_keymap_add_item(keymap, "POSE_OT_rot_clear", RKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "POSE_OT_loc_clear", GKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "POSE_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_item(keymap, "POSE_OT_quaternions_flip", FKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_item(keymap, "POSE_OT_rotation_mode_set", RKEY, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "POSE_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "flipped", false);
kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "flipped", true);
-
+
#ifdef __APPLE__
WM_keymap_add_item(keymap, "POSE_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0);
kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0);
@@ -337,7 +337,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
RNA_boolean_set(kmi->ptr, "extend", true);
-
+
kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
RNA_boolean_set(kmi->ptr, "extend", false);
@@ -348,14 +348,14 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "POSE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "POSE_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSE_OT_select_mirror", FKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
WM_keymap_add_item(keymap, "POSE_OT_ik_add", IKEY, KM_PRESS, /*KM_CTRL|*/ KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSE_OT_ik_clear", IKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
-
+
WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_group", GKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* set flags */
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_toggle", WKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
@@ -366,25 +366,25 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "ARMATURE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSE_OT_bone_layers", MKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "POSE_OT_toggle_bone_selection_overlay", ZKEY, KM_PRESS, 0, 0);
-
+
/* special transforms: */
/* 1) envelope/b-bone size */
kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
RNA_enum_set(kmi->ptr, "mode", TFM_BONESIZE);
-
+
/* keyframes management */
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0);
-
+
/* Pose -> PoseLib ------------- */
/* only set in posemode, by space_view3d listener */
WM_keymap_add_item(keymap, "POSELIB_OT_browse_interactive", LKEY, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "POSELIB_OT_pose_add", LKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSELIB_OT_pose_remove", LKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "POSELIB_OT_pose_rename", LKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
-
+
/* Pose -> Pose Sliding ------------- */
/* only set in posemode, by space_view3d listener */
WM_keymap_add_item(keymap, "POSE_OT_push", EKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index 91f8a8713bc..9282148e857 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -110,7 +110,7 @@ static void joined_armature_fix_links_constraints(
bActionConstraint *data = con->data;
if (data->act) {
- BKE_action_fix_paths_rename(&tarArm->id, data->act, "pose.bones[",
+ BKE_action_fix_paths_rename(&tarArm->id, data->act, "pose.bones[",
pchan->name, curbone->name, 0, 0, false);
}
}
@@ -122,7 +122,7 @@ static void joined_armature_fix_links_constraints(
typedef struct tJoinArmature_AdtFixData {
Object *srcArm;
Object *tarArm;
-
+
GHash *names_map;
} tJoinArmature_AdtFixData;
@@ -135,34 +135,34 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data
tJoinArmature_AdtFixData *afd = (tJoinArmature_AdtFixData *)user_data;
ID *src_id = &afd->srcArm->id;
ID *dst_id = &afd->tarArm->id;
-
+
GHashIterator gh_iter;
-
+
/* Fix paths - If this is the target object, it will have some "dirty" paths */
if ((id == src_id) && strstr(fcu->rna_path, "pose.bones[")) {
GHASH_ITER(gh_iter, afd->names_map) {
const char *old_name = BLI_ghashIterator_getKey(&gh_iter);
const char *new_name = BLI_ghashIterator_getValue(&gh_iter);
-
+
/* only remap if changed; this still means there will be some waste if there aren't many drivers/keys */
if (!STREQ(old_name, new_name) && strstr(fcu->rna_path, old_name)) {
fcu->rna_path = BKE_animsys_fix_rna_path_rename(id, fcu->rna_path, "pose.bones",
old_name, new_name, 0, 0, false);
-
- /* we don't want to apply a second remapping on this driver now,
+
+ /* we don't want to apply a second remapping on this driver now,
* so stop trying names, but keep fixing drivers
*/
break;
}
}
}
-
-
+
+
/* Driver targets */
if (fcu->driver) {
ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
-
+
/* Fix driver references to invalid ID's */
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
/* only change the used targets, since the others will need fixing manually anyway */
@@ -171,7 +171,7 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data
/* change the ID's used... */
if (dtar->id == src_id) {
dtar->id = dst_id;
-
+
/* also check on the subtarget...
* XXX: We duplicate the logic from drivers_path_rename_fix() here, with our own
* little twists so that we know that it isn't going to clobber the wrong data
@@ -180,7 +180,7 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data
GHASH_ITER(gh_iter, afd->names_map) {
const char *old_name = BLI_ghashIterator_getKey(&gh_iter);
const char *new_name = BLI_ghashIterator_getValue(&gh_iter);
-
+
/* only remap if changed */
if (!STREQ(old_name, new_name)) {
if ((dtar->rna_path) && strstr(dtar->rna_path, old_name)) {
@@ -210,7 +210,7 @@ static void joined_armature_fix_links(Main *bmain, Object *tarArm, Object *srcAr
Object *ob;
bPose *pose;
bPoseChannel *pchant;
-
+
/* let's go through all objects in database */
for (ob = bmain->object.first; ob; ob = ob->id.next) {
/* do some object-type specific things */
@@ -220,12 +220,12 @@ static void joined_armature_fix_links(Main *bmain, Object *tarArm, Object *srcAr
joined_armature_fix_links_constraints(tarArm, srcArm, pchan, curbone, &pchant->constraints);
}
}
-
+
/* fix object-level constraints */
if (ob != srcArm) {
joined_armature_fix_links_constraints(tarArm, srcArm, pchan, curbone, &ob->constraints);
}
-
+
/* See if an object is parented to this armature */
if (ob->parent && (ob->parent == srcArm)) {
/* Is object parented to a bone of this src armature? */
@@ -235,7 +235,7 @@ static void joined_armature_fix_links(Main *bmain, Object *tarArm, Object *srcAr
BLI_strncpy(ob->parsubstr, curbone->name, sizeof(ob->parsubstr));
}
}
-
+
/* make tar armature be new parent */
ob->parent = tarArm;
}
@@ -254,13 +254,13 @@ int join_armature_exec(bContext *C, wmOperator *op)
EditBone *curbone;
float mat[4][4], oimat[4][4];
bool ok = false;
-
+
/* Ensure we're not in editmode and that the active object is an armature*/
if (!ob || ob->type != OB_ARMATURE)
return OPERATOR_CANCELLED;
if (!arm || arm->edbo)
return OPERATOR_CANCELLED;
-
+
CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
{
if (base->object == ob) {
@@ -278,7 +278,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
/* Get editbones of active armature to add editbones to */
ED_armature_to_edit(arm);
-
+
/* get pose of active object and move it out of posemode */
pose = ob->pose;
ob->mode &= ~OB_MODE_POSE;
@@ -288,36 +288,36 @@ int join_armature_exec(bContext *C, wmOperator *op)
if ((base->object->type == OB_ARMATURE) && (base->object != ob)) {
tJoinArmature_AdtFixData afd = {NULL};
bArmature *curarm = base->object->data;
-
+
/* we assume that each armature datablock is only used in a single place */
BLI_assert(ob->data != base->object->data);
-
+
/* init callback data for fixing up AnimData links later */
afd.srcArm = base->object;
afd.tarArm = ob;
afd.names_map = BLI_ghash_str_new("join_armature_adt_fix");
-
+
/* Make a list of editbones in current armature */
ED_armature_to_edit(base->object->data);
-
+
/* Get Pose of current armature */
opose = base->object->pose;
base->object->mode &= ~OB_MODE_POSE;
//BASACT->flag &= ~OB_MODE_POSE;
-
+
/* Find the difference matrix */
invert_m4_m4(oimat, ob->obmat);
mul_m4_m4m4(mat, oimat, base->object->obmat);
-
+
/* Copy bones and posechannels from the object to the edit armature */
for (pchan = opose->chanbase.first; pchan; pchan = pchann) {
pchann = pchan->next;
curbone = ED_armature_ebone_find_name(curarm->edbo, pchan->name);
-
+
/* Get new name */
ED_armature_ebone_unique_name(arm->edbo, curbone->name, NULL);
BLI_ghash_insert(afd.names_map, BLI_strdup(pchan->name), curbone->name);
-
+
/* Transform the bone */
{
float premat[4][4];
@@ -325,48 +325,48 @@ int join_armature_exec(bContext *C, wmOperator *op)
float difmat[4][4];
float imat[4][4];
float temp[3][3];
-
+
/* Get the premat */
ED_armature_ebone_to_mat3(curbone, temp);
-
+
unit_m4(premat); /* mul_m4_m3m4 only sets 3x3 part */
mul_m4_m3m4(premat, temp, mat);
-
+
mul_m4_v3(mat, curbone->head);
mul_m4_v3(mat, curbone->tail);
-
+
/* Get the postmat */
ED_armature_ebone_to_mat3(curbone, temp);
copy_m4_m3(postmat, temp);
-
+
/* Find the roll */
invert_m4_m4(imat, premat);
mul_m4_m4m4(difmat, imat, postmat);
-
+
curbone->roll -= atan2f(difmat[2][0], difmat[2][2]);
}
-
+
/* Fix Constraints and Other Links to this Bone and Armature */
joined_armature_fix_links(bmain, ob, base->object, pchan, curbone);
-
+
/* Rename pchan */
BLI_strncpy(pchan->name, curbone->name, sizeof(pchan->name));
-
+
/* Jump Ship! */
BLI_remlink(curarm->edbo, curbone);
BLI_addtail(arm->edbo, curbone);
-
+
BLI_remlink(&opose->chanbase, pchan);
BLI_addtail(&pose->chanbase, pchan);
BKE_pose_channels_hash_free(opose);
BKE_pose_channels_hash_free(pose);
}
-
+
/* Fix all the drivers (and animation data) */
BKE_fcurves_main_cb(bmain, joined_armature_fix_animdata_cb, &afd);
BLI_ghash_free(afd.names_map, MEM_freeN, NULL);
-
- /* Only copy over animdata now, after all the remapping has been done,
+
+ /* Only copy over animdata now, after all the remapping has been done,
* so that we don't have to worry about ambiguities re which armature
* a bone came from!
*/
@@ -380,7 +380,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
BKE_animdata_merge_copy(&ob->id, &base->object->id, ADT_MERGECOPY_KEEP_DST, false);
}
}
-
+
if (curarm->adt) {
if (arm->adt == NULL) {
/* no animdata, so just use a copy of the whole thing */
@@ -391,39 +391,39 @@ int join_armature_exec(bContext *C, wmOperator *op)
BKE_animdata_merge_copy(&arm->id, &curarm->id, ADT_MERGECOPY_KEEP_DST, false);
}
}
-
+
/* Free the old object data */
ED_object_base_free_and_unlink(bmain, scene, base->object);
}
}
CTX_DATA_END;
-
+
DEG_relations_tag_update(bmain); /* because we removed object(s) */
- ED_armature_from_edit(arm);
+ ED_armature_from_edit(bmain, arm);
ED_armature_edit_free(arm);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
-
+
return OPERATOR_FINISHED;
}
/* *********************************** Separate *********************************************** */
/* Helper function for armature separating - link fixing */
-static void separated_armature_fix_links(Object *origArm, Object *newArm)
+static void separated_armature_fix_links(Main *bmain, Object *origArm, Object *newArm)
{
Object *ob;
bPoseChannel *pchan;
bConstraint *con;
ListBase *opchans, *npchans;
-
+
/* get reference to list of bones in original and new armatures */
opchans = &origArm->pose->chanbase;
npchans = &newArm->pose->chanbase;
-
+
/* let's go through all objects in database */
- for (ob = G.main->object.first; ob; ob = ob->id.next) {
+ for (ob = bmain->object.first; ob; ob = ob->id.next) {
/* do some object-type specific things */
if (ob->type == OB_ARMATURE) {
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -431,11 +431,11 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
-
+
/* constraint targets */
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
-
+
for (ct = targets.first; ct; ct = ct->next) {
/* any targets which point to original armature are redirected to the new one only if:
* - the target isn't origArm/newArm itself
@@ -462,18 +462,18 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
}
}
}
-
+
/* fix object-level constraints */
if (ob != origArm) {
for (con = ob->constraints.first; con; con = con->next) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
-
+
/* constraint targets */
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
-
+
for (ct = targets.first; ct; ct = ct->next) {
/* any targets which point to original armature are redirected to the new one only if:
* - the target isn't origArm/newArm itself
@@ -492,14 +492,14 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
}
}
}
-
+
if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 0);
}
}
}
}
-
+
/* See if an object is parented to this armature */
if (ob->parent && (ob->parent == origArm)) {
/* Is object parented to a bone of this src armature? */
@@ -512,31 +512,31 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
}
}
-/* Helper function for armature separating - remove certain bones from the given armature
+/* Helper function for armature separating - remove certain bones from the given armature
* sel: remove selected bones from the armature, otherwise the unselected bones are removed
* (ob is not in editmode)
*/
-static void separate_armature_bones(Object *ob, short sel)
+static void separate_armature_bones(Main *bmain, Object *ob, short sel)
{
bArmature *arm = (bArmature *)ob->data;
bPoseChannel *pchan, *pchann;
EditBone *curbone;
-
+
/* make local set of editbones to manipulate here */
ED_armature_to_edit(arm);
-
+
/* go through pose-channels, checking if a bone should be removed */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchann) {
pchann = pchan->next;
curbone = ED_armature_ebone_find_name(arm->edbo, pchan->name);
-
+
/* check if bone needs to be removed */
if ( (sel && (curbone->flag & BONE_SELECTED)) ||
(!sel && !(curbone->flag & BONE_SELECTED)) )
{
EditBone *ebo;
bPoseChannel *pchn;
-
+
/* clear the bone->parent var of any bone that had this as its parent */
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
if (ebo->parent == curbone) {
@@ -545,25 +545,25 @@ static void separate_armature_bones(Object *ob, short sel)
ebo->flag &= ~BONE_CONNECTED;
}
}
-
+
/* clear the pchan->parent var of any pchan that had this as its parent */
for (pchn = ob->pose->chanbase.first; pchn; pchn = pchn->next) {
if (pchn->parent == pchan)
pchn->parent = NULL;
}
-
+
/* free any of the extra-data this pchan might have */
BKE_pose_channel_free(pchan);
BKE_pose_channels_hash_free(ob->pose);
-
+
/* get rid of unneeded bone */
bone_free(arm, curbone);
BLI_freelinkN(&ob->pose->chanbase, pchan);
}
}
-
+
/* exit editmode (recalculates pchans too) */
- ED_armature_from_edit(ob->data);
+ ED_armature_from_edit(bmain, ob->data);
ED_armature_edit_free(ob->data);
}
@@ -576,14 +576,14 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
Object *oldob, *newob;
Base *oldbase, *newbase;
-
+
/* sanity checks */
if (obedit == NULL)
return OPERATOR_CANCELLED;
-
+
/* set wait cursor in case this takes a while */
WM_cursor_wait(1);
-
+
/* we are going to do this as follows (unlike every other instance of separate):
* 1. exit editmode +posemode for active armature/base. Take note of what this is.
* 2. duplicate base - BASACT is the new one now
@@ -604,16 +604,16 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_END;
-
+
/* 1) store starting settings and exit editmode */
oldob = obedit;
oldbase = view_layer->basact;
oldob->mode &= ~OB_MODE_POSE;
//oldbase->flag &= ~OB_POSEMODE;
-
- ED_armature_from_edit(obedit->data);
+
+ ED_armature_from_edit(bmain, obedit->data);
ED_armature_edit_free(obedit->data);
-
+
/* 2) duplicate base */
newbase = ED_object_add_duplicate(bmain, scene, view_layer, oldbase, USER_DUP_ARM); /* only duplicate linked armature */
DEG_relations_tag_update(bmain);
@@ -623,22 +623,22 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
/* 3) remove bones that shouldn't still be around on both armatures */
- separate_armature_bones(oldob, 1);
- separate_armature_bones(newob, 0);
-
-
+ separate_armature_bones(bmain, oldob, 1);
+ separate_armature_bones(bmain, newob, 0);
+
+
/* 4) fix links before depsgraph flushes */ // err... or after?
- separated_armature_fix_links(oldob, newob);
-
+ separated_armature_fix_links(bmain, oldob, newob);
+
DEG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */
DEG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */
-
-
+
+
/* 5) restore original conditions */
obedit = oldob;
-
+
ED_armature_to_edit(obedit->data);
-
+
/* parents tips remain selected when connected children are removed. */
ED_armature_edit_deselect_all(obedit);
@@ -646,10 +646,10 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit);
-
+
/* recalc/redraw + cleanup */
WM_cursor_wait(0);
-
+
return OPERATOR_FINISHED;
}
@@ -659,12 +659,12 @@ void ARMATURE_OT_separate(wmOperatorType *ot)
ot->name = "Separate Bones";
ot->idname = "ARMATURE_OT_separate";
ot->description = "Isolate selected bones into a separate armature";
-
+
/* callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = separate_armature_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -688,13 +688,13 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo
{
EditBone *ebone;
float offset[3];
-
+
if ((selbone->parent) && (selbone->flag & BONE_CONNECTED))
selbone->parent->flag &= ~(BONE_TIPSEL);
-
+
/* make actbone the parent of selbone */
selbone->parent = actbone;
-
+
/* in actbone tree we cannot have a loop */
for (ebone = actbone->parent; ebone; ebone = ebone->parent) {
if (ebone->parent == selbone) {
@@ -702,21 +702,21 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo
ebone->flag &= ~BONE_CONNECTED;
}
}
-
+
if (mode == ARM_PAR_CONNECT) {
/* Connected: Child bones will be moved to the parent tip */
selbone->flag |= BONE_CONNECTED;
sub_v3_v3v3(offset, actbone->tail, selbone->head);
-
+
copy_v3_v3(selbone->head, actbone->tail);
selbone->rad_head = actbone->rad_tail;
-
+
add_v3_v3(selbone->tail, offset);
-
+
/* offset for all its children */
for (ebone = edbo->first; ebone; ebone = ebone->next) {
EditBone *par;
-
+
for (par = ebone->parent; par; par = par->parent) {
if (par == selbone) {
add_v3_v3(ebone->head, offset);
@@ -739,14 +739,14 @@ static const EnumPropertyItem prop_editarm_make_parent_types[] = {
{0, NULL, 0, NULL, NULL}
};
-static int armature_parent_set_exec(bContext *C, wmOperator *op)
+static int armature_parent_set_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_edit_object(C);
bArmature *arm = (bArmature *)ob->data;
EditBone *actbone = CTX_data_active_bone(C);
EditBone *actmirb = NULL;
short val = RNA_enum_get(op->ptr, "type");
-
+
/* there must be an active bone */
if (actbone == NULL) {
BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone");
@@ -754,27 +754,27 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
}
else if (arm->flag & ARM_MIRROR_EDIT) {
/* For X-Axis Mirror Editing option, we may need a mirror copy of actbone
- * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone
+ * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone
* (i.e. selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R").
* This is useful for arm-chains, for example parenting lower arm to upper arm
* - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
* then just use actbone. Useful when doing upper arm to spine.
*/
actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone);
- if (actmirb == NULL)
+ if (actmirb == NULL)
actmirb = actbone;
}
-
- /* if there is only 1 selected bone, we assume that that is the active bone,
+
+ /* if there is only 1 selected bone, we assume that that is the active bone,
* since a user will need to have clicked on a bone (thus selecting it) to make it active
*/
if (CTX_DATA_COUNT(C, selected_editable_bones) <= 1) {
/* When only the active bone is selected, and it has a parent,
- * connect it to the parent, as that is the only possible outcome.
+ * connect it to the parent, as that is the only possible outcome.
*/
if (actbone->parent) {
bone_connect_to_existing_parent(actbone);
-
+
if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent))
bone_connect_to_existing_parent(actmirb);
}
@@ -783,16 +783,16 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
/* Parent 'selected' bones to the active one
* - the context iterator contains both selected bones and their mirrored copies,
* so we assume that unselected bones are mirrored copies of some selected bone
- * - since the active one (and/or its mirror) will also be selected, we also need
+ * - since the active one (and/or its mirror) will also be selected, we also need
* to check that we are not trying to operate on them, since such an operation
* would cause errors
*/
-
+
/* parent selected bones to the active one */
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
{
if (ELEM(ebone, actbone, actmirb) == 0) {
- if (ebone->flag & BONE_SELECTED)
+ if (ebone->flag & BONE_SELECTED)
bone_connect_to_new_parent(arm->edbo, ebone, actbone, val);
else
bone_connect_to_new_parent(arm->edbo, ebone, actmirb, val);
@@ -800,11 +800,11 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
}
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -814,7 +814,7 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const
uiPopupMenu *pup = UI_popup_menu_begin(C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Make Parent"), ICON_NONE);
uiLayout *layout = UI_popup_menu_layout(pup);
int allchildbones = 0;
-
+
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
{
if (ebone != actbone) {
@@ -824,13 +824,13 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const
CTX_DATA_END;
uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_CONNECT);
-
+
/* ob becomes parent, make the associated menus */
if (allchildbones)
uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_OFFSET);
-
+
UI_popup_menu_end(C, pup);
-
+
return OPERATOR_INTERFACE;
}
@@ -840,15 +840,15 @@ void ARMATURE_OT_parent_set(wmOperatorType *ot)
ot->name = "Make Parent";
ot->idname = "ARMATURE_OT_parent_set";
ot->description = "Set the active bone as the parent of the selected bones";
-
+
/* api callbacks */
ot->invoke = armature_parent_set_invoke;
ot->exec = armature_parent_set_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_enum(ot->srna, "type", prop_editarm_make_parent_types, 0, "ParentType", "Type of parenting");
}
@@ -866,28 +866,28 @@ static void editbone_clear_parent(EditBone *ebone, int mode)
/* for nice selection */
ebone->parent->flag &= ~(BONE_TIPSEL);
}
-
+
if (mode == 1) ebone->parent = NULL;
ebone->flag &= ~BONE_CONNECTED;
}
-static int armature_parent_clear_exec(bContext *C, wmOperator *op)
+static int armature_parent_clear_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_edit_object(C);
bArmature *arm = (bArmature *)ob->data;
int val = RNA_enum_get(op->ptr, "type");
-
+
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
{
editbone_clear_parent(ebone, val);
}
CTX_DATA_END;
-
+
ED_armature_edit_sync_selection(arm->edbo);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -897,15 +897,15 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot)
ot->name = "Clear Parent";
ot->idname = "ARMATURE_OT_parent_clear";
ot->description = "Remove the parent-child relationship between selected bones and their parents";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = armature_parent_clear_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
ot->prop = RNA_def_enum(ot->srna, "type", prop_editarm_clear_parent_types, 0, "ClearType", "What way to clear parenting");
}
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index 65f845ce34c..95acc8ab6ba 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -149,10 +149,10 @@ void *get_bone_from_selectbuffer(
short i;
bool takeNext = false;
int minsel = 0xffffffff, minunsel = 0xffffffff;
-
+
for (i = 0; i < hits; i++) {
hitresult = buffer[3 + (i * 4)];
-
+
if (!(hitresult & BONESEL_NOSEL)) {
if (hitresult & BONESEL_ANY) { /* to avoid including objects in selection */
Base *base = NULL;
@@ -184,7 +184,7 @@ void *get_bone_from_selectbuffer(
data = ebone;
}
-
+
if (data) {
if (sel) {
if (do_nearest) {
@@ -225,7 +225,7 @@ void *get_bone_from_selectbuffer(
}
}
}
-
+
if (firstunSel) {
*r_base = firstunSel_base;
return firstunSel;
@@ -249,11 +249,11 @@ void *get_nearest_bone(
short hits;
ED_view3d_viewcontext_init(C, &vc);
-
+
// rect.xmin = ... mouseco!
rect.xmin = rect.xmax = xy[0];
rect.ymin = rect.ymax = xy[1];
-
+
hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST);
*r_base = NULL;
@@ -310,7 +310,7 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv
curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
}
-
+
if (curBone->flag & BONE_CONNECTED)
next = curBone->parent;
else
@@ -339,11 +339,11 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv
if (!curBone)
bone = NULL;
}
-
+
ED_armature_edit_sync_selection(arm->edbo);
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, base->object);
-
+
return OPERATOR_FINISHED;
}
@@ -358,15 +358,15 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot)
ot->name = "Select Connected";
ot->idname = "ARMATURE_OT_select_linked";
ot->description = "Select bones related to selected ones by parent/child relationships";
-
+
/* api callbacks */
/* leave 'exec' unset */
ot->invoke = armature_select_linked_invoke;
ot->poll = armature_select_linked_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first");
}
@@ -505,7 +505,7 @@ cache_end:
dep = 1;
else if ( (hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL) == 0)
dep = 1;
- else
+ else
dep = 2;
}
else {
@@ -638,10 +638,10 @@ bool ED_armature_edit_select_pick(bContext *C, const int mval[2], bool extend, b
ED_armature_edit_deselect_all_multi(objects, objects_len);
MEM_freeN(objects);
}
-
+
/* by definition the non-root connected bones have no root point drawn,
* so a root selection needs to be delivered to the parent tip */
-
+
if (selmask & BONE_SELECTED) {
if (nearBone->parent && (nearBone->flag & BONE_CONNECTED)) {
/* click in a chain */
@@ -706,9 +706,9 @@ bool ED_armature_edit_select_pick(bContext *C, const int mval[2], bool extend, b
else
nearBone->flag |= selmask;
}
-
+
ED_armature_edit_sync_selection(arm->edbo);
-
+
if (nearBone) {
/* then now check for active status */
if (ebone_select_flag(nearBone)) {
@@ -748,7 +748,7 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
}
-
+
/* Set the flags */
CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones)
{
@@ -783,7 +783,7 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -793,14 +793,14 @@ void ARMATURE_OT_select_all(wmOperatorType *ot)
ot->name = "(De)select All";
ot->idname = "ARMATURE_OT_select_all";
ot->description = "Toggle selection status of all bones";
-
+
/* api callbacks */
ot->exec = armature_de_select_all_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
WM_operator_properties_select_all(ot);
}
@@ -1228,7 +1228,7 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
int direction = RNA_enum_get(op->ptr, "direction");
const bool add_to_sel = RNA_boolean_get(op->ptr, "extend");
bool changed = false;
-
+
ob = obedit;
arm = (bArmature *)ob->data;
@@ -1286,15 +1286,15 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
changed = true;
}
}
-
+
if (changed == false) {
return OPERATOR_CANCELLED;
}
ED_armature_edit_sync_selection(arm->edbo);
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1305,16 +1305,16 @@ void ARMATURE_OT_select_hierarchy(wmOperatorType *ot)
{BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "Select Hierarchy";
ot->idname = "ARMATURE_OT_select_hierarchy";
ot->description = "Select immediate parent/children of selected bones";
-
+
/* api callbacks */
ot->exec = armature_select_hierarchy_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c
index 1722cbd5c5c..87a66514417 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -45,6 +45,7 @@
#include "BKE_armature.h"
#include "BKE_context.h"
#include "BKE_deform.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_object_deform.h"
#include "BKE_report.h"
#include "BKE_subsurf.h"
@@ -71,7 +72,7 @@ static int bone_skinnable_cb(Object *UNUSED(ob), Bone *bone, void *datap)
* This function performs 2 functions:
*
* a) It returns 1 if the bone is skinnable.
- * If we loop over all bones with this
+ * If we loop over all bones with this
* function, we can count the number of
* skinnable bones.
* b) If the pointer data is non null,
@@ -96,10 +97,10 @@ static int bone_skinnable_cb(Object *UNUSED(ob), Bone *bone, void *datap)
segments = bone->segments;
else
segments = 1;
-
+
if (data->list != NULL) {
hbone = (Bone ***) &data->list;
-
+
for (a = 0; a < segments; a++) {
**hbone = bone;
++*hbone;
@@ -111,10 +112,10 @@ static int bone_skinnable_cb(Object *UNUSED(ob), Bone *bone, void *datap)
return 0;
}
-static int vgroup_add_unique_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
+static int vgroup_add_unique_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
{
/* This group creates a vertex group to ob that has the
- * same name as bone (provided the bone is skinnable).
+ * same name as bone (provided the bone is skinnable).
* If such a vertex group already exist the routine exits.
*/
if (!(bone->flag & BONE_NO_DEFORM)) {
@@ -126,7 +127,7 @@ static int vgroup_add_unique_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
return 0;
}
-static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
+static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
{
/* Bones that are deforming
* are regarded to be "skinnable" and are eligible for
@@ -134,16 +135,16 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
*
* This function performs 2 functions:
*
- * a) If the bone is skinnable, it creates
+ * a) If the bone is skinnable, it creates
* a vertex group for ob that has
* the name of the skinnable bone
* (if one doesn't exist already).
* b) If the pointer data is non null,
* it is treated like a handle to a
- * bDeformGroup pointer -- the
+ * bDeformGroup pointer -- the
* bDeformGroup pointer is set to point
* to the deform group with the bone's
- * name, and the pointer the handle
+ * name, and the pointer the handle
* points to is incremented to point to the
* next member of an array of pointers
* to bDeformGroups. This way we can loop using
@@ -162,7 +163,7 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
segments = bone->segments;
else
segments = 1;
-
+
if (!data->is_weight_paint || ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED))) {
if (!(defgroup = defgroup_find_name(ob, bone->name))) {
defgroup = BKE_object_defgroup_add_name(ob, bone->name);
@@ -172,10 +173,10 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
defgroup = NULL;
}
}
-
+
if (data->list != NULL) {
hgroup = (bDeformGroup ***) &data->list;
-
+
for (a = 0; a < segments; a++) {
**hgroup = defgroup;
++*hgroup;
@@ -215,25 +216,25 @@ static void envelope_bone_weighting(
}
iflip = (dgroupflip) ? mesh_get_x_mirror_vert(ob, NULL, i, use_topology) : -1;
-
+
/* for each skinnable bone */
for (j = 0; j < numbones; ++j) {
if (!selected[j])
continue;
-
+
bone = bonelist[j];
dgroup = dgrouplist[j];
-
+
/* store the distance-factor from the vertex to the bone */
distance = distfactor_to_bone(verts[i], root[j], tip[j],
bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale);
-
+
/* add the vert to the deform group if (weight != 0.0) */
if (distance != 0.0f)
ED_vgroup_vert_add(ob, dgroup, i, distance, WEIGHT_REPLACE);
else
ED_vgroup_vert_remove(ob, dgroup, i);
-
+
/* do same for mirror */
if (dgroupflip && dgroupflip[j] && iflip != -1) {
if (distance != 0.0f)
@@ -282,10 +283,10 @@ static void add_verts_to_dgroups(
/* count the number of skinnable bones */
numbones = bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb);
-
+
if (numbones == 0)
return;
-
+
if (BKE_object_defgroup_data_create(ob->data) == NULL)
return;
@@ -313,13 +314,13 @@ static void add_verts_to_dgroups(
for (j = 0; j < numbones; ++j) {
bone = bonelist[j];
dgroup = dgrouplist[j];
-
+
/* handle bbone */
if (heat) {
if (segments == 0) {
segments = 1;
bbone = NULL;
-
+
if ((par->pose) && (pchan = BKE_pose_channel_find_name(par->pose, bone->name))) {
if (bone->segments > 1) {
segments = bone->segments;
@@ -328,10 +329,10 @@ static void add_verts_to_dgroups(
}
}
}
-
+
segments--;
}
-
+
/* compute root and tip */
if (bbone) {
mul_v3_m4v3(root[j], bone->arm_mat, bbone[segments].mat[3]);
@@ -346,10 +347,10 @@ static void add_verts_to_dgroups(
copy_v3_v3(root[j], bone->arm_head);
copy_v3_v3(tip[j], bone->arm_tail);
}
-
+
mul_m4_v3(par->obmat, root[j]);
mul_m4_v3(par->obmat, tip[j]);
-
+
/* set selected */
if (wpmode) {
if ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED))
@@ -357,7 +358,7 @@ static void add_verts_to_dgroups(
}
else
selected[j] = 1;
-
+
/* find flipped group */
if (dgroup && mirror) {
char name_flip[MAXBONENAME];
@@ -374,12 +375,12 @@ static void add_verts_to_dgroups(
if (wpmode) {
/* if in weight paint mode, use final verts from derivedmesh */
DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
-
+
if (dm->foreachMappedVert) {
mesh_get_mapped_verts_coords(dm, verts, mesh->totvert);
vertsfilled = 1;
}
-
+
dm->release(dm);
}
else if (modifiers_findByType(ob, eModifierType_Subsurf)) {
@@ -431,7 +432,7 @@ void ED_object_vgroup_calc_from_armature(
ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, Object *par,
const int mode, const bool mirror)
{
- /* Lets try to create some vertex groups
+ /* Lets try to create some vertex groups
* based on the bones of the parent armature.
*/
bArmature *arm = par->data;
@@ -439,7 +440,7 @@ void ED_object_vgroup_calc_from_armature(
if (mode == ARM_GROUPS_NAME) {
const int defbase_tot = BLI_listbase_count(&ob->defbase);
int defbase_add;
- /* Traverse the bone list, trying to create empty vertex
+ /* Traverse the bone list, trying to create empty vertex
* groups corresponding to the bone.
*/
defbase_add = bone_looper(ob, arm->bonebase.first, NULL, vgroup_add_unique_bone_cb);
@@ -451,7 +452,7 @@ void ED_object_vgroup_calc_from_armature(
}
}
else if (ELEM(mode, ARM_GROUPS_ENVELOPE, ARM_GROUPS_AUTO)) {
- /* Traverse the bone list, trying to create vertex groups
+ /* Traverse the bone list, trying to create vertex groups
* that are populated with the vertices for which the
* bone is closest.
*/
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index ffa8b9f5007..02d45a4e041 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -57,7 +57,7 @@
void ED_armature_edit_sync_selection(ListBase *edbo)
{
EditBone *ebo;
-
+
for (ebo = edbo->first; ebo; ebo = ebo->next) {
/* if bone is not selectable, we shouldn't alter this setting... */
if ((ebo->flag & BONE_UNSELECTABLE) == 0) {
@@ -67,7 +67,7 @@ void ED_armature_edit_sync_selection(ListBase *edbo)
else
ebo->flag &= ~BONE_ROOTSEL;
}
-
+
if ((ebo->flag & BONE_TIPSEL) && (ebo->flag & BONE_ROOTSEL))
ebo->flag |= BONE_SELECTED;
else
@@ -94,27 +94,27 @@ void ED_armature_edit_validate_active(struct bArmature *arm)
int bone_looper(Object *ob, Bone *bone, void *data,
int (*bone_func)(Object *, Bone *, void *))
{
- /* We want to apply the function bone_func to every bone
- * in an armature -- feed bone_looper the first bone and
- * a pointer to the bone_func and watch it go!. The int count
+ /* We want to apply the function bone_func to every bone
+ * in an armature -- feed bone_looper the first bone and
+ * a pointer to the bone_func and watch it go!. The int count
* can be useful for counting bones with a certain property
* (e.g. skinnable)
*/
int count = 0;
-
+
if (bone) {
/* only do bone_func if the bone is non null */
count += bone_func(ob, bone, data);
-
+
/* try to execute bone_func for the first child */
count += bone_looper(ob, bone->childbase.first, data, bone_func);
-
+
/* try to execute bone_func for the next bone at this
* depth of the recursion.
*/
count += bone_looper(ob, bone->next, data, bone_func);
}
-
+
return count;
}
@@ -273,13 +273,13 @@ EditBone *ED_armature_ebone_get_mirrored(const ListBase *edbo, EditBone *ebo)
if (ebo == NULL)
return NULL;
-
+
BLI_string_flip_side_name(name_flip, ebo->name, false, sizeof(name_flip));
-
+
if (!STREQ(name_flip, ebo->name)) {
return ED_armature_ebone_find_name(edbo, name_flip);
}
-
+
return NULL;
}
@@ -293,7 +293,7 @@ void armature_select_mirrored_ex(bArmature *arm, const int flag)
/* Select mirrored bones */
if (arm->flag & ARM_MIRROR_EDIT) {
EditBone *curBone, *ebone_mirr;
-
+
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
if (arm->layer & curBone->layer) {
if (curBone->flag & flag) {
@@ -304,7 +304,7 @@ void armature_select_mirrored_ex(bArmature *arm, const int flag)
}
}
}
-
+
}
void armature_select_mirrored(bArmature *arm)
@@ -333,7 +333,7 @@ void armature_tag_select_mirrored(bArmature *arm)
}
}
}
-
+
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
if (curBone->flag & BONE_DONE) {
EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone);
@@ -363,17 +363,17 @@ void ED_armature_edit_transform_mirror_update(Object *obedit)
{
bArmature *arm = obedit->data;
EditBone *ebo, *eboflip;
-
+
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
/* no layer check, correct mirror is more important */
if (ebo->flag & (BONE_TIPSEL | BONE_ROOTSEL)) {
eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebo);
-
+
if (eboflip) {
/* we assume X-axis flipping for now */
if (ebo->flag & BONE_TIPSEL) {
EditBone *children;
-
+
eboflip->tail[0] = -ebo->tail[0];
eboflip->tail[1] = ebo->tail[1];
eboflip->tail[2] = ebo->tail[2];
@@ -381,7 +381,7 @@ void ED_armature_edit_transform_mirror_update(Object *obedit)
eboflip->roll = -ebo->roll;
eboflip->curveOutX = -ebo->curveOutX;
eboflip->roll2 = -ebo->roll2;
-
+
/* Also move connected children, in case children's name aren't mirrored properly */
for (children = arm->edbo->first; children; children = children->next) {
if (children->parent == eboflip && children->flag & BONE_CONNECTED) {
@@ -398,7 +398,7 @@ void ED_armature_edit_transform_mirror_update(Object *obedit)
eboflip->roll = -ebo->roll;
eboflip->curveInX = -ebo->curveInX;
eboflip->roll1 = -ebo->roll1;
-
+
/* Also move connected parent, in case parent's name isn't mirrored properly */
if (eboflip->parent && eboflip->flag & BONE_CONNECTED) {
EditBone *parent = eboflip->parent;
@@ -411,7 +411,7 @@ void ED_armature_edit_transform_mirror_update(Object *obedit)
eboflip->roll = -ebo->roll;
eboflip->xwidth = ebo->xwidth;
eboflip->zwidth = ebo->zwidth;
-
+
eboflip->curveInX = -ebo->curveInX;
eboflip->curveOutX = -ebo->curveOutX;
eboflip->roll1 = -ebo->roll1;
@@ -432,17 +432,17 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
EditBone *eBoneAct = NULL;
EditBone *eBoneTest = NULL;
Bone *curBone;
-
+
for (curBone = bones->first; curBone; curBone = curBone->next) {
eBone = MEM_callocN(sizeof(EditBone), "make_editbone");
-
+
/* Copy relevant data from bone to eBone
* Keep selection logic in sync with ED_armature_edit_sync_selection.
*/
eBone->parent = parent;
BLI_strncpy(eBone->name, curBone->name, sizeof(eBone->name));
eBone->flag = curBone->flag;
-
+
/* fix selection flags */
if (eBone->flag & BONE_SELECTED) {
/* if the bone is selected the copy its root selection to the parents tip */
@@ -462,11 +462,11 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
eBone->flag &= ~BONE_ROOTSEL;
}
}
-
+
copy_v3_v3(eBone->head, curBone->arm_head);
copy_v3_v3(eBone->tail, curBone->arm_tail);
eBone->roll = curBone->arm_roll;
-
+
/* rest of stuff copy */
eBone->length = curBone->length;
eBone->dist = curBone->dist;
@@ -492,20 +492,20 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
if (curBone->prop)
eBone->prop = IDP_CopyProperty(curBone->prop);
-
+
BLI_addtail(edbo, eBone);
-
+
/* Add children if necessary */
if (curBone->childbase.first) {
eBoneTest = make_boneList(edbo, &curBone->childbase, eBone, actBone);
if (eBoneTest)
eBoneAct = eBoneTest;
}
-
+
if (curBone == actBone)
eBoneAct = eBone;
}
-
+
return eBoneAct;
}
@@ -585,23 +585,23 @@ static void armature_finalize_restpose(ListBase *bonelist, ListBase *editbonelis
}
/* put EditMode back in Object */
-void ED_armature_from_edit(bArmature *arm)
+void ED_armature_from_edit(Main *bmain, bArmature *arm)
{
EditBone *eBone, *neBone;
Bone *newBone;
Object *obt;
-
+
/* armature bones */
BKE_armature_bonelist_free(&arm->bonebase);
arm->act_bone = NULL;
-
+
/* remove zero sized bones, this gives unstable restposes */
for (eBone = arm->edbo->first; eBone; eBone = neBone) {
float len_sq = len_squared_v3v3(eBone->head, eBone->tail);
neBone = eBone->next;
if (len_sq <= SQUARE(0.000001f)) { /* FLT_EPSILON is too large? */
EditBone *fBone;
-
+
/* Find any bones that refer to this bone */
for (fBone = arm->edbo->first; fBone; fBone = fBone->next) {
if (fBone->parent == eBone)
@@ -612,19 +612,19 @@ void ED_armature_from_edit(bArmature *arm)
bone_free(arm, eBone);
}
}
-
+
/* Copy the bones from the editData into the armature */
for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
newBone = MEM_callocN(sizeof(Bone), "bone");
eBone->temp.bone = newBone; /* Associate the real Bones with the EditBones */
-
+
BLI_strncpy(newBone->name, eBone->name, sizeof(newBone->name));
copy_v3_v3(newBone->arm_head, eBone->head);
copy_v3_v3(newBone->arm_tail, eBone->tail);
newBone->arm_roll = eBone->roll;
-
+
newBone->flag = eBone->flag;
-
+
if (eBone == arm->act_edbone) {
/* don't change active selection, this messes up separate which uses
* editmode toggle and can separate active bone which is de-selected originally */
@@ -632,10 +632,10 @@ void ED_armature_from_edit(bArmature *arm)
arm->act_bone = newBone;
}
newBone->roll = 0.0f;
-
+
newBone->weight = eBone->weight;
newBone->dist = eBone->dist;
-
+
newBone->xwidth = eBone->xwidth;
newBone->zwidth = eBone->zwidth;
newBone->rad_head = eBone->rad_head;
@@ -659,7 +659,7 @@ void ED_armature_from_edit(bArmature *arm)
if (eBone->prop)
newBone->prop = IDP_CopyProperty(eBone->prop);
}
-
+
/* Fix parenting in a separate pass to ensure ebone->bone connections are valid at this point.
* Do not set bone->head/tail here anymore, using EditBone data for that is not OK since our later fiddling
* with parent's arm_mat (for roll conversion) may have some small but visible impact on locations (T46010). */
@@ -674,24 +674,24 @@ void ED_armature_from_edit(bArmature *arm)
BLI_addtail(&arm->bonebase, newBone);
}
}
-
+
/* Finalize definition of restpose data (roll, bone_mat, arm_mat, head/tail...). */
armature_finalize_restpose(&arm->bonebase, arm->edbo);
-
+
/* so all users of this armature should get rebuilt */
- for (obt = G.main->object.first; obt; obt = obt->id.next) {
+ for (obt = bmain->object.first; obt; obt = obt->id.next) {
if (obt->data == arm) {
BKE_pose_rebuild(obt, arm);
}
}
-
+
DEG_id_tag_update(&arm->id, 0);
}
void ED_armature_edit_free(struct bArmature *arm)
{
EditBone *eBone;
-
+
/* Clear the editbones list */
if (arm->edbo) {
if (arm->edbo->first) {
@@ -701,7 +701,7 @@ void ED_armature_edit_free(struct bArmature *arm)
MEM_freeN(eBone->prop);
}
}
-
+
BLI_freelistN(arm->edbo);
}
MEM_freeN(arm->edbo);
diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c
new file mode 100644
index 00000000000..b74b515b37f
--- /dev/null
+++ b/source/blender/editors/armature/editarmature_retarget.c
@@ -0,0 +1,2644 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Martin Poirier
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ * autoarmature.c: Interface for automagically manipulating armature (retarget, created, ...)
+ */
+
+/** \file blender/editors/armature/editarmature_retarget.c
+ * \ingroup edarmature
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "PIL_time.h"
+
+#include "DNA_armature_types.h"
+#include "DNA_constraint_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+
+#include "BKE_constraint.h"
+#include "BKE_armature.h"
+#include "BKE_context.h"
+#include "BKE_main.h"
+
+#include "ED_armature.h"
+#include "ED_undo.h"
+
+#include "BIF_retarget.h"
+
+#include "armature_intern.h"
+
+/************ RIG RETARGET DATA STRUCTURES ***************/
+
+typedef struct MemoNode {
+ float weight;
+ int next;
+} MemoNode;
+
+typedef struct RetargetParam {
+ RigGraph *rigg;
+ RigArc *iarc;
+ RigNode *inode_start;
+ bContext *context;
+} RetargetParam;
+
+typedef enum {
+ RETARGET_LENGTH,
+ RETARGET_AGGRESSIVE
+} RetargetMode;
+
+typedef enum {
+ METHOD_BRUTE_FORCE = 0,
+ METHOD_MEMOIZE = 1
+} RetargetMethod;
+
+typedef enum {
+ ARC_FREE = 0,
+ ARC_TAKEN = 1,
+ ARC_USED = 2
+} ArcUsageFlags;
+
+static RigGraph *GLOBAL_RIGG = NULL;
+
+/*******************************************************************************************************/
+
+void exec_retargetArctoArc(TaskPool * __restrict pool, void *taskdata, int threadid);
+
+static void RIG_calculateEdgeAngles(RigEdge *edge_first, RigEdge *edge_second);
+float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4]);
+
+/* two levels */
+#define SHAPE_LEVELS (SHAPE_RADIX * SHAPE_RADIX)
+
+/*********************************** EDITBONE UTILS ****************************************************/
+
+static int countEditBoneChildren(ListBase *list, EditBone *parent)
+{
+ EditBone *ebone;
+ int count = 0;
+
+ for (ebone = list->first; ebone; ebone = ebone->next) {
+ if (ebone->parent == parent) {
+ count++;
+ }
+ }
+
+ return count;
+}
+
+static EditBone *nextEditBoneChild(ListBase *list, EditBone *parent, int n)
+{
+ EditBone *ebone;
+
+ for (ebone = list->first; ebone; ebone = ebone->next) {
+ if (ebone->parent == parent) {
+ if (n == 0) {
+ return ebone;
+ }
+ n--;
+ }
+ }
+
+ return NULL;
+}
+
+static void getEditBoneRollUpAxis(EditBone *bone, float roll, float up_axis[3])
+{
+ float mat[3][3], nor[3];
+
+ sub_v3_v3v3(nor, bone->tail, bone->head);
+
+ vec_roll_to_mat3(nor, roll, mat);
+ copy_v3_v3(up_axis, mat[2]);
+}
+
+static float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float qrot[4], float qroll[4], float aligned_axis[3])
+{
+ float nor[3], new_up_axis[3], x_axis[3], z_axis[3];
+
+ copy_v3_v3(new_up_axis, old_up_axis);
+ mul_qt_v3(qrot, new_up_axis);
+
+ sub_v3_v3v3(nor, bone->tail, bone->head);
+
+ cross_v3_v3v3(x_axis, nor, aligned_axis);
+ cross_v3_v3v3(z_axis, x_axis, nor);
+
+ normalize_v3(new_up_axis);
+ normalize_v3(x_axis);
+ normalize_v3(z_axis);
+
+ if (dot_v3v3(new_up_axis, x_axis) < 0) {
+ negate_v3(x_axis);
+ }
+
+ if (dot_v3v3(new_up_axis, z_axis) < 0) {
+ negate_v3(z_axis);
+ }
+
+ if (angle_normalized_v3v3(x_axis, new_up_axis) < angle_normalized_v3v3(z_axis, new_up_axis)) {
+ rotation_between_vecs_to_quat(qroll, new_up_axis, x_axis); /* set roll rotation quat */
+ return ED_armature_ebone_roll_to_vector(bone, x_axis, false);
+ }
+ else {
+ rotation_between_vecs_to_quat(qroll, new_up_axis, z_axis); /* set roll rotation quat */
+ return ED_armature_ebone_roll_to_vector(bone, z_axis, false);
+ }
+}
+
+static float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4], float qroll[4], float up_axis[3])
+{
+ if (previous == NULL) {
+ /* default to up_axis if no previous */
+ return rollBoneByQuatAligned(edge->bone, edge->up_axis, qrot, qroll, up_axis);
+ }
+ else {
+ float new_up_axis[3];
+ float vec_first[3], vec_second[3], normal[3];
+
+ if (previous->bone) {
+ sub_v3_v3v3(vec_first, previous->bone->tail, previous->bone->head);
+ }
+ else if (previous->prev->bone) {
+ sub_v3_v3v3(vec_first, edge->bone->head, previous->prev->bone->tail);
+ }
+ else {
+ /* default to up_axis if first bone in the chain is an offset */
+ return rollBoneByQuatAligned(edge->bone, edge->up_axis, qrot, qroll, up_axis);
+ }
+
+ sub_v3_v3v3(vec_second, edge->bone->tail, edge->bone->head);
+
+ normalize_v3(vec_first);
+ normalize_v3(vec_second);
+
+ cross_v3_v3v3(normal, vec_first, vec_second);
+ normalize_v3(normal);
+
+ axis_angle_to_quat(qroll, vec_second, edge->up_angle);
+
+ mul_qt_v3(qroll, normal);
+
+ copy_v3_v3(new_up_axis, edge->up_axis);
+ mul_qt_v3(qrot, new_up_axis);
+
+ normalize_v3(new_up_axis);
+
+ /* real qroll between normal and up_axis */
+ rotation_between_vecs_to_quat(qroll, new_up_axis, normal);
+
+ return ED_armature_ebone_roll_to_vector(edge->bone, normal, false);
+ }
+}
+
+float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4])
+{
+ float new_up_axis[3];
+
+ copy_v3_v3(new_up_axis, old_up_axis);
+ mul_qt_v3(qrot, new_up_axis);
+
+ return ED_armature_ebone_roll_to_vector(bone, new_up_axis, false);
+}
+
+/************************************ DESTRUCTORS ******************************************************/
+
+static void RIG_freeRigArc(BArc *arc)
+{
+ BLI_freelistN(&((RigArc *)arc)->edges);
+}
+
+void RIG_freeRigGraph(BGraph *rg)
+{
+ RigGraph *rigg = (RigGraph *)rg;
+ BNode *node;
+ BArc *arc;
+
+ BLI_task_pool_free(rigg->task_pool);
+ BLI_task_scheduler_free(rigg->task_scheduler);
+
+ if (rigg->link_mesh) {
+ REEB_freeGraph(rigg->link_mesh);
+ }
+
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
+ RIG_freeRigArc(arc);
+ }
+ BLI_freelistN(&rg->arcs);
+
+ for (node = rg->nodes.first; node; node = node->next) {
+ BLI_freeNode(rg, (BNode *)node);
+ }
+ BLI_freelistN(&rg->nodes);
+
+ BLI_freelistN(&rigg->controls);
+
+ BLI_ghash_free(rigg->bones_map, NULL, NULL);
+ BLI_ghash_free(rigg->controls_map, NULL, NULL);
+
+ if (rigg->flag & RIG_FREE_BONELIST) {
+ BLI_freelistN(rigg->editbones);
+ MEM_freeN(rigg->editbones);
+ }
+
+ MEM_freeN(rg);
+}
+
+/************************************* ALLOCATORS ******************************************************/
+
+static RigGraph *newRigGraph(void)
+{
+ RigGraph *rg;
+ int totthread;
+
+ rg = MEM_callocN(sizeof(RigGraph), "rig graph");
+
+ rg->head = NULL;
+
+ rg->bones_map = BLI_ghash_str_new("newRigGraph bones gh");
+ rg->controls_map = BLI_ghash_str_new("newRigGraph cont gh");
+
+ rg->free_arc = RIG_freeRigArc;
+ rg->free_node = NULL;
+
+#ifdef USE_THREADS
+ totthread = TASK_SCHEDULER_AUTO_THREADS;
+#else
+ totthread = TASK_SCHEDULER_SINGLE_THREAD;
+#endif
+
+ rg->task_scheduler = BLI_task_scheduler_create(totthread);
+ rg->task_pool = BLI_task_pool_create(rg->task_scheduler, NULL);
+
+ return rg;
+}
+
+static RigArc *newRigArc(RigGraph *rg)
+{
+ RigArc *arc;
+
+ arc = MEM_callocN(sizeof(RigArc), "rig arc");
+ arc->count = 0;
+ BLI_addtail(&rg->arcs, arc);
+
+ return arc;
+}
+
+static RigControl *newRigControl(RigGraph *rg)
+{
+ RigControl *ctrl;
+
+ ctrl = MEM_callocN(sizeof(RigControl), "rig control");
+
+ BLI_addtail(&rg->controls, ctrl);
+
+ return ctrl;
+}
+
+static RigNode *newRigNodeHead(RigGraph *rg, RigArc *arc, float p[3])
+{
+ RigNode *node;
+ node = MEM_callocN(sizeof(RigNode), "rig node");
+ BLI_addtail(&rg->nodes, node);
+
+ copy_v3_v3(node->p, p);
+ node->degree = 1;
+ node->arcs = NULL;
+
+ arc->head = node;
+
+ return node;
+}
+
+static void addRigNodeHead(RigGraph *UNUSED(rg), RigArc *arc, RigNode *node)
+{
+ node->degree++;
+
+ arc->head = node;
+}
+
+static RigNode *newRigNode(RigGraph *rg, float p[3])
+{
+ RigNode *node;
+ node = MEM_callocN(sizeof(RigNode), "rig node");
+ BLI_addtail(&rg->nodes, node);
+
+ copy_v3_v3(node->p, p);
+ node->degree = 0;
+ node->arcs = NULL;
+
+ return node;
+}
+
+static RigNode *newRigNodeTail(RigGraph *rg, RigArc *arc, float p[3])
+{
+ RigNode *node = newRigNode(rg, p);
+
+ node->degree = 1;
+ arc->tail = node;
+
+ return node;
+}
+
+static void RIG_appendEdgeToArc(RigArc *arc, RigEdge *edge)
+{
+ BLI_addtail(&arc->edges, edge);
+
+ if (edge->prev == NULL) {
+ copy_v3_v3(edge->head, arc->head->p);
+ }
+ else {
+ RigEdge *last_edge = edge->prev;
+ copy_v3_v3(edge->head, last_edge->tail);
+ RIG_calculateEdgeAngles(last_edge, edge);
+ }
+
+ edge->length = len_v3v3(edge->head, edge->tail);
+
+ arc->length += edge->length;
+
+ arc->count += 1;
+}
+
+static void RIG_addEdgeToArc(RigArc *arc, float tail[3], EditBone *bone)
+{
+ RigEdge *edge;
+
+ edge = MEM_callocN(sizeof(RigEdge), "rig edge");
+
+ copy_v3_v3(edge->tail, tail);
+ edge->bone = bone;
+
+ if (bone) {
+ getEditBoneRollUpAxis(bone, bone->roll, edge->up_axis);
+ }
+
+ RIG_appendEdgeToArc(arc, edge);
+}
+/************************************** CLONING TEMPLATES **********************************************/
+
+static void renameTemplateBone(char *name, char *template_name, ListBase *editbones, char *side_string, char *num_string)
+{
+ int i, j;
+
+ for (i = 0, j = 0; i < (MAXBONENAME - 1) && j < (MAXBONENAME - 1) && template_name[i] != '\0'; i++) {
+ if (template_name[i] == '&') {
+ if (template_name[i + 1] == 'S' || template_name[i + 1] == 's') {
+ j += BLI_strncpy_rlen(name + j, side_string, MAXBONENAME);
+ i++;
+ }
+ else if (template_name[i + 1] == 'N' || template_name[i + 1] == 'n') {
+ j += BLI_strncpy_rlen(name + j, num_string, MAXBONENAME);
+ i++;
+ }
+ else {
+ name[j] = template_name[i];
+ j++;
+ }
+ }
+ else {
+ name[j] = template_name[i];
+ j++;
+ }
+ }
+
+ name[j] = '\0';
+
+ ED_armature_ebone_unique_name(editbones, name, NULL);
+}
+
+static RigControl *cloneControl(RigGraph *rg, RigGraph *src_rg, RigControl *src_ctrl, GHash *ptr_hash, char *side_string, char *num_string)
+{
+ RigControl *ctrl;
+ char name[MAXBONENAME];
+
+ ctrl = newRigControl(rg);
+
+ copy_v3_v3(ctrl->head, src_ctrl->head);
+ copy_v3_v3(ctrl->tail, src_ctrl->tail);
+ copy_v3_v3(ctrl->up_axis, src_ctrl->up_axis);
+ copy_v3_v3(ctrl->offset, src_ctrl->offset);
+
+ ctrl->tail_mode = src_ctrl->tail_mode;
+ ctrl->flag = src_ctrl->flag;
+
+ renameTemplateBone(name, src_ctrl->bone->name, rg->editbones, side_string, num_string);
+ ctrl->bone = duplicateEditBoneObjects(src_ctrl->bone, name, rg->editbones, src_rg->ob, rg->ob);
+ ctrl->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
+ BLI_ghash_insert(ptr_hash, src_ctrl->bone, ctrl->bone);
+
+ ctrl->link = src_ctrl->link;
+ ctrl->link_tail = src_ctrl->link_tail;
+
+ return ctrl;
+}
+
+static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash *ptr_hash, char *side_string, char *num_string)
+{
+ RigEdge *src_edge;
+ RigArc *arc;
+
+ arc = newRigArc(rg);
+
+ arc->head = BLI_ghash_lookup(ptr_hash, src_arc->head);
+ arc->tail = BLI_ghash_lookup(ptr_hash, src_arc->tail);
+
+ arc->head->degree++;
+ arc->tail->degree++;
+
+ arc->length = src_arc->length;
+
+ arc->count = src_arc->count;
+
+ for (src_edge = src_arc->edges.first; src_edge; src_edge = src_edge->next) {
+ RigEdge *edge;
+
+ edge = MEM_callocN(sizeof(RigEdge), "rig edge");
+
+ copy_v3_v3(edge->head, src_edge->head);
+ copy_v3_v3(edge->tail, src_edge->tail);
+ copy_v3_v3(edge->up_axis, src_edge->up_axis);
+
+ edge->length = src_edge->length;
+ edge->angle = src_edge->angle;
+ edge->up_angle = src_edge->up_angle;
+
+ if (src_edge->bone != NULL) {
+ char name[MAXBONENAME];
+ renameTemplateBone(name, src_edge->bone->name, rg->editbones, side_string, num_string);
+ edge->bone = duplicateEditBoneObjects(src_edge->bone, name, rg->editbones, src_rg->ob, rg->ob);
+ edge->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
+ BLI_ghash_insert(ptr_hash, src_edge->bone, edge->bone);
+ }
+
+ BLI_addtail(&arc->edges, edge);
+ }
+
+ return arc;
+}
+
+static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, char *side_string, char *num_string)
+{
+ GHash *ptr_hash;
+ RigNode *node;
+ RigArc *arc;
+ RigControl *ctrl;
+ RigGraph *rg;
+
+ ptr_hash = BLI_ghash_ptr_new("cloneRigGraph gh");
+
+ rg = newRigGraph();
+
+ rg->ob = ob;
+ rg->editbones = editbones;
+
+ preEditBoneDuplicate(rg->editbones); /* prime bones for duplication */
+ preEditBoneDuplicate(src->editbones); /* prime bones for duplication */
+
+ /* Clone nodes */
+ for (node = src->nodes.first; node; node = node->next) {
+ RigNode *cloned_node = newRigNode(rg, node->p);
+ BLI_ghash_insert(ptr_hash, node, cloned_node);
+ }
+
+ rg->head = BLI_ghash_lookup(ptr_hash, src->head);
+
+ /* Clone arcs */
+ for (arc = src->arcs.first; arc; arc = arc->next) {
+ cloneArc(rg, src, arc, ptr_hash, side_string, num_string);
+ }
+
+ /* Clone controls */
+ for (ctrl = src->controls.first; ctrl; ctrl = ctrl->next) {
+ cloneControl(rg, src, ctrl, ptr_hash, side_string, num_string);
+ }
+
+ /* Relink bones properly */
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
+ RigEdge *edge;
+
+ for (edge = arc->edges.first; edge; edge = edge->next) {
+ if (edge->bone != NULL) {
+ EditBone *bone;
+
+ updateDuplicateSubtargetObjects(edge->bone, src->editbones, src->ob, rg->ob);
+
+ if (edge->bone->parent) {
+ bone = BLI_ghash_lookup(ptr_hash, edge->bone->parent);
+
+ if (bone != NULL) {
+ edge->bone->parent = bone;
+ }
+ else {
+ /* disconnect since parent isn't cloned
+ * this will only happen when cloning from selected bones
+ * */
+ edge->bone->flag &= ~BONE_CONNECTED;
+ }
+ }
+ }
+ }
+ }
+
+ for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
+ EditBone *bone;
+
+ updateDuplicateSubtargetObjects(ctrl->bone, src->editbones, src->ob, rg->ob);
+
+ if (ctrl->bone->parent) {
+ bone = BLI_ghash_lookup(ptr_hash, ctrl->bone->parent);
+
+ if (bone != NULL) {
+ ctrl->bone->parent = bone;
+ }
+ else {
+ /* disconnect since parent isn't cloned
+ * this will only happen when cloning from selected bones
+ * */
+ ctrl->bone->flag &= ~BONE_CONNECTED;
+ }
+ }
+
+ ctrl->link = BLI_ghash_lookup(ptr_hash, ctrl->link);
+ ctrl->link_tail = BLI_ghash_lookup(ptr_hash, ctrl->link_tail);
+ }
+
+ BLI_ghash_free(ptr_hash, NULL, NULL);
+
+ return rg;
+}
+
+
+/*******************************************************************************************************/
+
+static void RIG_calculateEdgeAngles(RigEdge *edge_first, RigEdge *edge_second)
+{
+ float vec_first[3], vec_second[3];
+
+ sub_v3_v3v3(vec_first, edge_first->tail, edge_first->head);
+ sub_v3_v3v3(vec_second, edge_second->tail, edge_second->head);
+
+ normalize_v3(vec_first);
+ normalize_v3(vec_second);
+
+ edge_first->angle = angle_normalized_v3v3(vec_first, vec_second);
+
+ if (edge_second->bone != NULL) {
+ float normal[3];
+
+ cross_v3_v3v3(normal, vec_first, vec_second);
+ normalize_v3(normal);
+
+ edge_second->up_angle = angle_normalized_v3v3(normal, edge_second->up_axis);
+ }
+}
+
+/************************************ CONTROL BONES ****************************************************/
+
+static void RIG_addControlBone(RigGraph *rg, EditBone *bone)
+{
+ RigControl *ctrl = newRigControl(rg);
+ ctrl->bone = bone;
+ copy_v3_v3(ctrl->head, bone->head);
+ copy_v3_v3(ctrl->tail, bone->tail);
+ getEditBoneRollUpAxis(bone, bone->roll, ctrl->up_axis);
+ ctrl->tail_mode = TL_NONE;
+
+ BLI_ghash_insert(rg->controls_map, bone->name, ctrl);
+}
+
+static int RIG_parentControl(RigControl *ctrl, EditBone *link)
+{
+ if (link) {
+ float offset[3];
+ int flag = 0;
+
+ sub_v3_v3v3(offset, ctrl->bone->head, link->head);
+
+ /* if root matches, check for direction too */
+ if (dot_v3v3(offset, offset) < 0.0001f) {
+ float vbone[3], vparent[3];
+
+ flag |= RIG_CTRL_FIT_ROOT;
+
+ sub_v3_v3v3(vbone, ctrl->bone->tail, ctrl->bone->head);
+ sub_v3_v3v3(vparent, link->tail, link->head);
+
+ /* test for opposite direction */
+ if (dot_v3v3(vbone, vparent) > 0) {
+ float nor[3];
+ float len;
+
+ cross_v3_v3v3(nor, vbone, vparent);
+
+ len = dot_v3v3(nor, nor);
+ if (len < 0.0001f) {
+ flag |= RIG_CTRL_FIT_BONE;
+ }
+ }
+ }
+
+ /* Bail out if old one is automatically better */
+ if (flag < ctrl->flag) {
+ return 0;
+ }
+
+ /* if there's already a link
+ * overwrite only if new link is higher in the chain */
+ if (ctrl->link && flag == ctrl->flag) {
+ EditBone *bone = NULL;
+
+ for (bone = ctrl->link; bone; bone = bone->parent) {
+ /* if link is in the chain, break and use that one */
+ if (bone == link) {
+ break;
+ }
+ }
+
+ /* not in chain, don't update link */
+ if (bone == NULL) {
+ return 0;
+ }
+ }
+
+
+ ctrl->link = link;
+ ctrl->flag = flag;
+
+ copy_v3_v3(ctrl->offset, offset);
+
+ return 1;
+ }
+
+ return 0;
+}
+
+static void RIG_reconnectControlBones(RigGraph *rg)
+{
+ RigControl *ctrl;
+ bool changed = true;
+
+ /* first pass, link to deform bones */
+ for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
+ bPoseChannel *pchan;
+ bConstraint *con;
+ int found = 0;
+
+ /* DO SOME MAGIC HERE */
+ for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ for (con = pchan->constraints.first; con; con = con->next) {
+ const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
+ ListBase targets = {NULL, NULL};
+ bConstraintTarget *ct;
+
+ /* constraint targets */
+ if (cti && cti->get_constraint_targets) {
+ int target_index;
+
+ cti->get_constraint_targets(con, &targets);
+
+ for (target_index = 0, ct = targets.first; ct; target_index++, ct = ct->next) {
+ if ((ct->tar == rg->ob) && STREQ(ct->subtarget, ctrl->bone->name)) {
+ /* SET bone link to bone corresponding to pchan */
+ EditBone *link = BLI_ghash_lookup(rg->bones_map, pchan->name);
+
+ /* Making sure bone is in this armature */
+ if (link != NULL) {
+ /* for pole targets, link to parent bone instead, if possible */
+ if (con->type == CONSTRAINT_TYPE_KINEMATIC && target_index == 1) {
+ if (link->parent && BLI_ghash_haskey(rg->bones_map, link->parent->name)) {
+ link = link->parent;
+ }
+ }
+
+ found = RIG_parentControl(ctrl, link);
+ }
+ }
+ }
+
+ if (cti->flush_constraint_targets)
+ cti->flush_constraint_targets(con, &targets, 0);
+ }
+ }
+ }
+
+ /* if not found yet, check parent */
+ if (found == 0) {
+ if (ctrl->bone->parent) {
+ /* make sure parent is a deforming bone
+ * NULL if not
+ * */
+ EditBone *link = BLI_ghash_lookup(rg->bones_map, ctrl->bone->parent->name);
+
+ found = RIG_parentControl(ctrl, link);
+ }
+
+ /* check if bone is not superposed on another one */
+ {
+ RigArc *arc;
+ RigArc *best_arc = NULL;
+ EditBone *link = NULL;
+
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
+ RigEdge *edge;
+ for (edge = arc->edges.first; edge; edge = edge->next) {
+ if (edge->bone) {
+ int fit = 0;
+
+ fit = len_v3v3(ctrl->bone->head, edge->bone->head) < 0.0001f;
+ fit = fit || len_v3v3(ctrl->bone->tail, edge->bone->tail) < 0.0001f;
+
+ if (fit) {
+ /* pick the bone on the arc with the lowest symmetry level
+ * means you connect control to the trunk of the skeleton */
+ if (best_arc == NULL || arc->symmetry_level < best_arc->symmetry_level) {
+ best_arc = arc;
+ link = edge->bone;
+ }
+ }
+ }
+ }
+ }
+
+ found = RIG_parentControl(ctrl, link);
+ }
+ }
+
+ /* if not found yet, check child */
+ if (found == 0) {
+ RigArc *arc;
+ RigArc *best_arc = NULL;
+ EditBone *link = NULL;
+
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
+ RigEdge *edge;
+ for (edge = arc->edges.first; edge; edge = edge->next) {
+ if (edge->bone && edge->bone->parent == ctrl->bone) {
+ /* pick the bone on the arc with the lowest symmetry level
+ * means you connect control to the trunk of the skeleton */
+ if (best_arc == NULL || arc->symmetry_level < best_arc->symmetry_level) {
+ best_arc = arc;
+ link = edge->bone;
+ }
+ }
+ }
+ }
+
+ found = RIG_parentControl(ctrl, link);
+ }
+
+ }
+
+
+ /* second pass, make chains in control bones */
+ while (changed) {
+ changed = false;
+
+ for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
+ /* if control is not linked yet */
+ if (ctrl->link == NULL) {
+ bPoseChannel *pchan;
+ bConstraint *con;
+ RigControl *ctrl_parent = NULL;
+ RigControl *ctrl_child;
+ int found = 0;
+
+ if (ctrl->bone->parent) {
+ ctrl_parent = BLI_ghash_lookup(rg->controls_map, ctrl->bone->parent->name);
+ }
+
+ /* check constraints first */
+
+ /* DO SOME MAGIC HERE */
+ for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ for (con = pchan->constraints.first; con; con = con->next) {
+ const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
+ ListBase targets = {NULL, NULL};
+ bConstraintTarget *ct;
+
+ /* constraint targets */
+ if (cti && cti->get_constraint_targets) {
+ cti->get_constraint_targets(con, &targets);
+
+ for (ct = targets.first; ct; ct = ct->next) {
+ if ((ct->tar == rg->ob) && STREQ(ct->subtarget, ctrl->bone->name)) {
+ /* SET bone link to ctrl corresponding to pchan */
+ RigControl *link = BLI_ghash_lookup(rg->controls_map, pchan->name);
+
+ /* if owner is a control bone, link with it */
+ if (link && link->link) {
+ RIG_parentControl(ctrl, link->bone);
+ found = 1;
+ break;
+ }
+ }
+ }
+
+ if (cti->flush_constraint_targets)
+ cti->flush_constraint_targets(con, &targets, 0);
+ }
+ }
+ }
+
+ if (found == 0) {
+ /* check if parent is already linked */
+ if (ctrl_parent && ctrl_parent->link) {
+ RIG_parentControl(ctrl, ctrl_parent->bone);
+ changed = true;
+ }
+ else {
+ /* check childs */
+ for (ctrl_child = rg->controls.first; ctrl_child; ctrl_child = ctrl_child->next) {
+ /* if a child is linked, link to that one */
+ if (ctrl_child->link && ctrl_child->bone->parent == ctrl->bone) {
+ RIG_parentControl(ctrl, ctrl_child->bone);
+ changed = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* third pass, link control tails */
+ for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
+ /* fit bone already means full match, so skip those */
+ if ((ctrl->flag & RIG_CTRL_FIT_BONE) == 0) {
+ GHashIterator ghi;
+
+ /* look on deform bones first */
+ BLI_ghashIterator_init(&ghi, rg->bones_map);
+
+ for (; !BLI_ghashIterator_done(&ghi); BLI_ghashIterator_step(&ghi)) {
+ EditBone *bone = (EditBone *)BLI_ghashIterator_getValue(&ghi);
+
+ /* don't link with parent */
+ if (bone->parent != ctrl->bone) {
+ if (len_v3v3(ctrl->bone->tail, bone->head) < 0.01f) {
+ ctrl->tail_mode = TL_HEAD;
+ ctrl->link_tail = bone;
+ break;
+ }
+ else if (len_v3v3(ctrl->bone->tail, bone->tail) < 0.01f) {
+ ctrl->tail_mode = TL_TAIL;
+ ctrl->link_tail = bone;
+ break;
+ }
+ }
+ }
+
+ /* if we haven't found one yet, look in control bones */
+ if (ctrl->tail_mode == TL_NONE) {
+ /* pass */
+ }
+ }
+ }
+
+}
+
+/*******************************************************************************************************/
+
+static void RIG_joinArcs(RigGraph *rg, RigNode *node, RigArc *joined_arc1, RigArc *joined_arc2)
+{
+ RigEdge *edge, *next_edge;
+
+ /* ignore cases where joint is at start or end */
+ if (joined_arc1->head == joined_arc2->head || joined_arc1->tail == joined_arc2->tail) {
+ return;
+ }
+
+ /* swap arcs to make sure arc1 is before arc2 */
+ if (joined_arc1->head == joined_arc2->tail) {
+ RigArc *tmp = joined_arc1;
+ joined_arc1 = joined_arc2;
+ joined_arc2 = tmp;
+ }
+
+ for (edge = joined_arc2->edges.first; edge; edge = next_edge) {
+ next_edge = edge->next;
+
+ RIG_appendEdgeToArc(joined_arc1, edge);
+ }
+
+ joined_arc1->tail = joined_arc2->tail;
+
+ BLI_listbase_clear(&joined_arc2->edges);
+
+ BLI_removeArc((BGraph *)rg, (BArc *)joined_arc2);
+
+ BLI_removeNode((BGraph *)rg, (BNode *)node);
+}
+
+static void RIG_removeNormalNodes(RigGraph *rg)
+{
+ RigNode *node, *next_node;
+
+ for (node = rg->nodes.first; node; node = next_node) {
+ next_node = node->next;
+
+ if (node->degree == 2) {
+ RigArc *arc, *joined_arc1 = NULL, *joined_arc2 = NULL;
+
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
+ if (arc->head == node || arc->tail == node) {
+ if (joined_arc1 == NULL) {
+ joined_arc1 = arc;
+ }
+ else {
+ joined_arc2 = arc;
+ break;
+ }
+ }
+ }
+
+ RIG_joinArcs(rg, node, joined_arc1, joined_arc2);
+ }
+ }
+}
+
+static void RIG_removeUneededOffsets(RigGraph *rg)
+{
+ RigArc *arc;
+
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
+ RigEdge *first_edge, *last_edge;
+
+ first_edge = arc->edges.first;
+ last_edge = arc->edges.last;
+
+ if (first_edge->bone == NULL) {
+ if (first_edge->bone == NULL && len_v3v3(first_edge->tail, arc->head->p) <= 0.001f) {
+ BLI_remlink(&arc->edges, first_edge);
+ MEM_freeN(first_edge);
+ }
+ else if (arc->head->degree == 1) {
+ RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001f);
+
+ if (new_node) {
+ BLI_remlink(&arc->edges, first_edge);
+ MEM_freeN(first_edge);
+ BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->head);
+ }
+ else {
+ RigEdge *next_edge = first_edge->next;
+
+ if (next_edge) {
+ BLI_remlink(&arc->edges, first_edge);
+ MEM_freeN(first_edge);
+
+ copy_v3_v3(arc->head->p, next_edge->head);
+ }
+ }
+ }
+ else {
+ /* check if all arc connected start with a null edge */
+ RigArc *other_arc;
+ for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) {
+ if (other_arc != arc) {
+ RigEdge *test_edge;
+ if (other_arc->head == arc->head) {
+ test_edge = other_arc->edges.first;
+
+ if (test_edge->bone != NULL) {
+ break;
+ }
+ }
+ else if (other_arc->tail == arc->head) {
+ test_edge = other_arc->edges.last;
+
+ if (test_edge->bone != NULL) {
+ break;
+ }
+ }
+ }
+ }
+
+ if (other_arc == NULL) {
+ RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001);
+
+ if (new_node) {
+ /* remove null edge in other arcs too */
+ for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) {
+ if (other_arc != arc) {
+ RigEdge *test_edge;
+ if (other_arc->head == arc->head) {
+ BLI_replaceNodeInArc((BGraph *)rg, (BArc *)other_arc, (BNode *)new_node, (BNode *)other_arc->head);
+ test_edge = other_arc->edges.first;
+ BLI_remlink(&other_arc->edges, test_edge);
+ MEM_freeN(test_edge);
+ }
+ else if (other_arc->tail == arc->head) {
+ BLI_replaceNodeInArc((BGraph *)rg, (BArc *)other_arc, (BNode *)new_node, (BNode *)other_arc->tail);
+ test_edge = other_arc->edges.last;
+ BLI_remlink(&other_arc->edges, test_edge);
+ MEM_freeN(test_edge);
+ }
+ }
+ }
+
+ BLI_remlink(&arc->edges, first_edge);
+ MEM_freeN(first_edge);
+ BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->head);
+ }
+ else {
+ RigEdge *next_edge = first_edge->next;
+
+ if (next_edge) {
+ BLI_remlink(&arc->edges, first_edge);
+ MEM_freeN(first_edge);
+
+ copy_v3_v3(arc->head->p, next_edge->head);
+
+ /* remove null edge in other arcs too */
+ for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) {
+ if (other_arc != arc) {
+ RigEdge *test_edge;
+ if (other_arc->head == arc->head) {
+ test_edge = other_arc->edges.first;
+ BLI_remlink(&other_arc->edges, test_edge);
+ MEM_freeN(test_edge);
+ }
+ else if (other_arc->tail == arc->head) {
+ test_edge = other_arc->edges.last;
+ BLI_remlink(&other_arc->edges, test_edge);
+ MEM_freeN(test_edge);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (last_edge->bone == NULL) {
+ if (len_v3v3(last_edge->head, arc->tail->p) <= 0.001f) {
+ BLI_remlink(&arc->edges, last_edge);
+ MEM_freeN(last_edge);
+ }
+ else if (arc->tail->degree == 1) {
+ RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, last_edge->head, 0.001f);
+
+ if (new_node) {
+ RigEdge *previous_edge = last_edge->prev;
+
+ BLI_remlink(&arc->edges, last_edge);
+ MEM_freeN(last_edge);
+ BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->tail);
+
+ /* set previous angle to 0, since there's no following edges */
+ if (previous_edge) {
+ previous_edge->angle = 0;
+ }
+ }
+ else {
+ RigEdge *previous_edge = last_edge->prev;
+
+ if (previous_edge) {
+ BLI_remlink(&arc->edges, last_edge);
+ MEM_freeN(last_edge);
+
+ copy_v3_v3(arc->tail->p, previous_edge->tail);
+ previous_edge->angle = 0;
+ }
+ }
+ }
+ }
+ }
+}
+
+static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bone, RigNode *starting_node, bool selected)
+{
+ EditBone *bone, *last_bone = root_bone;
+ RigArc *arc = NULL;
+ int contain_head = 0;
+
+ for (bone = root_bone; bone; bone = nextEditBoneChild(list, bone, 0)) {
+ int nb_children;
+
+ if (selected == 0 || (bone->flag & BONE_SELECTED)) {
+ if ((bone->flag & BONE_NO_DEFORM) == 0) {
+ BLI_ghash_insert(rg->bones_map, bone->name, bone);
+
+ if (arc == NULL) {
+ arc = newRigArc(rg);
+
+ if (starting_node == NULL) {
+ starting_node = newRigNodeHead(rg, arc, root_bone->head);
+ }
+ else {
+ addRigNodeHead(rg, arc, starting_node);
+ }
+ }
+
+ if (bone->parent && (bone->flag & BONE_CONNECTED) == 0) {
+ RIG_addEdgeToArc(arc, bone->head, NULL);
+ }
+
+ RIG_addEdgeToArc(arc, bone->tail, bone);
+
+ last_bone = bone;
+
+ if (STREQ(bone->name, "head")) {
+ contain_head = 1;
+ }
+ }
+ else if ((bone->flag & BONE_EDITMODE_LOCKED) == 0) { /* ignore locked bones */
+ RIG_addControlBone(rg, bone);
+ }
+ }
+
+ nb_children = countEditBoneChildren(list, bone);
+ if (nb_children > 1) {
+ RigNode *end_node = NULL;
+ int i;
+
+ if (arc != NULL) {
+ end_node = newRigNodeTail(rg, arc, bone->tail);
+ }
+ else {
+ end_node = newRigNode(rg, bone->tail);
+ }
+
+ for (i = 0; i < nb_children; i++) {
+ root_bone = nextEditBoneChild(list, bone, i);
+ RIG_arcFromBoneChain(rg, list, root_bone, end_node, selected);
+ }
+
+ /* arc ends here, break */
+ break;
+ }
+ }
+
+ /* If the loop exited without forking */
+ if (arc != NULL && bone == NULL) {
+ newRigNodeTail(rg, arc, last_bone->tail);
+ }
+
+ if (contain_head) {
+ rg->head = arc->tail;
+ }
+}
+
+/*******************************************************************************************************/
+static void RIG_findHead(RigGraph *rg)
+{
+ if (rg->head == NULL) {
+ if (BLI_listbase_is_single(&rg->arcs)) {
+ RigArc *arc = rg->arcs.first;
+
+ rg->head = (RigNode *)arc->head;
+ }
+ else {
+ RigArc *arc;
+
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
+ RigEdge *edge = arc->edges.last;
+
+ if (edge->bone->flag & (BONE_TIPSEL | BONE_SELECTED)) {
+ rg->head = arc->tail;
+ break;
+ }
+ }
+ }
+
+ if (rg->head == NULL) {
+ rg->head = rg->nodes.first;
+ }
+ }
+}
+
+/*******************************************************************************************************/
+
+static void RIG_printNode(RigNode *node, const char name[])
+{
+ printf("%s %p %i <%0.3f, %0.3f, %0.3f>\n", name, (void *)node, node->degree, node->p[0], node->p[1], node->p[2]);
+
+ if (node->symmetry_flag & SYM_TOPOLOGICAL) {
+ if (node->symmetry_flag & SYM_AXIAL)
+ printf("Symmetry AXIAL\n");
+ else if (node->symmetry_flag & SYM_RADIAL)
+ printf("Symmetry RADIAL\n");
+
+ print_v3("symmetry axis", node->symmetry_axis);
+ }
+}
+
+void RIG_printArcBones(RigArc *arc)
+{
+ RigEdge *edge;
+
+ for (edge = arc->edges.first; edge; edge = edge->next) {
+ if (edge->bone)
+ printf("%s ", edge->bone->name);
+ else
+ printf("---- ");
+ }
+ printf("\n");
+}
+
+static void RIG_printCtrl(RigControl *ctrl, char *indent)
+{
+ char text[128];
+
+ printf("%sBone: %s\n", indent, ctrl->bone->name);
+ printf("%sLink: %s\n", indent, ctrl->link ? ctrl->link->name : "!NONE!");
+
+ BLI_snprintf(text, sizeof(text), "%soffset", indent);
+ print_v3(text, ctrl->offset);
+
+ printf("%sFlag: %i\n", indent, ctrl->flag);
+}
+
+static void RIG_printLinkedCtrl(RigGraph *rg, EditBone *bone, int tabs)
+{
+ RigControl *ctrl;
+ char indent[64];
+ char *s = indent;
+ int i;
+
+ for (i = 0; i < tabs; i++) {
+ s[0] = '\t';
+ s++;
+ }
+ s[0] = 0;
+
+ for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
+ if (ctrl->link == bone) {
+ RIG_printCtrl(ctrl, indent);
+ RIG_printLinkedCtrl(rg, ctrl->bone, tabs + 1);
+ }
+ }
+}
+
+void RIG_printArc(RigGraph *rg, RigArc *arc)
+{
+ RigEdge *edge;
+
+ RIG_printNode((RigNode *)arc->head, "head");
+
+ for (edge = arc->edges.first; edge; edge = edge->next) {
+ printf("\tinner joints %0.3f %0.3f %0.3f\n", edge->tail[0], edge->tail[1], edge->tail[2]);
+ printf("\t\tlength %f\n", edge->length);
+ printf("\t\tangle %f\n", edge->angle * (float)(180 / M_PI));
+ if (edge->bone) {
+ printf("\t\t%s\n", edge->bone->name);
+ RIG_printLinkedCtrl(rg, edge->bone, 3);
+ }
+ }
+ printf("symmetry level: %i flag: %i group %i\n", arc->symmetry_level, arc->symmetry_flag, arc->symmetry_group);
+
+ RIG_printNode((RigNode *)arc->tail, "tail");
+}
+
+void RIG_printGraph(RigGraph *rg)
+{
+ RigArc *arc;
+
+ printf("---- ARCS ----\n");
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
+ RIG_printArc(rg, arc);
+ printf("\n");
+ }
+
+ if (rg->head) {
+ RIG_printNode(rg->head, "HEAD NODE:");
+ }
+ else {
+ printf("HEAD NODE: NONE\n");
+ }
+}
+
+/*******************************************************************************************************/
+
+RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ Scene *scene = CTX_data_scene(C);
+ EditBone *ebone;
+ RigGraph *rg;
+
+ rg = newRigGraph();
+
+ if (obedit == ob) {
+ rg->editbones = ((bArmature *)obedit->data)->edbo;
+ }
+ else {
+ rg->editbones = MEM_callocN(sizeof(ListBase), "EditBones");
+ make_boneList(rg->editbones, &arm->bonebase, NULL, NULL);
+ rg->flag |= RIG_FREE_BONELIST;
+ }
+
+ rg->ob = ob;
+
+ /* Do the rotations */
+ for (ebone = rg->editbones->first; ebone; ebone = ebone->next) {
+ if (ebone->parent == NULL) {
+ RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 0);
+ }
+ }
+
+ BLI_removeDoubleNodes((BGraph *)rg, 0.001);
+
+ RIG_removeNormalNodes(rg);
+
+ RIG_removeUneededOffsets(rg);
+
+ BLI_buildAdjacencyList((BGraph *)rg);
+
+ RIG_findHead(rg);
+
+ BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit);
+
+ RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */
+
+ if (BLI_isGraphCyclic((BGraph *)rg)) {
+ printf("armature cyclic\n");
+ }
+
+ return rg;
+}
+
+static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ Scene *scene = CTX_data_scene(C);
+ EditBone *ebone;
+ RigGraph *rg;
+
+ rg = newRigGraph();
+
+ if (obedit == ob) {
+ rg->editbones = arm->edbo;
+ }
+ else {
+ rg->editbones = MEM_callocN(sizeof(ListBase), "EditBones");
+ make_boneList(rg->editbones, &arm->bonebase, NULL, NULL);
+ rg->flag |= RIG_FREE_BONELIST;
+ }
+
+ rg->ob = ob;
+
+ /* Do the rotations */
+ for (ebone = rg->editbones->first; ebone; ebone = ebone->next) {
+ if (ebone->parent == NULL) {
+ RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 1);
+ }
+ }
+
+ BLI_removeDoubleNodes((BGraph *)rg, 0.001);
+
+ RIG_removeNormalNodes(rg);
+
+ RIG_removeUneededOffsets(rg);
+
+ BLI_buildAdjacencyList((BGraph *)rg);
+
+ RIG_findHead(rg);
+
+ BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit);
+
+ RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */
+
+ if (BLI_isGraphCyclic((BGraph *)rg)) {
+ printf("armature cyclic\n");
+ }
+
+ return rg;
+}
+/************************************ GENERATING *****************************************************/
+
+#if 0
+static EditBone *add_editbonetolist(char *name, ListBase *list)
+{
+ EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone");
+
+ BLI_strncpy(bone->name, name, sizeof(bone->name));
+ ED_armature_ebone_unique_name(list, bone->name, NULL);
+
+ BLI_addtail(list, bone);
+
+ bone->flag |= BONE_TIPSEL;
+ bone->weight = 1.0F;
+ bone->dist = 0.25F;
+ bone->xwidth = 0.1;
+ bone->zwidth = 0.1;
+ bone->rad_head = 0.10;
+ bone->rad_tail = 0.05;
+ bone->segments = 1;
+ bone->layer = 1; //arm->layer;
+
+ /* Bendy-Bone parameters */
+ bone->roll1 = 0.0f;
+ bone->roll2 = 0.0f;
+ bone->curveInX = 0.0f;
+ bone->curveInY = 0.0f;
+ bone->curveOutX = 0.0f;
+ bone->curveOutY = 0.0f;
+ bone->ease1 = 1.0f;
+ bone->ease2 = 1.0f;
+ bone->scaleIn = 1.0f;
+ bone->scaleOut = 1.0f;
+
+ return bone;
+}
+#endif
+
+#if 0 /* UNUSED */
+static void generateMissingArcsFromNode(RigGraph *rigg, ReebNode *node, int multi_level_limit)
+{
+ while (node->multi_level > multi_level_limit && node->link_up)
+ {
+ node = node->link_up;
+ }
+
+ while (node->multi_level < multi_level_limit && node->link_down)
+ {
+ node = node->link_down;
+ }
+
+ if (node->multi_level == multi_level_limit)
+ {
+ int i;
+
+ for (i = 0; i < node->degree; i++)
+ {
+ ReebArc *earc = node->arcs[i];
+
+ if (earc->flag == ARC_FREE && earc->head == node)
+ {
+ ReebNode *other = BIF_otherNodeFromIndex(earc, node);
+
+ earc->flag = ARC_USED;
+
+ //generateBonesForArc(rigg, earc, node, other);
+ generateMissingArcsFromNode(rigg, other, multi_level_limit);
+ }
+ }
+ }
+}
+
+static void generateMissingArcs(RigGraph *rigg)
+{
+ ReebGraph *reebg;
+ int multi_level_limit = 5;
+
+ for (reebg = rigg->link_mesh; reebg; reebg = reebg->link_up)
+ {
+ ReebArc *earc;
+
+ for (earc = reebg->arcs.first; earc; earc = earc->next)
+ {
+ if (earc->flag == ARC_USED)
+ {
+ generateMissingArcsFromNode(rigg, earc->head, multi_level_limit);
+ generateMissingArcsFromNode(rigg, earc->tail, multi_level_limit);
+ }
+ }
+ }
+}
+#endif
+
+/************************************ RETARGETTING *****************************************************/
+
+static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], float tail[3], float qrot[4], float resize);
+
+static void repositionTailControl(RigGraph *rigg, RigControl *ctrl);
+
+static void finalizeControl(RigGraph *rigg, RigControl *ctrl, float resize)
+{
+ if ((ctrl->flag & RIG_CTRL_DONE) == RIG_CTRL_DONE) {
+ RigControl *ctrl_child;
+
+#if 0
+ printf("CTRL: %s LINK: %s", ctrl->bone->name, ctrl->link->name);
+
+ if (ctrl->link_tail)
+ {
+ printf(" TAIL: %s", ctrl->link_tail->name);
+ }
+
+ printf("\n");
+#endif
+
+ /* if there was a tail link: apply link, recalc resize factor and qrot */
+ if (ctrl->tail_mode != TL_NONE) {
+ float *tail_vec = NULL;
+ float v1[3], v2[3], qtail[4];
+
+ if (ctrl->tail_mode == TL_TAIL) {
+ tail_vec = ctrl->link_tail->tail;
+ }
+ else if (ctrl->tail_mode == TL_HEAD) {
+ tail_vec = ctrl->link_tail->head;
+ }
+
+ sub_v3_v3v3(v1, ctrl->bone->tail, ctrl->bone->head);
+ sub_v3_v3v3(v2, tail_vec, ctrl->bone->head);
+
+ copy_v3_v3(ctrl->bone->tail, tail_vec);
+
+ rotation_between_vecs_to_quat(qtail, v1, v2);
+ mul_qt_qtqt(ctrl->qrot, qtail, ctrl->qrot);
+
+ resize = len_v3(v2) / len_v3v3(ctrl->head, ctrl->tail);
+ }
+
+ ctrl->bone->roll = rollBoneByQuat(ctrl->bone, ctrl->up_axis, ctrl->qrot);
+
+ /* Cascade to connected control bones */
+ for (ctrl_child = rigg->controls.first; ctrl_child; ctrl_child = ctrl_child->next) {
+ if (ctrl_child->link == ctrl->bone) {
+ repositionControl(rigg, ctrl_child, ctrl->bone->head, ctrl->bone->tail, ctrl->qrot, resize);
+ }
+ if (ctrl_child->link_tail == ctrl->bone) {
+ repositionTailControl(rigg, ctrl_child);
+ }
+ }
+ }
+}
+
+static void repositionTailControl(RigGraph *rigg, RigControl *ctrl)
+{
+ ctrl->flag |= RIG_CTRL_TAIL_DONE;
+
+ finalizeControl(rigg, ctrl, 1); /* resize will be recalculated anyway so we don't need it */
+}
+
+static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], float UNUSED(tail[3]), float qrot[4], float resize)
+{
+ float parent_offset[3], tail_offset[3];
+
+ copy_v3_v3(parent_offset, ctrl->offset);
+ mul_v3_fl(parent_offset, resize);
+ mul_qt_v3(qrot, parent_offset);
+
+ add_v3_v3v3(ctrl->bone->head, head, parent_offset);
+
+ ctrl->flag |= RIG_CTRL_HEAD_DONE;
+
+ copy_qt_qt(ctrl->qrot, qrot);
+
+ if (ctrl->tail_mode == TL_NONE) {
+ sub_v3_v3v3(tail_offset, ctrl->tail, ctrl->head);
+ mul_v3_fl(tail_offset, resize);
+ mul_qt_v3(qrot, tail_offset);
+
+ add_v3_v3v3(ctrl->bone->tail, ctrl->bone->head, tail_offset);
+
+ ctrl->flag |= RIG_CTRL_TAIL_DONE;
+ }
+
+ finalizeControl(rigg, ctrl, resize);
+}
+
+static void repositionBone(bContext *C, RigGraph *rigg, RigEdge *edge, float vec0[3], float vec1[3], float up_axis[3])
+{
+ Scene *scene = CTX_data_scene(C);
+ EditBone *bone;
+ RigControl *ctrl;
+ float qrot[4], resize;
+ float v1[3], v2[3];
+ float l1, l2;
+
+ bone = edge->bone;
+
+ sub_v3_v3v3(v1, edge->tail, edge->head);
+ sub_v3_v3v3(v2, vec1, vec0);
+
+ l1 = normalize_v3(v1);
+ l2 = normalize_v3(v2);
+
+ resize = l2 / l1;
+
+ rotation_between_vecs_to_quat(qrot, v1, v2);
+
+ copy_v3_v3(bone->head, vec0);
+ copy_v3_v3(bone->tail, vec1);
+
+ if (!is_zero_v3(up_axis)) {
+ float qroll[4];
+
+ if (scene->toolsettings->skgen_retarget_roll == SK_RETARGET_ROLL_VIEW) {
+ bone->roll = rollBoneByQuatAligned(bone, edge->up_axis, qrot, qroll, up_axis);
+ }
+ else if (scene->toolsettings->skgen_retarget_roll == SK_RETARGET_ROLL_JOINT) {
+ bone->roll = rollBoneByQuatJoint(edge, edge->prev, qrot, qroll, up_axis);
+ }
+ else {
+ unit_qt(qroll);
+ }
+
+ mul_qt_qtqt(qrot, qroll, qrot);
+ }
+ else {
+ bone->roll = rollBoneByQuat(bone, edge->up_axis, qrot);
+ }
+
+ for (ctrl = rigg->controls.first; ctrl; ctrl = ctrl->next) {
+ if (ctrl->link == bone) {
+ repositionControl(rigg, ctrl, vec0, vec1, qrot, resize);
+ }
+ if (ctrl->link_tail == bone) {
+ repositionTailControl(rigg, ctrl);
+ }
+ }
+}
+
+static RetargetMode detectArcRetargetMode(RigArc *arc);
+static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start);
+
+
+static RetargetMode detectArcRetargetMode(RigArc *iarc)
+{
+ RetargetMode mode = RETARGET_AGGRESSIVE;
+ ReebArc *earc = iarc->link_mesh;
+ RigEdge *edge;
+ int large_angle = 0;
+ float avg_angle = 0;
+ /* float avg_length = 0; */ /* UNUSED */
+ int nb_edges = 0;
+
+
+ for (edge = iarc->edges.first; edge; edge = edge->next) {
+ avg_angle += edge->angle;
+ nb_edges++;
+ }
+
+ avg_angle /= nb_edges - 1; /* -1 because last edge doesn't have an angle */
+
+ /* avg_length = iarc->length / nb_edges; */ /* UNUSED */
+
+
+ if (nb_edges > 2) {
+ for (edge = iarc->edges.first; edge; edge = edge->next) {
+ if (fabsf(edge->angle - avg_angle) > (float)(M_PI / 6)) {
+ large_angle = 1;
+ }
+ }
+ }
+ else if (nb_edges == 2 && avg_angle > 0) {
+ large_angle = 1;
+ }
+
+
+ if (large_angle == 0) {
+ mode = RETARGET_LENGTH;
+ }
+
+ if (earc->bcount <= (iarc->count - 1)) {
+ mode = RETARGET_LENGTH;
+ }
+
+ return mode;
+}
+
+#ifndef USE_THREADS
+static void printMovesNeeded(int *positions, int nb_positions)
+{
+ int moves = 0;
+ int i;
+
+ for (i = 0; i < nb_positions; i++) {
+ moves += positions[i] - (i + 1);
+ }
+
+ printf("%i moves needed\n", moves);
+}
+
+static void printPositions(int *positions, int nb_positions)
+{
+ int i;
+
+ for (i = 0; i < nb_positions; i++) {
+ printf("%i ", positions[i]);
+ }
+ printf("\n");
+}
+#endif
+
+#define MAX_COST FLT_MAX /* FIX ME */
+
+static float costDistance(BArcIterator *iter, float *vec0, float *vec1, int i0, int i1, float distance_weight)
+{
+ EmbedBucket *bucket = NULL;
+ float max_dist = 0;
+ float v1[3], v2[3], c[3];
+ float v1_inpf;
+
+ if (distance_weight > 0) {
+ sub_v3_v3v3(v1, vec0, vec1);
+
+ v1_inpf = dot_v3v3(v1, v1);
+
+ if (v1_inpf > 0) {
+ int j;
+ for (j = i0 + 1; j < i1 - 1; j++) {
+ float dist;
+
+ bucket = IT_peek(iter, j);
+
+ sub_v3_v3v3(v2, bucket->p, vec1);
+
+ cross_v3_v3v3(c, v1, v2);
+
+ dist = dot_v3v3(c, c) / v1_inpf;
+
+ max_dist = dist > max_dist ? dist : max_dist;
+ }
+
+ return distance_weight * max_dist;
+ }
+ else {
+ return MAX_COST;
+ }
+ }
+ else {
+ return 0;
+ }
+}
+
+static float costAngle(float original_angle, float vec_first[3], float vec_second[3], float angle_weight)
+{
+ if (angle_weight > 0) {
+ float current_angle;
+
+ if (!is_zero_v3(vec_first) && !is_zero_v3(vec_second)) {
+ current_angle = saacos(dot_v3v3(vec_first, vec_second));
+
+ return angle_weight * fabsf(current_angle - original_angle);
+ }
+ else {
+ return angle_weight * (float)M_PI;
+ }
+ }
+ else {
+ return 0;
+ }
+}
+
+static float costLength(float original_length, float current_length, float length_weight)
+{
+ if (current_length == 0) {
+ return MAX_COST;
+ }
+ else {
+ float length_ratio = fabsf((current_length - original_length) / original_length);
+ return length_weight * length_ratio * length_ratio;
+ }
+}
+
+#if 0
+static float calcCostLengthDistance(BArcIterator *iter, float **vec_cache, RigEdge *edge, float *vec1, float *vec2, int i1, int i2)
+{
+ float vec[3];
+ float length;
+
+ sub_v3_v3v3(vec, vec2, vec1);
+ length = normalize_v3(vec);
+
+ return costLength(edge->length, length) + costDistance(iter, vec1, vec2, i1, i2);
+}
+#endif
+
+static float calcCostAngleLengthDistance(BArcIterator *iter, float **UNUSED(vec_cache), RigEdge *edge,
+ float *vec0, float *vec1, float *vec2, int i1, int i2,
+ float angle_weight, float length_weight, float distance_weight)
+{
+ float vec_second[3], vec_first[3];
+ float length2;
+ float new_cost = 0;
+
+ sub_v3_v3v3(vec_second, vec2, vec1);
+ length2 = normalize_v3(vec_second);
+
+
+ /* Angle cost */
+ if (edge->prev) {
+ sub_v3_v3v3(vec_first, vec1, vec0);
+ normalize_v3(vec_first);
+
+ new_cost += costAngle(edge->prev->angle, vec_first, vec_second, angle_weight);
+ }
+
+ /* Length cost */
+ new_cost += costLength(edge->length, length2, length_weight);
+
+ /* Distance cost */
+ new_cost += costDistance(iter, vec1, vec2, i1, i2, distance_weight);
+
+ return new_cost;
+}
+
+static int indexMemoNode(int nb_positions, int previous, int current, int joints_left)
+{
+ return joints_left * nb_positions * nb_positions + current * nb_positions + previous;
+}
+
+static void copyMemoPositions(int *positions, MemoNode *table, int nb_positions, int joints_left)
+{
+ int previous = 0, current = 0;
+ int i = 0;
+
+ for (i = 0; joints_left > 0; joints_left--, i++) {
+ MemoNode *node;
+ node = table + indexMemoNode(nb_positions, previous, current, joints_left);
+
+ positions[i] = node->next;
+
+ previous = current;
+ current = node->next;
+ }
+}
+
+static MemoNode *solveJoints(MemoNode *table, BArcIterator *iter, float **vec_cache,
+ int nb_joints, int nb_positions, int previous, int current, RigEdge *edge,
+ int joints_left, float angle_weight, float length_weight, float distance_weight)
+{
+ MemoNode *node;
+ int index = indexMemoNode(nb_positions, previous, current, joints_left);
+
+ node = table + index;
+
+ if (node->weight != 0) {
+ return node;
+ }
+ else if (joints_left == 0) {
+ float *vec0 = vec_cache[previous];
+ float *vec1 = vec_cache[current];
+ float *vec2 = vec_cache[nb_positions + 1];
+
+ node->weight = calcCostAngleLengthDistance(iter, vec_cache, edge, vec0, vec1, vec2, current, iter->length, angle_weight, length_weight, distance_weight);
+
+ return node;
+ }
+ else {
+ MemoNode *min_node = NULL;
+ float *vec0 = vec_cache[previous];
+ float *vec1 = vec_cache[current];
+ float min_weight = 0.0f;
+ int min_next = 0;
+ int next;
+
+ for (next = current + 1; next <= nb_positions - (joints_left - 1); next++) {
+ MemoNode *next_node;
+ float *vec2 = vec_cache[next];
+ float weight = 0.0f;
+
+ /* ADD WEIGHT OF PREVIOUS - CURRENT - NEXT triple */
+ weight = calcCostAngleLengthDistance(iter, vec_cache, edge, vec0, vec1, vec2, current, next, angle_weight, length_weight, distance_weight);
+
+ if (weight >= MAX_COST) {
+ continue;
+ }
+
+ /* add node weight */
+ next_node = solveJoints(table, iter, vec_cache, nb_joints, nb_positions, current, next, edge->next, joints_left - 1, angle_weight, length_weight, distance_weight);
+ weight += next_node->weight;
+
+ if (min_node == NULL || weight < min_weight) {
+ min_weight = weight;
+ min_node = next_node;
+ min_next = next;
+ }
+ }
+
+ if (min_node) {
+ node->weight = min_weight;
+ node->next = min_next;
+ return node;
+ }
+ else {
+ node->weight = MAX_COST;
+ return node;
+ }
+ }
+
+}
+
+static int testFlipArc(RigArc *iarc, RigNode *inode_start)
+{
+ ReebArc *earc = iarc->link_mesh;
+ ReebNode *enode_start = BIF_NodeFromIndex(earc, inode_start->link_mesh);
+
+ /* no flip needed if both nodes are the same */
+ if ((enode_start == earc->head && inode_start == iarc->head) ||
+ (enode_start == earc->tail && inode_start == iarc->tail))
+ {
+ return 0;
+ }
+ else {
+ return 1;
+ }
+}
+
+static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start)
+{
+ ReebArcIterator arc_iter;
+ BArcIterator *iter = (BArcIterator *)&arc_iter;
+ RigEdge *edge;
+ ReebNode *node_start, *node_end;
+ ReebArc *earc = iarc->link_mesh;
+ float angle_weight = 1.0; // GET FROM CONTEXT
+ float length_weight = 1.0;
+ float distance_weight = 1.0;
+#ifndef USE_THREADS
+ float min_cost = FLT_MAX;
+#endif
+ float *vec0, *vec1;
+ int *best_positions;
+ int nb_edges = BLI_listbase_count(&iarc->edges);
+ int nb_joints = nb_edges - 1;
+ RetargetMethod method = METHOD_MEMOIZE;
+ int i;
+
+ if (nb_joints > earc->bcount) {
+ printf("NOT ENOUGH BUCKETS!\n");
+ return;
+ }
+
+ best_positions = MEM_callocN(sizeof(int) * nb_joints, "Best positions");
+
+ if (testFlipArc(iarc, inode_start)) {
+ node_start = earc->tail;
+ node_end = earc->head;
+ }
+ else {
+ node_start = earc->head;
+ node_end = earc->tail;
+ }
+
+ /* equal number of joints and potential position, just fill them in */
+ if (nb_joints == earc->bcount) {
+ /* init with first values */
+ for (i = 0; i < nb_joints; i++) {
+ best_positions[i] = i + 1;
+ }
+ }
+ if (method == METHOD_MEMOIZE) {
+ int nb_positions = earc->bcount;
+ int nb_memo_nodes = nb_positions * nb_positions * (nb_joints + 1);
+ MemoNode *table = MEM_callocN(nb_memo_nodes * sizeof(MemoNode), "memoization table");
+#ifndef USE_THREADS
+ MemoNode *result;
+#endif
+ float **positions_cache = MEM_callocN(sizeof(float *) * (nb_positions + 2), "positions cache");
+
+ positions_cache[0] = node_start->p;
+ positions_cache[nb_positions + 1] = node_end->p;
+
+ initArcIterator(iter, earc, node_start);
+
+ for (i = 1; i <= nb_positions; i++) {
+ EmbedBucket *bucket = IT_peek(iter, i);
+ positions_cache[i] = bucket->p;
+ }
+
+#ifndef USE_THREADS
+ result = solveJoints(table, iter, positions_cache, nb_joints, earc->bcount, 0, 0, iarc->edges.first, nb_joints, angle_weight, length_weight, distance_weight);
+ min_cost = result->weight;
+#else
+ solveJoints(table, iter, positions_cache, nb_joints, earc->bcount, 0, 0, iarc->edges.first, nb_joints, angle_weight, length_weight, distance_weight);
+#endif
+
+ copyMemoPositions(best_positions, table, earc->bcount, nb_joints);
+
+ MEM_freeN(table);
+ MEM_freeN(positions_cache);
+ }
+
+ vec0 = node_start->p;
+ initArcIterator(iter, earc, node_start);
+
+#ifndef USE_THREADS
+ printPositions(best_positions, nb_joints);
+ printMovesNeeded(best_positions, nb_joints);
+ printf("min_cost %f\n", min_cost);
+ printf("buckets: %i\n", earc->bcount);
+#endif
+
+ /* set joints to best position */
+ for (edge = iarc->edges.first, i = 0;
+ edge;
+ edge = edge->next, i++)
+ {
+ float *no = NULL;
+ if (i < nb_joints) {
+ EmbedBucket *bucket = IT_peek(iter, best_positions[i]);
+ vec1 = bucket->p;
+ no = bucket->no;
+ }
+ else {
+ vec1 = node_end->p;
+ no = node_end->no;
+ }
+
+ if (edge->bone) {
+ repositionBone(C, rigg, edge, vec0, vec1, no);
+ }
+
+ vec0 = vec1;
+ }
+
+ MEM_freeN(best_positions);
+}
+
+static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start)
+{
+ ReebArcIterator arc_iter;
+ BArcIterator *iter = (BArcIterator *)&arc_iter;
+ ReebArc *earc = iarc->link_mesh;
+ ReebNode *node_start, *node_end;
+ RigEdge *edge;
+ EmbedBucket *bucket = NULL;
+ float embedding_length = 0;
+ float *vec0 = NULL;
+ float *vec1 = NULL;
+ float *previous_vec = NULL;
+
+
+ if (testFlipArc(iarc, inode_start)) {
+ node_start = (ReebNode *)earc->tail;
+ node_end = (ReebNode *)earc->head;
+ }
+ else {
+ node_start = (ReebNode *)earc->head;
+ node_end = (ReebNode *)earc->tail;
+ }
+
+ initArcIterator(iter, earc, node_start);
+
+ bucket = IT_next(iter);
+
+ vec0 = node_start->p;
+
+ while (bucket != NULL) {
+ vec1 = bucket->p;
+
+ embedding_length += len_v3v3(vec0, vec1);
+
+ vec0 = vec1;
+ bucket = IT_next(iter);
+ }
+
+ embedding_length += len_v3v3(node_end->p, vec1);
+
+ /* fit bones */
+ initArcIterator(iter, earc, node_start);
+
+ bucket = IT_next(iter);
+
+ vec0 = node_start->p;
+ previous_vec = vec0;
+ vec1 = bucket->p;
+
+ for (edge = iarc->edges.first; edge; edge = edge->next) {
+ float new_bone_length = edge->length / iarc->length * embedding_length;
+ float *no = NULL;
+ float length = 0;
+
+ while (bucket && new_bone_length > length) {
+ length += len_v3v3(previous_vec, vec1);
+ bucket = IT_next(iter);
+ previous_vec = vec1;
+ vec1 = bucket->p;
+ no = bucket->no;
+ }
+
+ if (bucket == NULL) {
+ vec1 = node_end->p;
+ no = node_end->no;
+ }
+
+ /* no need to move virtual edges (space between unconnected bones) */
+ if (edge->bone) {
+ repositionBone(C, rigg, edge, vec0, vec1, no);
+ }
+
+ vec0 = vec1;
+ previous_vec = vec1;
+ }
+}
+
+static void retargetArctoArc(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start)
+{
+ RetargetParam *p = MEM_callocN(sizeof(RetargetParam), "RetargetParam");
+
+ p->rigg = rigg;
+ p->iarc = iarc;
+ p->inode_start = inode_start;
+ p->context = C;
+
+ BLI_task_pool_push(rigg->task_pool, exec_retargetArctoArc, p, true, TASK_PRIORITY_HIGH);
+}
+
+void exec_retargetArctoArc(TaskPool * __restrict UNUSED(pool), void *taskdata, int UNUSED(threadid))
+{
+ RetargetParam *p = (RetargetParam *)taskdata;
+ RigGraph *rigg = p->rigg;
+ RigArc *iarc = p->iarc;
+ bContext *C = p->context;
+ RigNode *inode_start = p->inode_start;
+ ReebArc *earc = iarc->link_mesh;
+
+ if (BLI_listbase_is_single(&iarc->edges)) {
+ RigEdge *edge = iarc->edges.first;
+
+ if (testFlipArc(iarc, inode_start)) {
+ repositionBone(C, rigg, edge, earc->tail->p, earc->head->p, earc->head->no);
+ }
+ else {
+ repositionBone(C, rigg, edge, earc->head->p, earc->tail->p, earc->tail->no);
+ }
+ }
+ else {
+ RetargetMode mode = detectArcRetargetMode(iarc);
+
+ if (mode == RETARGET_AGGRESSIVE) {
+ retargetArctoArcAggresive(C, rigg, iarc, inode_start);
+ }
+ else {
+ retargetArctoArcLength(C, rigg, iarc, inode_start);
+ }
+ }
+}
+
+static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *top_node)
+{
+ ReebNode *enode = top_node;
+ ReebGraph *reebg = BIF_graphForMultiNode(rigg->link_mesh, enode);
+ int ishape, eshape;
+
+ ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS;
+ eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
+
+ inode->link_mesh = enode;
+
+ while (ishape == eshape && enode->link_down) {
+ inode->link_mesh = enode;
+
+ enode = enode->link_down;
+ reebg = BIF_graphForMultiNode(rigg->link_mesh, enode); /* replace with call to link_down once that exists */
+ eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
+ }
+}
+
+static void markMultiResolutionChildArc(ReebNode *end_enode, ReebNode *enode)
+{
+ int i;
+
+ for (i = 0; i < enode->degree; i++) {
+ ReebArc *earc = (ReebArc *)enode->arcs[i];
+
+ if (earc->flag == ARC_FREE) {
+ earc->flag = ARC_TAKEN;
+
+ if (earc->tail->degree > 1 && earc->tail != end_enode) {
+ markMultiResolutionChildArc(end_enode, earc->tail);
+ }
+ break;
+ }
+ }
+}
+
+static void markMultiResolutionArc(ReebArc *start_earc)
+{
+ if (start_earc->link_up) {
+ ReebArc *earc;
+ for (earc = start_earc->link_up; earc; earc = earc->link_up) {
+ earc->flag = ARC_TAKEN;
+
+ if (earc->tail->index != start_earc->tail->index) {
+ markMultiResolutionChildArc(earc->tail, earc->tail);
+ }
+ }
+ }
+}
+
+static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc *next_iarc, ReebArc *next_earc)
+{
+ ReebNode *enode = next_earc->head;
+ ReebGraph *reebg = BIF_graphForMultiNode(rigg->link_mesh, enode);
+ int ishape, eshape;
+
+ ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)start_node, (BArc *)next_iarc, 1) % SHAPE_LEVELS;
+ eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS;
+
+ while (ishape != eshape && next_earc->link_up) {
+ next_earc->flag = ARC_TAKEN; // mark previous as taken, to prevent backtrack on lower levels
+
+ next_earc = next_earc->link_up;
+ reebg = reebg->link_up;
+ enode = next_earc->head;
+ eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS;
+ }
+
+ next_earc->flag = ARC_USED;
+ next_iarc->link_mesh = next_earc;
+
+ /* mark all higher levels as taken too */
+ markMultiResolutionArc(next_earc);
+// while (next_earc->link_up)
+// {
+// next_earc = next_earc->link_up;
+// next_earc->flag = ARC_TAKEN;
+// }
+}
+
+static void matchMultiResolutionStartingNode(RigGraph *rigg, ReebGraph *reebg, RigNode *inode)
+{
+ ReebNode *enode;
+ int ishape, eshape;
+
+ enode = reebg->nodes.first;
+
+ ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS;
+ eshape = BLI_subtreeShape((BGraph *)rigg->link_mesh, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
+
+ while (ishape != eshape && reebg->link_up) {
+ reebg = reebg->link_up;
+
+ enode = reebg->nodes.first;
+
+ eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
+ }
+
+ inode->link_mesh = enode;
+}
+
+static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *start_node, RigArc *next_iarc, int root)
+{
+ ReebNode *enode = start_node->link_mesh;
+ ReebArc *next_earc;
+ int symmetry_level = next_iarc->symmetry_level;
+ int symmetry_group = next_iarc->symmetry_group;
+ int symmetry_flag = next_iarc->symmetry_flag;
+ int i;
+
+ next_iarc->link_mesh = NULL;
+
+// if (root)
+// {
+// printf("-----------------------\n");
+// printf("MATCHING LIMB\n");
+// RIG_printArcBones(next_iarc);
+// }
+
+ for (i = 0; i < enode->degree; i++) {
+ next_earc = (ReebArc *)enode->arcs[i];
+
+// if (next_earc->flag == ARC_FREE)
+// {
+// printf("candidate (level %i ?= %i) (flag %i ?= %i) (group %i ?= %i)\n",
+// symmetry_level, next_earc->symmetry_level,
+// symmetry_flag, next_earc->symmetry_flag,
+// symmetry_group, next_earc->symmetry_flag);
+// }
+
+ if (next_earc->flag == ARC_FREE &&
+ next_earc->symmetry_flag == symmetry_flag &&
+ next_earc->symmetry_group == symmetry_group &&
+ next_earc->symmetry_level == symmetry_level)
+ {
+// printf("CORRESPONDING ARC FOUND\n");
+// printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group);
+
+ matchMultiResolutionArc(rigg, start_node, next_iarc, next_earc);
+ break;
+ }
+ }
+
+ /* not found, try at higher nodes (lower node might have filtered internal arcs, messing shape of tree */
+ if (next_iarc->link_mesh == NULL) {
+// printf("NO CORRESPONDING ARC FOUND - GOING TO HIGHER LEVELS\n");
+
+ if (enode->link_up) {
+ start_node->link_mesh = enode->link_up;
+ findCorrespondingArc(rigg, start_arc, start_node, next_iarc, 0);
+ }
+ }
+
+ /* still not found, print debug info */
+ if (root && next_iarc->link_mesh == NULL) {
+ start_node->link_mesh = enode; /* linking back with root node */
+
+// printf("NO CORRESPONDING ARC FOUND\n");
+// RIG_printArcBones(next_iarc);
+//
+// printf("ON NODE %i, multilevel %i\n", enode->index, enode->multi_level);
+//
+// printf("LOOKING FOR\n");
+// printf("flag %i -- level %i -- flag %i -- group %i\n", ARC_FREE, symmetry_level, symmetry_flag, symmetry_group);
+//
+// printf("CANDIDATES\n");
+// for (i = 0; i < enode->degree; i++)
+// {
+// next_earc = (ReebArc *)enode->arcs[i];
+// printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group);
+// }
+
+ /* Emergency matching */
+ for (i = 0; i < enode->degree; i++) {
+ next_earc = (ReebArc *)enode->arcs[i];
+
+ if (next_earc->flag == ARC_FREE && next_earc->symmetry_level == symmetry_level) {
+// printf("USING:\n");
+// printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group);
+ matchMultiResolutionArc(rigg, start_node, next_iarc, next_earc);
+ break;
+ }
+ }
+ }
+
+}
+
+static void retargetSubgraph(bContext *C, RigGraph *rigg, RigArc *start_arc, RigNode *start_node)
+{
+ RigNode *inode = start_node;
+ int i;
+
+ /* no start arc on first node */
+ if (start_arc) {
+ ReebNode *enode = start_node->link_mesh;
+ ReebArc *earc = start_arc->link_mesh;
+
+ retargetArctoArc(C, rigg, start_arc, start_node);
+
+ enode = BIF_otherNodeFromIndex(earc, enode);
+ inode = (RigNode *)BLI_otherNode((BArc *)start_arc, (BNode *)inode);
+
+ /* match with lowest node with correct shape */
+ matchMultiResolutionNode(rigg, inode, enode);
+ }
+
+ for (i = 0; i < inode->degree; i++) {
+ RigArc *next_iarc = (RigArc *)inode->arcs[i];
+
+ /* no back tracking */
+ if (next_iarc != start_arc) {
+ findCorrespondingArc(rigg, start_arc, inode, next_iarc, 1);
+ if (next_iarc->link_mesh) {
+ retargetSubgraph(C, rigg, next_iarc, inode);
+ }
+ }
+ }
+}
+
+static void finishRetarget(RigGraph *rigg)
+{
+ BLI_task_pool_work_and_wait(rigg->task_pool);
+}
+
+static void adjustGraphs(bContext *C, RigGraph *rigg)
+{
+ Main *bmain = CTX_data_main(C);
+ bArmature *arm = rigg->ob->data;
+ RigArc *arc;
+
+ for (arc = rigg->arcs.first; arc; arc = arc->next) {
+ if (arc->link_mesh) {
+ retargetArctoArc(C, rigg, arc, arc->head);
+ }
+ }
+
+ finishRetarget(rigg);
+
+ /* Turn the list into an armature */
+ arm->edbo = rigg->editbones;
+ ED_armature_from_edit(bmain, arm);
+
+ ED_undo_push(C, "Retarget Skeleton");
+}
+
+static void retargetGraphs(bContext *C, RigGraph *rigg)
+{
+ Main *bmain = CTX_data_main(C);
+ bArmature *arm = rigg->ob->data;
+ ReebGraph *reebg = rigg->link_mesh;
+ RigNode *inode;
+
+ /* flag all ReebArcs as free */
+ BIF_flagMultiArcs(reebg, ARC_FREE);
+
+ /* return to first level */
+ inode = rigg->head;
+
+ matchMultiResolutionStartingNode(rigg, reebg, inode);
+
+ retargetSubgraph(C, rigg, NULL, inode);
+
+ //generateMissingArcs(rigg);
+
+ finishRetarget(rigg);
+
+ /* Turn the list into an armature */
+ arm->edbo = rigg->editbones;
+ ED_armature_from_edit(bmain, arm);
+}
+
+const char *RIG_nameBone(RigGraph *rg, int arc_index, int bone_index)
+{
+ RigArc *arc = BLI_findlink(&rg->arcs, arc_index);
+ RigEdge *iedge;
+
+ if (arc == NULL) {
+ return "None";
+ }
+
+ if (bone_index == BLI_listbase_count(&arc->edges)) {
+ return "Last joint";
+ }
+
+ iedge = BLI_findlink(&arc->edges, bone_index);
+
+ if (iedge == NULL) {
+ return "Done";
+ }
+
+ if (iedge->bone == NULL) {
+ return "Bone offset";
+ }
+
+ return iedge->bone->name;
+}
+
+int RIG_nbJoints(RigGraph *rg)
+{
+ RigArc *arc;
+ int total = 0;
+
+ total += BLI_listbase_count(&rg->nodes);
+
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
+ total += BLI_listbase_count(&arc->edges) - 1; /* -1 because end nodes are already counted */
+ }
+
+ return total;
+}
+
+static void BIF_freeRetarget(void)
+{
+ if (GLOBAL_RIGG) {
+ RIG_freeRigGraph((BGraph *)GLOBAL_RIGG);
+ GLOBAL_RIGG = NULL;
+ }
+}
+
+void BIF_retargetArmature(bContext *C)
+{
+ ReebGraph *reebg;
+ double start_time, end_time;
+ double gstart_time, gend_time;
+ double reeb_time, rig_time = 0.0, retarget_time = 0.0, total_time;
+
+ gstart_time = start_time = PIL_check_seconds_timer();
+
+ reebg = BIF_ReebGraphMultiFromEditMesh(C);
+
+ end_time = PIL_check_seconds_timer();
+ reeb_time = end_time - start_time;
+
+ printf("Reeb Graph created\n");
+
+ CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
+ {
+ Object *ob = base->object;
+
+ if (ob->type == OB_ARMATURE) {
+ RigGraph *rigg;
+ bArmature *arm;
+
+ arm = ob->data;
+
+ /* Put the armature into editmode */
+
+
+ start_time = PIL_check_seconds_timer();
+
+ rigg = RIG_graphFromArmature(C, ob, arm);
+
+ end_time = PIL_check_seconds_timer();
+ rig_time = end_time - start_time;
+
+ printf("Armature graph created\n");
+
+ //RIG_printGraph(rigg);
+
+ rigg->link_mesh = reebg;
+
+ printf("retargetting %s\n", ob->id.name);
+
+ start_time = PIL_check_seconds_timer();
+
+ retargetGraphs(C, rigg);
+
+ end_time = PIL_check_seconds_timer();
+ retarget_time = end_time - start_time;
+
+ BIF_freeRetarget();
+
+ GLOBAL_RIGG = rigg;
+
+ break; /* only one armature at a time */
+ }
+ }
+ CTX_DATA_END;
+
+
+ gend_time = PIL_check_seconds_timer();
+
+ total_time = gend_time - gstart_time;
+
+ printf("-----------\n");
+ printf("runtime: \t%.3f\n", total_time);
+ printf("reeb: \t\t%.3f (%.1f%%)\n", reeb_time, reeb_time / total_time * 100);
+ printf("rig: \t\t%.3f (%.1f%%)\n", rig_time, rig_time / total_time * 100);
+ printf("retarget: \t%.3f (%.1f%%)\n", retarget_time, retarget_time / total_time * 100);
+ printf("-----------\n");
+
+ ED_undo_push(C, "Retarget Skeleton");
+
+ // XXX
+// allqueue(REDRAWVIEW3D, 0);
+}
+
+void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ Scene *scene = CTX_data_scene(C);
+ bArmature *armedit = obedit->data;
+ Object *ob;
+ RigGraph *rigg;
+ RigArc *iarc;
+ char *side_string = scene->toolsettings->skgen_side_string;
+ char *num_string = scene->toolsettings->skgen_num_string;
+ int free_template = 0;
+
+ if (template_rigg) {
+ ob = template_rigg->ob;
+ }
+ else {
+ free_template = 1;
+ ob = obedit;
+ template_rigg = armatureSelectedToGraph(C, ob, ob->data);
+ }
+
+ if (BLI_listbase_is_empty(&template_rigg->arcs)) {
+// XXX
+// error("No Template and no deforming bones selected");
+ return;
+ }
+
+ rigg = cloneRigGraph(template_rigg, armedit->edbo, obedit, side_string, num_string);
+
+ iarc = rigg->arcs.first;
+
+ iarc->link_mesh = earc;
+ iarc->head->link_mesh = earc->head;
+ iarc->tail->link_mesh = earc->tail;
+
+ retargetArctoArc(C, rigg, iarc, iarc->head);
+
+ finishRetarget(rigg);
+
+ /* free template if it comes from the edit armature */
+ if (free_template) {
+ RIG_freeRigGraph((BGraph *)template_rigg);
+ }
+ RIG_freeRigGraph((BGraph *)rigg);
+
+ ED_armature_edit_validate_active(armedit);
+
+// XXX
+// allqueue(REDRAWVIEW3D, 0);
+}
+
+void BIF_adjustRetarget(bContext *C)
+{
+ if (GLOBAL_RIGG) {
+ adjustGraphs(C, GLOBAL_RIGG);
+ }
+}
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index aa0e13a3e16..1f01def5133 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -42,6 +42,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_modifier.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "ED_mesh.h"
#include "ED_armature.h"
@@ -96,7 +97,7 @@ struct LaplacianSystem {
float *H; /* diagonal H matrix */
float *p; /* values from all p vectors */
float *mindist; /* minimum distance to a bone for all vertices */
-
+
BVHTree *bvhtree; /* ray tracing acceleration structure */
const MLoopTri **vltree; /* a looptri that the vertex belongs to */
} heat;
@@ -107,7 +108,7 @@ struct LaplacianSystem {
/* Computation of these weights for the laplacian is based on:
* "Discrete Differential-Geometry Operators for Triangulated 2-Manifolds",
* Meyer et al, 2002. Section 3.5, formula (8).
- *
+ *
* We do it a bit different by going over faces instead of going over each
* vertex and adjacent faces, since we don't store this adjacency. Also, the
* formulas are tweaked a bit to work for non-manifold meshes. */
@@ -261,7 +262,7 @@ static void laplacian_system_construct_end(LaplacianSystem *sys)
if (sys->areaweights)
for (a = 0, face = sys->faces; a < sys->totface; a++, face++)
laplacian_triangle_area(sys, (*face)[0], (*face)[1], (*face)[2]);
-
+
for (a = 0; a < totvert; a++) {
if (sys->areaweights) {
if (sys->varea[a] != 0.0f)
@@ -277,7 +278,7 @@ static void laplacian_system_construct_end(LaplacianSystem *sys)
if (sys->storeweights)
sys->fweights = MEM_callocN(sizeof(float) * 3 * totface, "LaplacianFWeight");
-
+
for (a = 0, face = sys->faces; a < totface; a++, face++)
laplacian_triangle_weights(sys, a, (*face)[0], (*face)[1], (*face)[2]);
@@ -405,7 +406,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys)
const MLoopTri *lt = &looptri[a];
float bb[6];
int vtri[3];
-
+
vtri[0] = mloop[lt->tri[0]].v;
vtri[1] = mloop[lt->tri[1]].v;
vtri[2] = mloop[lt->tri[2]].v;
@@ -416,14 +417,14 @@ static void heat_ray_tree_create(LaplacianSystem *sys)
minmax_v3v3_v3(bb, bb + 3, verts[vtri[2]]);
BLI_bvhtree_insert(sys->heat.bvhtree, a, bb, 2);
-
+
//Setup inverse pointers to use on isect.orig
sys->heat.vltree[vtri[0]] = lt;
sys->heat.vltree[vtri[1]] = lt;
sys->heat.vltree[vtri[2]] = lt;
}
- BLI_bvhtree_balance(sys->heat.bvhtree);
+ BLI_bvhtree_balance(sys->heat.bvhtree);
}
static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source)
@@ -459,7 +460,7 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source)
static float heat_source_distance(LaplacianSystem *sys, int vertex, int source)
{
float closest[3], d[3], dist, cosine;
-
+
/* compute euclidian distance */
closest_to_line_segment_v3(closest, sys->heat.verts[vertex], sys->heat.root[source], sys->heat.tip[source]);
@@ -481,7 +482,7 @@ static int heat_source_closest(LaplacianSystem *sys, int vertex, int source)
if (dist <= sys->heat.mindist[vertex] * (1.0f + DISTANCE_EPSILON))
if (heat_ray_source_visible(sys, vertex, source))
return 1;
-
+
return 0;
}
@@ -516,7 +517,7 @@ static void heat_set_H(LaplacianSystem *sys, int vertex)
}
else
h = 0.0f;
-
+
sys->heat.H[vertex] = h;
}
@@ -533,7 +534,7 @@ static void heat_calc_vnormals(LaplacianSystem *sys)
v3 = (*face)[2];
normal_tri_v3(fnor, sys->verts[v1], sys->verts[v2], sys->verts[v3]);
-
+
add_v3_v3(sys->heat.vnors[v1], fnor);
add_v3_v3(sys->heat.vnors[v2], fnor);
add_v3_v3(sys->heat.vnors[v3], fnor);
@@ -680,7 +681,7 @@ void heat_bone_weighting(
for (a = 0; a < me->totvert; a++)
vertsflipped[a] = mesh_get_x_mirror_vert(ob, NULL, a, use_topology);
}
-
+
/* compute weights per bone */
for (j = 0; j < numsource; j++) {
if (!selected[j])
@@ -718,7 +719,7 @@ void heat_bone_weighting(
continue;
solution = laplacian_system_get_solution(sys, a);
-
+
if (bbone) {
if (solution > 0.0f)
ED_vgroup_vert_add(ob, dgrouplist[j], a, solution,
@@ -853,7 +854,7 @@ typedef struct MeshDeformBind {
/* direct solver */
int *varidx;
-
+
BVHTree *bvhtree;
BVHTreeFromMesh bvhdata;
@@ -874,7 +875,7 @@ typedef struct MeshDeformIsect {
bool isect;
float u, v;
-
+
} MeshDeformIsect;
/* ray intersection */
@@ -894,9 +895,9 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r
MeshDeformIsect *isec = data->isec;
float no[3], co[3], dist;
float *face[3];
-
+
lt = &looptri[index];
-
+
face[0] = mdb->cagecos[mloop[lt->tri[0]].v];
face[1] = mdb->cagecos[mloop[lt->tri[1]].v];
face[2] = mdb->cagecos[mloop[lt->tri[2]].v];
@@ -920,7 +921,7 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r
hit->index = index;
hit->dist = dist;
copy_v3_v3(hit->co, co);
-
+
isec->isect = (dot_v3v3(no, ray->direction) <= 0.0f);
isec->lambda = dist;
}
@@ -1003,7 +1004,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co)
copy_v3_v3(start, co);
sub_v3_v3v3(dir, outside, start);
normalize_v3(dir);
-
+
isect = meshdeform_ray_tree_intersect(mdb, start, outside);
if (isect && !isect->facing)
return 1;
@@ -1017,7 +1018,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co)
BLI_INLINE int meshdeform_index(MeshDeformBind *mdb, int x, int y, int z, int n)
{
int size = mdb->size;
-
+
x += MESHDEFORM_OFFSET[n][0];
y += MESHDEFORM_OFFSET[n][1];
z += MESHDEFORM_OFFSET[n][2];
@@ -1121,7 +1122,7 @@ static void meshdeform_bind_floodfill(MeshDeformBind *mdb)
if (mdb->semibound[a])
ts++;
}
-
+
printf("interior %d exterior %d boundary %d semi-boundary %d\n", ti, te, tb, ts);
}
#endif
@@ -1230,7 +1231,7 @@ static void meshdeform_matrix_add_cell(MeshDeformBind *mdb, LinearSolver *contex
return;
EIG_linear_solver_matrix_add(context, mdb->varidx[acenter], mdb->varidx[acenter], 1.0f);
-
+
totweight = meshdeform_boundary_total_weight(mdb, x, y, z);
for (i = 1; i <= 6; i++) {
a = meshdeform_index(mdb, x, y, z, i);
@@ -1280,7 +1281,7 @@ static void meshdeform_matrix_add_semibound_phi(MeshDeformBind *mdb, int x, int
a = meshdeform_index(mdb, x, y, z, 0);
if (!mdb->semibound[a])
return;
-
+
mdb->phi[a] = 0.0f;
totweight = meshdeform_boundary_total_weight(mdb, x, y, z);
@@ -1418,7 +1419,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
printf("totalphi deficiency [%s|%d] %d: %.10f\n",
(mdb->tag[b] == MESHDEFORM_TAG_INTERIOR) ? "interior" : "boundary", mdb->semibound[b], mdb->varidx[b], mdb->totalphi[b]);
#endif
-
+
/* free */
MEM_freeN(mdb->varidx);
@@ -1504,7 +1505,7 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa
/* start with all cells untyped */
for (a = 0; a < mdb->size3; a++)
mdb->tag[a] = MESHDEFORM_TAG_UNTYPED;
-
+
/* detect intersections and tag boundary cells */
for (z = 0; z < mdb->size; z++)
for (y = 0; y < mdb->size; y++)
@@ -1591,7 +1592,7 @@ void ED_mesh_deform_bind_callback(
/* get mesh and cage mesh */
mdb.vertexcos = MEM_callocN(sizeof(float) * 3 * totvert, "MeshDeformCos");
mdb.totvert = totvert;
-
+
mdb.cagemesh = cagemesh;
mdb.totcagevert = mdb.cagemesh->totvert;
mdb.cagecos = MEM_callocN(sizeof(*mdb.cagecos) * mdb.totcagevert, "MeshDeformBindCos");
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 932919cb19d..ffe64cc24b0 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -46,6 +46,7 @@
#include "BKE_armature.h"
#include "BKE_context.h"
#include "BKE_deform.h"
+#include "BKE_main.h"
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_layer.h"
@@ -91,7 +92,7 @@ bool ED_object_posemode_enter_ex(struct Main *bmain, Object *ob)
{
BLI_assert(!ID_IS_LINKED(ob));
bool ok = false;
-
+
switch (ob->type) {
case OB_ARMATURE:
ob->restore_mode = ob->mode;
@@ -178,72 +179,75 @@ static bool pose_has_protected_selected(Object *ob, short warn)
/* For the object with pose/action: update paths for those that have got them
* This should selectively update paths that exist...
*
- * To be called from various tools that do incremental updates
+ * To be called from various tools that do incremental updates
*/
void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob)
{
struct Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
ListBase targets = {NULL, NULL};
-
+
/* set flag to force recalc, then grab the relevant bones to target */
ob->pose->avs.recalc |= ANIMVIZ_RECALC_PATHS;
animviz_get_object_motionpaths(ob, &targets);
-
+
/* recalculate paths, then free */
animviz_calc_motionpaths(depsgraph, bmain, scene, &targets);
BLI_freelistN(&targets);
+
+ /* tag armature object for copy on write - so paths will draw/redraw */
+ DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
}
/* show popup to determine settings */
static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
+{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
+
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
/* set default settings from existing/stored settings */
{
bAnimVizSettings *avs = &ob->pose->avs;
PointerRNA avs_ptr;
-
+
RNA_int_set(op->ptr, "start_frame", avs->path_sf);
RNA_int_set(op->ptr, "end_frame", avs->path_ef);
-
+
RNA_pointer_create(NULL, &RNA_AnimVizMotionPaths, avs, &avs_ptr);
RNA_enum_set(op->ptr, "bake_location", RNA_enum_get(&avs_ptr, "bake_location"));
}
-
+
/* show popup dialog to allow editing of range... */
// FIXME: hardcoded dimensions here are just arbitrary
return WM_operator_props_dialog_popup(C, op, 10 * UI_UNIT_X, 10 * UI_UNIT_Y);
}
-/* For the object with pose/action: create path curves for selected bones
+/* For the object with pose/action: create path curves for selected bones
* This recalculates the WHOLE path within the pchan->pathsf and pchan->pathef range
*/
static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
Scene *scene = CTX_data_scene(C);
-
+
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
/* grab baking settings from operator settings */
{
bAnimVizSettings *avs = &ob->pose->avs;
PointerRNA avs_ptr;
-
+
avs->path_sf = RNA_int_get(op->ptr, "start_frame");
avs->path_ef = RNA_int_get(op->ptr, "end_frame");
-
+
RNA_pointer_create(NULL, &RNA_AnimVizMotionPaths, avs, &avs_ptr);
RNA_enum_set(&avs_ptr, "bake_location", RNA_enum_get(op->ptr, "bake_location"));
}
-
+
/* set up path data for bones being calculated */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
@@ -259,7 +263,7 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void POSE_OT_paths_calculate(wmOperatorType *ot)
@@ -268,23 +272,23 @@ void POSE_OT_paths_calculate(wmOperatorType *ot)
ot->name = "Calculate Bone Paths";
ot->idname = "POSE_OT_paths_calculate";
ot->description = "Calculate paths for the selected bones";
-
+
/* api callbacks */
ot->invoke = pose_calculate_paths_invoke;
ot->exec = pose_calculate_paths_exec;
ot->poll = ED_operator_posemode_exclusive;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
- RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start",
+ RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start",
"First frame to calculate bone paths on", MINFRAME, MAXFRAME / 2.0);
- RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End",
+ RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End",
"Last frame to calculate bone paths on", MINFRAME, MAXFRAME / 2.0);
-
- RNA_def_enum(ot->srna, "bake_location", rna_enum_motionpath_bake_location_items, 0,
- "Bake Location",
+
+ RNA_def_enum(ot->srna, "bake_location", rna_enum_motionpath_bake_location_items, 0,
+ "Bake Location",
"Which point on the bones is used when calculating paths");
}
@@ -296,7 +300,7 @@ static int pose_update_paths_poll(bContext *C)
Object *ob = CTX_data_active_object(C);
return (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) != 0;
}
-
+
return false;
}
@@ -304,17 +308,17 @@ static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
Scene *scene = CTX_data_scene(C);
-
+
if (ELEM(NULL, ob, scene))
return OPERATOR_CANCELLED;
/* calculate the bones that now have motionpaths... */
/* TODO: only make for the selected bones? */
ED_pose_recalculate_paths(C, scene, ob);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -324,11 +328,11 @@ void POSE_OT_paths_update(wmOperatorType *ot)
ot->name = "Update Bone Paths";
ot->idname = "POSE_OT_paths_update";
ot->description = "Recalculate paths for bones that already have them";
-
+
/* api callbakcs */
ot->exec = pose_update_paths_exec;
ot->poll = pose_update_paths_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -340,10 +344,10 @@ static void ED_pose_clear_paths(Object *ob, bool only_selected)
{
bPoseChannel *pchan;
bool skipped = false;
-
+
if (ELEM(NULL, ob, ob->pose))
return;
-
+
/* free the motionpath blocks for all bones - This is easier for users to quickly clear all */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->mpath) {
@@ -356,7 +360,7 @@ static void ED_pose_clear_paths(Object *ob, bool only_selected)
}
}
}
-
+
/* if nothing was skipped, there should be no paths left! */
if (skipped == false)
ob->pose->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS;
@@ -367,18 +371,18 @@ static int pose_clear_paths_exec(bContext *C, wmOperator *op)
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
bool only_selected = RNA_boolean_get(op->ptr, "only_selected");
-
+
/* only continue if there's an object */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
/* use the backend function for this */
ED_pose_clear_paths(ob, only_selected);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
- return OPERATOR_FINISHED;
+
+ return OPERATOR_FINISHED;
}
/* operator callback/wrapper */
@@ -396,17 +400,17 @@ void POSE_OT_paths_clear(wmOperatorType *ot)
ot->name = "Clear Bone Paths";
ot->idname = "POSE_OT_paths_clear";
ot->description = "Clear path caches for all bones, hold Shift key for selected bones only";
-
+
/* api callbacks */
ot->invoke = pose_clear_paths_invoke;
ot->exec = pose_clear_paths_exec;
ot->poll = ED_operator_posemode_exclusive;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
- ot->prop = RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected",
+ ot->prop = RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected",
"Only clear paths from selected bones");
RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
}
@@ -421,13 +425,13 @@ static void pose_copy_menu(Scene *scene)
bPoseChannel *pchan, *pchanact;
short nr = 0;
int i = 0;
-
+
/* paranoia checks */
if (ELEM(NULL, ob, ob->pose)) return;
if ((ob == obedit) || (ob->mode & OB_MODE_POSE) == 0) return;
-
+
pchan = BKE_pose_channel_active(ob);
-
+
if (pchan == NULL) return;
pchanact = pchan;
arm = ob->data;
@@ -449,10 +453,10 @@ static void pose_copy_menu(Scene *scene)
else
nr = pupmenu("Copy Pose Attributes %t|Local Location %x1|Local Rotation %x2|Local Size %x3|%l|Visual Location %x9|Visual Rotation %x10|Visual Size %x11|%l|Constraints (All) %x4|%l|Transform Locks %x6|IK Limits %x7|Bone Shape %x8");
}
-
- if (nr <= 0)
+
+ if (nr <= 0)
return;
-
+
if (nr != 5) {
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if ((arm->layer & pchan->bone->layer) &&
@@ -473,23 +477,23 @@ static void pose_copy_menu(Scene *scene)
case 4: /* All Constraints */
{
ListBase tmp_constraints = {NULL, NULL};
-
- /* copy constraints to tmpbase and apply 'local' tags before
+
+ /* copy constraints to tmpbase and apply 'local' tags before
* appending to list of constraints for this channel
*/
BKE_constraints_copy(&tmp_constraints, &pchanact->constraints, true);
if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) {
bConstraint *con;
-
+
/* add proxy-local tags */
for (con = tmp_constraints.first; con; con = con->next)
con->flag |= CONSTRAINT_PROXY_LOCAL;
}
BLI_movelisttolist(&pchan->constraints, &tmp_constraints);
-
+
/* update flags (need to add here, not just copy) */
pchan->constflag |= pchanact->constflag;
-
+
if (ob->pose)
BKE_pose_tag_recalc(bmain, ob->pose);
}
@@ -520,12 +524,12 @@ static void pose_copy_menu(Scene *scene)
case 10: /* Visual Rotation */
{
float delta_mat[4][4];
-
+
BKE_armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat);
-
+
if (pchan->rotmode == ROT_MODE_AXISANGLE) {
float tmp_quat[4];
-
+
/* need to convert to quat first (in temp var)... */
mat4_to_quat(tmp_quat, delta_mat);
quat_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, tmp_quat);
@@ -539,7 +543,7 @@ static void pose_copy_menu(Scene *scene)
case 11: /* Visual Size */
{
float delta_mat[4][4], size[4];
-
+
BKE_armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat);
mat4_to_size(size, delta_mat);
copy_v3_v3(pchan->size, size);
@@ -552,20 +556,20 @@ static void pose_copy_menu(Scene *scene)
bConstraint *con, *con_back;
int const_toggle[24] = {0}; /* XXX, initialize as 0 to quiet errors */
ListBase const_copy = {NULL, NULL};
-
+
BLI_duplicatelist(&const_copy, &(pchanact->constraints));
-
+
/* build the puplist of constraints */
for (con = pchanact->constraints.first, i = 0; con; con = con->next, i++) {
const_toggle[i] = 1;
// add_numbut(i, UI_BTYPE_TOGGLE|INT, con->name, 0, 0, &(const_toggle[i]), "");
}
-
+
// if (!do_clever_numbuts("Select Constraints", i, REDRAW)) {
// BLI_freelistN(&const_copy);
// return;
// }
-
+
/* now build a new listbase from the options selected */
for (i = 0, con = const_copy.first; con; i++) {
/* if not selected, free/remove it from the list */
@@ -577,7 +581,7 @@ static void pose_copy_menu(Scene *scene)
else
con = con->next;
}
-
+
/* Copy the temo listbase to the selected posebones */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if ((arm->layer & pchan->bone->layer) &&
@@ -585,8 +589,8 @@ static void pose_copy_menu(Scene *scene)
(pchan != pchanact) )
{
ListBase tmp_constraints = {NULL, NULL};
-
- /* copy constraints to tmpbase and apply 'local' tags before
+
+ /* copy constraints to tmpbase and apply 'local' tags before
* appending to list of constraints for this channel
*/
BKE_constraints_copy(&tmp_constraints, &const_copy, true);
@@ -596,22 +600,22 @@ static void pose_copy_menu(Scene *scene)
con->flag |= CONSTRAINT_PROXY_LOCAL;
}
BLI_movelisttolist(&pchan->constraints, &tmp_constraints);
-
+
/* update flags (need to add here, not just copy) */
pchan->constflag |= pchanact->constflag;
}
}
BLI_freelistN(&const_copy);
BKE_pose_update_constraint_flags(ob->pose); /* we could work out the flags but its simpler to do this */
-
+
if (ob->pose)
BKE_pose_tag_recalc(bmain, ob->pose);
}
-
+
DEG_id_tag_update(&ob->id, OB_RECALC_DATA); // and all its relations
-
+
BIF_undo_push("Copy Pose Attributes");
-
+
}
#endif
@@ -619,9 +623,10 @@ static void pose_copy_menu(Scene *scene)
static int pose_flip_names_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
const bool do_strip_numbers = RNA_boolean_get(op->ptr, "do_strip_numbers");
-
+
FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob)
{
bArmature *arm = ob->data;
@@ -633,10 +638,10 @@ static int pose_flip_names_exec(bContext *C, wmOperator *op)
}
FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
- ED_armature_bones_flip_names(arm, &bones_names, do_strip_numbers);
+ ED_armature_bones_flip_names(bmain, arm, &bones_names, do_strip_numbers);
BLI_freelistN(&bones_names);
-
+
/* since we renamed stuff... */
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -644,7 +649,7 @@ static int pose_flip_names_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
}
FOREACH_OBJECT_IN_MODE_END;
-
+
return OPERATOR_FINISHED;
}
@@ -654,11 +659,11 @@ void POSE_OT_flip_names(wmOperatorType *ot)
ot->name = "Flip Names";
ot->idname = "POSE_OT_flip_names";
ot->description = "Flips (and corrects) the axis suffixes of the names of selected bones";
-
+
/* api callbacks */
ot->exec = pose_flip_names_exec;
ot->poll = ED_operator_posemode_local;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -671,31 +676,32 @@ void POSE_OT_flip_names(wmOperatorType *ot)
static int pose_autoside_names_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
bArmature *arm;
char newname[MAXBONENAME];
short axis = RNA_enum_get(op->ptr, "axis");
-
+
/* paranoia checks */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
arm = ob->data;
-
+
/* loop through selected bones, auto-naming them */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
BLI_strncpy(newname, pchan->name, sizeof(newname));
if (bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis]))
- ED_armature_bone_rename(arm, pchan->name, newname);
+ ED_armature_bone_rename(bmain, arm, pchan->name, newname);
}
CTX_DATA_END;
-
+
/* since we renamed stuff... */
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -707,20 +713,20 @@ void POSE_OT_autoside_names(wmOperatorType *ot)
{2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "AutoName by Axis";
ot->idname = "POSE_OT_autoside_names";
ot->description = "Automatically renames the selected bones according to which side of the target axis they fall on";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = pose_autoside_names_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* settings */
ot->prop = RNA_def_enum(ot->srna, "axis", axis_items, 0, "Axis", "Axis tag names with");
}
@@ -731,18 +737,18 @@ static int pose_bone_rotmode_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
int mode = RNA_enum_get(op->ptr, "type");
-
+
/* set rotation mode of selected bones */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
pchan->rotmode = mode;
}
CTX_DATA_END;
-
+
/* notifiers and updates */
DEG_id_tag_update((ID *)ob, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -752,15 +758,15 @@ void POSE_OT_rotation_mode_set(wmOperatorType *ot)
ot->name = "Set Rotation Mode";
ot->idname = "POSE_OT_rotation_mode_set";
ot->description = "Set the rotation representation used by selected bones";
-
+
/* callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = pose_bone_rotmode_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_posebone_rotmode_items, 0, "Rotation Mode", "");
}
@@ -802,26 +808,26 @@ static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op)
int maxLayers = (RNA_boolean_get(op->ptr, "all")) ? 32 : 16;
int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
int i;
-
+
/* sanity checking */
if (arm == NULL)
return OPERATOR_CANCELLED;
-
+
/* use RNA to set the layers
* although it would be faster to just set directly using bitflags, we still
* need to setup a RNA pointer so that we get the "update" callbacks for free...
*/
RNA_id_pointer_create(&arm->id, &ptr);
-
+
for (i = 0; i < maxLayers; i++)
layers[i] = 1;
-
+
RNA_boolean_set_array(&ptr, "layers", layers);
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -832,14 +838,14 @@ void ARMATURE_OT_layers_show_all(wmOperatorType *ot)
ot->name = "Show All Layers";
ot->idname = "ARMATURE_OT_layers_show_all";
ot->description = "Make all armature layers visible";
-
+
/* callbacks */
ot->exec = pose_armature_layers_showall_exec;
ot->poll = armature_layers_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All Layers", "Enable all layers or just the first 16 (top row)");
}
@@ -853,16 +859,16 @@ static int armature_layers_invoke(bContext *C, wmOperator *op, const wmEvent *ev
bArmature *arm = armature_layers_get_data(&ob);
PointerRNA ptr;
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
-
+
/* sanity checking */
if (arm == NULL)
return OPERATOR_CANCELLED;
-
+
/* get RNA pointer to armature data to use that to retrieve the layers as ints to init the operator */
RNA_id_pointer_create((ID *)arm, &ptr);
RNA_boolean_get_array(&ptr, "layers", layers);
RNA_boolean_set_array(op->ptr, "layers", layers);
-
+
/* part to sync with other similar operators... */
return WM_operator_props_popup(C, op, event);
}
@@ -899,15 +905,15 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot)
ot->name = "Change Armature Layers";
ot->idname = "ARMATURE_OT_armature_layers";
ot->description = "Change the visible armature layers";
-
+
/* callbacks */
ot->invoke = armature_layers_invoke;
ot->exec = armature_layers_exec;
ot->poll = armature_layers_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible");
}
@@ -918,22 +924,22 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot)
static int pose_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
-
+
/* get layers that are active already */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
short bit;
-
+
/* loop over the bits for this pchan's layers, adding layers where they're needed */
for (bit = 0; bit < 32; bit++) {
layers[bit] = (pchan->bone->layer & (1u << bit)) != 0;
}
}
CTX_DATA_END;
-
+
/* copy layers to operator */
RNA_boolean_set_array(op->ptr, "layers", layers);
-
+
/* part to sync with other similar operators... */
return WM_operator_props_popup(C, op, event);
}
@@ -974,15 +980,15 @@ void POSE_OT_bone_layers(wmOperatorType *ot)
ot->name = "Change Bone Layers";
ot->idname = "POSE_OT_bone_layers";
ot->description = "Change the layers that the selected bones belong to";
-
+
/* callbacks */
ot->invoke = pose_bone_layers_invoke;
ot->exec = pose_bone_layers_exec;
ot->poll = ED_operator_posemode_exclusive;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to");
}
@@ -993,12 +999,12 @@ void POSE_OT_bone_layers(wmOperatorType *ot)
static int armature_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
-
+
/* get layers that are active already */
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
{
short bit;
-
+
/* loop over the bits for this pchan's layers, adding layers where they're needed */
for (bit = 0; bit < 32; bit++) {
if (ebone->layer & (1u << bit)) {
@@ -1007,10 +1013,10 @@ static int armature_bone_layers_invoke(bContext *C, wmOperator *op, const wmEven
}
}
CTX_DATA_END;
-
+
/* copy layers to operator */
RNA_boolean_set_array(op->ptr, "layers", layers);
-
+
/* part to sync with other similar operators... */
return WM_operator_props_popup(C, op, event);
}
@@ -1021,10 +1027,10 @@ static int armature_bone_layers_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_edit_object(C);
PointerRNA ptr;
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
-
+
/* get the values set in the operator properties */
RNA_boolean_get_array(op->ptr, "layers", layers);
-
+
/* set layers of pchans based on the values set in the operator props */
CTX_DATA_BEGIN_WITH_ID (C, EditBone *, ebone, selected_editable_bones, bArmature *, arm)
{
@@ -1033,10 +1039,10 @@ static int armature_bone_layers_exec(bContext *C, wmOperator *op)
RNA_boolean_set_array(&ptr, "layers", layers);
}
CTX_DATA_END;
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1046,15 +1052,15 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot)
ot->name = "Change Bone Layers";
ot->idname = "ARMATURE_OT_bone_layers";
ot->description = "Change the layers that the selected bones belong to";
-
+
/* callbacks */
ot->invoke = armature_bone_layers_invoke;
ot->exec = armature_bone_layers_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to");
}
@@ -1118,19 +1124,19 @@ void POSE_OT_hide(wmOperatorType *ot)
ot->name = "Hide Selected";
ot->idname = "POSE_OT_hide";
ot->description = "Tag selected bones to not be visible in Pose Mode";
-
+
/* api callbacks */
ot->exec = pose_hide_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "");
}
-static int show_pose_bone_cb(Object *ob, Bone *bone, void *data)
+static int show_pose_bone_cb(Object *ob, Bone *bone, void *data)
{
const bool select = GET_INT_FROM_POINTER(data);
@@ -1181,11 +1187,11 @@ void POSE_OT_reveal(wmOperatorType *ot)
ot->name = "Reveal Selected";
ot->idname = "POSE_OT_reveal";
ot->description = "Reveal all bones hidden in Pose Mode";
-
+
/* api callbacks */
ot->exec = pose_reveal_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1234,11 +1240,11 @@ void POSE_OT_quaternions_flip(wmOperatorType *ot)
ot->name = "Flip Quats";
ot->idname = "POSE_OT_quaternions_flip";
ot->description = "Flip quaternion values to achieve desired rotations, while maintaining the same orientations";
-
+
/* callbacks */
ot->exec = pose_flip_quats_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c
index 449383fb0b8..aefca13d66c 100644
--- a/source/blender/editors/armature/pose_group.c
+++ b/source/blender/editors/armature/pose_group.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -68,13 +68,13 @@ static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op))
/* only continue if there's an object and pose */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
/* for now, just call the API function for this */
BKE_pose_add_group(ob->pose, NULL);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -84,11 +84,11 @@ void POSE_OT_group_add(wmOperatorType *ot)
ot->name = "Add Bone Group";
ot->idname = "POSE_OT_group_add";
ot->description = "Add a new bone group";
-
+
/* api callbacks */
ot->exec = pose_group_add_exec;
ot->poll = ED_operator_posemode_context;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -97,18 +97,18 @@ void POSE_OT_group_add(wmOperatorType *ot)
static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_pose_object_from_context(C);
-
+
/* only continue if there's an object and pose */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
/* for now, just call the API function for this */
BKE_pose_remove_group_index(ob->pose, ob->pose->active_group);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
-
+
return OPERATOR_FINISHED;
}
@@ -118,11 +118,11 @@ void POSE_OT_group_remove(wmOperatorType *ot)
ot->name = "Remove Bone Group";
ot->idname = "POSE_OT_group_remove";
ot->description = "Remove the active bone group";
-
+
/* api callbacks */
ot->exec = pose_group_remove_exec;
ot->poll = ED_operator_posemode_context;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -135,14 +135,14 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
Object *ob = ED_pose_object_from_context(C);
bPose *pose;
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "type");
-
+
uiPopupMenu *pup;
uiLayout *layout;
bActionGroup *grp;
int i;
-
+
/* only continue if there's an object, and a pose there too */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
pose = ob->pose;
@@ -156,28 +156,28 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
return op->type->exec(C, op);
}
}
-
+
/* if there's no active group (or active is invalid), create a new menu to find it */
if (pose->active_group <= 0) {
/* create a new menu, and start populating it with group names */
pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE);
layout = UI_popup_menu_layout(pup);
-
- /* special entry - allow to create new group, then use that
+
+ /* special entry - allow to create new group, then use that
* (not to be used for removing though)
*/
if (strstr(op->idname, "assign")) {
uiItemIntO(layout, "New Group", ICON_NONE, op->idname, "type", 0);
uiItemS(layout);
}
-
+
/* add entries for each group */
for (grp = pose->agroups.first, i = 1; grp; grp = grp->next, i++)
uiItemIntO(layout, grp->name, ICON_NONE, op->idname, "type", i);
-
+
/* finish building the menu, and process it (should result in calling self again) */
UI_popup_menu_end(C, pup);
-
+
return OPERATOR_INTERFACE;
}
else {
@@ -199,14 +199,14 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
pose = ob->pose;
-
- /* set the active group number to the one from operator props
+
+ /* set the active group number to the one from operator props
* - if 0 after this, make a new group...
*/
pose->active_group = RNA_int_get(op->ptr, "type");
if (pose->active_group == 0)
BKE_pose_add_group(ob->pose, NULL);
-
+
/* add selected bones to group then */
FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob, pchan)
{
@@ -218,7 +218,7 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op)
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
-
+
/* report done status */
if (done)
return OPERATOR_FINISHED;
@@ -232,15 +232,15 @@ void POSE_OT_group_assign(wmOperatorType *ot)
ot->name = "Add Selected to Bone Group";
ot->idname = "POSE_OT_group_assign";
ot->description = "Add selected bones to the chosen bone group";
-
+
/* api callbacks */
ot->invoke = pose_groups_menu_invoke;
ot->exec = pose_group_assign_exec;
ot->poll = ED_operator_posemode_context;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_int(ot->srna, "type", 0, 0, INT_MAX, "Bone Group Index", "", 0, 10);
}
@@ -250,11 +250,11 @@ static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_pose_object_from_context(C);
bool done = false;
-
+
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
/* find selected bones to remove from all bone groups */
FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob, pchan)
{
@@ -264,11 +264,11 @@ static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op))
}
}
FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
-
+
/* report done status */
if (done)
return OPERATOR_FINISHED;
@@ -282,11 +282,11 @@ void POSE_OT_group_unassign(wmOperatorType *ot)
ot->name = "Remove Selected from Bone Groups";
ot->idname = "POSE_OT_group_unassign";
ot->description = "Remove selected bones from all bone groups";
-
+
/* api callbacks */
ot->exec = pose_group_unassign_exec;
ot->poll = ED_operator_posemode_context;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -442,16 +442,16 @@ void POSE_OT_group_sort(wmOperatorType *ot)
static void pose_group_select(Object *ob, bool select)
{
bPose *pose = ob->pose;
-
+
FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN (ob, pchan)
{
if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
if (select) {
- if (pchan->agrp_index == pose->active_group)
+ if (pchan->agrp_index == pose->active_group)
pchan->bone->flag |= BONE_SELECTED;
}
else {
- if (pchan->agrp_index == pose->active_group)
+ if (pchan->agrp_index == pose->active_group)
pchan->bone->flag &= ~BONE_SELECTED;
}
}
@@ -462,16 +462,16 @@ static void pose_group_select(Object *ob, bool select)
static int pose_group_select_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_pose_object_from_context(C);
-
+
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
pose_group_select(ob, 1);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -481,11 +481,11 @@ void POSE_OT_group_select(wmOperatorType *ot)
ot->name = "Select Bones of Bone Group";
ot->idname = "POSE_OT_group_select";
ot->description = "Select bones in active Bone Group";
-
+
/* api callbacks */
ot->exec = pose_group_select_exec;
ot->poll = ED_operator_posemode_context;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -493,16 +493,16 @@ void POSE_OT_group_select(wmOperatorType *ot)
static int pose_group_deselect_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_pose_object_from_context(C);
-
+
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
pose_group_select(ob, 0);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -512,11 +512,11 @@ void POSE_OT_group_deselect(wmOperatorType *ot)
ot->name = "Deselect Bone Group";
ot->idname = "POSE_OT_group_deselect";
ot->description = "Deselect bones of active Bone Group";
-
+
/* api callbacks */
ot->exec = pose_group_deselect_exec;
ot->poll = ED_operator_posemode_context;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index 609281a7bf2..b9c4584ff15 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -48,6 +48,7 @@
#include "BKE_armature.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
+#include "BKE_main.h"
#include "BKE_library.h"
#include "BKE_object.h"
@@ -81,9 +82,9 @@
static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUSED(c)) {}
/* ************************************************************* */
-/* == POSE-LIBRARY TOOL FOR BLENDER ==
- *
- * Overview:
+/* == POSE-LIBRARY TOOL FOR BLENDER ==
+ *
+ * Overview:
* This tool allows animators to store a set of frequently used poses to dump into
* the active action to help in "budget" productions to quickly block out new actions.
* It acts as a kind of "glorified clipboard for poses", allowing for naming of poses.
@@ -100,7 +101,7 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS
/* ************************************************************* */
-/* gets the first available frame in poselib to store a pose on
+/* gets the first available frame in poselib to store a pose on
* - frames start from 1, and a pose should occur on every frame... 0 is error!
*/
static int poselib_get_free_index(bAction *act)
@@ -108,17 +109,17 @@ static int poselib_get_free_index(bAction *act)
TimeMarker *marker;
int low = 0, high = 0;
bool changed = false;
-
+
/* sanity checks */
if (ELEM(NULL, act, act->markers.first)) return 1;
-
- /* As poses are not stored in chronological order, we must iterate over this list
+
+ /* As poses are not stored in chronological order, we must iterate over this list
* a few times until we don't make any new discoveries (mostly about the lower bound).
* Prevents problems with deleting then trying to add new poses [#27412]
*/
do {
changed = false;
-
+
for (marker = act->markers.first; marker; marker = marker->next) {
/* only increase low if value is 1 greater than low, to find "gaps" where
* poses were removed from the poselib
@@ -127,7 +128,7 @@ static int poselib_get_free_index(bAction *act)
low++;
changed = true;
}
-
+
/* value replaces high if it is the highest value encountered yet */
if (marker->frame > high) {
high = marker->frame;
@@ -135,19 +136,19 @@ static int poselib_get_free_index(bAction *act)
}
}
} while (changed != 0);
-
- /* - if low is not equal to high, then low+1 is a gap
- * - if low is equal to high, then high+1 is the next index (add at end)
+
+ /* - if low is not equal to high, then low+1 is a gap
+ * - if low is equal to high, then high+1 is the next index (add at end)
*/
- if (low < high)
+ if (low < high)
return (low + 1);
- else
+ else
return (high + 1);
}
/* returns the active pose for a poselib */
static TimeMarker *poselib_get_active_pose(bAction *act)
-{
+{
if ((act) && (act->active_marker))
return BLI_findlink(&act->markers, act->active_marker - 1);
else
@@ -159,14 +160,14 @@ static TimeMarker *poselib_get_active_pose(bAction *act)
static Object *get_poselib_object(bContext *C)
{
ScrArea *sa;
-
+
/* sanity check */
if (C == NULL)
return NULL;
-
+
sa = CTX_wm_area(C);
-
- if (sa && (sa->spacetype == SPACE_BUTS))
+
+ if (sa && (sa->spacetype == SPACE_BUTS))
return ED_object_context(C);
else
return BKE_object_pose_armature_get(CTX_data_active_object(C));
@@ -191,29 +192,29 @@ static int has_poselib_pose_data_for_editing_poll(bContext *C)
/* ----------------------------------- */
/* Initialize a new poselib (whether it is needed or not) */
-static bAction *poselib_init_new(Object *ob)
+static bAction *poselib_init_new(Main *bmain, Object *ob)
{
/* sanity checks - only for armatures */
if (ELEM(NULL, ob, ob->pose))
return NULL;
-
+
/* init object's poselib action (unlink old one if there) */
if (ob->poselib)
id_us_min(&ob->poselib->id);
-
- ob->poselib = BKE_action_add(G.main, "PoseLib");
+
+ ob->poselib = BKE_action_add(bmain, "PoseLib");
ob->poselib->idroot = ID_OB;
-
+
return ob->poselib;
}
/* Initialize a new poselib (checks if that needs to happen) */
-static bAction *poselib_validate(Object *ob)
+static bAction *poselib_validate(Main *bmain, Object *ob)
{
if (ELEM(NULL, ob, ob->pose))
return NULL;
else if (ob->poselib == NULL)
- return poselib_init_new(ob);
+ return poselib_init_new(bmain, ob);
else
return ob->poselib;
}
@@ -223,18 +224,19 @@ static bAction *poselib_validate(Object *ob)
static int poselib_new_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Main *bmain = CTX_data_main(C);
Object *ob = get_poselib_object(C);
-
+
/* sanity checks */
if (ob == NULL)
return OPERATOR_CANCELLED;
-
+
/* new method here deals with the rest... */
- poselib_init_new(ob);
-
+ poselib_init_new(bmain, ob);
+
/* notifier here might evolve? */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -244,11 +246,11 @@ void POSELIB_OT_new(wmOperatorType *ot)
ot->name = "New Pose Library";
ot->idname = "POSELIB_OT_new";
ot->description = "Add New Pose Library to active Object";
-
+
/* callbacks */
ot->exec = poselib_new_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -258,18 +260,18 @@ void POSELIB_OT_new(wmOperatorType *ot)
static int poselib_unlink_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = get_poselib_object(C);
-
+
/* sanity checks */
if (ELEM(NULL, ob, ob->poselib))
return OPERATOR_CANCELLED;
-
+
/* there should be a poselib (we just checked above!), so just lower its user count and remove */
id_us_min(&ob->poselib->id);
ob->poselib = NULL;
-
+
/* notifier here might evolve? */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -279,11 +281,11 @@ void POSELIB_OT_unlink(wmOperatorType *ot)
ot->name = "Unlink Pose Library";
ot->idname = "POSELIB_OT_unlink";
ot->description = "Remove Pose Library from active Object";
-
+
/* callbacks */
ot->exec = poselib_unlink_exec;
ot->poll = has_poselib_pose_data_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -291,7 +293,7 @@ void POSELIB_OT_unlink(wmOperatorType *ot)
/* ************************************************************* */
/* Pose Editing Operators */
-/* This tool automagically generates/validates poselib data so that it corresponds to the data
+/* This tool automagically generates/validates poselib data so that it corresponds to the data
* in the action. This is for use in making existing actions usable as poselibs.
*/
static int poselib_sanitize_exec(bContext *C, wmOperator *op)
@@ -301,13 +303,13 @@ static int poselib_sanitize_exec(bContext *C, wmOperator *op)
DLRBT_Tree keys;
ActKeyColumn *ak;
TimeMarker *marker, *markern;
-
+
/* validate action */
if (act == NULL) {
BKE_report(op->reports, RPT_WARNING, "No action to validate");
return OPERATOR_CANCELLED;
}
-
+
/* determine which frames have keys */
BLI_dlrbTree_init(&keys);
action_to_keylist(NULL, act, &keys, NULL);
@@ -323,39 +325,39 @@ static int poselib_sanitize_exec(bContext *C, wmOperator *op)
break;
}
}
-
+
/* add new if none found */
if (marker == NULL) {
/* add pose to poselib */
marker = MEM_callocN(sizeof(TimeMarker), "ActionMarker");
-
+
BLI_snprintf(marker->name, sizeof(marker->name), "F%d Pose", (int)ak->cfra);
-
+
marker->frame = (int)ak->cfra;
marker->flag = -1;
-
+
BLI_addtail(&act->markers, marker);
}
}
-
+
/* remove all untagged poses (unused), and remove all tags */
for (marker = act->markers.first; marker; marker = markern) {
markern = marker->next;
-
+
if (marker->flag != -1)
BLI_freelinkN(&act->markers, marker);
else
marker->flag = 0;
}
-
+
/* free temp memory */
BLI_dlrbTree_free(&keys);
-
- /* send notifiers for this - using keyframe editing notifiers, since action
- * may be being shown in anim editors as active action
+
+ /* send notifiers for this - using keyframe editing notifiers, since action
+ * may be being shown in anim editors as active action
*/
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -365,11 +367,11 @@ void POSELIB_OT_action_sanitize(wmOperatorType *ot)
ot->name = "Sanitize Pose Library Action";
ot->idname = "POSELIB_OT_action_sanitize";
ot->description = "Make action suitable for use as a Pose Library";
-
+
/* callbacks */
ot->exec = poselib_sanitize_exec;
ot->poll = has_poselib_pose_data_for_editing_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -400,14 +402,14 @@ static void poselib_add_menu_invoke__replacemenu(bContext *C, uiLayout *layout,
Object *ob = get_poselib_object(C);
bAction *act = ob->poselib; /* never NULL */
TimeMarker *marker;
-
+
wmOperatorType *ot = WM_operatortype_find("POSELIB_OT_pose_add", 1);
BLI_assert(ot != NULL);
/* set the operator execution context correctly */
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
-
+
/* add each marker to this menu */
for (marker = act->markers.first; marker; marker = marker->next) {
PointerRNA props_ptr;
@@ -427,30 +429,30 @@ static int poselib_add_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
bPose *pose = (ob) ? ob->pose : NULL;
uiPopupMenu *pup;
uiLayout *layout;
-
+
/* sanity check */
- if (ELEM(NULL, ob, pose))
+ if (ELEM(NULL, ob, pose))
return OPERATOR_CANCELLED;
-
+
/* start building */
pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE);
layout = UI_popup_menu_layout(pup);
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
-
+
/* add new (adds to the first unoccupied frame) */
uiItemIntO(layout, IFACE_("Add New"), ICON_NONE, "POSELIB_OT_pose_add", "frame", poselib_get_free_index(ob->poselib));
-
+
/* check if we have any choices to add a new pose in any other way */
if ((ob->poselib) && (ob->poselib->markers.first)) {
/* add new (on current frame) */
uiItemIntO(layout, IFACE_("Add New (Current Frame)"), ICON_NONE, "POSELIB_OT_pose_add", "frame", CFRA);
-
+
/* replace existing - submenu */
uiItemMenuF(layout, IFACE_("Replace Existing..."), 0, poselib_add_menu_invoke__replacemenu, NULL);
}
-
+
UI_popup_menu_end(C, pup);
-
+
/* this operator is only for a menu, not used further */
return OPERATOR_INTERFACE;
}
@@ -458,21 +460,22 @@ static int poselib_add_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
static int poselib_add_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Object *ob = get_poselib_object(C);
- bAction *act = poselib_validate(ob);
+ bAction *act = poselib_validate(bmain, ob);
bPose *pose = (ob) ? ob->pose : NULL;
TimeMarker *marker;
KeyingSet *ks;
int frame = RNA_int_get(op->ptr, "frame");
char name[64];
-
+
/* sanity check (invoke should have checked this anyway) */
- if (ELEM(NULL, ob, pose))
+ if (ELEM(NULL, ob, pose))
return OPERATOR_CANCELLED;
-
+
/* get name to give to pose */
RNA_string_get(op->ptr, "name", name);
-
+
/* add pose to poselib - replaces any existing pose there
* - for the 'replace' option, this should end up finding the appropriate marker,
* so no new one will be added
@@ -485,23 +488,24 @@ static int poselib_add_exec(bContext *C, wmOperator *op)
}
if (marker == NULL) {
marker = MEM_callocN(sizeof(TimeMarker), "ActionMarker");
-
+
BLI_strncpy(marker->name, name, sizeof(marker->name));
marker->frame = frame;
-
+
BLI_addtail(&act->markers, marker);
}
-
+
/* validate name */
BLI_uniquename(&act->markers, marker, DATA_("Pose"), '.', offsetof(TimeMarker, name), sizeof(marker->name));
-
+
/* use Keying Set to determine what to store for the pose */
ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_WHOLE_CHARACTER_SELECTED_ID); /* this includes custom props :)*/
ANIM_apply_keyingset(C, NULL, act, ks, MODIFYKEY_MODE_INSERT, (float)frame);
-
+
/* store new 'active' pose number */
act->active_marker = BLI_listbase_count(&act->markers);
-
+ DEG_id_tag_update(&act->id, DEG_TAG_COPY_ON_WRITE);
+
/* done */
return OPERATOR_FINISHED;
}
@@ -512,15 +516,15 @@ void POSELIB_OT_pose_add(wmOperatorType *ot)
ot->name = "PoseLib Add Pose";
ot->idname = "POSELIB_OT_pose_add";
ot->description = "Add the current Pose to the active Pose Library";
-
+
/* api callbacks */
ot->invoke = poselib_add_menu_invoke;
ot->exec = poselib_add_exec;
ot->poll = poselib_add_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_int(ot->srna, "frame", 1, 0, INT_MAX, "Frame", "Frame to store pose on", 0, INT_MAX);
RNA_def_string(ot->srna, "name", "Pose", 64, "Pose Name", "Name of newly added Pose");
@@ -541,7 +545,7 @@ static const EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA
if (C == NULL) {
return DummyRNA_NULL_items;
}
-
+
/* check that the action exists */
if (act) {
/* add each marker to the list */
@@ -588,12 +592,12 @@ static int poselib_remove_exec(bContext *C, wmOperator *op)
BKE_reportf(op->reports, RPT_ERROR, "Invalid pose specified %d", marker_index);
return OPERATOR_CANCELLED;
}
-
+
/* remove relevant keyframes */
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
BezTriple *bezt;
unsigned int i;
-
+
if (fcu->bezt) {
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
/* check if remove */
@@ -604,18 +608,19 @@ static int poselib_remove_exec(bContext *C, wmOperator *op)
}
}
}
-
+
/* remove poselib from list */
BLI_freelinkN(&act->markers, marker);
-
+
/* fix active pose number */
act->active_marker = 0;
-
- /* send notifiers for this - using keyframe editing notifiers, since action
- * may be being shown in anim editors as active action
+
+ /* send notifiers for this - using keyframe editing notifiers, since action
+ * may be being shown in anim editors as active action
*/
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+ DEG_id_tag_update(&act->id, DEG_TAG_COPY_ON_WRITE);
+
/* done */
return OPERATOR_FINISHED;
}
@@ -623,20 +628,20 @@ static int poselib_remove_exec(bContext *C, wmOperator *op)
void POSELIB_OT_pose_remove(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "PoseLib Remove Pose";
ot->idname = "POSELIB_OT_pose_remove";
ot->description = "Remove nth pose from the active Pose Library";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = poselib_remove_exec;
ot->poll = has_poselib_pose_data_for_editing_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
prop = RNA_def_enum(ot->srna, "pose", DummyRNA_NULL_items, 0, "Pose", "The pose to remove");
RNA_def_enum_funcs(prop, poselib_stored_pose_itemf);
@@ -649,13 +654,13 @@ static int poselib_rename_invoke(bContext *C, wmOperator *op, const wmEvent *eve
Object *ob = get_poselib_object(C);
bAction *act = (ob) ? ob->poselib : NULL;
TimeMarker *marker;
-
+
/* check if valid poselib */
if (act == NULL) {
BKE_report(op->reports, RPT_ERROR, "Object does not have pose lib data");
return OPERATOR_CANCELLED;
}
-
+
/* get index (and pointer) of pose to remove */
marker = BLI_findlink(&act->markers, act->active_marker - 1);
if (marker == NULL) {
@@ -667,7 +672,7 @@ static int poselib_rename_invoke(bContext *C, wmOperator *op, const wmEvent *eve
RNA_enum_set(op->ptr, "pose", act->active_marker - 1);
RNA_string_set(op->ptr, "name", marker->name);
}
-
+
/* part to sync with other similar operators... */
return WM_operator_props_popup_confirm(C, op, event);
}
@@ -678,32 +683,32 @@ static int poselib_rename_exec(bContext *C, wmOperator *op)
bAction *act = (ob) ? ob->poselib : NULL;
TimeMarker *marker;
char newname[64];
-
+
/* check if valid poselib */
if (act == NULL) {
BKE_report(op->reports, RPT_ERROR, "Object does not have pose lib data");
return OPERATOR_CANCELLED;
}
-
+
/* get index (and pointer) of pose to remove */
marker = BLI_findlink(&act->markers, RNA_enum_get(op->ptr, "pose"));
if (marker == NULL) {
BKE_report(op->reports, RPT_ERROR, "Invalid index for pose");
return OPERATOR_CANCELLED;
}
-
+
/* get new name */
RNA_string_get(op->ptr, "name", newname);
-
+
/* copy name and validate it */
BLI_strncpy(marker->name, newname, sizeof(marker->name));
BLI_uniquename(&act->markers, marker, DATA_("Pose"), '.', offsetof(TimeMarker, name), sizeof(marker->name));
-
- /* send notifiers for this - using keyframe editing notifiers, since action
- * may be being shown in anim editors as active action
+
+ /* send notifiers for this - using keyframe editing notifiers, since action
+ * may be being shown in anim editors as active action
*/
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -711,20 +716,20 @@ static int poselib_rename_exec(bContext *C, wmOperator *op)
void POSELIB_OT_pose_rename(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "PoseLib Rename Pose";
ot->idname = "POSELIB_OT_pose_rename";
ot->description = "Rename specified pose from the active Pose Library";
-
+
/* api callbacks */
ot->invoke = poselib_rename_invoke;
ot->exec = poselib_rename_exec;
ot->poll = has_poselib_pose_data_for_editing_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
/* NOTE: name not pose is the operator's "main" property, so that it will get activated in the popup for easy renaming */
ot->prop = RNA_def_string(ot->srna, "name", "RenamedPose", 64, "New Pose Name", "New name for pose");
@@ -823,10 +828,10 @@ void POSELIB_OT_pose_move(wmOperatorType *ot)
typedef struct tPoseLib_PreviewData {
ListBase backups; /* tPoseLib_Backup structs for restoring poses */
ListBase searchp; /* LinkData structs storing list of poses which match the current search-string */
-
+
Scene *scene; /* active scene */
ScrArea *sa; /* active area */
-
+
PointerRNA rna_ptr; /* RNA-Pointer to Object 'ob' */
Object *ob; /* object to work on */
bArmature *arm; /* object's armature data */
@@ -843,7 +848,7 @@ typedef struct tPoseLib_PreviewData {
short search_cursor; /* position of cursor in searchstr (cursor occurs before the item at the nominated index) */
char searchstr[64]; /* (Part of) Name to search for to filter poses that get shown */
char searchold[64]; /* Previously set searchstr (from last loop run), so that we can detected when to rebuild searchp */
-
+
char headerstr[UI_MAX_DRAW_STR]; /* Info-text to print in header */
} tPoseLib_PreviewData;
@@ -853,7 +858,7 @@ enum {
PL_PREVIEW_RUNNING,
PL_PREVIEW_CONFIRM,
PL_PREVIEW_CANCEL,
- PL_PREVIEW_RUNONCE
+ PL_PREVIEW_RUNONCE
};
/* defines for tPoseLib_PreviewData->redraw values */
@@ -875,9 +880,9 @@ enum {
/* simple struct for storing backup info */
typedef struct tPoseLib_Backup {
struct tPoseLib_Backup *next, *prev;
-
+
bPoseChannel *pchan; /* pose channel backups are for */
-
+
bPoseChannel olddata; /* copy of pose channel's old data (at start) */
IDProperty *oldprops; /* copy (needs freeing) of pose channel's properties (at start) */
} tPoseLib_Backup;
@@ -905,22 +910,22 @@ static void poselib_backup_posecopy(tPoseLib_PreviewData *pld)
for (agrp = pld->act->groups.first; agrp; agrp = agrp->next) {
/* try to find posechannel */
pchan = BKE_pose_channel_find_name(pld->pose, agrp->name);
-
+
/* backup data if available */
if (pchan) {
tPoseLib_Backup *plb;
-
+
/* store backup */
plb = MEM_callocN(sizeof(tPoseLib_Backup), "tPoseLib_Backup");
-
+
plb->pchan = pchan;
memcpy(&plb->olddata, plb->pchan, sizeof(bPoseChannel));
-
+
if (pchan->prop)
plb->oldprops = IDP_CopyProperty(pchan->prop);
-
+
BLI_addtail(&pld->backups, plb);
-
+
/* mark as being affected */
pld->totcount++;
}
@@ -931,7 +936,7 @@ static void poselib_backup_posecopy(tPoseLib_PreviewData *pld)
static void poselib_backup_restore(tPoseLib_PreviewData *pld)
{
tPoseLib_Backup *plb;
-
+
for (plb = pld->backups.first; plb; plb = plb->next) {
/* copy most of data straight back */
memcpy(plb->pchan, &plb->olddata, sizeof(bPoseChannel));
@@ -957,7 +962,7 @@ static void poselib_backup_free_data(tPoseLib_PreviewData *pld)
IDP_FreeProperty(plb->oldprops);
MEM_freeN(plb->oldprops);
}
-
+
/* free backup element now */
BLI_freelinkN(&pld->backups, plb);
}
@@ -978,19 +983,19 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld)
bPoseChannel *pchan;
bAction *act = pld->act;
bActionGroup *agrp;
-
+
KeyframeEditData ked = {{NULL}};
KeyframeEditFunc group_ok_cb;
int frame = 1;
const bool any_bone_selected = pld->flag & PL_PREVIEW_ANY_BONE_SELECTED;
-
+
/* get the frame */
if (pld->marker)
frame = pld->marker->frame;
else
return;
-
-
+
+
/* init settings for testing groups for keyframes */
group_ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
ked.f1 = ((float)frame) - 0.5f;
@@ -1002,10 +1007,10 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld)
if (ANIM_animchanneldata_keyframes_loop(&ked, NULL, agrp, ALE_GROUP, NULL, group_ok_cb, NULL)) {
/* has keyframe on this frame, so try to get a PoseChannel with this name */
pchan = BKE_pose_channel_find_name(pose, agrp->name);
-
+
if (pchan) {
bool ok = 0;
-
+
/* check if this bone should get any animation applied */
if (!any_bone_selected) {
/* if no bones are selected, then any bone is ok */
@@ -1021,7 +1026,7 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld)
}
}
- if (ok)
+ if (ok)
animsys_evaluate_action_group(ptr, act, agrp, NULL, (float)frame);
}
}
@@ -1035,7 +1040,7 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData
bPoseChannel *pchan;
bAction *act = pld->act;
bActionGroup *agrp;
-
+
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID);
ListBase dsources = {NULL, NULL};
bool autokey = autokeyframe_cfra_can_key(scene, &pld->ob->id);
@@ -1045,13 +1050,13 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
/* only for selected bones unless there aren't any selected, in which case all are included */
pchan = BKE_pose_channel_find_name(pose, agrp->name);
-
+
if (pchan) {
if (!any_bone_selected || ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED))) {
if (autokey) {
/* add datasource override for the PoseChannel, to be used later */
- ANIM_relative_keyingset_add_source(&dsources, &pld->ob->id, &RNA_PoseBone, pchan);
-
+ ANIM_relative_keyingset_add_source(&dsources, &pld->ob->id, &RNA_PoseBone, pchan);
+
/* clear any unkeyed tags */
if (pchan->bone)
pchan->bone->flag &= ~BONE_UNKEYED;
@@ -1064,14 +1069,14 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData
}
}
}
-
+
/* perform actual auto-keying now */
if (autokey) {
/* insert keyframes for all relevant bones in one go */
ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
BLI_freelistN(&dsources);
}
-
+
/* send notifiers for this */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
@@ -1080,7 +1085,7 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData
static void poselib_preview_apply(bContext *C, wmOperator *op)
{
tPoseLib_PreviewData *pld = (tPoseLib_PreviewData *)op->customdata;
-
+
/* only recalc pose (and its dependencies) if pose has changed */
if (pld->redraw == PL_PREVIEW_REDRAWALL) {
/* don't clear pose if firsttime */
@@ -1088,7 +1093,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
poselib_backup_restore(pld);
else
pld->flag &= ~PL_PREVIEW_FIRSTTIME;
-
+
/* pose should be the right one to draw (unless we're temporarily not showing it) */
if ((pld->flag & PL_PREVIEW_SHOWORIGINAL) == 0) {
RNA_int_set(op->ptr, "pose_index", BLI_findindex(&pld->act->markers, pld->marker));
@@ -1096,8 +1101,8 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
}
else
RNA_int_set(op->ptr, "pose_index", -2); /* -2 means don't apply any pose */
-
- /* old optimize trick... this enforces to bypass the depgraph
+
+ /* old optimize trick... this enforces to bypass the depgraph
* - note: code copied from transform_generics.c -> recalcData()
*/
// FIXME: shouldn't this use the builtin stuff?
@@ -1106,7 +1111,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
else
BKE_pose_where_is(CTX_data_depsgraph(C), pld->scene, pld->ob);
}
-
+
/* do header print - if interactively previewing */
if (pld->state == PL_PREVIEW_RUNNING) {
if (pld->flag & PL_PREVIEW_SHOWORIGINAL) {
@@ -1119,10 +1124,10 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
char tempstr[65];
char markern[64];
short index;
-
+
/* get search-string */
index = pld->search_cursor;
-
+
if (index >= 0 && index < sizeof(tempstr) - 1) {
memcpy(&tempstr[0], &pld->searchstr[0], index);
tempstr[index] = '|';
@@ -1131,7 +1136,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
else {
BLI_strncpy(tempstr, pld->searchstr, sizeof(tempstr));
}
-
+
/* get marker name */
BLI_strncpy(markern, pld->marker ? pld->marker->name : "No Matches", sizeof(markern));
@@ -1150,7 +1155,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
ED_area_headerprint(pld->sa, pld->headerstr);
}
}
-
+
/* request drawing of view + clear redraw flag */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, pld->ob);
pld->redraw = PL_PREVIEW_NOREDRAW;
@@ -1158,7 +1163,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
/* ---------------------------- */
-/* This helper function is called during poselib_preview_poses to find the
+/* This helper function is called during poselib_preview_poses to find the
* pose to preview next (after a change event)
*/
static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
@@ -1166,20 +1171,20 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
/* stop if not going anywhere, as we assume that there is a direction to move in */
if (step == 0)
return;
-
+
/* search-string dictates a special approach */
if (pld->searchstr[0]) {
TimeMarker *marker;
LinkData *ld, *ldn, *ldc;
-
+
/* free and rebuild if needed (i.e. if search-str changed) */
if (!STREQ(pld->searchstr, pld->searchold)) {
/* free list of temporary search matches */
BLI_freelistN(&pld->searchp);
-
+
/* generate a new list of search matches */
for (marker = pld->act->markers.first; marker; marker = marker->next) {
- /* does the name partially match?
+ /* does the name partially match?
* - don't worry about case, to make it easier for users to quickly input a name (or
* part of one), which is the whole point of this feature
*/
@@ -1190,17 +1195,17 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
BLI_addtail(&pld->searchp, ld);
}
}
-
+
/* set current marker to NULL (so that we start from first) */
pld->marker = NULL;
}
-
+
/* check if any matches */
if (BLI_listbase_is_empty(&pld->searchp)) {
pld->marker = NULL;
return;
}
-
+
/* find first match */
for (ldc = pld->searchp.first; ldc; ldc = ldc->next) {
if (ldc->data == pld->marker)
@@ -1208,8 +1213,8 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
}
if (ldc == NULL)
ldc = pld->searchp.first;
-
- /* Loop through the matches in a cyclic fashion, incrementing/decrementing step as appropriate
+
+ /* Loop through the matches in a cyclic fashion, incrementing/decrementing step as appropriate
* until step == 0. At this point, marker should be the correct marker.
*/
if (step > 0) {
@@ -1220,19 +1225,19 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
for (ld = ldc; ld && step; ld = ldn, step++)
ldn = (ld->prev) ? ld->prev : pld->searchp.last;
}
-
+
/* set marker */
if (ld)
pld->marker = ld->data;
}
else {
TimeMarker *marker, *next;
-
+
/* if no marker, because we just ended searching, then set that to the start of the list */
if (pld->marker == NULL)
pld->marker = pld->act->markers.first;
-
- /* Loop through the markers in a cyclic fashion, incrementing/decrementing step as appropriate
+
+ /* Loop through the markers in a cyclic fashion, incrementing/decrementing step as appropriate
* until step == 0. At this point, marker should be the correct marker.
*/
if (step > 0) {
@@ -1243,7 +1248,7 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
for (marker = pld->marker; marker && step; marker = next, step++)
next = (marker->prev) ? marker->prev : pld->act->markers.last;
}
-
+
/* it should be fairly impossible for marker to be NULL */
if (marker)
pld->marker = marker;
@@ -1260,28 +1265,28 @@ static void poselib_preview_handle_search(tPoseLib_PreviewData *pld, unsigned sh
short len = strlen(pld->searchstr);
short index = pld->search_cursor;
short i;
-
- for (i = index; i <= len; i++)
+
+ for (i = index; i <= len; i++)
pld->searchstr[i - 1] = pld->searchstr[i];
-
+
pld->search_cursor--;
-
+
poselib_preview_get_next(pld, 1);
pld->redraw = PL_PREVIEW_REDRAWALL;
return;
}
break;
-
+
case DELKEY:
if (pld->searchstr[0] && pld->searchstr[1]) {
short len = strlen(pld->searchstr);
short index = pld->search_cursor;
int i;
-
+
if (index < len) {
- for (i = index; i < len; i++)
+ for (i = index; i < len; i++)
pld->searchstr[i] = pld->searchstr[i + 1];
-
+
poselib_preview_get_next(pld, 1);
pld->redraw = PL_PREVIEW_REDRAWALL;
return;
@@ -1289,23 +1294,23 @@ static void poselib_preview_handle_search(tPoseLib_PreviewData *pld, unsigned sh
}
break;
}
-
+
if (ascii) {
/* character to add to the string */
short index = pld->search_cursor;
short len = (pld->searchstr[0]) ? strlen(pld->searchstr) : 0;
short i;
-
+
if (len) {
- for (i = len; i > index; i--)
+ for (i = len; i > index; i--)
pld->searchstr[i] = pld->searchstr[i - 1];
}
else
pld->searchstr[1] = 0;
-
+
pld->searchstr[index] = ascii;
pld->search_cursor++;
-
+
poselib_preview_get_next(pld, 1);
pld->redraw = PL_PREVIEW_REDRAWALL;
}
@@ -1316,18 +1321,18 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
{
tPoseLib_PreviewData *pld = op->customdata;
int ret = OPERATOR_RUNNING_MODAL;
-
+
/* only accept 'press' event, and ignore 'release', so that we don't get double actions */
if (ELEM(event->val, KM_PRESS, KM_NOTHING) == 0) {
//printf("PoseLib: skipping event with type '%s' and val %d\n", WM_key_event_string(event->type, false), event->val);
- return ret;
+ return ret;
}
-
+
/* backup stuff that needs to occur before every operation
* - make a copy of searchstr, so that we know if cache needs to be rebuilt
*/
BLI_strncpy(pld->searchold, pld->searchstr, sizeof(pld->searchold));
-
+
/* if we're currently showing the original pose, only certain events are handled */
if (pld->flag & PL_PREVIEW_SHOWORIGINAL) {
switch (event->type) {
@@ -1336,7 +1341,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
case RIGHTMOUSE:
pld->state = PL_PREVIEW_CANCEL;
break;
-
+
/* exit - confirm */
case LEFTMOUSE:
case RETKEY:
@@ -1344,30 +1349,30 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
case SPACEKEY:
pld->state = PL_PREVIEW_CONFIRM;
break;
-
+
/* view manipulation */
- /* we add pass through here, so that the operators responsible for these can still run,
+ /* we add pass through here, so that the operators responsible for these can still run,
* even though we still maintain control (as RUNNING_MODAL flag is still set too)
*/
case PAD0: case PAD1: case PAD2: case PAD3: case PAD4:
case PAD5: case PAD6: case PAD7: case PAD8: case PAD9:
- case PADPLUSKEY: case PADMINUS:
+ case PADPLUSKEY: case PADMINUS:
case MIDDLEMOUSE: case MOUSEMOVE:
//pld->redraw = PL_PREVIEW_REDRAWHEADER;
ret = OPERATOR_PASS_THROUGH;
break;
-
+
/* quicky compare to original */
case TABKEY:
pld->flag &= ~PL_PREVIEW_SHOWORIGINAL;
pld->redraw = PL_PREVIEW_REDRAWALL;
break;
}
-
+
/* EXITS HERE... */
return ret;
}
-
+
/* NORMAL EVENT HANDLING... */
/* searching takes priority over normal activity */
switch (event->type) {
@@ -1376,7 +1381,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
case RIGHTMOUSE:
pld->state = PL_PREVIEW_CANCEL;
break;
-
+
/* exit - confirm */
case LEFTMOUSE:
case RETKEY:
@@ -1384,39 +1389,39 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
case SPACEKEY:
pld->state = PL_PREVIEW_CONFIRM;
break;
-
+
/* toggle between original pose and poselib pose*/
case TABKEY:
pld->flag |= PL_PREVIEW_SHOWORIGINAL;
pld->redraw = PL_PREVIEW_REDRAWALL;
break;
-
+
/* change to previous pose (cyclic) */
case PAGEUPKEY:
case WHEELUPMOUSE:
poselib_preview_get_next(pld, -1);
pld->redraw = PL_PREVIEW_REDRAWALL;
break;
-
+
/* change to next pose (cyclic) */
case PAGEDOWNKEY:
case WHEELDOWNMOUSE:
poselib_preview_get_next(pld, 1);
pld->redraw = PL_PREVIEW_REDRAWALL;
break;
-
+
/* jump 5 poses (cyclic, back) */
case DOWNARROWKEY:
poselib_preview_get_next(pld, -5);
pld->redraw = PL_PREVIEW_REDRAWALL;
break;
-
+
/* jump 5 poses (cyclic, forward) */
case UPARROWKEY:
poselib_preview_get_next(pld, 5);
pld->redraw = PL_PREVIEW_REDRAWALL;
break;
-
+
/* change to next pose or searching cursor control */
case RIGHTARROWKEY:
if (pld->searchstr[0]) {
@@ -1431,7 +1436,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
pld->redraw = PL_PREVIEW_REDRAWALL;
}
break;
-
+
/* change to next pose or searching cursor control */
case LEFTARROWKEY:
if (pld->searchstr[0]) {
@@ -1446,7 +1451,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
pld->redraw = PL_PREVIEW_REDRAWALL;
}
break;
-
+
/* change to first pose or start of searching string */
case HOMEKEY:
if (pld->searchstr[0]) {
@@ -1457,11 +1462,11 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
/* change to first pose */
pld->marker = pld->act->markers.first;
pld->act->active_marker = 1;
-
+
pld->redraw = PL_PREVIEW_REDRAWALL;
}
break;
-
+
/* change to last pose or start of searching string */
case ENDKEY:
if (pld->searchstr[0]) {
@@ -1472,20 +1477,20 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
/* change to last pose */
pld->marker = pld->act->markers.last;
pld->act->active_marker = BLI_listbase_count(&pld->act->markers);
-
+
pld->redraw = PL_PREVIEW_REDRAWALL;
}
break;
-
+
/* view manipulation */
- /* we add pass through here, so that the operators responsible for these can still run,
+ /* we add pass through here, so that the operators responsible for these can still run,
* even though we still maintain control (as RUNNING_MODAL flag is still set too)
*/
case MIDDLEMOUSE: case MOUSEMOVE:
//pld->redraw = PL_PREVIEW_REDRAWHEADER;
ret = OPERATOR_PASS_THROUGH;
break;
-
+
/* view manipulation, or searching */
case PAD0: case PAD1: case PAD2: case PAD3: case PAD4:
case PAD5: case PAD6: case PAD7: case PAD8: case PAD9:
@@ -1500,13 +1505,13 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
ret = OPERATOR_PASS_THROUGH;
}
break;
-
+
/* otherwise, assume that searching might be able to handle it */
default:
poselib_preview_handle_search(pld, event->type, event->ascii);
break;
}
-
+
return ret;
}
@@ -1518,19 +1523,19 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op)
tPoseLib_PreviewData *pld;
Object *ob = get_poselib_object(C);
int pose_index = RNA_int_get(op->ptr, "pose_index");
-
+
/* set up preview state info */
op->customdata = pld = MEM_callocN(sizeof(tPoseLib_PreviewData), "PoseLib Preview Data");
-
+
/* get basic data */
pld->ob = ob;
pld->arm = (ob) ? (ob->data) : NULL;
pld->pose = (ob) ? (ob->pose) : NULL;
pld->act = (ob) ? (ob->poselib) : NULL;
-
+
pld->scene = CTX_data_scene(C);
pld->sa = CTX_wm_area(C);
-
+
/* get starting pose based on RNA-props for this operator */
if (pose_index == -1)
pld->marker = poselib_get_active_pose(pld->act);
@@ -1538,7 +1543,7 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op)
pld->flag |= PL_PREVIEW_SHOWORIGINAL;
else
pld->marker = (pld->act) ? BLI_findlink(&pld->act->markers, pose_index) : NULL;
-
+
/* check if valid poselib */
if (ELEM(NULL, pld->ob, pld->pose, pld->arm)) {
BKE_report(op->reports, RPT_ERROR, "Pose lib is only for armatures in pose mode");
@@ -1554,7 +1559,7 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op)
if (pld->act->markers.first) {
/* just use first one then... */
pld->marker = pld->act->markers.first;
- if (pose_index > -2)
+ if (pose_index > -2)
BKE_report(op->reports, RPT_WARNING, "Pose lib had no active pose");
}
else {
@@ -1563,23 +1568,23 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op)
return;
}
}
-
+
/* get ID pointer for applying poses */
RNA_id_pointer_create(&ob->id, &pld->rna_ptr);
-
+
/* make backups for restoring pose */
poselib_backup_posecopy(pld);
-
+
/* set flags for running */
pld->state = PL_PREVIEW_RUNNING;
pld->redraw = PL_PREVIEW_REDRAWALL;
pld->flag |= PL_PREVIEW_FIRSTTIME;
-
+
/* set depsgraph flags */
/* make sure the lock is set OK, unlock can be accidentally saved? */
pld->pose->flag |= POSE_LOCKED;
pld->pose->flag &= ~POSE_DO_UNLOCK;
-
+
/* clear strings + search */
pld->headerstr[0] = pld->searchstr[0] = pld->searchold[0] = '\0';
pld->search_cursor = 0;
@@ -1595,18 +1600,18 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
bArmature *arm = pld->arm;
bAction *act = pld->act;
TimeMarker *marker = pld->marker;
-
+
/* redraw the header so that it doesn't show any of our stuff anymore */
ED_area_headerprint(pld->sa, NULL);
-
+
/* this signal does one recalc on pose, then unlocks, so ESC or edit will work */
pose->flag |= POSE_DO_UNLOCK;
-
+
/* clear pose if canceled */
if (pld->state == PL_PREVIEW_CANCEL) {
poselib_backup_restore(pld);
-
- /* old optimize trick... this enforces to bypass the depgraph
+
+ /* old optimize trick... this enforces to bypass the depgraph
* - note: code copied from transform_generics.c -> recalcData()
*/
if ((arm->flag & ARM_DELAYDEFORM) == 0)
@@ -1617,14 +1622,14 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
else if (pld->state == PL_PREVIEW_CONFIRM) {
/* tag poses as appropriate */
poselib_keytag_pose(C, scene, pld);
-
+
/* change active pose setting */
act->active_marker = BLI_findindex(&act->markers, marker) + 1;
action_set_activemarker(act, marker, NULL);
-
+
/* Update event for pose and deformation children */
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
-
+
/* updates */
if (IS_AUTOKEY_MODE(scene, NORMAL)) {
//remake_action_ipos(ob->action);
@@ -1632,14 +1637,14 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
else
BKE_pose_where_is(CTX_data_depsgraph(C), scene, ob);
}
-
+
/* Request final redraw of the view. */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, pld->ob);
-
+
/* free memory used for backups and searching */
poselib_backup_free_data(pld);
BLI_freelistN(&pld->searchp);
-
+
/* free temp data for operator */
MEM_freeN(pld);
op->customdata = NULL;
@@ -1650,10 +1655,10 @@ static int poselib_preview_exit(bContext *C, wmOperator *op)
{
tPoseLib_PreviewData *pld = op->customdata;
int exit_state = pld->state;
-
+
/* finish up */
poselib_preview_cleanup(C, op);
-
+
if (ELEM(exit_state, PL_PREVIEW_CANCEL, PL_PREVIEW_ERROR))
return OPERATOR_CANCELLED;
else
@@ -1671,18 +1676,18 @@ static int poselib_preview_modal(bContext *C, wmOperator *op, const wmEvent *eve
{
tPoseLib_PreviewData *pld = op->customdata;
int ret;
-
+
/* 1) check state to see if we're still running */
if (pld->state != PL_PREVIEW_RUNNING)
return poselib_preview_exit(C, op);
-
+
/* 2) handle events */
ret = poselib_preview_handle_event(C, op, event);
-
+
/* 3) apply changes and redraw, otherwise, confirming goes wrong */
if (pld->redraw)
poselib_preview_apply(C, op);
-
+
return ret;
}
@@ -1690,20 +1695,20 @@ static int poselib_preview_modal(bContext *C, wmOperator *op, const wmEvent *eve
static int poselib_preview_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
tPoseLib_PreviewData *pld;
-
+
/* check if everything is ok, and init settings for modal operator */
poselib_preview_init_data(C, op);
pld = (tPoseLib_PreviewData *)op->customdata;
-
+
if (pld->state == PL_PREVIEW_ERROR) {
/* an error occurred, so free temp mem used */
poselib_preview_cleanup(C, op);
return OPERATOR_CANCELLED;
}
-
+
/* do initial apply to have something to look at */
poselib_preview_apply(C, op);
-
+
/* add temp handler if we're running as a modal operator */
WM_event_add_modal_handler(C, op);
@@ -1714,28 +1719,28 @@ static int poselib_preview_invoke(bContext *C, wmOperator *op, const wmEvent *UN
static int poselib_preview_exec(bContext *C, wmOperator *op)
{
tPoseLib_PreviewData *pld;
-
+
/* check if everything is ok, and init settings for modal operator */
poselib_preview_init_data(C, op);
pld = (tPoseLib_PreviewData *)op->customdata;
-
+
if (pld->state == PL_PREVIEW_ERROR) {
/* an error occurred, so free temp mem used */
poselib_preview_cleanup(C, op);
return OPERATOR_CANCELLED;
}
-
+
/* the exec() callback is effectively a 'run-once' scenario, so set the state to that
* so that everything draws correctly
*/
pld->state = PL_PREVIEW_RUNONCE;
-
+
/* apply the active pose */
poselib_preview_apply(C, op);
-
+
/* now, set the status to exit */
pld->state = PL_PREVIEW_CONFIRM;
-
+
/* cleanup */
return poselib_preview_exit(C, op);
}
@@ -1746,21 +1751,21 @@ void POSELIB_OT_browse_interactive(wmOperatorType *ot)
ot->name = "PoseLib Browse Poses";
ot->idname = "POSELIB_OT_browse_interactive";
ot->description = "Interactively browse poses in 3D-View";
-
+
/* callbacks */
ot->invoke = poselib_preview_invoke;
ot->modal = poselib_preview_modal;
ot->cancel = poselib_preview_cancel;
ot->exec = poselib_preview_exec;
ot->poll = has_poselib_pose_data_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
-
+
/* properties */
// TODO: make the pose_index into a proper enum instead of a cryptic int...
ot->prop = RNA_def_int(ot->srna, "pose_index", -1, -2, INT_MAX, "Pose", "Index of the pose to apply (-2 for no change to pose, -1 for poselib active pose)", 0, INT_MAX);
-
+
// XXX: percentage vs factor?
/* not used yet */
/* RNA_def_float_factor(ot->srna, "blend_factor", 1.0f, 0.0f, 1.0f, "Blend Factor", "Amount that the pose is applied on top of the existing poses", 0.0f, 1.0f); */
@@ -1772,7 +1777,7 @@ void POSELIB_OT_apply_pose(wmOperatorType *ot)
ot->name = "Apply Pose Library Pose";
ot->idname = "POSELIB_OT_apply_pose";
ot->description = "Apply specified Pose Library pose to the rig";
-
+
/* callbacks */
ot->exec = poselib_preview_exec;
ot->poll = has_poselib_pose_data_poll;
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index f0dc680598c..75fd952b52a 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -103,9 +103,9 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
// XXX: actually, we can probably still get away with no object - at most we have no updates
if (ELEM(NULL, ob, ob->pose, pchan, pchan->bone))
return;
-
+
arm = ob->data;
-
+
/* can only change selection state if bone can be modified */
if (PBONE_SELECTABLE(arm, pchan->bone)) {
/* change selection state - activate too if selected */
@@ -117,19 +117,19 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
pchan->bone->flag &= ~BONE_SELECTED;
arm->act_bone = NULL;
}
-
+
// TODO: select and activate corresponding vgroup?
-
- /* tag necessary depsgraph updates
+
+ /* tag necessary depsgraph updates
* (see rna_Bone_select_update() in rna_armature.c for details)
*/
if (arm->flag & ARM_HAS_VIZ_DEPS) {
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
-
+
/* send necessary notifiers */
WM_main_add_notifier(NC_GEOM | ND_DATA, ob);
-
+
/* tag armature for copy-on-write update (since act_bone is in armature not object) */
DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
}
@@ -143,7 +143,7 @@ bool ED_armature_pose_select_pick_with_buffer(
{
Object *ob = base->object;
Bone *nearBone;
-
+
if (!ob || !ob->pose) return 0;
Object *ob_act = OBACT(view_layer);
@@ -152,11 +152,11 @@ bool ED_armature_pose_select_pick_with_buffer(
/* Callers happen to already get the active base */
Base *base_dummy = NULL;
nearBone = get_bone_from_selectbuffer(&base, 1, obedit != NULL, buffer, hits, 1, do_nearest, &base_dummy);
-
+
/* if the bone cannot be affected, don't do anything */
if ((nearBone) && !(nearBone->flag & BONE_UNSELECTABLE)) {
bArmature *arm = ob->data;
-
+
/* since we do unified select, we don't shift+select a bone if the
* armature object was not active yet.
* note, special exception for armature mode so we can do multi-select
@@ -205,7 +205,7 @@ bool ED_armature_pose_select_pick_with_buffer(
}
}
}
-
+
if (ob_act) {
/* in weightpaint we select the associated vertex group too */
if (ob_act->mode & OB_MODE_WEIGHT_PAINT) {
@@ -214,21 +214,21 @@ bool ED_armature_pose_select_pick_with_buffer(
DEG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
}
}
- /* if there are some dependencies for visualizing armature state
- * (e.g. Mask Modifier in 'Armature' mode), force update
+ /* if there are some dependencies for visualizing armature state
+ * (e.g. Mask Modifier in 'Armature' mode), force update
*/
else if (arm->flag & ARM_HAS_VIZ_DEPS) {
- /* NOTE: ob not ob_act here is intentional - it's the source of the
+ /* NOTE: ob not ob_act here is intentional - it's the source of the
* bones being selected [T37247]
*/
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
-
+
/* tag armature for copy-on-write update (since act_bone is in armature not object) */
DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
}
}
-
+
return nearBone != NULL;
}
@@ -238,12 +238,12 @@ void ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil
{
bArmature *arm = ob->data;
bPoseChannel *pchan;
-
+
/* we call this from outliner too */
if (ob->pose == NULL) {
return;
}
-
+
/* Determine if we're selecting or deselecting */
if (select_mode == SEL_TOGGLE) {
select_mode = SEL_SELECT;
@@ -256,7 +256,7 @@ void ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil
}
}
}
-
+
/* Set the flags accordingly */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
/* ignore the pchan if it isn't visible or if its selection cannot be changed */
@@ -300,9 +300,9 @@ void ED_pose_deselect_all_multi(Object **objects, uint objects_len, int select_m
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob_iter = objects[ob_index];
bArmature *arm = ob_iter->data;
-
+
ED_pose_deselect_all(ob_iter, select_mode, ignore_visibility);
-
+
/* if there are some dependencies for visualizing armature state
* (e.g. Mask Modifier in 'Armature' mode), force update
*/
@@ -312,7 +312,7 @@ void ED_pose_deselect_all_multi(Object **objects, uint objects_len, int select_m
*/
DEG_id_tag_update(&ob_iter->id, OB_RECALC_DATA);
}
-
+
/* need to tag armature for cow updates, or else selection doesn't update */
DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
}
@@ -323,16 +323,16 @@ void ED_pose_deselect_all_multi(Object **objects, uint objects_len, int select_m
static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend)
{
Bone *curBone;
-
+
/* stop when unconnected child is encountered, or when unselectable bone is encountered */
if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE))
return;
-
+
if (extend)
bone->flag &= ~BONE_SELECTED;
else
bone->flag |= BONE_SELECTED;
-
+
for (curBone = bone->childbase.first; curBone; curBone = curBone->next)
selectconnected_posebonechildren(ob, curBone, extend);
}
@@ -353,7 +353,7 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve
return OPERATOR_CANCELLED;
bArmature *arm = base->object->data;
-
+
/* Select parents */
for (curBone = bone; curBone; curBone = next) {
/* ignore bone if cannot be selected */
@@ -362,7 +362,7 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve
curBone->flag &= ~BONE_SELECTED;
else
curBone->flag |= BONE_SELECTED;
-
+
if (curBone->flag & BONE_CONNECTED)
next = curBone->parent;
else
@@ -371,19 +371,19 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve
else
next = NULL;
}
-
+
/* Select children */
for (curBone = bone->childbase.first; curBone; curBone = next)
selectconnected_posebonechildren(base->object, curBone, extend);
-
+
/* updates */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, base->object);
-
+
if (arm->flag & ARM_HAS_VIZ_DEPS) {
/* mask modifier ('armature' mode), etc. */
DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
}
-
+
/* need to tag armature for cow updates, or else selection doesn't update */
DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
@@ -401,15 +401,15 @@ void POSE_OT_select_linked(wmOperatorType *ot)
ot->name = "Select Connected";
ot->idname = "POSE_OT_select_linked";
ot->description = "Select bones related to selected ones by parent/child relationships";
-
+
/* callbacks */
/* leave 'exec' unset */
ot->invoke = pose_select_connected_invoke;
ot->poll = pose_select_linked_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first");
}
@@ -419,7 +419,7 @@ void POSE_OT_select_linked(wmOperatorType *ot)
static int pose_de_select_all_exec(bContext *C, wmOperator *op)
{
int action = RNA_enum_get(op->ptr, "action");
-
+
Scene *scene = CTX_data_scene(C);
int multipaint = scene->toolsettings->multipaint;
@@ -428,7 +428,7 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
}
Object *ob_prev = NULL;
-
+
/* Set the flags */
CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob)
{
@@ -458,14 +458,14 @@ void POSE_OT_select_all(wmOperatorType *ot)
ot->name = "(De)select All";
ot->idname = "POSE_OT_select_all";
ot->description = "Toggle selection status of all bones";
-
+
/* api callbacks */
ot->exec = pose_de_select_all_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
WM_operator_properties_select_all(ot);
}
@@ -546,10 +546,10 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
-
+
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
-
+
for (ct = targets.first; ct; ct = ct->next) {
if ((ct->tar == ob) && (ct->subtarget[0])) {
bPoseChannel *pchanc = BKE_pose_channel_find_name(ob->pose, ct->subtarget);
@@ -571,7 +571,7 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op
}
}
}
-
+
if (cti->flush_constraint_targets)
cti->flush_constraint_targets(con, &targets, 1);
}
@@ -579,10 +579,10 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op
}
}
CTX_DATA_END;
-
+
if (!found)
return OPERATOR_CANCELLED;
-
+
return OPERATOR_FINISHED;
}
@@ -592,11 +592,11 @@ void POSE_OT_select_constraint_target(wmOperatorType *ot)
ot->name = "Select Constraint Target";
ot->idname = "POSE_OT_select_constraint_target";
ot->description = "Select bones used as targets for the currently selected bones";
-
+
/* api callbacks */
ot->exec = pose_select_constraint_target_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -611,7 +611,7 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
int direction = RNA_enum_get(op->ptr, "direction");
const bool add_to_sel = RNA_boolean_get(op->ptr, "extend");
bool changed = false;
-
+
pchan_act = BKE_pose_channel_active(ob);
if (pchan_act == NULL) {
return OPERATOR_CANCELLED;
@@ -668,10 +668,10 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
if (changed == false) {
return OPERATOR_CANCELLED;
}
-
+
/* updates */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
if (arm->flag & ARM_HAS_VIZ_DEPS) {
/* mask modifier ('armature' mode), etc. */
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -690,19 +690,19 @@ void POSE_OT_select_hierarchy(wmOperatorType *ot)
{BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "Select Hierarchy";
ot->idname = "POSE_OT_select_hierarchy";
ot->description = "Select immediate parent/children of selected bones";
-
+
/* api callbacks */
ot->exec = pose_select_hierarchy_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
ot->prop = RNA_def_enum(ot->srna, "direction", direction_items, BONE_SELECT_PARENT, "Direction", "");
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
@@ -724,22 +724,22 @@ static bool pose_select_same_group(bContext *C, Object *ob, bool extend)
char *group_flags;
int numGroups = 0;
bool changed = false, tagged = false;
-
+
/* sanity checks */
if (ELEM(NULL, ob, pose, arm))
return 0;
-
+
/* count the number of groups */
numGroups = BLI_listbase_count(&pose->agroups);
if (numGroups == 0)
return 0;
-
- /* alloc a small array to keep track of the groups to use
+
+ /* alloc a small array to keep track of the groups to use
* - each cell stores on/off state for whether group should be used
* - size is (numGroups + 1), since (index = 0) is used for no-group
*/
group_flags = MEM_callocN(numGroups + 1, "pose_select_same_group");
-
+
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
{
/* keep track of group as group to use later? */
@@ -747,13 +747,13 @@ static bool pose_select_same_group(bContext *C, Object *ob, bool extend)
group_flags[pchan->agrp_index] = 1;
tagged = true;
}
-
+
/* deselect all bones before selecting new ones? */
if ((extend == false) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0)
pchan->bone->flag &= ~BONE_SELECTED;
}
CTX_DATA_END;
-
+
/* small optimization: only loop through bones a second time if there are any groups tagged */
if (tagged) {
/* only if group matches (and is not selected or current bone) */
@@ -769,10 +769,10 @@ static bool pose_select_same_group(bContext *C, Object *ob, bool extend)
}
CTX_DATA_END;
}
-
+
/* free temp info */
MEM_freeN(group_flags);
-
+
return changed;
}
@@ -782,25 +782,25 @@ static bool pose_select_same_layer(bContext *C, Object *ob, bool extend)
bArmature *arm = (ob) ? ob->data : NULL;
bool changed = false;
int layers = 0;
-
+
if (ELEM(NULL, ob, pose, arm))
return 0;
-
+
/* figure out what bones are selected */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
{
/* keep track of layers to use later? */
if (pchan->bone->flag & BONE_SELECTED)
layers |= pchan->bone->layer;
-
+
/* deselect all bones before selecting new ones? */
if ((extend == false) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0)
pchan->bone->flag &= ~BONE_SELECTED;
}
CTX_DATA_END;
- if (layers == 0)
+ if (layers == 0)
return 0;
-
+
/* select bones that are on same layers as layers flag */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
{
@@ -811,7 +811,7 @@ static bool pose_select_same_layer(bContext *C, Object *ob, bool extend)
}
}
CTX_DATA_END;
-
+
return changed;
}
@@ -819,11 +819,11 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object
{
KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C));
KS_Path *ksp;
-
+
bArmature *arm = (ob) ? ob->data : NULL;
bPose *pose = (ob) ? ob->pose : NULL;
bool changed = false;
-
+
/* sanity checks: validate Keying Set and object */
if (ks == NULL) {
BKE_report(reports, RPT_ERROR, "No active Keying Set to use");
@@ -832,7 +832,7 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object
else if (ANIM_validate_keyingset(C, NULL, ks) != 0) {
if (ks->paths.first == NULL) {
if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) {
- BKE_report(reports, RPT_ERROR,
+ BKE_report(reports, RPT_ERROR,
"Use another Keying Set, as the active one depends on the currently "
"selected items or cannot find any targets due to unsuitable context");
}
@@ -842,10 +842,10 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object
}
return false;
}
-
+
if (ELEM(NULL, ob, pose, arm))
return false;
-
+
/* if not extending selection, deselect all selected first */
if (extend == false) {
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
@@ -855,8 +855,8 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object
}
CTX_DATA_END;
}
-
- /* iterate over elements in the Keying Set, setting selection depending on whether
+
+ /* iterate over elements in the Keying Set, setting selection depending on whether
* that bone is visible or not...
*/
for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
@@ -864,10 +864,10 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object
if ((ksp->id == &ob->id) && (ksp->rna_path != NULL)) {
if (strstr(ksp->rna_path, "bones")) {
char *boneName = BLI_str_quoted_substrN(ksp->rna_path, "bones[");
-
+
if (boneName) {
bPoseChannel *pchan = BKE_pose_channel_find_name(pose, boneName);
-
+
if (pchan) {
/* select if bone is visible and can be affected */
if (PBONE_SELECTABLE(arm, pchan->bone)) {
@@ -875,14 +875,14 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object
changed = true;
}
}
-
+
/* free temp memory */
MEM_freeN(boneName);
}
}
}
}
-
+
return changed;
}
@@ -893,41 +893,41 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op)
const ePose_SelectSame_Mode type = RNA_enum_get(op->ptr, "type");
const bool extend = RNA_boolean_get(op->ptr, "extend");
bool changed = false;
-
+
/* sanity check */
if (ob->pose == NULL)
return OPERATOR_CANCELLED;
-
+
/* selection types */
switch (type) {
case POSE_SEL_SAME_LAYER: /* layer */
changed = pose_select_same_layer(C, ob, extend);
break;
-
+
case POSE_SEL_SAME_GROUP: /* group */
changed = pose_select_same_group(C, ob, extend);
break;
-
+
case POSE_SEL_SAME_KEYINGSET: /* Keying Set */
changed = pose_select_same_keyingset(C, op->reports, ob, extend);
break;
-
+
default:
printf("pose_select_grouped() - Unknown selection type %u\n", type);
break;
}
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
if (arm->flag & ARM_HAS_VIZ_DEPS) {
/* mask modifier ('armature' mode), etc. */
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
-
+
/* need to tag armature for cow updates, or else selection doesn't update */
DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
-
+
/* report done status */
if (changed)
return OPERATOR_FINISHED;
@@ -948,15 +948,15 @@ void POSE_OT_select_grouped(wmOperatorType *ot)
ot->name = "Select Grouped";
ot->description = "Select all visible bones grouped by similar properties";
ot->idname = "POSE_OT_select_grouped";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = pose_select_grouped_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first");
ot->prop = RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", "");
@@ -1022,7 +1022,7 @@ static int pose_select_mirror_exec(bContext *C, wmOperator *op)
}
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
/* need to tag armature for cow updates, or else selection doesn't update */
DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
}
@@ -1037,11 +1037,11 @@ void POSE_OT_select_mirror(wmOperatorType *ot)
ot->name = "Flip Active/Selected Bone";
ot->idname = "POSE_OT_select_mirror";
ot->description = "Mirror the bone selection";
-
+
/* api callbacks */
ot->exec = pose_select_mirror_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index e5331aff12b..b82535f013b 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -63,7 +63,7 @@
#include "armature_intern.h"
/* **************************************************** */
-/* == POSE 'SLIDING' TOOLS ==
+/* == POSE 'SLIDING' TOOLS ==
*
* A) Push & Relax, Breakdowner
* These tools provide the animator with various capabilities
@@ -79,7 +79,7 @@
* C) Pose Sculpting
* This is yet to be implemented, but the idea here is to use
* sculpting techniques to make it easier to pose rigs by allowing
- * rigs to be manipulated using a familiar paint-based interface.
+ * rigs to be manipulated using a familiar paint-based interface.
*/
/* **************************************************** */
/* A) Push & Relax, Breakdowner */
@@ -96,21 +96,21 @@ typedef struct tPoseSlideOp {
DLRBT_Tree keys; /* binary tree for quicker searching for keyframes (when applicable) */
int cframe; /* current frame number - global time */
-
+
int prevFrame; /* frame before current frame (blend-from) - global time */
int nextFrame; /* frame after current frame (blend-to) - global time */
-
+
float prevFrameF; /* prevFrame, but in local action time (for F-Curve lookups to work) */
float nextFrameF; /* nextFrame, but in local action time (for F-Curve lookups to work) */
-
+
short mode; /* sliding mode (ePoseSlide_Modes) */
short flag; /* unused for now, but can later get used for storing runtime settings.... */
-
+
short channels; /* which transforms/channels are affected (ePoseSlide_Channels) */
short axislock; /* axis-limits for transforms (ePoseSlide_AxisLock) */
-
+
float percentage; /* 0-1 value for determining the influence of whatever is relevant */
-
+
NumInput num; /* numeric input */
} tPoseSlideOp;
@@ -125,19 +125,19 @@ typedef enum ePoseSlide_Modes {
/* Transforms/Channels to Affect */
typedef enum ePoseSlide_Channels {
PS_TFM_ALL = 0, /* All transforms and properties */
-
+
PS_TFM_LOC, /* Loc/Rot/Scale */
PS_TFM_ROT,
PS_TFM_SIZE,
-
+
PS_TFM_BBONE_SHAPE, /* Bendy Bones */
-
+
PS_TFM_PROPS /* Custom Properties */
} ePoseSlide_Channels;
/* Property enum for ePoseSlide_Channels */
static const EnumPropertyItem prop_channels_types[] = {
- {PS_TFM_ALL, "ALL", 0, "All Properties",
+ {PS_TFM_ALL, "ALL", 0, "All Properties",
"All properties, including transforms, bendy bone shape, and custom properties"},
{PS_TFM_LOC, "LOC", 0, "Location", "Location only"},
{PS_TFM_ROT, "ROT", 0, "Rotation", "Rotation only"},
@@ -171,60 +171,60 @@ static int pose_slide_init(bContext *C, wmOperator *op, short mode)
{
tPoseSlideOp *pso;
bAction *act = NULL;
-
+
/* init slide-op data */
pso = op->customdata = MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp");
-
+
/* get info from context */
pso->scene = CTX_data_scene(C);
pso->ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
pso->arm = (pso->ob) ? pso->ob->data : NULL;
pso->sa = CTX_wm_area(C); /* only really needed when doing modal() */
pso->ar = CTX_wm_region(C); /* only really needed when doing modal() */
-
+
pso->cframe = pso->scene->r.cfra;
pso->mode = mode;
-
+
/* set range info from property values - these may get overridden for the invoke() */
pso->percentage = RNA_float_get(op->ptr, "percentage");
pso->prevFrame = RNA_int_get(op->ptr, "prev_frame");
pso->nextFrame = RNA_int_get(op->ptr, "next_frame");
-
+
/* get the set of properties/axes that can be operated on */
pso->channels = RNA_enum_get(op->ptr, "channels");
pso->axislock = RNA_enum_get(op->ptr, "axis_lock");
-
+
/* ensure validity of the settings from the context */
if (ELEM(NULL, pso->ob, pso->arm, pso->ob->adt, pso->ob->adt->action))
return 0;
-
+
act = pso->ob->adt->action;
-
+
/* apply NLA mapping corrections so the frame lookups work */
pso->prevFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP);
pso->nextFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP);
-
- /* for each Pose-Channel which gets affected, get the F-Curves for that channel
+
+ /* for each Pose-Channel which gets affected, get the F-Curves for that channel
* and set the relevant transform flags...
*/
poseAnim_mapping_get(C, &pso->pfLinks, pso->ob, act);
-
+
/* set depsgraph flags */
/* make sure the lock is set OK, unlock can be accidentally saved? */
pso->ob->pose->flag |= POSE_LOCKED;
pso->ob->pose->flag &= ~POSE_DO_UNLOCK;
-
- /* do basic initialize of RB-BST used for finding keyframes, but leave the filling of it up
+
+ /* do basic initialize of RB-BST used for finding keyframes, but leave the filling of it up
* to the caller of this (usually only invoke() will do it, to make things more efficient).
*/
BLI_dlrbTree_init(&pso->keys);
-
+
/* initialise numeric input */
initNumInput(&pso->num);
pso->num.idx_max = 0; /* one axis */
pso->num.val_flag[0] |= NUM_NO_NEGATIVE;
pso->num.unit_type[0] = B_UNIT_NONE; /* percentages don't have any units... */
-
+
/* return status is whether we've got all the data we were requested to get */
return 1;
}
@@ -233,19 +233,19 @@ static int pose_slide_init(bContext *C, wmOperator *op, short mode)
static void pose_slide_exit(wmOperator *op)
{
tPoseSlideOp *pso = op->customdata;
-
+
/* if data exists, clear its data and exit */
if (pso) {
/* free the temp pchan links and their data */
poseAnim_mapping_free(&pso->pfLinks);
-
+
/* free RB-BST for keyframes (if it contained data) */
BLI_dlrbTree_free(&pso->keys);
-
+
/* free data itself */
MEM_freeN(pso);
}
-
+
/* cleanup */
op->customdata = NULL;
}
@@ -265,19 +265,19 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val)
float cframe = (float)pso->cframe;
float sVal, eVal;
float w1, w2;
-
+
/* get keyframe values for endpoint poses to blend with */
/* previous/start */
sVal = evaluate_fcurve(fcu, pso->prevFrameF);
/* next/end */
eVal = evaluate_fcurve(fcu, pso->nextFrameF);
-
+
/* if both values are equal, don't do anything */
if (IS_EQF(sVal, eVal)) {
(*val) = sVal;
return;
}
-
+
/* calculate the relative weights of the endpoints */
if (pso->mode == POSESLIDE_BREAKDOWN) {
/* get weights from the percentage control */
@@ -285,20 +285,20 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val)
w2 = 1.0f - w1; /* this must come first */
}
else {
- /* - these weights are derived from the relative distance of these
+ /* - these weights are derived from the relative distance of these
* poses from the current frame
* - they then get normalized so that they only sum up to 1
*/
- float wtot;
-
+ float wtot;
+
w1 = cframe - (float)pso->prevFrame;
w2 = (float)pso->nextFrame - cframe;
-
+
wtot = w1 + w2;
w1 = (w1 / wtot);
w2 = (w2 / wtot);
}
-
+
/* depending on the mode, calculate the new value
* - in all of these, the start+end values are multiplied by w2 and w1 (respectively),
* since multiplication in another order would decrease the value the current frame is closer to
@@ -311,7 +311,7 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val)
* - perform this weighting a number of times given by the percentage...
*/
int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */
-
+
while (iters-- > 0) {
(*val) = (-((sVal * w2) + (eVal * w1)) + ((*val) * 6.0f) ) / 5.0f;
}
@@ -324,7 +324,7 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val)
* - perform this weighting a number of times given by the percentage...
*/
int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */
-
+
while (iters-- > 0) {
(*val) = ( ((sVal * w2) + (eVal * w1)) + ((*val) * 5.0f) ) / 6.0f;
}
@@ -345,19 +345,19 @@ static void pose_slide_apply_vec3(tPoseSlideOp *pso, tPChanFCurveLink *pfl, floa
{
LinkData *ld = NULL;
char *path = NULL;
-
+
/* get the path to use... */
path = BLI_sprintfN("%s.%s", pfl->pchan_path, propName);
-
+
/* using this path, find each matching F-Curve for the variables we're interested in */
while ( (ld = poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) {
FCurve *fcu = (FCurve *)ld->data;
const int idx = fcu->array_index;
const int lock = pso->axislock;
-
+
/* check if this F-Curve is ok given the current axis locks */
BLI_assert(fcu->array_index < 3);
-
+
if ((lock == 0) ||
((lock & PS_LOCK_X) && (idx == 0)) ||
((lock & PS_LOCK_Y) && (idx == 1)) ||
@@ -367,7 +367,7 @@ static void pose_slide_apply_vec3(tPoseSlideOp *pso, tPChanFCurveLink *pfl, floa
pose_slide_apply_val(pso, fcu, &vec[fcu->array_index]);
}
}
-
+
/* free the temp path we got */
MEM_freeN(path);
}
@@ -378,11 +378,11 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con
PointerRNA ptr = {{NULL}};
LinkData *ld;
int len = strlen(pfl->pchan_path);
-
+
/* setup pointer RNA for resolving paths */
RNA_pointer_create(NULL, &RNA_PoseBone, pfl->pchan, &ptr);
-
- /* - custom properties are just denoted using ["..."][etc.] after the end of the base path,
+
+ /* - custom properties are just denoted using ["..."][etc.] after the end of the base path,
* so just check for opening pair after the end of the path
* - bbone properties are similar, but they always start with a prefix "bbone_*",
* so a similar method should work here for those too
@@ -390,23 +390,23 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con
for (ld = pfl->fcurves.first; ld; ld = ld->next) {
FCurve *fcu = (FCurve *)ld->data;
const char *bPtr, *pPtr;
-
+
if (fcu->rna_path == NULL)
continue;
-
- /* do we have a match?
+
+ /* do we have a match?
* - bPtr is the RNA Path with the standard part chopped off
* - pPtr is the chunk of the path which is left over
*/
bPtr = strstr(fcu->rna_path, pfl->pchan_path) + len;
pPtr = strstr(bPtr, prop_prefix);
-
+
if (pPtr) {
/* use RNA to try and get a handle on this property, then, assuming that it is just
* numerical, try and grab the value as a float for temp editing before setting back
*/
PropertyRNA *prop = RNA_struct_find_property(&ptr, pPtr);
-
+
if (prop) {
switch (RNA_property_type(prop)) {
/* continuous values that can be smoothly interpolated... */
@@ -424,7 +424,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con
RNA_property_int_set(&ptr, prop, (int)tval);
break;
}
-
+
/* values which can only take discrete values */
case PROP_BOOLEAN:
{
@@ -440,7 +440,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con
*/
break;
}
-
+
default:
/* cannot handle */
//printf("Cannot Pose Slide non-numerical property\n");
@@ -459,17 +459,17 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
LinkData *ld = NULL;
char *path = NULL;
float cframe;
-
+
/* get the path to use - this should be quaternion rotations only (needs care) */
path = BLI_sprintfN("%s.%s", pfl->pchan_path, "rotation_quaternion");
-
+
/* get the current frame number */
cframe = (float)pso->cframe;
-
+
/* using this path, find each matching F-Curve for the variables we're interested in */
while ( (ld = poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) {
FCurve *fcu = (FCurve *)ld->data;
-
+
/* assign this F-Curve to one of the relevant pointers... */
switch (fcu->array_index) {
case 3: /* z */
@@ -486,22 +486,22 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
break;
}
}
-
+
/* only if all channels exist, proceed */
if (fcu_w && fcu_x && fcu_y && fcu_z) {
float quat_prev[4], quat_next[4];
-
+
/* get 2 quats */
quat_prev[0] = evaluate_fcurve(fcu_w, pso->prevFrameF);
quat_prev[1] = evaluate_fcurve(fcu_x, pso->prevFrameF);
quat_prev[2] = evaluate_fcurve(fcu_y, pso->prevFrameF);
quat_prev[3] = evaluate_fcurve(fcu_z, pso->prevFrameF);
-
+
quat_next[0] = evaluate_fcurve(fcu_w, pso->nextFrameF);
quat_next[1] = evaluate_fcurve(fcu_x, pso->nextFrameF);
quat_next[2] = evaluate_fcurve(fcu_y, pso->nextFrameF);
quat_next[3] = evaluate_fcurve(fcu_z, pso->nextFrameF);
-
+
/* perform blending */
if (pso->mode == POSESLIDE_BREAKDOWN) {
/* just perform the interpol between quat_prev and quat_next using pso->percentage as a guide */
@@ -509,35 +509,35 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
}
else if (pso->mode == POSESLIDE_PUSH) {
float quat_diff[4], quat_orig[4];
-
+
/* calculate the delta transform from the previous to the current */
/* TODO: investigate ways to favour one transform more? */
sub_qt_qtqt(quat_diff, pchan->quat, quat_prev);
-
+
/* make a copy of the original rotation */
copy_qt_qt(quat_orig, pchan->quat);
-
+
/* increase the original by the delta transform, by an amount determined by percentage */
add_qt_qtqt(pchan->quat, quat_orig, quat_diff, pso->percentage);
}
else {
float quat_interp[4], quat_orig[4];
int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */
-
+
/* perform this blending several times until a satisfactory result is reached */
while (iters-- > 0) {
/* calculate the interpolation between the endpoints */
interp_qt_qtqt(quat_interp, quat_prev, quat_next, (cframe - pso->prevFrame) / (pso->nextFrame - pso->prevFrame));
-
+
/* make a copy of the original rotation */
copy_qt_qt(quat_orig, pchan->quat);
-
+
/* tricky interpolations - blending between original and new */
interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 1.0f / 6.0f);
}
}
}
-
+
/* free the path now */
MEM_freeN(path);
}
@@ -546,37 +546,37 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
{
tPChanFCurveLink *pfl;
-
+
/* sanitise the frame ranges */
if (pso->prevFrame == pso->nextFrame) {
/* move out one step either side */
pso->prevFrame--;
pso->nextFrame++;
-
+
/* apply NLA mapping corrections so the frame lookups work */
pso->prevFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP);
pso->nextFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP);
}
-
+
/* for each link, handle each set of transforms */
for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) {
- /* valid transforms for each PoseChannel should have been noted already
- * - sliding the pose should be a straightforward exercise for location+rotation,
- * but rotations get more complicated since we may want to use quaternion blending
+ /* valid transforms for each PoseChannel should have been noted already
+ * - sliding the pose should be a straightforward exercise for location+rotation,
+ * but rotations get more complicated since we may want to use quaternion blending
* for quaternions instead...
*/
bPoseChannel *pchan = pfl->pchan;
-
+
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_LOC) && (pchan->flag & POSE_LOC)) {
/* calculate these for the 'location' vector, and use location curves */
pose_slide_apply_vec3(pso, pfl, pchan->loc, "location");
}
-
+
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_SIZE) && (pchan->flag & POSE_SIZE)) {
/* calculate these for the 'scale' vector, and use scale curves */
pose_slide_apply_vec3(pso, pfl, pchan->size, "scale");
}
-
+
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_ROT) && (pchan->flag & POSE_ROT)) {
/* everything depends on the rotation mode */
if (pchan->rotmode > 0) {
@@ -591,12 +591,12 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
pose_slide_apply_quat(pso, pfl);
}
}
-
+
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_BBONE_SHAPE) && (pchan->flag & POSE_BBONE_SHAPE)) {
/* bbone properties - they all start a "bbone_" prefix */
- pose_slide_apply_props(pso, pfl, "bbone_");
+ pose_slide_apply_props(pso, pfl, "bbone_");
}
-
+
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_PROPS) && (pfl->oldprops)) {
/* not strictly a transform, but custom properties contribute to the pose produced in many rigs
* (e.g. the facial rigs used in Sintel)
@@ -604,7 +604,7 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
pose_slide_apply_props(pso, pfl, "[\""); /* dummy " for texteditor bugs */
}
}
-
+
/* depsgraph updates + redraws */
pose_slide_refresh(C, pso);
}
@@ -633,7 +633,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
char limits_str[UI_MAX_DRAW_STR];
char axis_str[50];
char mode_str[32];
-
+
switch (pso->mode) {
case POSESLIDE_PUSH:
strcpy(mode_str, "Push Pose");
@@ -644,13 +644,13 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
case POSESLIDE_BREAKDOWN:
strcpy(mode_str, "Breakdown");
break;
-
+
default:
/* unknown */
strcpy(mode_str, "Sliding-Tool");
break;
}
-
+
switch (pso->axislock) {
case PS_LOCK_X:
BLI_strncpy(axis_str, "[X]/Y/Z axis only (X to clear)", sizeof(axis_str));
@@ -661,7 +661,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
case PS_LOCK_Z:
BLI_strncpy(axis_str, "X/Y/[Z] axis only (Z to clear)", sizeof(axis_str));
break;
-
+
default:
if (ELEM(pso->channels, PS_TFM_LOC, PS_TFM_ROT, PS_TFM_SIZE)) {
BLI_strncpy(axis_str, "X/Y/Z = Axis Constraint", sizeof(axis_str));
@@ -671,7 +671,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
}
break;
}
-
+
switch (pso->channels) {
case PS_TFM_LOC:
BLI_snprintf(limits_str, sizeof(limits_str), "[G]/R/S/B/C - Location only (G to clear) | %s", axis_str);
@@ -692,19 +692,19 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
BLI_strncpy(limits_str, "G/R/S/B/C - Limit to Transform/Property Set", sizeof(limits_str));
break;
}
-
+
if (hasNumInput(&pso->num)) {
Scene *scene = pso->scene;
char str_offs[NUM_STR_REP_LEN];
-
+
outputNumInput(&pso->num, str_offs, &scene->unit);
-
+
BLI_snprintf(status_str, sizeof(status_str), "%s: %s | %s", mode_str, str_offs, limits_str);
}
else {
BLI_snprintf(status_str, sizeof(status_str), "%s: %d %% | %s", mode_str, (int)(pso->percentage * 100.0f), limits_str);
}
-
+
ED_area_headerprint(pso->sa, status_str);
}
@@ -714,34 +714,34 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p
tPChanFCurveLink *pfl;
AnimData *adt = pso->ob->adt;
wmWindow *win = CTX_wm_window(C);
-
+
/* for each link, add all its keyframes to the search tree */
for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) {
LinkData *ld;
-
+
/* do this for each F-Curve */
for (ld = pfl->fcurves.first; ld; ld = ld->next) {
FCurve *fcu = (FCurve *)ld->data;
fcurve_to_keylist(adt, fcu, &pso->keys, NULL);
}
}
-
+
/* consolidate these keyframes, and figure out the nearest ones */
BLI_dlrbTree_linkedlist_sync(&pso->keys);
-
+
/* cancel if no keyframes found... */
if (pso->keys.root) {
ActKeyColumn *ak;
float cframe = (float)pso->cframe;
-
+
/* firstly, check if the current frame is a keyframe... */
ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(&pso->keys, compare_ak_cfraPtr, &cframe);
-
+
if (ak == NULL) {
/* current frame is not a keyframe, so search */
ActKeyColumn *pk = (ActKeyColumn *)BLI_dlrbTree_search_prev(&pso->keys, compare_ak_cfraPtr, &cframe);
ActKeyColumn *nk = (ActKeyColumn *)BLI_dlrbTree_search_next(&pso->keys, compare_ak_cfraPtr, &cframe);
-
+
/* new set the frames */
/* prev frame */
pso->prevFrame = (pk) ? (pk->cfra) : (pso->cframe - 1);
@@ -759,7 +759,7 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p
pso->nextFrame = (ak->next) ? (ak->next->cfra) : (pso->cframe + 1);
RNA_int_set(op->ptr, "next_frame", pso->nextFrame);
}
-
+
/* apply NLA mapping corrections so the frame lookups work */
pso->prevFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP);
pso->nextFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP);
@@ -769,20 +769,20 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p
pose_slide_exit(op);
return OPERATOR_CANCELLED;
}
-
+
/* initial apply for operator... */
/* TODO: need to calculate percentage for initial round too... */
pose_slide_apply(C, pso);
-
+
/* depsgraph updates + redraws */
pose_slide_refresh(C, pso);
-
+
/* set cursor to indicate modal */
WM_cursor_modal_set(win, BC_EW_SCROLLCURSOR);
-
+
/* header print */
pose_slide_draw_status(pso);
-
+
/* add a modal handler for this operator */
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
@@ -810,8 +810,8 @@ static void pose_slide_toggle_channels_mode(wmOperator *op, tPoseSlideOp *pso, e
pso->channels = channel;
}
RNA_enum_set(op->ptr, "channels", pso->channels);
-
-
+
+
/* Reset axis limits too for good measure */
pso->axislock = 0;
RNA_enum_set(op->ptr, "axis_lock", pso->axislock);
@@ -826,7 +826,7 @@ static bool pose_slide_toggle_axis_locks(wmOperator *op, tPoseSlideOp *pso, ePos
RNA_enum_set(op->ptr, "axis_lock", pso->axislock);
return false;
}
-
+
/* Turn on or off? */
if (pso->axislock == axis) {
/* Already limiting on this axis, so turn off */
@@ -837,7 +837,7 @@ static bool pose_slide_toggle_axis_locks(wmOperator *op, tPoseSlideOp *pso, ePos
pso->axislock = axis;
}
RNA_enum_set(op->ptr, "axis_lock", pso->axislock);
-
+
/* Setting changed, so pose update is needed */
return true;
}
@@ -848,9 +848,9 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
tPoseSlideOp *pso = op->customdata;
wmWindow *win = CTX_wm_window(C);
bool do_pose_update = false;
-
+
const bool has_numinput = hasNumInput(&pso->num);
-
+
switch (event->type) {
case LEFTMOUSE: /* confirm */
case RETKEY:
@@ -859,35 +859,35 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* return to normal cursor and header status */
ED_area_headerprint(pso->sa, NULL);
WM_cursor_modal_restore(win);
-
+
/* insert keyframes as required... */
pose_slide_autoKeyframe(C, pso);
pose_slide_exit(op);
-
+
/* done! */
return OPERATOR_FINISHED;
}
-
+
case ESCKEY: /* cancel */
- case RIGHTMOUSE:
+ case RIGHTMOUSE:
{
/* return to normal cursor and header status */
ED_area_headerprint(pso->sa, NULL);
WM_cursor_modal_restore(win);
-
+
/* reset transforms back to original state */
pose_slide_reset(pso);
-
+
/* depsgraph updates + redraws */
pose_slide_refresh(C, pso);
-
+
/* clean up temp data */
pose_slide_exit(op);
-
+
/* canceled! */
return OPERATOR_CANCELLED;
}
-
+
/* Percentage Chane... */
case MOUSEMOVE: /* calculate new position */
{
@@ -895,7 +895,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (has_numinput == false) {
/* update percentage based on position of mouse */
pose_slide_mouse_update_percentage(pso, op, event);
-
+
/* update pose to reflect the new values (see below) */
do_pose_update = true;
}
@@ -905,17 +905,17 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
if ((event->val == KM_PRESS) && handleNumInput(C, &pso->num, event)) {
float value;
-
- /* Grab percentage from numeric input, and store this new value for redo
+
+ /* Grab percentage from numeric input, and store this new value for redo
* NOTE: users see ints, while internally we use a 0-1 float
*/
value = pso->percentage * 100.0f;
applyNumInput(&pso->num, &value);
-
+
pso->percentage = value / 100.0f;
CLAMP(pso->percentage, 0.0f, 1.0f);
RNA_float_set(op->ptr, "percentage", pso->percentage);
-
+
/* Update pose to reflect the new values (see below) */
do_pose_update = true;
break;
@@ -954,8 +954,8 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
do_pose_update = true;
break;
}
-
-
+
+
/* Axis Locks */
/* XXX: Hardcoded... */
case XKEY:
@@ -979,8 +979,8 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
break;
}
-
-
+
+
default: /* Some other unhandled key... */
break;
}
@@ -992,20 +992,20 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
}
-
-
+
+
/* perform pose updates - in response to some user action (e.g. pressing a key or moving the mouse) */
if (do_pose_update) {
/* update percentage indicator in header */
pose_slide_draw_status(pso);
-
+
/* reset transforms (to avoid accumulation errors) */
pose_slide_reset(pso);
-
+
/* apply... */
pose_slide_apply(C, pso);
}
-
+
/* still running... */
return OPERATOR_RUNNING_MODAL;
}
@@ -1022,13 +1022,13 @@ static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso
{
/* settings should have been set up ok for applying, so just apply! */
pose_slide_apply(C, pso);
-
+
/* insert keyframes if needed */
pose_slide_autoKeyframe(C, pso);
-
+
/* cleanup and done */
pose_slide_exit(op);
-
+
return OPERATOR_FINISHED;
}
@@ -1037,10 +1037,10 @@ static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso
static void pose_slide_opdef_properties(wmOperatorType *ot)
{
RNA_def_float_percentage(ot->srna, "percentage", 0.5f, 0.0f, 1.0f, "Percentage", "Weighting factor for which keyframe is favored more", 0.3, 0.7);
-
+
RNA_def_int(ot->srna, "prev_frame", 0, MINAFRAME, MAXFRAME, "Previous Keyframe", "Frame number of keyframe immediately before the current frame", 0, 50);
RNA_def_int(ot->srna, "next_frame", 0, MINAFRAME, MAXFRAME, "Next Keyframe", "Frame number of keyframe immediately after the current frame", 0, 50);
-
+
RNA_def_enum(ot->srna, "channels", prop_channels_types, PS_TFM_ALL, "Channels", "Set of properties that are affected");
RNA_def_enum(ot->srna, "axis_lock", prop_axis_lock_types, 0, "Axis Lock", "Transform axis to restrict effects to");
}
@@ -1051,7 +1051,7 @@ static void pose_slide_opdef_properties(wmOperatorType *ot)
static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tPoseSlideOp *pso;
-
+
/* initialize data */
if (pose_slide_init(C, op, POSESLIDE_PUSH) == 0) {
pose_slide_exit(op);
@@ -1059,10 +1059,10 @@ static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *ev
}
else
pso = op->customdata;
-
+
/* initialise percentage so that it won't pop on first mouse move */
pose_slide_mouse_update_percentage(pso, op, event);
-
+
/* do common setup work */
return pose_slide_invoke_common(C, op, pso);
}
@@ -1071,7 +1071,7 @@ static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *ev
static int pose_slide_push_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
-
+
/* initialize data (from RNA-props) */
if (pose_slide_init(C, op, POSESLIDE_PUSH) == 0) {
pose_slide_exit(op);
@@ -1079,7 +1079,7 @@ static int pose_slide_push_exec(bContext *C, wmOperator *op)
}
else
pso = op->customdata;
-
+
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
}
@@ -1090,17 +1090,17 @@ void POSE_OT_push(wmOperatorType *ot)
ot->name = "Push Pose";
ot->idname = "POSE_OT_push";
ot->description = "Exaggerate the current pose";
-
+
/* callbacks */
ot->exec = pose_slide_push_exec;
ot->invoke = pose_slide_push_invoke;
ot->modal = pose_slide_modal;
ot->cancel = pose_slide_cancel;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
-
+
/* Properties */
pose_slide_opdef_properties(ot);
}
@@ -1111,7 +1111,7 @@ void POSE_OT_push(wmOperatorType *ot)
static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tPoseSlideOp *pso;
-
+
/* initialize data */
if (pose_slide_init(C, op, POSESLIDE_RELAX) == 0) {
pose_slide_exit(op);
@@ -1119,10 +1119,10 @@ static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *e
}
else
pso = op->customdata;
-
+
/* initialise percentage so that it won't pop on first mouse move */
pose_slide_mouse_update_percentage(pso, op, event);
-
+
/* do common setup work */
return pose_slide_invoke_common(C, op, pso);
}
@@ -1131,7 +1131,7 @@ static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *e
static int pose_slide_relax_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
-
+
/* initialize data (from RNA-props) */
if (pose_slide_init(C, op, POSESLIDE_RELAX) == 0) {
pose_slide_exit(op);
@@ -1139,7 +1139,7 @@ static int pose_slide_relax_exec(bContext *C, wmOperator *op)
}
else
pso = op->customdata;
-
+
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
}
@@ -1150,17 +1150,17 @@ void POSE_OT_relax(wmOperatorType *ot)
ot->name = "Relax Pose";
ot->idname = "POSE_OT_relax";
ot->description = "Make the current pose more similar to its surrounding ones";
-
+
/* callbacks */
ot->exec = pose_slide_relax_exec;
ot->invoke = pose_slide_relax_invoke;
ot->modal = pose_slide_modal;
ot->cancel = pose_slide_cancel;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
-
+
/* Properties */
pose_slide_opdef_properties(ot);
}
@@ -1171,7 +1171,7 @@ void POSE_OT_relax(wmOperatorType *ot)
static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tPoseSlideOp *pso;
-
+
/* initialize data */
if (pose_slide_init(C, op, POSESLIDE_BREAKDOWN) == 0) {
pose_slide_exit(op);
@@ -1179,10 +1179,10 @@ static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEven
}
else
pso = op->customdata;
-
+
/* initialise percentage so that it won't pop on first mouse move */
pose_slide_mouse_update_percentage(pso, op, event);
-
+
/* do common setup work */
return pose_slide_invoke_common(C, op, pso);
}
@@ -1191,7 +1191,7 @@ static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEven
static int pose_slide_breakdown_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
-
+
/* initialize data (from RNA-props) */
if (pose_slide_init(C, op, POSESLIDE_BREAKDOWN) == 0) {
pose_slide_exit(op);
@@ -1199,7 +1199,7 @@ static int pose_slide_breakdown_exec(bContext *C, wmOperator *op)
}
else
pso = op->customdata;
-
+
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
}
@@ -1210,17 +1210,17 @@ void POSE_OT_breakdown(wmOperatorType *ot)
ot->name = "Pose Breakdowner";
ot->idname = "POSE_OT_breakdown";
ot->description = "Create a suitable breakdown pose on the current frame";
-
+
/* callbacks */
ot->exec = pose_slide_breakdown_exec;
ot->invoke = pose_slide_breakdown_invoke;
ot->modal = pose_slide_modal;
ot->cancel = pose_slide_cancel;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
-
+
/* Properties */
pose_slide_opdef_properties(ot);
}
@@ -1240,7 +1240,7 @@ typedef enum ePosePropagate_Termination {
POSE_PROPAGATE_BEFORE_FRAME,
/* stop when we run out of keyframes */
POSE_PROPAGATE_BEFORE_END,
-
+
/* only do on keyframes that are selected */
POSE_PROPAGATE_SELECTED_KEYS,
/* only do on the frames where markers are selected */
@@ -1251,14 +1251,14 @@ typedef enum ePosePropagate_Termination {
typedef union tPosePropagate_ModeData {
/* smart holds + before frame: frame number to stop on */
float end_frame;
-
+
/* selected markers: listbase for CfraElem's marking these frames */
ListBase sel_markers;
} tPosePropagate_ModeData;
/* --------------------------------- */
-/* get frame on which the "hold" for the bone ends
+/* get frame on which the "hold" for the bone ends
* XXX: this may not really work that well if a bone moves on some channels and not others
* if this happens to be a major issue, scrap this, and just make this happen
* independently per F-Curve
@@ -1267,47 +1267,47 @@ static float pose_propagate_get_boneHoldEndFrame(Object *ob, tPChanFCurveLink *p
{
DLRBT_Tree keys, blocks;
ActKeyBlock *ab;
-
+
AnimData *adt = ob->adt;
LinkData *ld;
float endFrame = startFrame;
-
+
/* set up optimized data-structures for searching for relevant keyframes + holds */
BLI_dlrbTree_init(&keys);
BLI_dlrbTree_init(&blocks);
-
+
for (ld = pfl->fcurves.first; ld; ld = ld->next) {
FCurve *fcu = (FCurve *)ld->data;
fcurve_to_keylist(adt, fcu, &keys, &blocks);
}
-
+
BLI_dlrbTree_linkedlist_sync(&keys);
BLI_dlrbTree_linkedlist_sync(&blocks);
-
- /* find the long keyframe (i.e. hold), and hence obtain the endFrame value
+
+ /* find the long keyframe (i.e. hold), and hence obtain the endFrame value
* - the best case would be one that starts on the frame itself
*/
ab = (ActKeyBlock *)BLI_dlrbTree_search_exact(&blocks, compare_ab_cfraPtr, &startFrame);
-
+
if (actkeyblock_is_valid(ab, &keys) == 0) {
/* There are only two cases for no-exact match:
* 1) the current frame is just before another key but not on a key itself
* 2) the current frame is on a key, but that key doesn't link to the next
*
- * If we've got the first case, then we can search for another block,
+ * If we've got the first case, then we can search for another block,
* otherwise forget it, as we'd be overwriting some valid data.
*/
if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &startFrame) == NULL) {
/* we've got case 1, so try the one after */
ab = (ActKeyBlock *)BLI_dlrbTree_search_next(&blocks, compare_ab_cfraPtr, &startFrame);
-
+
if (actkeyblock_is_valid(ab, &keys) == 0) {
/* try the block before this frame then as last resort */
ab = (ActKeyBlock *)BLI_dlrbTree_search_prev(&blocks, compare_ab_cfraPtr, &startFrame);
-
+
/* whatever happens, stop searching now... */
if (actkeyblock_is_valid(ab, &keys) == 0) {
- /* restrict range to just the frame itself
+ /* restrict range to just the frame itself
* i.e. everything is in motion, so no holds to safely overwrite
*/
ab = NULL;
@@ -1319,13 +1319,13 @@ static float pose_propagate_get_boneHoldEndFrame(Object *ob, tPChanFCurveLink *p
ab = NULL;
}
}
-
+
/* check if we can go any further than we've already gone */
if (ab) {
/* go to next if it is also valid and meets "extension" criteria */
while (ab->next) {
ActKeyBlock *abn = (ActKeyBlock *)ab->next;
-
+
/* must be valid */
if (actkeyblock_is_valid(abn, &keys) == 0)
break;
@@ -1335,24 +1335,24 @@ static float pose_propagate_get_boneHoldEndFrame(Object *ob, tPChanFCurveLink *p
/* should have the same number of curves */
if (ab->totcurve != abn->totcurve)
break;
- /* should have the same value
+ /* should have the same value
* XXX: this may be a bit fuzzy on larger data sets, so be careful
*/
if (ab->val != abn->val)
break;
-
+
/* we can extend the bounds to the end of this "next" block now */
ab = abn;
}
-
+
/* end frame can now take the value of the end of the block */
endFrame = ab->end;
}
-
+
/* free temp memory */
BLI_dlrbTree_free(&keys);
BLI_dlrbTree_free(&blocks);
-
+
/* return the end frame we've found */
return endFrame;
}
@@ -1363,10 +1363,10 @@ static bool pose_propagate_get_refVal(Object *ob, FCurve *fcu, float *value)
PointerRNA id_ptr, ptr;
PropertyRNA *prop;
bool found = false;
-
+
/* base pointer is always the object -> id_ptr */
RNA_id_pointer_create(&ob->id, &id_ptr);
-
+
/* resolve the property... */
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
if (RNA_property_array_check(prop)) {
@@ -1411,7 +1411,7 @@ static bool pose_propagate_get_refVal(Object *ob, FCurve *fcu, float *value)
}
}
}
-
+
return found;
}
@@ -1420,25 +1420,25 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
float startFrame, tPosePropagate_ModeData modeData)
{
const int mode = RNA_enum_get(op->ptr, "mode");
-
+
BezTriple *bezt;
float refVal = 0.0f;
bool keyExists;
int i, match;
short first = 1;
-
+
/* skip if no keyframes to edit */
if ((fcu->bezt == NULL) || (fcu->totvert < 2))
return;
-
+
/* find the reference value from bones directly, which means that the user
- * doesn't need to firstly keyframe the pose (though this doesn't mean that
+ * doesn't need to firstly keyframe the pose (though this doesn't mean that
* they can't either)
*/
if (!pose_propagate_get_refVal(ob, fcu, &refVal))
return;
-
- /* find the first keyframe to start propagating from
+
+ /* find the first keyframe to start propagating from
* - if there's a keyframe on the current frame, we probably want to save this value there too
* since it may be as of yet unkeyed
* - if starting before the starting frame, don't touch the key, as it may have had some valid
@@ -1447,7 +1447,7 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
*/
if (mode != POSE_PROPAGATE_SELECTED_KEYS) {
match = binarysearch_bezt_index(fcu->bezt, startFrame, fcu->totvert, &keyExists);
-
+
if (fcu->bezt[match].vec[1][0] < startFrame)
i = match + 1;
else
@@ -1457,13 +1457,13 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
/* selected - start from first keyframe */
i = 0;
}
-
+
for (bezt = &fcu->bezt[i]; i < fcu->totvert; i++, bezt++) {
/* additional termination conditions based on the operator 'mode' property go here... */
if (ELEM(mode, POSE_PROPAGATE_BEFORE_FRAME, POSE_PROPAGATE_SMART_HOLDS)) {
/* stop if keyframe is outside the accepted range */
if (bezt->vec[1][0] > modeData.end_frame)
- break;
+ break;
}
else if (mode == POSE_PROPAGATE_NEXT_KEY) {
/* stop after the first keyframe has been processed */
@@ -1478,13 +1478,13 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
else if (mode == POSE_PROPAGATE_SELECTED_MARKERS) {
/* only allow if there's a marker on this frame */
CfraElem *ce = NULL;
-
+
/* stop on matching marker if there is one */
for (ce = modeData.sel_markers.first; ce; ce = ce->next) {
if (ce->cfra == round_fl_to_int(bezt->vec[1][0]))
break;
}
-
+
/* skip this keyframe if no marker */
if (ce == NULL)
continue;
@@ -1494,11 +1494,11 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
if (BEZT_ISSEL_ANY(bezt) == 0)
continue;
}
-
+
/* just flatten handles, since values will now be the same either side... */
/* TODO: perhaps a fade-out modulation of the value is required here (optional once again)? */
bezt->vec[0][1] = bezt->vec[1][1] = bezt->vec[2][1] = refVal;
-
+
/* select keyframe to indicate that it's been changed */
bezt->f2 |= SELECT;
first = 0;
@@ -1512,13 +1512,13 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
bAction *act = (ob && ob->adt) ? ob->adt->action : NULL;
-
+
ListBase pflinks = {NULL, NULL};
tPChanFCurveLink *pfl;
-
+
tPosePropagate_ModeData modeData;
const int mode = RNA_enum_get(op->ptr, "mode");
-
+
/* sanity checks */
if (ob == NULL) {
BKE_report(op->reports, RPT_ERROR, "No object to propagate poses for");
@@ -1528,10 +1528,10 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No keyframed poses to propagate to");
return OPERATOR_CANCELLED;
}
-
+
/* isolate F-Curves related to the selected bones */
poseAnim_mapping_get(C, &pflinks, ob, act);
-
+
/* mode-specific data preprocessing (requiring no access to curves) */
if (mode == POSE_PROPAGATE_SELECTED_MARKERS) {
/* get a list of selected markers */
@@ -1541,11 +1541,11 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
/* assume everything else wants endFrame */
modeData.end_frame = RNA_float_get(op->ptr, "end_frame");
}
-
+
/* for each bone, perform the copying required */
for (pfl = pflinks.first; pfl; pfl = pfl->next) {
LinkData *ld;
-
+
/* mode-specific data preprocessing (requiring access to all curves) */
if (mode == POSE_PROPAGATE_SMART_HOLDS) {
/* we store in endFrame the end frame of the "long keyframe" (i.e. a held value) starting
@@ -1553,21 +1553,21 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
*/
modeData.end_frame = pose_propagate_get_boneHoldEndFrame(ob, pfl, (float)CFRA);
}
-
+
/* go through propagating pose to keyframes, curve by curve */
for (ld = pfl->fcurves.first; ld; ld = ld->next)
pose_propagate_fcurve(op, ob, (FCurve *)ld->data, (float)CFRA, modeData);
}
-
+
/* free temp data */
poseAnim_mapping_free(&pflinks);
-
+
if (mode == POSE_PROPAGATE_SELECTED_MARKERS)
BLI_freelistN(&modeData.sel_markers);
-
+
/* updates + notifiers */
poseAnim_mapping_refresh(C, scene, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1591,19 +1591,19 @@ void POSE_OT_propagate(wmOperatorType *ot)
{POSE_PROPAGATE_SELECTED_MARKERS, "SELECTED_MARKERS", 0, "On Selected Markers",
"Propagate pose to all keyframes occurring on frames with Scene Markers after the current frame"},
{0, NULL, 0, NULL, NULL}};
-
+
/* identifiers */
ot->name = "Propagate Pose";
ot->idname = "POSE_OT_propagate";
ot->description = "Copy selected aspects of the current pose to subsequent poses already keyframed";
-
+
/* callbacks */
ot->exec = pose_propagate_exec;
ot->poll = ED_operator_posemode; /* XXX: needs selected bones! */
-
+
/* flag */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
/* TODO: add "fade out" control for tapering off amount of propagation as time goes by? */
ot->prop = RNA_def_enum(ot->srna, "mode", terminate_items, POSE_PROPAGATE_SMART_HOLDS, "Terminate Mode", "Method used to determine when to stop propagating pose to keyframes");
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index 1657fe4eaea..22c710dcda5 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -78,16 +78,16 @@ static void applyarmature_fix_boneparents(const bContext *C, Scene *scene, Objec
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Main *bmain = CTX_data_main(C);
Object workob, *ob;
-
+
/* go through all objects in database */
for (ob = bmain->object.first; ob; ob = ob->id.next) {
/* if parent is bone in this armature, apply corrections */
if ((ob->parent == armob) && (ob->partype == PARBONE)) {
- /* apply current transform from parent (not yet destroyed),
+ /* apply current transform from parent (not yet destroyed),
* then calculate new parent inverse matrix
*/
BKE_object_apply_mat4(ob, ob->obmat, false, false);
-
+
BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
}
@@ -97,6 +97,7 @@ static void applyarmature_fix_boneparents(const bContext *C, Scene *scene, Objec
/* set the current pose as the restpose */
static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
@@ -123,18 +124,18 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
/* Get editbones of active armature to alter */
ED_armature_to_edit(arm);
-
+
/* get pose of active object and move it out of posemode */
pose = ob->pose;
-
+
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
const bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name);
curbone = ED_armature_ebone_find_name(arm->edbo, pchan->name);
-
+
/* simply copy the head/tail values from pchan over to curbone */
copy_v3_v3(curbone->head, pchan_eval->pose_head);
copy_v3_v3(curbone->tail, pchan_eval->pose_tail);
-
+
/* fix roll:
* 1. find auto-calculated roll value for this bone now
* 2. remove this from the 'visual' y-rotation
@@ -142,23 +143,23 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
{
float premat[3][3], imat[3][3], pmat[3][3], tmat[3][3];
float delta[3], eul[3];
-
+
/* obtain new auto y-rotation */
sub_v3_v3v3(delta, curbone->tail, curbone->head);
vec_roll_to_mat3(delta, 0.0f, premat);
invert_m3_m3(imat, premat);
-
+
/* get pchan 'visual' matrix */
copy_m3_m4(pmat, pchan_eval->pose_mat);
-
+
/* remove auto from visual and get euler rotation */
mul_m3_m3m3(tmat, imat, pmat);
mat3_to_eul(eul, tmat);
-
+
/* just use this euler-y as new roll value */
curbone->roll = eul[1];
}
-
+
/* combine pose and rest values for bendy bone settings,
* then clear the pchan values (so we don't get a double-up)
*/
@@ -174,7 +175,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
curbone->ease2 += pchan_eval->ease2;
curbone->scaleIn += pchan_eval->scaleIn;
curbone->scaleOut += pchan_eval->scaleOut;
-
+
/* reset pose values */
pchan->curveInX = pchan->curveOutX = 0.0f;
pchan->curveInY = pchan->curveOutY = 0.0f;
@@ -182,32 +183,32 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
pchan->ease1 = pchan->ease2 = 0.0f;
pchan->scaleIn = pchan->scaleOut = 1.0f;
}
-
+
/* clear transform values for pchan */
zero_v3(pchan->loc);
zero_v3(pchan->eul);
unit_qt(pchan->quat);
unit_axis_angle(pchan->rotAxis, &pchan->rotAngle);
pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f;
-
+
/* set anim lock */
curbone->flag |= BONE_UNKEYED;
}
-
+
/* convert editbones back to bones, and then free the edit-data */
- ED_armature_from_edit(arm);
+ ED_armature_from_edit(bmain, arm);
ED_armature_edit_free(arm);
-
+
/* flush positions of posebones */
BKE_pose_where_is(depsgraph, scene, ob);
-
+
/* fix parenting of objects which are bone-parented */
applyarmature_fix_boneparents(C, scene, ob);
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
-
+
return OPERATOR_FINISHED;
}
@@ -217,11 +218,11 @@ void POSE_OT_armature_apply(wmOperatorType *ot)
ot->name = "Apply Pose as Rest Pose";
ot->idname = "POSE_OT_armature_apply";
ot->description = "Apply the current pose as the new rest pose";
-
+
/* callbacks */
ot->exec = apply_armature_pose2bones_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -244,21 +245,21 @@ static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name);
float delta_mat[4][4];
-
+
/* chan_mat already contains the delta transform from rest pose to pose-mode pose
* as that is baked into there so that B-Bones will work. Once we've set this as the
- * new raw-transform components, don't recalc the poses yet, otherwise IK result will
+ * new raw-transform components, don't recalc the poses yet, otherwise IK result will
* change, thus changing the result we may be trying to record.
*/
/* XXX For some reason, we can't use pchan->chan_mat here, gives odd rotation/offset (see T38251).
* Using pchan->pose_mat and bringing it back in bone space seems to work as expected!
*/
BKE_armature_mat_pose_to_bone(pchan_eval, pchan_eval->pose_mat, delta_mat);
-
+
BKE_pchan_apply_mat4(pchan, delta_mat, true);
}
FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
-
+
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* note, notifier might evolve */
@@ -275,11 +276,11 @@ void POSE_OT_visual_transform_apply(wmOperatorType *ot)
ot->name = "Apply Visual Transform to Pose";
ot->idname = "POSE_OT_visual_transform_apply";
ot->description = "Apply final constrained position of pose bones to their transform";
-
+
/* callbacks */
ot->exec = pose_visual_transform_apply_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -287,7 +288,7 @@ void POSE_OT_visual_transform_apply(wmOperatorType *ot)
/* ********************************************** */
/* Copy/Paste */
-/* This function is used to indicate that a bone is selected
+/* This function is used to indicate that a bone is selected
* and needs to be included in copy buffer (used to be for inserting keys)
*/
static void set_pose_keys(Object *ob)
@@ -320,33 +321,33 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo
bPoseChannel *pchan;
char name[MAXBONENAME];
short paste_ok;
-
+
/* get the name - if flipping, we must flip this first */
if (flip)
BLI_string_flip_side_name(name, chan->name, false, sizeof(name));
else
BLI_strncpy(name, chan->name, sizeof(name));
-
+
/* only copy when:
* 1) channel exists - poses are not meant to add random channels to anymore
* 2) if selection-masking is on, channel is selected - only selected bones get pasted on, allowing making both sides symmetrical
*/
pchan = BKE_pose_channel_find_name(ob->pose, name);
-
+
if (selOnly)
paste_ok = ((pchan) && (pchan->bone->flag & BONE_SELECTED));
else
paste_ok = (pchan != NULL);
-
+
/* continue? */
if (paste_ok) {
- /* only loc rot size
- * - only copies transform info for the pose
+ /* only loc rot size
+ * - only copies transform info for the pose
*/
copy_v3_v3(pchan->loc, chan->loc);
copy_v3_v3(pchan->size, chan->size);
pchan->flag = chan->flag;
-
+
/* check if rotation modes are compatible (i.e. do they need any conversions) */
if (pchan->rotmode == chan->rotmode) {
/* copy the type of rotation in use */
@@ -382,29 +383,29 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo
else
axis_angle_to_quat(pchan->quat, chan->rotAxis, pchan->rotAngle);
}
-
+
/* B-Bone posing options should also be included... */
pchan->curveInX = chan->curveInX;
pchan->curveInY = chan->curveInY;
pchan->curveOutX = chan->curveOutX;
pchan->curveOutY = chan->curveOutY;
-
+
pchan->roll1 = chan->roll1;
pchan->roll2 = chan->roll2;
pchan->ease1 = chan->ease1;
pchan->ease2 = chan->ease2;
pchan->scaleIn = chan->scaleIn;
pchan->scaleOut = chan->scaleOut;
-
+
/* paste flipped pose? */
if (flip) {
pchan->loc[0] *= -1;
-
+
pchan->curveInX *= -1;
pchan->curveOutX *= -1;
pchan->roll1 *= -1; // XXX?
pchan->roll2 *= -1; // XXX?
-
+
/* has to be done as eulers... */
if (pchan->rotmode > 0) {
pchan->eul[1] *= -1;
@@ -412,7 +413,7 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo
}
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
float eul[3];
-
+
axis_angle_to_eulO(eul, EULER_ORDER_DEFAULT, pchan->rotAxis, pchan->rotAngle);
eul[1] *= -1;
eul[2] *= -1;
@@ -420,7 +421,7 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo
}
else {
float eul[3];
-
+
normalize_qt(pchan->quat);
quat_to_eul(eul, pchan->quat);
eul[1] *= -1;
@@ -428,12 +429,12 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo
eul_to_quat(pchan->quat, eul);
}
}
-
+
/* ID properties */
if (chan->prop) {
if (pchan->prop) {
- /* if we have existing properties on a bone, just copy over the values of
- * matching properties (i.e. ones which will have some impact) on to the
+ /* if we have existing properties on a bone, just copy over the values of
+ * matching properties (i.e. ones which will have some impact) on to the
* target instead of just blinding replacing all [
*/
IDP_SyncGroupValues(pchan->prop, chan->prop);
@@ -444,7 +445,7 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo
}
}
}
-
+
/* return whether paste went ahead */
return pchan;
}
@@ -502,11 +503,11 @@ void POSE_OT_copy(wmOperatorType *ot)
ot->name = "Copy Pose";
ot->idname = "POSE_OT_copy";
ot->description = "Copies the current pose of the selected bones to copy/paste buffer";
-
+
/* api callbacks */
ot->exec = pose_copy_exec;
ot->poll = ED_operator_posemode;
-
+
/* flag */
ot->flag = OPTYPE_REGISTER;
}
@@ -520,15 +521,15 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
bPoseChannel *chan;
const bool flip = RNA_boolean_get(op->ptr, "flipped");
bool selOnly = RNA_boolean_get(op->ptr, "selected_mask");
-
+
/* Get KeyingSet to use. */
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID);
-
+
/* Sanity checks. */
if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
}
-
+
/* Read copy buffer .blend file. */
char str[FILE_MAX];
Main *tmp_bmain = BKE_main_new();
@@ -544,7 +545,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
BKE_main_free(tmp_bmain);
return OPERATOR_CANCELLED;
}
-
+
Object *object_from = tmp_bmain->object.first;
bPose *pose_from = object_from->pose;
if (pose_from == NULL) {
@@ -552,7 +553,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
BKE_main_free(tmp_bmain);
return OPERATOR_CANCELLED;
}
-
+
/* If selOnly option is enabled, if user hasn't selected any bones,
* just go back to default behavior to be more in line with other
* pose tools.
@@ -562,7 +563,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
selOnly = false;
}
}
-
+
/* Safely merge all of the channels in the buffer pose into any
* existing pose.
*/
@@ -577,15 +578,15 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
}
}
BKE_main_free(tmp_bmain);
-
+
/* Update event for pose and deformation children. */
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
-
+
/* Recalculate paths if any of the bones have paths... */
if ((ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) {
ED_pose_recalculate_paths(C, scene, ob);
}
-
+
/* Notifiers for updates, */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
@@ -600,14 +601,14 @@ void POSE_OT_paste(wmOperatorType *ot)
ot->name = "Paste Pose";
ot->idname = "POSE_OT_paste";
ot->description = "Paste the stored pose on to the current pose";
-
+
/* api callbacks */
ot->exec = pose_paste_exec;
ot->poll = ED_operator_posemode;
-
+
/* flag */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
prop = RNA_def_boolean(ot->srna, "flipped", false, "Flipped on X-Axis", "Paste the stored pose flipped on to current pose");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
@@ -627,9 +628,9 @@ static void pchan_clear_scale(bPoseChannel *pchan)
pchan->size[1] = 1.0f;
if ((pchan->protectflag & OB_LOCK_SCALEZ) == 0)
pchan->size[2] = 1.0f;
-
+
pchan->ease1 = 0.0f;
- pchan->ease2 = 0.0f;
+ pchan->ease2 = 0.0f;
pchan->scaleIn = 1.0f;
pchan->scaleOut = 1.0f;
}
@@ -661,7 +662,7 @@ static void pchan_clear_rot(bPoseChannel *pchan)
pchan->rotAxis[1] = 0.0f;
if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
pchan->rotAxis[2] = 0.0f;
-
+
/* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */
if (IS_EQF(pchan->rotAxis[0], pchan->rotAxis[1]) && IS_EQF(pchan->rotAxis[1], pchan->rotAxis[2]))
pchan->rotAxis[1] = 1.0f;
@@ -690,7 +691,7 @@ static void pchan_clear_rot(bPoseChannel *pchan)
/* perform clamping using euler form (3-components) */
float eul[3], oldeul[3], quat1[4] = {0};
float qlen = 0.0f;
-
+
if (pchan->rotmode == ROT_MODE_QUAT) {
qlen = normalize_qt_qt(quat1, pchan->quat);
quat_to_eul(oldeul, quat1);
@@ -701,22 +702,22 @@ static void pchan_clear_rot(bPoseChannel *pchan)
else {
copy_v3_v3(oldeul, pchan->eul);
}
-
+
eul[0] = eul[1] = eul[2] = 0.0f;
-
+
if (pchan->protectflag & OB_LOCK_ROTX)
eul[0] = oldeul[0];
if (pchan->protectflag & OB_LOCK_ROTY)
eul[1] = oldeul[1];
if (pchan->protectflag & OB_LOCK_ROTZ)
eul[2] = oldeul[2];
-
+
if (pchan->rotmode == ROT_MODE_QUAT) {
eul_to_quat(pchan->quat, eul);
-
+
/* restore original quat size */
mul_qt_fl(pchan->quat, qlen);
-
+
/* quaternions flip w sign to accumulate rotations correctly */
if ((quat1[0] < 0.0f && pchan->quat[0] > 0.0f) || (quat1[0] > 0.0f && pchan->quat[0] < 0.0f)) {
mul_qt_fl(pchan->quat, -1.0f);
@@ -742,11 +743,11 @@ static void pchan_clear_rot(bPoseChannel *pchan)
zero_v3(pchan->eul);
}
}
-
+
/* Clear also Bendy Bone stuff - Roll is obvious, but Curve X/Y stuff is also kindof rotational in nature... */
pchan->roll1 = 0.0f;
pchan->roll2 = 0.0f;
-
+
pchan->curveInX = 0.0f;
pchan->curveInY = 0.0f;
pchan->curveOutX = 0.0f;
@@ -764,7 +765,7 @@ static void pchan_clear_transforms(bPoseChannel *pchan)
/* --------------- */
/* generic exec for clear-pose operators */
-static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
+static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
void (*clear_func)(bPoseChannel *), const char default_ksName[])
{
Scene *scene = CTX_data_scene(C);
@@ -798,7 +799,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
}
/* tag for autokeying later */
ANIM_relative_keyingset_add_source(&dsources, &ob_iter->id, &RNA_PoseBone, pchan);
-
+
#if 1 /* XXX: Ugly Hack - Run clearing function on evaluated copy of pchan */
bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name);
clear_func(pchan_eval);
@@ -845,7 +846,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
/* --------------- */
-static int pose_clear_scale_exec(bContext *C, wmOperator *op)
+static int pose_clear_scale_exec(bContext *C, wmOperator *op)
{
return pose_clear_transform_generic_exec(C, op, pchan_clear_scale, ANIM_KS_SCALING_ID);
}
@@ -856,17 +857,17 @@ void POSE_OT_scale_clear(wmOperatorType *ot)
ot->name = "Clear Pose Scale";
ot->idname = "POSE_OT_scale_clear";
ot->description = "Reset scaling of selected bones to their default values";
-
+
/* api callbacks */
ot->exec = pose_clear_scale_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-static int pose_clear_rot_exec(bContext *C, wmOperator *op)
+static int pose_clear_rot_exec(bContext *C, wmOperator *op)
{
return pose_clear_transform_generic_exec(C, op, pchan_clear_rot, ANIM_KS_ROTATION_ID);
}
@@ -877,17 +878,17 @@ void POSE_OT_rot_clear(wmOperatorType *ot)
ot->name = "Clear Pose Rotation";
ot->idname = "POSE_OT_rot_clear";
ot->description = "Reset rotations of selected bones to their default values";
-
+
/* api callbacks */
ot->exec = pose_clear_rot_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-static int pose_clear_loc_exec(bContext *C, wmOperator *op)
+static int pose_clear_loc_exec(bContext *C, wmOperator *op)
{
return pose_clear_transform_generic_exec(C, op, pchan_clear_loc, ANIM_KS_LOCATION_ID);
}
@@ -898,17 +899,17 @@ void POSE_OT_loc_clear(wmOperatorType *ot)
ot->name = "Clear Pose Location";
ot->idname = "POSE_OT_loc_clear";
ot->description = "Reset locations of selected bones to their default values";
-
+
/* api callbacks */
ot->exec = pose_clear_loc_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-static int pose_clear_transforms_exec(bContext *C, wmOperator *op)
+static int pose_clear_transforms_exec(bContext *C, wmOperator *op)
{
return pose_clear_transform_generic_exec(C, op, pchan_clear_transforms, ANIM_KS_LOC_ROT_SCALE_ID);
}
@@ -919,11 +920,11 @@ void POSE_OT_transforms_clear(wmOperatorType *ot)
ot->name = "Clear Pose Transforms";
ot->idname = "POSE_OT_transforms_clear";
ot->description = "Reset location, rotation, and scaling of selected bones to their default values";
-
+
/* api callbacks */
ot->exec = pose_clear_transforms_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -937,7 +938,7 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
float cframe = (float)CFRA;
const bool only_select = RNA_boolean_get(op->ptr, "only_selected");
-
+
FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob)
{
if ((ob->adt) && (ob->adt->action)) {
@@ -947,23 +948,23 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
bPose *dummyPose = NULL;
Object workob = {{NULL}};
bPoseChannel *pchan;
-
+
/* execute animation step for current frame using a dummy copy of the pose */
BKE_pose_copy_data(&dummyPose, ob->pose, 0);
-
+
BLI_strncpy(workob.id.name, "OB<ClearTfmWorkOb>", sizeof(workob.id.name));
workob.type = OB_ARMATURE;
workob.data = ob->data;
workob.adt = ob->adt;
workob.pose = dummyPose;
-
- BKE_animsys_evaluate_animdata(scene, &workob.id, workob.adt, cframe, ADT_RECALC_ANIM);
-
+
+ BKE_animsys_evaluate_animdata(NULL, scene, &workob.id, workob.adt, cframe, ADT_RECALC_ANIM);
+
/* copy back values, but on selected bones only */
for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) {
pose_bone_do_paste(ob, pchan, only_select, 0);
}
-
+
/* free temp data - free manually as was copied without constraints */
for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->prop) {
@@ -971,7 +972,7 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
MEM_freeN(pchan->prop);
}
}
-
+
/* was copied without constraints */
BLI_freelistN(&dummyPose->chanbase);
MEM_freeN(dummyPose);
@@ -982,13 +983,13 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
*/
BKE_pose_rest(ob->pose);
}
-
+
/* notifiers and updates */
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
}
FOREACH_OBJECT_IN_MODE_END;
-
+
return OPERATOR_FINISHED;
}
@@ -998,11 +999,11 @@ void POSE_OT_user_transforms_clear(wmOperatorType *ot)
ot->name = "Clear User Transforms";
ot->idname = "POSE_OT_user_transforms_clear";
ot->description = "Reset pose on selected bones to keyframed state";
-
+
/* callbacks */
ot->exec = pose_clear_user_transforms_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c
index 6bc88dc5b0e..b64c8528010 100644
--- a/source/blender/editors/armature/pose_utils.c
+++ b/source/blender/editors/armature/pose_utils.c
@@ -59,11 +59,11 @@
/* Contents of this File:
*
* This file contains methods shared between Pose Slide and Pose Lib;
- * primarily the functions in question concern Animato <-> Pose
+ * primarily the functions in question concern Animato <-> Pose
* convenience functions, such as applying/getting pose values
* and/or inserting keyframes for these.
*/
-/* *********************************************** */
+/* *********************************************** */
/* FCurves <-> PoseChannels Links */
/* helper for poseAnim_mapping_get() -> get the relevant F-Curves per PoseChannel */
@@ -71,25 +71,25 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a
{
ListBase curves = {NULL, NULL};
int transFlags = action_get_item_transforms(act, ob, pchan, &curves);
-
+
pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE | POSE_BBONE_SHAPE);
-
+
/* check if any transforms found... */
if (transFlags) {
/* make new linkage data */
tPChanFCurveLink *pfl = MEM_callocN(sizeof(tPChanFCurveLink), "tPChanFCurveLink");
PointerRNA ptr;
-
+
pfl->fcurves = curves;
pfl->pchan = pchan;
-
+
/* get the RNA path to this pchan - this needs to be freed! */
RNA_pointer_create((ID *)ob, &RNA_PoseBone, pchan, &ptr);
pfl->pchan_path = RNA_path_from_ID_to_struct(&ptr);
-
+
/* add linkage data to operator data */
BLI_addtail(pfLinks, pfl);
-
+
/* set pchan's transform flags */
if (transFlags & ACT_TRANS_LOC)
pchan->flag |= POSE_LOC;
@@ -99,7 +99,7 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a
pchan->flag |= POSE_SIZE;
if (transFlags & ACT_TRANS_BBONE)
pchan->flag |= POSE_BBONE_SHAPE;
-
+
/* store current transforms */
copy_v3_v3(pfl->oldloc, pchan->loc);
copy_v3_v3(pfl->oldrot, pchan->eul);
@@ -107,7 +107,7 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a
copy_qt_qt(pfl->oldquat, pchan->quat);
copy_v3_v3(pfl->oldaxis, pchan->rotAxis);
pfl->oldangle = pchan->rotAngle;
-
+
/* store current bbone values */
pfl->roll1 = pchan->roll1;
pfl->roll2 = pchan->roll2;
@@ -119,18 +119,18 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a
pfl->ease2 = pchan->ease2;
pfl->scaleIn = pchan->scaleIn;
pfl->scaleOut = pchan->scaleOut;
-
+
/* make copy of custom properties */
if (pchan->prop && (transFlags & ACT_TRANS_PROP))
pfl->oldprops = IDP_CopyProperty(pchan->prop);
}
-}
+}
/* get sets of F-Curves providing transforms for the bones in the Pose */
void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *act)
-{
- /* for each Pose-Channel which gets affected, get the F-Curves for that channel
+{
+ /* for each Pose-Channel which gets affected, get the F-Curves for that channel
* and set the relevant transform flags...
*/
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
@@ -138,7 +138,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a
fcurves_to_pchan_links_get(pfLinks, ob, act, pchan);
}
CTX_DATA_END;
-
+
/* if no PoseChannels were found, try a second pass, doing visible ones instead
* i.e. if nothing selected, do whole pose
*/
@@ -148,7 +148,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a
fcurves_to_pchan_links_get(pfLinks, ob, act, pchan);
}
CTX_DATA_END;
-
+
}
}
@@ -156,23 +156,23 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a
void poseAnim_mapping_free(ListBase *pfLinks)
{
tPChanFCurveLink *pfl, *pfln = NULL;
-
+
/* free the temp pchan links and their data */
for (pfl = pfLinks->first; pfl; pfl = pfln) {
pfln = pfl->next;
-
+
/* free custom properties */
if (pfl->oldprops) {
IDP_FreeProperty(pfl->oldprops);
MEM_freeN(pfl->oldprops);
}
-
+
/* free list of F-Curve reference links */
BLI_freelistN(&pfl->fcurves);
-
+
/* free pchan RNA Path */
MEM_freeN(pfl->pchan_path);
-
+
/* free link itself */
BLI_freelinkN(pfLinks, pfl);
}
@@ -185,8 +185,8 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
bArmature *arm = (bArmature *)ob->data;
-
- /* old optimize trick... this enforces to bypass the depgraph
+
+ /* old optimize trick... this enforces to bypass the depgraph
* - note: code copied from transform_generics.c -> recalcData()
*/
/* FIXME: shouldn't this use the builtin stuff? */
@@ -194,7 +194,7 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */
else
BKE_pose_where_is(depsgraph, scene, ob);
-
+
DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE); /* otherwise animation doesn't get updated */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
}
@@ -203,11 +203,11 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
void poseAnim_mapping_reset(ListBase *pfLinks)
{
tPChanFCurveLink *pfl;
-
+
/* iterate over each pose-channel affected, restoring all channels to their original values */
for (pfl = pfLinks->first; pfl; pfl = pfl->next) {
bPoseChannel *pchan = pfl->pchan;
-
+
/* just copy all the values over regardless of whether they changed or not */
copy_v3_v3(pchan->loc, pfl->oldloc);
copy_v3_v3(pchan->eul, pfl->oldrot);
@@ -215,7 +215,7 @@ void poseAnim_mapping_reset(ListBase *pfLinks)
copy_qt_qt(pchan->quat, pfl->oldquat);
copy_v3_v3(pchan->rotAxis, pfl->oldaxis);
pchan->rotAngle = pfl->oldangle;
-
+
/* store current bbone values */
pchan->roll1 = pfl->roll1;
pchan->roll2 = pfl->roll2;
@@ -227,7 +227,7 @@ void poseAnim_mapping_reset(ListBase *pfLinks)
pchan->ease2 = pfl->ease2;
pchan->scaleIn = pfl->scaleIn;
pchan->scaleOut = pfl->scaleOut;
-
+
/* just overwrite values of properties from the stored copies (there should be some) */
if (pfl->oldprops)
IDP_SyncGroupValues(pfl->pchan->prop, pfl->oldprops);
@@ -242,26 +242,26 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBa
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID);
ListBase dsources = {NULL, NULL};
tPChanFCurveLink *pfl;
-
+
/* iterate over each pose-channel affected, tagging bones to be keyed */
- /* XXX: here we already have the information about what transforms exist, though
+ /* XXX: here we already have the information about what transforms exist, though
* it might be easier to just overwrite all using normal mechanisms
*/
for (pfl = pfLinks->first; pfl; pfl = pfl->next) {
bPoseChannel *pchan = pfl->pchan;
-
+
/* add datasource override for the PoseChannel, to be used later */
- ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan);
-
+ ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan);
+
/* clear any unkeyed tags */
if (pchan->bone)
pchan->bone->flag &= ~BONE_UNKEYED;
}
-
+
/* insert keyframes for all relevant bones in one go */
ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cframe);
BLI_freelistN(&dsources);
-
+
/* do the bone paths
* - only do this if keyframes should have been added
* - do not calculate unless there are paths already to update...
@@ -275,25 +275,25 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBa
/* ------------------------- */
-/* find the next F-Curve for a PoseChannel with matching path...
+/* find the next F-Curve for a PoseChannel with matching path...
* - path is not just the pfl rna_path, since that path doesn't have property info yet
*/
LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, const char *path)
{
LinkData *first = (prev) ? prev->next : (fcuLinks) ? fcuLinks->first : NULL;
LinkData *ld;
-
+
/* check each link to see if the linked F-Curve has a matching path */
for (ld = first; ld; ld = ld->next) {
FCurve *fcu = (FCurve *)ld->data;
-
+
/* check if paths match */
if (STREQ(path, fcu->rna_path))
return ld;
}
-
+
/* none found */
return NULL;
}
-/* *********************************************** */
+/* *********************************************** */
diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h
index 020d34f2767..01047d4badd 100644
--- a/source/blender/editors/curve/curve_intern.h
+++ b/source/blender/editors/curve/curve_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c
index 71cccdfa33d..5d27e13ed17 100644
--- a/source/blender/editors/curve/curve_ops.c
+++ b/source/blender/editors/curve/curve_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -73,10 +73,10 @@ void ED_operatortypes_curve(void)
WM_operatortype_append(FONT_OT_change_character);
WM_operatortype_append(FONT_OT_change_spacing);
-
+
WM_operatortype_append(FONT_OT_open);
WM_operatortype_append(FONT_OT_unlink);
-
+
WM_operatortype_append(FONT_OT_textbox_add);
WM_operatortype_append(FONT_OT_textbox_remove);
@@ -98,20 +98,20 @@ void ED_operatortypes_curve(void)
WM_operatortype_append(CURVE_OT_shade_smooth);
WM_operatortype_append(CURVE_OT_shade_flat);
WM_operatortype_append(CURVE_OT_tilt_clear);
-
+
WM_operatortype_append(CURVE_OT_primitive_bezier_curve_add);
WM_operatortype_append(CURVE_OT_primitive_bezier_circle_add);
WM_operatortype_append(CURVE_OT_primitive_nurbs_curve_add);
WM_operatortype_append(CURVE_OT_primitive_nurbs_circle_add);
WM_operatortype_append(CURVE_OT_primitive_nurbs_path_add);
-
+
WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_curve_add);
WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_circle_add);
WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_surface_add);
WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_cylinder_add);
WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_sphere_add);
WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_torus_add);
-
+
WM_operatortype_append(CURVE_OT_smooth);
WM_operatortype_append(CURVE_OT_smooth_weight);
WM_operatortype_append(CURVE_OT_smooth_radius);
@@ -168,10 +168,10 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
{
wmKeyMap *keymap;
wmKeyMapItem *kmi;
-
+
keymap = WM_keymap_find(keyconf, "Font", 0, 0);
keymap->poll = ED_operator_editfont;
-
+
/* only set in editmode font, by space_view3d listener */
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", BKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_BOLD);
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_ITALIC);
@@ -233,7 +233,7 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
keymap->poll = ED_operator_editsurfcurve;
WM_keymap_add_menu(keymap, "INFO_MT_edit_curve_add", AKEY, KM_PRESS, KM_SHIFT, 0);
-
+
WM_keymap_add_item(keymap, "CURVE_OT_handle_type_set", VKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "CURVE_OT_vertex_add", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0);
@@ -289,7 +289,7 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "CURVE_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_curve_specials", WKEY, KM_PRESS, 0, 0);
/* menus */
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 1987fe56bdb..616017dac0a 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -1105,7 +1105,7 @@ static int *initialize_index_map(Object *obedit, int *r_old_totvert)
return old_to_new_map;
}
-static void remap_hooks_and_vertex_parents(Object *obedit)
+static void remap_hooks_and_vertex_parents(Main *bmain, Object *obedit)
{
Object *object;
Curve *curve = (Curve *) obedit->data;
@@ -1121,7 +1121,7 @@ static void remap_hooks_and_vertex_parents(Object *obedit)
return;
}
- for (object = G.main->object.first; object; object = object->id.next) {
+ for (object = bmain->object.first; object; object = object->id.next) {
ModifierData *md;
int index;
if ((object->parent) &&
@@ -1184,7 +1184,7 @@ static void remap_hooks_and_vertex_parents(Object *obedit)
}
/* load editNurb in object */
-void ED_curve_editnurb_load(Object *obedit)
+void ED_curve_editnurb_load(Main *bmain, Object *obedit)
{
ListBase *editnurb = object_editcurve_get(obedit);
@@ -1195,7 +1195,7 @@ void ED_curve_editnurb_load(Object *obedit)
Nurb *nu, *newnu;
ListBase newnurb = {NULL, NULL}, oldnurb = cu->nurb;
- remap_hooks_and_vertex_parents(obedit);
+ remap_hooks_and_vertex_parents(bmain, obedit);
for (nu = editnurb->first; nu; nu = nu->next) {
newnu = BKE_nurb_duplicate(nu);
@@ -1325,7 +1325,7 @@ static int separate_exec(bContext *C, wmOperator *op)
BLI_movelisttolist(&newedit->nurbs, &newnurb);
/* 4. put old object out of editmode and delete separated geometry */
- ED_curve_editnurb_load(newob);
+ ED_curve_editnurb_load(bmain, newob);
ED_curve_editnurb_free(newob);
curve_delete_segments(oldob, true);
@@ -1346,12 +1346,12 @@ void CURVE_OT_separate(wmOperatorType *ot)
ot->name = "Separate";
ot->idname = "CURVE_OT_separate";
ot->description = "Separate selected points from connected unselected points into a new object";
-
+
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = separate_exec;
ot->poll = ED_operator_editsurfcurve;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1856,7 +1856,7 @@ bool ed_editnurb_extrude_flag(EditNurb *editnurb, const short flag)
while (a--) {
select_bpoint(bp, SELECT, flag, HIDDEN);
select_bpoint(newbp, DESELECT, flag, HIDDEN);
- bp++;
+ bp++;
newbp++;
}
@@ -2336,7 +2336,7 @@ void CURVE_OT_switch_direction(wmOperatorType *ot)
ot->name = "Switch Direction";
ot->description = "Switch direction of selected splines";
ot->idname = "CURVE_OT_switch_direction";
-
+
/* api callbacks */
ot->exec = switch_direction_exec;
ot->poll = ED_operator_editsurfcurve;
@@ -2356,7 +2356,7 @@ static int set_goal_weight_exec(bContext *C, wmOperator *op)
BPoint *bp;
float weight = RNA_float_get(op->ptr, "weight");
int a;
-
+
for (nu = editnurb->first; nu; nu = nu->next) {
if (nu->bezt) {
for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) {
@@ -2384,7 +2384,7 @@ void CURVE_OT_spline_weight_set(wmOperatorType *ot)
ot->name = "Set Goal Weight";
ot->description = "Set softbody goal weight for selected points";
ot->idname = "CURVE_OT_spline_weight_set";
-
+
/* api callbacks */
ot->exec = set_goal_weight_exec;
ot->invoke = WM_operator_props_popup;
@@ -2408,7 +2408,7 @@ static int set_radius_exec(bContext *C, wmOperator *op)
BPoint *bp;
float radius = RNA_float_get(op->ptr, "radius");
int a;
-
+
for (nu = editnurb->first; nu; nu = nu->next) {
if (nu->bezt) {
for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) {
@@ -2436,7 +2436,7 @@ void CURVE_OT_radius_set(wmOperatorType *ot)
ot->name = "Set Curve Radius";
ot->description = "Set per-point radius which is used for bevel tapering";
ot->idname = "CURVE_OT_radius_set";
-
+
/* api callbacks */
ot->exec = set_radius_exec;
ot->invoke = WM_operator_props_popup;
@@ -2588,7 +2588,7 @@ void CURVE_OT_smooth(wmOperatorType *ot)
ot->name = "Smooth";
ot->description = "Flatten angles of selected points";
ot->idname = "CURVE_OT_smooth";
-
+
/* api callbacks */
ot->exec = smooth_exec;
ot->poll = ED_operator_editsurfcurve;
@@ -2792,7 +2792,7 @@ static int curve_smooth_radius_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *obedit = CTX_data_edit_object(C);
ListBase *editnurb = object_editcurve_get(obedit);
-
+
curve_smooth_value(editnurb, offsetof(BezTriple, radius), offsetof(BPoint, radius));
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
@@ -2807,11 +2807,11 @@ void CURVE_OT_smooth_radius(wmOperatorType *ot)
ot->name = "Smooth Curve Radius";
ot->description = "Interpolate radii of selected points";
ot->idname = "CURVE_OT_smooth_radius";
-
+
/* api clastbacks */
ot->exec = curve_smooth_radius_exec;
ot->poll = ED_operator_editsurfcurve;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2909,14 +2909,14 @@ void CURVE_OT_hide(wmOperatorType *ot)
ot->name = "Hide Selected";
ot->idname = "CURVE_OT_hide";
ot->description = "Hide (un)selected control points";
-
+
/* api callbacks */
ot->exec = hide_exec;
ot->poll = ED_operator_editsurfcurve;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected");
}
@@ -2971,11 +2971,11 @@ void CURVE_OT_reveal(wmOperatorType *ot)
ot->name = "Reveal Hidden";
ot->idname = "CURVE_OT_reveal";
ot->description = "Reveal hidden control points";
-
+
/* api callbacks */
ot->exec = reveal_exec;
ot->poll = ED_operator_editsurfcurve;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3231,7 +3231,7 @@ static void subdividenurb(Object *obedit, int number_cuts)
for (b = 0; b < nu->pntsu; b++) {
*bpn = *bp;
keyIndex_updateBP(editnurb, bp, bpn, 1);
- bpn++;
+ bpn++;
bp++;
if (b < nu->pntsu - 1) {
prevbp = bp - 1;
@@ -3259,7 +3259,7 @@ static void subdividenurb(Object *obedit, int number_cuts)
interp_v4_v4v4(tmp->vec, prevbp->vec, bp->vec, factor);
tmp += countu;
}
- bp++;
+ bp++;
prevbp++;
bpn++;
}
@@ -3335,7 +3335,7 @@ static void subdividenurb(Object *obedit, int number_cuts)
for (b = 0; b < nu->pntsu; b++) {
*bpn = *bp;
keyIndex_updateBP(editnurb, bp, bpn, 1);
- bpn++;
+ bpn++;
bp++;
if ( (b < nu->pntsu - 1) && usel[b] == nu->pntsv && usel[b + 1] == nu->pntsv) {
/*
@@ -3362,7 +3362,7 @@ static void subdividenurb(Object *obedit, int number_cuts)
}
}
}
- MEM_freeN(usel);
+ MEM_freeN(usel);
MEM_freeN(vsel);
} /* End of 'if (nu->type == CU_NURBS)' */
@@ -3406,11 +3406,11 @@ void CURVE_OT_subdivide(wmOperatorType *ot)
ot->name = "Subdivide";
ot->description = "Subdivide selected segments";
ot->idname = "CURVE_OT_subdivide";
-
+
/* api callbacks */
ot->exec = subdivide_exec;
ot->poll = ED_operator_editsurfcurve;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3568,7 +3568,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Not yet implemented");
return OPERATOR_CANCELLED;
}
-
+
for (nu = editnurb->first; nu; nu = nu->next) {
if (ED_curve_nurb_select_check(obedit->data, nu)) {
const int pntsu_prev = nu->pntsu;
@@ -3618,12 +3618,12 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot)
ot->name = "Set Spline Type";
ot->description = "Set type of active spline";
ot->idname = "CURVE_OT_spline_type_set";
-
+
/* api callbacks */
ot->exec = set_spline_type_exec;
ot->invoke = WM_menu_invoke;
ot->poll = ED_operator_editcurve;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3663,12 +3663,12 @@ void CURVE_OT_handle_type_set(wmOperatorType *ot)
ot->name = "Set Handle Type";
ot->description = "Set type of handles for selected control points";
ot->idname = "CURVE_OT_handle_type_set";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = set_handle_type_exec;
ot->poll = ED_operator_editcurve;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3718,9 +3718,9 @@ static void switchdirection_knots(float *base, int tot)
{
float *fp1, *fp2, *tempf;
int a;
-
+
if (base == NULL || tot == 0) return;
-
+
/* reverse knots */
a = tot;
fp1 = base;
@@ -3729,7 +3729,7 @@ static void switchdirection_knots(float *base, int tot)
while (fp1 != fp2 && a > 0) {
SWAP(float, *fp1, *fp2);
a--;
- fp1++;
+ fp1++;
fp2--;
}
@@ -3761,15 +3761,15 @@ static void rotate_direction_nurb(Nurb *nu)
{
BPoint *bp1, *bp2, *temp;
int u, v;
-
+
SWAP(int, nu->pntsu, nu->pntsv);
SWAP(short, nu->orderu, nu->orderv);
SWAP(short, nu->resolu, nu->resolv);
SWAP(short, nu->flagu, nu->flagv);
-
+
SWAP(float *, nu->knotsu, nu->knotsv);
switchdirection_knots(nu->knotsv, KNOTSV(nu));
-
+
temp = MEM_dupallocN(nu->bp);
bp1 = nu->bp;
for (v = 0; v < nu->pntsv; v++) {
@@ -3786,7 +3786,7 @@ static bool is_u_selected(Nurb *nu, int u)
{
BPoint *bp;
int v;
-
+
/* what about resolu == 2? */
bp = &nu->bp[u];
for (v = 0; v < nu->pntsv - 1; v++, bp += nu->pntsu) {
@@ -3794,7 +3794,7 @@ static bool is_u_selected(Nurb *nu, int u)
return true;
}
}
-
+
return false;
}
@@ -3815,14 +3815,14 @@ static void make_selection_list_nurb(Curve *cu, ListBase *editnurb)
BPoint *bp;
float dist, headdist, taildist;
int a;
-
+
for (nu = editnurb->first; nu; nu = nu->next) {
if (ED_curve_nurb_select_check(cu, nu)) {
-
+
nus = (NurbSort *)MEM_callocN(sizeof(NurbSort), "sort");
BLI_addhead(&nbase, nus);
nus->nu = nu;
-
+
bp = nu->bp;
a = nu->pntsu;
while (a--) {
@@ -3830,8 +3830,8 @@ static void make_selection_list_nurb(Curve *cu, ListBase *editnurb)
bp++;
}
mul_v3_fl(nus->vec, 1.0f / (float)nu->pntsu);
-
-
+
+
}
}
@@ -3839,10 +3839,10 @@ static void make_selection_list_nurb(Curve *cu, ListBase *editnurb)
nus = nbase.first;
BLI_remlink(&nbase, nus);
BLI_addtail(&nsortbase, nus);
-
+
/* now add, either at head or tail, the closest one */
while (nbase.first) {
-
+
headdist = taildist = 1.0e30;
headdo = taildo = NULL;
@@ -3862,7 +3862,7 @@ static void make_selection_list_nurb(Curve *cu, ListBase *editnurb)
}
nustest = nustest->next;
}
-
+
if (headdist < taildist) {
BLI_remlink(&nbase, headdo);
BLI_addhead(&nsortbase, headdo);
@@ -3879,12 +3879,12 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu
BPoint *bp, *bp1, *bp2, *temp;
float len1, len2;
int origu, u, v;
-
+
/* first nurbs will be changed to make u = resolu-1 selected */
/* 2nd nurbs will be changed to make u = 0 selected */
/* first nurbs: u = resolu-1 selected */
-
+
if (is_u_selected(nu1, nu1->pntsu - 1)) {
/* pass */
}
@@ -3915,7 +3915,7 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu
}
}
}
-
+
/* 2nd nurbs: u = 0 selected */
if (is_u_selected(nu2, 0)) {
/* pass */
@@ -3945,19 +3945,19 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu
}
}
}
-
+
if (nu1->pntsv != nu2->pntsv) {
BKE_report(op->reports, RPT_ERROR, "Resolution does not match");
return;
}
-
+
/* ok, now nu1 has the rightmost column and nu2 the leftmost column selected */
/* maybe we need a 'v' flip of nu2? */
-
+
bp1 = &nu1->bp[nu1->pntsu - 1];
bp2 = nu2->bp;
len1 = 0.0;
-
+
for (v = 0; v < nu1->pntsv; v++, bp1 += nu1->pntsu, bp2 += nu2->pntsu) {
len1 += len_v3v3(bp1->vec, bp2->vec);
}
@@ -3965,7 +3965,7 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu
bp1 = &nu1->bp[nu1->pntsu - 1];
bp2 = &nu2->bp[nu2->pntsu * (nu2->pntsv - 1)];
len2 = 0.0;
-
+
for (v = 0; v < nu1->pntsv; v++, bp1 += nu1->pntsu, bp2 -= nu2->pntsu) {
len2 += len_v3v3(bp1->vec, bp2->vec);
}
@@ -3977,12 +3977,12 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu
if (nu1->orderv < 3 && nu1->orderv < nu1->pntsv) nu1->orderv++;
temp = nu1->bp;
nu1->bp = MEM_mallocN(nu1->pntsu * nu1->pntsv * sizeof(BPoint), "mergeBP");
-
+
bp = nu1->bp;
bp1 = temp;
-
+
for (v = 0; v < nu1->pntsv; v++) {
-
+
/* switch direction? */
if (len1 < len2) bp2 = &nu2->bp[v * nu2->pntsu];
else bp2 = &nu2->bp[(nu1->pntsv - v - 1) * nu2->pntsu];
@@ -4003,11 +4003,11 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu
if (nu1->type == CU_NURBS) {
/* merge knots */
BKE_nurb_knot_calc_u(nu1);
-
+
/* make knots, for merged curved for example */
BKE_nurb_knot_calc_v(nu1);
}
-
+
MEM_freeN(temp);
BLI_remlink(editnurb, nu2);
BKE_nurb_free(nu2);
@@ -4020,15 +4020,15 @@ static int merge_nurb(bContext *C, wmOperator *op)
ListBase *editnurb = object_editcurve_get(obedit);
NurbSort *nus1, *nus2;
bool ok = true;
-
+
make_selection_list_nurb(cu, editnurb);
-
+
if (nsortbase.first == nsortbase.last) {
BLI_freelistN(&nsortbase);
BKE_report(op->reports, RPT_ERROR, "Too few selections to merge");
return OPERATOR_CANCELLED;
}
-
+
nus1 = nsortbase.first;
nus2 = nus1->next;
@@ -4058,7 +4058,7 @@ static int merge_nurb(bContext *C, wmOperator *op)
else {
ok = 0;
}
-
+
if (ok == 0) {
BKE_report(op->reports, RPT_ERROR, "Resolution does not match");
BLI_freelistN(&nsortbase);
@@ -4069,14 +4069,14 @@ static int merge_nurb(bContext *C, wmOperator *op)
merge_2_nurb(op, cu, editnurb, nus1->nu, nus2->nu);
nus2 = nus2->next;
}
-
+
BLI_freelistN(&nsortbase);
-
+
BKE_curve_nurb_active_set(obedit->data, NULL);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
-
+
return OPERATOR_FINISHED;
}
@@ -4094,7 +4094,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
/* first decide if this is a surface merge! */
if (obedit->type == OB_SURF) nu = nubase->first;
else nu = NULL;
-
+
while (nu) {
const int nu_select_num = ED_curve_nurb_select_count(cu, nu);
if (nu_select_num) {
@@ -4123,7 +4123,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
if (nu)
return merge_nurb(C, op);
-
+
/* find both nurbs and points, nu1 will be put behind nu2 */
for (nu = nubase->first; nu; nu = nu->next) {
if (nu->pntsu == 1)
@@ -4293,7 +4293,7 @@ void CURVE_OT_make_segment(wmOperatorType *ot)
ot->name = "Make Segment";
ot->idname = "CURVE_OT_make_segment";
ot->description = "Join two curves by their selected ends";
-
+
/* api callbacks */
ot->exec = make_segment_exec;
ot->poll = ED_operator_editsurfcurve;
@@ -4316,10 +4316,10 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
const void *vert = BKE_curve_vert_active_get(cu);
int location[2];
short hand;
-
+
view3d_operator_needs_opengl(C);
ED_view3d_viewcontext_init(C, &vc);
-
+
location[0] = mval[0];
location[1] = mval[1];
@@ -4417,7 +4417,7 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
return true;
}
-
+
return false;
}
@@ -4442,7 +4442,7 @@ bool ed_editnurb_spin(float viewmat[4][4], Object *obedit, const float axis[3],
/* imat and center and size */
copy_m3_m4(bmat, obedit->obmat);
invert_m3_m3(imat, bmat);
-
+
axis_angle_to_mat3(cmat, axis, M_PI / 4.0);
mul_m3_m3m3(tmat, cmat, bmat);
mul_m3_m3m3(rotmat, imat, tmat);
@@ -4505,18 +4505,18 @@ static int spin_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
float cent[3], axis[3], viewmat[4][4];
-
+
RNA_float_get_array(op->ptr, "center", cent);
RNA_float_get_array(op->ptr, "axis", axis);
-
+
invert_m4_m4(obedit->imat, obedit->obmat);
mul_m4_v3(obedit->imat, cent);
-
+
if (rv3d)
copy_m4_m4(viewmat, rv3d->viewmat);
else
unit_m4(viewmat);
-
+
if (!ed_editnurb_spin(viewmat, obedit, axis, cent)) {
BKE_report(op->reports, RPT_ERROR, "Cannot spin");
return OPERATOR_CANCELLED;
@@ -4537,13 +4537,13 @@ static int spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
float axis[3] = {0.0f, 0.0f, 1.0f};
-
+
if (rv3d)
copy_v3_v3(axis, rv3d->viewinv[2]);
-
+
RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d)->location);
RNA_float_set_array(op->ptr, "axis", axis);
-
+
return spin_exec(C, op);
}
@@ -4553,7 +4553,7 @@ void CURVE_OT_spin(wmOperatorType *ot)
ot->name = "Spin";
ot->idname = "CURVE_OT_spin";
ot->description = "Extrude selected boundary row around pivot point and current view axis";
-
+
/* api callbacks */
ot->exec = spin_exec;
ot->invoke = spin_invoke;
@@ -4561,7 +4561,7 @@ void CURVE_OT_spin(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_float_vector_xyz(ot->srna, "center", 3, NULL, -OBJECT_ADD_SIZE_MAXF, OBJECT_ADD_SIZE_MAXF,
"Center", "Center in global view space", -1000.0f, 1000.0f);
RNA_def_float_vector(ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -1.0f, 1.0f);
@@ -5026,7 +5026,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
const float mval[2] = {UNPACK2(event->mval)};
struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
- vc.scene, CTX_data_depsgraph(C), 0, vc.ar, vc.v3d);
+ vc.bmain, vc.scene, vc.depsgraph, 0, vc.ar, vc.v3d);
ED_transform_snap_object_project_view3d(
snap_context,
@@ -5085,7 +5085,7 @@ void CURVE_OT_vertex_add(wmOperatorType *ot)
ot->name = "Add Vertex";
ot->idname = "CURVE_OT_vertex_add";
ot->description = "Add a new control point (linked to only selected end-curve one, if any)";
-
+
/* api callbacks */
ot->exec = add_vertex_exec;
ot->invoke = add_vertex_invoke;
@@ -5108,7 +5108,7 @@ static int curve_extrude_exec(bContext *C, wmOperator *UNUSED(op))
EditNurb *editnurb = cu->editnurb;
bool changed = false;
bool as_curve = false;
-
+
/* first test: curve? */
if (obedit->type != OB_CURVE) {
Nurb *nu;
@@ -5147,7 +5147,7 @@ void CURVE_OT_extrude(wmOperatorType *ot)
ot->name = "Extrude";
ot->description = "Extrude selected control point(s)";
ot->idname = "CURVE_OT_extrude";
-
+
/* api callbacks */
ot->exec = curve_extrude_exec;
ot->poll = ED_operator_editsurfcurve;
@@ -5214,7 +5214,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op)
a = nu->pntsu * nu->pntsv;
bp = nu->bp;
while (a--) {
-
+
if (bp->f1 & SELECT) {
if (direction == 0 && nu->pntsu > 1) {
nu->flagu ^= CU_NURB_CYCLIC;
@@ -5228,7 +5228,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op)
}
bp++;
}
-
+
}
}
}
@@ -5276,7 +5276,7 @@ void CURVE_OT_cyclic_toggle(wmOperatorType *ot)
ot->name = "Toggle Cyclic";
ot->description = "Make active spline closed/opened loop";
ot->idname = "CURVE_OT_cyclic_toggle";
-
+
/* api callbacks */
ot->exec = toggle_cyclic_exec;
ot->invoke = toggle_cyclic_invoke;
@@ -5316,11 +5316,11 @@ void CURVE_OT_duplicate(wmOperatorType *ot)
ot->name = "Duplicate Curve";
ot->description = "Duplicate selected control points";
ot->idname = "CURVE_OT_duplicate";
-
+
/* api callbacks */
ot->exec = duplicate_exec;
ot->poll = ED_operator_editsurfcurve;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -5791,12 +5791,12 @@ void CURVE_OT_delete(wmOperatorType *ot)
ot->name = "Delete";
ot->description = "Delete selected control points or segments";
ot->idname = "CURVE_OT_delete";
-
+
/* api callbacks */
ot->exec = curve_delete_exec;
ot->invoke = WM_menu_invoke;
ot->poll = ED_operator_editsurfcurve;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -6005,17 +6005,17 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
ListBase *editnurb = object_editcurve_get(obedit);
Nurb *nu;
int clear = (STREQ(op->idname, "CURVE_OT_shade_flat"));
-
+
if (obedit->type != OB_CURVE)
return OPERATOR_CANCELLED;
-
+
for (nu = editnurb->first; nu; nu = nu->next) {
if (ED_curve_nurb_select_check(obedit->data, nu)) {
if (!clear) nu->flag |= CU_SMOOTH;
else nu->flag &= ~CU_SMOOTH;
}
}
-
+
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
@@ -6028,11 +6028,11 @@ void CURVE_OT_shade_smooth(wmOperatorType *ot)
ot->name = "Shade Smooth";
ot->idname = "CURVE_OT_shade_smooth";
ot->description = "Set shading to smooth";
-
+
/* api callbacks */
ot->exec = shade_smooth_exec;
ot->poll = ED_operator_editsurfcurve;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -6043,11 +6043,11 @@ void CURVE_OT_shade_flat(wmOperatorType *ot)
ot->name = "Shade Flat";
ot->idname = "CURVE_OT_shade_flat";
ot->description = "Set shading to flat";
-
+
/* api callbacks */
ot->exec = shade_smooth_exec;
ot->poll = ED_operator_editsurfcurve;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -6084,21 +6084,21 @@ int join_curve_exec(bContext *C, wmOperator *op)
}
BLI_listbase_clear(&tempbase);
-
+
/* trasnform all selected curves inverse in obact */
invert_m4_m4(imat, ob->obmat);
-
+
CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
{
if (base->object->type == ob->type) {
if (base->object != ob) {
-
+
cu = base->object->data;
-
+
if (cu->nurb.first) {
/* watch it: switch order here really goes wrong */
mul_m4_m4m4(cmat, imat, base->object->obmat);
-
+
nu = cu->nurb.first;
while (nu) {
newnu = BKE_nurb_duplicate(nu);
@@ -6109,7 +6109,7 @@ int join_curve_exec(bContext *C, wmOperator *op)
newnu->mat_nr = 0;
}
BLI_addtail(&tempbase, newnu);
-
+
if ((bezt = newnu->bezt)) {
a = newnu->pntsu;
while (a--) {
@@ -6130,16 +6130,16 @@ int join_curve_exec(bContext *C, wmOperator *op)
nu = nu->next;
}
}
-
+
ED_object_base_free_and_unlink(bmain, scene, base->object);
}
}
}
CTX_DATA_END;
-
+
cu = ob->data;
BLI_movelisttolist(&cu->nurb, &tempbase);
-
+
if (ob->type == OB_CURVE) {
/* Account for mixed 2D/3D curves when joining */
BKE_curve_curve_dimension_update(cu);
@@ -6198,11 +6198,11 @@ void CURVE_OT_tilt_clear(wmOperatorType *ot)
ot->name = "Clear Tilt";
ot->idname = "CURVE_OT_tilt_clear";
ot->description = "Clear the tilt of selected control points";
-
+
/* api callbacks */
ot->exec = clear_tilt_exec;
ot->poll = ED_operator_editcurve;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index bbe88bd1446..887f3dd13da 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -34,6 +34,7 @@
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_fcurve.h"
+#include "BKE_main.h"
#include "BKE_report.h"
#include "DEG_depsgraph.h"
@@ -616,6 +617,7 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke)
}
}
else {
+ cdd->vc.bmain = CTX_data_main(C);
cdd->vc.depsgraph = CTX_data_depsgraph(C);
cdd->vc.scene = CTX_data_scene(C);
cdd->vc.view_layer = CTX_data_view_layer(C);
@@ -1016,7 +1018,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
nu->resolv = 1;
nu->orderu = 4;
nu->orderv = 1;
-
+
BPoint *bp = nu->bp;
BLI_mempool_iternew(cdd->stroke_elem_pool, &iter);
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index a9a8901acc6..7cdfafdad43 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -82,7 +82,7 @@ static int kill_selection(Object *obedit, int ins);
static char findaccent(char char1, unsigned int code)
{
char new = 0;
-
+
if (char1 == 'a') {
if (code == '`') new = 224;
else if (code == 39) new = 225;
@@ -214,7 +214,7 @@ static char findaccent(char char1, unsigned int code)
else if (char1 == '+') {
if (code == '-') new = 177;
}
-
+
if (new) return new;
else return char1;
}
@@ -223,7 +223,7 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
{
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
-
+
if (ef->len < MAXTEXT - 1) {
int x;
@@ -233,7 +233,7 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
ef->textbufinfo[ef->pos] = cu->curinfo;
ef->textbufinfo[ef->pos].kern = 0;
ef->textbufinfo[ef->pos].mat_nr = obedit->actcol;
-
+
ef->pos++;
ef->len++;
ef->textbuf[ef->len] = '\0';
@@ -378,7 +378,7 @@ static int paste_from_file_exec(bContext *C, wmOperator *op)
{
char *path;
int retval;
-
+
path = RNA_string_get_alloc(op->ptr, "filepath", NULL, 0);
retval = paste_from_file(C, op->reports, path);
MEM_freeN(path);
@@ -391,7 +391,7 @@ static int paste_from_file_invoke(bContext *C, wmOperator *op, const wmEvent *UN
if (RNA_struct_property_is_set(op->ptr, "filepath"))
return paste_from_file_exec(C, op);
- WM_event_add_fileselect(C, op);
+ WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
}
@@ -402,12 +402,12 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot)
ot->name = "Paste File";
ot->description = "Paste contents from file";
ot->idname = "FONT_OT_text_paste_from_file";
-
+
/* api callbacks */
ot->exec = paste_from_file_exec;
ot->invoke = paste_from_file_invoke;
ot->poll = ED_operator_editfont;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -433,7 +433,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const
char *s;
int a;
float rot[3] = {0.f, 0.f, 0.f};
-
+
obedit = BKE_object_add(bmain, scene, view_layer, OB_FONT, NULL);
base = view_layer->basact;
@@ -506,12 +506,12 @@ void ED_text_to_object(bContext *C, Text *text, const bool split_lines)
linenum++;
continue;
}
-
+
/* do the translation */
offset[0] = 0;
offset[1] = -linenum;
offset[2] = 0;
-
+
if (rv3d)
mul_mat3_m4_v3(rv3d->viewinv, offset);
@@ -607,11 +607,11 @@ void FONT_OT_style_set(wmOperatorType *ot)
ot->name = "Set Style";
ot->description = "Set font style";
ot->idname = "FONT_OT_style_set";
-
+
/* api callbacks */
ot->exec = set_style_exec;
ot->poll = ED_operator_editfont;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -630,7 +630,7 @@ static int toggle_style_exec(bContext *C, wmOperator *op)
if (!BKE_vfont_select_get(obedit, &selstart, &selend))
return OPERATOR_CANCELLED;
-
+
style = RNA_enum_get(op->ptr, "style");
cu->curinfo.flag ^= style;
@@ -645,11 +645,11 @@ void FONT_OT_style_toggle(wmOperatorType *ot)
ot->name = "Toggle Style";
ot->description = "Toggle font style";
ot->idname = "FONT_OT_style_toggle";
-
+
/* api callbacks */
ot->exec = toggle_style_exec;
ot->poll = ED_operator_editfont;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -703,7 +703,7 @@ void FONT_OT_select_all(wmOperatorType *ot)
static void copy_selection(Object *obedit)
{
int selstart, selend;
-
+
if (BKE_vfont_select_get(obedit, &selstart, &selend)) {
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
@@ -740,7 +740,7 @@ void FONT_OT_text_copy(wmOperatorType *ot)
ot->name = "Copy Text";
ot->description = "Copy selected text to clipboard";
ot->idname = "FONT_OT_text_copy";
-
+
/* api callbacks */
ot->exec = copy_text_exec;
ot->poll = ED_operator_editfont;
@@ -770,7 +770,7 @@ void FONT_OT_text_cut(wmOperatorType *ot)
ot->name = "Cut Text";
ot->description = "Cut selected text to clipboard";
ot->idname = "FONT_OT_text_cut";
-
+
/* api callbacks */
ot->exec = cut_text_exec;
ot->poll = ED_operator_editfont;
@@ -871,7 +871,7 @@ void FONT_OT_text_paste(wmOperatorType *ot)
ot->name = "Paste Text";
ot->description = "Paste text from clipboard";
ot->idname = "FONT_OT_text_paste";
-
+
/* api callbacks */
ot->exec = paste_text_exec;
ot->poll = ED_operator_editfont;
@@ -915,7 +915,7 @@ static int move_cursor(bContext *C, int type, const bool select)
}
cursmove = FO_CURS;
break;
-
+
case LINE_END:
while (ef->pos < ef->len) {
if (ef->textbuf[ef->pos] == 0) break;
@@ -958,7 +958,7 @@ static int move_cursor(bContext *C, int type, const bool select)
case PREV_LINE:
cursmove = FO_CURSUP;
break;
-
+
case NEXT_LINE:
cursmove = FO_CURSDOWN;
break;
@@ -971,7 +971,7 @@ static int move_cursor(bContext *C, int type, const bool select)
cursmove = FO_PAGEDOWN;
break;
}
-
+
if (cursmove == -1)
return OPERATOR_CANCELLED;
@@ -1016,7 +1016,7 @@ void FONT_OT_move(wmOperatorType *ot)
ot->name = "Move Cursor";
ot->description = "Move cursor to position type";
ot->idname = "FONT_OT_move";
-
+
/* api callbacks */
ot->exec = move_exec;
ot->poll = ED_operator_editfont;
@@ -1043,7 +1043,7 @@ void FONT_OT_move_select(wmOperatorType *ot)
ot->name = "Move Select";
ot->description = "Move the cursor while selecting";
ot->idname = "FONT_OT_move_select";
-
+
/* api callbacks */
ot->exec = move_select_exec;
ot->poll = ED_operator_editfont;
@@ -1084,7 +1084,7 @@ void FONT_OT_change_spacing(wmOperatorType *ot)
ot->name = "Change Spacing";
ot->description = "Change font spacing";
ot->idname = "FONT_OT_change_spacing";
-
+
/* api callbacks */
ot->exec = change_spacing_exec;
ot->poll = ED_operator_editfont;
@@ -1128,7 +1128,7 @@ void FONT_OT_change_character(wmOperatorType *ot)
ot->name = "Change Character";
ot->description = "Change font character code";
ot->idname = "FONT_OT_change_character";
-
+
/* api callbacks */
ot->exec = change_character_exec;
ot->poll = ED_operator_editfont;
@@ -1163,7 +1163,7 @@ void FONT_OT_line_break(wmOperatorType *ot)
ot->name = "Line Break";
ot->description = "Insert line break at cursor position";
ot->idname = "FONT_OT_line_break";
-
+
/* api callbacks */
ot->exec = line_break_exec;
ot->poll = ED_operator_editfont;
@@ -1289,7 +1289,7 @@ void FONT_OT_delete(wmOperatorType *ot)
ot->name = "Delete";
ot->description = "Delete text by cursor position";
ot->idname = "FONT_OT_delete";
-
+
/* api callbacks */
ot->exec = delete_exec;
ot->poll = ED_operator_editfont;
@@ -1312,7 +1312,7 @@ static int insert_text_exec(bContext *C, wmOperator *op)
if (!RNA_struct_property_is_set(op->ptr, "text"))
return OPERATOR_CANCELLED;
-
+
inserted_utf8 = RNA_string_get_alloc(op->ptr, "text", NULL, 0);
len = BLI_strlen_utf8(inserted_utf8);
@@ -1350,7 +1350,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
accentcode = 1;
return OPERATOR_FINISHED;
}
-
+
/* tab should exit editmode, but we allow it to be typed using modifier keys */
if (event_type == TABKEY) {
if ((alt || ctrl || shift) == 0)
@@ -1358,7 +1358,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
else
ascii = 9;
}
-
+
if (event_type == BACKSPACEKEY) {
if (alt && ef->len != 0 && ef->pos > 0)
accentcode = 1;
@@ -1394,7 +1394,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
else {
BLI_assert(0);
}
-
+
kill_selection(obedit, 1);
text_update_edited(C, obedit, FO_EDIT);
}
@@ -1418,7 +1418,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* reset property? */
if (event_val == 0)
accentcode = 0;
-
+
return OPERATOR_FINISHED;
}
@@ -1428,12 +1428,12 @@ void FONT_OT_text_insert(wmOperatorType *ot)
ot->name = "Insert Text";
ot->description = "Insert text at cursor position";
ot->idname = "FONT_OT_text_insert";
-
+
/* api callbacks */
ot->exec = insert_text_exec;
ot->invoke = insert_text_invoke;
ot->poll = ED_operator_editfont;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1449,14 +1449,14 @@ static int textbox_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *obedit = CTX_data_active_object(C);
Curve *cu = obedit->data;
int i;
-
+
if (cu->totbox < 256) {
for (i = cu->totbox; i > cu->actbox; i--) cu->tb[i] = cu->tb[i - 1];
cu->tb[cu->actbox] = cu->tb[cu->actbox - 1];
cu->actbox++;
cu->totbox++;
}
-
+
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -1467,15 +1467,15 @@ void FONT_OT_textbox_add(wmOperatorType *ot)
ot->name = "Add Textbox";
ot->description = "Add a new text box";
ot->idname = "FONT_OT_textbox_add";
-
+
/* api callbacks */
ot->exec = textbox_add_exec;
ot->poll = ED_operator_object_active_editable_font;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
-
+
+
}
@@ -1490,17 +1490,17 @@ static int textbox_remove_exec(bContext *C, wmOperator *op)
Curve *cu = obedit->data;
int i;
int index = RNA_int_get(op->ptr, "index");
-
-
+
+
if (cu->totbox > 1) {
for (i = index; i < cu->totbox; i++) cu->tb[i] = cu->tb[i + 1];
cu->totbox--;
if (cu->actbox >= index)
cu->actbox--;
}
-
+
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-
+
return OPERATOR_FINISHED;
}
@@ -1510,14 +1510,14 @@ void FONT_OT_textbox_remove(wmOperatorType *ot)
ot->name = "Remove Textbox";
ot->description = "Remove the textbox";
ot->idname = "FONT_OT_textbox_remove";
-
+
/* api callbacks */
ot->exec = textbox_remove_exec;
ot->poll = ED_operator_object_active_editable_font;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "The current text box", 0, INT_MAX);
}
@@ -1530,14 +1530,14 @@ void ED_curve_editfont_make(Object *obedit)
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
int len_wchar;
-
+
if (ef == NULL) {
ef = cu->editfont = MEM_callocN(sizeof(EditFont), "editfont");
-
+
ef->textbuf = MEM_callocN((MAXTEXT + 4) * sizeof(wchar_t), "texteditbuf");
ef->textbufinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "texteditbufinfo");
}
-
+
/* Convert the original text to wchar_t */
len_wchar = BLI_strncpy_wchar_from_utf8(ef->textbuf, cu->str, MAXTEXT + 4);
BLI_assert(len_wchar == cu->len_wchar);
@@ -1576,7 +1576,7 @@ void ED_curve_editfont_load(Object *obedit)
/* Copy the wchar to UTF-8 */
BLI_strncpy_wchar_as_utf8(cu->str, ef->textbuf, cu->len + 1);
-
+
if (cu->strinfo)
MEM_freeN(cu->strinfo);
cu->strinfo = MEM_callocN((cu->len_wchar + 4) * sizeof(CharInfo), "texteditinfo");
@@ -1608,7 +1608,7 @@ static int set_case(bContext *C, int ccase)
wchar_t *str;
int len;
int selstart, selend;
-
+
if (BKE_vfont_select_get(obedit, &selstart, &selend)) {
len = (selend - selstart) + 1;
str = &ef->textbuf[selstart];
@@ -1648,7 +1648,7 @@ void FONT_OT_case_set(wmOperatorType *ot)
ot->name = "Set Case";
ot->description = "Set font case";
ot->idname = "FONT_OT_case_set";
-
+
/* api callbacks */
ot->exec = set_case_exec;
ot->poll = ED_operator_editfont;
@@ -1669,7 +1669,7 @@ static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op))
EditFont *ef = cu->editfont;
wchar_t *str;
int len, ccase = CASE_UPPER;
-
+
len = wcslen(ef->textbuf);
str = ef->textbuf;
while (len) {
@@ -1681,7 +1681,7 @@ static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op))
len--;
str++;
}
-
+
return set_case(C, ccase);
}
@@ -1691,7 +1691,7 @@ void FONT_OT_case_toggle(wmOperatorType *ot)
ot->name = "Toggle Case";
ot->description = "Toggle font case";
ot->idname = "FONT_OT_case_toggle";
-
+
/* api callbacks */
ot->exec = toggle_case_exec;
ot->poll = ED_operator_editfont;
@@ -1705,7 +1705,7 @@ void FONT_OT_case_toggle(wmOperatorType *ot)
static void font_ui_template_init(bContext *C, wmOperator *op)
{
PropertyPointerRNA *pprop;
-
+
op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA");
UI_context_active_but_prop_get_templateID(C, &pprop->ptr, &pprop->prop);
}
@@ -1734,7 +1734,7 @@ static int font_open_exec(bContext *C, wmOperator *op)
if (!op->customdata)
font_ui_template_init(C, op);
-
+
/* hook into UI */
pprop = op->customdata;
@@ -1742,7 +1742,7 @@ static int font_open_exec(bContext *C, wmOperator *op)
/* when creating new ID blocks, use is already 1, but RNA
* pointer use also increases user, so this compensates it */
id_us_min(&font->id);
-
+
RNA_id_pointer_create(&font->id, &idptr);
RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr);
RNA_property_update(C, &pprop->ptr, pprop->prop);
@@ -1777,7 +1777,7 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
return font_open_exec(C, op);
RNA_string_set(op->ptr, "filepath", path);
- WM_event_add_fileselect(C, op);
+ WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
}
@@ -1788,15 +1788,15 @@ void FONT_OT_open(wmOperatorType *ot)
ot->name = "Open Font";
ot->idname = "FONT_OT_open";
ot->description = "Load a new font from a file";
-
+
/* api callbacks */
ot->exec = font_open_exec;
ot->invoke = open_invoke;
ot->cancel = font_open_cancel;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
WM_operator_properties_filesel(
ot, FILE_TYPE_FOLDER | FILE_TYPE_FTFONT, FILE_SPECIAL, FILE_OPENFILE,
@@ -1813,7 +1813,7 @@ static int font_unlink_exec(bContext *C, wmOperator *op)
PropertyPointerRNA pprop;
UI_context_active_but_prop_get_templateID(C, &pprop.ptr, &pprop.prop);
-
+
if (pprop.prop == NULL) {
BKE_report(op->reports, RPT_ERROR, "Incorrect context for running font unlink");
return OPERATOR_CANCELLED;
@@ -1834,7 +1834,7 @@ void FONT_OT_unlink(wmOperatorType *ot)
ot->name = "Unlink";
ot->idname = "FONT_OT_unlink";
ot->description = "Unlink active font data-block";
-
+
/* api callbacks */
ot->exec = font_unlink_exec;
}
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 50a6e9125a0..a30cb578046 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -249,7 +249,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1);
/* need to roll-back one point to ensure that there are no gaps in the stroke */
- if (i != 0) {
+ if (i != 0) {
gp_set_tpoint_varying_color(pt - 1, ink, color);
immVertex2iv(pos, &(pt - 1)->x);
++draw_points;
@@ -389,7 +389,7 @@ static void gp_draw_stroke_volumetric_3d(
const bGPDspoint *pt = points;
for (int i = 0; i < totpoints && pt; i++, pt++) {
- gp_set_point_varying_color(pt, ink, color);
+ gp_set_point_varying_color(pt, ink, color);
immAttrib1f(size, pt->pressure * thickness); /* TODO: scale based on view transform */
immVertex3fv(pos, &pt->x); /* we can adjust size in vertex shader based on view/projection! */
}
@@ -650,7 +650,7 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi
immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add);
/* need to roll-back one point to ensure that there are no gaps in the stroke */
- if (i != 0) {
+ if (i != 0) {
const bGPDspoint *pt2 = pt - 1;
mul_v3_m4v3(fpt, diff_mat, &pt2->x);
gp_set_point_varying_color(pt2, ink, color);
@@ -1322,7 +1322,7 @@ void ED_gp_draw_interpolation(tGPDinterpolate *tgpi, const int type)
UI_GetThemeColor3fv(TH_GP_VERTEX_SELECT, color);
color[3] = 0.6f;
- int dflag = 0;
+ int dflag = 0;
/* if 3d stuff, enable flags */
if (type == REGION_DRAW_POST_VIEW) {
dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS);
@@ -1366,7 +1366,7 @@ static void gp_draw_data_layers(
/* set basic stroke thickness */
glLineWidth(lthick);
-
+
/* Add layer drawing settings to the set of "draw flags"
* NOTE: If the setting doesn't apply, it *must* be cleared,
* as dflag's carry over from the previous layer
@@ -1386,7 +1386,7 @@ static void gp_draw_data_layers(
GP_DRAWFLAG_APPLY((gpl->flag & GP_LAYER_HQ_FILL), GP_DRAWDATA_HQ_FILL);
#undef GP_DRAWFLAG_APPLY
-
+
/* Draw 'onionskins' (frame left + right)
* - It is only possible to show these if the option is enabled
* - The "no onions" flag prevents ghosts from appearing during animation playback/scrubbing
@@ -1394,8 +1394,8 @@ static void gp_draw_data_layers(
* - The per-layer "always show" flag however overrides the playback/render restriction,
* allowing artists to selectively turn onionskins on/off during playback
*/
- if ((gpl->flag & GP_LAYER_ONIONSKIN) &&
- ((dflag & GP_DRAWDATA_NO_ONIONS) == 0 || (gpl->flag & GP_LAYER_GHOST_ALWAYS)))
+ if ((gpl->flag & GP_LAYER_ONIONSKIN) &&
+ ((dflag & GP_DRAWDATA_NO_ONIONS) == 0 || (gpl->flag & GP_LAYER_GHOST_ALWAYS)))
{
/* Drawing method - only immediately surrounding (gstep = 0),
* or within a frame range on either side (gstep > 0)
@@ -1430,7 +1430,7 @@ static void gp_draw_data_layers(
{
/* Buffer stroke needs to be drawn with a different linestyle
* to help differentiate them from normal strokes.
- *
+ *
* It should also be noted that sbuffer contains temporary point types
* i.e. tGPspoints NOT bGPDspoints
*/
@@ -1465,7 +1465,7 @@ static void gp_draw_status_text(const bGPdata *gpd, ARegion *ar)
int font_id = BLF_default();
BLF_width_and_height(font_id, printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]);
-
+
int xco = (rect.xmax - U.widget_unit) - (int)printable_size[0];
int yco = (rect.ymax - U.widget_unit);
@@ -1499,7 +1499,7 @@ static void gp_draw_data(
/* turn on smooth lines (i.e. anti-aliasing) */
glEnable(GL_LINE_SMOOTH);
- /* XXX: turn on some way of ensuring that the polygon edges get smoothed
+ /* XXX: turn on some way of ensuring that the polygon edges get smoothed
* GL_POLYGON_SMOOTH is nasty and shouldn't be used, as it ends up
* creating internal white rays due to the ways it accumulates stuff
*/
@@ -1643,7 +1643,7 @@ void ED_gpencil_draw_view2d(const bContext *C, bool onlyv2d)
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
int dflag = 0;
-
+
/* check that we have grease-pencil stuff to draw */
if (sa == NULL) return;
bGPdata *gpd = ED_gpencil_data_get_active(C); // XXX
@@ -1725,7 +1725,7 @@ void ED_gpencil_draw_view3d(wmWindowManager *wm,
}
/* draw it! */
- gp_draw_data_all(scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype);
+ gp_draw_data_all(scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype);
}
void ED_gpencil_draw_ex(Scene *scene, bGPdata *gpd, int winx, int winy, const int cfra, const char spacetype)
diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c
index 90d44503013..5e62a87caf3 100644
--- a/source/blender/editors/gpencil/editaction_gpencil.c
+++ b/source/blender/editors/gpencil/editaction_gpencil.c
@@ -66,18 +66,18 @@
bool ED_gplayer_frames_looper(bGPDlayer *gpl, Scene *scene, short (*gpf_cb)(bGPDframe *, Scene *))
{
bGPDframe *gpf;
-
+
/* error checker */
if (gpl == NULL)
return false;
-
+
/* do loop */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
/* execute callback */
if (gpf_cb(gpf, scene))
return true;
}
-
+
/* nothing to return */
return false;
}
@@ -90,19 +90,19 @@ void ED_gplayer_make_cfra_list(bGPDlayer *gpl, ListBase *elems, bool onlysel)
{
bGPDframe *gpf;
CfraElem *ce;
-
+
/* error checking */
if (ELEM(NULL, gpl, elems))
return;
-
+
/* loop through gp-frames, adding */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
if ((onlysel == 0) || (gpf->flag & GP_FRAME_SELECT)) {
ce = MEM_callocN(sizeof(CfraElem), "CfraElem");
-
+
ce->cfra = (float)gpf->framenum;
ce->sel = (gpf->flag & GP_FRAME_SELECT) ? 1 : 0;
-
+
BLI_addtail(elems, ce);
}
}
@@ -115,17 +115,17 @@ void ED_gplayer_make_cfra_list(bGPDlayer *gpl, ListBase *elems, bool onlysel)
bool ED_gplayer_frame_select_check(bGPDlayer *gpl)
{
bGPDframe *gpf;
-
+
/* error checking */
if (gpl == NULL)
return false;
-
+
/* stop at the first one found */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
if (gpf->flag & GP_FRAME_SELECT)
return true;
}
-
+
/* not found */
return false;
}
@@ -135,7 +135,7 @@ static void gpframe_select(bGPDframe *gpf, short select_mode)
{
if (gpf == NULL)
return;
-
+
switch (select_mode) {
case SELECT_ADD:
gpf->flag |= GP_FRAME_SELECT;
@@ -153,11 +153,11 @@ static void gpframe_select(bGPDframe *gpf, short select_mode)
void ED_gpencil_select_frames(bGPDlayer *gpl, short select_mode)
{
bGPDframe *gpf;
-
+
/* error checking */
if (gpl == NULL)
return;
-
+
/* handle according to mode */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
gpframe_select(gpf, select_mode);
@@ -170,7 +170,7 @@ void ED_gplayer_frame_select_set(bGPDlayer *gpl, short mode)
/* error checking */
if (gpl == NULL)
return;
-
+
/* now call the standard function */
ED_gpencil_select_frames(gpl, mode);
}
@@ -179,12 +179,12 @@ void ED_gplayer_frame_select_set(bGPDlayer *gpl, short mode)
void ED_gpencil_select_frame(bGPDlayer *gpl, int selx, short select_mode)
{
bGPDframe *gpf;
-
+
if (gpl == NULL)
return;
-
+
gpf = BKE_gpencil_layer_find_frame(gpl, selx);
-
+
if (gpf) {
gpframe_select(gpf, select_mode);
}
@@ -194,10 +194,10 @@ void ED_gpencil_select_frame(bGPDlayer *gpl, int selx, short select_mode)
void ED_gplayer_frames_select_border(bGPDlayer *gpl, float min, float max, short select_mode)
{
bGPDframe *gpf;
-
+
if (gpl == NULL)
return;
-
+
/* only select those frames which are in bounds */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
if (IN_RANGE(gpf->framenum, min, max))
@@ -209,21 +209,21 @@ void ED_gplayer_frames_select_border(bGPDlayer *gpl, float min, float max, short
void ED_gplayer_frames_select_region(KeyframeEditData *ked, bGPDlayer *gpl, short tool, short select_mode)
{
bGPDframe *gpf;
-
+
if (gpl == NULL)
return;
-
+
/* only select frames which are within the region */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
/* construct a dummy point coordinate to do this testing with */
float pt[2] = {0};
-
+
pt[0] = gpf->framenum;
pt[1] = ked->channel_y;
-
+
/* check the necessary regions */
if (tool == BEZT_OK_CHANNEL_LASSO) {
- /* Lasso */
+ /* Lasso */
if (keyframe_region_lasso_test(ked->data, pt))
gpframe_select(gpf, select_mode);
}
@@ -243,21 +243,21 @@ bool ED_gplayer_frames_delete(bGPDlayer *gpl)
{
bGPDframe *gpf, *gpfn;
bool changed = false;
-
+
/* error checking */
if (gpl == NULL)
return false;
-
+
/* check for frames to delete */
for (gpf = gpl->frames.first; gpf; gpf = gpfn) {
gpfn = gpf->next;
-
+
if (gpf->flag & GP_FRAME_SELECT) {
BKE_gpencil_layer_delframe(gpl, gpf);
changed = true;
}
}
-
+
return changed;
}
@@ -265,23 +265,23 @@ bool ED_gplayer_frames_delete(bGPDlayer *gpl)
void ED_gplayer_frames_duplicate(bGPDlayer *gpl)
{
bGPDframe *gpf, *gpfn;
-
+
/* error checking */
if (gpl == NULL)
return;
-
+
/* duplicate selected frames */
for (gpf = gpl->frames.first; gpf; gpf = gpfn) {
gpfn = gpf->next;
-
+
/* duplicate this frame */
if (gpf->flag & GP_FRAME_SELECT) {
bGPDframe *gpfd;
-
+
/* duplicate frame, and deselect self */
gpfd = BKE_gpencil_frame_duplicate(gpf);
gpf->flag &= ~GP_FRAME_SELECT;
-
+
BLI_insertlinkafter(&gpl->frames, gpf, gpfd);
}
}
@@ -293,10 +293,10 @@ void ED_gplayer_frames_duplicate(bGPDlayer *gpl)
void ED_gplayer_frames_keytype_set(bGPDlayer *gpl, short type)
{
bGPDframe *gpf;
-
+
if (gpl == NULL)
return;
-
+
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
if (gpf->flag & GP_FRAME_SELECT) {
gpf->key_type = type;
@@ -327,7 +327,7 @@ void ED_gpencil_anim_copybuf_free(void)
{
BKE_gpencil_free_layers(&gp_anim_copybuf);
BLI_listbase_clear(&gp_anim_copybuf);
-
+
gp_anim_copy_firstframe = 999999999;
gp_anim_copy_lastframe = -999999999;
gp_anim_copy_cfra = 0;
@@ -344,23 +344,23 @@ bool ED_gpencil_anim_copybuf_copy(bAnimContext *ac)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
Scene *scene = ac->scene;
-
-
+
+
/* clear buffer first */
ED_gpencil_anim_copybuf_free();
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* assume that each of these is a GP layer */
for (ale = anim_data.first; ale; ale = ale->next) {
ListBase copied_frames = {NULL, NULL};
bGPDlayer *gpl = (bGPDlayer *)ale->data;
bGPDframe *gpf;
-
+
/* loop over frames, and copy only selected frames */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
/* if frame is selected, make duplicate it and its strokes */
@@ -368,41 +368,41 @@ bool ED_gpencil_anim_copybuf_copy(bAnimContext *ac)
/* make a copy of this frame */
bGPDframe *new_frame = BKE_gpencil_frame_duplicate(gpf);
BLI_addtail(&copied_frames, new_frame);
-
+
/* extend extents for keyframes encountered */
if (gpf->framenum < gp_anim_copy_firstframe)
- gp_anim_copy_firstframe = gpf->framenum;
+ gp_anim_copy_firstframe = gpf->framenum;
if (gpf->framenum > gp_anim_copy_lastframe)
gp_anim_copy_lastframe = gpf->framenum;
}
}
-
+
/* create a new layer in buffer if there were keyframes here */
if (BLI_listbase_is_empty(&copied_frames) == false) {
bGPDlayer *new_layer = MEM_callocN(sizeof(bGPDlayer), "GPCopyPasteLayer");
BLI_addtail(&gp_anim_copybuf, new_layer);
-
+
/* move over copied frames */
BLI_movelisttolist(&new_layer->frames, &copied_frames);
BLI_assert(copied_frames.first == NULL);
-
+
/* make a copy of the layer's name - for name-based matching later... */
BLI_strncpy(new_layer->info, gpl->info, sizeof(new_layer->info));
}
}
-
+
/* in case 'relative' paste method is used */
gp_anim_copy_cfra = CFRA;
-
+
/* clean up */
ANIM_animdata_freelist(&anim_data);
-
+
/* check if anything ended up in the buffer */
if (ELEM(NULL, gp_anim_copybuf.first, gp_anim_copybuf.last)) {
BKE_report(ac->reports, RPT_ERROR, "No keyframes copied to keyframes copy/paste buffer");
return false;
}
-
+
/* report success */
return true;
}
@@ -414,22 +414,22 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
Scene *scene = ac->scene;
bool no_name = false;
int offset = 0;
-
+
/* check if buffer is empty */
if (BLI_listbase_is_empty(&gp_anim_copybuf)) {
BKE_report(ac->reports, RPT_ERROR, "No data in buffer to paste");
return false;
}
-
+
/* check if single channel in buffer (disregard names if so) */
if (gp_anim_copybuf.first == gp_anim_copybuf.last) {
no_name = true;
}
-
+
/* methods of offset (eKeyPasteOffset) */
switch (offset_mode) {
case KEYFRAME_PASTE_OFFSET_CFRA_START:
@@ -446,19 +446,19 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
break;
}
-
+
/* filter data */
// TODO: try doing it with selection, then without selection imits
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* from selected channels */
for (ale = anim_data.first; ale; ale = ale->next) {
bGPDlayer *gpld = (bGPDlayer *)ale->data;
bGPDlayer *gpls = NULL;
bGPDframe *gpfs, *gpf;
-
-
+
+
/* find suitable layer from buffer to use to paste from */
for (gpls = gp_anim_copybuf.first; gpls; gpls = gpls->next) {
/* check if layer name matches */
@@ -466,21 +466,21 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
break;
}
}
-
+
/* this situation might occur! */
if (gpls == NULL)
continue;
-
+
/* add frames from buffer */
for (gpfs = gpls->frames.first; gpfs; gpfs = gpfs->next) {
/* temporarily apply offset to buffer-frame while copying */
gpfs->framenum += offset;
-
+
/* get frame to copy data into (if no frame returned, then just ignore) */
gpf = BKE_gpencil_layer_getframe(gpld, gpfs->framenum, 1);
if (gpf) {
bGPDstroke *gps, *gpsn;
-
+
/* This should be the right frame... as it may be a pre-existing frame,
* must make sure that only compatible stroke types get copied over
* - We cannot just add a duplicate frame, as that would cause errors
@@ -495,19 +495,19 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
/* duplicate triangle information */
gpsn->triangles = MEM_dupallocN(gps->triangles);
/* append stroke to frame */
- BLI_addtail(&gpf->strokes, gpsn);
+ BLI_addtail(&gpf->strokes, gpsn);
}
-
+
/* if no strokes (i.e. new frame) added, free gpf */
if (BLI_listbase_is_empty(&gpf->strokes))
BKE_gpencil_layer_delframe(gpld, gpf);
}
-
+
/* unapply offset from buffer-frame */
gpfs->framenum -= offset;
}
}
-
+
/* clean up */
ANIM_animdata_freelist(&anim_data);
return true;
@@ -574,37 +574,37 @@ void ED_gplayer_snap_frames(bGPDlayer *gpl, Scene *scene, short mode)
static short mirror_gpf_cframe(bGPDframe *gpf, Scene *scene)
{
int diff;
-
+
if (gpf->flag & GP_FRAME_SELECT) {
diff = CFRA - gpf->framenum;
gpf->framenum = CFRA + diff;
}
-
+
return 0;
}
static short mirror_gpf_yaxis(bGPDframe *gpf, Scene *UNUSED(scene))
{
int diff;
-
+
if (gpf->flag & GP_FRAME_SELECT) {
diff = -gpf->framenum;
gpf->framenum = diff;
}
-
+
return 0;
}
static short mirror_gpf_xaxis(bGPDframe *gpf, Scene *UNUSED(scene))
{
int diff;
-
+
/* NOTE: since we can't really do this, we just do the same as for yaxis... */
if (gpf->flag & GP_FRAME_SELECT) {
diff = -gpf->framenum;
gpf->framenum = diff;
}
-
+
return 0;
}
@@ -613,7 +613,7 @@ static short mirror_gpf_marker(bGPDframe *gpf, Scene *scene)
static TimeMarker *marker;
static short initialized = 0;
int diff;
-
+
/* In order for this mirror function to work without
* any extra arguments being added, we use the case
* of bezt==NULL to denote that we should find the
@@ -621,7 +621,7 @@ static short mirror_gpf_marker(bGPDframe *gpf, Scene *scene)
* to use this way, as it will be set to null after
* each cycle in which this is called.
*/
-
+
if (gpf) {
/* mirroring time */
if ((gpf->flag & GP_FRAME_SELECT) && (marker)) {
@@ -644,7 +644,7 @@ static short mirror_gpf_marker(bGPDframe *gpf, Scene *scene)
}
}
}
-
+
return 0;
}
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 1cb882e9a43..c2e532be0b3 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -87,54 +87,54 @@ typedef struct tGP_BrushEditData {
/* Current editor/region/etc. */
/* NOTE: This stuff is mainly needed to handle 3D view projection stuff... */
Scene *scene;
-
+
ScrArea *sa;
ARegion *ar;
-
+
/* Current GPencil datablock */
bGPdata *gpd;
-
+
/* Brush Settings */
GP_BrushEdit_Settings *settings;
GP_EditBrush_Data *brush;
-
+
eGP_EditBrush_Types brush_type;
eGP_EditBrush_Flag flag;
-
+
/* Space Conversion Data */
GP_SpaceConversion gsc;
-
-
+
+
/* Is the brush currently painting? */
bool is_painting;
-
+
/* Start of new sculpt stroke */
bool first;
-
+
/* Current frame */
int cfra;
-
-
+
+
/* Brush Runtime Data: */
/* - position and pressure
* - the *_prev variants are the previous values
*/
int mval[2], mval_prev[2];
float pressure, pressure_prev;
-
+
/* - effect vector (e.g. 2D/3D translation for grab brush) */
float dvec[3];
-
+
/* brush geometry (bounding box) */
rcti brush_rect;
-
+
/* Custom data for certain brushes */
/* - map from bGPDstroke's to structs containing custom data about those strokes */
GHash *stroke_customdata;
/* - general customdata */
void *customdata;
-
-
+
+
/* Timer for in-place accumulation of brush effect */
wmTimer *timer;
bool timerTick; /* is this event from a timer */
@@ -170,12 +170,12 @@ static bool gp_brush_invert_check(tGP_BrushEditData *gso)
{
/* The basic setting is the brush's setting (from the panel) */
bool invert = ((gso->brush->flag & GP_EDITBRUSH_FLAG_INVERT) != 0);
-
+
/* During runtime, the user can hold down the Ctrl key to invert the basic behaviour */
if (gso->flag & GP_EDITBRUSH_FLAG_INVERT) {
invert ^= true;
}
-
+
return invert;
}
@@ -183,26 +183,26 @@ static bool gp_brush_invert_check(tGP_BrushEditData *gso)
static float gp_brush_influence_calc(tGP_BrushEditData *gso, const int radius, const int co[2])
{
GP_EditBrush_Data *brush = gso->brush;
-
+
/* basic strength factor from brush settings */
float influence = brush->strength;
-
+
/* use pressure? */
if (brush->flag & GP_EDITBRUSH_FLAG_USE_PRESSURE) {
influence *= gso->pressure;
}
-
+
/* distance fading */
if (brush->flag & GP_EDITBRUSH_FLAG_USE_FALLOFF) {
float distance = (float)len_v2v2_int(gso->mval, co);
float fac;
-
+
CLAMP(distance, 0.0f, (float)radius);
fac = 1.0f - (distance / (float)radius);
-
+
influence *= fac;
}
-
+
/* return influence */
return influence;
}
@@ -241,7 +241,7 @@ static bool gp_brush_smooth_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i
if (gso->settings->flag & GP_BRUSHEDIT_FLAG_APPLY_THICKNESS) {
gp_smooth_stroke_thickness(gps, i, inf);
}
-
+
return true;
}
@@ -254,13 +254,13 @@ static bool gp_brush_thickness_apply(tGP_BrushEditData *gso, bGPDstroke *gps, in
{
bGPDspoint *pt = gps->points + i;
float inf;
-
+
/* Compute strength of effect
* - We divide the strength by 10, so that users can set "sane" values.
* Otherwise, good default values are in the range of 0.093
*/
inf = gp_brush_influence_calc(gso, radius, co) / 10.0f;
-
+
/* apply */
// XXX: this is much too strong, and it should probably do some smoothing with the surrounding stuff
if (gp_brush_invert_check(gso)) {
@@ -271,7 +271,7 @@ static bool gp_brush_thickness_apply(tGP_BrushEditData *gso, bGPDstroke *gps, in
/* make line thicker - increase stroke pressure */
pt->pressure += inf;
}
-
+
/* Pressure should stay within [0.0, 1.0]
* However, it is nice for volumetric strokes to be able to exceed
* the upper end of this range. Therefore, we don't actually clamp
@@ -279,7 +279,7 @@ static bool gp_brush_thickness_apply(tGP_BrushEditData *gso, bGPDstroke *gps, in
*/
if (pt->pressure < 0.0f)
pt->pressure = 0.0f;
-
+
return true;
}
@@ -333,7 +333,7 @@ typedef struct tGPSB_Grab_StrokeData {
int *points;
/* array of influence weights for each of the included points */
float *weights;
-
+
/* capacity of the arrays */
int capacity;
/* actual number of items currently stored */
@@ -344,9 +344,9 @@ typedef struct tGPSB_Grab_StrokeData {
static void gp_brush_grab_stroke_init(tGP_BrushEditData *gso, bGPDstroke *gps)
{
tGPSB_Grab_StrokeData *data = NULL;
-
+
BLI_assert(gps->totpoints > 0);
-
+
/* Check if there are buffers already (from a prior run) */
if (BLI_ghash_haskey(gso->stroke_customdata, gps)) {
/* Ensure that the caches are empty
@@ -355,25 +355,25 @@ static void gp_brush_grab_stroke_init(tGP_BrushEditData *gso, bGPDstroke *gps)
*/
data = BLI_ghash_lookup(gso->stroke_customdata, gps);
BLI_assert(data != NULL);
-
+
data->size = 0; /* minimum requirement - so that we can repopulate again */
-
+
memset(data->points, 0, sizeof(int) * data->capacity);
memset(data->weights, 0, sizeof(float) * data->capacity);
}
else {
/* Create new instance */
data = MEM_callocN(sizeof(tGPSB_Grab_StrokeData), "GP Stroke Grab Data");
-
+
data->capacity = gps->totpoints;
data->size = 0;
-
+
data->points = MEM_callocN(sizeof(int) * data->capacity, "GP Stroke Grab Indices");
data->weights = MEM_callocN(sizeof(float) * data->capacity, "GP Stroke Grab Weights");
-
+
/* hook up to the cache */
BLI_ghash_insert(gso->stroke_customdata, gps, data);
- }
+ }
}
/* store references to stroke points in the initial stage */
@@ -382,15 +382,15 @@ static bool gp_brush_grab_store_points(tGP_BrushEditData *gso, bGPDstroke *gps,
{
tGPSB_Grab_StrokeData *data = BLI_ghash_lookup(gso->stroke_customdata, gps);
float inf = gp_brush_influence_calc(gso, radius, co);
-
+
BLI_assert(data != NULL);
BLI_assert(data->size < data->capacity);
-
+
/* insert this point into the set of affected points */
data->points[data->size] = i;
data->weights[data->size] = inf;
data->size++;
-
+
/* done */
return true;
}
@@ -406,13 +406,13 @@ static void gp_brush_grab_calc_dvec(tGP_BrushEditData *gso)
RegionView3D *rv3d = gso->ar->regiondata;
float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d)->location;
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
-
+
float mval_f[2];
-
+
/* convert from 2D screenspace to 3D... */
mval_f[0] = (float)(gso->mval[0] - gso->mval_prev[0]);
mval_f[1] = (float)(gso->mval[1] - gso->mval_prev[1]);
-
+
ED_view3d_win_to_delta(gso->ar, mval_f, gso->dvec, zfac);
}
else {
@@ -435,7 +435,7 @@ static void gp_brush_grab_apply_cached(
for (i = 0; i < data->size; i++) {
bGPDspoint *pt = &gps->points[data->points[i]];
float delta[3] = {0.0f};
-
+
/* adjust the amount of displacement to apply */
mul_v3_v3fl(delta, gso->dvec, data->weights[i]);
if (!parented) {
@@ -454,7 +454,7 @@ static void gp_brush_grab_apply_cached(
invert_m4_m4(inverse_diff_mat, diff_mat);
mul_m4_v3(inverse_diff_mat, &pt->x);
}
-
+
}
}
@@ -462,11 +462,11 @@ static void gp_brush_grab_apply_cached(
static void gp_brush_grab_stroke_free(void *ptr)
{
tGPSB_Grab_StrokeData *data = (tGPSB_Grab_StrokeData *)ptr;
-
+
/* free arrays */
MEM_freeN(data->points);
MEM_freeN(data->weights);
-
+
/* ... and this item itself, since it was also allocated */
MEM_freeN(data);
}
@@ -481,10 +481,10 @@ static bool gp_brush_push_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i,
bGPDspoint *pt = gps->points + i;
float inf = gp_brush_influence_calc(gso, radius, co);
float delta[3] = {0.0f};
-
+
/* adjust the amount of displacement to apply */
mul_v3_v3fl(delta, gso->dvec, inf);
-
+
/* apply */
add_v3_v3(&pt->x, delta);
@@ -506,12 +506,12 @@ static void gp_brush_calc_midpoint(tGP_BrushEditData *gso)
RegionView3D *rv3d = gso->ar->regiondata;
float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d)->location;
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
-
+
float mval_f[2] = {UNPACK2(gso->mval)};
float mval_prj[2];
float dvec[3];
-
-
+
+
if (ED_view3d_project_float_global(gso->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
sub_v2_v2v2(mval_f, mval_prj, mval_f);
ED_view3d_win_to_delta(gso->ar, mval_f, dvec, zfac);
@@ -537,17 +537,17 @@ static bool gp_brush_pinch_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i,
bGPDspoint *pt = gps->points + i;
float fac, inf;
float vec[3];
-
+
/* Scale down standard influence value to get it more manageable...
* - No damping = Unmanageable at > 0.5 strength
* - Div 10 = Not enough effect
* - Div 5 = Happy medium... (by trial and error)
*/
inf = gp_brush_influence_calc(gso, radius, co) / 5.0f;
-
+
/* 1) Make this point relative to the cursor/midpoint (dvec) */
sub_v3_v3v3(vec, &pt->x, gso->dvec);
-
+
/* 2) Shrink the distance by pulling the point towards the midpoint
* (0.0 = at midpoint, 1 = at edge of brush region)
* OR
@@ -562,10 +562,10 @@ static bool gp_brush_pinch_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i,
fac = 1.0f - (inf * inf); /* squared to temper the effect... */
}
mul_v3_fl(vec, fac);
-
+
/* 3) Translate back to original space, with the shrinkage applied */
add_v3_v3v3(&pt->x, gso->dvec, vec);
-
+
/* done */
return true;
}
@@ -582,16 +582,16 @@ static bool gp_brush_twist_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i,
{
bGPDspoint *pt = gps->points + i;
float angle, inf;
-
+
/* Angle to rotate by */
inf = gp_brush_influence_calc(gso, radius, co);
angle = DEG2RADF(1.0f) * inf;
-
+
if (gp_brush_invert_check(gso)) {
/* invert angle that we rotate by */
angle *= -1;
}
-
+
/* Rotate in 2D or 3D space? */
if (gps->flag & GP_STROKE_3DSPACE) {
/* Perform rotation in 3D space... */
@@ -599,13 +599,13 @@ static bool gp_brush_twist_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i,
float rmat[3][3];
float axis[3];
float vec[3];
-
+
/* Compute rotation matrix - rotate around view vector by angle */
negate_v3_v3(axis, rv3d->persinv[2]);
normalize_v3(axis);
-
+
axis_angle_normalized_to_mat3(rmat, axis, angle);
-
+
/* Rotate point (no matrix-space transforms needed, as GP points are in world space) */
sub_v3_v3v3(vec, &pt->x, gso->dvec); /* make relative to center (center is stored in dvec) */
mul_m3_v3(rmat, vec);
@@ -615,20 +615,20 @@ static bool gp_brush_twist_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i,
const float axis[3] = {0.0f, 0.0f, 1.0f};
float vec[3] = {0.0f};
float rmat[3][3];
-
+
/* Express position of point relative to cursor, ready to rotate */
// XXX: There is still some offset here, but it's close to working as expected...
vec[0] = (float)(co[0] - gso->mval[0]);
vec[1] = (float)(co[1] - gso->mval[1]);
-
+
/* rotate point */
axis_angle_normalized_to_mat3(rmat, axis, angle);
mul_m3_v3(rmat, vec);
-
+
/* Convert back to screen-coordinates */
vec[0] += (float)gso->mval[0];
vec[1] += (float)gso->mval[1];
-
+
/* Map from screen-coordinates to final coordinate space */
if (gps->flag & GP_STROKE_2DSPACE) {
View2D *v2d = gso->gsc.v2d;
@@ -639,7 +639,7 @@ static bool gp_brush_twist_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i,
copy_v2_v2(&pt->x, vec);
}
}
-
+
/* done */
return true;
}
@@ -653,7 +653,7 @@ static bool gp_brush_randomize_apply(tGP_BrushEditData *gso, bGPDstroke *gps, in
const int radius, const int co[2])
{
bGPDspoint *pt = gps->points + i;
-
+
/* Amount of jitter to apply depends on the distance of the point to the cursor,
* as well as the strength of the brush
*/
@@ -766,13 +766,13 @@ static bool gp_brush_randomize_apply(tGP_BrushEditData *gso, bGPDstroke *gps, in
typedef struct tGPSB_CloneBrushData {
/* midpoint of the strokes on the clipboard */
float buffer_midpoint[3];
-
+
/* number of strokes in the paste buffer (and/or to be created each time) */
size_t totitems;
-
+
/* for "stamp" mode, the currently pasted brushes */
bGPDstroke **new_strokes;
-
+
/* mapping from colors referenced per stroke, to the new colours in the "pasted" strokes */
GHash *new_colors;
} tGPSB_CloneBrushData;
@@ -782,43 +782,43 @@ static void gp_brush_clone_init(bContext *C, tGP_BrushEditData *gso)
{
tGPSB_CloneBrushData *data;
bGPDstroke *gps;
-
+
/* init custom data */
gso->customdata = data = MEM_callocN(sizeof(tGPSB_CloneBrushData), "CloneBrushData");
-
+
/* compute midpoint of strokes on clipboard */
for (gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) {
if (ED_gpencil_stroke_can_use(C, gps)) {
const float dfac = 1.0f / ((float)gps->totpoints);
float mid[3] = {0.0f};
-
+
bGPDspoint *pt;
int i;
-
+
/* compute midpoint of this stroke */
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
float co[3];
-
+
mul_v3_v3fl(co, &pt->x, dfac);
add_v3_v3(mid, co);
}
-
+
/* combine this stroke's data with the main data */
add_v3_v3(data->buffer_midpoint, mid);
data->totitems++;
}
}
-
+
/* Divide the midpoint by the number of strokes, to finish averaging it */
if (data->totitems > 1) {
mul_v3_fl(data->buffer_midpoint, 1.0f / (float)data->totitems);
}
-
+
/* Create a buffer for storing the current strokes */
if (1 /*gso->brush->mode == GP_EDITBRUSH_CLONE_MODE_STAMP*/) {
data->new_strokes = MEM_callocN(sizeof(bGPDstroke *) * data->totitems, "cloned strokes ptr array");
}
-
+
/* Init colormap for mapping between the pasted stroke's source colour(names)
* and the final colours that will be used here instead...
*/
@@ -829,19 +829,19 @@ static void gp_brush_clone_init(bContext *C, tGP_BrushEditData *gso)
static void gp_brush_clone_free(tGP_BrushEditData *gso)
{
tGPSB_CloneBrushData *data = gso->customdata;
-
+
/* free strokes array */
if (data->new_strokes) {
MEM_freeN(data->new_strokes);
data->new_strokes = NULL;
}
-
+
/* free copybuf colormap */
if (data->new_colors) {
BLI_ghash_free(data->new_colors, NULL, NULL);
data->new_colors = NULL;
}
-
+
/* free the customdata itself */
MEM_freeN(data);
gso->customdata = NULL;
@@ -851,44 +851,44 @@ static void gp_brush_clone_free(tGP_BrushEditData *gso)
static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso)
{
tGPSB_CloneBrushData *data = gso->customdata;
-
+
Scene *scene = gso->scene;
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, true);
bGPDstroke *gps;
-
+
float delta[3];
size_t strokes_added = 0;
-
+
/* Compute amount to offset the points by */
/* NOTE: This assumes that screenspace strokes are NOT used in the 3D view... */
-
+
gp_brush_calc_midpoint(gso); /* this puts the cursor location into gso->dvec */
sub_v3_v3v3(delta, gso->dvec, data->buffer_midpoint);
-
+
/* Copy each stroke into the layer */
for (gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) {
if (ED_gpencil_stroke_can_use(C, gps)) {
bGPDstroke *new_stroke;
bGPDspoint *pt;
int i;
-
+
/* Make a new stroke */
new_stroke = MEM_dupallocN(gps);
-
+
new_stroke->points = MEM_dupallocN(gps->points);
new_stroke->triangles = MEM_dupallocN(gps->triangles);
-
+
new_stroke->next = new_stroke->prev = NULL;
BLI_addtail(&gpf->strokes, new_stroke);
-
+
/* Fix color references */
BLI_assert(new_stroke->colorname[0] != '\0');
new_stroke->palcolor = BLI_ghash_lookup(data->new_colors, new_stroke->colorname);
-
+
BLI_assert(new_stroke->palcolor != NULL);
BLI_strncpy(new_stroke->colorname, new_stroke->palcolor->info, sizeof(new_stroke->colorname));
-
+
/* Adjust all the stroke's points, so that the strokes
* get pasted relative to where the cursor is now
*/
@@ -896,7 +896,7 @@ static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso)
/* assume that the delta can just be applied, and then everything works */
add_v3_v3(&pt->x, delta);
}
-
+
/* Store ref for later */
if ((data->new_strokes) && (strokes_added < data->totitems)) {
data->new_strokes[strokes_added] = new_stroke;
@@ -911,31 +911,31 @@ static void gp_brush_clone_adjust(tGP_BrushEditData *gso)
{
tGPSB_CloneBrushData *data = gso->customdata;
size_t snum;
-
+
/* Compute the amount of movement to apply (overwrites dvec) */
gp_brush_grab_calc_dvec(gso);
-
+
/* For each of the stored strokes, apply the offset to each point */
/* NOTE: Again this assumes that in the 3D view, we only have 3d space and not screenspace strokes... */
for (snum = 0; snum < data->totitems; snum++) {
bGPDstroke *gps = data->new_strokes[snum];
bGPDspoint *pt;
int i;
-
+
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
if (gso->brush->flag & GP_EDITBRUSH_FLAG_USE_FALLOFF) {
/* "Smudge" Effect when falloff is enabled */
float delta[3] = {0.0f};
int sco[2] = {0};
float influence;
-
+
/* compute influence on point */
gp_point_to_xy(&gso->gsc, gps, pt, &sco[0], &sco[1]);
influence = gp_brush_influence_calc(gso, gso->brush->size, sco);
-
+
/* adjust the amount of displacement to apply */
mul_v3_v3fl(delta, gso->dvec, influence);
-
+
/* apply */
add_v3_v3(&pt->x, delta);
}
@@ -967,7 +967,7 @@ static bool gpsculpt_brush_apply_clone(bContext *C, tGP_BrushEditData *gso)
gp_brush_clone_add(C, gso);
}
}
-
+
return true;
}
@@ -1007,7 +1007,7 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customda
static void gpencil_toggle_brush_cursor(bContext *C, bool enable)
{
GP_BrushEdit_Settings *gset = gpsculpt_get_settings(CTX_data_scene(C));
-
+
if (gset->paintcursor && !enable) {
/* clear cursor */
WM_paint_cursor_end(CTX_wm_manager(C), gset->paintcursor);
@@ -1015,8 +1015,8 @@ static void gpencil_toggle_brush_cursor(bContext *C, bool enable)
}
else if (enable) {
/* enable cursor */
- gset->paintcursor = WM_paint_cursor_activate(CTX_wm_manager(C),
- NULL,
+ gset->paintcursor = WM_paint_cursor_activate(CTX_wm_manager(C),
+ NULL,
gp_brush_drawcursor, NULL);
}
}
@@ -1029,15 +1029,15 @@ static void gpsculpt_brush_header_set(bContext *C, tGP_BrushEditData *gso)
{
const char *brush_name = NULL;
char str[UI_MAX_DRAW_STR] = "";
-
+
RNA_enum_name(rna_enum_gpencil_sculpt_brush_items, gso->brush_type, &brush_name);
-
+
BLI_snprintf(str, sizeof(str),
IFACE_("GPencil Sculpt: %s Stroke | LMB to paint | RMB/Escape to Exit"
" | Ctrl to Invert Action | Wheel Up/Down for Size "
" | Shift-Wheel Up/Down for Strength"),
(brush_name) ? brush_name : "<?>");
-
+
ED_area_headerprint(CTX_wm_area(C), str);
}
@@ -1050,36 +1050,36 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
tGP_BrushEditData *gso;
-
+
/* setup operator data */
gso = MEM_callocN(sizeof(tGP_BrushEditData), "tGP_BrushEditData");
op->customdata = gso;
-
+
/* store state */
gso->settings = gpsculpt_get_settings(scene);
gso->brush = gpsculpt_get_brush(scene);
-
+
gso->brush_type = gso->settings->brushtype;
-
-
+
+
gso->is_painting = false;
gso->first = true;
-
+
gso->gpd = ED_gpencil_data_get_active(C);
gso->cfra = INT_MAX; /* NOTE: So that first stroke will get handled in init_stroke() */
-
+
gso->scene = scene;
-
+
gso->sa = CTX_wm_area(C);
gso->ar = CTX_wm_region(C);
-
+
/* initialise custom data for brushes */
switch (gso->brush_type) {
case GP_EDITBRUSH_TYPE_CLONE:
{
bGPDstroke *gps;
bool found = false;
-
+
/* check that there are some usable strokes in the buffer */
for (gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) {
if (ED_gpencil_stroke_can_use(C, gps)) {
@@ -1087,12 +1087,12 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
break;
}
}
-
+
if (found == false) {
/* STOP HERE! Nothing to paste! */
- BKE_report(op->reports, RPT_ERROR,
+ BKE_report(op->reports, RPT_ERROR,
"Copy some strokes to the clipboard before using the Clone brush to paste copies of them");
-
+
MEM_freeN(gso);
op->customdata = NULL;
return false;
@@ -1103,30 +1103,30 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
}
break;
}
-
+
case GP_EDITBRUSH_TYPE_GRAB:
{
/* initialise the cache needed for this brush */
gso->stroke_customdata = BLI_ghash_ptr_new("GP Grab Brush - Strokes Hash");
break;
}
-
+
/* Others - No customdata needed */
default:
break;
}
-
-
+
+
/* setup space conversions */
gp_point_conversion_init(C, &gso->gsc);
-
+
/* update header */
gpsculpt_brush_header_set(C, gso);
-
+
/* setup cursor drawing */
WM_cursor_modal_set(CTX_wm_window(C), BC_CROSSCURSOR);
gpencil_toggle_brush_cursor(C, true);
-
+
return true;
}
@@ -1134,7 +1134,7 @@ static void gpsculpt_brush_exit(bContext *C, wmOperator *op)
{
tGP_BrushEditData *gso = op->customdata;
wmWindow *win = CTX_wm_window(C);
-
+
/* free brush-specific data */
switch (gso->brush_type) {
case GP_EDITBRUSH_TYPE_GRAB:
@@ -1146,18 +1146,18 @@ static void gpsculpt_brush_exit(bContext *C, wmOperator *op)
BLI_ghash_free(gso->stroke_customdata, NULL, gp_brush_grab_stroke_free);
break;
}
-
+
case GP_EDITBRUSH_TYPE_CLONE:
{
/* Free customdata */
gp_brush_clone_free(gso);
break;
}
-
+
default:
break;
}
-
+
/* unregister timer (only used for realtime) */
if (gso->timer) {
WM_event_remove_timer(CTX_wm_manager(C), win, gso->timer);
@@ -1167,7 +1167,7 @@ static void gpsculpt_brush_exit(bContext *C, wmOperator *op)
ED_area_headerprint(CTX_wm_area(C), NULL);
WM_cursor_modal_restore(win);
gpencil_toggle_brush_cursor(C, false);
-
+
/* free operator data */
MEM_freeN(gso);
op->customdata = NULL;
@@ -1188,18 +1188,18 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso)
bGPdata *gpd = gso->gpd;
bGPDlayer *gpl;
int cfra = CFRA;
-
+
/* only try to add a new frame if this is the first stroke, or the frame has changed */
if ((gpd == NULL) || (cfra == gso->cfra))
return;
-
+
/* go through each layer, and ensure that we've got a valid frame to use */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* only editable and visible layers are considered */
if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
bGPDframe *gpf = gpl->actframe;
-
- /* Make a new frame to work on if the layer's frame and the current scene frame don't match up
+
+ /* Make a new frame to work on if the layer's frame and the current scene frame don't match up
* - This is useful when animating as it saves that "uh-oh" moment when you realize you've
* spent too much time editing the wrong frame...
*/
@@ -1209,7 +1209,7 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso)
}
}
}
-
+
/* save off new current frame, so that next update works fine */
gso->cfra = cfra;
}
@@ -1224,7 +1224,7 @@ static bool gpsculpt_brush_do_stroke(
GP_SpaceConversion *gsc = &gso->gsc;
rcti *rect = &gso->brush_rect;
const int radius = gso->brush->size;
-
+
bGPDspoint *pt1, *pt2;
int pc1[2] = {0};
int pc2[2] = {0};
@@ -1241,7 +1241,7 @@ static bool gpsculpt_brush_do_stroke(
gp_point_to_parent_space(gps->points, diff_mat, &pt_temp);
gp_point_to_xy(gsc, gps, &pt_temp, &pc1[0], &pc1[1]);
}
-
+
/* do boundbox check first */
if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) {
/* only check if point is inside */
@@ -1252,14 +1252,14 @@ static bool gpsculpt_brush_do_stroke(
}
}
else {
- /* Loop over the points in the stroke, checking for intersections
+ /* Loop over the points in the stroke, checking for intersections
* - an intersection means that we touched the stroke
*/
for (i = 0; (i + 1) < gps->totpoints; i++) {
/* Get points to work with */
pt1 = gps->points + i;
pt2 = gps->points + i + 1;
-
+
/* Skip if neither one is selected (and we are only allowed to edit/consider selected points) */
if (gso->settings->flag & GP_BRUSHEDIT_FLAG_SELECT_MASK) {
if (!(pt1->flag & GP_SPOINT_SELECT) && !(pt2->flag & GP_SPOINT_SELECT)) {
@@ -1292,14 +1292,14 @@ static bool gpsculpt_brush_do_stroke(
if (gp_stroke_inside_circle(gso->mval, gso->mval_prev, radius, pc1[0], pc1[1], pc2[0], pc2[1])) {
/* Apply operation to these points */
bool ok = false;
-
+
/* To each point individually... */
ok = apply(gso, gps, i, radius, pc1);
-
+
/* Only do the second point if this is the last segment,
* and it is unlikely that the point will get handled
- * otherwise.
- *
+ * otherwise.
+ *
* NOTE: There is a small risk here that the second point wasn't really
* actually in-range. In that case, it only got in because
* the line linking the points was!
@@ -1311,13 +1311,13 @@ static bool gpsculpt_brush_do_stroke(
else {
include_last = true;
}
-
+
changed |= ok;
}
else if (include_last) {
/* This case is for cases where for whatever reason the second vert (1st here) doesn't get included
* because the whole edge isn't in bounds, but it would've qualified since it did with the
- * previous step (but wasn't added then, to avoid double-ups)
+ * previous step (but wasn't added then, to avoid double-ups)
*/
changed |= apply(gso, gps, i, radius, pc1);
include_last = false;
@@ -1325,7 +1325,7 @@ static bool gpsculpt_brush_do_stroke(
}
}
}
-
+
return changed;
}
@@ -1333,7 +1333,7 @@ static bool gpsculpt_brush_do_stroke(
static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso)
{
bool changed = false;
-
+
/* Calculate brush-specific data which applies equally to all points */
switch (gso->brush_type) {
case GP_EDITBRUSH_TYPE_GRAB: /* Grab points */
@@ -1343,7 +1343,7 @@ static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso)
gp_brush_grab_calc_dvec(gso);
break;
}
-
+
case GP_EDITBRUSH_TYPE_PINCH: /* Pinch points */
case GP_EDITBRUSH_TYPE_TWIST: /* Twist points around midpoint */
{
@@ -1351,19 +1351,19 @@ static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso)
gp_brush_calc_midpoint(gso);
break;
}
-
+
case GP_EDITBRUSH_TYPE_RANDOMIZE: /* Random jitter */
{
/* compute the displacement vector for the cursor (in data space) */
gp_brush_grab_calc_dvec(gso);
break;
}
-
+
default:
break;
}
-
-
+
+
/* Find visible strokes, and perform operations on those if hit */
float diff_mat[4][4];
bool parented = false;
@@ -1373,7 +1373,7 @@ static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso)
bGPDframe *gpf = gpl->actframe;
if (gpf == NULL)
continue;
-
+
/* calculate difference matrix if parent object */
if (gpl->parent != NULL) {
ED_gpencil_parent_location(gpl, diff_mat);
@@ -1382,7 +1382,7 @@ static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso)
else {
parented = false;
}
-
+
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false)
@@ -1477,34 +1477,34 @@ static void gpsculpt_brush_apply(bContext *C, wmOperator *op, PointerRNA *itempt
float mousef[2];
int mouse[2];
bool changed = false;
-
+
/* Get latest mouse coordinates */
RNA_float_get_array(itemptr, "mouse", mousef);
gso->mval[0] = mouse[0] = (int)(mousef[0]);
gso->mval[1] = mouse[1] = (int)(mousef[1]);
-
+
gso->pressure = RNA_float_get(itemptr, "pressure");
-
+
if (RNA_boolean_get(itemptr, "pen_flip"))
gso->flag |= GP_EDITBRUSH_FLAG_INVERT;
else
gso->flag &= ~GP_EDITBRUSH_FLAG_INVERT;
-
-
+
+
/* Store coordinates as reference, if operator just started running */
if (gso->first) {
gso->mval_prev[0] = gso->mval[0];
gso->mval_prev[1] = gso->mval[1];
gso->pressure_prev = gso->pressure;
}
-
+
/* Update brush_rect, so that it represents the bounding rectangle of brush */
gso->brush_rect.xmin = mouse[0] - radius;
gso->brush_rect.ymin = mouse[1] - radius;
gso->brush_rect.xmax = mouse[0] + radius;
gso->brush_rect.ymax = mouse[1] + radius;
-
-
+
+
/* Apply brush */
if (gso->brush_type == GP_EDITBRUSH_TYPE_CLONE) {
changed = gpsculpt_brush_apply_clone(C, gso);
@@ -1512,13 +1512,13 @@ static void gpsculpt_brush_apply(bContext *C, wmOperator *op, PointerRNA *itempt
else {
changed = gpsculpt_brush_apply_standard(C, gso);
}
-
-
+
+
/* Updates */
if (changed) {
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
-
+
/* Store values for next step */
gso->mval_prev[0] = gso->mval[0];
gso->mval_prev[1] = gso->mval[1];
@@ -1535,24 +1535,24 @@ static void gpsculpt_brush_apply_event(bContext *C, wmOperator *op, const wmEven
PointerRNA itemptr;
float mouse[2];
int tablet = 0;
-
+
mouse[0] = event->mval[0] + 1;
mouse[1] = event->mval[1] + 1;
-
+
/* fill in stroke */
RNA_collection_add(op->ptr, "stroke", &itemptr);
-
+
RNA_float_set_array(&itemptr, "mouse", mouse);
RNA_boolean_set(&itemptr, "pen_flip", event->ctrl != false);
RNA_boolean_set(&itemptr, "is_start", gso->first);
-
+
/* handle pressure sensitivity (which is supplied by tablets) */
if (event->tablet_data) {
const wmTabletData *wmtab = event->tablet_data;
float pressure = wmtab->Pressure;
-
+
tablet = (wmtab->Active != EVT_TABLET_NONE);
-
+
/* special exception here for too high pressure values on first touch in
* windows for some tablets: clamp the values to be sane
*/
@@ -1564,7 +1564,7 @@ static void gpsculpt_brush_apply_event(bContext *C, wmOperator *op, const wmEven
else {
RNA_float_set(&itemptr, "pressure", 1.0f);
}
-
+
/* apply */
gpsculpt_brush_apply(C, op, &itemptr);
}
@@ -1574,15 +1574,15 @@ static int gpsculpt_brush_exec(bContext *C, wmOperator *op)
{
if (!gpsculpt_brush_init(C, op))
return OPERATOR_CANCELLED;
-
- RNA_BEGIN(op->ptr, itemptr, "stroke")
+
+ RNA_BEGIN(op->ptr, itemptr, "stroke")
{
gpsculpt_brush_apply(C, op, &itemptr);
}
RNA_END;
-
+
gpsculpt_brush_exit(C, op);
-
+
return OPERATOR_FINISHED;
}
@@ -1594,13 +1594,13 @@ static int gpsculpt_brush_invoke(bContext *C, wmOperator *op, const wmEvent *eve
const bool is_modal = RNA_boolean_get(op->ptr, "wait_for_input");
bool needs_timer = false;
float brush_rate = 0.0f;
-
+
/* init painting data */
if (!gpsculpt_brush_init(C, op))
return OPERATOR_CANCELLED;
-
+
gso = op->customdata;
-
+
/* initialise type-specific data (used for the entire session) */
switch (gso->brush_type) {
/* Brushes requiring timer... */
@@ -1608,7 +1608,7 @@ static int gpsculpt_brush_invoke(bContext *C, wmOperator *op, const wmEvent *eve
brush_rate = 0.01f; // XXX: hardcoded
needs_timer = true;
break;
-
+
case GP_EDITBRUSH_TYPE_STRENGTH:
brush_rate = 0.01f; // XXX: hardcoded
needs_timer = true;
@@ -1618,39 +1618,39 @@ static int gpsculpt_brush_invoke(bContext *C, wmOperator *op, const wmEvent *eve
brush_rate = 0.001f; // XXX: hardcoded
needs_timer = true;
break;
-
+
case GP_EDITBRUSH_TYPE_TWIST:
brush_rate = 0.01f; // XXX: hardcoded
needs_timer = true;
break;
-
+
default:
break;
}
-
+
/* register timer for increasing influence by hovering over an area */
if (needs_timer) {
gso->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, brush_rate);
}
-
+
/* register modal handler */
WM_event_add_modal_handler(C, op);
-
+
/* start drawing immediately? */
if (is_modal == false) {
ARegion *ar = CTX_wm_region(C);
-
+
/* ensure that we'll have a new frame to draw on */
gpsculpt_brush_init_stroke(gso);
-
+
/* apply first dab... */
gso->is_painting = true;
gpsculpt_brush_apply_event(C, op, event);
-
+
/* redraw view with feedback */
ED_region_tag_redraw(ar);
}
-
+
return OPERATOR_RUNNING_MODAL;
}
@@ -1661,7 +1661,7 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
const bool is_modal = RNA_boolean_get(op->ptr, "wait_for_input");
bool redraw_region = false;
bool redraw_toolsettings = false;
-
+
/* The operator can be in 2 states: Painting and Idling */
if (gso->is_painting) {
/* Painting */
@@ -1671,11 +1671,11 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
case INBETWEEN_MOUSEMOVE:
/* apply brush effect at new position */
gpsculpt_brush_apply_event(C, op, event);
-
+
/* force redraw, so that the cursor will at least be valid */
redraw_region = true;
break;
-
+
/* Timer Tick - Only if this was our own timer */
case TIMER:
if (event->customdata == gso->timer) {
@@ -1684,7 +1684,7 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
gso->timerTick = false;
}
break;
-
+
/* Adjust brush settings */
/* FIXME: Step increments and modifier keys are hardcoded here! */
case WHEELUPMOUSE:
@@ -1699,12 +1699,12 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
gso->brush->size += 3;
CLAMP_MAX(gso->brush->size, 300);
}
-
+
redraw_region = true;
redraw_toolsettings = true;
break;
-
- case WHEELDOWNMOUSE:
+
+ case WHEELDOWNMOUSE:
case PADMINUS:
if (event->shift) {
/* decrease strength */
@@ -1716,11 +1716,11 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
gso->brush->size -= 3;
CLAMP_MIN(gso->brush->size, 1);
}
-
+
redraw_region = true;
redraw_toolsettings = true;
break;
-
+
/* Painting mbut release = Stop painting (back to idle) */
case LEFTMOUSE:
//BLI_assert(event->val == KM_RELEASE);
@@ -1731,12 +1731,12 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
else {
/* end sculpt session, since we're not modal */
gso->is_painting = false;
-
+
gpsculpt_brush_exit(C, op);
return OPERATOR_FINISHED;
}
break;
-
+
/* Abort painting if any of the usual things are tried */
case MIDDLEMOUSE:
case RIGHTMOUSE:
@@ -1748,34 +1748,34 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
else {
/* Idling */
BLI_assert(is_modal == true);
-
+
switch (event->type) {
/* Painting mbut press = Start painting (switch to painting state) */
case LEFTMOUSE:
/* do initial "click" apply */
gso->is_painting = true;
gso->first = true;
-
+
gpsculpt_brush_init_stroke(gso);
gpsculpt_brush_apply_event(C, op, event);
break;
-
+
/* Exit modal operator, based on the "standard" ops */
case RIGHTMOUSE:
case ESCKEY:
gpsculpt_brush_exit(C, op);
return OPERATOR_FINISHED;
-
+
/* MMB is often used for view manipulations */
case MIDDLEMOUSE:
return OPERATOR_PASS_THROUGH;
-
+
/* Mouse movements should update the brush cursor - Just redraw the active region */
case MOUSEMOVE:
case INBETWEEN_MOUSEMOVE:
redraw_region = true;
break;
-
+
/* Adjust brush settings */
/* FIXME: Step increments and modifier keys are hardcoded here! */
case WHEELUPMOUSE:
@@ -1790,12 +1790,12 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
gso->brush->size += 3;
CLAMP_MAX(gso->brush->size, 300);
}
-
+
redraw_region = true;
redraw_toolsettings = true;
break;
-
- case WHEELDOWNMOUSE:
+
+ case WHEELDOWNMOUSE:
case PADMINUS:
if (event->shift) {
/* decrease strength */
@@ -1807,41 +1807,41 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
gso->brush->size -= 3;
CLAMP_MIN(gso->brush->size, 1);
}
-
+
redraw_region = true;
redraw_toolsettings = true;
break;
-
+
/* Change Frame - Allowed */
case LEFTARROWKEY:
case RIGHTARROWKEY:
case UPARROWKEY:
case DOWNARROWKEY:
return OPERATOR_PASS_THROUGH;
-
+
/* Camera/View Manipulations - Allowed */
/* (See rationale in gpencil_paint.c -> gpencil_draw_modal()) */
case PAD0: case PAD1: case PAD2: case PAD3: case PAD4:
case PAD5: case PAD6: case PAD7: case PAD8: case PAD9:
return OPERATOR_PASS_THROUGH;
-
+
/* Unhandled event */
default:
break;
}
}
-
+
/* Redraw region? */
if (redraw_region) {
ARegion *ar = CTX_wm_region(C);
ED_region_tag_redraw(ar);
}
-
+
/* Redraw toolsettings (brush settings)? */
if (redraw_toolsettings) {
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
}
-
+
return OPERATOR_RUNNING_MODAL;
}
@@ -1854,7 +1854,7 @@ void GPENCIL_OT_brush_paint(wmOperatorType *ot)
ot->name = "Stroke Sculpt";
ot->idname = "GPENCIL_OT_brush_paint";
ot->description = "Apply tweaks to strokes by painting over the strokes"; // XXX
-
+
/* api callbacks */
ot->exec = gpsculpt_brush_exec;
ot->invoke = gpsculpt_brush_invoke;
@@ -1869,7 +1869,7 @@ void GPENCIL_OT_brush_paint(wmOperatorType *ot)
PropertyRNA *prop;
prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
-
+
prop = RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input",
"Enter a mini 'sculpt-mode' if enabled, otherwise, exit after drawing a single stroke");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index e503b35d878..dfaa1420d68 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -66,6 +66,7 @@
#include "BKE_gpencil.h"
#include "BKE_layer.h"
#include "BKE_library.h"
+#include "BKE_main.h"
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_scene.h"
@@ -179,7 +180,7 @@ static void gp_strokepoint_convertcoords(
else {
const float *fp = ED_view3d_cursor3d_get(scene, v3d)->location;
float mvalf[2];
-
+
/* get screen coordinate */
if (gps->flag & GP_STROKE_2DSPACE) {
View2D *v2d = &ar->v2d;
@@ -195,7 +196,7 @@ static void gp_strokepoint_convertcoords(
mvalf[1] = (float)pt->y / 100.0f * ar->winy;
}
}
-
+
ED_view3d_win_to_3d(v3d, ar, fp, mvalf, p3d);
}
}
@@ -211,19 +212,19 @@ typedef struct tGpTimingData {
bool realtime; /* Will overwrite end_frame in case of Original or CustomGap timing... */
float gap_duration, gap_randomness; /* To be used with CustomGap mode*/
int seed;
-
+
/* Data set from points, used to compute final timing FCurve */
int num_points, cur_point;
-
+
/* Distances */
float *dists;
float tot_dist;
-
+
/* Times */
float *times; /* Note: Gap times will be negative! */
float tot_time, gap_tot_time;
double inittime;
-
+
/* Only used during creation of dists & times lists. */
float offset_time;
} tGpTimingData;
@@ -234,9 +235,9 @@ typedef struct tGpTimingData {
static void gp_timing_data_set_nbr(tGpTimingData *gtd, const int nbr)
{
float *tmp;
-
+
BLI_assert(nbr > gtd->num_points);
-
+
/* distances */
tmp = gtd->dists;
gtd->dists = MEM_callocN(sizeof(float) * nbr, __func__);
@@ -244,7 +245,7 @@ static void gp_timing_data_set_nbr(tGpTimingData *gtd, const int nbr)
memcpy(gtd->dists, tmp, sizeof(float) * gtd->num_points);
MEM_freeN(tmp);
}
-
+
/* times */
tmp = gtd->times;
gtd->times = MEM_callocN(sizeof(float) * nbr, __func__);
@@ -252,7 +253,7 @@ static void gp_timing_data_set_nbr(tGpTimingData *gtd, const int nbr)
memcpy(gtd->times, tmp, sizeof(float) * gtd->num_points);
MEM_freeN(tmp);
}
-
+
gtd->num_points = nbr;
}
@@ -262,7 +263,7 @@ static void gp_timing_data_add_point(tGpTimingData *gtd, const double stroke_ini
{
float delta_time = 0.0f;
const int cur_point = gtd->cur_point;
-
+
if (!cur_point) {
/* Special case, first point, if time is not 0.0f we have to compensate! */
gtd->offset_time = -time;
@@ -272,18 +273,18 @@ static void gp_timing_data_add_point(tGpTimingData *gtd, const double stroke_ini
/* This is a gap, negative value! */
gtd->times[cur_point] = -(((float)(stroke_inittime - gtd->inittime)) + time + gtd->offset_time);
delta_time = -gtd->times[cur_point] - gtd->times[cur_point - 1];
-
+
gtd->gap_tot_time += delta_time;
}
else {
gtd->times[cur_point] = (((float)(stroke_inittime - gtd->inittime)) + time + gtd->offset_time);
delta_time = gtd->times[cur_point] - fabsf(gtd->times[cur_point - 1]);
}
-
+
gtd->tot_time += delta_time;
gtd->tot_dist += delta_dist;
gtd->dists[cur_point] = gtd->tot_dist;
-
+
gtd->cur_point++;
}
@@ -298,7 +299,7 @@ static int gp_find_end_of_stroke_idx(tGpTimingData *gtd, RNG *rng, const int idx
float *next_delta_time)
{
int j;
-
+
for (j = idx + 1; j < gtd->num_points; j++) {
if (gtd->times[j] < 0) {
gtd->times[j] = -gtd->times[j];
@@ -317,16 +318,16 @@ static int gp_find_end_of_stroke_idx(tGpTimingData *gtd, RNG *rng, const int idx
}
else {
float delta, min, max;
-
+
/* This code ensures that if the first gaps have been shorter than average gap_duration,
* next gaps will tend to be longer (i.e. try to recover the lateness), and vice-versa!
*/
delta = delta_time - (gtd->gap_duration * (*nbr_done_gaps));
-
+
/* Clamp min between [-gap_randomness, 0.0], with lower delta giving higher min */
min = -gtd->gap_randomness - delta;
CLAMP(min, -gtd->gap_randomness, 0.0f);
-
+
/* Clamp max between [0.0, gap_randomness], with lower delta giving higher max */
max = gtd->gap_randomness - delta;
CLAMP(max, 0.0f, gtd->gap_randomness);
@@ -341,7 +342,7 @@ static int gp_find_end_of_stroke_idx(tGpTimingData *gtd, RNG *rng, const int idx
break;
}
}
-
+
return j - 1;
}
@@ -349,7 +350,7 @@ static void gp_stroke_path_animation_preprocess_gaps(tGpTimingData *gtd, RNG *rn
{
int i;
float delta_time = 0.0f;
-
+
for (i = 0; i < gtd->num_points; i++) {
if (gtd->times[i] < 0 && i) {
(*nbr_gaps)++;
@@ -362,7 +363,7 @@ static void gp_stroke_path_animation_preprocess_gaps(tGpTimingData *gtd, RNG *rn
}
}
gtd->tot_time -= delta_time;
-
+
*tot_gaps_time = (float)(*nbr_gaps) * gtd->gap_duration;
gtd->tot_time += *tot_gaps_time;
if (G.debug & G_DEBUG) {
@@ -379,18 +380,18 @@ static void gp_stroke_path_animation_add_keyframes(Depsgraph *depsgraph, ReportL
{
/* Use actual recorded timing! */
const float time_start = (float)gtd->start_frame;
-
+
float last_valid_time = 0.0f;
int end_stroke_idx = -1, start_stroke_idx = 0;
float end_stroke_time = 0.0f;
-
+
/* CustomGaps specific */
float delta_time = 0.0f, next_delta_time = 0.0f;
int nbr_done_gaps = 0;
-
+
int i;
float cfra;
-
+
/* This is a bit tricky, as:
* - We can't add arbitrarily close points on FCurve (in time).
* - We *must* have all "caps" points of all strokes in FCurve, as much as possible!
@@ -406,11 +407,11 @@ static void gp_stroke_path_animation_add_keyframes(Depsgraph *depsgraph, ReportL
/* This one should *never* be negative! */
end_stroke_time = time_start + ((gtd->times[end_stroke_idx] + delta_time) / gtd->tot_time * time_range);
}
-
+
/* Simple proportional stuff... */
cu->ctime = gtd->dists[i] / gtd->tot_dist * cu->pathlen;
cfra = time_start + ((gtd->times[i] + delta_time) / gtd->tot_time * time_range);
-
+
/* And now, the checks about timing... */
if (i == start_stroke_idx) {
/* If first point of a stroke, be sure it's enough ahead of last valid keyframe, and
@@ -456,49 +457,50 @@ static void gp_stroke_path_animation_add_keyframes(Depsgraph *depsgraph, ReportL
static void gp_stroke_path_animation(bContext *C, ReportList *reports, Curve *cu, tGpTimingData *gtd)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
bAction *act;
FCurve *fcu;
PointerRNA ptr;
PropertyRNA *prop = NULL;
int nbr_gaps = 0, i;
-
+
if (gtd->mode == GP_STROKECONVERT_TIMING_NONE)
return;
-
+
/* gap_duration and gap_randomness are in frames, but we need seconds!!! */
gtd->gap_duration = FRA2TIME(gtd->gap_duration);
gtd->gap_randomness = FRA2TIME(gtd->gap_randomness);
-
+
/* Enable path! */
cu->flag |= CU_PATH;
cu->pathlen = gtd->frame_range;
-
+
/* Get RNA pointer to read/write path time values */
RNA_id_pointer_create((ID *)cu, &ptr);
prop = RNA_struct_find_property(&ptr, "eval_time");
-
+
/* Ensure we have an F-Curve to add keyframes to */
- act = verify_adt_action((ID *)cu, true);
+ act = verify_adt_action(bmain, (ID *)cu, true);
fcu = verify_fcurve(act, NULL, &ptr, "eval_time", 0, true);
-
+
if (G.debug & G_DEBUG) {
printf("%s: tot len: %f\t\ttot time: %f\n", __func__, gtd->tot_dist, gtd->tot_time);
for (i = 0; i < gtd->num_points; i++) {
printf("\tpoint %d:\t\tlen: %f\t\ttime: %f\n", i, gtd->dists[i], gtd->times[i]);
}
}
-
+
if (gtd->mode == GP_STROKECONVERT_TIMING_LINEAR) {
float cfra;
-
+
/* Linear extrapolation! */
fcu->extend = FCURVE_EXTRAPOLATE_LINEAR;
-
+
cu->ctime = 0.0f;
cfra = (float)gtd->start_frame;
insert_keyframe_direct(depsgraph, reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST);
-
+
cu->ctime = cu->pathlen;
if (gtd->realtime) {
cfra += (float)TIME2FRA(gtd->tot_time); /* Seconds to frames */
@@ -512,35 +514,35 @@ static void gp_stroke_path_animation(bContext *C, ReportList *reports, Curve *cu
/* Use actual recorded timing! */
RNG *rng = BLI_rng_new(0);
float time_range;
-
+
/* CustomGaps specific */
float tot_gaps_time = 0.0f;
-
+
/* Pre-process gaps, in case we don't want to keep their original timing */
if (gtd->mode == GP_STROKECONVERT_TIMING_CUSTOMGAP) {
gp_stroke_path_animation_preprocess_gaps(gtd, rng, &nbr_gaps, &tot_gaps_time);
}
-
+
if (gtd->realtime) {
time_range = (float)TIME2FRA(gtd->tot_time); /* Seconds to frames */
}
else {
time_range = (float)(gtd->end_frame - gtd->start_frame);
}
-
+
if (G.debug & G_DEBUG) {
printf("GP Stroke Path Conversion: Starting keying!\n");
}
-
+
gp_stroke_path_animation_add_keyframes(depsgraph, reports, ptr, prop, fcu, cu, gtd, rng, time_range,
nbr_gaps, tot_gaps_time);
-
+
BLI_rng_free(rng);
}
-
+
/* As we used INSERTKEY_FAST mode, we need to recompute all curve's handles now */
calchandles_fcurve(fcu);
-
+
if (G.debug & G_DEBUG) {
printf("%s: \ntot len: %f\t\ttot time: %f\n", __func__, gtd->tot_dist, gtd->tot_time);
for (i = 0; i < gtd->num_points; i++) {
@@ -548,9 +550,9 @@ static void gp_stroke_path_animation(bContext *C, ReportList *reports, Curve *cu
}
printf("\n\n");
}
-
+
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
/* send updates */
DEG_id_tag_update(&cu->id, 0);
}
@@ -570,7 +572,7 @@ static void gp_stroke_to_path_add_point(tGpTimingData *gtd, BPoint *bp, const fl
{
copy_v3_v3(bp->vec, p);
bp->vec[3] = 1.0f;
-
+
/* set settings */
bp->f1 = SELECT;
bp->radius = width * rad_fac;
@@ -582,7 +584,7 @@ static void gp_stroke_to_path_add_point(tGpTimingData *gtd, BPoint *bp, const fl
else if (bp->weight > minmax_weights[1]) {
minmax_weights[1] = bp->weight;
}
-
+
/* Update timing data */
if (do_gtd) {
gp_timing_data_add_point(gtd, inittime, time, len_v3v3(prev_p, p));
@@ -599,7 +601,7 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv
const bool do_gtd = (gtd->mode != GP_STROKECONVERT_TIMING_NONE);
const int add_start_end_points = (add_start_point ? 1 : 0) + (add_end_point ? 1 : 0);
int i, old_nbp = 0;
-
+
/* create new 'nurb' or extend current one within the curve */
if (nu) {
old_nbp = nu->pntsu;
@@ -611,7 +613,7 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv
}
else {
nu = (Nurb *)MEM_callocN(sizeof(Nurb), "gpstroke_to_path(nurb)");
-
+
nu->pntsu = gps->totpoints + add_start_end_points;
nu->pntsv = 1;
nu->orderu = 2; /* point-to-point! */
@@ -620,16 +622,16 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv
nu->resolu = cu->resolu;
nu->resolv = cu->resolv;
nu->knotsu = NULL;
-
+
nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * nu->pntsu, "bpoints");
-
+
stitch = false; /* Security! */
}
-
+
if (do_gtd) {
gp_timing_data_set_nbr(gtd, nu->pntsu);
}
-
+
/* If needed, make the link between both strokes with two zero-radius additional points */
/* About "zero-radius" point interpolations:
* - If we have at least two points in current curve (most common case), we linearly extrapolate
@@ -642,16 +644,16 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv
if (curnu && !stitch && old_nbp) {
float p1[3], p2[3], p[3], next_p[3];
float dt1 = 0.0f, dt2 = 0.0f;
-
+
BLI_assert(gps->prev != NULL);
-
+
prev_bp = NULL;
if ((old_nbp > 1) && (gps->prev->totpoints > 1)) {
/* Only use last curve segment if previous stroke was not a single-point one! */
prev_bp = &nu->bp[old_nbp - 2];
}
bp = &nu->bp[old_nbp - 1];
-
+
/* First point */
gp_strokepoint_convertcoords(C, gpl, gps, gps->points, p, subrect);
if (prev_bp) {
@@ -670,7 +672,7 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv
bp++;
gp_stroke_to_path_add_point(gtd, bp, p1, (bp - 1)->vec, do_gtd, gps->prev->inittime, dt1,
0.0f, rad_fac, minmax_weights);
-
+
/* Second point */
/* Note dt2 is always negative, which marks the gap. */
if (gps->totpoints > 1) {
@@ -688,13 +690,13 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv
}
bp++;
gp_stroke_to_path_add_point(gtd, bp, p2, p1, do_gtd, gps->inittime, dt2, 0.0f, rad_fac, minmax_weights);
-
+
old_nbp += 2;
}
else if (add_start_point) {
float p[3], next_p[3];
float dt = 0.0f;
-
+
gp_strokepoint_convertcoords(C, gpl, gps, gps->points, p, subrect);
if (gps->totpoints > 1) {
gp_strokepoint_convertcoords(C, gpl, gps, gps->points + 1, next_p, subrect);
@@ -712,14 +714,14 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv
* would not work (it would be *before* gtd->inittime, which is not supported currently).
*/
gp_stroke_to_path_add_point(gtd, bp, p, p, do_gtd, gps->inittime, dt, 0.0f, rad_fac, minmax_weights);
-
+
old_nbp++;
}
-
+
if (old_nbp) {
prev_bp = &nu->bp[old_nbp - 1];
}
-
+
/* add points */
for (i = (stitch) ? 1 : 0, pt = &gps->points[(stitch) ? 1 : 0], bp = &nu->bp[old_nbp];
i < gps->totpoints;
@@ -727,20 +729,20 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv
{
float p[3];
float width = pt->pressure * (gps->thickness + gpl->thickness) * WIDTH_CORR_FAC;
-
+
/* get coordinates to add at */
gp_strokepoint_convertcoords(C, gpl, gps, pt, p, subrect);
-
+
gp_stroke_to_path_add_point(gtd, bp, p, (prev_bp) ? prev_bp->vec : p, do_gtd, gps->inittime, pt->time,
width, rad_fac, minmax_weights);
-
+
prev_bp = bp;
}
if (add_end_point) {
float p[3];
float dt = 0.0f;
-
+
if (gps->totpoints > 1) {
interp_v3_v3v3(p, prev_bp->vec, (prev_bp - 1)->vec, -GAP_DFAC);
if (do_gtd) {
@@ -756,7 +758,7 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv
/* Note bp has already been incremented in main loop above, so it points to the right place. */
gp_stroke_to_path_add_point(gtd, bp, p, prev_bp->vec, do_gtd, gps->inittime, dt, 0.0f, rad_fac, minmax_weights);
}
-
+
/* add nurb to curve */
if (!curnu || !*curnu) {
BLI_addtail(&cu->nurb, nu);
@@ -764,7 +766,7 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv
if (curnu) {
*curnu = nu;
}
-
+
BKE_nurb_knot_calc_u(nu);
}
@@ -779,7 +781,7 @@ static void gp_stroke_to_bezier_add_point(tGpTimingData *gtd, BezTriple *bezt,
copy_v3_v3(bezt->vec[0], h1);
copy_v3_v3(bezt->vec[1], p);
copy_v3_v3(bezt->vec[2], h2);
-
+
/* set settings */
bezt->h1 = bezt->h2 = HD_FREE;
bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
@@ -792,7 +794,7 @@ static void gp_stroke_to_bezier_add_point(tGpTimingData *gtd, BezTriple *bezt,
else if (bezt->weight > minmax_weights[1]) {
minmax_weights[1] = bezt->weight;
}
-
+
/* Update timing data */
if (do_gtd) {
gp_timing_data_add_point(gtd, inittime, time, len_v3v3(prev_p, p));
@@ -810,7 +812,7 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu
const int add_start_end_points = (add_start_point ? 1 : 0) + (add_end_point ? 1 : 0);
float p3d_cur[3], p3d_prev[3], p3d_next[3], h1[3], h2[3];
const bool do_gtd = (gtd->mode != GP_STROKECONVERT_TIMING_NONE);
-
+
/* create new 'nurb' or extend current one within the curve */
if (nu) {
old_nbezt = nu->pntsu;
@@ -822,22 +824,22 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu
}
else {
nu = (Nurb *)MEM_callocN(sizeof(Nurb), "gpstroke_to_bezier(nurb)");
-
+
nu->pntsu = gps->totpoints + add_start_end_points;
nu->resolu = 12;
nu->resolv = 12;
nu->type = CU_BEZIER;
nu->bezt = (BezTriple *)MEM_callocN(sizeof(BezTriple) * nu->pntsu, "bezts");
-
+
stitch = false; /* Security! */
}
-
+
if (do_gtd) {
gp_timing_data_set_nbr(gtd, nu->pntsu);
}
-
+
tot = gps->totpoints;
-
+
/* get initial coordinates */
pt = gps->points;
if (tot) {
@@ -849,11 +851,11 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu
gp_strokepoint_convertcoords(C, gpl, gps, pt + 2, p3d_next, subrect);
}
}
-
+
/* If needed, make the link between both strokes with two zero-radius additional points */
if (curnu && old_nbezt) {
BLI_assert(gps->prev != NULL);
-
+
/* Update last point's second handle */
if (stitch) {
bezt = &nu->bezt[old_nbezt - 1];
@@ -861,7 +863,7 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu
copy_v3_v3(bezt->vec[2], h2);
pt++;
}
-
+
/* Create "link points" */
/* About "zero-radius" point interpolations:
* - If we have at least two points in current curve (most common case), we linearly extrapolate
@@ -874,14 +876,14 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu
else {
float p1[3], p2[3];
float dt1 = 0.0f, dt2 = 0.0f;
-
+
prev_bezt = NULL;
if ((old_nbezt > 1) && (gps->prev->totpoints > 1)) {
/* Only use last curve segment if previous stroke was not a single-point one! */
prev_bezt = &nu->bezt[old_nbezt - 2];
}
bezt = &nu->bezt[old_nbezt - 1];
-
+
/* First point */
if (prev_bezt) {
interp_v3_v3v3(p1, prev_bezt->vec[1], bezt->vec[1], 1.0f + GAP_DFAC);
@@ -896,7 +898,7 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu
dt1 = interpf(gps->inittime - gps->prev->inittime, 0.0f, GAP_DFAC);
}
}
-
+
/* Second point */
/* Note dt2 is always negative, which marks the gap. */
if (tot > 1) {
@@ -911,25 +913,25 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu
dt2 = interpf(gps->prev->inittime - gps->inittime, 0.0f, GAP_DFAC);
}
}
-
+
/* Second handle of last point of previous stroke. */
interp_v3_v3v3(h2, bezt->vec[1], p1, BEZT_HANDLE_FAC);
copy_v3_v3(bezt->vec[2], h2);
-
+
/* First point */
interp_v3_v3v3(h1, p1, bezt->vec[1], BEZT_HANDLE_FAC);
interp_v3_v3v3(h2, p1, p2, BEZT_HANDLE_FAC);
bezt++;
gp_stroke_to_bezier_add_point(gtd, bezt, p1, h1, h2, (bezt - 1)->vec[1], do_gtd, gps->prev->inittime, dt1,
0.0f, rad_fac, minmax_weights);
-
+
/* Second point */
interp_v3_v3v3(h1, p2, p1, BEZT_HANDLE_FAC);
interp_v3_v3v3(h2, p2, p3d_cur, BEZT_HANDLE_FAC);
bezt++;
gp_stroke_to_bezier_add_point(gtd, bezt, p2, h1, h2, p1, do_gtd, gps->inittime, dt2,
0.0f, rad_fac, minmax_weights);
-
+
old_nbezt += 2;
copy_v3_v3(p3d_prev, p2);
}
@@ -937,7 +939,7 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu
else if (add_start_point) {
float p[3];
float dt = 0.0f;
-
+
if (gps->totpoints > 1) {
interp_v3_v3v3(p, p3d_cur, p3d_next, -GAP_DFAC);
if (do_gtd) {
@@ -954,51 +956,51 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu
bezt = &nu->bezt[old_nbezt];
gp_stroke_to_bezier_add_point(gtd, bezt, p, h1, h2, p, do_gtd, gps->inittime, dt,
0.0f, rad_fac, minmax_weights);
-
+
old_nbezt++;
copy_v3_v3(p3d_prev, p);
}
-
+
if (old_nbezt) {
prev_bezt = &nu->bezt[old_nbezt - 1];
}
-
+
/* add points */
for (i = stitch ? 1 : 0, bezt = &nu->bezt[old_nbezt]; i < tot; i++, pt++, bezt++) {
float width = pt->pressure * (gps->thickness + gpl->thickness) * WIDTH_CORR_FAC;
-
+
if (i || old_nbezt) {
interp_v3_v3v3(h1, p3d_cur, p3d_prev, BEZT_HANDLE_FAC);
}
else {
interp_v3_v3v3(h1, p3d_cur, p3d_next, -BEZT_HANDLE_FAC);
}
-
+
if (i < tot - 1) {
interp_v3_v3v3(h2, p3d_cur, p3d_next, BEZT_HANDLE_FAC);
}
else {
interp_v3_v3v3(h2, p3d_cur, p3d_prev, -BEZT_HANDLE_FAC);
}
-
+
gp_stroke_to_bezier_add_point(gtd, bezt, p3d_cur, h1, h2, prev_bezt ? prev_bezt->vec[1] : p3d_cur,
do_gtd, gps->inittime, pt->time, width, rad_fac, minmax_weights);
-
+
/* shift coord vects */
copy_v3_v3(p3d_prev, p3d_cur);
copy_v3_v3(p3d_cur, p3d_next);
-
+
if (i + 2 < tot) {
gp_strokepoint_convertcoords(C, gpl, gps, pt + 2, p3d_next, subrect);
}
-
+
prev_bezt = bezt;
}
if (add_end_point) {
float p[3];
float dt = 0.0f;
-
+
if (gps->totpoints > 1) {
interp_v3_v3v3(p, prev_bezt->vec[1], (prev_bezt - 1)->vec[1], -GAP_DFAC);
if (do_gtd) {
@@ -1011,11 +1013,11 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu
p[0] += GAP_DFAC; /* Rather arbitrary... */
dt = GAP_DFAC; /* Rather arbitrary too! */
}
-
+
/* Second handle of last point of this stroke. */
interp_v3_v3v3(h2, prev_bezt->vec[1], p, BEZT_HANDLE_FAC);
copy_v3_v3(prev_bezt->vec[2], h2);
-
+
/* The end point */
interp_v3_v3v3(h1, p, prev_bezt->vec[1], BEZT_HANDLE_FAC);
interp_v3_v3v3(h2, p, prev_bezt->vec[1], -BEZT_HANDLE_FAC);
@@ -1023,10 +1025,10 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu
gp_stroke_to_bezier_add_point(gtd, bezt, p, h1, h2, prev_bezt->vec[1], do_gtd, gps->inittime, dt,
0.0f, rad_fac, minmax_weights);
}
-
+
/* must calculate handles or else we crash */
BKE_nurb_handles_calc(nu);
-
+
if (!curnu || !*curnu) {
BLI_addtail(&cu->nurb, nu);
}
@@ -1056,7 +1058,7 @@ static void gp_stroke_finalize_curve_endpoints(Curve *cu)
bp[i].weight = bp[i].radius = 0.0f;
}
}
-
+
/* end */
nu = cu->nurb.last;
i = nu->pntsu - 1;
@@ -1080,13 +1082,13 @@ static void gp_stroke_norm_curve_weights(Curve *cu, const float minmax_weights[2
const float delta = minmax_weights[0];
float fac;
int i;
-
+
/* when delta == minmax_weights[0] == minmax_weights[1], we get div by zero [#35686] */
if (IS_EQF(delta, minmax_weights[1]))
fac = 1.0f;
else
fac = 1.0f / (minmax_weights[1] - delta);
-
+
for (nu = cu->nurb.first; nu; nu = nu->next) {
if (nu->bezt) {
BezTriple *bezt = nu->bezt;
@@ -1107,10 +1109,10 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect)
{
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
-
+
if (v3d) {
RegionView3D *rv3d = ar->regiondata;
-
+
/* for camera view set the subrect */
if (rv3d->persp == RV3D_CAMOB) {
Scene *scene = CTX_data_scene(C);
@@ -1119,7 +1121,7 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect)
return 1;
}
}
-
+
return 0;
}
@@ -1138,23 +1140,23 @@ static void gp_layer_to_curve(bContext *C, ReportList *reports, bGPdata *gpd, bG
Nurb *nu = NULL;
Base *base_new = NULL;
float minmax_weights[2] = {1.0f, 0.0f};
-
+
/* camera framing */
rctf subrect, *subrect_ptr = NULL;
-
+
/* error checking */
if (ELEM(NULL, gpd, gpl, gpf))
return;
-
+
/* only convert if there are any strokes on this layer's frame to convert */
if (BLI_listbase_is_empty(&gpf->strokes))
return;
-
+
/* initialize camera framing */
if (gp_camera_view_subrect(C, &subrect)) {
subrect_ptr = &subrect;
}
-
+
/* init the curve object (remove rotation and get curve data from it)
* - must clear transforms set on object, as those skew our results
*/
@@ -1162,32 +1164,32 @@ static void gp_layer_to_curve(bContext *C, ReportList *reports, bGPdata *gpd, bG
cu = ob->data = BKE_curve_add(bmain, gpl->info, OB_CURVE);
BKE_collection_object_add(bmain, collection, ob);
base_new = BKE_view_layer_base_find(view_layer, ob);
-
+
cu->flag |= CU_3D;
-
+
gtd->inittime = ((bGPDstroke *)gpf->strokes.first)->inittime;
-
+
/* add points to curve */
for (gps = gpf->strokes.first; gps; gps = gps->next) {
const bool add_start_point = (link_strokes && !(prev_gps));
const bool add_end_point = (link_strokes && !(gps->next));
-
+
/* Detect new strokes created because of GP_STROKE_BUFFER_MAX reached, and stitch them to previous one. */
bool stitch = false;
if (prev_gps) {
bGPDspoint *pt1 = &prev_gps->points[prev_gps->totpoints - 1];
bGPDspoint *pt2 = &gps->points[0];
-
+
if ((pt1->x == pt2->x) && (pt1->y == pt2->y)) {
stitch = true;
}
}
-
+
/* Decide whether we connect this stroke to previous one */
if (!(stitch || link_strokes)) {
nu = NULL;
}
-
+
switch (mode) {
case GP_STROKECONVERT_PATH:
gp_stroke_to_path(C, gpl, gps, cu, subrect_ptr, &nu, minmax_weights, rad_fac, stitch,
@@ -1204,26 +1206,26 @@ static void gp_layer_to_curve(bContext *C, ReportList *reports, bGPdata *gpd, bG
}
prev_gps = gps;
}
-
+
/* If link_strokes, be sure first and last points have a zero weight/size! */
if (link_strokes) {
gp_stroke_finalize_curve_endpoints(cu);
}
-
+
/* Update curve's weights, if needed */
if (norm_weights && ((minmax_weights[0] > 0.0f) || (minmax_weights[1] < 1.0f))) {
gp_stroke_norm_curve_weights(cu, minmax_weights);
}
-
+
/* Create the path animation, if needed */
gp_stroke_path_animation(C, reports, cu, gtd);
-
+
if (mode == GP_STROKECONVERT_POLY) {
for (nu = cu->nurb.first; nu; nu = nu->next) {
BKE_nurb_type_convert(nu, CU_POLY, false);
}
}
-
+
/* set the layer and select */
base_new->flag |= SELECT;
BKE_scene_object_base_flag_sync_from_base(base_new);
@@ -1243,17 +1245,17 @@ static bool gp_convert_check_has_valid_timing(bContext *C, bGPDlayer *gpl, wmOpe
double base_time, cur_time, prev_time = -1.0;
int i;
bool valid = true;
-
+
if (!gpl || !(gpf = BKE_gpencil_layer_getframe(gpl, CFRA, 0)) || !(gps = gpf->strokes.first))
return false;
-
+
do {
base_time = cur_time = gps->inittime;
if (cur_time <= prev_time) {
valid = false;
break;
}
-
+
prev_time = cur_time;
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
cur_time = base_time + (double)pt->time;
@@ -1266,12 +1268,12 @@ static bool gp_convert_check_has_valid_timing(bContext *C, bGPDlayer *gpl, wmOpe
}
prev_time = cur_time;
}
-
+
if (!valid) {
break;
}
} while ((gps = gps->next));
-
+
if (op) {
RNA_boolean_set(op->ptr, "use_timing_data", valid);
}
@@ -1283,7 +1285,7 @@ static void gp_convert_set_end_frame(struct Main *UNUSED(main), struct Scene *UN
{
int start_frame = RNA_int_get(ptr, "start_frame");
int end_frame = RNA_int_get(ptr, "end_frame");
-
+
if (end_frame <= start_frame) {
RNA_int_set(ptr, "end_frame", start_frame + 1);
}
@@ -1297,7 +1299,7 @@ static int gp_convert_poll(bContext *C)
ScrArea *sa = CTX_wm_area(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
-
+
/* only if the current view is 3D View, if there's valid data (i.e. at least one stroke!),
* and if we are not in edit mode!
*/
@@ -1320,19 +1322,19 @@ static int gp_convert_layer_exec(bContext *C, wmOperator *op)
const bool link_strokes = RNA_boolean_get(op->ptr, "use_link_strokes");
bool valid_timing;
tGpTimingData gtd;
-
+
/* check if there's data to work with */
if (gpd == NULL) {
BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data to work on");
return OPERATOR_CANCELLED;
}
-
+
if (!RNA_property_is_set(op->ptr, prop) && !gp_convert_check_has_valid_timing(C, gpl, op)) {
BKE_report(op->reports, RPT_WARNING,
"Current Grease Pencil strokes have no valid timing data, most timing options will be hidden!");
}
valid_timing = RNA_property_boolean_get(op->ptr, prop);
-
+
gtd.mode = RNA_enum_get(op->ptr, "timing_mode");
/* Check for illegal timing mode! */
if (!valid_timing && !ELEM(gtd.mode, GP_STROKECONVERT_TIMING_NONE, GP_STROKECONVERT_TIMING_LINEAR)) {
@@ -1342,7 +1344,7 @@ static int gp_convert_layer_exec(bContext *C, wmOperator *op)
if (!link_strokes) {
gtd.mode = GP_STROKECONVERT_TIMING_NONE;
}
-
+
/* grab all relevant settings */
gtd.frame_range = RNA_int_get(op->ptr, "frame_range");
gtd.start_frame = RNA_int_get(op->ptr, "start_frame");
@@ -1357,10 +1359,10 @@ static int gp_convert_layer_exec(bContext *C, wmOperator *op)
gtd.tot_dist = gtd.tot_time = gtd.gap_tot_time = 0.0f;
gtd.inittime = 0.0;
gtd.offset_time = 0.0f;
-
+
/* perform conversion */
gp_layer_to_curve(C, op->reports, gpd, gpl, mode, norm_weights, rad_fac, link_strokes, &gtd);
-
+
/* free temp memory */
if (gtd.dists) {
MEM_freeN(gtd.dists);
@@ -1370,11 +1372,11 @@ static int gp_convert_layer_exec(bContext *C, wmOperator *op)
MEM_freeN(gtd.times);
gtd.times = NULL;
}
-
+
/* notifiers */
WM_event_add_notifier(C, NC_OBJECT | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -1388,7 +1390,7 @@ static bool gp_convert_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop)
float gap_duration = RNA_float_get(ptr, "gap_duration");
float gap_randomness = RNA_float_get(ptr, "gap_randomness");
const bool valid_timing = RNA_boolean_get(ptr, "use_timing_data");
-
+
/* Always show those props */
if (STREQ(prop_id, "type") ||
STREQ(prop_id, "use_normalize_weights") ||
@@ -1397,16 +1399,16 @@ static bool gp_convert_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop)
{
return true;
}
-
+
/* Never show this prop */
if (STREQ(prop_id, "use_timing_data"))
return false;
-
+
if (link_strokes) {
/* Only show when link_stroke is true */
if (STREQ(prop_id, "timing_mode"))
return true;
-
+
if (timing_mode != GP_STROKECONVERT_TIMING_NONE) {
/* Only show when link_stroke is true and stroke timing is enabled */
if (STREQ(prop_id, "frame_range") ||
@@ -1414,31 +1416,31 @@ static bool gp_convert_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop)
{
return true;
}
-
+
/* Only show if we have valid timing data! */
if (valid_timing && STREQ(prop_id, "use_realtime"))
return true;
-
+
/* Only show if realtime or valid_timing is false! */
if ((!realtime || !valid_timing) && STREQ(prop_id, "end_frame"))
return true;
-
+
if (valid_timing && timing_mode == GP_STROKECONVERT_TIMING_CUSTOMGAP) {
/* Only show for custom gaps! */
if (STREQ(prop_id, "gap_duration"))
return true;
-
+
/* Only show randomness for non-null custom gaps! */
if (STREQ(prop_id, "gap_randomness") && (gap_duration > 0.0f))
return true;
-
+
/* Only show seed for randomize action! */
if (STREQ(prop_id, "seed") && (gap_duration > 0.0f) && (gap_randomness > 0.0f))
return true;
}
}
}
-
+
/* Else, hidden! */
return false;
}
@@ -1448,9 +1450,9 @@ static void gp_convert_ui(bContext *C, wmOperator *op)
uiLayout *layout = op->layout;
wmWindowManager *wm = CTX_wm_manager(C);
PointerRNA ptr;
-
+
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
-
+
/* Main auto-draw call */
uiDefAutoButsRNA(layout, &ptr, gp_convert_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
}
@@ -1458,35 +1460,35 @@ static void gp_convert_ui(bContext *C, wmOperator *op)
void GPENCIL_OT_convert(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Convert Grease Pencil";
ot->idname = "GPENCIL_OT_convert";
ot->description = "Convert the active Grease Pencil layer to a new Curve Object";
-
+
/* callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = gp_convert_layer_exec;
ot->poll = gp_convert_poll;
ot->ui = gp_convert_ui;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", prop_gpencil_convertmodes, 0, "Type", "Which type of curve to convert to");
-
+
RNA_def_boolean(ot->srna, "use_normalize_weights", true, "Normalize Weight",
"Normalize weight (set from stroke width)");
RNA_def_float(ot->srna, "radius_multiplier", 1.0f, 0.0f, 1000.0f, "Radius Fac",
"Multiplier for the points' radii (set from stroke width)", 0.0f, 10.0f);
RNA_def_boolean(ot->srna, "use_link_strokes", true, "Link Strokes",
"Whether to link strokes with zero-radius sections of curves");
-
+
prop = RNA_def_enum(ot->srna, "timing_mode", prop_gpencil_convert_timingmodes, GP_STROKECONVERT_TIMING_FULL,
"Timing Mode", "How to use timing data stored in strokes");
RNA_def_enum_funcs(prop, rna_GPConvert_mode_items);
-
+
RNA_def_int(ot->srna, "frame_range", 100, 1, 10000, "Frame Range",
"The duration of evaluation of the path control curve", 1, 1000);
RNA_def_int(ot->srna, "start_frame", 1, 1, 100000, "Start Frame",
@@ -1496,7 +1498,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot)
prop = RNA_def_int(ot->srna, "end_frame", 250, 1, 100000, "End Frame",
"The end frame of the path control curve (if Realtime is not set)", 1, 100000);
RNA_def_property_update_runtime(prop, gp_convert_set_end_frame);
-
+
RNA_def_float(ot->srna, "gap_duration", 0.0f, 0.0f, 10000.0f, "Gap Duration",
"Custom Gap mode: (Average) length of gaps, in frames "
"(Note: Realtime value, will be scaled if Realtime is not set)", 0.0f, 1000.0f);
@@ -1504,7 +1506,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot)
"Custom Gap mode: Number of frames that gap lengths can vary", 0.0f, 1000.0f);
RNA_def_int(ot->srna, "seed", 0, 0, 1000, "Random Seed",
"Custom Gap mode: Random generator seed", 0, 100);
-
+
/* Note: Internal use, this one will always be hidden by UI code... */
prop = RNA_def_boolean(ot->srna, "use_timing_data", false, "Has Valid Timing",
"Whether the converted Grease Pencil layer has valid timing data (internal use)");
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 9d183222c2d..2e8e48b2f15 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -93,7 +93,7 @@ static int gp_data_add_exec(bContext *C, wmOperator *op)
else {
/* decrement user count and add new datablock */
bGPdata *gpd = (*gpd_ptr);
-
+
id_us_min(&gpd->id);
*gpd_ptr = BKE_gpencil_data_addnew(DATA_("GPencil"));
@@ -106,10 +106,10 @@ static int gp_data_add_exec(bContext *C, wmOperator *op)
}
}
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -120,7 +120,7 @@ void GPENCIL_OT_data_add(wmOperatorType *ot)
ot->idname = "GPENCIL_OT_data_add";
ot->description = "Add new Grease Pencil data-block";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* callbacks */
ot->exec = gp_data_add_exec;
ot->poll = gp_add_poll;
@@ -132,7 +132,7 @@ void GPENCIL_OT_data_add(wmOperatorType *ot)
static int gp_data_unlink_poll(bContext *C)
{
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
-
+
/* if we have access to some active data, make sure there's a datablock before enabling this */
return (gpd_ptr && *gpd_ptr);
}
@@ -142,7 +142,7 @@ static int gp_data_unlink_poll(bContext *C)
static int gp_data_unlink_exec(bContext *C, wmOperator *op)
{
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
-
+
if (gpd_ptr == NULL) {
BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go");
return OPERATOR_CANCELLED;
@@ -154,10 +154,10 @@ static int gp_data_unlink_exec(bContext *C, wmOperator *op)
id_us_min(&gpd->id);
*gpd_ptr = NULL;
}
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -168,7 +168,7 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot)
ot->idname = "GPENCIL_OT_data_unlink";
ot->description = "Unlink active Grease Pencil data-block";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* callbacks */
ot->exec = gp_data_unlink_exec;
ot->poll = gp_data_unlink_poll;
@@ -193,7 +193,7 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op)
}
if (*gpd_ptr == NULL)
*gpd_ptr = BKE_gpencil_data_addnew(DATA_("GPencil"));
-
+
/* if not exist brushes, create a new set */
if (ts) {
if (BLI_listbase_is_empty(&ts->gp_brushes)) {
@@ -204,10 +204,10 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op)
/* add new layer now */
BKE_gpencil_layer_addnew(*gpd_ptr, DATA_("GP_Layer"), true);
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -217,9 +217,9 @@ void GPENCIL_OT_layer_add(wmOperatorType *ot)
ot->name = "Add New Layer";
ot->idname = "GPENCIL_OT_layer_add";
ot->description = "Add new Grease Pencil layer for the active Grease Pencil data-block";
-
+
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* callbacks */
ot->exec = gp_layer_add_exec;
ot->poll = gp_add_poll;
@@ -231,16 +231,16 @@ static int gp_layer_remove_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
-
+
/* sanity checks */
if (ELEM(NULL, gpd, gpl))
return OPERATOR_CANCELLED;
-
+
if (gpl->flag & GP_LAYER_LOCKED) {
BKE_report(op->reports, RPT_ERROR, "Cannot delete locked layers");
return OPERATOR_CANCELLED;
}
-
+
/* make the layer before this the new active layer
* - use the one after if this is the first
* - if this is the only layer, this naturally becomes NULL
@@ -249,13 +249,13 @@ static int gp_layer_remove_exec(bContext *C, wmOperator *op)
BKE_gpencil_layer_setactive(gpd, gpl->prev);
else
BKE_gpencil_layer_setactive(gpd, gpl->next);
-
+
/* delete the layer now... */
BKE_gpencil_layer_delete(gpd, gpl);
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -265,9 +265,9 @@ void GPENCIL_OT_layer_remove(wmOperatorType *ot)
ot->name = "Remove Layer";
ot->idname = "GPENCIL_OT_layer_remove";
ot->description = "Remove active Grease Pencil layer";
-
+
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* callbacks */
ot->exec = gp_layer_remove_exec;
ot->poll = gp_active_layer_poll;
@@ -284,18 +284,18 @@ static int gp_layer_move_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
-
+
int direction = RNA_enum_get(op->ptr, "type");
-
+
/* sanity checks */
if (ELEM(NULL, gpd, gpl))
return OPERATOR_CANCELLED;
-
+
BLI_assert(ELEM(direction, -1, 0, 1)); /* we use value below */
if (BLI_listbase_link_move(&gpd->layers, gpl, direction)) {
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
-
+
return OPERATOR_FINISHED;
}
@@ -306,19 +306,19 @@ void GPENCIL_OT_layer_move(wmOperatorType *ot)
{GP_LAYER_MOVE_DOWN, "DOWN", 0, "Down", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "Move Grease Pencil Layer";
ot->idname = "GPENCIL_OT_layer_move";
ot->description = "Move the active Grease Pencil layer up/down in the list";
-
+
/* api callbacks */
ot->exec = gp_layer_move_exec;
ot->poll = gp_active_layer_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
ot->prop = RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", "");
}
@@ -329,22 +329,22 @@ static int gp_layer_copy_exec(bContext *C, wmOperator *UNUSED(op))
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
bGPDlayer *new_layer;
-
+
/* sanity checks */
if (ELEM(NULL, gpd, gpl))
return OPERATOR_CANCELLED;
-
+
/* make copy of layer, and add it immediately after the existing layer */
new_layer = BKE_gpencil_layer_duplicate(gpl);
BLI_insertlinkafter(&gpd->layers, gpl, new_layer);
-
+
/* ensure new layer has a unique name, and is now the active layer */
BLI_uniquename(&gpd->layers, new_layer, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), sizeof(new_layer->info));
BKE_gpencil_layer_setactive(gpd, new_layer);
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -354,11 +354,11 @@ void GPENCIL_OT_layer_duplicate(wmOperatorType *ot)
ot->name = "Duplicate Layer";
ot->idname = "GPENCIL_OT_layer_duplicate";
ot->description = "Make a copy of the active Grease Pencil layer";
-
+
/* callbacks */
ot->exec = gp_layer_copy_exec;
ot->poll = gp_active_layer_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -370,14 +370,14 @@ static int gp_hide_exec(bContext *C, wmOperator *op)
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *layer = BKE_gpencil_layer_getactive(gpd);
bool unselected = RNA_boolean_get(op->ptr, "unselected");
-
+
/* sanity checks */
if (ELEM(NULL, gpd, layer))
return OPERATOR_CANCELLED;
-
+
if (unselected) {
bGPDlayer *gpl;
-
+
/* hide unselected */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if (gpl != layer) {
@@ -389,10 +389,10 @@ static int gp_hide_exec(bContext *C, wmOperator *op)
/* hide selected/active */
layer->flag |= GP_LAYER_HIDE;
}
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -402,14 +402,14 @@ void GPENCIL_OT_hide(wmOperatorType *ot)
ot->name = "Hide Layer(s)";
ot->idname = "GPENCIL_OT_hide";
ot->description = "Hide selected/unselected Grease Pencil layers";
-
+
/* callbacks */
ot->exec = gp_hide_exec;
ot->poll = gp_active_layer_poll; /* NOTE: we need an active layer to play with */
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected layers");
}
@@ -452,7 +452,7 @@ static int gp_reveal_exec(bContext *C, wmOperator *op)
/* sanity checks */
if (gpd == NULL)
return OPERATOR_CANCELLED;
-
+
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if (gpl->flag & GP_LAYER_HIDE) {
@@ -476,10 +476,10 @@ static int gp_reveal_exec(bContext *C, wmOperator *op)
}
}
}
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -489,11 +489,11 @@ void GPENCIL_OT_reveal(wmOperatorType *ot)
ot->name = "Show All Layers";
ot->idname = "GPENCIL_OT_reveal";
ot->description = "Show all Grease Pencil layers";
-
+
/* callbacks */
ot->exec = gp_reveal_exec;
ot->poll = gp_reveal_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -507,19 +507,19 @@ static int gp_lock_all_exec(bContext *C, wmOperator *UNUSED(op))
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl;
-
+
/* sanity checks */
if (gpd == NULL)
return OPERATOR_CANCELLED;
-
+
/* make all layers non-editable */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
gpl->flag |= GP_LAYER_LOCKED;
}
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -529,11 +529,11 @@ void GPENCIL_OT_lock_all(wmOperatorType *ot)
ot->name = "Lock All Layers";
ot->idname = "GPENCIL_OT_lock_all";
ot->description = "Lock all Grease Pencil layers to prevent them from being accidentally modified";
-
+
/* callbacks */
ot->exec = gp_lock_all_exec;
ot->poll = gp_reveal_poll; /* XXX: could use dedicated poll later */
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -544,19 +544,19 @@ static int gp_unlock_all_exec(bContext *C, wmOperator *UNUSED(op))
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl;
-
+
/* sanity checks */
if (gpd == NULL)
return OPERATOR_CANCELLED;
-
+
/* make all layers editable again */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
gpl->flag &= ~GP_LAYER_LOCKED;
}
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -566,11 +566,11 @@ void GPENCIL_OT_unlock_all(wmOperatorType *ot)
ot->name = "Unlock All Layers";
ot->idname = "GPENCIL_OT_unlock_all";
ot->description = "Unlock all Grease Pencil layers so that they can be edited";
-
+
/* callbacks */
ot->exec = gp_unlock_all_exec;
ot->poll = gp_reveal_poll; /* XXX: could use dedicated poll later */
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -584,21 +584,21 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op)
bGPDlayer *gpl;
int flags = GP_LAYER_LOCKED;
bool isolate = false;
-
+
if (RNA_boolean_get(op->ptr, "affect_visibility"))
flags |= GP_LAYER_HIDE;
-
+
if (ELEM(NULL, gpd, layer)) {
BKE_report(op->reports, RPT_ERROR, "No active layer to isolate");
return OPERATOR_CANCELLED;
}
-
+
/* Test whether to isolate or clear all flags */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* Skip if this is the active layer */
if (gpl == layer)
continue;
-
+
/* If the flags aren't set, that means that the layer is
* not alone, so we have some layers to isolate still
*/
@@ -607,7 +607,7 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op)
break;
}
}
-
+
/* Set/Clear flags as appropriate */
/* TODO: Include onionskinning on this list? */
if (isolate) {
@@ -625,10 +625,10 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op)
gpl->flag &= ~flags;
}
}
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -638,14 +638,14 @@ void GPENCIL_OT_layer_isolate(wmOperatorType *ot)
ot->name = "Isolate Layer";
ot->idname = "GPENCIL_OT_layer_isolate";
ot->description = "Toggle whether the active layer is the only one that can be edited and/or visible";
-
+
/* callbacks */
ot->exec = gp_isolate_layer_exec;
ot->poll = gp_active_layer_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "affect_visibility", false, "Affect Visibility",
"In addition to toggling the editability, also affect the visibility");
@@ -712,13 +712,13 @@ static int gp_layer_change_invoke(bContext *C, wmOperator *op, const wmEvent *UN
{
uiPopupMenu *pup;
uiLayout *layout;
-
+
/* call the menu, which will call this operator again, hence the canceled */
pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE);
layout = UI_popup_menu_layout(pup);
uiItemsEnumO(layout, "GPENCIL_OT_layer_change", "layer");
UI_popup_menu_end(C, pup);
-
+
return OPERATOR_INTERFACE;
}
@@ -727,7 +727,7 @@ static int gp_layer_change_exec(bContext *C, wmOperator *op)
bGPdata *gpd = CTX_data_gpencil_data(C);
bGPDlayer *gpl = NULL;
int layer_num = RNA_enum_get(op->ptr, "layer");
-
+
/* Get layer or create new one */
if (layer_num == -1) {
/* Create layer */
@@ -736,19 +736,19 @@ static int gp_layer_change_exec(bContext *C, wmOperator *op)
else {
/* Try to get layer */
gpl = BLI_findlink(&gpd->layers, layer_num);
-
+
if (gpl == NULL) {
BKE_reportf(op->reports, RPT_ERROR, "Cannot change to non-existent layer (index = %d)", layer_num);
return OPERATOR_CANCELLED;
}
}
-
+
/* Set active layer */
BKE_gpencil_layer_setactive(gpd, gpl);
-
+
/* updates */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -758,15 +758,15 @@ void GPENCIL_OT_layer_change(wmOperatorType *ot)
ot->name = "Change Layer";
ot->idname = "GPENCIL_OT_layer_change";
ot->description = "Change active Grease Pencil layer";
-
+
/* callbacks */
ot->invoke = gp_layer_change_invoke;
ot->exec = gp_layer_change_exec;
ot->poll = gp_active_layer_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* gp layer to use (dynamic enum) */
ot->prop = RNA_def_enum(ot->srna, "layer", DummyRNA_DEFAULT_items, 0, "Grease Pencil Layer", "");
RNA_def_enum_funcs(ot->prop, ED_gpencil_layers_with_new_enum_itemf);
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index d2f291f69fb..45caadf3742 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -57,6 +57,7 @@
#include "BKE_context.h"
#include "BKE_gpencil.h"
#include "BKE_library.h"
+#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_screen.h"
@@ -93,10 +94,10 @@ static int gpencil_editmode_toggle_poll(bContext *C)
static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
-
+
if (gpd == NULL)
return OPERATOR_CANCELLED;
-
+
/* Just toggle editmode flag... */
gpd->flag ^= GP_DATA_STROKE_EDITMODE;
/* recalculate parent matrix */
@@ -107,7 +108,7 @@ static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *UNUSED(op))
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL);
WM_event_add_notifier(C, NC_GPENCIL | ND_GPENCIL_EDITMODE, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_MODE, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -117,11 +118,11 @@ void GPENCIL_OT_editmode_toggle(wmOperatorType *ot)
ot->name = "Strokes Edit Mode Toggle";
ot->idname = "GPENCIL_OT_editmode_toggle";
ot->description = "Enter/Exit edit mode for Grease Pencil strokes";
-
+
/* callbacks */
ot->exec = gpencil_editmode_toggle_exec;
ot->poll = gpencil_editmode_toggle_poll;
-
+
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER;
}
@@ -182,10 +183,10 @@ static void gp_duplicate_points(const bGPDstroke *gps, ListBase *new_strokes, co
{
bGPDspoint *pt;
int i;
-
+
int start_idx = -1;
-
-
+
+
/* Step through the original stroke's points:
* - We accumulate selected points (from start_idx to current index)
* and then convert that to a new stroke
@@ -200,7 +201,7 @@ static void gp_duplicate_points(const bGPDstroke *gps, ListBase *new_strokes, co
}
else {
size_t len = 0;
-
+
/* is this the end of current island yet?
* 1) Point i-1 was the last one that was selected
* 2) Point i is the last in the array
@@ -212,29 +213,29 @@ static void gp_duplicate_points(const bGPDstroke *gps, ListBase *new_strokes, co
len = i - start_idx + 1;
}
//printf("copying from %d to %d = %d\n", start_idx, i, len);
-
+
/* make copies of the relevant data */
if (len) {
bGPDstroke *gpsd;
-
+
/* make a stupid copy first of the entire stroke (to get the flags too) */
gpsd = MEM_dupallocN(gps);
BLI_strncpy(gpsd->tmp_layerinfo, layername, sizeof(gpsd->tmp_layerinfo)); /* saves original layer name */
-
+
/* initialize triangle memory - will be calculated on next redraw */
gpsd->triangles = NULL;
gpsd->flag |= GP_STROKE_RECALC_CACHES;
gpsd->tot_triangles = 0;
-
+
/* now, make a new points array, and copy of the relevant parts */
gpsd->points = MEM_callocN(sizeof(bGPDspoint) * len, "gps stroke points copy");
memcpy(gpsd->points, gps->points + start_idx, sizeof(bGPDspoint) * len);
gpsd->totpoints = len;
-
+
/* add to temp buffer */
gpsd->next = gpsd->prev = NULL;
BLI_addtail(new_strokes, gpsd);
-
+
/* cleanup + reset for next */
start_idx = -1;
}
@@ -245,12 +246,12 @@ static void gp_duplicate_points(const bGPDstroke *gps, ListBase *new_strokes, co
static int gp_duplicate_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
-
+
if (gpd == NULL) {
BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
return OPERATOR_CANCELLED;
}
-
+
/* for each visible (and editable) layer's selected strokes,
* copy the strokes into a temporary buffer, then append
* once all done
@@ -260,22 +261,22 @@ static int gp_duplicate_exec(bContext *C, wmOperator *op)
ListBase new_strokes = {NULL, NULL};
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps;
-
+
if (gpf == NULL)
continue;
-
+
/* make copies of selected strokes, and deselect these once we're done */
for (gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
}
-
+
if (gps->flag & GP_STROKE_SELECT) {
if (gps->totpoints == 1) {
/* Special Case: If there's just a single point in this stroke... */
bGPDstroke *gpsd;
-
+
/* make direct copies of the stroke and its points */
gpsd = MEM_dupallocN(gps);
BLI_strncpy(gpsd->tmp_layerinfo, gpl->info, sizeof(gpsd->tmp_layerinfo));
@@ -284,7 +285,7 @@ static int gp_duplicate_exec(bContext *C, wmOperator *op)
/* triangle information - will be calculated on next redraw */
gpsd->flag |= GP_STROKE_RECALC_CACHES;
gpsd->triangles = NULL;
-
+
/* add to temp buffer */
gpsd->next = gpsd->prev = NULL;
BLI_addtail(&new_strokes, gpsd);
@@ -293,23 +294,23 @@ static int gp_duplicate_exec(bContext *C, wmOperator *op)
/* delegate to a helper, as there's too much to fit in here (for copying subsets)... */
gp_duplicate_points(gps, &new_strokes, gpl->info);
}
-
+
/* deselect original stroke, or else the originals get moved too
* (when using the copy + move macro)
*/
gps->flag &= ~GP_STROKE_SELECT;
}
}
-
+
/* add all new strokes in temp buffer to the frame (preventing double-copies) */
BLI_movelisttolist(&gpf->strokes, &new_strokes);
BLI_assert(new_strokes.first == NULL);
}
CTX_DATA_END;
-
+
/* updates */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -319,11 +320,11 @@ void GPENCIL_OT_duplicate(wmOperatorType *ot)
ot->name = "Duplicate Strokes";
ot->idname = "GPENCIL_OT_duplicate";
ot->description = "Duplicate the selected Grease Pencil strokes";
-
+
/* callbacks */
ot->exec = gp_duplicate_exec;
ot->poll = gp_stroke_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -352,7 +353,7 @@ static GHash *gp_strokes_copypastebuf_colors = NULL;
void ED_gpencil_strokes_copybuf_free(void)
{
bGPDstroke *gps, *gpsn;
-
+
/* Free the palettes buffer
* NOTE: This is done before the strokes so that the name ptrs (keys) are still safe
*/
@@ -360,17 +361,17 @@ void ED_gpencil_strokes_copybuf_free(void)
BLI_ghash_free(gp_strokes_copypastebuf_colors, NULL, MEM_freeN);
gp_strokes_copypastebuf_colors = NULL;
}
-
+
/* Free the stroke buffer */
for (gps = gp_strokes_copypastebuf.first; gps; gps = gpsn) {
gpsn = gps->next;
-
+
if (gps->points) MEM_freeN(gps->points);
if (gps->triangles) MEM_freeN(gps->triangles);
-
+
BLI_freelinkN(&gp_strokes_copypastebuf, gps);
}
-
+
gp_strokes_copypastebuf.first = gp_strokes_copypastebuf.last = NULL;
}
@@ -381,18 +382,18 @@ GHash *gp_copybuf_validate_colormap(bGPdata *gpd)
{
GHash *new_colors = BLI_ghash_str_new("GPencil Paste Dst Colors");
GHashIterator gh_iter;
-
+
/* If there's no active palette yet (i.e. new datablock), add one */
bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd);
if (palette == NULL) {
palette = BKE_gpencil_palette_addnew(gpd, "Pasted Palette", true);
}
-
+
/* For each color, figure out what to map to... */
GHASH_ITER(gh_iter, gp_strokes_copypastebuf_colors) {
bGPDpalettecolor *palcolor;
char *name = BLI_ghashIterator_getKey(&gh_iter);
-
+
/* Look for existing color to map to */
/* XXX: What to do if same name but different color? Behaviour here should depend on a property? */
palcolor = BKE_gpencil_palettecolor_getbyname(palette, name);
@@ -400,17 +401,17 @@ GHash *gp_copybuf_validate_colormap(bGPdata *gpd)
/* Doesn't Exist - Create new matching color for this palette */
/* XXX: This still doesn't fix the pasting across file boundaries problem... */
bGPDpalettecolor *src_color = BLI_ghashIterator_getValue(&gh_iter);
-
+
palcolor = MEM_dupallocN(src_color);
BLI_addtail(&palette->colors, palcolor);
-
+
BLI_uniquename(&palette->colors, palcolor, DATA_("GP Color"), '.', offsetof(bGPDpalettecolor, info), sizeof(palcolor->info));
}
-
+
/* Store this mapping (for use later when pasting) */
BLI_ghash_insert(new_colors, name, palcolor);
}
-
+
return new_colors;
}
@@ -420,15 +421,15 @@ GHash *gp_copybuf_validate_colormap(bGPdata *gpd)
static int gp_strokes_copy_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
-
+
if (gpd == NULL) {
BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
return OPERATOR_CANCELLED;
}
-
+
/* clear the buffer first */
ED_gpencil_strokes_copybuf_free();
-
+
/* for each visible (and editable) layer's selected strokes,
* copy the strokes into a temporary buffer, then append
* once all done
@@ -437,31 +438,31 @@ static int gp_strokes_copy_exec(bContext *C, wmOperator *op)
{
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps;
-
+
if (gpf == NULL)
continue;
-
+
/* make copies of selected strokes, and deselect these once we're done */
for (gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false)
continue;
-
+
if (gps->flag & GP_STROKE_SELECT) {
if (gps->totpoints == 1) {
/* Special Case: If there's just a single point in this stroke... */
bGPDstroke *gpsd;
-
+
/* make direct copies of the stroke and its points */
gpsd = MEM_dupallocN(gps);
BLI_strncpy(gpsd->tmp_layerinfo, gpl->info, sizeof(gpsd->tmp_layerinfo)); /* saves original layer name */
gpsd->points = MEM_dupallocN(gps->points);
-
+
/* triangles cache - will be recalculated on next redraw */
gpsd->flag |= GP_STROKE_RECALC_CACHES;
gpsd->tot_triangles = 0;
gpsd->triangles = NULL;
-
+
/* add to temp buffer */
gpsd->next = gpsd->prev = NULL;
BLI_addtail(&gp_strokes_copypastebuf, gpsd);
@@ -474,26 +475,26 @@ static int gp_strokes_copy_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_END;
-
+
/* Build up hash of colors used in these strokes, making copies of these to protect against dangling pointers */
if (gp_strokes_copypastebuf.first) {
gp_strokes_copypastebuf_colors = BLI_ghash_str_new("GPencil CopyBuf Colors");
-
+
for (bGPDstroke *gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) {
if (ED_gpencil_stroke_can_use(C, gps)) {
if (BLI_ghash_haskey(gp_strokes_copypastebuf_colors, gps->colorname) == false) {
bGPDpalettecolor *color = MEM_dupallocN(gps->palcolor);
-
+
BLI_ghash_insert(gp_strokes_copypastebuf_colors, gps->colorname, color);
gps->palcolor = color;
}
}
}
}
-
+
/* updates (to ensure operator buttons are refreshed, when used via hotkeys) */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL); // XXX?
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -504,11 +505,11 @@ void GPENCIL_OT_copy(wmOperatorType *ot)
ot->name = "Copy Strokes";
ot->idname = "GPENCIL_OT_copy";
ot->description = "Copy selected Grease Pencil points and strokes";
-
+
/* callbacks */
ot->exec = gp_strokes_copy_exec;
ot->poll = gp_stroke_edit_poll;
-
+
/* flags */
//ot->flag = OPTYPE_REGISTER;
}
@@ -537,10 +538,10 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C); /* only use active for copy merge */
bGPDframe *gpf;
-
+
eGP_PasteMode type = RNA_enum_get(op->ptr, "type");
GHash *new_colors;
-
+
/* check for various error conditions */
if (gpd == NULL) {
BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
@@ -562,14 +563,14 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
/* Check that some of the strokes in the buffer can be used */
bGPDstroke *gps;
bool ok = false;
-
+
for (gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) {
if (ED_gpencil_stroke_can_use(C, gps)) {
ok = true;
break;
}
}
-
+
if (ok == false) {
/* XXX: this check is not 100% accurate (i.e. image editor is incompatible with normal 2D strokes),
* but should be enough to give users a good idea of what's going on
@@ -578,28 +579,28 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Cannot paste 2D strokes in 3D View");
else
BKE_report(op->reports, RPT_ERROR, "Cannot paste 3D strokes in 2D editors");
-
+
return OPERATOR_CANCELLED;
}
}
-
+
/* Deselect all strokes first */
CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes)
{
bGPDspoint *pt;
int i;
-
+
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
pt->flag &= ~GP_SPOINT_SELECT;
}
-
+
gps->flag &= ~GP_STROKE_SELECT;
}
CTX_DATA_END;
-
+
/* Ensure that all the necessary colors exist */
new_colors = gp_copybuf_validate_colormap(gpd);
-
+
/* Copy over the strokes from the buffer (and adjust the colors) */
for (bGPDstroke *gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) {
if (ED_gpencil_stroke_can_use(C, gps)) {
@@ -611,7 +612,7 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
gpl = CTX_data_active_gpencil_layer(C);
}
}
-
+
/* Ensure we have a frame to draw into
* NOTE: Since this is an op which creates strokes,
* we are obliged to add a new frame if one
@@ -622,33 +623,33 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
/* Create new stroke */
bGPDstroke *new_stroke = MEM_dupallocN(gps);
new_stroke->tmp_layerinfo[0] = '\0';
-
+
new_stroke->points = MEM_dupallocN(gps->points);
-
+
new_stroke->flag |= GP_STROKE_RECALC_CACHES;
new_stroke->triangles = NULL;
-
+
new_stroke->next = new_stroke->prev = NULL;
BLI_addtail(&gpf->strokes, new_stroke);
-
+
/* Fix color references */
BLI_assert(new_stroke->colorname[0] != '\0');
new_stroke->palcolor = BLI_ghash_lookup(new_colors, new_stroke->colorname);
-
+
BLI_assert(new_stroke->palcolor != NULL);
BLI_strncpy(new_stroke->colorname, new_stroke->palcolor->info, sizeof(new_stroke->colorname));
-
+
/*new_stroke->flag |= GP_STROKE_RECALC_COLOR; */
}
}
}
-
+
/* free temp data */
BLI_ghash_free(new_colors, NULL, NULL);
-
+
/* updates */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -659,19 +660,19 @@ void GPENCIL_OT_paste(wmOperatorType *ot)
{GP_COPY_MERGE, "MERGE", 0, "Merge", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "Paste Strokes";
ot->idname = "GPENCIL_OT_paste";
ot->description = "Paste previously copied strokes or copy and merge in active layer";
-
+
/* callbacks */
ot->exec = gp_strokes_paste_exec;
ot->poll = gp_strokes_paste_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", copy_type, 0, "Type", "");
}
@@ -682,13 +683,13 @@ static int gp_move_to_layer_invoke(bContext *C, wmOperator *op, const wmEvent *U
{
uiPopupMenu *pup;
uiLayout *layout;
-
+
/* call the menu, which will call this operator again, hence the canceled */
pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE);
layout = UI_popup_menu_layout(pup);
uiItemsEnumO(layout, "GPENCIL_OT_move_to_layer", "layer");
UI_popup_menu_end(C, pup);
-
+
return OPERATOR_INTERFACE;
}
@@ -699,7 +700,7 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op)
bGPDlayer *target_layer = NULL;
ListBase strokes = {NULL, NULL};
int layer_num = RNA_enum_get(op->ptr, "layer");
-
+
/* Get layer or create new one */
if (layer_num == -1) {
/* Create layer */
@@ -708,13 +709,13 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op)
else {
/* Try to get layer */
target_layer = BLI_findlink(&gpd->layers, layer_num);
-
+
if (target_layer == NULL) {
BKE_reportf(op->reports, RPT_ERROR, "There is no layer number %d", layer_num);
return OPERATOR_CANCELLED;
}
}
-
+
/* Extract all strokes to move to this layer
* NOTE: We need to do this in a two-pass system to avoid conflicts with strokes
* getting repeatedly moved
@@ -723,19 +724,19 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op)
{
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps, *gpsn;
-
+
/* skip if no frame with strokes, or if this is the layer we're moving strokes to */
if ((gpl == target_layer) || (gpf == NULL))
continue;
-
+
/* make copies of selected strokes, and deselect these once we're done */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
-
+
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false)
continue;
-
+
/* TODO: Don't just move entire strokes - instead, only copy the selected portions... */
if (gps->flag & GP_STROKE_SELECT) {
BLI_remlink(&gpf->strokes, gps);
@@ -744,19 +745,19 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_END;
-
+
/* Paste them all in one go */
if (strokes.first) {
Scene *scene = CTX_data_scene(C);
bGPDframe *gpf = BKE_gpencil_layer_getframe(target_layer, CFRA, true);
-
+
BLI_movelisttolist(&gpf->strokes, &strokes);
BLI_assert((strokes.first == strokes.last) && (strokes.first == NULL));
}
-
+
/* updates */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -766,15 +767,15 @@ void GPENCIL_OT_move_to_layer(wmOperatorType *ot)
ot->name = "Move Strokes to Layer";
ot->idname = "GPENCIL_OT_move_to_layer";
ot->description = "Move selected strokes to another layer"; // XXX: allow moving individual points too?
-
+
/* callbacks */
ot->invoke = gp_move_to_layer_invoke;
ot->exec = gp_move_to_layer_exec;
ot->poll = gp_stroke_edit_poll; // XXX?
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* gp layer to use (dynamic enum) */
ot->prop = RNA_def_enum(ot->srna, "layer", DummyRNA_DEFAULT_items, 0, "Grease Pencil Layer", "");
RNA_def_enum_funcs(ot->prop, ED_gpencil_layers_with_new_enum_itemf);
@@ -797,7 +798,7 @@ static int UNUSED_FUNCTION(gp_blank_frame_add_poll)(bContext *C)
else {
CTX_wm_operator_poll_msg_set(C, "Active region not set");
}
-
+
return 0;
}
@@ -814,8 +815,8 @@ static int gp_blank_frame_add_exec(bContext *C, wmOperator *op)
/* let's just be lazy, and call the "Add New Layer" operator, which sets everything up as required */
WM_operator_name_call(C, "GPENCIL_OT_layer_add", WM_OP_EXEC_DEFAULT, NULL);
}
-
- /* Go through each layer, adding a frame after the active one
+
+ /* Go through each layer, adding a frame after the active one
* and/or shunting all the others out of the way
*/
CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
@@ -832,15 +833,15 @@ static int gp_blank_frame_add_exec(bContext *C, wmOperator *op)
gpf->framenum += 1;
}
}
-
+
/* 2) Now add a new frame, with nothing in it */
gpl->actframe = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_ADD_NEW);
}
CTX_DATA_END;
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -851,11 +852,11 @@ void GPENCIL_OT_blank_frame_add(wmOperatorType *ot)
ot->idname = "GPENCIL_OT_blank_frame_add";
ot->description = "Insert a blank frame on the current frame "
"(all subsequently existing frames, if any, are shifted right by one frame)";
-
+
/* callbacks */
ot->exec = gp_blank_frame_add_exec;
ot->poll = gp_add_poll;
-
+
/* properties */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "all_layers", false, "All Layers", "Create blank frame in all layers, not only active");
@@ -867,7 +868,7 @@ static int gp_actframe_delete_poll(bContext *C)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
-
+
/* only if there's an active layer with an active frame */
return (gpl && gpl->actframe);
}
@@ -879,7 +880,7 @@ static int gp_actframe_delete_exec(bContext *C, wmOperator *op)
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, 0);
-
+
/* if there's no existing Grease-Pencil data there, add some */
if (gpd == NULL) {
BKE_report(op->reports, RPT_ERROR, "No grease pencil data");
@@ -889,13 +890,13 @@ static int gp_actframe_delete_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active frame to delete");
return OPERATOR_CANCELLED;
}
-
+
/* delete it... */
BKE_gpencil_layer_delframe(gpl, gpf);
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -905,9 +906,9 @@ void GPENCIL_OT_active_frame_delete(wmOperatorType *ot)
ot->name = "Delete Active Frame";
ot->idname = "GPENCIL_OT_active_frame_delete";
ot->description = "Delete the active frame for the active Grease Pencil Layer";
-
+
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* callbacks */
ot->exec = gp_actframe_delete_exec;
ot->poll = gp_actframe_delete_poll;
@@ -918,7 +919,7 @@ void GPENCIL_OT_active_frame_delete(wmOperatorType *ot)
static int gp_actframe_delete_all_poll(bContext *C)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
-
+
/* 1) There must be grease pencil data
* 2) Hopefully some of the layers have stuff we can use
*/
@@ -929,26 +930,26 @@ static int gp_actframe_delete_all_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
bool success = false;
-
+
CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
{
/* try to get the "active" frame - but only if it actually occurs on this frame */
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, 0);
-
+
if (gpf == NULL)
continue;
-
+
/* delete it... */
BKE_gpencil_layer_delframe(gpl, gpf);
-
+
/* we successfully modified something */
success = true;
}
CTX_DATA_END;
-
+
/* updates */
if (success) {
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
else {
@@ -963,9 +964,9 @@ void GPENCIL_OT_active_frames_delete_all(wmOperatorType *ot)
ot->name = "Delete All Active Frames";
ot->idname = "GPENCIL_OT_active_frames_delete_all";
ot->description = "Delete the active frame(s) of all editable Grease Pencil layers";
-
+
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* callbacks */
ot->exec = gp_actframe_delete_all_exec;
ot->poll = gp_actframe_delete_all_poll;
@@ -988,36 +989,36 @@ typedef enum eGP_DeleteMode {
static int gp_delete_selected_strokes(bContext *C)
{
bool changed = false;
-
+
CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
{
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps, *gpsn;
-
+
if (gpf == NULL)
continue;
-
+
/* simply delete strokes which are selected */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
-
+
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false)
continue;
-
+
/* free stroke if selected */
if (gps->flag & GP_STROKE_SELECT) {
/* free stroke memory arrays, then stroke itself */
if (gps->points) MEM_freeN(gps->points);
if (gps->triangles) MEM_freeN(gps->triangles);
BLI_freelinkN(&gpf->strokes, gps);
-
+
changed = true;
}
}
}
CTX_DATA_END;
-
+
if (changed) {
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1033,34 +1034,34 @@ static int gp_delete_selected_strokes(bContext *C)
static int gp_dissolve_selected_points(bContext *C)
{
bool changed = false;
-
+
CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
{
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps, *gpsn;
-
+
if (gpf == NULL)
continue;
-
+
/* simply delete points from selected strokes
* NOTE: we may still have to remove the stroke if it ends up having no points!
*/
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
-
+
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false)
continue;
/* check if the color is editable */
if (ED_gpencil_stroke_color_use(gpl, gps) == false)
continue;
-
+
if (gps->flag & GP_STROKE_SELECT) {
bGPDspoint *pt;
int i;
-
+
int tot = gps->totpoints; /* number of points in new buffer */
-
+
/* First Pass: Count how many points are selected (i.e. how many to remove) */
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
if (pt->flag & GP_SPOINT_SELECT) {
@@ -1068,7 +1069,7 @@ static int gp_dissolve_selected_points(bContext *C)
tot--;
}
}
-
+
/* if no points are left, we simply delete the entire stroke */
if (tot <= 0) {
/* remove the entire stroke */
@@ -1082,35 +1083,35 @@ static int gp_dissolve_selected_points(bContext *C)
/* just copy all unselected into a smaller buffer */
bGPDspoint *new_points = MEM_callocN(sizeof(bGPDspoint) * tot, "new gp stroke points copy");
bGPDspoint *npt = new_points;
-
+
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
if ((pt->flag & GP_SPOINT_SELECT) == 0) {
*npt = *pt;
npt++;
}
}
-
+
/* free the old buffer */
MEM_freeN(gps->points);
-
+
/* save the new buffer */
gps->points = new_points;
gps->totpoints = tot;
-
+
/* triangles cache needs to be recalculated */
gps->flag |= GP_STROKE_RECALC_CACHES;
gps->tot_triangles = 0;
-
+
/* deselect the stroke, since none of its selected points will still be selected */
gps->flag &= ~GP_STROKE_SELECT;
}
-
+
changed = true;
}
}
}
CTX_DATA_END;
-
+
if (changed) {
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1150,10 +1151,10 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke
tGPDeleteIsland *islands = MEM_callocN(sizeof(tGPDeleteIsland) * (gps->totpoints + 1) / 2, "gp_point_islands");
bool in_island = false;
int num_islands = 0;
-
+
bGPDspoint *pt;
int i;
-
+
/* First Pass: Identify start/end of islands */
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
if (pt->flag & tag_flags) {
@@ -1163,7 +1164,7 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke
else {
/* unselected - start of a new island? */
int idx;
-
+
if (in_island) {
/* extend existing island */
idx = num_islands - 1;
@@ -1173,37 +1174,37 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke
/* start of new island */
in_island = true;
num_islands++;
-
+
idx = num_islands - 1;
islands[idx].start_idx = islands[idx].end_idx = i;
}
}
}
-
+
/* Watch out for special case where No islands = All points selected = Delete Stroke only */
if (num_islands) {
/* there are islands, so create a series of new strokes, adding them before the "next" stroke */
int idx;
-
+
/* Create each new stroke... */
for (idx = 0; idx < num_islands; idx++) {
tGPDeleteIsland *island = &islands[idx];
bGPDstroke *new_stroke = MEM_dupallocN(gps);
-
+
/* initialize triangle memory - to be calculated on next redraw */
new_stroke->triangles = NULL;
new_stroke->flag |= GP_STROKE_RECALC_CACHES;
new_stroke->tot_triangles = 0;
-
+
/* Compute new buffer size (+ 1 needed as the endpoint index is "inclusive") */
new_stroke->totpoints = island->end_idx - island->start_idx + 1;
new_stroke->points = MEM_callocN(sizeof(bGPDspoint) * new_stroke->totpoints, "gp delete stroke fragment");
-
+
/* Copy over the relevant points */
memcpy(new_stroke->points, gps->points + island->start_idx, sizeof(bGPDspoint) * new_stroke->totpoints);
-
-
- /* Each island corresponds to a new stroke. We must adjust the
+
+
+ /* Each island corresponds to a new stroke. We must adjust the
* timings of these new strokes:
*
* Each point's timing data is a delta from stroke's inittime, so as we erase some points from
@@ -1215,15 +1216,15 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke
bGPDspoint *pts;
float delta = gps->points[island->start_idx].time;
int j;
-
+
new_stroke->inittime += (double)delta;
-
+
pts = new_stroke->points;
for (j = 0; j < new_stroke->totpoints; j++, pts++) {
pts->time -= delta;
}
}
-
+
/* Add new stroke to the frame */
if (next_stroke) {
BLI_insertlinkbefore(&gpf->strokes, next_stroke, new_stroke);
@@ -1233,10 +1234,10 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke
}
}
}
-
+
/* free islands */
MEM_freeN(islands);
-
+
/* Delete the old stroke */
MEM_freeN(gps->points);
if (gps->triangles) {
@@ -1250,40 +1251,40 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke
static int gp_delete_selected_points(bContext *C)
{
bool changed = false;
-
+
CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
{
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps, *gpsn;
-
+
if (gpf == NULL)
continue;
-
+
/* simply delete strokes which are selected */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
-
+
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false)
continue;
/* check if the color is editable */
if (ED_gpencil_stroke_color_use(gpl, gps) == false)
continue;
-
-
+
+
if (gps->flag & GP_STROKE_SELECT) {
/* deselect old stroke, since it will be used as template for the new strokes */
gps->flag &= ~GP_STROKE_SELECT;
-
+
/* delete unwanted points by splitting stroke into several smaller ones */
gp_stroke_delete_tagged_points(gpf, gps, gpsn, GP_SPOINT_SELECT);
-
+
changed = true;
}
}
}
CTX_DATA_END;
-
+
if (changed) {
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1299,21 +1300,21 @@ static int gp_delete_exec(bContext *C, wmOperator *op)
{
eGP_DeleteMode mode = RNA_enum_get(op->ptr, "type");
int result = OPERATOR_CANCELLED;
-
+
switch (mode) {
case GP_DELETEOP_STROKES: /* selected strokes */
result = gp_delete_selected_strokes(C);
break;
-
+
case GP_DELETEOP_POINTS: /* selected points (breaks the stroke into segments) */
result = gp_delete_selected_points(C);
break;
-
+
case GP_DELETEOP_FRAME: /* active frame */
result = gp_actframe_delete_exec(C, op);
break;
}
-
+
return result;
}
@@ -1325,20 +1326,20 @@ void GPENCIL_OT_delete(wmOperatorType *ot)
{GP_DELETEOP_FRAME, "FRAME", 0, "Frame", "Delete active frame"},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "Delete";
ot->idname = "GPENCIL_OT_delete";
ot->description = "Delete selected Grease Pencil strokes, vertices, or frames";
-
+
/* callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = gp_delete_exec;
ot->poll = gp_stroke_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER;
-
+
/* props */
ot->prop = RNA_def_enum(ot->srna, "type", prop_gpencil_delete_types, 0, "Type", "Method used for deleting Grease Pencil data");
}
@@ -1373,7 +1374,7 @@ static int gp_snap_poll(bContext *C)
{
bGPdata *gpd = CTX_data_gpencil_data(C);
ScrArea *sa = CTX_wm_area(C);
-
+
return (gpd != NULL) && ((sa != NULL) && (sa->spacetype == SPACE_VIEW3D));
}
@@ -1384,29 +1385,29 @@ static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op))
bGPdata *gpd = ED_gpencil_data_get_active(C);
RegionView3D *rv3d = CTX_wm_region_data(C);
const float gridf = rv3d->gridview;
-
+
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* only editable and visible layers are considered */
if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
bGPDframe *gpf = gpl->actframe;
float diff_mat[4][4];
-
+
/* calculate difference matrix if parent object */
if (gpl->parent != NULL) {
ED_gpencil_parent_location(gpl, diff_mat);
}
-
+
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
bGPDspoint *pt;
int i;
-
+
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false)
continue;
/* check if the color is editable */
if (ED_gpencil_stroke_color_use(gpl, gps) == false)
continue;
-
+
// TODO: if entire stroke is selected, offset entire stroke by same amount?
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
/* only if point is selected */
@@ -1420,11 +1421,11 @@ static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op))
/* apply parent transformations */
float fpt[3];
mul_v3_m4v3(fpt, diff_mat, &pt->x);
-
+
fpt[0] = gridf * floorf(0.5f + fpt[0] / gridf);
fpt[1] = gridf * floorf(0.5f + fpt[1] / gridf);
fpt[2] = gridf * floorf(0.5f + fpt[2] / gridf);
-
+
/* return data */
copy_v3_v3(&pt->x, fpt);
gp_apply_parent_point(gpl, pt);
@@ -1434,7 +1435,7 @@ static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op))
}
}
}
-
+
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
@@ -1445,11 +1446,11 @@ void GPENCIL_OT_snap_to_grid(wmOperatorType *ot)
ot->name = "Snap Selection to Grid";
ot->idname = "GPENCIL_OT_snap_to_grid";
ot->description = "Snap selected points to the nearest grid points";
-
+
/* callbacks */
ot->exec = gp_snap_to_grid;
ot->poll = gp_snap_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1459,28 +1460,28 @@ void GPENCIL_OT_snap_to_grid(wmOperatorType *ot)
static int gp_snap_to_cursor(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
-
+
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
-
+
const bool use_offset = RNA_boolean_get(op->ptr, "use_offset");
const float *cursor_global = ED_view3d_cursor3d_get(scene, v3d)->location;
-
+
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* only editable and visible layers are considered */
if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
bGPDframe *gpf = gpl->actframe;
float diff_mat[4][4];
-
+
/* calculate difference matrix if parent object */
if (gpl->parent != NULL) {
ED_gpencil_parent_location(gpl, diff_mat);
}
-
+
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
bGPDspoint *pt;
int i;
-
+
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false)
continue;
@@ -1490,14 +1491,14 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op)
/* only continue if this stroke is selected (editable doesn't guarantee this)... */
if ((gps->flag & GP_STROKE_SELECT) == 0)
continue;
-
+
if (use_offset) {
float offset[3];
-
+
/* compute offset from first point of stroke to cursor */
/* TODO: Allow using midpoint instead? */
sub_v3_v3v3(offset, cursor_global, &gps->points->x);
-
+
/* apply offset to all points in the stroke */
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
add_v3_v3(&pt->x, offset);
@@ -1515,10 +1516,10 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op)
}
}
}
-
+
}
}
-
+
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
@@ -1529,14 +1530,14 @@ void GPENCIL_OT_snap_to_cursor(wmOperatorType *ot)
ot->name = "Snap Selection to Cursor";
ot->idname = "GPENCIL_OT_snap_to_cursor";
ot->description = "Snap selected points/strokes to the cursor";
-
+
/* callbacks */
ot->exec = gp_snap_to_cursor;
ot->poll = gp_snap_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
ot->prop = RNA_def_boolean(ot->srna, "use_offset", true, "With Offset",
"Offset the entire stroke instead of selected points only");
@@ -1547,33 +1548,33 @@ void GPENCIL_OT_snap_to_cursor(wmOperatorType *ot)
static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
-
+
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
-
+
float *cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
float centroid[3] = {0.0f};
float min[3], max[3];
size_t count = 0;
-
+
INIT_MINMAX(min, max);
-
+
/* calculate midpoints from selected points */
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* only editable and visible layers are considered */
if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
bGPDframe *gpf = gpl->actframe;
float diff_mat[4][4];
-
+
/* calculate difference matrix if parent object */
if (gpl->parent != NULL) {
ED_gpencil_parent_location(gpl, diff_mat);
}
-
+
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
bGPDspoint *pt;
int i;
-
+
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false)
continue;
@@ -1583,7 +1584,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
/* only continue if this stroke is selected (editable doesn't guarantee this)... */
if ((gps->flag & GP_STROKE_SELECT) == 0)
continue;
-
+
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
if (pt->flag & GP_SPOINT_SELECT) {
if (gpl->parent == NULL) {
@@ -1594,18 +1595,18 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
/* apply parent transformations */
float fpt[3];
mul_v3_m4v3(fpt, diff_mat, &pt->x);
-
+
add_v3_v3(centroid, fpt);
minmax_v3v3_v3(min, max, fpt);
}
count++;
}
}
-
+
}
}
}
-
+
if (scene->toolsettings->transform_pivot_point == V3D_AROUND_CENTER_MEAN && count) {
mul_v3_fl(centroid, 1.0f / (float)count);
copy_v3_v3(cursor, centroid);
@@ -1614,7 +1615,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
mid_v3_v3v3(cursor, min, max);
}
-
+
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
@@ -1625,11 +1626,11 @@ void GPENCIL_OT_snap_cursor_to_selected(wmOperatorType *ot)
ot->name = "Snap Cursor to Selected Points";
ot->idname = "GPENCIL_OT_snap_cursor_to_selected";
ot->description = "Snap cursor to center of selected points";
-
+
/* callbacks */
ot->exec = gp_snap_cursor_to_sel;
ot->poll = gp_snap_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1685,27 +1686,27 @@ static int gp_stroke_cyclical_set_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
const int type = RNA_enum_get(op->ptr, "type");
-
+
/* sanity checks */
if (ELEM(NULL, gpd))
return OPERATOR_CANCELLED;
-
+
/* loop all selected strokes */
CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
{
if (gpl->actframe == NULL)
continue;
-
+
for (bGPDstroke *gps = gpl->actframe->strokes.last; gps; gps = gps->prev) {
bGPDpalettecolor *palcolor = gps->palcolor;
-
+
/* skip strokes that are not selected or invalid for current view */
if (((gps->flag & GP_STROKE_SELECT) == 0) || ED_gpencil_stroke_can_use(C, gps) == false)
continue;
/* skip hidden or locked colors */
if (!palcolor || (palcolor->flag & PC_COLOR_HIDE) || (palcolor->flag & PC_COLOR_LOCKED))
continue;
-
+
switch (type) {
case GP_STROKE_CYCLIC_CLOSE:
/* Close all (enable) */
@@ -1726,10 +1727,10 @@ static int gp_stroke_cyclical_set_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_END;
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1745,19 +1746,19 @@ void GPENCIL_OT_stroke_cyclical_set(wmOperatorType *ot)
{GP_STROKE_CYCLIC_TOGGLE, "TOGGLE", 0, "Toggle", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "Set Cyclical State";
ot->idname = "GPENCIL_OT_stroke_cyclical_set";
ot->description = "Close or open the selected stroke adding an edge from last to first point";
-
+
/* api callbacks */
ot->exec = gp_stroke_cyclical_set_exec;
ot->poll = gp_active_layer_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", cyclic_type, GP_STROKE_CYCLIC_TOGGLE, "Type", "");
}
@@ -1768,11 +1769,11 @@ void GPENCIL_OT_stroke_cyclical_set(wmOperatorType *ot)
static void gpencil_flip_stroke(bGPDstroke *gps)
{
int end = gps->totpoints - 1;
-
+
for (int i = 0; i < gps->totpoints / 2; i++) {
bGPDspoint *point, *point2;
bGPDspoint pt;
-
+
/* save first point */
point = &gps->points[i];
pt.x = point->x;
@@ -1782,7 +1783,7 @@ static void gpencil_flip_stroke(bGPDstroke *gps)
pt.pressure = point->pressure;
pt.strength = point->strength;
pt.time = point->time;
-
+
/* replace first point with last point */
point2 = &gps->points[end];
point->x = point2->x;
@@ -1792,7 +1793,7 @@ static void gpencil_flip_stroke(bGPDstroke *gps)
point->pressure = point2->pressure;
point->strength = point2->strength;
point->time = point2->time;
-
+
/* replace last point with first saved before */
point = &gps->points[end];
point->x = pt.x;
@@ -1802,7 +1803,7 @@ static void gpencil_flip_stroke(bGPDstroke *gps)
point->pressure = pt.pressure;
point->strength = pt.strength;
point->time = pt.time;
-
+
end--;
}
}
@@ -1812,10 +1813,10 @@ static void gpencil_stroke_copy_point(bGPDstroke *gps, bGPDspoint *point, float
float pressure, float strength, float deltatime)
{
bGPDspoint *newpoint;
-
+
gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1));
gps->totpoints++;
-
+
newpoint = &gps->points[gps->totpoints - 1];
newpoint->x = point->x * delta[0];
newpoint->y = point->y * delta[1];
@@ -1834,28 +1835,28 @@ static void gpencil_stroke_join_strokes(bGPDstroke *gps_a, bGPDstroke *gps_b, co
int i;
float delta[3] = {1.0f, 1.0f, 1.0f};
float deltatime = 0.0f;
-
+
/* sanity checks */
if (ELEM(NULL, gps_a, gps_b))
return;
-
+
if ((gps_a->totpoints == 0) || (gps_b->totpoints == 0))
return;
-
+
/* define start and end points of each stroke */
float sa[3], sb[3], ea[3], eb[3];
pt = &gps_a->points[0];
copy_v3_v3(sa, &pt->x);
-
+
pt = &gps_a->points[gps_a->totpoints - 1];
copy_v3_v3(ea, &pt->x);
-
+
pt = &gps_b->points[0];
copy_v3_v3(sb, &pt->x);
-
+
pt = &gps_b->points[gps_b->totpoints - 1];
copy_v3_v3(eb, &pt->x);
-
+
/* review if need flip stroke B */
float ea_sb = len_squared_v3v3(ea, sb);
float ea_eb = len_squared_v3v3(ea, eb);
@@ -1863,19 +1864,19 @@ static void gpencil_stroke_join_strokes(bGPDstroke *gps_a, bGPDstroke *gps_b, co
if (ea_eb < ea_sb) {
gpencil_flip_stroke(gps_b);
}
-
+
/* don't visibly link the first and last points? */
if (leave_gaps) {
/* 1st: add one tail point to start invisible area */
point = gps_a->points[gps_a->totpoints - 1];
deltatime = point.time;
gpencil_stroke_copy_point(gps_a, &point, delta, 0.0f, 0.0f, 0.0f);
-
+
/* 2nd: add one head point to finish invisible area */
point = gps_b->points[0];
gpencil_stroke_copy_point(gps_a, &point, delta, 0.0f, 0.0f, deltatime);
}
-
+
/* 3rd: add all points */
for (i = 0, pt = gps_b->points; i < gps_b->totpoints && pt; i++, pt++) {
/* check if still room in buffer */
@@ -1892,25 +1893,25 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op)
bGPDstroke *gps, *gpsn;
bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd);
bGPDpalettecolor *palcolor = BKE_gpencil_palettecolor_getactive(palette);
-
+
bGPDframe *gpf_a = NULL;
bGPDstroke *stroke_a = NULL;
bGPDstroke *stroke_b = NULL;
bGPDstroke *new_stroke = NULL;
-
+
const int type = RNA_enum_get(op->ptr, "type");
const bool leave_gaps = RNA_boolean_get(op->ptr, "leave_gaps");
-
+
/* sanity checks */
if (ELEM(NULL, gpd))
return OPERATOR_CANCELLED;
-
+
if (activegpl->flag & GP_LAYER_LOCKED)
return OPERATOR_CANCELLED;
-
+
BLI_assert(ELEM(type, GP_STROKE_JOIN, GP_STROKE_JOINCOPY));
-
-
+
+
/* read all selected strokes */
bool first = false;
CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
@@ -1918,7 +1919,7 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op)
bGPDframe *gpf = gpl->actframe;
if (gpf == NULL)
continue;
-
+
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
if (gps->flag & GP_STROKE_SELECT) {
@@ -1930,10 +1931,10 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op)
if (ED_gpencil_stroke_color_use(gpl, gps) == false) {
continue;
}
-
+
/* to join strokes, cyclic must be disabled */
gps->flag &= ~GP_STROKE_CYCLIC;
-
+
/* saves first frame and stroke */
if (!first) {
first = true;
@@ -1942,7 +1943,7 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op)
}
else {
stroke_b = gps;
-
+
/* create a new stroke if was not created before (only created if something to join) */
if (new_stroke == NULL) {
new_stroke = MEM_dupallocN(stroke_a);
@@ -1950,7 +1951,7 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op)
new_stroke->triangles = NULL;
new_stroke->tot_triangles = 0;
new_stroke->flag |= GP_STROKE_RECALC_CACHES;
-
+
/* if new, set current color */
if (type == GP_STROKE_JOINCOPY) {
new_stroke->palcolor = palcolor;
@@ -1958,10 +1959,10 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op)
new_stroke->flag |= GP_STROKE_RECALC_COLOR;
}
}
-
+
/* join new_stroke and stroke B. New stroke will contain all the previous data */
gpencil_stroke_join_strokes(new_stroke, stroke_b, leave_gaps);
-
+
/* if join only, delete old strokes */
if (type == GP_STROKE_JOIN) {
if (stroke_a) {
@@ -1981,21 +1982,21 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_END;
-
+
/* add new stroke if was not added before */
if (type == GP_STROKE_JOINCOPY) {
if (new_stroke) {
/* Add a new frame if needed */
if (activegpl->actframe == NULL)
activegpl->actframe = BKE_gpencil_frame_addnew(activegpl, gpf_a->framenum);
-
+
BLI_addtail(&activegpl->actframe->strokes, new_stroke);
}
}
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -2006,19 +2007,19 @@ void GPENCIL_OT_stroke_join(wmOperatorType *ot)
{GP_STROKE_JOINCOPY, "JOINCOPY", 0, "Join and Copy", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "Join Strokes";
ot->idname = "GPENCIL_OT_stroke_join";
ot->description = "Join selected strokes (optionally as new stroke)";
-
+
/* api callbacks */
ot->exec = gp_stroke_join_exec;
ot->poll = gp_active_layer_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", join_type, GP_STROKE_JOIN, "Type", "");
RNA_def_boolean(ot->srna, "leave_gaps", false, "Leave Gaps", "Leave gaps between joined strokes instead of linking them");
@@ -2040,7 +2041,7 @@ static int gp_stroke_flip_exec(bContext *C, wmOperator *UNUSED(op))
bGPDframe *gpf = gpl->actframe;
if (gpf == NULL)
continue;
-
+
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
if (gps->flag & GP_STROKE_SELECT) {
/* skip strokes that are invalid for current view */
@@ -2051,17 +2052,17 @@ static int gp_stroke_flip_exec(bContext *C, wmOperator *UNUSED(op))
if (ED_gpencil_stroke_color_use(gpl, gps) == false) {
continue;
}
-
+
/* flip stroke */
gpencil_flip_stroke(gps);
}
}
}
CTX_DATA_END;
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -2071,11 +2072,11 @@ void GPENCIL_OT_stroke_flip(wmOperatorType *ot)
ot->name = "Flip Stroke";
ot->idname = "GPENCIL_OT_stroke_flip";
ot->description = "Change direction of the points of the selected strokes";
-
+
/* api callbacks */
ot->exec = gp_stroke_flip_exec;
ot->poll = gp_active_layer_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2103,19 +2104,19 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
GP_SpaceConversion gsc = {NULL};
eGP_ReprojectModes mode = RNA_boolean_get(op->ptr, "type");
-
+
/* init space conversion stuff */
gp_point_conversion_init(C, &gsc);
-
+
/* init autodist for geometry projection */
if (mode == GP_REPROJECT_SURFACE) {
- struct Depsgraph *graph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
view3d_region_operator_needs_opengl(CTX_wm_window(C), gsc.ar);
- ED_view3d_autodist_init(graph, gsc.ar, CTX_wm_view3d(C), 0);
+ ED_view3d_autodist_init(depsgraph, gsc.ar, CTX_wm_view3d(C), 0);
}
-
+
// TODO: For deforming geometry workflow, create new frames?
-
+
/* Go through each editable + selected stroke, adjusting each of its points one by one... */
GP_EDITABLE_STROKES_BEGIN(C, gpl, gps)
{
@@ -2123,17 +2124,17 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
bGPDspoint *pt;
int i;
float inverse_diff_mat[4][4];
-
+
/* Compute inverse matrix for unapplying parenting once instead of doing per-point */
/* TODO: add this bit to the iteration macro? */
if (gpl->parent) {
invert_m4_m4(inverse_diff_mat, diff_mat);
}
-
+
/* Adjust each point */
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
float xy[2];
-
+
/* 3D to Screenspace */
/* Note: We can't use gp_point_to_xy() here because that uses ints for the screenspace
* coordinates, resulting in lost precision, which in turn causes stairstepping
@@ -2147,7 +2148,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
gp_point_to_parent_space(pt, diff_mat, &pt2);
gp_point_to_xy_fl(&gsc, gps, &pt2, &xy[0], &xy[1]);
}
-
+
/* Project screenspace back to 3D space (from current perspective)
* so that all points have been treated the same way
*/
@@ -2159,10 +2160,10 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
/* Geometry - Snap to surfaces of visible geometry */
/* XXX: There will be precision loss (possible stairstep artifacts) from this conversion to satisfy the API's */
const int screen_co[2] = {(int)xy[0], (int)xy[1]};
-
+
int depth_margin = 0; // XXX: 4 for strokes, 0 for normal
float depth;
-
+
/* XXX: The proper procedure computes the depths into an array, to have smooth transitions when all else fails... */
if (ED_view3d_autodist_depth(gsc.ar, screen_co, depth_margin, &depth)) {
ED_view3d_autodist_simple(gsc.ar, screen_co, &pt->x, 0, &depth);
@@ -2172,7 +2173,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
gp_point_xy_to_3d(&gsc, scene, xy, &pt->x);
}
}
-
+
/* Unapply parent corrections */
if (gpl->parent) {
mul_m4_v3(inverse_diff_mat, &pt->x);
@@ -2181,7 +2182,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
}
}
GP_EDITABLE_STROKES_END;
-
+
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
@@ -2189,29 +2190,29 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
void GPENCIL_OT_reproject(wmOperatorType *ot)
{
static const EnumPropertyItem reproject_type[] = {
- {GP_REPROJECT_PLANAR, "PLANAR", 0, "Planar",
+ {GP_REPROJECT_PLANAR, "PLANAR", 0, "Planar",
"Reproject the strokes to end up on the same plane, as if drawn from the current viewpoint "
"using 'Cursor' Stroke Placement"},
{GP_REPROJECT_SURFACE, "SURFACE", 0, "Surface",
"Reproject the strokes on to the scene geometry, as if drawn using 'Surface' placement"},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "Reproject Strokes";
ot->idname = "GPENCIL_OT_reproject";
ot->description = "Reproject the selected strokes from the current viewpoint as if they had been newly drawn "
"(e.g. to fix problems from accidental 3D cursor movement or accidental viewport changes, "
"or for matching deforming geometry)";
-
+
/* callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = gp_strokes_reproject_exec;
ot->poll = gp_strokes_reproject_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", reproject_type, GP_REPROJECT_PLANAR, "Projection Type", "");
}
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index 04bcea02c9b..33af6cab915 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index 83e2a85db49..ff3f5b20858 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -89,18 +89,18 @@ static int gpencil_view3d_poll(bContext *C)
{
bGPdata *gpd = CTX_data_gpencil_data(C);
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
-
+
/* only 3D view */
ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype != SPACE_VIEW3D) {
return 0;
}
-
+
/* need data to interpolate */
if (ELEM(NULL, gpd, gpl)) {
return 0;
}
-
+
return 1;
}
@@ -108,13 +108,13 @@ static int gpencil_view3d_poll(bContext *C)
static void gp_interpolate_update_points(bGPDstroke *gps_from, bGPDstroke *gps_to, bGPDstroke *new_stroke, float factor)
{
bGPDspoint *prev, *pt, *next;
-
+
/* update points */
for (int i = 0; i < new_stroke->totpoints; i++) {
prev = &gps_from->points[i];
pt = &new_stroke->points[i];
next = &gps_to->points[i];
-
+
/* Interpolate all values */
interp_v3_v3v3(&pt->x, &prev->x, &next->x, factor);
pt->pressure = interpf(prev->pressure, next->pressure, 1.0f - factor);
@@ -130,32 +130,32 @@ static void gp_interpolate_update_strokes(bContext *C, tGPDinterpolate *tgpi)
{
tGPDinterpolate_layer *tgpil;
const float shift = tgpi->shift;
-
+
for (tgpil = tgpi->ilayers.first; tgpil; tgpil = tgpil->next) {
bGPDstroke *new_stroke;
const float factor = tgpil->factor + shift;
-
+
for (new_stroke = tgpil->interFrame->strokes.first; new_stroke; new_stroke = new_stroke->next) {
bGPDstroke *gps_from, *gps_to;
int stroke_idx;
-
+
if (new_stroke->totpoints == 0) {
continue;
}
-
+
/* get strokes to interpolate */
stroke_idx = BLI_findindex(&tgpil->interFrame->strokes, new_stroke);
-
+
gps_from = BLI_findlink(&tgpil->prevFrame->strokes, stroke_idx);
gps_to = BLI_findlink(&tgpil->nextFrame->strokes, stroke_idx);
-
+
/* update points position */
if ((gps_from) && (gps_to)) {
gp_interpolate_update_points(gps_from, gps_to, new_stroke, factor);
}
}
}
-
+
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
}
@@ -164,7 +164,7 @@ static bool gp_interpolate_check_todo(bContext *C, bGPdata *gpd)
{
ToolSettings *ts = CTX_data_tool_settings(C);
eGP_Interpolate_SettingsFlag flag = ts->gp_interpolate.flag;
-
+
/* get layers */
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* all layers or only active */
@@ -175,12 +175,12 @@ static bool gp_interpolate_check_todo(bContext *C, bGPdata *gpd)
if (!gpencil_layer_is_editable(gpl) || (gpl->actframe == NULL)) {
continue;
}
-
+
/* read strokes */
for (bGPDstroke *gps_from = gpl->actframe->strokes.first; gps_from; gps_from = gps_from->next) {
bGPDstroke *gps_to;
int fFrame;
-
+
/* only selected */
if ((flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
continue;
@@ -193,14 +193,14 @@ static bool gp_interpolate_check_todo(bContext *C, bGPdata *gpd)
if (ED_gpencil_stroke_color_use(gpl, gps_from) == false) {
continue;
}
-
+
/* get final stroke to interpolate */
fFrame = BLI_findindex(&gpl->actframe->strokes, gps_from);
gps_to = BLI_findlink(&gpl->actframe->next->strokes, fFrame);
if (gps_to == NULL) {
continue;
}
-
+
return true;
}
}
@@ -213,18 +213,18 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
bGPdata *gpd = tgpi->gpd;
bGPDlayer *active_gpl = CTX_data_active_gpencil_layer(C);
bGPDframe *actframe = active_gpl->actframe;
-
+
/* save initial factor for active layer to define shift limits */
tgpi->init_factor = (float)(tgpi->cframe - actframe->framenum) / (actframe->next->framenum - actframe->framenum + 1);
-
+
/* limits are 100% below 0 and 100% over the 100% */
tgpi->low_limit = -1.0f - tgpi->init_factor;
tgpi->high_limit = 2.0f - tgpi->init_factor;
-
+
/* set layers */
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
tGPDinterpolate_layer *tgpil;
-
+
/* all layers or only active */
if (!(tgpi->flag & GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS) && (gpl != active_gpl)) {
continue;
@@ -233,32 +233,32 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
if (!gpencil_layer_is_editable(gpl) || (gpl->actframe == NULL)) {
continue;
}
-
+
/* create temp data for each layer */
tgpil = MEM_callocN(sizeof(tGPDinterpolate_layer), "GPencil Interpolate Layer");
-
+
tgpil->gpl = gpl;
tgpil->prevFrame = gpl->actframe;
tgpil->nextFrame = gpl->actframe->next;
-
+
BLI_addtail(&tgpi->ilayers, tgpil);
-
+
/* create a new temporary frame */
tgpil->interFrame = MEM_callocN(sizeof(bGPDframe), "bGPDframe");
tgpil->interFrame->framenum = tgpi->cframe;
-
+
/* get interpolation factor by layer (usually must be equal for all layers, but not sure) */
tgpil->factor = (float)(tgpi->cframe - tgpil->prevFrame->framenum) / (tgpil->nextFrame->framenum - tgpil->prevFrame->framenum + 1);
-
+
/* create new strokes data with interpolated points reading original stroke */
for (bGPDstroke *gps_from = tgpil->prevFrame->strokes.first; gps_from; gps_from = gps_from->next) {
bGPDstroke *gps_to;
int fFrame;
-
+
bGPDstroke *new_stroke;
bool valid = true;
-
-
+
+
/* only selected */
if ((tgpi->flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
valid = false;
@@ -267,19 +267,19 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
if (ED_gpencil_stroke_can_use(C, gps_from) == false) {
valid = false;
}
-
+
/* check if the color is editable */
if (ED_gpencil_stroke_color_use(tgpil->gpl, gps_from) == false) {
valid = false;
}
-
+
/* get final stroke to interpolate */
fFrame = BLI_findindex(&tgpil->prevFrame->strokes, gps_from);
gps_to = BLI_findlink(&tgpil->nextFrame->strokes, fFrame);
if (gps_to == NULL) {
valid = false;
}
-
+
/* create new stroke */
new_stroke = MEM_dupallocN(gps_from);
new_stroke->points = MEM_dupallocN(gps_from->points);
@@ -306,7 +306,7 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
new_stroke->triangles = MEM_recallocN(new_stroke->triangles, sizeof(*new_stroke->triangles));
new_stroke->flag |= GP_STROKE_RECALC_CACHES;
}
-
+
/* add to strokes */
BLI_addtail(&tgpil->interFrame->strokes, new_stroke);
}
@@ -339,14 +339,14 @@ static void gpencil_mouse_update_shift(tGPDinterpolate *tgpi, wmOperator *op, co
{
float mid = (float)(tgpi->ar->winx - tgpi->ar->winrct.xmin) / 2.0f;
float mpos = event->x - tgpi->ar->winrct.xmin;
-
+
if (mpos >= mid) {
tgpi->shift = ((mpos - mid) * tgpi->high_limit) / mid;
}
else {
tgpi->shift = tgpi->low_limit - ((mpos * tgpi->low_limit) / mid);
}
-
+
CLAMP(tgpi->shift, tgpi->low_limit, tgpi->high_limit);
RNA_float_set(op->ptr, "shift", tgpi->shift);
}
@@ -357,19 +357,19 @@ static void gpencil_interpolate_status_indicators(tGPDinterpolate *p)
Scene *scene = p->scene;
char status_str[UI_MAX_DRAW_STR];
char msg_str[UI_MAX_DRAW_STR];
-
+
BLI_strncpy(msg_str, IFACE_("GPencil Interpolation: ESC/RMB to cancel, Enter/LMB to confirm, WHEEL/MOVE to adjust factor"), UI_MAX_DRAW_STR);
-
+
if (hasNumInput(&p->num)) {
char str_offs[NUM_STR_REP_LEN];
-
+
outputNumInput(&p->num, str_offs, &scene->unit);
BLI_snprintf(status_str, sizeof(status_str), "%s: %s", msg_str, str_offs);
}
else {
BLI_snprintf(status_str, sizeof(status_str), "%s: %d %%", msg_str, (int)((p->init_factor + p->shift) * 100.0f));
}
-
+
ED_area_headerprint(p->sa, status_str);
}
@@ -391,7 +391,7 @@ static void gpencil_interpolate_exit(bContext *C, wmOperator *op)
{
tGPDinterpolate *tgpi = op->customdata;
tGPDinterpolate_layer *tgpil;
-
+
/* don't assume that operator data exists at all */
if (tgpi) {
/* remove drawing handler */
@@ -401,21 +401,21 @@ static void gpencil_interpolate_exit(bContext *C, wmOperator *op)
if (tgpi->draw_handle_3d) {
ED_region_draw_cb_exit(tgpi->ar->type, tgpi->draw_handle_3d);
}
-
+
/* clear status message area */
ED_area_headerprint(tgpi->sa, NULL);
-
+
/* finally, free memory used by temp data */
for (tgpil = tgpi->ilayers.first; tgpil; tgpil = tgpil->next) {
BKE_gpencil_free_strokes(tgpil->interFrame);
MEM_freeN(tgpil->interFrame);
}
-
+
BLI_freelistN(&tgpi->ilayers);
MEM_freeN(tgpi);
}
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
-
+
/* clear pointer */
op->customdata = NULL;
}
@@ -425,24 +425,24 @@ static bool gp_interpolate_set_init_values(bContext *C, wmOperator *op, tGPDinte
{
ToolSettings *ts = CTX_data_tool_settings(C);
bGPdata *gpd = CTX_data_gpencil_data(C);
-
+
/* set current scene and window */
tgpi->scene = CTX_data_scene(C);
tgpi->sa = CTX_wm_area(C);
tgpi->ar = CTX_wm_region(C);
tgpi->flag = ts->gp_interpolate.flag;
-
+
/* set current frame number */
tgpi->cframe = tgpi->scene->r.cfra;
-
+
/* set GP datablock */
tgpi->gpd = gpd;
-
+
/* set interpolation weight */
tgpi->shift = RNA_float_get(op->ptr, "shift");
/* set layers */
gp_interpolate_set_points(C, tgpi);
-
+
return 1;
}
@@ -450,10 +450,10 @@ static bool gp_interpolate_set_init_values(bContext *C, wmOperator *op, tGPDinte
static tGPDinterpolate *gp_session_init_interpolation(bContext *C, wmOperator *op)
{
tGPDinterpolate *tgpi = MEM_callocN(sizeof(tGPDinterpolate), "GPencil Interpolate Data");
-
+
/* define initial values */
gp_interpolate_set_init_values(C, op, tgpi);
-
+
/* return context data for running operator */
return tgpi;
}
@@ -462,7 +462,7 @@ static tGPDinterpolate *gp_session_init_interpolation(bContext *C, wmOperator *o
static int gpencil_interpolate_init(bContext *C, wmOperator *op)
{
tGPDinterpolate *tgpi;
-
+
/* check context */
tgpi = op->customdata = gp_session_init_interpolation(C, op);
if (tgpi == NULL) {
@@ -470,7 +470,7 @@ static int gpencil_interpolate_init(bContext *C, wmOperator *op)
gpencil_interpolate_exit(C, op);
return 0;
}
-
+
/* everything is now setup ok */
return 1;
}
@@ -492,19 +492,19 @@ static int gpencil_interpolate_invoke(bContext *C, wmOperator *op, const wmEvent
BKE_report(op->reports, RPT_ERROR, "Cannot find a pair of grease pencil frames to interpolate between in active layer");
return OPERATOR_CANCELLED;
}
-
+
/* cannot interpolate in extremes */
if (ELEM(CFRA, actframe->framenum, actframe->next->framenum)) {
BKE_report(op->reports, RPT_ERROR, "Cannot interpolate as current frame already has existing grease pencil frames");
return OPERATOR_CANCELLED;
}
-
+
/* need editable strokes */
if (!gp_interpolate_check_todo(C, gpd)) {
BKE_report(op->reports, RPT_ERROR, "Interpolation requires some editable strokes");
return OPERATOR_CANCELLED;
}
-
+
/* try to initialize context data needed */
if (!gpencil_interpolate_init(C, op)) {
if (op->customdata)
@@ -514,24 +514,24 @@ static int gpencil_interpolate_invoke(bContext *C, wmOperator *op, const wmEvent
else {
tgpi = op->customdata;
}
-
+
/* Enable custom drawing handlers
- * It needs 2 handlers because strokes can in 3d space and screen space
- * and each handler use different coord system
+ * It needs 2 handlers because strokes can in 3d space and screen space
+ * and each handler use different coord system
*/
tgpi->draw_handle_screen = ED_region_draw_cb_activate(tgpi->ar->type, gpencil_interpolate_draw_screen, tgpi, REGION_DRAW_POST_PIXEL);
tgpi->draw_handle_3d = ED_region_draw_cb_activate(tgpi->ar->type, gpencil_interpolate_draw_3d, tgpi, REGION_DRAW_POST_VIEW);
-
+
/* set cursor to indicate modal */
WM_cursor_modal_set(win, BC_EW_SCROLLCURSOR);
-
+
/* update shift indicator in header */
gpencil_interpolate_status_indicators(tgpi);
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
-
+
/* add a modal handler for this operator */
WM_event_add_modal_handler(C, op);
-
+
return OPERATOR_RUNNING_MODAL;
}
@@ -544,7 +544,7 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent
bGPDstroke *gps_src, *gps_dst;
tGPDinterpolate_layer *tgpil;
const bool has_numinput = hasNumInput(&tgpi->num);
-
+
switch (event->type) {
case LEFTMOUSE: /* confirm */
case RETKEY:
@@ -552,19 +552,19 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent
/* return to normal cursor and header status */
ED_area_headerprint(tgpi->sa, NULL);
WM_cursor_modal_restore(win);
-
+
/* insert keyframes as required... */
for (tgpil = tgpi->ilayers.first; tgpil; tgpil = tgpil->next) {
gpf_dst = BKE_gpencil_layer_getframe(tgpil->gpl, tgpi->cframe, GP_GETFRAME_ADD_NEW);
gpf_dst->key_type = BEZT_KEYTYPE_BREAKDOWN;
-
+
/* copy strokes */
BLI_listbase_clear(&gpf_dst->strokes);
for (gps_src = tgpil->interFrame->strokes.first; gps_src; gps_src = gps_src->next) {
if (gps_src->totpoints == 0) {
continue;
}
-
+
/* make copy of source stroke, then adjust pointer to points too */
gps_dst = MEM_dupallocN(gps_src);
gps_dst->points = MEM_dupallocN(gps_src->points);
@@ -573,34 +573,34 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent
BLI_addtail(&gpf_dst->strokes, gps_dst);
}
}
-
+
/* clean up temp data */
gpencil_interpolate_exit(C, op);
-
+
/* done! */
return OPERATOR_FINISHED;
}
-
+
case ESCKEY: /* cancel */
case RIGHTMOUSE:
{
/* return to normal cursor and header status */
ED_area_headerprint(tgpi->sa, NULL);
WM_cursor_modal_restore(win);
-
+
/* clean up temp data */
gpencil_interpolate_exit(C, op);
-
+
/* canceled! */
return OPERATOR_CANCELLED;
}
-
+
case WHEELUPMOUSE:
{
tgpi->shift = tgpi->shift + 0.01f;
CLAMP(tgpi->shift, tgpi->low_limit, tgpi->high_limit);
RNA_float_set(op->ptr, "shift", tgpi->shift);
-
+
/* update screen */
gpencil_interpolate_update(C, op, tgpi);
break;
@@ -610,7 +610,7 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent
tgpi->shift = tgpi->shift - 0.01f;
CLAMP(tgpi->shift, tgpi->low_limit, tgpi->high_limit);
RNA_float_set(op->ptr, "shift", tgpi->shift);
-
+
/* update screen */
gpencil_interpolate_update(C, op, tgpi);
break;
@@ -621,7 +621,7 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent
if (has_numinput == false) {
/* update shift based on position of mouse */
gpencil_mouse_update_shift(tgpi, op, event);
-
+
/* update screen */
gpencil_interpolate_update(C, op, tgpi);
}
@@ -632,21 +632,21 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent
if ((event->val == KM_PRESS) && handleNumInput(C, &tgpi->num, event)) {
const float factor = tgpi->init_factor;
float value;
-
+
/* Grab shift from numeric input, and store this new value (the user see an int) */
value = (factor + tgpi->shift) * 100.0f;
applyNumInput(&tgpi->num, &value);
tgpi->shift = value / 100.0f;
-
+
/* recalculate the shift to get the right value in the frame scale */
tgpi->shift = tgpi->shift - factor;
-
+
CLAMP(tgpi->shift, tgpi->low_limit, tgpi->high_limit);
RNA_float_set(op->ptr, "shift", tgpi->shift);
-
+
/* update screen */
gpencil_interpolate_update(C, op, tgpi);
-
+
break;
}
else {
@@ -655,7 +655,7 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent
}
}
}
-
+
/* still running... */
return OPERATOR_RUNNING_MODAL;
}
@@ -673,16 +673,16 @@ void GPENCIL_OT_interpolate(wmOperatorType *ot)
ot->name = "Grease Pencil Interpolation";
ot->idname = "GPENCIL_OT_interpolate";
ot->description = "Interpolate grease pencil strokes between frames";
-
+
/* callbacks */
ot->invoke = gpencil_interpolate_invoke;
ot->modal = gpencil_interpolate_modal;
ot->cancel = gpencil_interpolate_cancel;
ot->poll = gpencil_view3d_poll;
-
+
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING;
-
+
/* properties */
RNA_def_float_percentage(ot->srna, "shift", 0.0f, -1.0f, 1.0f, "Shift", "Bias factor for which frame has more influence on the interpolated strokes", -0.9f, 0.9f);
}
@@ -695,14 +695,14 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting
const float begin = 0.0f;
const float change = 1.0f;
const float duration = 1.0f;
-
+
const float back = ipo_settings->back;
const float amplitude = ipo_settings->amplitude;
const float period = ipo_settings->period;
-
+
eBezTriple_Easing easing = ipo_settings->easing;
float result = time;
-
+
switch (ipo_settings->type) {
case GP_IPO_BACK:
switch (easing) {
@@ -715,7 +715,7 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting
case BEZT_IPO_EASE_IN_OUT:
result = BLI_easing_back_ease_in_out(time, begin, change, duration, back);
break;
-
+
default: /* default/auto: same as ease out */
result = BLI_easing_back_ease_out(time, begin, change, duration, back);
break;
@@ -733,13 +733,13 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting
case BEZT_IPO_EASE_IN_OUT:
result = BLI_easing_bounce_ease_in_out(time, begin, change, duration);
break;
-
+
default: /* default/auto: same as ease out */
result = BLI_easing_bounce_ease_out(time, begin, change, duration);
break;
}
break;
-
+
case GP_IPO_CIRC:
switch (easing) {
case BEZT_IPO_EASE_IN:
@@ -751,7 +751,7 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting
case BEZT_IPO_EASE_IN_OUT:
result = BLI_easing_circ_ease_in_out(time, begin, change, duration);
break;
-
+
default: /* default/auto: same as ease in */
result = BLI_easing_circ_ease_in(time, begin, change, duration);
break;
@@ -769,13 +769,13 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting
case BEZT_IPO_EASE_IN_OUT:
result = BLI_easing_cubic_ease_in_out(time, begin, change, duration);
break;
-
+
default: /* default/auto: same as ease in */
result = BLI_easing_cubic_ease_in(time, begin, change, duration);
break;
}
break;
-
+
case GP_IPO_ELASTIC:
switch (easing) {
case BEZT_IPO_EASE_IN:
@@ -787,13 +787,13 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting
case BEZT_IPO_EASE_IN_OUT:
result = BLI_easing_elastic_ease_in_out(time, begin, change, duration, amplitude, period);
break;
-
+
default: /* default/auto: same as ease out */
result = BLI_easing_elastic_ease_out(time, begin, change, duration, amplitude, period);
break;
}
break;
-
+
case GP_IPO_EXPO:
switch (easing) {
case BEZT_IPO_EASE_IN:
@@ -805,13 +805,13 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting
case BEZT_IPO_EASE_IN_OUT:
result = BLI_easing_expo_ease_in_out(time, begin, change, duration);
break;
-
+
default: /* default/auto: same as ease in */
result = BLI_easing_expo_ease_in(time, begin, change, duration);
break;
}
break;
-
+
case GP_IPO_QUAD:
switch (easing) {
case BEZT_IPO_EASE_IN:
@@ -823,13 +823,13 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting
case BEZT_IPO_EASE_IN_OUT:
result = BLI_easing_quad_ease_in_out(time, begin, change, duration);
break;
-
+
default: /* default/auto: same as ease in */
result = BLI_easing_quad_ease_in(time, begin, change, duration);
break;
}
break;
-
+
case GP_IPO_QUART:
switch (easing) {
case BEZT_IPO_EASE_IN:
@@ -841,13 +841,13 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting
case BEZT_IPO_EASE_IN_OUT:
result = BLI_easing_quart_ease_in_out(time, begin, change, duration);
break;
-
+
default: /* default/auto: same as ease in */
result = BLI_easing_quart_ease_in(time, begin, change, duration);
break;
}
break;
-
+
case GP_IPO_QUINT:
switch (easing) {
case BEZT_IPO_EASE_IN:
@@ -859,13 +859,13 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting
case BEZT_IPO_EASE_IN_OUT:
result = BLI_easing_quint_ease_in_out(time, begin, change, duration);
break;
-
+
default: /* default/auto: same as ease in */
result = BLI_easing_quint_ease_in(time, begin, change, duration);
break;
}
break;
-
+
case GP_IPO_SINE:
switch (easing) {
case BEZT_IPO_EASE_IN:
@@ -877,18 +877,18 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting
case BEZT_IPO_EASE_IN_OUT:
result = BLI_easing_sine_ease_in_out(time, begin, change, duration);
break;
-
+
default: /* default/auto: same as ease in */
result = BLI_easing_sine_ease_in(time, begin, change, duration);
break;
}
break;
-
+
default:
printf("%s: Unknown interpolation type - %d\n", __func__, ipo_settings->type);
break;
}
-
+
return result;
}
@@ -897,12 +897,12 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
bGPdata *gpd = CTX_data_gpencil_data(C);
bGPDlayer *active_gpl = CTX_data_active_gpencil_layer(C);
bGPDframe *actframe = active_gpl->actframe;
-
+
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = CTX_data_tool_settings(C);
GP_Interpolate_Settings *ipo_settings = &ts->gp_interpolate;
eGP_Interpolate_SettingsFlag flag = ipo_settings->flag;
-
+
/* cannot interpolate if not between 2 frames */
if (ELEM(NULL, actframe, actframe->next)) {
BKE_report(op->reports, RPT_ERROR, "Cannot find a pair of grease pencil frames to interpolate between in active layer");
@@ -913,13 +913,13 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Cannot interpolate as current frame already has existing grease pencil frames");
return OPERATOR_CANCELLED;
}
-
+
/* loop all layer to check if need interpolation */
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
bGPDframe *prevFrame, *nextFrame;
bGPDstroke *gps_from, *gps_to;
int cframe, fFrame;
-
+
/* all layers or only active */
if (((flag & GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS) == 0) && (gpl != active_gpl)) {
continue;
@@ -928,19 +928,19 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
if (!gpencil_layer_is_editable(gpl) || (gpl->actframe == NULL)) {
continue;
}
-
+
/* store extremes */
prevFrame = gpl->actframe;
nextFrame = gpl->actframe->next;
-
+
/* Loop over intermediary frames and create the interpolation */
for (cframe = prevFrame->framenum + 1; cframe < nextFrame->framenum; cframe++) {
bGPDframe *interFrame = NULL;
float factor;
-
+
/* get interpolation factor */
factor = (float)(cframe - prevFrame->framenum) / (nextFrame->framenum - prevFrame->framenum + 1);
-
+
if (ipo_settings->type == GP_IPO_CURVEMAP) {
/* custom curvemap */
if (ipo_settings->custom_ipo) {
@@ -954,11 +954,11 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
/* easing equation... */
factor = gp_interpolate_seq_easing_calc(ipo_settings, factor);
}
-
+
/* create new strokes data with interpolated points reading original stroke */
for (gps_from = prevFrame->strokes.first; gps_from; gps_from = gps_from->next) {
bGPDstroke *new_stroke;
-
+
/* only selected */
if ((flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
continue;
@@ -971,20 +971,20 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
if (ED_gpencil_stroke_color_use(gpl, gps_from) == false) {
continue;
}
-
+
/* get final stroke to interpolate */
fFrame = BLI_findindex(&prevFrame->strokes, gps_from);
gps_to = BLI_findlink(&nextFrame->strokes, fFrame);
if (gps_to == NULL) {
continue;
}
-
+
/* create a new frame if needed */
if (interFrame == NULL) {
interFrame = BKE_gpencil_layer_getframe(gpl, cframe, GP_GETFRAME_ADD_NEW);
interFrame->key_type = BEZT_KEYTYPE_BREAKDOWN;
}
-
+
/* create new stroke */
new_stroke = MEM_dupallocN(gps_from);
new_stroke->points = MEM_dupallocN(gps_from->points);
@@ -999,19 +999,19 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
new_stroke->tot_triangles = 0;
new_stroke->flag |= GP_STROKE_RECALC_CACHES;
}
-
+
/* update points position */
gp_interpolate_update_points(gps_from, gps_to, new_stroke, factor);
-
+
/* add to strokes */
BLI_addtail(&interFrame->strokes, new_stroke);
}
}
}
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1021,11 +1021,11 @@ void GPENCIL_OT_interpolate_sequence(wmOperatorType *ot)
ot->name = "Interpolate Sequence";
ot->idname = "GPENCIL_OT_interpolate_sequence";
ot->description = "Generate 'in-betweens' to smoothly interpolate between Grease Pencil frames";
-
+
/* api callbacks */
ot->exec = gpencil_interpolate_seq_exec;
ot->poll = gpencil_view3d_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1045,7 +1045,7 @@ static int gpencil_interpolate_reverse_poll(bContext *C)
CTX_wm_operator_poll_msg_set(C, "Expected current frame to be a breakdown");
return 0;
}
-
+
return 1;
}
@@ -1059,11 +1059,11 @@ static int gpencil_interpolate_reverse_exec(bContext *C, wmOperator *UNUSED(op))
bGPDframe *start_key = NULL;
bGPDframe *end_key = NULL;
bGPDframe *gpf, *gpfn;
-
+
/* Only continue if we're currently on a breakdown keyframe */
if ((gpl->actframe == NULL) || (gpl->actframe->key_type != BEZT_KEYTYPE_BREAKDOWN))
continue;
-
+
/* Search left for "start_key" (i.e. the first breakdown to remove) */
gpf = gpl->actframe;
while (gpf) {
@@ -1077,7 +1077,7 @@ static int gpencil_interpolate_reverse_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
-
+
/* Search right for "end_key" (i.e. the last breakdown to remove) */
gpf = gpl->actframe;
while (gpf) {
@@ -1091,36 +1091,36 @@ static int gpencil_interpolate_reverse_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
-
+
/* Did we find anything? */
/* NOTE: We should only proceed if there's something before/after these extents...
* Otherwise, there's just an extent of breakdowns with no keys to interpolate between
*/
- if ((start_key && end_key) &&
+ if ((start_key && end_key) &&
ELEM(NULL, start_key->prev, end_key->next) == false)
{
/* Set actframe to the key before start_key, since the keys have been removed now */
gpl->actframe = start_key->prev;
-
+
/* Free each frame we're removing (except the last one) */
for (gpf = start_key; gpf && gpf != end_key; gpf = gpfn) {
gpfn = gpf->next;
-
+
/* free strokes and their associated memory */
BKE_gpencil_free_strokes(gpf);
BLI_freelinkN(&gpl->frames, gpf);
}
-
+
/* Now free the last one... */
BKE_gpencil_free_strokes(end_key);
BLI_freelinkN(&gpl->frames, end_key);
}
}
CTX_DATA_END;
-
+
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1130,11 +1130,11 @@ void GPENCIL_OT_interpolate_reverse(wmOperatorType *ot)
ot->name = "Remove Breakdowns";
ot->idname = "GPENCIL_OT_interpolate_reverse";
ot->description = "Remove breakdown frames generated by interpolating between two Grease Pencil frames";
-
+
/* callbacks */
ot->exec = gpencil_interpolate_reverse_exec;
ot->poll = gpencil_interpolate_reverse_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index 3a2169798e5..cb6ccc8d8ef 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -57,28 +57,28 @@ static void ed_keymap_gpencil_general(wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_find(keyconf, "Grease Pencil", 0, 0);
wmKeyMapItem *kmi;
-
+
/* Draw --------------------------------------- */
/* draw */
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, 0, DKEY);
RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW);
RNA_boolean_set(kmi->ptr, "wait_for_input", false);
-
+
/* draw - straight lines */
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, KM_CTRL, DKEY);
RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_STRAIGHT);
RNA_boolean_set(kmi->ptr, "wait_for_input", false);
-
+
/* draw - poly lines */
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, KM_CTRL, DKEY);
RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_POLY);
RNA_boolean_set(kmi->ptr, "wait_for_input", false);
-
+
/* erase */
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, 0, DKEY);
RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER);
RNA_boolean_set(kmi->ptr, "wait_for_input", false);
-
+
/* Tablet Mappings for Drawing ------------------ */
/* For now, only support direct drawing using the eraser, as most users using a tablet
* may still want to use that as their primary pointing device!
@@ -88,24 +88,24 @@ static void ed_keymap_gpencil_general(wmKeyConfig *keyconf)
RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW);
RNA_boolean_set(kmi->ptr, "wait_for_input", false);
#endif
-
+
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", TABLET_ERASER, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER);
RNA_boolean_set(kmi->ptr, "wait_for_input", false);
-
+
/* Viewport Tools ------------------------------- */
-
+
/* Enter EditMode */
WM_keymap_add_item(keymap, "GPENCIL_OT_editmode_toggle", TABKEY, KM_PRESS, 0, DKEY);
-
+
/* Pie Menu - For standard tools */
WM_keymap_add_menu_pie(keymap, "GPENCIL_MT_pie_tool_palette", QKEY, KM_PRESS, 0, DKEY);
WM_keymap_add_menu_pie(keymap, "GPENCIL_MT_pie_settings_palette", WKEY, KM_PRESS, 0, DKEY);
-
+
/* Add Blank Frame */
/* XXX: BKEY or NKEY? BKEY is easier to reach from DKEY, so we'll use that for now */
WM_keymap_add_item(keymap, "GPENCIL_OT_blank_frame_add", BKEY, KM_PRESS, 0, DKEY);
-
+
/* Delete Active Frame - For easier video tutorials/review sessions */
/* NOTE: This works even when not in EditMode */
WM_keymap_add_item(keymap, "GPENCIL_OT_active_frames_delete_all", XKEY, KM_PRESS, 0, DKEY);
@@ -125,81 +125,81 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_find(keyconf, "Grease Pencil Stroke Edit Mode", 0, 0);
wmKeyMapItem *kmi;
-
+
/* set poll callback - so that this keymap only gets enabled when stroke editmode is enabled */
keymap->poll = gp_stroke_editmode_poll;
-
+
/* ----------------------------------------------- */
-
+
/* Exit EditMode */
WM_keymap_add_item(keymap, "GPENCIL_OT_editmode_toggle", TABKEY, KM_PRESS, 0, 0);
-
+
/* Pie Menu - For settings/tools easy access */
WM_keymap_add_menu_pie(keymap, "GPENCIL_MT_pie_sculpt", EKEY, KM_PRESS, 0, DKEY);
-
+
/* Brush Settings */
/* NOTE: We cannot expose these in the standard keymap, as they will interfere with regular hotkeys
* in other modes. However, when we are dealing with Stroke Edit Mode, we know for certain
* that the only data being edited is that of the Grease Pencil strokes
*/
-
+
/* CTRL + FKEY = Eraser Radius */
kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0);
RNA_string_set(kmi->ptr, "data_path_primary", "user_preferences.edit.grease_pencil_eraser_radius");
-
+
/* Interpolation */
WM_keymap_add_item(keymap, "GPENCIL_OT_interpolate", EKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
WM_keymap_add_item(keymap, "GPENCIL_OT_interpolate_sequence", EKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
/* Sculpting ------------------------------------- */
-
+
/* Brush-Based Editing:
- * EKEY + LMB = Single stroke, draw immediately
+ * EKEY + LMB = Single stroke, draw immediately
* + Other Modifiers (Ctrl/Shift) = Invert, Smooth, etc.
*
* For the modal version, use D+E -> Sculpt
*/
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_paint", LEFTMOUSE, KM_PRESS, 0, EKEY);
RNA_boolean_set(kmi->ptr, "wait_for_input", false);
-
+
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_paint", LEFTMOUSE, KM_PRESS, KM_CTRL, EKEY);
RNA_boolean_set(kmi->ptr, "wait_for_input", false);
/*RNA_boolean_set(kmi->ptr, "use_invert", true);*/
-
+
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_paint", LEFTMOUSE, KM_PRESS, KM_SHIFT, EKEY);
RNA_boolean_set(kmi->ptr, "wait_for_input", false);
/*RNA_boolean_set(kmi->ptr, "use_smooth", true);*/
-
-
+
+
/* Shift-FKEY = Sculpt Strength */
kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0);
RNA_string_set(kmi->ptr, "data_path_primary", "tool_settings.gpencil_sculpt.brush.strength");
-
+
/* FKEY = Sculpt Brush Size */
kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path_primary", "tool_settings.gpencil_sculpt.brush.size");
-
-
+
+
/* Selection ------------------------------------- */
/* select all */
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_all", AKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
-
+
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
-
+
/* circle select */
WM_keymap_add_item(keymap, "GPENCIL_OT_select_circle", CKEY, KM_PRESS, 0, 0);
-
+
/* border select */
WM_keymap_add_item(keymap, "GPENCIL_OT_select_border", BKEY, KM_PRESS, 0, 0);
-
+
/* lasso select */
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "deselect", false);
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT | KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "deselect", true);
-
+
/* In the Node Editor, lasso select needs ALT modifier too (as somehow CTRL+LMB drag gets taken for "cut" quite early)
* There probably isn't too much harm adding this for other editors too as part of standard GP editing keymap. This hotkey
* combo doesn't seem to see much use under standard scenarios?
@@ -208,57 +208,57 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "deselect", false);
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT | KM_CTRL | KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "deselect", true);
-
+
/* normal select */
WM_keymap_add_item(keymap, "GPENCIL_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
-
+
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", true);
RNA_boolean_set(kmi->ptr, "toggle", true);
-
+
/* whole stroke select */
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "entire_strokes", true);
-
+
/* select linked */
/* NOTE: While LKEY is redundant, not having it breaks the mode illusion too much */
WM_keymap_add_item(keymap, "GPENCIL_OT_select_linked", LKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "GPENCIL_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* select grouped */
WM_keymap_add_item(keymap, "GPENCIL_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
-
+
/* select more/less */
WM_keymap_add_item(keymap, "GPENCIL_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "GPENCIL_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
-
+
/* Editing ----------------------------------------- */
-
+
/* duplicate and move selected points */
WM_keymap_add_item(keymap, "GPENCIL_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
-
+
/* delete */
WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_gpencil_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_gpencil_delete", DELKEY, KM_PRESS, 0, 0);
-
+
WM_keymap_add_item(keymap, "GPENCIL_OT_dissolve", XKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "GPENCIL_OT_dissolve", DELKEY, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "GPENCIL_OT_active_frames_delete_all", XKEY, KM_PRESS, KM_SHIFT, 0);
-
+
/* menu edit specials */
WM_keymap_add_menu(keymap, "GPENCIL_MT_gpencil_edit_specials", WKEY, KM_PRESS, 0, 0);
/* join strokes */
WM_keymap_add_item(keymap, "GPENCIL_OT_stroke_join", JKEY, KM_PRESS, KM_CTRL, 0);
-
+
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_stroke_join", JKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "type", GP_STROKE_JOINCOPY);
-
+
/* copy + paste */
WM_keymap_add_item(keymap, "GPENCIL_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "GPENCIL_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
-
+
#ifdef __APPLE__
WM_keymap_add_item(keymap, "GPENCIL_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0);
WM_keymap_add_item(keymap, "GPENCIL_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0);
@@ -266,72 +266,50 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf)
/* snap */
WM_keymap_add_menu(keymap, "GPENCIL_MT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
-
-
+
+
/* convert to geometry */
WM_keymap_add_item(keymap, "GPENCIL_OT_convert", CKEY, KM_PRESS, KM_ALT, 0);
-
-
+
+
/* Show/Hide */
/* NOTE: These are available only in EditMode now, since they clash with general-purpose hotkeys */
WM_keymap_add_item(keymap, "GPENCIL_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
-
+
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_hide", HKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "unselected", false);
-
+
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "unselected", true);
WM_keymap_add_item(keymap, "GPENCIL_OT_selection_opacity_toggle", HKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* Isolate Layer */
WM_keymap_add_item(keymap, "GPENCIL_OT_layer_isolate", PADASTERKEY, KM_PRESS, 0, 0);
-
+
/* Move to Layer */
WM_keymap_add_item(keymap, "GPENCIL_OT_move_to_layer", MKEY, KM_PRESS, 0, 0);
- /* Select drawing brush using index */
- kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_select", ONEKEY, KM_PRESS, 0, 0);
- RNA_int_set(kmi->ptr, "index", 0);
- kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_select", TWOKEY, KM_PRESS, 0, 0);
- RNA_int_set(kmi->ptr, "index", 1);
- kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_select", THREEKEY, KM_PRESS, 0, 0);
- RNA_int_set(kmi->ptr, "index", 2);
- kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_select", FOURKEY, KM_PRESS, 0, 0);
- RNA_int_set(kmi->ptr, "index", 3);
- kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_select", FIVEKEY, KM_PRESS, 0, 0);
- RNA_int_set(kmi->ptr, "index", 4);
- kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_select", SIXKEY, KM_PRESS, 0, 0);
- RNA_int_set(kmi->ptr, "index", 5);
- kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_select", SEVENKEY, KM_PRESS, 0, 0);
- RNA_int_set(kmi->ptr, "index", 6);
- kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_select", EIGHTKEY, KM_PRESS, 0, 0);
- RNA_int_set(kmi->ptr, "index", 7);
- kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_select", NINEKEY, KM_PRESS, 0, 0);
- RNA_int_set(kmi->ptr, "index", 8);
- kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_select", ZEROKEY, KM_PRESS, 0, 0);
- RNA_int_set(kmi->ptr, "index", 9);
-
/* Transform Tools */
kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_translate", GKEY, KM_PRESS, 0, 0);
-
+
kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_translate", EVT_TWEAK_S, KM_ANY, 0, 0);
-
+
kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_rotate", RKEY, KM_PRESS, 0, 0);
-
+
kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_resize", SKEY, KM_PRESS, 0, 0);
-
+
kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_mirror", MKEY, KM_PRESS, KM_CTRL, 0);
-
+
kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_bend", WKEY, KM_PRESS, KM_SHIFT, 0);
-
+
WM_keymap_add_item(keymap, "TRANSFORM_OT_tosphere", SKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0);
-
+
WM_keymap_add_item(keymap, "TRANSFORM_OT_shear", SKEY, KM_PRESS, KM_ALT | KM_CTRL | KM_SHIFT, 0);
-
+
kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_ALT, 0);
RNA_enum_set(kmi->ptr, "mode", TFM_GPENCIL_SHRINKFATTEN);
-
+
/* Proportional Editing */
ED_keymap_proportional_cycle(keyconf, keymap);
ED_keymap_proportional_editmode(keyconf, keymap, true);
@@ -350,11 +328,11 @@ void ED_keymap_gpencil(wmKeyConfig *keyconf)
void ED_operatortypes_gpencil(void)
{
/* Drawing ----------------------- */
-
+
WM_operatortype_append(GPENCIL_OT_draw);
-
+
/* Editing (Strokes) ------------ */
-
+
WM_operatortype_append(GPENCIL_OT_editmode_toggle);
WM_operatortype_append(GPENCIL_OT_selection_opacity_toggle);
@@ -363,41 +341,41 @@ void ED_operatortypes_gpencil(void)
WM_operatortype_append(GPENCIL_OT_select_circle);
WM_operatortype_append(GPENCIL_OT_select_border);
WM_operatortype_append(GPENCIL_OT_select_lasso);
-
+
WM_operatortype_append(GPENCIL_OT_select_linked);
WM_operatortype_append(GPENCIL_OT_select_grouped);
WM_operatortype_append(GPENCIL_OT_select_more);
WM_operatortype_append(GPENCIL_OT_select_less);
WM_operatortype_append(GPENCIL_OT_select_first);
WM_operatortype_append(GPENCIL_OT_select_last);
-
+
WM_operatortype_append(GPENCIL_OT_duplicate);
WM_operatortype_append(GPENCIL_OT_delete);
WM_operatortype_append(GPENCIL_OT_dissolve);
WM_operatortype_append(GPENCIL_OT_copy);
WM_operatortype_append(GPENCIL_OT_paste);
-
+
WM_operatortype_append(GPENCIL_OT_move_to_layer);
WM_operatortype_append(GPENCIL_OT_layer_change);
-
+
WM_operatortype_append(GPENCIL_OT_snap_to_grid);
WM_operatortype_append(GPENCIL_OT_snap_to_cursor);
WM_operatortype_append(GPENCIL_OT_snap_cursor_to_selected);
-
+
WM_operatortype_append(GPENCIL_OT_reproject);
-
+
WM_operatortype_append(GPENCIL_OT_brush_paint);
-
+
/* Editing (Buttons) ------------ */
-
+
WM_operatortype_append(GPENCIL_OT_data_add);
WM_operatortype_append(GPENCIL_OT_data_unlink);
-
+
WM_operatortype_append(GPENCIL_OT_layer_add);
WM_operatortype_append(GPENCIL_OT_layer_remove);
WM_operatortype_append(GPENCIL_OT_layer_move);
WM_operatortype_append(GPENCIL_OT_layer_duplicate);
-
+
WM_operatortype_append(GPENCIL_OT_hide);
WM_operatortype_append(GPENCIL_OT_reveal);
WM_operatortype_append(GPENCIL_OT_lock_all);
@@ -406,10 +384,10 @@ void ED_operatortypes_gpencil(void)
WM_operatortype_append(GPENCIL_OT_layer_merge);
WM_operatortype_append(GPENCIL_OT_blank_frame_add);
-
+
WM_operatortype_append(GPENCIL_OT_active_frame_delete);
WM_operatortype_append(GPENCIL_OT_active_frames_delete_all);
-
+
WM_operatortype_append(GPENCIL_OT_convert);
WM_operatortype_append(GPENCIL_OT_stroke_arrange);
@@ -445,7 +423,7 @@ void ED_operatortypes_gpencil(void)
WM_operatortype_append(GPENCIL_OT_brush_select);
/* Editing (Time) --------------- */
-
+
/* Interpolation */
WM_operatortype_append(GPENCIL_OT_interpolate);
WM_operatortype_append(GPENCIL_OT_interpolate_sequence);
@@ -456,7 +434,7 @@ void ED_operatormacros_gpencil(void)
{
wmOperatorType *ot;
wmOperatorTypeMacro *otmacro;
-
+
/* Duplicate + Move = Interactively place newly duplicated strokes */
ot = WM_operatortype_append_macro("GPENCIL_OT_duplicate_move", "Duplicate Strokes",
"Make copies of the selected Grease Pencil strokes and move them",
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 3f3349a752c..437d5cef6f8 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -46,14 +46,15 @@
#include "PIL_time.h"
-#include "BKE_paint.h"
-#include "BKE_gpencil.h"
+#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_global.h"
+#include "BKE_gpencil.h"
+#include "BKE_main.h"
+#include "BKE_paint.h"
#include "BKE_report.h"
#include "BKE_screen.h"
#include "BKE_tracking.h"
-#include "BKE_colortools.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -115,37 +116,38 @@ typedef enum eGPencil_PaintFlags {
* "p" = op->customdata
*/
typedef struct tGPsdata {
+ Main *bmain;
Scene *scene; /* current scene from context */
- struct Depsgraph *graph;
-
+ struct Depsgraph *depsgraph;
+
wmWindow *win; /* window where painting originated */
ScrArea *sa; /* area where painting originated */
ARegion *ar; /* region where painting originated */
View2D *v2d; /* needed for GP_STROKE_2DSPACE */
rctf *subrect; /* for using the camera rect within the 3d view */
rctf subrect_data;
-
+
GP_SpaceConversion gsc; /* settings to pass to gp_points_to_xy() */
-
+
PointerRNA ownerPtr; /* pointer to owner of gp-datablock */
bGPdata *gpd; /* gp-datablock layer comes from */
bGPDlayer *gpl; /* layer we're working on */
bGPDframe *gpf; /* frame we're working on */
-
+
char *align_flag; /* projection-mode flags (toolsettings - eGPencil_Placement_Flags) */
-
+
eGPencil_PaintStatus status; /* current status of painting */
eGPencil_PaintModes paintmode; /* mode for painting */
eGPencil_PaintFlags flags; /* flags that can get set during runtime (eGPencil_PaintFlags) */
-
+
short radius; /* radius of influence for eraser */
-
+
int mval[2]; /* current mouse-position */
int mvalo[2]; /* previous recorded mouse-position */
-
+
float pressure; /* current stylus pressure */
float opressure; /* previous stylus pressure */
-
+
/* These need to be doubles, as (at least under unix) they are in seconds since epoch,
* float (and its 7 digits precision) is definitively not enough here!
* double, with its 15 digits precision, ensures us millisecond precision for a few centuries at least.
@@ -153,13 +155,13 @@ typedef struct tGPsdata {
double inittime; /* Used when converting to path */
double curtime; /* Used when converting to path */
double ocurtime; /* Used when converting to path */
-
+
float imat[4][4]; /* inverted transformation matrix applying when converting coords from screen-space
* to region space */
float mat[4][4];
-
+
float custom_color[4]; /* custom color - hack for enforcing a particular color for track/mask editing */
-
+
void *erasercursor; /* radial cursor data for drawing eraser */
bGPDpalettecolor *palettecolor; /* current palette color */
@@ -216,7 +218,7 @@ static int gpencil_draw_poll(bContext *C)
else {
CTX_wm_operator_poll_msg_set(C, "Active region not set");
}
-
+
return 0;
}
@@ -237,12 +239,12 @@ static void gp_get_3d_reference(tGPsdata *p, float vec[3])
{
View3D *v3d = p->sa->spacedata.first;
const float *fp = ED_view3d_cursor3d_get(p->scene, v3d)->location;
-
+
/* the reference point used depends on the owner... */
#if 0 /* XXX: disabled for now, since we can't draw relative to the owner yet */
if (p->ownerPtr.type == &RNA_Object) {
Object *ob = (Object *)p->ownerPtr.data;
-
+
/* active Object
* - use relative distance of 3D-cursor from object center
*/
@@ -263,24 +265,24 @@ static bool gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2])
{
int dx = abs(mval[0] - pmval[0]);
int dy = abs(mval[1] - pmval[1]);
-
+
/* if buffer is empty, just let this go through (i.e. so that dots will work) */
if (p->gpd->sbuffer_size == 0)
return true;
-
+
/* check if mouse moved at least certain distance on both axes (best case)
* - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand
*/
else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX))
return true;
-
+
/* check if the distance since the last point is significant enough
* - prevents points being added too densely
* - distance here doesn't use sqrt to prevent slowness... we should still be safe from overflows though
*/
else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX)
return true;
-
+
/* mouse 'didn't move' */
else
return false;
@@ -349,7 +351,7 @@ static void gp_reproject_toplane(tGPsdata *p, bGPDstroke *gps)
static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3], float *depth)
{
bGPdata *gpd = p->gpd;
-
+
/* in 3d-space - pt->x/y/z are 3 side-by-side floats */
if (gpd->sbuffer_sflag & GP_STROKE_3DSPACE) {
if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval, out, 0, depth))) {
@@ -362,7 +364,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
float rvec[3], dvec[3];
float mval_f[2] = {UNPACK2(mval)};
float zfac;
-
+
/* Current method just converts each point in screen-coordinates to
* 3D-coordinates using the 3D-cursor as reference. In general, this
* works OK, but it could of course be improved.
@@ -371,10 +373,10 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
* - investigate using nearest point(s) on a previous stroke as
* reference point instead or as offset, for easier stroke matching
*/
-
+
gp_get_3d_reference(p, rvec);
zfac = ED_view3d_calc_zfac(p->ar->regiondata, rvec, NULL);
-
+
if (ED_view3d_project_float_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
sub_v2_v2v2(mval_f, mval_prj, mval_f);
ED_view3d_win_to_delta(p->ar, mval_f, dvec, zfac);
@@ -385,13 +387,13 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
}
}
}
-
+
/* 2d - on 'canvas' (assume that p->v2d is set) */
else if ((gpd->sbuffer_sflag & GP_STROKE_2DSPACE) && (p->v2d)) {
UI_view2d_region_to_view(p->v2d, mval[0], mval[1], &out[0], &out[1]);
mul_v3_m4v3(out, p->imat, out);
}
-
+
/* 2d - relative to screen (viewport area) */
else {
if (p->subrect == NULL) { /* normal 3D view */
@@ -477,7 +479,7 @@ static void gp_brush_angle(bGPdata *gpd, bGPDbrush *brush, tGPspoint *pt, const
fac = 1.0f - fabs(dot_v2v2(v0, mvec)); /* 0.0 to 1.0 */
/* interpolate with previous point for smoother transitions */
mpressure = interpf(pt->pressure - (sen * fac), (pt - 1)->pressure, 0.3f);
- pt->pressure = mpressure;
+ pt->pressure = mpressure;
CLAMP(pt->pressure, GPENCIL_ALPHA_OPACITY_THRESH, 1.0f);
}
@@ -499,13 +501,13 @@ static short gp_stroke_addpoint(
if (gpd->sbuffer_size == 0) {
/* first point in buffer (start point) */
pt = (tGPspoint *)(gpd->sbuffer);
-
+
/* store settings */
copy_v2_v2_int(&pt->x, mval);
pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */
pt->strength = 1.0f;
pt->time = (float)(curtime - p->inittime);
-
+
/* increment buffer size */
gpd->sbuffer_size++;
}
@@ -514,17 +516,17 @@ static short gp_stroke_addpoint(
* - assume that pointers for this are always valid...
*/
pt = ((tGPspoint *)(gpd->sbuffer) + 1);
-
+
/* store settings */
copy_v2_v2_int(&pt->x, mval);
pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */
pt->strength = 1.0f;
pt->time = (float)(curtime - p->inittime);
-
+
/* now the buffer has 2 points (and shouldn't be allowed to get any larger) */
gpd->sbuffer_size = 2;
}
-
+
/* can keep carrying on this way :) */
return GP_STROKEADD_NORMAL;
}
@@ -532,10 +534,10 @@ static short gp_stroke_addpoint(
/* check if still room in buffer */
if (gpd->sbuffer_size >= GP_STROKE_BUFFER_MAX)
return GP_STROKEADD_OVERFLOW;
-
+
/* get pointer to destination point */
pt = ((tGPspoint *)(gpd->sbuffer) + gpd->sbuffer_size);
-
+
/* store settings */
/* pressure */
if (brush->flag & GP_BRUSH_USE_PRESSURE) {
@@ -597,10 +599,10 @@ static short gp_stroke_addpoint(
/* point time */
pt->time = (float)(curtime - p->inittime);
-
+
/* increment counters */
gpd->sbuffer_size++;
-
+
/* check if another operation can still occur */
if (gpd->sbuffer_size == GP_STROKE_BUFFER_MAX)
return GP_STROKEADD_FULL;
@@ -608,17 +610,17 @@ static short gp_stroke_addpoint(
return GP_STROKEADD_NORMAL;
}
else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
-
+
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
/* get pointer to destination point */
pt = (tGPspoint *)(gpd->sbuffer);
-
+
/* store settings */
copy_v2_v2_int(&pt->x, mval);
pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */
pt->strength = 1.0f;
pt->time = (float)(curtime - p->inittime);
-
+
/* if there's stroke for this poly line session add (or replace last) point
* to stroke. This allows to draw lines more interactively (see new segment
* during mouse slide, e.g.)
@@ -626,15 +628,15 @@ static short gp_stroke_addpoint(
if (gp_stroke_added_check(p)) {
bGPDstroke *gps = p->gpf->strokes.last;
bGPDspoint *pts;
-
+
/* first time point is adding to temporary buffer -- need to allocate new point in stroke */
if (gpd->sbuffer_size == 0) {
gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1));
gps->totpoints++;
}
-
+
pts = &gps->points[gps->totpoints - 1];
-
+
/* special case for poly lines: normally,
* depth is needed only when creating new stroke from buffer,
* but poly lines are converting to stroke instantly,
@@ -642,12 +644,12 @@ static short gp_stroke_addpoint(
*/
if (gpencil_project_check(p)) {
View3D *v3d = p->sa->spacedata.first;
-
+
view3d_region_operator_needs_opengl(p->win, p->ar);
ED_view3d_autodist_init(
- p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
+ p->depsgraph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
}
-
+
/* convert screen-coordinates to appropriate coordinates (and store them) */
gp_stroke_convertcoords(p, &pt->x, &pts->x, NULL);
/* if axis locked, reproject to plane locked (only in 3d space) */
@@ -665,11 +667,11 @@ static short gp_stroke_addpoint(
/* force fill recalc */
gps->flag |= GP_STROKE_RECALC_CACHES;
}
-
+
/* increment counters */
if (gpd->sbuffer_size == 0)
gpd->sbuffer_size++;
-
+
return GP_STROKEADD_NORMAL;
}
@@ -688,15 +690,15 @@ static void gp_stroke_simplify(tGPsdata *p)
short num_points = gpd->sbuffer_size;
short flag = gpd->sbuffer_sflag;
short i, j;
-
+
/* only simplify if simplification is enabled, and we're not doing a straight line */
if (!(U.gp_settings & GP_PAINT_DOSIMPLIFY) || (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT))
return;
-
+
/* don't simplify if less than 4 points in buffer */
if ((num_points <= 4) || (old_points == NULL))
return;
-
+
/* clear buffer (but don't free mem yet) so that we can write to it
* - firstly set sbuffer to NULL, so a new one is allocated
* - secondly, reset flag after, as it gets cleared auto
@@ -704,7 +706,7 @@ static void gp_stroke_simplify(tGPsdata *p)
gpd->sbuffer = NULL;
gp_session_validatebuffer(p);
gpd->sbuffer_sflag = flag;
-
+
/* macro used in loop to get position of new point
* - used due to the mixture of datatypes in use here
*/
@@ -715,30 +717,30 @@ static void gp_stroke_simplify(tGPsdata *p)
pressure += old_points[offs].pressure * sfac; \
time += old_points[offs].time * sfac; \
} (void)0
-
+
/* XXX Here too, do not lose start and end points! */
gp_stroke_addpoint(p, &old_points->x, old_points->pressure, p->inittime + (double)old_points->time);
for (i = 0, j = 0; i < num_points; i++) {
if (i - j == 3) {
float co[2], pressure, time;
int mco[2];
-
+
/* initialize values */
co[0] = 0.0f;
co[1] = 0.0f;
pressure = 0.0f;
time = 0.0f;
-
+
/* using macro, calculate new point */
GP_SIMPLIFY_AVPOINT(j, -0.25f);
GP_SIMPLIFY_AVPOINT(j + 1, 0.75f);
GP_SIMPLIFY_AVPOINT(j + 2, 0.75f);
GP_SIMPLIFY_AVPOINT(j + 3, -0.25f);
-
+
/* set values for adding */
mco[0] = (int)co[0];
mco[1] = (int)co[1];
-
+
/* ignore return values on this... assume to be ok for now */
gp_stroke_addpoint(p, mco, pressure, p->inittime + (double)time);
@@ -747,7 +749,7 @@ static void gp_stroke_simplify(tGPsdata *p)
}
gp_stroke_addpoint(p, &old_points[num_points - 1].x, old_points[num_points - 1].pressure,
p->inittime + (double)old_points[num_points - 1].time);
-
+
/* free old buffer */
MEM_freeN(old_points);
}
@@ -762,11 +764,11 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
tGPspoint *ptc;
bGPDbrush *brush = p->brush;
ToolSettings *ts = p->scene->toolsettings;
-
+
int i, totelem;
/* since strokes are so fine, when using their depth we need a margin otherwise they might get missed */
int depth_margin = (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 4 : 0;
-
+
/* get total number of points to allocate space for
* - drawing straight-lines only requires the endpoints
*/
@@ -774,14 +776,14 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
totelem = (gpd->sbuffer_size >= 2) ? 2 : gpd->sbuffer_size;
else
totelem = gpd->sbuffer_size;
-
+
/* exit with error if no valid points from this stroke */
if (totelem == 0) {
if (G.debug & G_DEBUG)
printf("Error: No valid points in stroke buffer to convert (tot=%d)\n", gpd->sbuffer_size);
return;
}
-
+
/* special case for poly line -- for already added stroke during session
* coordinates are getting added to stroke immediately to allow more
* interactive behavior
@@ -791,23 +793,23 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
return;
}
}
-
+
/* allocate memory for a new stroke */
gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke");
-
+
/* copy appropriate settings for stroke */
gps->totpoints = totelem;
gps->thickness = brush->thickness;
gps->flag = gpd->sbuffer_sflag;
gps->inittime = p->inittime;
-
+
/* enable recalculation flag by default (only used if hq fill) */
gps->flag |= GP_STROKE_RECALC_CACHES;
/* allocate enough memory for a continuous array for storage points */
int sublevel = brush->sublevel;
int new_totpoints = gps->totpoints;
-
+
for (i = 0; i < sublevel; i++) {
new_totpoints += new_totpoints - 1;
}
@@ -818,14 +820,14 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
gps->tot_triangles = 0;
/* set pointer to first non-initialized point */
pt = gps->points + (gps->totpoints - totelem);
-
+
/* copy points from the buffer to the stroke */
if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) {
/* straight lines only -> only endpoints */
{
/* first point */
ptc = gpd->sbuffer;
-
+
/* convert screen-coordinates to appropriate coordinates (and store them) */
gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL);
/* if axis locked, reproject to plane locked (only in 3d space) */
@@ -841,14 +843,14 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
pt->strength = ptc->strength;
CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
pt->time = ptc->time;
-
+
pt++;
}
-
+
if (totelem == 2) {
/* last point if applicable */
ptc = ((tGPspoint *)gpd->sbuffer) + (gpd->sbuffer_size - 1);
-
+
/* convert screen-coordinates to appropriate coordinates (and store them) */
gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL);
/* if axis locked, reproject to plane locked (only in 3d space) */
@@ -870,7 +872,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
/* first point */
ptc = gpd->sbuffer;
-
+
/* convert screen-coordinates to appropriate coordinates (and store them) */
gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL);
/* if axis locked, reproject to plane locked (only in 3d space) */
@@ -1012,7 +1014,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
gps->palcolor = palcolor;
BLI_strncpy(gps->colorname, palcolor->info, sizeof(gps->colorname));
- /* add stroke to frame, usually on tail of the listbase, but if on back is enabled the stroke is added on listbase head
+ /* add stroke to frame, usually on tail of the listbase, but if on back is enabled the stroke is added on listbase head
* because the drawing order is inverse and the head stroke is the first to draw. This is very useful for artist
* when drawing the background
*/
@@ -1060,7 +1062,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, cons
mul_v3_m4v3(fpt, diff_mat, &pt->x);
const float depth_pt = view3d_point_depth(rv3d, fpt);
-
+
if (depth_pt > depth_mval) {
return true;
}
@@ -1075,13 +1077,13 @@ static float gp_stroke_eraser_calc_influence(tGPsdata *p, const int mval[2], con
/* Linear Falloff... */
float distance = (float)len_v2v2_int(mval, co);
float fac;
-
+
CLAMP(distance, 0.0f, (float)radius);
fac = 1.0f - (distance / (float)radius);
-
+
/* Control this further using pen pressure */
fac *= p->pressure;
-
+
/* Return influence factor computed here */
return fac;
}
@@ -1142,15 +1144,15 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
* below which we would have invisible strokes
*/
const float cull_thresh = (gps->thickness) ? 1.0f / ((float)gps->thickness) : 1.0f;
-
+
/* Amount to decrease the pressure of each point with each stroke */
// TODO: Fetch from toolsettings, or compute based on thickness instead?
const float strength = 0.1f;
-
+
/* Perform culling? */
bool do_cull = false;
-
-
+
+
/* Clear Tags
*
* Note: It's better this way, as we are sure that
@@ -1161,7 +1163,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
bGPDspoint *pt = &gps->points[i];
pt->flag &= ~GP_SPOINT_TAG;
}
-
+
/* First Pass: Loop over the points in the stroke
* 1) Thin out parts of the stroke under the brush
* 2) Tag "too thin" parts for removal (in second pass)
@@ -1174,7 +1176,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
/* only process if it hasn't been masked out... */
if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT))
continue;
-
+
if (gpl->parent == NULL) {
gp_point_to_xy(&p->gsc, gps, pt1, &pc1[0], &pc1[1]);
gp_point_to_xy(&p->gsc, gps, pt2, &pc2[0], &pc2[1]);
@@ -1207,7 +1209,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
*/
pt1->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc1) * strength;
pt2->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc2) * strength / 2.0f;
-
+
/* 2) Tag any point with overly low influence for removal in the next pass */
if (pt1->pressure < cull_thresh) {
pt1->flag |= GP_SPOINT_TAG;
@@ -1221,7 +1223,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
}
}
}
-
+
/* Second Pass: Remove any points that are tagged */
if (do_cull) {
gp_stroke_delete_tagged_points(gpf, gps, gps->next, GP_SPOINT_TAG);
@@ -1235,28 +1237,28 @@ static void gp_stroke_doeraser(tGPsdata *p)
bGPDlayer *gpl;
bGPDstroke *gps, *gpn;
rcti rect;
-
+
/* rect is rectangle of eraser */
rect.xmin = p->mval[0] - p->radius;
rect.ymin = p->mval[1] - p->radius;
rect.xmax = p->mval[0] + p->radius;
rect.ymax = p->mval[1] + p->radius;
-
+
if (p->sa->spacetype == SPACE_VIEW3D) {
if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) {
View3D *v3d = p->sa->spacedata.first;
view3d_region_operator_needs_opengl(p->win, p->ar);
- ED_view3d_autodist_init(p->graph, p->ar, v3d, 0);
+ ED_view3d_autodist_init(p->depsgraph, p->ar, v3d, 0);
}
}
-
+
/* loop over all layers too, since while it's easy to restrict editing to
* only a subset of layers, it is harder to perform the same erase operation
* on multiple layers...
*/
for (gpl = p->gpd->layers.first; gpl; gpl = gpl->next) {
bGPDframe *gpf = gpl->actframe;
-
+
/* only affect layer if it's editable (and visible) */
if (gpencil_layer_is_editable(gpl) == false) {
continue;
@@ -1264,7 +1266,7 @@ static void gp_stroke_doeraser(tGPsdata *p)
else if (gpf == NULL) {
continue;
}
-
+
/* loop over strokes, checking segments for intersections */
for (gps = gpf->strokes.first; gps; gps = gpn) {
gpn = gps->next;
@@ -1289,7 +1291,7 @@ static void gp_stroke_doeraser(tGPsdata *p)
static void gp_session_validatebuffer(tGPsdata *p)
{
bGPdata *gpd = p->gpd;
-
+
/* clear memory of buffer (or allocate it if starting a new session) */
if (gpd->sbuffer) {
/* printf("\t\tGP - reset sbuffer\n"); */
@@ -1299,13 +1301,13 @@ static void gp_session_validatebuffer(tGPsdata *p)
/* printf("\t\tGP - allocate sbuffer\n"); */
gpd->sbuffer = MEM_callocN(sizeof(tGPspoint) * GP_STROKE_BUFFER_MAX, "gp_session_strokebuffer");
}
-
+
/* reset indices */
gpd->sbuffer_size = 0;
-
+
/* reset flags */
gpd->sbuffer_sflag = 0;
-
+
/* reset inittime */
p->inittime = 0.0;
}
@@ -1316,7 +1318,7 @@ static bGPDpalettecolor *gp_create_new_color(bGPDpalette *palette)
bGPDpalettecolor *palcolor;
palcolor = BKE_gpencil_palettecolor_addnew(palette, DATA_("Color"), true);
-
+
return palcolor;
}
@@ -1389,7 +1391,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
ScrArea *curarea = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
ToolSettings *ts = CTX_data_tool_settings(C);
-
+
/* make sure the active view (at the starting time) is a 3d-view */
if (curarea == NULL) {
p->status = GP_STATUS_ERROR;
@@ -1397,22 +1399,23 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
printf("Error: No active view for painting\n");
return 0;
}
-
+
/* pass on current scene and window */
+ p->bmain = CTX_data_main(C);
p->scene = CTX_data_scene(C);
- p->graph = CTX_data_depsgraph(C);
+ p->depsgraph = CTX_data_depsgraph(C);
p->win = CTX_wm_window(C);
-
+
unit_m4(p->imat);
unit_m4(p->mat);
-
+
switch (curarea->spacetype) {
/* supported views first */
case SPACE_VIEW3D:
{
/* View3D *v3d = curarea->spacedata.first; */
/* RegionView3D *rv3d = ar->regiondata; */
-
+
/* set current area
* - must verify that region data is 3D-view (and not something else)
*/
@@ -1420,7 +1423,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
p->sa = curarea;
p->ar = ar;
p->align_flag = &ts->gpencil_v3d_align;
-
+
if (ar->regiondata == NULL) {
p->status = GP_STATUS_ERROR;
if (G.debug & G_DEBUG)
@@ -1432,7 +1435,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
case SPACE_NODE:
{
/* SpaceNode *snode = curarea->spacedata.first; */
-
+
/* set current area */
p->sa = curarea;
p->ar = ar;
@@ -1443,13 +1446,13 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
case SPACE_SEQ:
{
SpaceSeq *sseq = curarea->spacedata.first;
-
+
/* set current area */
p->sa = curarea;
p->ar = ar;
p->v2d = &ar->v2d;
p->align_flag = &ts->gpencil_seq_align;
-
+
/* check that gpencil data is allowed to be drawn */
if (sseq->mainb == SEQ_DRAW_SEQUENCE) {
p->status = GP_STATUS_ERROR;
@@ -1462,7 +1465,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
case SPACE_IMAGE:
{
/* SpaceImage *sima = curarea->spacedata.first; */
-
+
/* set the current area */
p->sa = curarea;
p->ar = ar;
@@ -1474,7 +1477,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
{
SpaceClip *sc = curarea->spacedata.first;
MovieClip *clip = ED_space_clip_get_clip(sc);
-
+
if (clip == NULL) {
p->status = GP_STATUS_ERROR;
return false;
@@ -1485,15 +1488,15 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
p->ar = ar;
p->v2d = &ar->v2d;
p->align_flag = &ts->gpencil_v2d_align;
-
+
invert_m4_m4(p->imat, sc->unistabmat);
-
+
/* custom color for new layer */
p->custom_color[0] = 1.0f;
p->custom_color[1] = 0.0f;
p->custom_color[2] = 0.5f;
p->custom_color[3] = 0.9f;
-
+
if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
int framenr = ED_space_clip_get_clip_frame_number(sc);
MovieTrackingTrack *track = BKE_tracking_track_get_active(&clip->tracking);
@@ -1508,7 +1511,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
return false;
}
}
-
+
invert_m4_m4(p->mat, p->imat);
copy_m4_m4(p->gsc.mat, p->mat);
break;
@@ -1522,7 +1525,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
return 0;
}
}
-
+
/* get gp-data */
gpd_ptr = ED_gpencil_data_get_pointers(C, &p->ownerPtr);
if (gpd_ptr == NULL) {
@@ -1537,14 +1540,14 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
*gpd_ptr = BKE_gpencil_data_addnew("GPencil");
p->gpd = *gpd_ptr;
}
-
+
if (ED_gpencil_session_active() == 0) {
/* initialize undo stack,
* also, existing undo stack would make buffer drawn
*/
gpencil_undo_init(p->gpd);
}
-
+
/* clear out buffer (stored in gp-data), in case something contaminated it */
gp_session_validatebuffer(p);
/* set brush and create a new one if null */
@@ -1567,12 +1570,12 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
static tGPsdata *gp_session_initpaint(bContext *C)
{
tGPsdata *p = NULL;
-
+
/* create new context data */
p = MEM_callocN(sizeof(tGPsdata), "GPencil Drawing Data");
-
+
gp_session_initdata(C, p);
-
+
/* radius for eraser circle is defined in userprefs now */
/* NOTE: we do this here, so that if we exit immediately,
* erase size won't get lost
@@ -1587,18 +1590,18 @@ static tGPsdata *gp_session_initpaint(bContext *C)
static void gp_session_cleanup(tGPsdata *p)
{
bGPdata *gpd = (p) ? p->gpd : NULL;
-
+
/* error checking */
if (gpd == NULL)
return;
-
+
/* free stroke buffer */
if (gpd->sbuffer) {
/* printf("\t\tGP - free sbuffer\n"); */
MEM_freeN(gpd->sbuffer);
gpd->sbuffer = NULL;
}
-
+
/* clear flags */
gpd->sbuffer_size = 0;
gpd->sbuffer_sflag = 0;
@@ -1610,12 +1613,12 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
{
Scene *scene = p->scene;
ToolSettings *ts = scene->toolsettings;
-
+
/* get active layer (or add a new one if non-existent) */
p->gpl = BKE_gpencil_layer_getactive(p->gpd);
if (p->gpl == NULL) {
p->gpl = BKE_gpencil_layer_addnew(p->gpd, "GP_Layer", true);
-
+
if (p->custom_color[3])
copy_v3_v3(p->gpl->color, p->custom_color);
}
@@ -1625,7 +1628,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
printf("Error: Cannot paint on locked layer\n");
return;
}
-
+
/* get active frame (add a new one if not matching frame) */
if (paintmode == GP_PAINTMODE_ERASER) {
/* Eraser mode:
@@ -1634,12 +1637,12 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
* (to avoid problems with other tools which expect it to exist)
*/
bool has_layer_to_erase = false;
-
+
for (bGPDlayer *gpl = p->gpd->layers.first; gpl; gpl = gpl->next) {
/* Skip if layer not editable */
if (gpencil_layer_is_editable(gpl) == false)
continue;
-
+
/* Add a new frame if needed (and based off the active frame,
* as we need some existing strokes to erase)
*
@@ -1651,16 +1654,16 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
gpl->actframe = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_ADD_COPY);
has_layer_to_erase = true;
}
-
+
/* XXX: we omit GP_FRAME_PAINT here for now,
* as it is only really useful for doing
* paintbuffer drawing
*/
}
-
+
/* Ensure this gets set... */
p->gpf = p->gpl->actframe;
-
+
/* Restrict eraser to only affecting selected strokes, if the "selection mask" is on
* (though this is only available in editmode)
*/
@@ -1669,7 +1672,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
p->flags |= GP_PAINTFLAG_SELECTMASK;
}
}
-
+
if (has_layer_to_erase == false) {
p->status = GP_STATUS_ERROR;
//if (G.debug & G_DEBUG)
@@ -1680,14 +1683,14 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
else {
/* Drawing Modes - Add a new frame if needed on the active layer */
short add_frame_mode;
-
+
if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST)
add_frame_mode = GP_GETFRAME_ADD_COPY;
else
add_frame_mode = GP_GETFRAME_ADD_NEW;
-
+
p->gpf = BKE_gpencil_layer_getframe(p->gpl, CFRA, add_frame_mode);
-
+
if (p->gpf == NULL) {
p->status = GP_STATUS_ERROR;
if (G.debug & G_DEBUG)
@@ -1698,12 +1701,12 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
p->gpf->flag |= GP_FRAME_PAINT;
}
}
-
+
/* set 'eraser' for this stroke if using eraser */
p->paintmode = paintmode;
if (p->paintmode == GP_PAINTMODE_ERASER) {
p->gpd->sbuffer_sflag |= GP_STROKE_ERASER;
-
+
/* check if we should respect depth while erasing */
if (p->sa->spacetype == SPACE_VIEW3D) {
if (p->gpl->flag & GP_LAYER_NO_XRAY) {
@@ -1714,25 +1717,25 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
else {
/* disable eraser flags - so that we can switch modes during a session */
p->gpd->sbuffer_sflag &= ~GP_STROKE_ERASER;
-
+
if (p->sa->spacetype == SPACE_VIEW3D) {
if (p->gpl->flag & GP_LAYER_NO_XRAY) {
p->flags &= ~GP_PAINTFLAG_V3D_ERASER_DEPTH;
}
}
}
-
+
/* set 'initial run' flag, which is only used to denote when a new stroke is starting */
p->flags |= GP_PAINTFLAG_FIRSTRUN;
-
-
+
+
/* when drawing in the camera view, in 2D space, set the subrect */
p->subrect = NULL;
if ((*p->align_flag & GP_PROJECT_VIEWSPACE) == 0) {
if (p->sa->spacetype == SPACE_VIEW3D) {
View3D *v3d = p->sa->spacedata.first;
RegionView3D *rv3d = p->ar->regiondata;
-
+
/* for camera view set the subrect */
if (rv3d->persp == RV3D_CAMOB) {
ED_view3d_calc_camera_border(p->scene, depsgraph, p->ar, v3d, rv3d, &p->subrect_data, true); /* no shift */
@@ -1740,21 +1743,21 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
}
}
}
-
+
/* init stroke point space-conversion settings... */
p->gsc.gpd = p->gpd;
p->gsc.gpl = p->gpl;
-
+
p->gsc.sa = p->sa;
p->gsc.ar = p->ar;
p->gsc.v2d = p->v2d;
-
+
p->gsc.subrect_data = p->subrect_data;
p->gsc.subrect = p->subrect;
-
+
copy_m4_m4(p->gsc.mat, p->mat);
-
-
+
+
/* check if points will need to be made in view-aligned space */
if (*p->align_flag & GP_PROJECT_VIEWSPACE) {
switch (p->sa->spacetype) {
@@ -1776,7 +1779,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
case SPACE_IMAGE:
{
SpaceImage *sima = (SpaceImage *)p->sa->spacedata.first;
-
+
/* only set these flags if the image editor doesn't have an image active,
* otherwise user will be confused by strokes not appearing after they're drawn
*
@@ -1810,12 +1813,12 @@ static void gp_paint_strokeend(tGPsdata *p)
*/
if (gpencil_project_check(p)) {
View3D *v3d = p->sa->spacedata.first;
-
+
/* need to restore the original projection settings before packing up */
view3d_region_operator_needs_opengl(p->win, p->ar);
- ED_view3d_autodist_init(p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
+ ED_view3d_autodist_init(p->depsgraph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
}
-
+
/* check if doing eraser or not */
if ((p->gpd->sbuffer_sflag & GP_STROKE_ERASER) == 0) {
/* simplify stroke before transferring? */
@@ -1824,7 +1827,7 @@ static void gp_paint_strokeend(tGPsdata *p)
/* transfer stroke to frame */
gp_stroke_newfrombuffer(p);
}
-
+
/* clean up buffer now */
gp_session_validatebuffer(p);
}
@@ -1839,7 +1842,7 @@ static void gp_paint_cleanup(tGPsdata *p)
/* finish off a stroke */
gp_paint_strokeend(p);
}
-
+
/* "unlock" frame */
if (p->gpf)
p->gpf->flag &= ~GP_FRAME_PAINT;
@@ -1912,7 +1915,7 @@ static bool gpencil_is_tablet_eraser_active(const wmEvent *event)
const wmTabletData *wmtab = event->tablet_data;
return (wmtab->Active == EVT_TABLET_ERASER);
}
-
+
return false;
}
@@ -1921,13 +1924,13 @@ static bool gpencil_is_tablet_eraser_active(const wmEvent *event)
static void gpencil_draw_exit(bContext *C, wmOperator *op)
{
tGPsdata *p = op->customdata;
-
+
/* clear undo stack */
gpencil_undo_finish();
-
+
/* restore cursor to indicate end of drawing */
WM_cursor_modal_restore(CTX_wm_window(C));
-
+
/* don't assume that operator data exists at all */
if (p) {
/* check size of buffer before cleanup, to determine if anything happened here */
@@ -1941,15 +1944,15 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op)
* have been toggled at some point.
*/
U.gp_eraser = p->radius;
-
+
/* cleanup */
gp_paint_cleanup(p);
gp_session_cleanup(p);
-
+
/* finally, free the temp data */
MEM_freeN(p);
}
-
+
op->customdata = NULL;
}
@@ -1966,7 +1969,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event)
{
tGPsdata *p;
eGPencil_PaintModes paintmode = RNA_enum_get(op->ptr, "mode");
-
+
/* check context */
p = op->customdata = gp_session_initpaint(C);
if ((p == NULL) || (p->status == GP_STATUS_ERROR)) {
@@ -1974,7 +1977,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event)
gpencil_draw_exit(C, op);
return 0;
}
-
+
/* init painting data */
gp_paint_initstroke(p, paintmode, CTX_data_depsgraph(C));
if (p->status == GP_STATUS_ERROR) {
@@ -1988,7 +1991,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event)
else {
p->keymodifier = -1;
}
-
+
/* everything is now setup ok */
return 1;
}
@@ -2015,7 +2018,7 @@ static void gpencil_draw_status_indicators(tGPsdata *p)
if (GPENCIL_SKETCH_SESSIONS_ON(p->scene))
ED_area_headerprint(p->sa, IFACE_("Grease Pencil: Drawing/erasing stroke... Release to end stroke"));
break;
-
+
case GP_STATUS_IDLING:
/* print status info */
switch (p->paintmode) {
@@ -2035,13 +2038,13 @@ static void gpencil_draw_status_indicators(tGPsdata *p)
ED_area_headerprint(p->sa, IFACE_("Grease Pencil Poly Session: LMB click to place next stroke vertex | "
"ESC/Enter to end (or click outside this area)"));
break;
-
+
default: /* unhandled future cases */
ED_area_headerprint(p->sa, IFACE_("Grease Pencil Session: ESC/Enter to end (or click outside this area)"));
break;
}
break;
-
+
case GP_STATUS_ERROR:
case GP_STATUS_DONE:
/* clear status string */
@@ -2076,7 +2079,7 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata *p, Depsgraph *depsgraph
gp_paint_strokeend(p);
/* And start a new one!!! Else, projection errors! */
gp_paint_initstroke(p, p->paintmode, depsgraph);
-
+
/* start a new stroke, starting from previous point */
/* XXX Must manually reset inittime... */
/* XXX We only need to reuse previous point if overflow! */
@@ -2093,12 +2096,12 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata *p, Depsgraph *depsgraph
/* the painting operation cannot continue... */
BKE_report(op->reports, RPT_ERROR, "Cannot paint stroke");
p->status = GP_STATUS_ERROR;
-
+
if (G.debug & G_DEBUG)
printf("Error: Grease-Pencil Paint - Add Point Invalid\n");
return;
}
-
+
/* store used values */
p->mvalo[0] = p->mval[0];
p->mvalo[1] = p->mval[1];
@@ -2114,13 +2117,13 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event, Depsg
PointerRNA itemptr;
float mousef[2];
int tablet = 0;
-
+
/* convert from window-space to area-space mouse coordinates
* NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding...
*/
p->mval[0] = event->mval[0] + 1;
p->mval[1] = event->mval[1] + 1;
-
+
/* verify key status for straight lines */
if ((event->ctrl > 0) || (event->alt > 0)) {
if (p->straight[0] == 0) {
@@ -2146,14 +2149,14 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event, Depsg
}
p->curtime = PIL_check_seconds_timer();
-
+
/* handle pressure sensitivity (which is supplied by tablets) */
if (event->tablet_data) {
const wmTabletData *wmtab = event->tablet_data;
-
+
tablet = (wmtab->Active != EVT_TABLET_NONE);
p->pressure = wmtab->Pressure;
-
+
/* Hack for pressure sensitive eraser on D+RMB when using a tablet:
* The pen has to float over the tablet surface, resulting in
* zero pressure (T47101). Ignore pressure values if floating
@@ -2170,11 +2173,11 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event, Depsg
/* No tablet data -> No pressure info is available */
p->pressure = 1.0f;
}
-
+
/* special exception for start of strokes (i.e. maybe for just a dot) */
if (p->flags & GP_PAINTFLAG_FIRSTRUN) {
p->flags &= ~GP_PAINTFLAG_FIRSTRUN;
-
+
p->mvalo[0] = p->mval[0];
p->mvalo[1] = p->mval[1];
p->opressure = p->pressure;
@@ -2188,7 +2191,7 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event, Depsg
if (tablet && (p->pressure >= 0.99f))
return;
}
-
+
/* check if alt key is pressed and limit to straight lines */
if (p->straight[0] != 0) {
if (p->straight[0] == 1) {
@@ -2203,15 +2206,15 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event, Depsg
/* fill in stroke data (not actually used directly by gpencil_draw_apply) */
RNA_collection_add(op->ptr, "stroke", &itemptr);
-
+
mousef[0] = p->mval[0];
mousef[1] = p->mval[1];
RNA_float_set_array(&itemptr, "mouse", mousef);
RNA_float_set(&itemptr, "pressure", p->pressure);
RNA_boolean_set(&itemptr, "is_start", (p->flags & GP_PAINTFLAG_FIRSTRUN) != 0);
-
+
RNA_float_set(&itemptr, "time", p->curtime - p->inittime);
-
+
/* apply the current latest drawing point */
gpencil_draw_apply(op, p, depsgraph);
@@ -2226,9 +2229,9 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op)
{
tGPsdata *p = NULL;
Depsgraph *depsgraph = CTX_data_depsgraph(C);
-
+
/* printf("GPencil - Starting Re-Drawing\n"); */
-
+
/* try to initialize context data needed while drawing */
if (!gpencil_draw_init(C, op, NULL)) {
if (op->customdata) MEM_freeN(op->customdata);
@@ -2237,25 +2240,25 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op)
}
else
p = op->customdata;
-
+
/* printf("\tGP - Start redrawing stroke\n"); */
-
+
/* loop over the stroke RNA elements recorded (i.e. progress of mouse movement),
* setting the relevant values in context at each step, then applying
*/
RNA_BEGIN (op->ptr, itemptr, "stroke")
{
float mousef[2];
-
+
/* printf("\t\tGP - stroke elem\n"); */
-
+
/* get relevant data for this point from stroke */
RNA_float_get_array(&itemptr, "mouse", mousef);
p->mval[0] = (int)mousef[0];
p->mval[1] = (int)mousef[1];
p->pressure = RNA_float_get(&itemptr, "pressure");
p->curtime = (double)RNA_float_get(&itemptr, "time") + p->inittime;
-
+
if (RNA_boolean_get(&itemptr, "is_start")) {
/* if first-run flag isn't set already (i.e. not true first stroke),
* then we must terminate the previous one first before continuing
@@ -2266,30 +2269,30 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op)
gp_paint_initstroke(p, p->paintmode, depsgraph);
}
}
-
+
/* if first run, set previous data too */
if (p->flags & GP_PAINTFLAG_FIRSTRUN) {
p->flags &= ~GP_PAINTFLAG_FIRSTRUN;
-
+
p->mvalo[0] = p->mval[0];
p->mvalo[1] = p->mval[1];
p->opressure = p->pressure;
p->ocurtime = p->curtime;
}
-
+
/* apply this data as necessary now (as per usual) */
gpencil_draw_apply(op, p, depsgraph);
}
RNA_END;
-
+
/* printf("\tGP - done\n"); */
-
+
/* cleanup */
gpencil_draw_exit(C, op);
-
+
/* refreshes */
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -2300,10 +2303,10 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op)
static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tGPsdata *p = NULL;
-
+
if (G.debug & G_DEBUG)
printf("GPencil - Starting Drawing\n");
-
+
/* try to initialize context data needed while drawing */
if (!gpencil_draw_init(C, op, event)) {
if (op->customdata)
@@ -2314,17 +2317,17 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
}
else
p = op->customdata;
-
+
/* TODO: set any additional settings that we can take from the events?
* TODO? if tablet is erasing, force eraser to be on? */
-
+
/* TODO: move cursor setting stuff to stroke-start so that paintmode can be changed midway... */
-
+
/* if eraser is on, draw radial aid */
if (p->paintmode == GP_PAINTMODE_ERASER) {
gpencil_draw_toggle_eraser_cursor(C, p, true);
}
- /* set cursor
+ /* set cursor
* NOTE: This may change later (i.e. intentionally via brush toggle,
* or unintentionally if the user scrolls outside the area)...
*/
@@ -2345,7 +2348,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
/* printf("\tGP - hotkey invoked... waiting for click-drag\n"); */
op->flag |= OP_IS_MODAL_CURSOR_REGION;
}
-
+
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
/* add a modal handler for this operator, so that we can then draw continuous strokes */
WM_event_add_modal_handler(C, op);
@@ -2362,7 +2365,7 @@ static bool gpencil_area_exists(bContext *C, ScrArea *sa_test)
static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
{
tGPsdata *p = op->customdata;
-
+
/* we must check that we're still within the area that we're set up to work from
* otherwise we could crash (see bug #20586)
*/
@@ -2370,21 +2373,21 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
printf("\t\t\tGP - wrong area execution abort!\n");
p->status = GP_STATUS_ERROR;
}
-
+
/* printf("\t\tGP - start stroke\n"); */
-
+
/* we may need to set up paint env again if we're resuming */
/* XXX: watch it with the paintmode! in future,
* it'd be nice to allow changing paint-mode when in sketching-sessions */
-
+
if (gp_session_initdata(C, p))
gp_paint_initstroke(p, p->paintmode, CTX_data_depsgraph(C));
-
+
if (p->status != GP_STATUS_ERROR) {
p->status = GP_STATUS_PAINTING;
op->flag &= ~OP_IS_MODAL_CURSOR_REGION;
}
-
+
return op->customdata;
}
@@ -2395,12 +2398,12 @@ static void gpencil_stroke_end(wmOperator *op)
gp_paint_cleanup(p);
gpencil_undo_push(p->gpd);
-
+
gp_session_cleanup(p);
-
+
p->status = GP_STATUS_IDLING;
op->flag |= OP_IS_MODAL_CURSOR_REGION;
-
+
p->gpd = NULL;
p->gpl = NULL;
p->gpf = NULL;
@@ -2434,7 +2437,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
tGPsdata *p = op->customdata;
ToolSettings *ts = CTX_data_tool_settings(C);
int estate = OPERATOR_PASS_THROUGH; /* default exit state - pass through to support MMB view nav, etc. */
-
+
/* if (event->type == NDOF_MOTION)
* return OPERATOR_PASS_THROUGH;
* -------------------------------
@@ -2447,7 +2450,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
* better in tools that immediately apply
* in 3D space.
*/
-
+
if (p->status == GP_STATUS_IDLING) {
ARegion *ar = CTX_wm_region(C);
p->ar = ar;
@@ -2484,9 +2487,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
estate = OPERATOR_RUNNING_MODAL;
}
}
-
+
//printf("\tGP - handle modal event...\n");
-
+
/* exit painting mode (and/or end current stroke)
* NOTE: cannot do RIGHTMOUSE (as is standard for canceling) as that would break polyline [#32647]
*/
@@ -2504,25 +2507,25 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
p->status = GP_STATUS_DONE;
estate = OPERATOR_FINISHED;
}
-
+
/* toggle painting mode upon mouse-button movement
* - LEFTMOUSE = standard drawing (all) / straight line drawing (all) / polyline (toolbox only)
* - RIGHTMOUSE = polyline (hotkey) / eraser (all)
* (Disabling RIGHTMOUSE case here results in bugs like [#32647])
* also making sure we have a valid event value, to not exit too early
*/
- if (ELEM(event->type, LEFTMOUSE, RIGHTMOUSE) && (event->val != KM_NOTHING)) {
+ if (ELEM(event->type, LEFTMOUSE, RIGHTMOUSE) && (ELEM(event->val, KM_PRESS, KM_RELEASE))) {
/* if painting, end stroke */
if (p->status == GP_STATUS_PAINTING) {
int sketch = 0;
-
+
/* basically, this should be mouse-button up = end stroke
* BUT what happens next depends on whether we 'painting sessions' is enabled
*/
sketch |= GPENCIL_SKETCH_SESSIONS_ON(p->scene);
/* polyline drawing is also 'sketching' -- all knots should be added during one session */
sketch |= (p->paintmode == GP_PAINTMODE_DRAW_POLY);
-
+
if (sketch) {
/* end stroke only, and then wait to resume painting soon */
/* printf("\t\tGP - end stroke only\n"); */
@@ -2533,13 +2536,13 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
*/
if (p->paintmode == GP_PAINTMODE_ERASER) {
p->paintmode = RNA_enum_get(op->ptr, "mode");
-
+
/* if the original mode was *still* eraser,
* we'll let it say for now, since this gives
* users an opportunity to have visual feedback
* when adjusting eraser size
*/
- if (p->paintmode != GP_PAINTMODE_ERASER) {
+ if (p->paintmode != GP_PAINTMODE_ERASER) {
/* turn off cursor...
* NOTE: this should be enough for now
* Just hiding this makes it seem like
@@ -2548,10 +2551,10 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
gpencil_draw_toggle_eraser_cursor(C, p, false);
}
}
-
+
/* we've just entered idling state, so this event was processed (but no others yet) */
estate = OPERATOR_RUNNING_MODAL;
-
+
/* stroke could be smoothed, send notifier to refresh screen */
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
}
@@ -2571,7 +2574,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
else if (event->val == KM_PRESS) {
bool in_bounds = false;
-
+
/* Check if we're outside the bounds of the active region
* NOTE: An exception here is that if launched from the toolbar,
* whatever region we're now in should become the new region
@@ -2579,13 +2582,13 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
if ((p->ar) && (p->ar->regiontype == RGN_TYPE_TOOLS)) {
/* Change to whatever region is now under the mouse */
ARegion *current_region = BKE_area_find_region_xy(p->sa, RGN_TYPE_ANY, event->x, event->y);
-
+
if (G.debug & G_DEBUG) {
printf("found alternative region %p (old was %p) - at %d %d (sa: %d %d -> %d %d)\n",
current_region, p->ar, event->x, event->y,
p->sa->totrct.xmin, p->sa->totrct.ymin, p->sa->totrct.xmax, p->sa->totrct.ymax);
}
-
+
if (current_region) {
/* Assume that since we found the cursor in here, it is in bounds
* and that this should be the region that we begin drawing in
@@ -2597,14 +2600,14 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* Out of bounds, or invalid in some other way */
p->status = GP_STATUS_ERROR;
estate = OPERATOR_CANCELLED;
-
+
if (G.debug & G_DEBUG)
printf("%s: Region under cursor is out of bounds, so cannot be drawn on\n", __func__);
}
}
else if (p->ar) {
rcti region_rect;
-
+
/* Perform bounds check using */
ED_region_visible_rect(p->ar, &region_rect);
in_bounds = BLI_rcti_isect_pt_v(&region_rect, event->mval);
@@ -2613,11 +2616,11 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* No region */
p->status = GP_STATUS_ERROR;
estate = OPERATOR_CANCELLED;
-
+
if (G.debug & G_DEBUG)
printf("%s: No active region found in GP Paint session data\n", __func__);
}
-
+
if (in_bounds) {
/* Switch paintmode (temporarily if need be) based on which button was used
* NOTE: This is to make it more convenient to erase strokes when using drawing sessions
@@ -2630,18 +2633,18 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* restore drawmode to default */
p->paintmode = RNA_enum_get(op->ptr, "mode");
}
-
+
gpencil_draw_toggle_eraser_cursor(C, p, p->paintmode == GP_PAINTMODE_ERASER);
-
+
/* not painting, so start stroke (this should be mouse-button down) */
p = gpencil_stroke_begin(C, op);
-
+
if (p->status == GP_STATUS_ERROR) {
estate = OPERATOR_CANCELLED;
}
}
else if (p->status != GP_STATUS_ERROR) {
- /* User clicked outside bounds of window while idling, so exit paintmode
+ /* User clicked outside bounds of window while idling, so exit paintmode
* NOTE: Don't enter this case if an error occurred while finding the
* region (as above)
*/
@@ -2657,12 +2660,12 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
estate = OPERATOR_FINISHED;
}
}
- else {
+ else if (event->val == KM_RELEASE) {
p->status = GP_STATUS_IDLING;
op->flag |= OP_IS_MODAL_CURSOR_REGION;
}
}
-
+
/* handle mode-specific events */
if (p->status == GP_STATUS_PAINTING) {
/* handle painting mouse-movements? */
@@ -2695,19 +2698,19 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
case PADPLUSKEY:
p->radius += 5;
break;
-
+
case WHEELUPMOUSE: /* smaller */
case PADMINUS:
p->radius -= 5;
-
+
if (p->radius <= 0)
p->radius = 1;
break;
}
-
+
/* force refresh */
ED_region_tag_redraw(p->ar); /* just active area for now, since doing whole screen is too slow */
-
+
/* event handled, so just tag as running modal */
estate = OPERATOR_RUNNING_MODAL;
}
@@ -2719,7 +2722,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
estate = OPERATOR_RUNNING_MODAL;
}
}
-
+
/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
if (0 == gpencil_area_exists(C, p->sa))
estate = OPERATOR_CANCELLED;
@@ -2728,7 +2731,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
gpencil_draw_status_indicators(p);
gpencil_draw_cursor_set(p); /* cursor may have changed outside our control - T44084 */
}
-
+
/* process last operations before exiting */
switch (estate) {
case OPERATOR_FINISHED:
@@ -2736,11 +2739,11 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
gpencil_draw_exit(C, op);
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
break;
-
+
case OPERATOR_CANCELLED:
gpencil_draw_exit(C, op);
break;
-
+
case OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH:
/* event doesn't need to be handled */
#if 0
@@ -2749,7 +2752,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
#endif
break;
}
-
+
/* return status code */
return estate;
}
@@ -2767,28 +2770,28 @@ static const EnumPropertyItem prop_gpencil_drawmodes[] = {
void GPENCIL_OT_draw(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Grease Pencil Draw";
ot->idname = "GPENCIL_OT_draw";
ot->description = "Make annotations on the active data";
-
+
/* api callbacks */
ot->exec = gpencil_draw_exec;
ot->invoke = gpencil_draw_invoke;
ot->modal = gpencil_draw_modal;
ot->cancel = gpencil_draw_cancel;
ot->poll = gpencil_draw_poll;
-
+
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING;
-
+
/* settings for drawing */
ot->prop = RNA_def_enum(ot->srna, "mode", prop_gpencil_drawmodes, 0, "Mode", "Way to interpret mouse movements");
prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
-
+
/* NOTE: wait for input is enabled by default, so that all UI code can work properly without needing users to know about this */
prop = RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input", "Wait for first click instead of painting immediately");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index dc3483163bf..ac0b046e499 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -70,14 +70,14 @@
static int gpencil_select_poll(bContext *C)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
-
+
/* we just need some visible strokes, and to be in editmode */
if ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE)) {
/* TODO: include a check for visible strokes? */
if (gpd->layers.first)
return true;
}
-
+
return false;
}
@@ -88,16 +88,16 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
int action = RNA_enum_get(op->ptr, "action");
-
+
if (gpd == NULL) {
BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
return OPERATOR_CANCELLED;
}
-
+
/* for "toggle", test for existing selected strokes */
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
-
+
CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes)
{
if (gps->flag & GP_STROKE_SELECT) {
@@ -107,7 +107,7 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
}
-
+
/* if deselecting, we need to deselect strokes across all frames
* - Currently, an exception is only given for deselection
* Selecting and toggling should only affect what's visible,
@@ -122,21 +122,21 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
{
bGPDframe *gpf;
-
+
/* deselect all strokes on all frames */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
bGPDstroke *gps;
-
+
for (gps = gpf->strokes.first; gps; gps = gps->next) {
bGPDspoint *pt;
int i;
-
+
/* only edit strokes that are valid in this view... */
if (ED_gpencil_stroke_can_use(C, gps)) {
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
pt->flag &= ~GP_SPOINT_SELECT;
}
-
+
gps->flag &= ~GP_STROKE_SELECT;
}
}
@@ -151,7 +151,7 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op)
bGPDspoint *pt;
int i;
bool selected = false;
-
+
/* Change selection status of all points, then make the stroke match */
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
switch (action) {
@@ -165,11 +165,11 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op)
pt->flag ^= GP_SPOINT_SELECT;
break;
}
-
+
if (pt->flag & GP_SPOINT_SELECT)
selected = true;
}
-
+
/* Change status of stroke */
if (selected)
gps->flag |= GP_STROKE_SELECT;
@@ -178,7 +178,7 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
}
-
+
/* updates */
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -190,14 +190,14 @@ void GPENCIL_OT_select_all(wmOperatorType *ot)
ot->name = "(De)select All Strokes";
ot->idname = "GPENCIL_OT_select_all";
ot->description = "Change selection of all Grease Pencil strokes currently visible";
-
+
/* callbacks */
ot->exec = gpencil_select_all_exec;
ot->poll = gpencil_select_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
WM_operator_properties_select_all(ot);
}
@@ -207,26 +207,26 @@ void GPENCIL_OT_select_all(wmOperatorType *ot)
static int gpencil_select_linked_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
-
+
if (gpd == NULL) {
BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
return OPERATOR_CANCELLED;
}
-
+
/* select all points in selected strokes */
CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes)
{
if (gps->flag & GP_STROKE_SELECT) {
bGPDspoint *pt;
int i;
-
+
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
pt->flag |= GP_SPOINT_SELECT;
}
}
}
CTX_DATA_END;
-
+
/* updates */
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -238,11 +238,11 @@ void GPENCIL_OT_select_linked(wmOperatorType *ot)
ot->name = "Select Linked";
ot->idname = "GPENCIL_OT_select_linked";
ot->description = "Select all points in same strokes as already selected points";
-
+
/* callbacks */
ot->exec = gpencil_select_linked_exec;
ot->poll = gpencil_select_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -253,10 +253,10 @@ void GPENCIL_OT_select_linked(wmOperatorType *ot)
typedef enum eGP_SelectGrouped {
/* Select strokes in the same layer */
GP_SEL_SAME_LAYER = 0,
-
+
/* Select strokes with the same color */
GP_SEL_SAME_COLOR = 1,
-
+
/* TODO: All with same prefix - Useful for isolating all layers for a particular character for instance */
/* TODO: All with same appearance - colour/opacity/volumetric/fills ? */
} eGP_SelectGrouped;
@@ -267,16 +267,16 @@ typedef enum eGP_SelectGrouped {
static void gp_select_same_layer(bContext *C)
{
Scene *scene = CTX_data_scene(C);
-
+
CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
{
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, 0);
bGPDstroke *gps;
bool found = false;
-
+
if (gpf == NULL)
continue;
-
+
/* Search for a selected stroke */
for (gps = gpf->strokes.first; gps; gps = gps->next) {
if (ED_gpencil_stroke_can_use(C, gps)) {
@@ -286,18 +286,18 @@ static void gp_select_same_layer(bContext *C)
}
}
}
-
+
/* Select all if found */
if (found) {
for (gps = gpf->strokes.first; gps; gps = gps->next) {
if (ED_gpencil_stroke_can_use(C, gps)) {
bGPDspoint *pt;
int i;
-
+
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
pt->flag |= GP_SPOINT_SELECT;
}
-
+
gps->flag |= GP_STROKE_SELECT;
}
}
@@ -310,11 +310,11 @@ static void gp_select_same_layer(bContext *C)
static void gp_select_same_color(bContext *C)
{
/* First, build set containing all the colors of selected strokes
- * - We use the palette names, so that we can select all strokes with one
+ * - We use the palette names, so that we can select all strokes with one
* (potentially missing) color, and remap them to something else
*/
GSet *selected_colors = BLI_gset_str_new("GP Selected Colors");
-
+
CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes)
{
if (gps->flag & GP_STROKE_SELECT) {
@@ -325,7 +325,7 @@ static void gp_select_same_color(bContext *C)
}
}
CTX_DATA_END;
-
+
/* Second, select any visible stroke that uses these colors */
CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes)
{
@@ -333,11 +333,11 @@ static void gp_select_same_color(bContext *C)
/* select this stroke */
bGPDspoint *pt;
int i;
-
+
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
pt->flag |= GP_SPOINT_SELECT;
}
-
+
gps->flag |= GP_STROKE_SELECT;
}
}
@@ -350,7 +350,7 @@ static void gp_select_same_color(bContext *C)
static int gpencil_select_grouped_exec(bContext *C, wmOperator *op)
{
eGP_SelectGrouped mode = RNA_enum_get(op->ptr, "type");
-
+
switch (mode) {
case GP_SEL_SAME_LAYER:
gp_select_same_layer(C);
@@ -358,12 +358,12 @@ static int gpencil_select_grouped_exec(bContext *C, wmOperator *op)
case GP_SEL_SAME_COLOR:
gp_select_same_color(C);
break;
-
+
default:
BLI_assert(!"unhandled select grouped gpencil mode");
break;
}
-
+
/* updates */
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -376,20 +376,20 @@ void GPENCIL_OT_select_grouped(wmOperatorType *ot)
{GP_SEL_SAME_COLOR, "COLOR", 0, "Color", "Shared colors"},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "Select Grouped";
ot->idname = "GPENCIL_OT_select_grouped";
ot->description = "Select all strokes with similar characteristics";
-
+
/* callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = gpencil_select_grouped_exec;
ot->poll = gpencil_select_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
ot->prop = RNA_def_enum(ot->srna, "type", prop_select_grouped_types, GP_SEL_SAME_LAYER, "Type", "");
}
@@ -401,33 +401,33 @@ static int gpencil_select_first_exec(bContext *C, wmOperator *op)
{
const bool only_selected = RNA_boolean_get(op->ptr, "only_selected_strokes");
const bool extend = RNA_boolean_get(op->ptr, "extend");
-
+
CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes)
{
/* skip stroke if we're only manipulating selected strokes */
if (only_selected && !(gps->flag & GP_STROKE_SELECT)) {
continue;
}
-
+
/* select first point */
BLI_assert(gps->totpoints >= 1);
-
+
gps->points->flag |= GP_SPOINT_SELECT;
gps->flag |= GP_STROKE_SELECT;
-
+
/* deselect rest? */
if ((extend == false) && (gps->totpoints > 1)) {
/* start from index 1, to skip the first point that we'd just selected... */
bGPDspoint *pt = &gps->points[1];
int i = 1;
-
+
for (; i < gps->totpoints; i++, pt++) {
pt->flag &= ~GP_SPOINT_SELECT;
}
}
}
CTX_DATA_END;
-
+
/* updates */
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -439,18 +439,18 @@ void GPENCIL_OT_select_first(wmOperatorType *ot)
ot->name = "Select First";
ot->idname = "GPENCIL_OT_select_first";
ot->description = "Select first point in Grease Pencil strokes";
-
+
/* callbacks */
ot->exec = gpencil_select_first_exec;
ot->poll = gpencil_select_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "only_selected_strokes", false, "Selected Strokes Only",
"Only select the first point of strokes that already have points selected");
-
+
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting all other selected points");
}
@@ -461,33 +461,33 @@ static int gpencil_select_last_exec(bContext *C, wmOperator *op)
{
const bool only_selected = RNA_boolean_get(op->ptr, "only_selected_strokes");
const bool extend = RNA_boolean_get(op->ptr, "extend");
-
+
CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes)
{
/* skip stroke if we're only manipulating selected strokes */
if (only_selected && !(gps->flag & GP_STROKE_SELECT)) {
continue;
}
-
+
/* select last point */
BLI_assert(gps->totpoints >= 1);
-
+
gps->points[gps->totpoints - 1].flag |= GP_SPOINT_SELECT;
gps->flag |= GP_STROKE_SELECT;
-
+
/* deselect rest? */
if ((extend == false) && (gps->totpoints > 1)) {
/* don't include the last point... */
bGPDspoint *pt = gps->points;
int i = 1;
-
+
for (; i < gps->totpoints - 1; i++, pt++) {
pt->flag &= ~GP_SPOINT_SELECT;
}
}
}
CTX_DATA_END;
-
+
/* updates */
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -499,18 +499,18 @@ void GPENCIL_OT_select_last(wmOperatorType *ot)
ot->name = "Select Last";
ot->idname = "GPENCIL_OT_select_last";
ot->description = "Select last point in Grease Pencil strokes";
-
+
/* callbacks */
ot->exec = gpencil_select_last_exec;
ot->poll = gpencil_select_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "only_selected_strokes", false, "Selected Strokes Only",
"Only select the last point of strokes that already have points selected");
-
+
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting all other selected points");
}
@@ -525,8 +525,8 @@ static int gpencil_select_more_exec(bContext *C, wmOperator *UNUSED(op))
bGPDspoint *pt;
int i;
bool prev_sel;
-
- /* First Pass: Go in forward order, expanding selection if previous was selected (pre changes)...
+
+ /* First Pass: Go in forward order, expanding selection if previous was selected (pre changes)...
* - This pass covers the "after" edges of selection islands
*/
prev_sel = false;
@@ -543,8 +543,8 @@ static int gpencil_select_more_exec(bContext *C, wmOperator *UNUSED(op))
prev_sel = false;
}
}
-
- /* Second Pass: Go in reverse order, doing the same as before (except in opposite order)
+
+ /* Second Pass: Go in reverse order, doing the same as before (except in opposite order)
* - This pass covers the "before" edges of selection islands
*/
prev_sel = false;
@@ -563,7 +563,7 @@ static int gpencil_select_more_exec(bContext *C, wmOperator *UNUSED(op))
}
}
CTX_DATA_END;
-
+
/* updates */
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -575,11 +575,11 @@ void GPENCIL_OT_select_more(wmOperatorType *ot)
ot->name = "Select More";
ot->idname = "GPENCIL_OT_select_more";
ot->description = "Grow sets of selected Grease Pencil points";
-
+
/* callbacks */
ot->exec = gpencil_select_more_exec;
ot->poll = gpencil_select_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -595,8 +595,8 @@ static int gpencil_select_less_exec(bContext *C, wmOperator *UNUSED(op))
bGPDspoint *pt;
int i;
bool prev_sel;
-
- /* First Pass: Go in forward order, shrinking selection if previous was not selected (pre changes)...
+
+ /* First Pass: Go in forward order, shrinking selection if previous was not selected (pre changes)...
* - This pass covers the "after" edges of selection islands
*/
prev_sel = false;
@@ -613,8 +613,8 @@ static int gpencil_select_less_exec(bContext *C, wmOperator *UNUSED(op))
prev_sel = false;
}
}
-
- /* Second Pass: Go in reverse order, doing the same as before (except in opposite order)
+
+ /* Second Pass: Go in reverse order, doing the same as before (except in opposite order)
* - This pass covers the "before" edges of selection islands
*/
prev_sel = false;
@@ -634,7 +634,7 @@ static int gpencil_select_less_exec(bContext *C, wmOperator *UNUSED(op))
}
}
CTX_DATA_END;
-
+
/* updates */
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -646,11 +646,11 @@ void GPENCIL_OT_select_less(wmOperatorType *ot)
ot->name = "Select Less";
ot->idname = "GPENCIL_OT_select_less";
ot->description = "Shrink sets of selected Grease Pencil points";
-
+
/* callbacks */
ot->exec = gpencil_select_less_exec;
ot->poll = gpencil_select_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -671,7 +671,7 @@ static bool gp_stroke_do_circle_sel(
int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
int i;
bool changed = false;
-
+
if (gps->totpoints == 1) {
if (!parented) {
gp_point_to_xy(gsc, gps, gps->points, &x0, &y0);
@@ -681,7 +681,7 @@ static bool gp_stroke_do_circle_sel(
gp_point_to_parent_space(gps->points, diff_mat, &pt_temp);
gp_point_to_xy(gsc, gps, &pt_temp, &x0, &y0);
}
-
+
/* do boundbox check first */
if ((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(rect, x0, y0)) {
/* only check if point is inside */
@@ -695,13 +695,13 @@ static bool gp_stroke_do_circle_sel(
gps->points->flag &= ~GP_SPOINT_SELECT;
gps->flag &= ~GP_STROKE_SELECT;
}
-
+
return true;
}
}
}
else {
- /* Loop over the points in the stroke, checking for intersections
+ /* Loop over the points in the stroke, checking for intersections
* - an intersection means that we touched the stroke
*/
for (i = 0; (i + 1) < gps->totpoints; i++) {
@@ -720,43 +720,43 @@ static bool gp_stroke_do_circle_sel(
gp_point_to_parent_space(pt2, diff_mat, &npt);
gp_point_to_xy(gsc, gps, &npt, &x1, &y1);
}
-
+
/* check that point segment of the boundbox of the selection stroke */
if (((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(rect, x0, y0)) ||
((!ELEM(V2D_IS_CLIPPED, x1, y1)) && BLI_rcti_isect_pt(rect, x1, y1)))
{
int mval[2] = {mx, my};
int mvalo[2] = {mx, my}; /* dummy - this isn't used... */
-
+
/* check if point segment of stroke had anything to do with
* eraser region (either within stroke painted, or on its lines)
* - this assumes that linewidth is irrelevant
*/
if (gp_stroke_inside_circle(mval, mvalo, radius, x0, y0, x1, y1)) {
- /* change selection of stroke, and then of both points
+ /* change selection of stroke, and then of both points
* (as the last point otherwise wouldn't get selected
- * as we only do n-1 loops through)
+ * as we only do n-1 loops through)
*/
if (select) {
pt1->flag |= GP_SPOINT_SELECT;
pt2->flag |= GP_SPOINT_SELECT;
-
+
changed = true;
}
else {
pt1->flag &= ~GP_SPOINT_SELECT;
pt2->flag &= ~GP_SPOINT_SELECT;
-
+
changed = true;
}
}
}
}
-
+
/* Ensure that stroke selection is in sync with its points */
BKE_gpencil_stroke_sync_selection(gps);
}
-
+
return changed;
}
@@ -764,36 +764,36 @@ static bool gp_stroke_do_circle_sel(
static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
{
ScrArea *sa = CTX_wm_area(C);
-
+
const int mx = RNA_int_get(op->ptr, "x");
const int my = RNA_int_get(op->ptr, "y");
const int radius = RNA_int_get(op->ptr, "radius");
-
+
bool select = !RNA_boolean_get(op->ptr, "deselect");
-
+
GP_SpaceConversion gsc = {NULL};
rcti rect = {0}; /* for bounding rect around circle (for quicky intersection testing) */
-
+
bool changed = false;
-
-
+
+
/* sanity checks */
if (sa == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active area");
return OPERATOR_CANCELLED;
}
-
+
/* init space conversion stuff */
gp_point_conversion_init(C, &gsc);
-
-
+
+
/* rect is rectangle of selection circle */
rect.xmin = mx - radius;
rect.ymin = my - radius;
rect.xmax = mx + radius;
rect.ymax = my + radius;
-
-
+
+
/* find visible strokes, and select if hit */
GP_EDITABLE_STROKES_BEGIN(C, gpl, gps)
{
@@ -807,7 +807,7 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
if (changed) {
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
}
-
+
return OPERATOR_FINISHED;
}
@@ -817,17 +817,17 @@ void GPENCIL_OT_select_circle(wmOperatorType *ot)
ot->name = "Circle Select";
ot->description = "Select Grease Pencil strokes using brush selection";
ot->idname = "GPENCIL_OT_select_circle";
-
+
/* callbacks */
ot->invoke = WM_gesture_circle_invoke;
ot->modal = WM_gesture_circle_modal;
ot->exec = gpencil_circle_select_exec;
ot->poll = gpencil_select_poll;
ot->cancel = WM_gesture_circle_cancel;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
WM_operator_properties_gesture_circle_select(ot);
}
@@ -838,45 +838,45 @@ void GPENCIL_OT_select_circle(wmOperatorType *ot)
static int gpencil_border_select_exec(bContext *C, wmOperator *op)
{
ScrArea *sa = CTX_wm_area(C);
-
+
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
-
+
GP_SpaceConversion gsc = {NULL};
rcti rect = {0};
-
+
bool changed = false;
-
-
+
+
/* sanity checks */
if (sa == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active area");
return OPERATOR_CANCELLED;
}
-
+
/* init space conversion stuff */
gp_point_conversion_init(C, &gsc);
-
-
+
+
/* deselect all strokes first? */
if (select && !extend) {
CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes)
{
bGPDspoint *pt;
int i;
-
+
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
pt->flag &= ~GP_SPOINT_SELECT;
}
-
+
gps->flag &= ~GP_STROKE_SELECT;
}
CTX_DATA_END;
}
-
+
/* get settings from operator */
WM_operator_properties_border_to_rcti(op, &rect);
-
+
/* select/deselect points */
GP_EDITABLE_STROKES_BEGIN(C, gpl, gps)
{
@@ -919,7 +919,7 @@ static int gpencil_border_select_exec(bContext *C, wmOperator *op)
if (changed) {
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
}
-
+
return OPERATOR_FINISHED;
}
@@ -929,18 +929,18 @@ void GPENCIL_OT_select_border(wmOperatorType *ot)
ot->name = "Border Select";
ot->description = "Select Grease Pencil strokes within a rectangular region";
ot->idname = "GPENCIL_OT_select_border";
-
+
/* callbacks */
ot->invoke = WM_gesture_border_invoke;
ot->exec = gpencil_border_select_exec;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
-
+
ot->poll = gpencil_select_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* rna */
WM_operator_properties_gesture_border_select(ot);
}
@@ -952,41 +952,41 @@ static int gpencil_lasso_select_exec(bContext *C, wmOperator *op)
{
GP_SpaceConversion gsc = {NULL};
rcti rect = {0};
-
+
const bool extend = RNA_boolean_get(op->ptr, "extend");
const bool select = !RNA_boolean_get(op->ptr, "deselect");
-
+
int mcords_tot;
const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
-
+
bool changed = false;
-
+
/* sanity check */
if (mcords == NULL)
return OPERATOR_PASS_THROUGH;
-
+
/* compute boundbox of lasso (for faster testing later) */
BLI_lasso_boundbox(&rect, mcords, mcords_tot);
-
+
/* init space conversion stuff */
gp_point_conversion_init(C, &gsc);
-
+
/* deselect all strokes first? */
if (select && !extend) {
CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes)
{
bGPDspoint *pt;
int i;
-
+
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
pt->flag &= ~GP_SPOINT_SELECT;
}
-
+
gps->flag &= ~GP_STROKE_SELECT;
}
CTX_DATA_END;
}
-
+
/* select/deselect points */
GP_EDITABLE_STROKES_BEGIN(C, gpl, gps)
{
@@ -1027,12 +1027,12 @@ static int gpencil_lasso_select_exec(bContext *C, wmOperator *op)
/* cleanup */
MEM_freeN((void *)mcords);
-
+
/* updates */
if (changed) {
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
}
-
+
return OPERATOR_FINISHED;
}
@@ -1041,16 +1041,16 @@ void GPENCIL_OT_select_lasso(wmOperatorType *ot)
ot->name = "Lasso Select Strokes";
ot->description = "Select Grease Pencil strokes using lasso selection";
ot->idname = "GPENCIL_OT_select_lasso";
-
+
ot->invoke = WM_gesture_lasso_invoke;
ot->modal = WM_gesture_lasso_modal;
ot->exec = gpencil_lasso_select_exec;
ot->poll = gpencil_select_poll;
ot->cancel = WM_gesture_lasso_cancel;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
-
+
/* properties */
WM_operator_properties_gesture_lasso_select(ot);
}
@@ -1061,36 +1061,36 @@ void GPENCIL_OT_select_lasso(wmOperatorType *ot)
static int gpencil_select_exec(bContext *C, wmOperator *op)
{
ScrArea *sa = CTX_wm_area(C);
-
+
/* "radius" is simply a threshold (screen space) to make it easier to test with a tolerance */
const float radius = 0.75f * U.widget_unit;
const int radius_squared = (int)(radius * radius);
-
+
bool extend = RNA_boolean_get(op->ptr, "extend");
bool deselect = RNA_boolean_get(op->ptr, "deselect");
bool toggle = RNA_boolean_get(op->ptr, "toggle");
bool whole = RNA_boolean_get(op->ptr, "entire_strokes");
-
+
int mval[2] = {0};
-
+
GP_SpaceConversion gsc = {NULL};
-
+
bGPDstroke *hit_stroke = NULL;
bGPDspoint *hit_point = NULL;
int hit_distance = radius_squared;
-
+
/* sanity checks */
if (sa == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active area");
return OPERATOR_CANCELLED;
}
-
+
/* init space conversion stuff */
gp_point_conversion_init(C, &gsc);
-
+
/* get mouse location */
RNA_int_get_array(op->ptr, "location", mval);
-
+
/* First Pass: Find stroke point which gets hit */
/* XXX: maybe we should go from the top of the stack down instead... */
GP_EDITABLE_STROKES_BEGIN(C, gpl, gps)
@@ -1133,38 +1133,38 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
if (ELEM(NULL, hit_stroke, hit_point)) {
return OPERATOR_CANCELLED;
}
-
+
/* adjust selection behaviour - for toggle option */
if (toggle) {
deselect = (hit_point->flag & GP_SPOINT_SELECT) != 0;
}
-
+
/* If not extending selection, deselect everything else */
if (extend == false) {
CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes)
- {
+ {
/* deselect stroke and its points if selected */
if (gps->flag & GP_STROKE_SELECT) {
bGPDspoint *pt;
int i;
-
+
/* deselect points */
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
pt->flag &= ~GP_SPOINT_SELECT;
}
-
+
/* deselect stroke itself too */
gps->flag &= ~GP_STROKE_SELECT;
}
}
CTX_DATA_END;
}
-
+
/* Perform selection operations... */
if (whole) {
bGPDspoint *pt;
int i;
-
+
/* entire stroke's points */
for (i = 0, pt = hit_stroke->points; i < hit_stroke->totpoints; i++, pt++) {
if (deselect == false)
@@ -1172,7 +1172,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
else
pt->flag &= ~GP_SPOINT_SELECT;
}
-
+
/* stroke too... */
if (deselect == false)
hit_stroke->flag |= GP_STROKE_SELECT;
@@ -1189,17 +1189,17 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
else {
/* deselect point */
hit_point->flag &= ~GP_SPOINT_SELECT;
-
+
/* ensure that stroke is selected correctly */
BKE_gpencil_stroke_sync_selection(hit_stroke);
}
}
-
+
/* updates */
if (hit_point != NULL) {
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
}
-
+
return OPERATOR_FINISHED;
}
@@ -1212,26 +1212,26 @@ static int gpencil_select_invoke(bContext *C, wmOperator *op, const wmEvent *eve
void GPENCIL_OT_select(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Select";
ot->description = "Select Grease Pencil strokes and/or stroke points";
ot->idname = "GPENCIL_OT_select";
-
+
/* callbacks */
ot->invoke = gpencil_select_invoke;
ot->exec = gpencil_select_exec;
ot->poll = gpencil_select_poll;
-
+
/* flag */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
WM_operator_properties_mouse_select(ot);
-
+
prop = RNA_def_boolean(ot->srna, "entire_strokes", false, "Entire Strokes", "Select entire strokes instead of just the nearest stroke vertex");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-
+
prop = RNA_def_int_vector(ot->srna, "location", 2, NULL, INT_MIN, INT_MAX, "Location", "Mouse location", INT_MIN, INT_MAX);
RNA_def_property_flag(prop, PROP_HIDDEN);
}
diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c
index 202d7630ae0..5e2be7c41f0 100644
--- a/source/blender/editors/gpencil/gpencil_undo.c
+++ b/source/blender/editors/gpencil/gpencil_undo.c
@@ -55,7 +55,7 @@
typedef struct bGPundonode {
struct bGPundonode *next, *prev;
-
+
char name[BKE_UNDO_STR_MAX];
struct bGPdata *gpd;
} bGPundonode;
@@ -71,9 +71,9 @@ int ED_gpencil_session_active(void)
int ED_undo_gpencil_step(bContext *C, int step, const char *name)
{
bGPdata **gpd_ptr = NULL, *new_gpd = NULL;
-
+
gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
-
+
if (step == 1) { /* undo */
//printf("\t\tGP - undo step\n");
if (cur_node->prev) {
@@ -92,18 +92,18 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name)
}
}
}
-
+
if (new_gpd) {
if (gpd_ptr) {
if (*gpd_ptr) {
bGPdata *gpd = *gpd_ptr;
bGPDlayer *gpl, *gpld;
-
+
BKE_gpencil_free_layers(&gpd->layers);
-
+
/* copy layers */
BLI_listbase_clear(&gpd->layers);
-
+
for (gpl = new_gpd->layers.first; gpl; gpl = gpl->next) {
/* make a copy of source layer and its data */
gpld = BKE_gpencil_layer_duplicate(gpl);
@@ -112,9 +112,9 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name)
}
}
}
-
+
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -129,7 +129,7 @@ static void gpencil_undo_free_node(bGPundonode *undo_node)
* or else the real copy will segfault when accessed
*/
undo_node->gpd->adt = NULL;
-
+
BKE_gpencil_free(undo_node->gpd, false);
MEM_freeN(undo_node->gpd);
}
@@ -137,65 +137,65 @@ static void gpencil_undo_free_node(bGPundonode *undo_node)
void gpencil_undo_push(bGPdata *gpd)
{
bGPundonode *undo_node;
-
+
//printf("\t\tGP - undo push\n");
-
+
if (cur_node) {
/* remove all un-done nodes from stack */
undo_node = cur_node->next;
-
+
while (undo_node) {
bGPundonode *next_node = undo_node->next;
-
+
gpencil_undo_free_node(undo_node);
BLI_freelinkN(&undo_nodes, undo_node);
-
+
undo_node = next_node;
}
}
-
+
/* limit number of undo steps to the maximum undo steps
- * - to prevent running out of memory during **really**
+ * - to prevent running out of memory during **really**
* long drawing sessions (triggering swapping)
*/
/* TODO: Undo-memory constraint is not respected yet, but can be added if we have any need for it */
if (U.undosteps && !BLI_listbase_is_empty(&undo_nodes)) {
/* remove anything older than n-steps before cur_node */
int steps = 0;
-
+
undo_node = (cur_node) ? cur_node : undo_nodes.last;
while (undo_node) {
bGPundonode *prev_node = undo_node->prev;
-
+
if (steps >= U.undosteps) {
gpencil_undo_free_node(undo_node);
BLI_freelinkN(&undo_nodes, undo_node);
}
-
+
steps++;
undo_node = prev_node;
}
}
-
+
/* create new undo node */
undo_node = MEM_callocN(sizeof(bGPundonode), "gpencil undo node");
undo_node->gpd = BKE_gpencil_data_duplicate(G.main, gpd, true);
-
+
cur_node = undo_node;
-
+
BLI_addtail(&undo_nodes, undo_node);
}
void gpencil_undo_finish(void)
{
bGPundonode *undo_node = undo_nodes.first;
-
+
while (undo_node) {
gpencil_undo_free_node(undo_node);
undo_node = undo_node->next;
}
-
+
BLI_freelistN(&undo_nodes);
-
+
cur_node = NULL;
}
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index babe68ba439..f6d72d9e575 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -47,10 +47,11 @@
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
+#include "BKE_action.h"
#include "BKE_context.h"
#include "BKE_gpencil.h"
+#include "BKE_main.h"
#include "BKE_tracking.h"
-#include "BKE_action.h"
#include "WM_api.h"
@@ -82,16 +83,16 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ID *screen_id, Scene *scene, ScrAr
*/
if (sa) {
SpaceLink *sl = sa->spacedata.first;
-
+
switch (sa->spacetype) {
case SPACE_VIEW3D: /* 3D-View */
{
BLI_assert(scene && ELEM(scene->toolsettings->gpencil_src,
GP_TOOL_SOURCE_SCENE, GP_TOOL_SOURCE_OBJECT));
-
+
if (scene->toolsettings->gpencil_src == GP_TOOL_SOURCE_OBJECT) {
/* legacy behaviour for usage with old addons requiring object-linked to objects */
-
+
/* just in case no active/selected object... */
if (ob && (ob->flag & SELECT)) {
/* for now, as long as there's an object, default to using that in 3D-View */
@@ -109,21 +110,21 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ID *screen_id, Scene *scene, ScrAr
case SPACE_NODE: /* Nodes Editor */
{
SpaceNode *snode = (SpaceNode *)sl;
-
+
/* return the GP data for the active node block/node */
if (snode && snode->nodetree) {
/* for now, as long as there's an active node tree, default to using that in the Nodes Editor */
if (ptr) RNA_id_pointer_create(&snode->nodetree->id, ptr);
return &snode->nodetree->gpd;
}
-
+
/* even when there is no node-tree, don't allow this to flow to scene */
return NULL;
}
case SPACE_SEQ: /* Sequencer */
{
SpaceSeq *sseq = (SpaceSeq *)sl;
-
+
/* for now, Grease Pencil data is associated with the space (actually preview region only) */
/* XXX our convention for everything else is to link to data though... */
if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceSequenceEditor, sseq, ptr);
@@ -132,7 +133,7 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ID *screen_id, Scene *scene, ScrAr
case SPACE_IMAGE: /* Image/UV Editor */
{
SpaceImage *sima = (SpaceImage *)sl;
-
+
/* for now, Grease Pencil data is associated with the space... */
/* XXX our convention for everything else is to link to data though... */
if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceImageEditor, sima, ptr);
@@ -142,23 +143,23 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ID *screen_id, Scene *scene, ScrAr
{
SpaceClip *sc = (SpaceClip *)sl;
MovieClip *clip = ED_space_clip_get_clip(sc);
-
+
if (clip) {
if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
MovieTrackingTrack *track = BKE_tracking_track_get_active(&clip->tracking);
-
+
if (!track)
return NULL;
-
+
if (ptr)
RNA_pointer_create(&clip->id, &RNA_MovieTrackingTrack, track, ptr);
-
+
return &track->gpd;
}
else {
if (ptr)
RNA_id_pointer_create(&clip->id, ptr);
-
+
return &clip->gpd;
}
}
@@ -168,7 +169,7 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ID *screen_id, Scene *scene, ScrAr
return NULL;
}
}
-
+
/* just fall back on the scene's GP data */
if (ptr) RNA_id_pointer_create((ID *)scene, ptr);
return (scene) ? &scene->gpd : NULL;
@@ -181,7 +182,7 @@ bGPdata **ED_gpencil_data_get_pointers(const bContext *C, PointerRNA *ptr)
Scene *scene = CTX_data_scene(C);
ScrArea *sa = CTX_wm_area(C);
Object *ob = CTX_data_active_object(C);
-
+
return ED_gpencil_data_get_pointers_direct(screen_id, scene, sa, ob, ptr);
}
@@ -211,7 +212,7 @@ bGPdata *ED_gpencil_data_get_active_v3d(Scene *scene, ViewLayer *view_layer)
/* We have to make sure active object is actually visible and selected, else we must use default scene gpd,
* to be consistent with ED_gpencil_data_get_active's behavior.
*/
-
+
if (base && TESTBASE(base)) {
gpd = base->object->gpd;
}
@@ -239,7 +240,7 @@ bool ED_gpencil_has_keyframe_v3d(Scene *scene, Object *ob, int cfra)
}
}
}
-
+
if (ob && ob->gpd) {
bGPDlayer *gpl = BKE_gpencil_layer_getactive(ob->gpd);
if (gpl) {
@@ -253,7 +254,7 @@ bool ED_gpencil_has_keyframe_v3d(Scene *scene, Object *ob, int cfra)
}
}
}
-
+
return false;
}
@@ -272,7 +273,7 @@ int gp_active_layer_poll(bContext *C)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
-
+
return (gpl != NULL);
}
@@ -317,25 +318,25 @@ const EnumPropertyItem *ED_gpencil_layers_enum_itemf(
EnumPropertyItem *item = NULL, item_tmp = {0};
int totitem = 0;
int i = 0;
-
+
if (ELEM(NULL, C, gpd)) {
return DummyRNA_DEFAULT_items;
}
-
+
/* Existing layers */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next, i++) {
item_tmp.identifier = gpl->info;
item_tmp.name = gpl->info;
item_tmp.value = i;
-
+
if (gpl->flag & GP_LAYER_ACTIVE)
item_tmp.icon = ICON_GREASEPENCIL;
- else
+ else
item_tmp.icon = ICON_NONE;
-
+
RNA_enum_item_add(&item, &totitem, &item_tmp);
}
-
+
RNA_enum_item_end(&item, &totitem);
*r_free = true;
@@ -351,11 +352,11 @@ const EnumPropertyItem *ED_gpencil_layers_with_new_enum_itemf(
EnumPropertyItem *item = NULL, item_tmp = {0};
int totitem = 0;
int i = 0;
-
+
if (ELEM(NULL, C, gpd)) {
return DummyRNA_DEFAULT_items;
}
-
+
/* Create new layer */
/* TODO: have some way of specifying that we don't want this? */
{
@@ -365,25 +366,25 @@ const EnumPropertyItem *ED_gpencil_layers_with_new_enum_itemf(
item_tmp.value = -1;
item_tmp.icon = ICON_ZOOMIN;
RNA_enum_item_add(&item, &totitem, &item_tmp);
-
+
/* separator */
RNA_enum_item_add_separator(&item, &totitem);
}
-
+
/* Existing layers */
for (gpl = gpd->layers.first, i = 0; gpl; gpl = gpl->next, i++) {
item_tmp.identifier = gpl->info;
item_tmp.name = gpl->info;
item_tmp.value = i;
-
+
if (gpl->flag & GP_LAYER_ACTIVE)
item_tmp.icon = ICON_GREASEPENCIL;
- else
+ else
item_tmp.icon = ICON_NONE;
-
+
RNA_enum_item_add(&item, &totitem, &item_tmp);
}
-
+
RNA_enum_item_end(&item, &totitem);
*r_free = true;
@@ -412,11 +413,11 @@ bool gp_stroke_inside_circle(const int mval[2], const int UNUSED(mvalo[2]),
const float mval_fl[2] = {mval[0], mval[1]};
const float screen_co_a[2] = {x0, y0};
const float screen_co_b[2] = {x1, y1};
-
+
if (edge_inside_circle(mval_fl, rad, screen_co_a, screen_co_b)) {
return true;
}
-
+
/* not inside */
return false;
}
@@ -469,7 +470,7 @@ bool ED_gpencil_stroke_color_use(const bGPDlayer *gpl, const bGPDstroke *gps)
if (((gpl->flag & GP_LAYER_UNLOCK_COLOR) == 0) && (palcolor->flag & PC_COLOR_LOCKED))
return false;
}
-
+
return true;
}
@@ -524,30 +525,30 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
-
+
/* zero out the storage (just in case) */
memset(r_gsc, 0, sizeof(GP_SpaceConversion));
unit_m4(r_gsc->mat);
-
+
/* store settings */
r_gsc->sa = sa;
r_gsc->ar = ar;
r_gsc->v2d = &ar->v2d;
-
+
/* init region-specific stuff */
if (sa->spacetype == SPACE_VIEW3D) {
wmWindow *win = CTX_wm_window(C);
Scene *scene = CTX_data_scene(C);
- struct Depsgraph *graph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
View3D *v3d = (View3D *)CTX_wm_space_data(C);
RegionView3D *rv3d = ar->regiondata;
-
+
/* init 3d depth buffers */
view3d_operator_needs_opengl(C);
-
+
view3d_region_operator_needs_opengl(win, ar);
- ED_view3d_autodist_init(graph, ar, v3d, 0);
-
+ ED_view3d_autodist_init(depsgraph, ar, v3d, 0);
+
/* for camera view set the subrect */
if (rv3d->persp == RV3D_CAMOB) {
ED_view3d_calc_camera_border(scene, CTX_data_depsgraph(C), ar, v3d, rv3d, &r_gsc->subrect_data, true); /* no shift */
@@ -563,7 +564,7 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
* \param diff_mat Matrix with the difference between original parent matrix
* \param[out] r_pt Pointer to new point after apply matrix
*/
-void gp_point_to_parent_space(bGPDspoint *pt, float diff_mat[4][4], bGPDspoint *r_pt)
+void gp_point_to_parent_space(bGPDspoint *pt, float diff_mat[4][4], bGPDspoint *r_pt)
{
float fpt[3];
@@ -626,12 +627,12 @@ void gp_point_to_xy(GP_SpaceConversion *gsc, bGPDstroke *gps, bGPDspoint *pt,
View2D *v2d = gsc->v2d;
rctf *subrect = gsc->subrect;
int xyval[2];
-
+
/* sanity checks */
BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->sa->spacetype == SPACE_VIEW3D));
BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->sa->spacetype != SPACE_VIEW3D));
-
-
+
+
if (gps->flag & GP_STROKE_3DSPACE) {
if (ED_view3d_project_int_global(ar, &pt->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
*r_x = xyval[0];
@@ -679,12 +680,12 @@ void gp_point_to_xy_fl(GP_SpaceConversion *gsc, bGPDstroke *gps, bGPDspoint *pt,
View2D *v2d = gsc->v2d;
rctf *subrect = gsc->subrect;
float xyval[2];
-
+
/* sanity checks */
BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->sa->spacetype == SPACE_VIEW3D));
BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->sa->spacetype != SPACE_VIEW3D));
-
-
+
+
if (gps->flag & GP_STROKE_3DSPACE) {
if (ED_view3d_project_float_global(ar, &pt->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
*r_x = xyval[0];
@@ -698,10 +699,10 @@ void gp_point_to_xy_fl(GP_SpaceConversion *gsc, bGPDstroke *gps, bGPDspoint *pt,
else if (gps->flag & GP_STROKE_2DSPACE) {
float vec[3] = {pt->x, pt->y, 0.0f};
int t_x, t_y;
-
+
mul_m4_v3(gsc->mat, vec);
UI_view2d_view_to_region_clip(v2d, vec[0], vec[1], &t_x, &t_y);
-
+
if ((t_x == t_y) && (t_x == V2D_IS_CLIPPED)) {
/* XXX: Or should we just always use the values as-is? */
*r_x = 0.0f;
@@ -748,22 +749,22 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen
float *rvec = ED_view3d_cursor3d_get(scene, v3d)->location;
float ref[3] = {rvec[0], rvec[1], rvec[2]};
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
-
+
float mval_f[2], mval_prj[2];
float dvec[3];
-
+
copy_v2_v2(mval_f, screen_co);
-
+
if (ED_view3d_project_float_global(gsc->ar, ref, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
sub_v2_v2v2(mval_f, mval_prj, mval_f);
ED_view3d_win_to_delta(gsc->ar, mval_f, dvec, zfac);
sub_v3_v3v3(r_out, rvec, dvec);
-
+
return true;
}
else {
zero_v3(r_out);
-
+
return false;
}
}
@@ -780,19 +781,19 @@ bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf, bool affect_pressure)
bGPDspoint *pt = &gps->points[i];
float pressure = 0.0f;
float sco[3] = {0.0f};
-
+
/* Do nothing if not enough points to smooth out */
if (gps->totpoints <= 2) {
return false;
}
-
+
/* Only affect endpoints by a fraction of the normal strength,
* to prevent the stroke from shrinking too much
*/
if ((i == 0) || (i == gps->totpoints - 1)) {
inf *= 0.1f;
}
-
+
/* Compute smoothed coordinate by taking the ones nearby */
/* XXX: This is potentially slow, and suffers from accumulation error as earlier points are handled before later ones */
{
@@ -800,14 +801,14 @@ bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf, bool affect_pressure)
const int steps = 2;
const float average_fac = 1.0f / (float)(steps * 2 + 1);
int step;
-
+
/* add the point itself */
madd_v3_v3fl(sco, &pt->x, average_fac);
-
+
if (affect_pressure) {
pressure += pt->pressure * average_fac;
}
-
+
/* n-steps before/after current point */
// XXX: review how the endpoints are treated by this algorithm
// XXX: falloff measures should also introduce some weighting variations, so that further-out points get less weight
@@ -815,17 +816,17 @@ bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf, bool affect_pressure)
bGPDspoint *pt1, *pt2;
int before = i - step;
int after = i + step;
-
+
CLAMP_MIN(before, 0);
CLAMP_MAX(after, gps->totpoints - 1);
-
+
pt1 = &gps->points[before];
pt2 = &gps->points[after];
-
+
/* add both these points to the average-sum (s += p[i]/n) */
madd_v3_v3fl(sco, &pt1->x, average_fac);
madd_v3_v3fl(sco, &pt2->x, average_fac);
-
+
#if 0
/* XXX: Disabled because get weird result */
/* do pressure too? */
@@ -836,17 +837,17 @@ bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf, bool affect_pressure)
#endif
}
}
-
+
/* Based on influence factor, blend between original and optimal smoothed coordinate */
interp_v3_v3v3(&pt->x, &pt->x, sco, inf);
-
+
#if 0
/* XXX: Disabled because get weird result */
if (affect_pressure) {
pt->pressure = pressure;
}
#endif
-
+
return true;
}
@@ -939,22 +940,22 @@ void gp_subdivide_stroke(bGPDstroke *gps, const int new_totpoints)
gps->points[new_totpoints - y] = gps->points[i];
y += 2;
}
-
+
/* Create interpolated points */
for (int i = 0; i < new_totpoints - 1; i += 2) {
bGPDspoint *prev = &gps->points[i];
bGPDspoint *pt = &gps->points[i + 1];
bGPDspoint *next = &gps->points[i + 2];
-
+
/* Interpolate all values */
interp_v3_v3v3(&pt->x, &prev->x, &next->x, 0.5f);
-
+
pt->pressure = interpf(prev->pressure, next->pressure, 0.5f);
pt->strength = interpf(prev->strength, next->strength, 0.5f);
CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
pt->time = interpf(prev->time, next->time, 0.5f);
}
-
+
/* Update to new total number of points */
gps->totpoints = new_totpoints;
}
@@ -987,12 +988,12 @@ void gp_randomize_stroke(bGPDstroke *gps, bGPDbrush *brush)
float normal[3];
cross_v3_v3v3(normal, v1, v2);
normalize_v3(normal);
-
+
/* get orthogonal vector to plane to rotate random effect */
float ortho[3];
cross_v3_v3v3(ortho, v1, normal);
normalize_v3(ortho);
-
+
/* Read all points and apply shift vector (first and last point not modified) */
for (int i = 1; i < gps->totpoints - 1; ++i) {
bGPDspoint *pt = &gps->points[i];
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 78ab16e929e..943191c8892 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
@@ -36,6 +36,7 @@ struct ListBase;
struct AnimData;
struct bContext;
+struct Main;
struct wmKeyConfig;
struct ReportList;
struct ScrArea;
@@ -64,31 +65,32 @@ struct PropertyRNA;
/* --------------- Context --------------------- */
-/* This struct defines a structure used for animation-specific
+/* This struct defines a structure used for animation-specific
* 'context' information
*/
typedef struct bAnimContext {
void *data; /* data to be filtered for use in animation editor */
short datatype; /* type of data eAnimCont_Types */
-
+
short mode; /* editor->mode */
short spacetype; /* sa->spacetype */
short regiontype; /* active region -> type (channels or main) */
-
+
struct ScrArea *sa; /* editor host */
struct SpaceLink *sl; /* editor data */
struct ARegion *ar; /* region within editor */
-
+
struct bDopeSheet *ads; /* dopesheet data for editor (or which is being used) */
-
+
struct Depsgraph *depsgraph; /* active dependency graph */
+ struct Main *bmain; /* Current Main */
struct Scene *scene; /* active scene */
struct ViewLayer *view_layer; /* active scene layer */
struct Object *obact; /* active object */
ListBase *markers; /* active set of markers */
-
+
struct ReportList *reports; /* pointer to current reports list */
-
+
float yscale_fac; /* scale factor for height of channels (i.e. based on the size of keyframes) */
} bAnimContext;
@@ -109,24 +111,24 @@ typedef enum eAnimCont_Types {
/* --------------- Channels -------------------- */
-/* This struct defines a structure used for quick and uniform access for
+/* This struct defines a structure used for quick and uniform access for
* channels of animation data
*/
typedef struct bAnimListElem {
struct bAnimListElem *next, *prev;
-
+
void *data; /* source data this elem represents */
int type; /* (eAnim_ChannelType) one of the ANIMTYPE_* values */
int flag; /* copy of elem's flags for quick access */
int index; /* for un-named data, the index of the data in its collection */
-
+
char update; /* (eAnim_Update_Flags) tag the element for updating */
char tag; /* tag the included data. Temporary always */
short datatype; /* (eAnim_KeyType) type of motion data to expect */
void *key_data; /* motion data - mostly F-Curves, but can be other types too */
-
-
+
+
/* NOTE: id here is the "IdAdtTemplate"-style datablock (e.g. Object, Material, Texture, NodeTree)
* from which evaluation of the RNA-paths takes place. It's used to figure out how deep
* channels should be nested (e.g. for Textures/NodeTrees) in the tree, and allows property
@@ -138,12 +140,12 @@ typedef struct bAnimListElem {
*/
struct ID *id; /* ID block that channel is attached to */
struct AnimData *adt; /* source of the animation data attached to ID block (for convenience) */
-
+
void *owner; /* for per-element F-Curves (e.g. NLA Control Curves), the element that this represents (e.g. NlaStrip) */
} bAnimListElem;
-/* Some types for easier type-testing
+/* Some types for easier type-testing
* NOTE: need to keep the order of these synchronized with the channels define code
* which is used for drawing and handling channel lists for
*/
@@ -151,20 +153,20 @@ typedef enum eAnim_ChannelType {
ANIMTYPE_NONE = 0,
ANIMTYPE_ANIMDATA,
ANIMTYPE_SPECIALDATA,
-
+
ANIMTYPE_SUMMARY,
-
+
ANIMTYPE_SCENE,
ANIMTYPE_OBJECT,
ANIMTYPE_GROUP,
ANIMTYPE_FCURVE,
-
+
ANIMTYPE_NLACONTROLS,
ANIMTYPE_NLACURVE,
-
+
ANIMTYPE_FILLACTD,
ANIMTYPE_FILLDRIVERS,
-
+
ANIMTYPE_DSMAT,
ANIMTYPE_DSLAM,
ANIMTYPE_DSCAM,
@@ -183,18 +185,18 @@ typedef enum eAnim_ChannelType {
ANIMTYPE_DSSPK,
ANIMTYPE_DSGPENCIL,
ANIMTYPE_DSMCLIP,
-
+
ANIMTYPE_SHAPEKEY,
-
+
ANIMTYPE_GPDATABLOCK,
ANIMTYPE_GPLAYER,
-
+
ANIMTYPE_MASKDATABLOCK,
ANIMTYPE_MASKLAYER,
-
+
ANIMTYPE_NLATRACK,
ANIMTYPE_NLAACTION,
-
+
/* always as last item, the total number of channel types... */
ANIMTYPE_NUM_TYPES
} eAnim_ChannelType;
@@ -239,31 +241,31 @@ typedef enum eAnimFilter_Flags {
ANIMFILTER_LIST_VISIBLE = (1 << 1),
/* channel has specifically been tagged as visible in Graph Editor (* Graph Editor Only) */
ANIMFILTER_CURVE_VISIBLE = (1 << 2),
-
+
/* include summary channels and "expanders" (for drawing/mouse-selection in channel list) */
ANIMFILTER_LIST_CHANNELS = (1 << 3),
-
+
/* for its type, channel should be "active" one */
ANIMFILTER_ACTIVE = (1 << 4),
/* channel is a child of the active group (* Actions speciality) */
ANIMFILTER_ACTGROUPED = (1 << 5),
-
+
/* channel must be selected/not-selected, but both must not be set together */
ANIMFILTER_SEL = (1 << 6),
ANIMFILTER_UNSEL = (1 << 7),
-
+
/* editability status - must be editable to be included */
ANIMFILTER_FOREDIT = (1 << 8),
/* only selected animchannels should be considerable as editable - mainly for Graph Editor's option for keys on select curves only */
ANIMFILTER_SELEDIT = (1 << 9),
-
+
/* flags used to enforce certain data types */
// NOTE: the ones for curves and NLA tracks were redundant and have been removed for now...
ANIMFILTER_ANIMDATA = (1 << 10),
-
+
/* duplicate entries for animation data attached to multi-user blocks must not occur */
ANIMFILTER_NODUPLIS = (1 << 11),
-
+
/* for checking if we should keep some collapsed channel around (internal use only!) */
ANIMFILTER_TMP_PEEK = (1 << 30),
@@ -325,7 +327,7 @@ typedef enum eAnimFilter_Flags {
/* Grease Pencil only */
/* Grease Pencil datablock settings */
-#define EXPANDED_GPD(gpd) (gpd->flag & GP_DATA_EXPAND)
+#define EXPANDED_GPD(gpd) (gpd->flag & GP_DATA_EXPAND)
/* Grease Pencil Layer settings */
#define EDITABLE_GPL(gpl) ((gpl->flag & GP_LAYER_LOCKED) == 0)
#define SEL_GPL(gpl) (gpl->flag & GP_LAYER_SELECT)
@@ -387,12 +389,12 @@ typedef enum eAnimFilter_Flags {
size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_Flags filter_mode, void *data, eAnimCont_Types datatype);
/* Obtain current anim-data context from Blender Context info.
- * Returns whether the operation was successful.
+ * Returns whether the operation was successful.
*/
bool ANIM_animdata_get_context(const struct bContext *C, bAnimContext *ac);
-/* Obtain current anim-data context (from Animation Editor) given
- * that Blender Context info has already been set.
+/* Obtain current anim-data context (from Animation Editor) given
+ * that Blender Context info has already been set.
* Returns whether the operation was successful.
*/
bool ANIM_animdata_context_getdata(bAnimContext *ac);
@@ -444,7 +446,7 @@ typedef struct bAnimChannelType {
const char *channel_type_name;
/* "level" or role in hierarchy - for finding the active channel */
eAnimChannel_Role channel_role;
-
+
/* -- Drawing -- */
/* get RGB color that is used to draw the majority of the backdrop */
void (*get_backdrop_color)(bAnimContext *ac, bAnimListElem *ale, float r_color[3]);
@@ -454,14 +456,14 @@ typedef struct bAnimChannelType {
short (*get_indent_level)(bAnimContext *ac, bAnimListElem *ale);
/* get offset in pixels for the start of the channel (in addition to the indent depth) */
short (*get_offset)(bAnimContext *ac, bAnimListElem *ale);
-
+
/* get name (for channel lists) */
void (*name)(bAnimListElem *ale, char *name);
/* get RNA property+pointer for editing the name */
bool (*name_prop)(bAnimListElem *ale, struct PointerRNA *ptr, struct PropertyRNA **prop);
/* get icon (for channel lists) */
int (*icon)(bAnimListElem *ale);
-
+
/* -- Settings -- */
/* check if the given setting is valid in the current context */
bool (*has_setting)(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting);
@@ -490,28 +492,28 @@ void ANIM_channel_draw_widgets(const struct bContext *C, bAnimContext *ac, bAnim
/* ------------------------ Editing API -------------------------- */
-/* Check if some setting for a channel is enabled
+/* Check if some setting for a channel is enabled
* Returns: 1 = On, 0 = Off, -1 = Invalid
*
* - setting: eAnimChannel_Settings
*/
short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting);
-/* Change value of some setting for a channel
+/* Change value of some setting for a channel
* - setting: eAnimChannel_Settings
* - mode: eAnimChannels_SetFlag
*/
void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting, eAnimChannels_SetFlag mode);
-/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting
+/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting
* - anim_data: list of the all the anim channels that can be chosen
* -> filtered using ANIMFILTER_CHANNELS only, since if we took VISIBLE too,
* then the channels under closed expanders get ignored...
* - ale_setting: the anim channel (not in the anim_data list directly, though occurring there)
- * with the new state of the setting that we want flushed up/down the hierarchy
+ * with the new state of the setting that we want flushed up/down the hierarchy
* - setting: type of setting to set
- * - on: whether the visibility setting has been enabled or disabled
+ * - on: whether the visibility setting has been enabled or disabled
*/
void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAnimListElem *ale_setting, eAnimChannel_Settings setting, eAnimChannels_SetFlag mode);
@@ -579,8 +581,8 @@ void ANIM_fmodifiers_copybuf_free(void);
*/
bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active);
-/* 'Paste' the F-Modifier(s) from the buffer to the specified list
- * - replace: free all the existing modifiers to leave only the pasted ones
+/* 'Paste' the F-Modifier(s) from the buffer to the specified list
+ * - replace: free all the existing modifiers to leave only the pasted ones
*/
bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, struct FCurve *curve);
@@ -654,7 +656,7 @@ float ANIM_unit_mapping_get_factor(struct Scene *scene, struct ID *id, struct FC
*/
#define BEZKEYTYPE(bezt) ((bezt)->hide)
-/* set/clear/toggle macro
+/* set/clear/toggle macro
* - channel - channel with a 'flag' member that we're setting
* - smode - 0=clear, 1=set, 2=invert
* - sflag - bitflag to set
@@ -665,8 +667,8 @@ float ANIM_unit_mapping_get_factor(struct Scene *scene, struct ID *id, struct FC
else if (smode == ACHANNEL_SETFLAG_ADD) (channel)->flag |= (sflag); \
else (channel)->flag &= ~(sflag); \
}
-
-/* set/clear/toggle macro, where the flag is negative
+
+/* set/clear/toggle macro, where the flag is negative
* - channel - channel with a 'flag' member that we're setting
* - smode - 0=clear, 1=set, 2=invert
* - sflag - bitflag to set
@@ -682,7 +684,7 @@ float ANIM_unit_mapping_get_factor(struct Scene *scene, struct ID *id, struct FC
/* --------- anim_deps.c, animation updates -------- */
void ANIM_id_update(struct Scene *scene, struct ID *id);
-void ANIM_list_elem_update(struct Scene *scene, bAnimListElem *ale);
+void ANIM_list_elem_update(struct Main *bmain, struct Scene *scene, bAnimListElem *ale);
/* data -> channels syncing */
void ANIM_sync_animchannels_to_data(const struct bContext *C);
@@ -690,7 +692,7 @@ void ANIM_sync_animchannels_to_data(const struct bContext *C);
void ANIM_center_frame(struct bContext *C, int smooth_viewtx);
/* ************************************************* */
/* OPERATORS */
-
+
/* generic animation channels */
void ED_operatortypes_animchannels(void);
void ED_keymap_animchannels(struct wmKeyConfig *keyconf);
@@ -698,7 +700,7 @@ void ED_keymap_animchannels(struct wmKeyConfig *keyconf);
/* generic time editing */
void ED_operatortypes_anim(void);
void ED_keymap_anim(struct wmKeyConfig *keyconf);
-
+
/* space_graph */
void ED_operatormacros_graph(void);
/* space_action */
@@ -710,7 +712,7 @@ void ED_operatormacros_action(void);
/* Action Editor - Action Management */
struct AnimData *ED_actedit_animdata_from_context(struct bContext *C);
-void ED_animedit_unlink_action(struct bContext *C, struct ID *id,
+void ED_animedit_unlink_action(struct bContext *C, struct ID *id,
struct AnimData *adt, struct bAction *act,
struct ReportList *reports, bool force_delete);
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 2934745484a..cb422c2fb95 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -42,6 +42,7 @@ struct bPoseChannel;
struct Depsgraph;
struct IDProperty;
struct ListBase;
+struct Main;
struct MeshDeformModifierData;
struct Mesh;
struct Object;
@@ -73,7 +74,7 @@ typedef struct EditBone {
* animation are automatically relative to the bones' rest positions*/
int flag;
int layer;
-
+
float dist, weight;
float xwidth, length, zwidth; /* put them in order! transform uses this as scale */
float rad_head, rad_tail;
@@ -86,7 +87,7 @@ typedef struct EditBone {
float scaleIn, scaleOut;
float oldlength; /* for envelope scaling */
-
+
short segments;
/* Used for display */
@@ -135,7 +136,7 @@ void ED_operatormacros_armature(void);
void ED_keymap_armature(struct wmKeyConfig *keyconf);
/* editarmature.c */
-void ED_armature_from_edit(struct bArmature *arm);
+void ED_armature_from_edit(struct Main *bmain, struct bArmature *arm);
void ED_armature_to_edit(struct bArmature *arm);
void ED_armature_edit_free(struct bArmature *arm);
@@ -181,11 +182,11 @@ void ED_armature_ebone_from_mat3(EditBone *ebone, float mat[3][3]);
void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]);
void ED_armature_edit_transform_mirror_update(struct Object *obedit);
-void ED_armature_origin_set(struct Object *ob, float cursor[3], int centermode, int around);
+void ED_armature_origin_set(struct Main *bmain, struct Object *ob, float cursor[3], int centermode, int around);
void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const bool do_props);
-void ED_armature_transform_apply(struct Object *ob, float mat[4][4], const bool do_props);
-void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do_props);
+void ED_armature_transform_apply(struct Main *bmain, struct Object *ob, float mat[4][4], const bool do_props);
+void ED_armature_transform(struct Main *bmain, struct bArmature *arm, float mat[4][4], const bool do_props);
#define ARM_GROUPS_NAME 1
#define ARM_GROUPS_ENVELOPE 2
@@ -197,8 +198,8 @@ void ED_object_vgroup_calc_from_armature(
/* if bone is already in list, pass it as param to ignore it */
void ED_armature_ebone_unique_name(struct ListBase *ebones, char *name, EditBone *bone);
-void ED_armature_bone_rename(struct bArmature *arm, const char *oldnamep, const char *newnamep);
-void ED_armature_bones_flip_names(struct bArmature *arm, struct ListBase *bones_names, const bool do_strip_numbers);
+void ED_armature_bone_rename(struct Main *bmain, struct bArmature *arm, const char *oldnamep, const char *newnamep);
+void ED_armature_bones_flip_names(struct Main *bmain, struct bArmature *arm, struct ListBase *bones_names, const bool do_strip_numbers);
/* low level selection functions which handle */
int ED_armature_ebone_selectflag_get(const EditBone *ebone);
diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h
index da726cb8000..8fcfb4743d5 100644
--- a/source/blender/editors/include/ED_curve.h
+++ b/source/blender/editors/include/ED_curve.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -32,15 +32,16 @@
#define __ED_CURVE_H__
struct bContext;
+struct BezTriple;
+struct BPoint;
+struct Curve;
+struct EditNurb;
+struct Main;
struct Nurb;
struct Object;
struct Text;
struct wmOperator;
struct wmKeyConfig;
-struct Curve;
-struct EditNurb;
-struct BezTriple;
-struct BPoint;
struct UndoType;
/* curve_ops.c */
@@ -51,7 +52,7 @@ void ED_keymap_curve(struct wmKeyConfig *keyconf);
/* editcurve.c */
struct ListBase *object_editcurve_get(struct Object *ob);
-void ED_curve_editnurb_load(struct Object *obedit);
+void ED_curve_editnurb_load(struct Main *bmain, struct Object *obedit);
void ED_curve_editnurb_make(struct Object *obedit);
void ED_curve_editnurb_free(struct Object *obedit);
diff --git a/source/blender/editors/include/ED_datafiles.h b/source/blender/editors/include/ED_datafiles.h
index 661ab58b98c..1559fc8f302 100644
--- a/source/blender/editors/include/ED_datafiles.h
+++ b/source/blender/editors/include/ED_datafiles.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h
index 645c3e6d75e..f2b7d2cb4a1 100644
--- a/source/blender/editors/include/ED_fileselect.h
+++ b/source/blender/editors/include/ED_fileselect.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 57ca1f04c0a..f1f2ce29e7f 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -87,7 +87,7 @@ typedef struct tGPDinterpolate {
void *draw_handle_screen; /* handle for drawing strokes while operator is running screen stuff */
} tGPDinterpolate;
-/* Temporary 'Stroke Point' data
+/* Temporary 'Stroke Point' data
*
* Used as part of the 'stroke cache' used during drawing of new strokes
*/
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index cb824b3c9b7..73926b8a687 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -43,7 +43,7 @@ struct ViewLayer;
/* image_edit.c, exported for transform */
struct Image *ED_space_image(struct SpaceImage *sima);
-void ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
+void ED_space_image_set(struct Main *bmain, struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
struct Mask *ED_space_image_get_mask(struct SpaceImage *sima);
void ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask);
@@ -60,8 +60,8 @@ void ED_space_image_get_uv_aspect(struct SpaceImage *sima, float *aspx, float *a
void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *sima, struct ImBuf *ibuf, bool use_view_settings);
-void ED_space_image_paint_update(struct wmWindowManager *wm, struct Scene *scene);
-void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct Scene *scene);
+void ED_space_image_paint_update(struct Main *bmain, struct wmWindowManager *wm, struct Scene *scene);
+void ED_space_image_uv_sculpt_update(struct Main *bmain, struct wmWindowManager *wm, struct Scene *scene);
void ED_image_get_uv_aspect(struct Image *ima, struct ImageUser *iuser, float *aspx, float *aspy);
void ED_image_mouse_pos(struct SpaceImage *sima, struct ARegion *ar, const int mval[2], float co[2]);
diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h
index 62f1a617fcb..9b0b2c970b2 100644
--- a/source/blender/editors/include/ED_keyframes_draw.h
+++ b/source/blender/editors/include/ED_keyframes_draw.h
@@ -53,17 +53,17 @@ struct DLRBT_Tree;
typedef struct ActKeyColumn {
/* ListBase linkage */
struct ActKeyColumn *next, *prev;
-
+
/* sorting-tree linkage */
struct ActKeyColumn *left, *right; /* 'children' of this node, less than and greater than it (respectively) */
struct ActKeyColumn *parent; /* parent of this node in the tree */
char tree_col; /* DLRB_BLACK or DLRB_RED */
-
+
/* keyframe info */
char key_type; /* eBezTripe_KeyframeType */
short sel;
float cfra;
-
+
/* only while drawing - used to determine if long-keyframe needs to be drawn */
short modified;
short totcurve;
@@ -73,21 +73,21 @@ typedef struct ActKeyColumn {
typedef struct ActKeyBlock {
/* ListBase linkage */
struct ActKeyBlock *next, *prev;
-
+
/* sorting-tree linkage */
struct ActKeyBlock *left, *right; /* 'children' of this node, less than and greater than it (respectively) */
struct ActKeyBlock *parent; /* parent of this node in the tree */
char tree_col; /* DLRB_BLACK or DLRB_RED */
-
+
/* key-block info */
char sel;
short flag;
float val;
float start, end;
-
+
/* only while drawing - used to determine if block needs to be drawn */
short modified;
- short totcurve;
+ short totcurve;
} ActKeyBlock;
/* ActKeyBlock - Flag */
diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h
index c0eb88cd982..5787a63d324 100644
--- a/source/blender/editors/include/ED_keyframes_edit.h
+++ b/source/blender/editors/include/ED_keyframes_edit.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
@@ -141,12 +141,12 @@ typedef enum eKeyframeVertOk {
typedef enum eKeyframeIterFlags {
/* consider handles in addition to key itself */
KEYFRAME_ITER_INCL_HANDLES = (1 << 0),
-
+
/* Perform NLA time remapping (global -> strip) for the "f1" parameter
* (e.g. used for selection tools on summary tracks)
*/
KED_F1_NLA_UNMAP = (1 << 1),
-
+
/* Perform NLA time remapping (global -> strip) for the "f2" parameter */
KED_F2_NLA_UNMAP = (1 << 2),
} eKeyframeIterFlags;
@@ -165,7 +165,7 @@ typedef struct KeyframeEditData {
struct FCurve *fcu; /* F-Curve that is being iterated over */
int curIndex; /* index of current keyframe being iterated over */
float channel_y; /* y-position of midpoint of the channel (for the dopesheet) */
-
+
/* flags */
eKeyframeVertOk curflags; /* current flags for the keyframe we're reached in the iteration process */
eKeyframeIterFlags iterflags; /* settings for iteration process */
@@ -243,8 +243,8 @@ KeyframeEditFunc ANIM_editkeyframes_easing(short mode);
/* -------- BezTriple Callbacks (Selection Map) ---------- */
-/* Get a callback to populate the selection settings map
- * requires: ked->custom = char[] of length fcurve->totvert
+/* Get a callback to populate the selection settings map
+ * requires: ked->custom = char[] of length fcurve->totvert
*/
KeyframeEditFunc ANIM_editkeyframes_buildselmap(short mode);
@@ -262,7 +262,7 @@ short bezt_calc_average(KeyframeEditData *ked, struct BezTriple *bezt);
short bezt_to_cfraelem(KeyframeEditData *ked, struct BezTriple *bezt);
/* used to remap times from one range to another
- * requires: ked->custom = KeyframeEditCD_Remap
+ * requires: ked->custom = KeyframeEditCD_Remap
*/
void bezt_remap_times(KeyframeEditData *ked, struct BezTriple *bezt);
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index 85e51874cf3..5882c44a9b3 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -61,19 +61,19 @@ struct EnumPropertyItem;
/* ************ Keyframing Management **************** */
-/* Get the active settings for keyframing settings from context (specifically the given scene)
+/* Get the active settings for keyframing settings from context (specifically the given scene)
* - incl_mode: include settings from keyframing mode in the result (i.e. replace only)
*/
short ANIM_get_keyframing_flags(struct Scene *scene, short incl_mode);
/* -------- */
-/* Get (or add relevant data to be able to do so) the Active Action for the given
+/* Get (or add relevant data to be able to do so) the Active Action for the given
* Animation Data block, given an ID block where the Animation Data should reside.
*/
-struct bAction *verify_adt_action(struct ID *id, short add);
+struct bAction *verify_adt_action(struct Main *bmain, struct ID *id, short add);
-/* Get (or add relevant data to be able to do so) F-Curve from the given Action.
+/* Get (or add relevant data to be able to do so) F-Curve from the given Action.
* This assumes that all the destinations are valid.
*/
struct FCurve *verify_fcurve(struct bAction *act, const char group[], struct PointerRNA *ptr,
@@ -96,7 +96,7 @@ void update_autoflags_fcurve(struct FCurve *fcu, struct bContext *C, struct Repo
*/
int insert_bezt_fcurve(struct FCurve *fcu, const struct BezTriple *bezt, eInsertKeyFlags flag);
-/* Main Keyframing API call:
+/* Main Keyframing API call:
* Use this when validation of necessary animation data isn't necessary as it
* already exists. It will insert a keyframe using the current value being keyframed.
* Returns the index at which a keyframe was added (or -1 if failed)
@@ -105,21 +105,23 @@ int insert_vert_fcurve(struct FCurve *fcu, float x, float y, eBezTriple_Keyframe
/* -------- */
-/* Secondary Keyframing API calls:
- * Use this to insert a keyframe using the current value being keyframed, in the
+/* Secondary Keyframing API calls:
+ * Use this to insert a keyframe using the current value being keyframed, in the
* nominated F-Curve (no creation of animation data performed). Returns success.
*/
bool insert_keyframe_direct(struct Depsgraph *depsgraph, struct ReportList *reports, struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag);
/* -------- */
-/* Main Keyframing API calls:
+/* Main Keyframing API calls:
* Use this to create any necessary animation data, and then insert a keyframe
* using the current value being keyframed, in the relevant place. Returns success.
*/
-short insert_keyframe(struct Depsgraph *depsgraph, struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag);
+short insert_keyframe(
+ struct Main *bmain, struct Depsgraph *depsgraph, struct ReportList *reports, struct ID *id, struct bAction *act,
+ const char group[], const char rna_path[], int array_index, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag);
-/* Main Keyframing API call:
+/* Main Keyframing API call:
* Use this to delete keyframe on current frame for relevant channel. Will perform checks just in case.
*/
short delete_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eInsertKeyFlags flag);
@@ -135,13 +137,13 @@ typedef int (*cbKeyingSet_Poll)(struct KeyingSetInfo *ksi, struct bContext *C);
/* Context Iterator Callback for KeyingSets */
typedef void (*cbKeyingSet_Iterator)(struct KeyingSetInfo *ksi, struct bContext *C, struct KeyingSet *ks);
/* Property Specifier Callback for KeyingSets (called from iterators) */
-typedef void (*cbKeyingSet_Generate)(struct KeyingSetInfo *ksi, struct bContext *C, struct KeyingSet *ks, struct PointerRNA *ptr);
+typedef void (*cbKeyingSet_Generate)(struct KeyingSetInfo *ksi, struct bContext *C, struct KeyingSet *ks, struct PointerRNA *ptr);
/* Callback info for 'Procedural' KeyingSets to use */
typedef struct KeyingSetInfo {
struct KeyingSetInfo *next, *prev;
-
+
/* info */
/* identifier used for class name, which KeyingSet instances reference as "Typeinfo Name" */
char idname[64];
@@ -151,11 +153,11 @@ typedef struct KeyingSetInfo {
char description[240]; /* RNA_DYN_DESCR_MAX */
/* keying settings */
short keyingflag;
-
+
/* polling callbacks */
/* callback for polling the context for whether the right data is available */
cbKeyingSet_Poll poll;
-
+
/* generate callbacks */
/* iterator to use to go through collections of data in context
* - this callback is separate from the 'adding' stage, allowing
@@ -164,7 +166,7 @@ typedef struct KeyingSetInfo {
cbKeyingSet_Iterator iter;
/* generator to use to add properties based on the data found by iterator */
cbKeyingSet_Generate generate;
-
+
/* RNA integration */
struct ExtensionRNA ext;
} KeyingSetInfo;
@@ -243,7 +245,7 @@ typedef enum eCreateDriver_MappingTypes {
CREATEDRIVER_MAPPING_1_N = 0, /* 1 to Many - Use the specified index, and drive all elements with it */
CREATEDRIVER_MAPPING_1_1 = 1, /* 1 to 1 - Only for the specified index on each side */
CREATEDRIVER_MAPPING_N_N = 2, /* Many to Many - Match up the indices one by one (only for drivers on vectors/arrays) */
-
+
CREATEDRIVER_MAPPING_NONE = 3, /* None (Single Prop) - Do not create driver with any targets; these will get added later instead */
CREATEDRIVER_MAPPING_NONE_ALL = 4, /* None (All Properties) - Do not create driver with any targets; these will get added later instead */
} eCreateDriver_MappingTypes;
@@ -272,7 +274,7 @@ struct FCurve *verify_driver_fcurve(struct ID *id, const char rna_path[], const
* - mapping_type: eCreateDriver_MappingTypes
*/
int ANIM_add_driver_with_target(
- struct ReportList *reports,
+ struct ReportList *reports,
struct ID *dst_id, const char dst_path[], int dst_index,
struct ID *src_id, const char src_path[], int src_index,
short flag, int driver_type, short mapping_type);
@@ -309,7 +311,7 @@ bool ANIM_copy_driver(struct ReportList *reports, struct ID *id, const char rna_
/* Main Driver Management API calls:
* Add a new driver for the specified property on the given ID block or replace an existing one
- * with the driver + driver-curve data from the buffer
+ * with the driver + driver-curve data from the buffer
*/
bool ANIM_paste_driver(struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag);
@@ -364,7 +366,7 @@ bool fcurve_frame_has_keyframe(struct FCurve *fcu, float frame, short filter);
*/
bool id_frame_has_keyframe(struct ID *id, float frame, short filter);
-/* filter flags for id_cfra_has_keyframe
+/* filter flags for id_cfra_has_keyframe
*
* WARNING: do not alter order of these, as also stored in files
* (for v3d->keyflags)
diff --git a/source/blender/editors/include/ED_markers.h b/source/blender/editors/include/ED_markers.h
index 5eaf459a4e1..a95e283f218 100644
--- a/source/blender/editors/include/ED_markers.h
+++ b/source/blender/editors/include/ED_markers.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -68,7 +68,7 @@ struct TimeMarker *ED_markers_get_first_selected(ListBase *markers);
/* Operators ------------------------------ */
/* called in screen_ops.c:ED_operatortypes_screen() */
-void ED_operatortypes_marker(void);
+void ED_operatortypes_marker(void);
/* called in screen_ops.c:ED_keymap_screen() */
void ED_keymap_marker(struct wmKeyConfig *keyconf);
diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h
index 9982c87a764..46c34d36efc 100644
--- a/source/blender/editors/include/ED_mball.h
+++ b/source/blender/editors/include/ED_mball.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index dfa5a51a775..0d323258a19 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h
index 20363c69fa0..0b3ce144097 100644
--- a/source/blender/editors/include/ED_node.h
+++ b/source/blender/editors/include/ED_node.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -86,7 +86,7 @@ float ED_node_grid_size(void);
/* node_relationships.c */
void ED_node_link_intersect_test(struct ScrArea *sa, int test);
-void ED_node_link_insert(struct ScrArea *sa);
+void ED_node_link_insert(struct Main *bmain, struct ScrArea *sa);
/* node_edit.c */
void ED_node_set_tree_type(struct SpaceNode *snode, struct bNodeTreeType *typeinfo);
@@ -107,7 +107,7 @@ void ED_node_composite_job(const struct bContext *C, struct bNodeTree *nodetree,
void ED_operatormacros_node(void);
/* node_view.c */
-bool ED_space_node_color_sample(struct SpaceNode *snode, struct ARegion *ar, int mval[2], float r_col[3]);
+bool ED_space_node_color_sample(struct Main *bmain, struct SpaceNode *snode, struct ARegion *ar, int mval[2], float r_col[3]);
#endif /* __ED_NODE_H__ */
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 8e844d327e2..f1311233f23 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -125,23 +125,23 @@ enum {
EM_IGNORE_LAYER = (1 << 3),
EM_NO_CONTEXT = (1 << 4),
};
-void ED_object_editmode_exit_ex(
- struct Scene *scene, struct Object *obedit, int flag);
-void ED_object_editmode_exit(struct bContext *C, int flag);
+bool ED_object_editmode_exit_ex(
+ struct Main *bmain, struct Scene *scene, struct Object *obedit, int flag);
+bool ED_object_editmode_exit(struct bContext *C, int flag);
-void ED_object_editmode_enter_ex(struct Scene *scene, struct Object *ob, int flag);
-void ED_object_editmode_enter(struct bContext *C, int flag);
-bool ED_object_editmode_load(struct Object *obedit);
+bool ED_object_editmode_enter_ex(struct Main *bmain, struct Scene *scene, struct Object *ob, int flag);
+bool ED_object_editmode_enter(struct bContext *C, int flag);
+bool ED_object_editmode_load(struct Main *bmain, struct Object *obedit);
bool ED_object_editmode_calc_active_center(struct Object *obedit, const bool select_only, float r_center[3]);
void ED_object_vpaintmode_enter_ex(
- struct Depsgraph *depsgraph, struct wmWindowManager *wm,
+ struct Main *bmain, struct Depsgraph *depsgraph, struct wmWindowManager *wm,
struct Scene *scene, struct Object *ob);
void ED_object_vpaintmode_enter(struct bContext *C);
void ED_object_wpaintmode_enter_ex(
- struct Depsgraph *depsgraph, struct wmWindowManager *wm,
+ struct Main *bmain, struct Depsgraph *depsgraph, struct wmWindowManager *wm,
struct Scene *scene, struct Object *ob);
void ED_object_wpaintmode_enter(struct bContext *C);
@@ -151,7 +151,7 @@ void ED_object_wpaintmode_exit_ex(struct Object *ob);
void ED_object_wpaintmode_exit(struct bContext *C);
void ED_object_sculptmode_enter_ex(
- struct Depsgraph *depsgraph,
+ struct Main *bmain, struct Depsgraph *depsgraph,
struct Scene *scene, struct Object *ob,
struct ReportList *reports);
void ED_object_sculptmode_enter(struct bContext *C, struct ReportList *reports);
@@ -197,13 +197,13 @@ struct ListBase *get_active_constraints(struct Object *ob);
struct ListBase *get_constraint_lb(struct Object *ob, struct bConstraint *con, struct bPoseChannel **r_pchan);
struct bConstraint *get_active_constraint(struct Object *ob);
-void object_test_constraints(struct Object *ob);
+void object_test_constraints(struct Main *bmain, struct Object *ob);
void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con);
-void ED_object_constraint_update(struct Object *ob);
+void ED_object_constraint_update(struct Main *bmain, struct Object *ob);
void ED_object_constraint_dependency_update(struct Main *bmain, struct Object *ob);
-void ED_object_constraint_tag_update(struct Object *ob, struct bConstraint *con);
+void ED_object_constraint_tag_update(struct Main *bmain, struct Object *ob, struct bConstraint *con);
void ED_object_constraint_dependency_tag_update(struct Main *bmain, struct Object *ob, struct bConstraint *con);
/* object_modes.c */
@@ -216,6 +216,7 @@ bool ED_object_mode_generic_enter(
struct bContext *C,
eObjectMode object_mode);
void ED_object_mode_generic_exit(
+ struct Main *bmain,
struct Depsgraph *depsgraph,
struct Scene *scene, struct Object *ob);
bool ED_object_mode_generic_has_data(
@@ -232,17 +233,20 @@ enum {
MODIFIER_APPLY_SHAPE
};
-struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene,
- struct Object *ob, const char *name, int type);
+struct ModifierData *ED_object_modifier_add(
+ struct ReportList *reports, struct Main *bmain, struct Scene *scene,
+ struct Object *ob, const char *name, int type);
bool ED_object_modifier_remove(struct ReportList *reports, struct Main *bmain,
struct Object *ob, struct ModifierData *md);
void ED_object_modifier_clear(struct Main *bmain, struct Object *ob);
int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
-int ED_object_modifier_convert(struct ReportList *reports, struct Main *bmain, struct Scene *scene,
- struct ViewLayer *view_layer, struct Object *ob, struct ModifierData *md);
-int ED_object_modifier_apply(struct ReportList *reports, struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, struct ModifierData *md, int mode);
+int ED_object_modifier_convert(
+ struct ReportList *reports, struct Main *bmain, struct Scene *scene,
+ struct ViewLayer *view_layer, struct Object *ob, struct ModifierData *md);
+int ED_object_modifier_apply(
+ struct ReportList *reports, struct Depsgraph *depsgraph, struct Scene *scene,
+ struct Object *ob, struct ModifierData *md, int mode);
int ED_object_modifier_copy(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
bool ED_object_iter_other(
@@ -262,7 +266,8 @@ const struct EnumPropertyItem *ED_object_vgroup_selection_itemf_helper(
bool *r_free,
const unsigned int selection_mask);
-void ED_object_check_force_modifiers(struct Main *bmain, struct Scene *scene, struct Object *object);
+void ED_object_check_force_modifiers(
+ struct Main *bmain, struct Scene *scene, struct Object *object);
/* object_facemap_ops.c */
void ED_object_facemap_face_add(struct Object *ob, struct bFaceMap *fmap, int facenum);
@@ -272,4 +277,7 @@ void ED_object_facemap_face_remove(struct Object *ob, struct bFaceMap *fmap, int
}
#endif
+/* Don't allow switching object-modes when selecting objects. */
+#define USE_OBJECT_MODE_STRICT
+
#endif /* __ED_OBJECT_H__ */
diff --git a/source/blender/editors/include/ED_outliner.h b/source/blender/editors/include/ED_outliner.h
index 73ee2542247..c1b3c3e9e1c 100644
--- a/source/blender/editors/include/ED_outliner.h
+++ b/source/blender/editors/include/ED_outliner.h
@@ -27,4 +27,11 @@
#ifndef __ED_OUTLINER_H__
#define __ED_OUTLINER_H__
+struct bContext;
+struct ListBase;
+
+int ED_outliner_collections_editor_poll(struct bContext *C);
+
+void ED_outliner_selected_objects_get(const struct bContext *C, struct ListBase *objects);
+
#endif /* __ED_OUTLINER_H__ */
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index b10d915553e..a741f12c112 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -79,7 +79,7 @@ void ED_region_tag_refresh_ui(struct ARegion *ar);
void ED_region_panels_init(struct wmWindowManager *wm, struct ARegion *ar);
void ED_region_panels(
const struct bContext *C, struct ARegion *ar,
- const char *context, int contextnr,
+ const char *contexts[], int contextnr,
const bool vertical);
void ED_region_header_init(struct ARegion *ar);
void ED_region_header(const struct bContext *C, struct ARegion *ar);
@@ -94,6 +94,7 @@ void ED_region_image_metadata_draw(int x, int y, struct ImBuf *ibuf, const rc
void ED_region_grid_draw(struct ARegion *ar, float zoomx, float zoomy);
float ED_region_blend_alpha(struct ARegion *ar);
void ED_region_visible_rect(struct ARegion *ar, struct rcti *rect);
+bool ED_region_is_overlap(int spacetype, int regiontype);
int ED_region_snap_size_test(const struct ARegion *ar);
bool ED_region_snap_size_apply(struct ARegion *ar, int snap_flag);
@@ -159,7 +160,7 @@ ScrArea *ED_screen_areas_iter_next(const bScreen *screen, const ScrArea *area);
vert_name = (vert_name == (win)->global_areas.vertbase.last) ? (screen)->vertbase.first : vert_name->next)
/* screens */
-void ED_screens_initialize(struct wmWindowManager *wm);
+void ED_screens_initialize(struct Main *bmain, struct wmWindowManager *wm);
void ED_screen_draw_edges(struct wmWindow *win);
void ED_screen_draw_join_shape(struct ScrArea *sa1, struct ScrArea *sa2);
void ED_screen_draw_split_preview(struct ScrArea *sa, const int dir, const float fac);
@@ -210,10 +211,12 @@ void ED_workspace_view_layer_unset(
const struct Main *bmain, struct Scene *scene,
const ViewLayer *layer_unset, ViewLayer *layer_new) ATTR_NONNULL(1, 2);
struct WorkSpaceLayout *ED_workspace_layout_add(
+ struct Main *bmain,
struct WorkSpace *workspace,
struct wmWindow *win,
const char *name) ATTR_NONNULL();
struct WorkSpaceLayout *ED_workspace_layout_duplicate(
+ struct Main *bmain,
struct WorkSpace *workspace, const struct WorkSpaceLayout *layout_old,
struct wmWindow *win) ATTR_NONNULL();
bool ED_workspace_layout_delete(
diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h
index 0fed5eb03fd..8ef7fee0f32 100644
--- a/source/blender/editors/include/ED_screen_types.h
+++ b/source/blender/editors/include/ED_screen_types.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -63,7 +63,7 @@ enum {
#define REDRAW_FRAME_AVERAGE 8
-/* for playback framerate info
+/* for playback framerate info
* stored during runtime as scene->fps_info
*/
typedef struct ScreenFrameRateInfo {
diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h
index 574523696f5..c624405cd0c 100644
--- a/source/blender/editors/include/ED_sculpt.h
+++ b/source/blender/editors/include/ED_sculpt.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/editors/include/ED_sound.h b/source/blender/editors/include/ED_sound.h
index d3e7502bb99..87ab9041305 100644
--- a/source/blender/editors/include/ED_sound.h
+++ b/source/blender/editors/include/ED_sound.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h
index 77539bff252..ddd8b59c264 100644
--- a/source/blender/editors/include/ED_space_api.h
+++ b/source/blender/editors/include/ED_space_api.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -60,7 +60,7 @@ void ED_spacetype_clip(void);
void ED_spacetype_statusbar(void);
void ED_spacetype_topbar(void);
-/* calls for instancing and freeing spacetype static data
+/* calls for instancing and freeing spacetype static data
* called in WM_init_exit */
/* in space_file.c */
void ED_file_init(void);
@@ -70,7 +70,7 @@ void ED_file_exit(void);
#define REGION_DRAW_POST_PIXEL 1
#define REGION_DRAW_PRE_VIEW 2
-void *ED_region_draw_cb_activate(struct ARegionType *,
+void *ED_region_draw_cb_activate(struct ARegionType *,
void (*draw)(const struct bContext *, struct ARegion *, void *),
void *custumdata, int type);
void ED_region_draw_cb_draw(const struct bContext *, struct ARegion *, int);
diff --git a/source/blender/editors/include/ED_text.h b/source/blender/editors/include/ED_text.h
index 763fbe3bac5..858902eeec1 100644
--- a/source/blender/editors/include/ED_text.h
+++ b/source/blender/editors/include/ED_text.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/include/ED_transform_snap_object_context.h b/source/blender/editors/include/ED_transform_snap_object_context.h
index 18d5101ebf7..8ac7dfcf9d8 100644
--- a/source/blender/editors/include/ED_transform_snap_object_context.h
+++ b/source/blender/editors/include/ED_transform_snap_object_context.h
@@ -79,9 +79,9 @@ struct SnapObjectParams {
typedef struct SnapObjectContext SnapObjectContext;
SnapObjectContext *ED_transform_snap_object_context_create(
- struct Scene *scene, struct Depsgraph *depsgraph, int flag);
+ struct Main *bmain, struct Scene *scene, struct Depsgraph *depsgraph, int flag);
SnapObjectContext *ED_transform_snap_object_context_create_view3d(
- struct Scene *scene, struct Depsgraph *depsgraph, int flag,
+ struct Main *bmain, struct Scene *scene, struct Depsgraph *depsgraph, int flag,
/* extra args for view3d */
const struct ARegion *ar, const struct View3D *v3d);
void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx);
diff --git a/source/blender/editors/include/ED_types.h b/source/blender/editors/include/ED_types.h
index fac4c02e8ed..a478278da4c 100644
--- a/source/blender/editors/include/ED_types.h
+++ b/source/blender/editors/include/ED_types.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/include/ED_undo.h b/source/blender/editors/include/ED_undo.h
index 6df568a6bc9..5103ac97361 100644
--- a/source/blender/editors/include/ED_undo.h
+++ b/source/blender/editors/include/ED_undo.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index 69e80f60d0a..3a35bddeb77 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h
index 4d5e4585221..e6cd276e5c7 100644
--- a/source/blender/editors/include/ED_uvedit.h
+++ b/source/blender/editors/include/ED_uvedit.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index e1a6d59a748..24e5b3e2662 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -75,6 +75,7 @@ enum eGPUFXFlags;
/* for derivedmesh drawing callbacks, for view3d_select, .... */
typedef struct ViewContext {
+ struct Main *bmain;
struct Depsgraph *depsgraph;
struct Scene *scene;
struct ViewLayer *view_layer;
@@ -93,7 +94,7 @@ typedef struct ViewDepths {
short x, y; /* only for temp use for sub-rects, added to ar->winx/y */
float *depths;
double depth_range[2];
-
+
bool damaged;
} ViewDepths;
@@ -326,12 +327,13 @@ unsigned int ED_view3d_backbuf_sample(
struct ViewContext *vc, int x, int y);
bool ED_view3d_autodist(
- struct Depsgraph *graph, struct ARegion *ar, struct View3D *v3d,
+ struct Depsgraph *depsgraph, struct ARegion *ar, struct View3D *v3d,
const int mval[2], float mouse_worldloc[3],
const bool alphaoverride, const float fallback_depth_pt[3]);
/* only draw so ED_view3d_autodist_simple can be called many times after */
-void ED_view3d_autodist_init(struct Depsgraph *graph, struct ARegion *ar, struct View3D *v3d, int mode);
+void ED_view3d_autodist_init(
+ struct Depsgraph *depsgraph, struct ARegion *ar, struct View3D *v3d, int mode);
bool ED_view3d_autodist_simple(struct ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth);
bool ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth);
bool ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth);
diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h
index 6a9067ef95d..3bc1255d23f 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -61,7 +61,7 @@ DEF_ICON(PLUG)
DEF_ICON(UI)
DEF_ICON(NODE)
DEF_ICON(NODE_SEL)
-
+
/* ui */
DEF_ICON(FULLSCREEN)
DEF_ICON(SPLITSCREEN)
@@ -89,7 +89,7 @@ DEF_ICON(DOTSDOWN)
DEF_ICON(LINK)
DEF_ICON(INLINK)
DEF_ICON(PLUGIN)
-
+
/* various ui */
DEF_ICON(HELP)
DEF_ICON(GHOST_ENABLED)
@@ -119,7 +119,7 @@ DEF_ICON(RECOVER_LAST)
DEF_ICON(FULLSCREEN_ENTER)
DEF_ICON(FULLSCREEN_EXIT)
DEF_ICON(BLANK1) // Not actually blank - this is used all over the place
-
+
/* BUTTONS */
DEF_ICON(LAMP)
DEF_ICON(MATERIAL)
@@ -208,7 +208,7 @@ DEF_ICON(GREASEPENCIL_STROKE_PAINT)
DEF_ICON(BLANK077)
DEF_ICON(BLANK077b)
#endif
-
+
/* DATA */
DEF_ICON(SCENE_DATA)
DEF_ICON(RENDERLAYERS)
@@ -298,7 +298,7 @@ DEF_ICON(RNA_ADD)
DEF_ICON(BLANK116)
DEF_ICON(BLANK116b)
#endif
-
+
/* OUTLINER */
DEF_ICON(OUTLINER_OB_EMPTY)
DEF_ICON(OUTLINER_OB_MESH)
@@ -360,7 +360,7 @@ DEF_ICON(OUTLINER_DATA_GREASEPENCIL)
DEF_ICON(BLANK142)
DEF_ICON(BLANK142b)
#endif
-
+
/* PRIMITIVES */
DEF_ICON(MESH_PLANE)
DEF_ICON(MESH_CUBE)
@@ -394,7 +394,7 @@ DEF_ICON(META_CAPSULE)
#ifndef DEF_ICON_BLANK_SKIP
DEF_ICON(BLANK625)
#endif
-
+
/* PRIMITIVES */
DEF_ICON(SURFACE_NCURVE)
DEF_ICON(SURFACE_NCIRCLE)
@@ -485,7 +485,7 @@ DEF_ICON(NODE_INSERT_OFF)
DEF_ICON(BLANK713)
DEF_ICON(BLANK714)
DEF_ICON(BLANK715)
-
+
/* EMPTY */
DEF_ICON(BLANK720)
DEF_ICON(BLANK721)
@@ -600,7 +600,7 @@ DEF_ICON(MOD_NORMALEDIT)
DEF_ICON(BLANK176)
DEF_ICON(BLANK177)
#endif
-
+
/* ANIMATION */
DEF_ICON(REC)
DEF_ICON(PLAY)
@@ -691,7 +691,7 @@ DEF_ICON(SCULPT_DYNTOPO) /* XXX Empty icon! */
DEF_ICON(PARTICLE_POINT)
DEF_ICON(PARTICLE_TIP)
DEF_ICON(PARTICLE_PATH)
-
+
/* EDITING */
DEF_ICON(MAN_TRANS)
DEF_ICON(MAN_ROT)
@@ -753,7 +753,7 @@ DEF_ICON(UV_SYNC_SELECT)
DEF_ICON(BLANK247)
DEF_ICON(BLANK247b)
#endif
-
+
/* 3D VIEW */
DEF_ICON(BBOX)
DEF_ICON(WIRE)
@@ -876,7 +876,7 @@ DEF_ICON(FORWARD)
DEF_ICON(FILE_HIDDEN)
DEF_ICON(FILE_BACKUP)
DEF_ICON(DISK_DRIVE)
-
+
/* SHADING / TEXT */
DEF_ICON(MATPLANE)
DEF_ICON(MATSPHERE)
@@ -908,7 +908,7 @@ DEF_ICON(SCRIPTPLUGINS) // XXX CREATE NEW
DEF_ICON(BLANK328)
DEF_ICON(BLANK328b)
#endif
-
+
/* SEQUENCE / IMAGE EDITOR */
DEF_ICON(SEQ_SEQUENCER)
DEF_ICON(SEQ_PREVIEW)
@@ -1002,7 +1002,7 @@ DEF_ICON(MATCAP_22)
DEF_ICON(MATCAP_23)
DEF_ICON(MATCAP_24)
-/* vector icons, VICO_ prefix added */
+/* vector icons, VICO_ prefix added */
DEF_VICO(SMALL_TRI_RIGHT_VEC)
DEF_VICO(KEYTYPE_KEYFRAME_VEC)
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 896d161f664..c82a320268f 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -305,7 +305,8 @@ typedef enum {
UI_BTYPE_NODE_SOCKET = (53 << 9),
UI_BTYPE_SEPR = (54 << 9),
UI_BTYPE_SEPR_LINE = (55 << 9),
- UI_BTYPE_GRIP = (56 << 9), /* resize handle (resize uilist) */
+ UI_BTYPE_SEPR_SPACER = (56 << 9), /* Dynamically fill available space. */
+ UI_BTYPE_GRIP = (57 << 9), /* resize handle (resize uilist) */
} eButType;
#define BUTTYPE (63 << 9)
@@ -476,7 +477,7 @@ void UI_popup_block_close(struct bContext *C, struct wmWindow *win, uiBlock *blo
*
* Functions for creating, drawing and freeing blocks. A Block is a
* container of buttons and used for various purposes.
- *
+ *
* Begin/Define Buttons/End/Draw is the typical order in which these
* function should be called, though for popup blocks Draw is left out.
* Freeing blocks is done by the screen/ module automatically.
@@ -491,8 +492,6 @@ void UI_blocklist_update_window_matrix(const struct bContext *C, const struct Li
void UI_blocklist_draw(const struct bContext *C, const struct ListBase *lb);
void UI_block_update_from_old(const struct bContext *C, struct uiBlock *block);
-uiBlock *UI_block_find_in_region(const char *name, struct ARegion *ar);
-
void UI_block_emboss_set(uiBlock *block, char dt);
void UI_block_free(const struct bContext *C, uiBlock *block);
@@ -581,7 +580,7 @@ bool UI_but_online_manual_id_from_active(
* - R: RNA
* - O: operator */
-uiBut *uiDefBut(uiBlock *block,
+uiBut *uiDefBut(uiBlock *block,
int type, int retval, const char *str,
int x1, int y1,
short x2, short y2,
@@ -601,7 +600,7 @@ uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int
uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, const char *tip);
uiBut *uiDefButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, const char *str, int x, int y, short width, short height, const char *tip);
-uiBut *uiDefIconBut(uiBlock *block,
+uiBut *uiDefIconBut(uiBlock *block,
int type, int retval, int icon,
int x1, int y1,
short x2, short y2,
@@ -665,7 +664,7 @@ enum {
typedef struct uiStringInfo {
int type;
char *strinfo;
-} uiStringInfo;
+} uiStringInfo;
/* Note: Expects pointers to uiStringInfo structs as parameters.
* Will fill them with translated strings, when possible.
@@ -824,11 +823,13 @@ void UI_panels_begin(const struct bContext *C, struct ARegion *ar);
void UI_panels_end(const struct bContext *C, struct ARegion *ar, int *x, int *y);
void UI_panels_draw(const struct bContext *C, struct ARegion *ar);
-struct Panel *UI_panel_find_by_type(struct ARegion *ar, struct PanelType *pt);
-struct Panel *UI_panel_begin(struct ScrArea *sa, struct ARegion *ar, uiBlock *block,
- struct PanelType *pt, struct Panel *pa, bool *r_open);
+struct Panel *UI_panel_find_by_type(struct ListBase *lb, struct PanelType *pt);
+struct Panel *UI_panel_begin(struct ScrArea *sa, struct ARegion *ar, struct ListBase *lb,
+ uiBlock *block, struct PanelType *pt, struct Panel *pa,
+ bool *r_open);
void UI_panel_end(uiBlock *block, int width, int height);
void UI_panels_scale(struct ARegion *ar, float new_width);
+void UI_panel_label_offset(struct uiBlock *block, int *x, int *y);
bool UI_panel_category_is_visible(struct ARegion *ar);
void UI_panel_category_add(struct ARegion *ar, const char *name);
@@ -860,7 +861,7 @@ void UI_popup_handlers_remove_all(struct bContext *C, struct ListBase *handlers)
* be used to reinitialize some internal state if user preferences change. */
void UI_init(void);
-void UI_init_userdef(void);
+void UI_init_userdef(struct Main *bmain);
void UI_reinit_font(void);
void UI_exit(void);
@@ -904,6 +905,7 @@ void UI_exit(void);
#define UI_ITEM_O_DEPRESS (1 << 9)
#define UI_ITEM_R_COMPACT (1 << 10)
+#define UI_HEADER_OFFSET_START ((void)0, 0.4f * UI_UNIT_X)
/* uiLayoutOperatorButs flags */
enum {
@@ -943,7 +945,6 @@ uiBlock *uiLayoutGetBlock(uiLayout *layout);
void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv);
void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr);
void uiLayoutContextCopy(uiLayout *layout, struct bContextStore *context);
-const char *uiLayoutIntrospect(uiLayout *layout); // XXX - testing
struct MenuType *UI_but_menutype_get(uiBut *but);
struct PanelType *UI_but_paneltype_get(uiBut *but);
void UI_menutype_draw(struct bContext *C, struct MenuType *mt, struct uiLayout *layout);
@@ -979,6 +980,8 @@ bool uiLayoutGetPropSep(uiLayout *layout);
uiLayout *uiLayoutRow(uiLayout *layout, int align);
uiLayout *uiLayoutColumn(uiLayout *layout, int align);
uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align);
+uiLayout *uiLayoutGridFlow(
+ uiLayout *layout, int row_major, int num_columns, int even_columns, int even_rows, int align);
uiLayout *uiLayoutBox(uiLayout *layout);
uiLayout *uiLayoutListBox(uiLayout *layout, struct uiList *ui_list, struct PointerRNA *ptr, struct PropertyRNA *prop,
struct PointerRNA *actptr, struct PropertyRNA *actprop);
@@ -1004,7 +1007,7 @@ void uiTemplateIDTabs(
PointerRNA *ptr, const char *propname,
const char *newop, const char *openop, const char *unlinkop,
int filter);
-void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
+void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
const char *proptypename, const char *text);
void uiTemplateSearch(
uiLayout *layout, struct bContext *C,
@@ -1017,7 +1020,7 @@ void uiTemplateSearchPreview(
struct PointerRNA *searchptr, const char *searchpropname,
const char *newop, const char *unlinkop,
const int rows, const int cols);
-void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
+void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
struct PointerRNA *root_ptr, const char *text);
uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
@@ -1125,6 +1128,7 @@ void uiItemLDrag(uiLayout *layout, struct PointerRNA *ptr, const char *name, int
void uiItemM(uiLayout *layout, struct bContext *C, const char *menuname, const char *name, int icon); /* menu */
void uiItemV(uiLayout *layout, const char *name, int icon, int argval); /* value */
void uiItemS(uiLayout *layout); /* separator */
+void uiItemSpacer(uiLayout *layout); /* Special separator. */
void uiItemPopoverPanel_ptr(
uiLayout *layout, struct bContext *C,
@@ -1245,10 +1249,10 @@ void UI_widgetbase_draw_cache_flush(void);
void UI_widgetbase_draw_cache_end(void);
/* Special drawing for toolbar, mainly workarounds for inflexible icon sizing. */
-#define USE_TOOLBAR_HACK
+#define USE_UI_TOOLBAR_HACK
/* Support click-drag motion which presses the button and closes a popover (like a menu). */
-#define USE_POPOVER_ONCE
+#define USE_UI_POPOVER_ONCE
bool UI_but_is_tool(const uiBut *but);
diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h
index a3be887bf5b..651081c46bb 100644
--- a/source/blender/editors/include/UI_interface_icons.h
+++ b/source/blender/editors/include/UI_interface_icons.h
@@ -21,7 +21,7 @@
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
- *
+ *
* ***** END GPL LICENSE BLOCK *****
*/
@@ -49,7 +49,7 @@ typedef struct IconFile {
#define ICON_DEFAULT_HEIGHT 16
#define ICON_DEFAULT_WIDTH 16
-#define ICON_DEFAULT_HEIGHT_TOOLBAR 38
+#define ICON_DEFAULT_HEIGHT_TOOLBAR 32
#define ICON_DEFAULT_HEIGHT_SCALE ((int)(UI_UNIT_Y * 0.8f))
#define ICON_DEFAULT_WIDTH_SCALE ((int)(UI_UNIT_X * 0.8f))
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index 2fc9b2946fb..cab0fa8645d 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -21,7 +21,7 @@
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
- *
+ *
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -56,7 +56,7 @@ typedef enum ThemeColorID {
TH_THEMEUI,
// common colors among spaces
-
+
TH_BACK,
TH_TEXT,
TH_TEXT_HI,
@@ -65,22 +65,23 @@ typedef enum ThemeColorID {
TH_TAB_INACTIVE,
TH_TAB_BACK,
TH_TAB_OUTLINE,
-
+
TH_HEADER,
TH_HEADERDESEL,
TH_HEADER_TEXT,
TH_HEADER_TEXT_HI,
-
+
/* panels */
TH_PANEL_HEADER,
TH_PANEL_BACK,
+ TH_PANEL_SUB_BACK,
TH_PANEL_SHOW_HEADER,
TH_PANEL_SHOW_BACK,
-
+
TH_BUTBACK,
TH_BUTBACK_TEXT,
TH_BUTBACK_TEXT_HI,
-
+
TH_SHADE1,
TH_SHADE2,
TH_HILITE,
@@ -141,14 +142,14 @@ typedef enum ThemeColorID {
TH_SYNTAX_D,
TH_SYNTAX_N,
TH_SYNTAX_S,
-
+
TH_BONE_SOLID,
TH_BONE_POSE,
TH_BONE_POSE_ACTIVE,
-
+
TH_STRIP,
TH_STRIP_SELECT,
-
+
TH_KEYTYPE_KEYFRAME, /* KEYTYPES */
TH_KEYTYPE_KEYFRAME_SELECT,
TH_KEYTYPE_EXTREME,
@@ -157,15 +158,15 @@ typedef enum ThemeColorID {
TH_KEYTYPE_BREAKDOWN_SELECT,
TH_KEYTYPE_JITTER,
TH_KEYTYPE_JITTER_SELECT,
-
+
TH_KEYBORDER,
TH_KEYBORDER_SELECT,
-
+
TH_LAMP,
TH_SPEAKER,
TH_CAMERA,
TH_EMPTY,
-
+
TH_NODE,
TH_NODE_INPUT,
TH_NODE_OUTPUT,
@@ -183,14 +184,14 @@ typedef enum ThemeColorID {
TH_NODE_FRAME,
TH_NODE_MATTE,
TH_NODE_DISTORT,
-
+
TH_CONSOLE_OUTPUT,
TH_CONSOLE_INPUT,
TH_CONSOLE_INFO,
TH_CONSOLE_ERROR,
TH_CONSOLE_CURSOR,
TH_CONSOLE_SELECT,
-
+
TH_SEQ_MOVIE,
TH_SEQ_MOVIECLIP,
TH_SEQ_MASK,
@@ -205,20 +206,20 @@ typedef enum ThemeColorID {
TH_EDGE_SHARP,
TH_EDITMESH_ACTIVE,
-
+
TH_HANDLE_VERTEX,
TH_HANDLE_VERTEX_SELECT,
TH_HANDLE_VERTEX_SIZE,
-
+
TH_GP_VERTEX,
TH_GP_VERTEX_SELECT,
TH_GP_VERTEX_SIZE,
-
+
TH_DOPESHEET_CHANNELOB,
TH_DOPESHEET_CHANNELSUBOB,
-
+
TH_PREVIEW_BACK,
-
+
TH_EDGE_CREASE,
TH_DRAWEXTRA_EDGELEN,
@@ -259,20 +260,20 @@ typedef enum ThemeColorID {
TH_SELECT_HIGHLIGHT, /* highlight color for selected outliner item */
TH_SKIN_ROOT,
-
+
TH_ANIM_ACTIVE, /* active action */
TH_ANIM_INACTIVE, /* no active action */
-
+
TH_NLA_TWEAK, /* 'tweaking' track in NLA */
TH_NLA_TWEAK_DUPLI, /* error/warning flag for other strips referencing dupli strip */
-
+
TH_NLA_TRANSITION,
TH_NLA_TRANSITION_SEL,
TH_NLA_META,
TH_NLA_META_SEL,
TH_NLA_SOUND,
TH_NLA_SOUND_SEL,
-
+
TH_WIDGET_EMBOSS,
TH_EDITOR_OUTLINE,
@@ -302,7 +303,7 @@ typedef enum ThemeColorID {
TH_INFO_DEBUG,
TH_INFO_DEBUG_TEXT,
TH_VIEW_OVERLAY,
-
+
TH_V3D_CLIPPING_BORDER,
TH_METADATA_BG,
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 1f106e3f08d..d407878d063 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,12 +18,12 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation, Joshua Leung
*
*
* Generic 2d view with should allow drawing grids,
- * panning, zooming, scrolling, ..
+ * panning, zooming, scrolling, ..
* ***** END GPL LICENSE BLOCK *****
*/
@@ -44,8 +44,8 @@
/* generic value to use when coordinate lies out of view when converting */
#define V2D_IS_CLIPPED 12000
-/* Common View2D view types
- * NOTE: only define a type here if it completely sets all (+/- a few) of the relevant flags
+/* Common View2D view types
+ * NOTE: only define a type here if it completely sets all (+/- a few) of the relevant flags
* and settings for a View2D region, and that set of settings is used in more
* than one specific place
*/
@@ -75,7 +75,7 @@ enum eView2D_Units {
V2D_UNIT_SECONDS = 0,
V2D_UNIT_FRAMES,
V2D_UNIT_FRAMESCALE,
-
+
/* for drawing values */
V2D_UNIT_VALUES,
V2D_UNIT_DEGREES,
@@ -95,7 +95,7 @@ enum eView2D_Gridlines {
V2D_HORIZONTAL_AXIS = (1 << 2),
V2D_VERTICAL_AXIS = (1 << 3),
V2D_HORIZONTAL_FINELINES = (1 << 4),
-
+
V2D_GRIDLINES_MAJOR = (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS | V2D_HORIZONTAL_LINES | V2D_HORIZONTAL_AXIS),
V2D_GRIDLINES_ALL = (V2D_GRIDLINES_MAJOR | V2D_HORIZONTAL_FINELINES),
};
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index a9995001659..811bd4457d8 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -53,10 +53,11 @@
#include "BKE_animsys.h"
#include "BKE_context.h"
-#include "BKE_unit.h"
+#include "BKE_idprop.h"
+#include "BKE_main.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
-#include "BKE_idprop.h"
+#include "BKE_unit.h"
#include "GPU_glew.h"
#include "GPU_matrix.h"
@@ -85,6 +86,9 @@
#include "interface_intern.h"
+/* prototypes. */
+static void ui_but_to_pixelrect(struct rcti *rect, const struct ARegion *ar, struct uiBlock *block, struct uiBut *but);
+
/* avoid unneeded calls to ui_but_value_get */
#define UI_BUT_VALUE_UNSET DBL_MAX
#define UI_GET_BUT_VALUE_INIT(_but, _value) if (_value == DBL_MAX) { (_value) = ui_but_value_get(_but); } (void)0
@@ -224,6 +228,39 @@ void ui_region_to_window(const ARegion *ar, int *x, int *y)
*y += ar->winrct.ymin;
}
+static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block)
+{
+ int sepr_flex_len = 0;
+ for (uiBut *but = block->buttons.first; but; but = but->next) {
+ if (but->type == UI_BTYPE_SEPR_SPACER) {
+ sepr_flex_len++;
+ }
+ }
+
+ if (sepr_flex_len == 0) {
+ return;
+ }
+
+ rcti rect;
+ ui_but_to_pixelrect(&rect, region, block, block->buttons.last);
+ const float buttons_width = (float)rect.xmax + UI_HEADER_OFFSET_START;
+ const float region_width = (float)region->sizex * U.dpi_fac;
+
+ if (region_width <= buttons_width) {
+ return;
+ }
+
+ const float spacing = ((region_width - buttons_width) / (float)sepr_flex_len);
+ float offset = 0;
+ for (uiBut *but = block->buttons.first; but; but = but->next) {
+ BLI_rctf_translate(&but->rect, offset, 0);
+ if (but->type == UI_BTYPE_SEPR_SPACER) {
+ offset += spacing;
+ }
+ }
+ ui_block_bounds_calc(block);
+}
+
static void ui_update_window_matrix(const wmWindow *window, const ARegion *region, uiBlock *block)
{
/* window matrix and aspect */
@@ -282,7 +319,7 @@ static void ui_block_bounds_calc_text(uiBlock *block, float offset)
UI_fontstyle_set(&style->widget);
for (init_col_bt = bt = block->buttons.first; bt; bt = bt->next) {
- if (!ELEM(bt->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE)) {
+ if (!ELEM(bt->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR_SPACER)) {
j = BLF_width(style->widget.uifont_id, bt->drawstr, sizeof(bt->drawstr));
if (j > i)
@@ -1181,6 +1218,7 @@ void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_x
{
wmWindow *window = CTX_wm_window(C);
Scene *scene = CTX_data_scene(C);
+ ARegion *region = CTX_wm_region(C);
uiBut *but;
BLI_assert(block->active);
@@ -1257,6 +1295,8 @@ void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_x
UI_block_align_end(block);
}
+ ui_update_flexible_spacing(region, block);
+
block->endblock = 1;
}
@@ -2814,11 +2854,6 @@ uiBlock *UI_block_begin(const bContext *C, ARegion *region, const char *name, sh
return block;
}
-uiBlock *UI_block_find_in_region(const char *name, ARegion *ar)
-{
- return BLI_findstring(&ar->uiblocks, name, offsetof(uiBlock, name));
-}
-
void UI_block_emboss_set(uiBlock *block, char dt)
{
block->dt = dt;
@@ -3229,7 +3264,8 @@ static uiBut *ui_def_but(
UI_BTYPE_BLOCK, UI_BTYPE_BUT, UI_BTYPE_LABEL,
UI_BTYPE_PULLDOWN, UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX,
UI_BTYPE_BUT_MENU, UI_BTYPE_SCROLL, UI_BTYPE_GRIP,
- UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE) ||
+ UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE,
+ UI_BTYPE_SEPR_SPACER) ||
(but->type >= UI_BTYPE_SEARCH_MENU))
{
/* pass */
@@ -4699,10 +4735,10 @@ void UI_init(void)
}
/* after reading userdef file */
-void UI_init_userdef(void)
+void UI_init_userdef(Main *bmain)
{
/* fix saved themes */
- init_userdef_do_versions();
+ init_userdef_do_versions(bmain);
uiStyleInit();
}
diff --git a/source/blender/editors/interface/interface_align.c b/source/blender/editors/interface/interface_align.c
index 619dce1b9d9..c945746c2df 100644
--- a/source/blender/editors/interface/interface_align.c
+++ b/source/blender/editors/interface/interface_align.c
@@ -111,7 +111,7 @@ enum {
bool ui_but_can_align(const uiBut *but)
{
const bool btype_can_align = !ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_CHECKBOX, UI_BTYPE_CHECKBOX_N,
- UI_BTYPE_TAB, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE);
+ UI_BTYPE_TAB, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR_SPACER);
return (btype_can_align && (BLI_rctf_size_x(&but->rect) > 0.0f) && (BLI_rctf_size_y(&but->rect) > 0.0f));
}
@@ -499,7 +499,8 @@ void ui_block_align_calc(uiBlock *block, const ARegion *region)
bool ui_but_can_align(uiBut *but)
{
- return !ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_CHECKBOX, UI_BTYPE_CHECKBOX_N, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE);
+ return !ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_CHECKBOX, UI_BTYPE_CHECKBOX_N,
+ UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR_SPACER);
}
static bool buts_are_horiz(uiBut *but1, uiBut *but2)
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index ea1b58107bd..fc0ad7e5dce 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -41,6 +41,7 @@
#include "BKE_context.h"
#include "BKE_fcurve.h"
#include "BKE_global.h"
+#include "BKE_main.h"
#include "BKE_nla.h"
#include "DEG_depsgraph.h"
@@ -226,6 +227,7 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
{
+ Main *bmain = CTX_data_main(C);
ID *id;
bAction *action;
FCurve *fcu;
@@ -277,7 +279,7 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
* because a button may control all items of an array at once.
* E.g., color wheels (see T42567). */
BLI_assert((fcu->array_index == but->rnaindex) || (but->rnaindex == -1));
- insert_keyframe(depsgraph, reports, id, action,
+ insert_keyframe(bmain, depsgraph, reports, id, action,
((fcu->grp) ? (fcu->grp->name) : (NULL)),
fcu->rna_path, but->rnaindex, cfra, ts->keyframe_type, flag);
diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c
index f3301d55284..a60b6f3f60b 100644
--- a/source/blender/editors/interface/interface_eyedropper_color.c
+++ b/source/blender/editors/interface/interface_eyedropper_color.c
@@ -38,6 +38,7 @@
#include "BLI_math_vector.h"
#include "BKE_context.h"
+#include "BKE_main.h"
#include "BKE_screen.h"
#include "RNA_access.h"
@@ -131,6 +132,7 @@ static void eyedropper_exit(bContext *C, wmOperator *op)
void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3])
{
/* we could use some clever */
+ Main *bmain = CTX_data_main(C);
bScreen *screen = CTX_wm_screen(C);
ScrArea *sa = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my);
const char *display_device = CTX_data_scene(C)->display_settings.display_device;
@@ -156,7 +158,7 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3])
int mval[2] = {mx - ar->winrct.xmin,
my - ar->winrct.ymin};
- if (ED_space_node_color_sample(snode, ar, mval, r_col)) {
+ if (ED_space_node_color_sample(bmain, snode, ar, mval, r_col)) {
return;
}
}
diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c
index fd9c5f1869d..df09c327da1 100644
--- a/source/blender/editors/interface/interface_eyedropper_depth.c
+++ b/source/blender/editors/interface/interface_eyedropper_depth.c
@@ -41,6 +41,7 @@
#include "BLI_math_vector.h"
#include "BKE_context.h"
+#include "BKE_main.h"
#include "BKE_screen.h"
#include "BKE_unit.h"
@@ -169,7 +170,7 @@ static void depthdropper_depth_sample_pt(bContext *C, DepthDropper *ddr, int mx,
if (sa->spacetype == SPACE_VIEW3D) {
ARegion *ar = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my);
if (ar) {
- struct Depsgraph *graph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
View3D *v3d = sa->spacedata.first;
RegionView3D *rv3d = ar->regiondata;
/* weak, we could pass in some reference point */
@@ -187,7 +188,7 @@ static void depthdropper_depth_sample_pt(bContext *C, DepthDropper *ddr, int mx,
view3d_operator_needs_opengl(C);
- if (ED_view3d_autodist(graph, ar, v3d, mval, co, true, NULL)) {
+ if (ED_view3d_autodist(depsgraph, ar, v3d, mval, co, true, NULL)) {
const float mval_center_fl[2] = {
(float)ar->winx / 2,
(float)ar->winy / 2};
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 0ebe079703b..02844f5e861 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -506,7 +506,7 @@ bool ui_but_is_toggle(const uiBut *but)
);
}
-#ifdef USE_POPOVER_ONCE
+#ifdef USE_UI_POPOVER_ONCE
bool ui_but_is_popover_once_compat(const uiBut *but)
{
return (
@@ -1400,7 +1400,7 @@ static int ui_handler_region_drag_toggle(bContext *C, const wmEvent *event, void
switch (event->type) {
case LEFTMOUSE:
{
- if (event->val != KM_PRESS) {
+ if (event->val == KM_RELEASE) {
done = true;
}
break;
@@ -3594,7 +3594,7 @@ static int ui_do_but_BUT(
button_activate_state(C, but, BUTTON_STATE_WAIT_RELEASE);
return WM_UI_HANDLER_BREAK;
}
- else if (event->type == LEFTMOUSE && but->block->handle) {
+ else if (event->type == LEFTMOUSE && event->val == KM_RELEASE && but->block->handle) {
/* regular buttons will be 'UI_SELECT', menu items 'UI_ACTIVE' */
if (!(but->flag & (UI_SELECT | UI_ACTIVE)))
data->cancel = true;
@@ -3607,7 +3607,7 @@ static int ui_do_but_BUT(
}
}
else if (data->state == BUTTON_STATE_WAIT_RELEASE) {
- if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
if (!(but->flag & UI_SELECT))
data->cancel = true;
button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -4317,7 +4317,7 @@ static int ui_do_but_NUM(
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
if (data->dragchange) {
#ifdef USE_DRAG_MULTINUM
/* if we started multibutton but didnt drag, then edit */
@@ -4625,7 +4625,7 @@ static int ui_do_but_SLI(
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
if (data->dragchange) {
#ifdef USE_DRAG_MULTINUM
/* if we started multibutton but didnt drag, then edit */
@@ -4778,7 +4778,7 @@ static int ui_do_but_SCROLL(
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if (event->type == MOUSEMOVE) {
@@ -4830,7 +4830,7 @@ static int ui_do_but_GRIP(
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if (event->type == MOUSEMOVE) {
@@ -5216,7 +5216,7 @@ static int ui_do_but_UNITVEC(
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
@@ -5550,7 +5550,7 @@ static int ui_do_but_HSVCUBE(
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
@@ -5828,7 +5828,7 @@ static int ui_do_but_HSVCIRCLE(
}
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
return WM_UI_HANDLER_BREAK;
@@ -5918,7 +5918,7 @@ static int ui_do_but_COLORBAND(
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if (ELEM(event->type, ESCKEY, RIGHTMOUSE)) {
@@ -6169,7 +6169,7 @@ static int ui_do_but_CURVE(
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
if (data->dragsel != -1) {
CurveMapping *cumap = (CurveMapping *)but->poin;
CurveMap *cuma = cumap->cm + cumap->cur;
@@ -6267,7 +6267,7 @@ static int ui_do_but_HISTOGRAM(
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
return WM_UI_HANDLER_BREAK;
@@ -6342,7 +6342,7 @@ static int ui_do_but_WAVEFORM(
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
return WM_UI_HANDLER_BREAK;
@@ -6426,7 +6426,7 @@ static int ui_do_but_TRACKPREVIEW(
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
return WM_UI_HANDLER_BREAK;
@@ -6792,16 +6792,8 @@ static bool ui_but_menu(bContext *C, uiBut *but)
else if (is_anim) {
uiItemS(layout);
- if (is_array_component) {
- uiItemMenuEnumO(layout, C, "ANIM_OT_driver_button_add", "mapping_type",
- CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Drivers"),
- ICON_DRIVER);
- }
- else {
- uiItemMenuEnumO(layout, C, "ANIM_OT_driver_button_add", "mapping_type",
- CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"),
- ICON_DRIVER);
- }
+ uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"),
+ ICON_DRIVER, "ANIM_OT_driver_button_add");
if (ANIM_driver_can_paste()) {
uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"),
@@ -7185,6 +7177,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
/* quiet warnings for unhandled types */
case UI_BTYPE_SEPR:
case UI_BTYPE_SEPR_LINE:
+ case UI_BTYPE_SEPR_SPACER:
case UI_BTYPE_EXTRA:
break;
}
@@ -8362,7 +8355,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
data->cancel = true;
button_activate_state(C, but, BUTTON_STATE_EXIT);
break;
-#ifdef USE_POPOVER_ONCE
+#ifdef USE_UI_POPOVER_ONCE
case LEFTMOUSE:
{
if (event->val == KM_RELEASE) {
@@ -9527,7 +9520,7 @@ static int ui_handle_menu_event(
retval = ui_handle_menu_button(C, event, menu);
}
-#ifdef USE_POPOVER_ONCE
+#ifdef USE_UI_POPOVER_ONCE
if (block->flag & UI_BLOCK_POPOVER_ONCE) {
if ((event->type == LEFTMOUSE) && (event->val == KM_RELEASE)) {
UI_popover_once_clear(menu->popup_create_vars.arg);
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index bacea087677..c2ada1e3733 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1252,7 +1252,7 @@ static void icon_draw_size(
/* We need to flush widget base first to ensure correct ordering. */
UI_widgetbase_draw_cache_flush();
-#ifdef USE_TOOLBAR_HACK
+#ifdef USE_UI_TOOLBAR_HACK
/* TODO(campbell): scale icons up for toolbar, we need a way to detect larger buttons and do this automatic. */
{
float scale = (float)ICON_DEFAULT_HEIGHT_TOOLBAR / (float)ICON_DEFAULT_HEIGHT;
@@ -1371,7 +1371,8 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
int tool = PAINT_TOOL_DRAW, mode = 0;
ScrArea *sa = CTX_wm_area(C);
char space_type = sa->spacetype;
- if (space_type == SPACE_TOPBAR) {
+ /* When in an unsupported space. */
+ if (!ELEM(space_type, SPACE_VIEW3D, SPACE_IMAGE)) {
space_type = workspace->tools_space_type;
}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index c7cf03a44dd..b5bf9be737b 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -784,7 +784,7 @@ void ui_icon_ensure_deferred(const struct bContext *C, const int icon_id, const
int ui_id_icon_get(const struct bContext *C, struct ID *id, const bool big);
/* resources.c */
-void init_userdef_do_versions(void);
+void init_userdef_do_versions(struct Main *bmain);
void ui_theme_init_default(void);
void ui_style_init_default(void);
void ui_resources_init(void);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 7991f03ea31..9888c6d65cc 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -37,6 +37,7 @@
#include "DNA_armature_types.h"
#include "DNA_userdef_types.h"
+#include "BLI_alloca.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_rect.h"
@@ -101,6 +102,7 @@ typedef enum uiItemType {
ITEM_LAYOUT_COLUMN,
ITEM_LAYOUT_COLUMN_FLOW,
ITEM_LAYOUT_ROW_FLOW,
+ ITEM_LAYOUT_GRID_FLOW,
ITEM_LAYOUT_BOX,
ITEM_LAYOUT_ABSOLUTE,
ITEM_LAYOUT_SPLIT,
@@ -152,6 +154,7 @@ struct uiLayout {
bool enabled;
bool redalert;
bool keepaspect;
+ bool variable_size; /* For layouts inside gridflow, they and their items shall never have a fixed maximal size. */
char alignment;
char emboss;
};
@@ -162,6 +165,22 @@ typedef struct uiLayoutItemFlow {
int totcol;
} uiLayoutItemFlow;
+typedef struct uiLayoutItemGridFlow {
+ uiLayout litem;
+
+ /* Extra parameters */
+ bool row_major; /* Fill first row first, instead of filling first column first. */
+ bool even_columns; /* Same width for all columns. */
+ bool even_rows; /* Same height for all rows. */
+ /* If positive, absolute fixed number of columns.
+ * If 0, fully automatic (based on available width).
+ * If negative, automatic but only generates number of columns/rows multiple of given (absolute) value. */
+ int num_columns;
+
+ /* Pure internal runtime storage. */
+ int tot_items, tot_columns, tot_rows;
+} uiLayoutItemGridFlow;
+
typedef struct uiLayoutItemBx {
uiLayout litem;
uiBut *roundbox;
@@ -237,6 +256,13 @@ static int ui_layout_vary_direction(uiLayout *layout)
UI_ITEM_VARY_X : UI_ITEM_VARY_Y);
}
+static bool ui_layout_variable_size(uiLayout *layout)
+{
+ /* Note that this code is probably a bit flacky, we'd probably want to know whether it's variable in X and/or Y,
+ * etc. But for now it mimics previous one, with addition of variable flag set for children of gridflow layouts. */
+ return ui_layout_vary_direction(layout) == UI_ITEM_VARY_X || layout->variable_size;
+}
+
/* estimated size of text + icon */
static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool compact)
{
@@ -246,7 +272,7 @@ static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool
if (icon && !name[0])
return unit_x; /* icon only */
- variable = (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X);
+ variable = ui_layout_variable_size(layout);
if (variable) {
if (layout->alignment != UI_LAYOUT_ALIGN_EXPAND) {
@@ -347,6 +373,7 @@ static int ui_layout_local_dir(uiLayout *layout)
return UI_LAYOUT_HORIZONTAL;
case ITEM_LAYOUT_COLUMN:
case ITEM_LAYOUT_COLUMN_FLOW:
+ case ITEM_LAYOUT_GRID_FLOW:
case ITEM_LAYOUT_SPLIT:
case ITEM_LAYOUT_ABSOLUTE:
case ITEM_LAYOUT_BOX:
@@ -701,6 +728,7 @@ static uiBut *ui_item_with_label(
PropertyType type;
PropertySubType subtype;
int prop_but_width = w_hint;
+ const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
sub = uiLayoutRow(layout, layout->align);
UI_block_layout_set_current(block, sub);
@@ -708,15 +736,25 @@ static uiBut *ui_item_with_label(
if (name[0]) {
int w_label;
- if (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X) {
- /* w_hint is width for label in this case. Use a default width for property button(s) */
- prop_but_width = UI_UNIT_X * 5;
- w_label = w_hint;
+ if (use_prop_sep) {
+ w_label = (int)((w_hint * 2) * UI_ITEM_PROP_SEP_DIVIDE);
}
else {
- w_label = w_hint / 3;
+ if (ui_layout_variable_size(layout)) {
+ /* w_hint is width for label in this case. Use a default width for property button(s) */
+ prop_but_width = UI_UNIT_X * 5;
+ w_label = w_hint;
+ }
+ else {
+ w_label = w_hint / 3;
+ }
+ }
+
+ uiBut *but_label = uiDefBut(block, UI_BTYPE_LABEL, 0, name, x, y, w_label, h, NULL, 0.0, 0.0, 0, 0, "");
+ if (use_prop_sep) {
+ but_label->drawflag |= UI_BUT_TEXT_RIGHT;
+ but_label->drawflag &= ~UI_BUT_TEXT_LEFT;
}
- uiDefBut(block, UI_BTYPE_LABEL, 0, name, x, y, w_label, h, NULL, 0.0, 0.0, 0, 0, "");
}
type = RNA_property_type(prop);
@@ -1415,7 +1453,7 @@ static void ui_item_rna_size(
else
h += len * UI_UNIT_Y;
}
- else if (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X) {
+ else if (ui_layout_variable_size(layout)) {
if (type == PROP_BOOLEAN && name[0])
w += UI_UNIT_X / 5;
else if (type == PROP_ENUM && !icon_only)
@@ -1520,45 +1558,55 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
/* Split the label / property. */
if (use_prop_sep) {
- uiLayout *layout_split = uiLayoutSplit(layout, UI_ITEM_PROP_SEP_DIVIDE, true);
- layout_split->space = 0;
- uiLayout *layout_sub = uiLayoutColumn(layout_split, true);
- layout_sub->space = 0;
-
- if (index == RNA_NO_INDEX && is_array) {
- char name_with_suffix[UI_MAX_DRAW_STR + 2];
- char str[2] = {'\0'};
- for (int a = 0; a < len; a++) {
- str[0] = RNA_property_array_item_char(prop, a);
- const bool use_prefix = (a == 0 && name && name[0]);
- if (use_prefix) {
- char *s = name_with_suffix;
- s += STRNCPY_RLEN(name_with_suffix, name);
- *s++ = ' ';
- *s++ = str[0];
- *s++ = '\0';
- }
- but = uiDefBut(
- block, UI_BTYPE_LABEL, 0, use_prefix ? name_with_suffix : str,
- 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
- but->drawflag |= UI_BUT_TEXT_RIGHT;
- but->drawflag &= ~UI_BUT_TEXT_LEFT;
- }
+ if (name[0] == '\0') {
+ /* Ensure we get a column when text is not set. */
+ layout = uiLayoutColumn(layout, true);
+ layout->space = 0;
}
else {
- if (name) {
- but = uiDefBut(
- block, UI_BTYPE_LABEL, 0, name,
- 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
- but->drawflag |= UI_BUT_TEXT_RIGHT;
- but->drawflag &= ~UI_BUT_TEXT_LEFT;
+ const PropertySubType subtype = RNA_property_subtype(prop);
+ uiLayout *layout_split = uiLayoutSplit(layout, UI_ITEM_PROP_SEP_DIVIDE, true);
+ layout_split->space = 0;
+ uiLayout *layout_sub = uiLayoutColumn(layout_split, true);
+ layout_sub->space = 0;
+
+ if ((index == RNA_NO_INDEX && is_array) &&
+ ((!expand && ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA, PROP_DIRECTION)) == 0))
+ {
+ char name_with_suffix[UI_MAX_DRAW_STR + 2];
+ char str[2] = {'\0'};
+ for (int a = 0; a < len; a++) {
+ str[0] = RNA_property_array_item_char(prop, a);
+ const bool use_prefix = (a == 0 && name && name[0]);
+ if (use_prefix) {
+ char *s = name_with_suffix;
+ s += STRNCPY_RLEN(name_with_suffix, name);
+ *s++ = ' ';
+ *s++ = str[0];
+ *s++ = '\0';
+ }
+ but = uiDefBut(
+ block, UI_BTYPE_LABEL, 0, use_prefix ? name_with_suffix : str,
+ 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+ but->drawflag |= UI_BUT_TEXT_RIGHT;
+ but->drawflag &= ~UI_BUT_TEXT_LEFT;
+ }
+ }
+ else {
+ if (name) {
+ but = uiDefBut(
+ block, UI_BTYPE_LABEL, 0, name,
+ 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+ but->drawflag |= UI_BUT_TEXT_RIGHT;
+ but->drawflag &= ~UI_BUT_TEXT_LEFT;
+ }
}
- }
- /* Watch out! We can only write into the new column now. */
- layout = uiLayoutColumn(layout_split, true);
- layout->space = 0;
- name = "";
+ /* Watch out! We can only write into the new column now. */
+ layout = uiLayoutColumn(layout_split, true);
+ layout->space = 0;
+ name = "";
+ }
}
/* End split. */
@@ -1841,6 +1889,7 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
StructRNA *icontype;
int w, h;
char namestr[UI_MAX_NAME_STR];
+ const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
/* validate arguments */
prop = RNA_struct_find_property(ptr, propname);
@@ -1883,7 +1932,9 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
if (!name)
name = RNA_property_ui_name(prop);
- name = ui_item_name_add_colon(name, namestr);
+ if (use_prop_sep == false) {
+ name = ui_item_name_add_colon(name, namestr);
+ }
/* create button */
block = uiLayoutGetBlock(layout);
@@ -1993,12 +2044,23 @@ void uiItemPopoverPanel_ptr(uiLayout *layout, bContext *C, PanelType *pt, const
name = CTX_IFACE_(pt->translation_context, pt->label);
}
- if (layout->root->type == UI_LAYOUT_MENU && !icon)
+ if (layout->root->type == UI_LAYOUT_MENU && !icon) {
icon = ICON_BLANK1;
+ }
+ const bool ok = (pt->poll == NULL) || pt->poll(C, pt);
+ if (ok && (pt->draw_header != NULL)) {
+ layout = uiLayoutRow(layout, true);
+ Panel panel = {
+ .type = pt,
+ .layout = layout,
+ .flag = PNL_POPOVER,
+ };
+ pt->draw_header(C, &panel);
+ }
uiBut *but = ui_item_menu(layout, name, icon, ui_item_paneltype_func, pt, NULL, NULL, true);
but->type = UI_BTYPE_POPOVER;
- if (pt->poll && (pt->poll(C, pt) == false)) {
+ if (!ok) {
but->flag |= UI_BUT_DISABLED;
}
}
@@ -2051,10 +2113,12 @@ void uiItemPopoverPanelFromGroup(
for (PanelType *pt = art->paneltypes.first; pt; pt = pt->next) {
/* Causes too many panels, check context. */
- if (/* (*context == '\0') || */ STREQ(pt->context, context)) {
- if ((*category == '\0') || STREQ(pt->category, category)) {
- if (pt->poll == NULL || pt->poll(C, pt)) {
- uiItemPopoverPanel_ptr(layout, C, pt, NULL, ICON_NONE);
+ if (pt->parent_id[0] == '\0') {
+ if (/* (*context == '\0') || */ STREQ(pt->context, context)) {
+ if ((*category == '\0') || STREQ(pt->category, category)) {
+ if (pt->poll == NULL || pt->poll(C, pt)) {
+ uiItemPopoverPanel_ptr(layout, C, pt, NULL, ICON_NONE);
+ }
}
}
}
@@ -2152,6 +2216,26 @@ void uiItemS(uiLayout *layout)
uiDefBut(block, (is_menu) ? UI_BTYPE_SEPR_LINE : UI_BTYPE_SEPR, 0, "", 0, 0, space, space, NULL, 0.0, 0.0, 0, 0, "");
}
+/* Flexible spacing. */
+void uiItemSpacer(uiLayout *layout)
+{
+ uiBlock *block = layout->root->block;
+ bool is_menu = ui_block_is_menu(block);
+
+ if (is_menu) {
+ printf("Error: separator_spacer() not supported in menus.\n");
+ return;
+ }
+
+ if (block->direction & UI_DIR_RIGHT) {
+ printf("Error: separator_spacer() only supported in horizontal blocks.\n");
+ return;
+ }
+
+ UI_block_layout_set_current(block, layout);
+ uiDefBut(block, UI_BTYPE_SEPR_SPACER, 0, "", 0, 0, 0.3f * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+}
+
/* level items */
void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg)
{
@@ -2535,7 +2619,7 @@ static bool ui_item_is_radial_displayable(uiItem *item)
static bool ui_item_is_radial_drawable(uiButtonItem *bitem)
{
- if (ELEM(bitem->but->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE))
+ if (ELEM(bitem->but->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR_SPACER))
return false;
return true;
@@ -2808,6 +2892,355 @@ static void ui_litem_layout_column_flow(uiLayout *litem)
litem->y = miny;
}
+/* multi-column and multi-row layout. */
+typedef struct UILayoutGridFlowInput {
+ /* General layout controll settings. */
+ const bool row_major : 1; /* Fill rows before columns */
+ const bool even_columns : 1; /* All columns will have same width. */
+ const bool even_rows : 1; /* All rows will have same height. */
+ const int space_x; /* Space between columns. */
+ const int space_y; /* Space between rows. */
+ /* Real data about current position and size of this layout item (either estimated, or final values). */
+ const int litem_w; /* Layout item width. */
+ const int litem_x; /* Layout item X position. */
+ const int litem_y; /* Layout item Y position. */
+ /* Actual number of columns and rows to generate (computed from first pass usually). */
+ const int tot_columns; /* Number of columns. */
+ const int tot_rows; /* Number of rows. */
+} UILayoutGridFlowInput;
+
+typedef struct UILayoutGridFlowOutput {
+ int *tot_items; /* Total number of items in this grid layout. */
+ /* Width / X pos data. */
+ float *global_avg_w; /* Computed average width of the columns. */
+ int *cos_x_array; /* Computed X coordinate of each column. */
+ int *widths_array; /* Computed width of each column. */
+ int *tot_w; /* Computed total width. */
+ /* Height / Y pos data. */
+ int *global_max_h; /* Computed height of the tallest item in the grid. */
+ int *cos_y_array; /* Computed Y coordinate of each column. */
+ int *heights_array; /* Computed height of each column. */
+ int *tot_h; /* Computed total height. */
+} UILayoutGridFlowOutput;
+
+static void ui_litem_grid_flow_compute(
+ ListBase *items, UILayoutGridFlowInput *parameters, UILayoutGridFlowOutput *results)
+{
+ uiItem *item;
+ int i;
+
+ float tot_w = 0.0f, tot_h = 0.0f;
+ float global_avg_w = 0.0f, global_totweight_w = 0.0f;
+ int global_max_h = 0;
+
+ float *avg_w = NULL, *totweight_w = NULL;
+ int *max_h = NULL;
+
+ BLI_assert(parameters->tot_columns != 0 || (results->cos_x_array == NULL && results->widths_array == NULL && results->tot_w == NULL));
+ BLI_assert(parameters->tot_rows != 0 || (results->cos_y_array == NULL && results->heights_array == NULL && results->tot_h == NULL));
+
+ if (results->tot_items) {
+ *results->tot_items = 0;
+ }
+
+ if (items->first == NULL) {
+ if (results->global_avg_w) {
+ *results->global_avg_w = 0.0f;
+ }
+ if (results->global_max_h) {
+ *results->global_max_h = 0;
+ }
+ return;
+ }
+
+ if (parameters->tot_columns != 0) {
+ avg_w = BLI_array_alloca(avg_w, parameters->tot_columns);
+ totweight_w = BLI_array_alloca(totweight_w, parameters->tot_columns);
+ memset(avg_w, 0, sizeof(*avg_w) * parameters->tot_columns);
+ memset(totweight_w, 0, sizeof(*totweight_w) * parameters->tot_columns);
+ }
+ if (parameters->tot_rows != 0) {
+ max_h = BLI_array_alloca(max_h, parameters->tot_rows);
+ memset(max_h, 0, sizeof(*max_h) * parameters->tot_rows);
+ }
+
+ for (i = 0, item = items->first; item; item = item->next, i++) {
+ int item_w, item_h;
+ ui_item_size(item, &item_w, &item_h);
+
+ global_avg_w += (float)(item_w * item_w);
+ global_totweight_w += (float)item_w;
+ global_max_h = max_ii(global_max_h, item_h);
+
+ if (parameters->tot_rows != 0 && parameters->tot_columns != 0) {
+ const int index_col = parameters->row_major ? i % parameters->tot_columns : i / parameters->tot_rows;
+ const int index_row = parameters->row_major ? i / parameters->tot_columns : i % parameters->tot_rows;
+
+ avg_w[index_col] += (float)(item_w * item_w);
+ totweight_w[index_col] += (float)item_w;
+
+ max_h[index_row] = max_ii(max_h[index_row], item_h);
+ }
+
+ if (results->tot_items) {
+ (*results->tot_items)++;
+ }
+ }
+
+ /* Finalize computing of column average sizes */
+ global_avg_w /= global_totweight_w;
+ if (parameters->tot_columns != 0) {
+ for (i = 0; i < parameters->tot_columns; i++) {
+ avg_w[i] /= totweight_w[i];
+ tot_w += avg_w[i];
+ }
+ if (parameters->even_columns) {
+ tot_w = ceilf(global_avg_w) * parameters->tot_columns;
+ }
+ }
+ /* Finalize computing of rows max sizes */
+ if (parameters->tot_rows != 0) {
+ for (i = 0; i < parameters->tot_rows; i++) {
+ tot_h += max_h[i];
+ }
+ if (parameters->even_rows) {
+ tot_h = global_max_h * parameters->tot_columns;
+ }
+ }
+
+ /* Compute positions and sizes of all cells. */
+ if (results->cos_x_array != NULL && results->widths_array != NULL) {
+ /* We enlarge/narrow columns evenly to match available width. */
+ const float wfac = (float)(parameters->litem_w - (parameters->tot_columns - 1) * parameters->space_x) / tot_w;
+
+ for (int col = 0; col < parameters->tot_columns; col++) {
+ results->cos_x_array[col] = col ? results->cos_x_array[col - 1] + results->widths_array[col - 1] + parameters->space_x : parameters->litem_x;
+ if (parameters->even_columns) {
+ /* (< remaining width > - < space between remaining columns >) / < remaining columns > */
+ results->widths_array[col] = ((parameters->litem_w - (results->cos_x_array[col] - parameters->litem_x)) - (parameters->tot_columns - col - 1) * parameters->space_x) / (parameters->tot_columns - col);
+ }
+ else if (col == parameters->tot_columns - 1) {
+ /* Last column copes width rounding errors... */
+ results->widths_array[col] = parameters->litem_w - (results->cos_x_array[col] - parameters->litem_x);
+ }
+ else {
+ results->widths_array[col] = (int)(avg_w[col] * wfac);
+ }
+ }
+ }
+ if (results->cos_y_array != NULL && results->heights_array != NULL) {
+ for (int row = 0; row < parameters->tot_rows; row++) {
+ if (parameters->even_rows) {
+ results->heights_array[row] = global_max_h;
+ }
+ else {
+ results->heights_array[row] = max_h[row];
+ }
+ results->cos_y_array[row] = row ? results->cos_y_array[row - 1] - parameters->space_y - results->heights_array[row] : parameters->litem_y - results->heights_array[row];
+ }
+ }
+
+ if (results->global_avg_w) {
+ *results->global_avg_w = global_avg_w;
+ }
+ if (results->global_max_h) {
+ *results->global_max_h = global_max_h;
+ }
+ if (results->tot_w) {
+ *results->tot_w = (int)tot_w + parameters->space_x * (parameters->tot_columns - 1);
+ }
+ if (results->tot_h) {
+ *results->tot_h = tot_h + parameters->space_y * (parameters->tot_rows - 1);
+ }
+}
+
+static void ui_litem_estimate_grid_flow(uiLayout *litem)
+{
+ uiStyle *style = litem->root->style;
+ uiLayoutItemGridFlow *gflow = (uiLayoutItemGridFlow *)litem;
+
+ const int space_x = style->columnspace;
+ const int space_y = style->buttonspacey;
+
+ /* Estimate average needed width and height per item. */
+ {
+ float avg_w;
+ int max_h;
+
+ ui_litem_grid_flow_compute(
+ &litem->items,
+ &((UILayoutGridFlowInput) {
+ .row_major = gflow->row_major,
+ .even_columns = gflow->even_columns,
+ .even_rows = gflow->even_rows,
+ .litem_w = litem->w,
+ .litem_x = litem->x,
+ .litem_y = litem->y,
+ .space_x = space_x,
+ .space_y = space_y,
+ }),
+ &((UILayoutGridFlowOutput) {
+ .tot_items = &gflow->tot_items,
+ .global_avg_w = &avg_w,
+ .global_max_h = &max_h,
+ }));
+
+ if (gflow->tot_items == 0) {
+ litem->w = litem->h = 0;
+ gflow->tot_columns = gflow->tot_rows = 0;
+ return;
+ }
+
+ /* Even in varying column width case, we fix our columns number from weighted average width of items,
+ * a proper solving of required width would be too costly, and this should give reasonably good results
+ * in all resonable cases... */
+ if (gflow->num_columns > 0) {
+ gflow->tot_columns = gflow->num_columns;
+ }
+ else {
+ if (avg_w == 0.0f) {
+ gflow->tot_columns = 1;
+ }
+ else {
+ gflow->tot_columns = min_ii(max_ii((int)(litem->w / avg_w), 1), gflow->tot_items);
+ }
+ }
+ gflow->tot_rows = (int)ceilf((float)gflow->tot_items / gflow->tot_columns);
+
+ /* Try to tweak number of columns and rows to get better filling of last column or row,
+ * and apply 'modulo' value to number of columns or rows.
+ * Note that modulo does not prevent ending with fewer columns/rows than modulo, if mandatory
+ * to avoid empty column/row. */
+ {
+ const int modulo = (gflow->num_columns < -1) ? -gflow->num_columns : 0;
+ const int step = modulo ? modulo : 1;
+
+ if (gflow->row_major) {
+ /* Adjust number of columns to be mutiple of given modulo. */
+ if (modulo && gflow->tot_columns % modulo != 0 && gflow->tot_columns > modulo) {
+ gflow->tot_columns = gflow->tot_columns - (gflow->tot_columns % modulo);
+ }
+ /* Find smallest number of columns conserving computed optimal number of rows. */
+ for (gflow->tot_rows = (int)ceilf((float)gflow->tot_items / gflow->tot_columns);
+ (gflow->tot_columns - step) > 0 &&
+ (int)ceilf((float)gflow->tot_items / (gflow->tot_columns - step)) <= gflow->tot_rows;
+ gflow->tot_columns -= step);
+ }
+ else {
+ /* Adjust number of rows to be mutiple of given modulo. */
+ if (modulo && gflow->tot_rows % modulo != 0) {
+ gflow->tot_rows = min_ii(gflow->tot_rows + modulo - (gflow->tot_rows % modulo), gflow->tot_items);
+ }
+ /* Find smallest number of rows conserving computed optimal number of columns. */
+ for (gflow->tot_columns = (int)ceilf((float)gflow->tot_items / gflow->tot_rows);
+ (gflow->tot_rows - step) > 0 &&
+ (int)ceilf((float)gflow->tot_items / (gflow->tot_rows - step)) <= gflow->tot_columns;
+ gflow->tot_rows -= step);
+ }
+ }
+
+ /* Set evenly-spaced axes size (quick optimization in case we have even columns and rows). */
+ if (gflow->even_columns && gflow->even_rows) {
+ litem->w = (int)(gflow->tot_columns * avg_w) + space_x * (gflow->tot_columns - 1);
+ litem->h = (int)(gflow->tot_rows * max_h) + space_y * (gflow->tot_rows - 1);
+ return;
+ }
+ }
+
+ /* Now that we have our final number of columns and rows,
+ * we can compute actual needed space for non-evenly sized axes. */
+ {
+ int tot_w, tot_h;
+
+ ui_litem_grid_flow_compute(
+ &litem->items,
+ &((UILayoutGridFlowInput) {
+ .row_major = gflow->row_major,
+ .even_columns = gflow->even_columns,
+ .even_rows = gflow->even_rows,
+ .litem_w = litem->w,
+ .litem_x = litem->x,
+ .litem_y = litem->y,
+ .space_x = space_x,
+ .space_y = space_y,
+ .tot_columns = gflow->tot_columns,
+ .tot_rows = gflow->tot_rows,
+ }),
+ &((UILayoutGridFlowOutput) {
+ .tot_w = &tot_w,
+ .tot_h = &tot_h,
+ }));
+
+ litem->w = tot_w;
+ litem->h = tot_h;
+ }
+}
+
+static void ui_litem_layout_grid_flow(uiLayout *litem)
+{
+ int i;
+ uiStyle *style = litem->root->style;
+ uiLayoutItemGridFlow *gflow = (uiLayoutItemGridFlow *)litem;
+ uiItem *item;
+
+ if (gflow->tot_items == 0) {
+ litem->w = litem->h = 0;
+ return;
+ }
+
+ BLI_assert(gflow->tot_columns > 0);
+ BLI_assert(gflow->tot_rows > 0);
+
+ const int space_x = style->columnspace;
+ const int space_y = style->buttonspacey;
+
+ int *widths = BLI_array_alloca(widths, gflow->tot_columns);
+ int *heights = BLI_array_alloca(heights, gflow->tot_rows);
+ int *cos_x = BLI_array_alloca(cos_x, gflow->tot_columns);
+ int *cos_y = BLI_array_alloca(cos_y, gflow->tot_rows);
+
+ /* This time we directly compute coordinates and sizes of all cells. */
+ ui_litem_grid_flow_compute(
+ &litem->items,
+ &((UILayoutGridFlowInput) {
+ .row_major = gflow->row_major,
+ .even_columns = gflow->even_columns,
+ .even_rows = gflow->even_rows,
+ .litem_w = litem->w,
+ .litem_x = litem->x,
+ .litem_y = litem->y,
+ .space_x = space_x,
+ .space_y = space_y,
+ .tot_columns = gflow->tot_columns,
+ .tot_rows = gflow->tot_rows,
+ }),
+ &((UILayoutGridFlowOutput) {
+ .cos_x_array = cos_x,
+ .cos_y_array = cos_y,
+ .widths_array = widths,
+ .heights_array = heights,
+ }));
+
+ for (item = litem->items.first, i = 0; item; item = item->next, i++) {
+ const int col = gflow->row_major ? i % gflow->tot_columns : i / gflow->tot_rows;
+ const int row = gflow->row_major ? i / gflow->tot_columns : i % gflow->tot_rows;
+ int item_w, item_h;
+ ui_item_size(item, &item_w, &item_h);
+
+ const int w = widths[col];
+ const int h = heights[row];
+
+ item_w = (litem->alignment == UI_LAYOUT_ALIGN_EXPAND) ? w : min_ii(w, item_w);
+ item_h = (litem->alignment == UI_LAYOUT_ALIGN_EXPAND) ? h : min_ii(h, item_h);
+
+ ui_item_position(item, cos_x[col], cos_y[row], item_w, item_h);
+ }
+
+ litem->h = litem->y - cos_y[gflow->tot_rows - 1];
+ litem->x = (cos_x[gflow->tot_columns - 1] - litem->x) + widths[gflow->tot_columns - 1];
+ litem->y = litem->y - litem->h;
+}
+
/* free layout */
static void ui_litem_estimate_absolute(uiLayout *litem)
{
@@ -2981,6 +3414,8 @@ static void ui_litem_init_from_parent(uiLayout *litem, uiLayout *layout, int ali
{
litem->root = layout->root;
litem->align = align;
+ /* Children of gridflow layout shall never have "ideal big size" returned as estimated size. */
+ litem->variable_size = layout->variable_size || layout->item.type == ITEM_LAYOUT_GRID_FLOW;
litem->active = true;
litem->enabled = true;
litem->context = layout->context;
@@ -3038,6 +3473,26 @@ uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align)
return &flow->litem;
}
+uiLayout *uiLayoutGridFlow(
+ uiLayout *layout, int row_major, int num_columns, int even_columns, int even_rows, int align)
+{
+ uiLayoutItemGridFlow *flow;
+
+ flow = MEM_callocN(sizeof(uiLayoutItemGridFlow), __func__);
+ flow->litem.item.type = ITEM_LAYOUT_GRID_FLOW;
+ ui_litem_init_from_parent(&flow->litem, layout, align);
+
+ flow->litem.space = (flow->litem.align) ? 0 : layout->root->style->columnspace;
+ flow->row_major = row_major;
+ flow->num_columns = num_columns;
+ flow->even_columns = even_columns;
+ flow->even_rows = even_rows;
+
+ UI_block_layout_set_current(layout->root->block, &flow->litem);
+
+ return &flow->litem;
+}
+
static uiLayoutItemBx *ui_layout_box(uiLayout *layout, int type)
{
uiLayoutItemBx *box;
@@ -3333,6 +3788,9 @@ static void ui_item_estimate(uiItem *item)
case ITEM_LAYOUT_COLUMN_FLOW:
ui_litem_estimate_column_flow(litem);
break;
+ case ITEM_LAYOUT_GRID_FLOW:
+ ui_litem_estimate_grid_flow(litem);
+ break;
case ITEM_LAYOUT_ROW:
ui_litem_estimate_row(litem);
break;
@@ -3432,6 +3890,9 @@ static void ui_item_layout(uiItem *item)
case ITEM_LAYOUT_COLUMN_FLOW:
ui_litem_layout_column_flow(litem);
break;
+ case ITEM_LAYOUT_GRID_FLOW:
+ ui_litem_layout_grid_flow(litem);
+ break;
case ITEM_LAYOUT_ROW:
ui_litem_layout_row(litem);
break;
@@ -3672,93 +4133,6 @@ void uiLayoutSetContextFromBut(uiLayout *layout, uiBut *but)
}
}
-/* introspect funcs */
-#include "BLI_dynstr.h"
-
-static void ui_intro_button(DynStr *ds, uiButtonItem *bitem)
-{
- uiBut *but = bitem->but;
- BLI_dynstr_appendf(ds, "'type':%d, ", (int)but->type);
- BLI_dynstr_appendf(ds, "'draw_string':'''%s''', ", but->drawstr);
- BLI_dynstr_appendf(ds, "'tip':'''%s''', ", but->tip ? but->tip : ""); /* not exactly needed, rna has this */
-
- if (but->optype) {
- char *opstr = WM_operator_pystring_ex(but->block->evil_C, NULL, false, true, but->optype, but->opptr);
- BLI_dynstr_appendf(ds, "'operator':'''%s''', ", opstr ? opstr : "");
- MEM_freeN(opstr);
- }
-
- if (but->rnaprop) {
- BLI_dynstr_appendf(ds, "'rna':'%s.%s[%d]', ", RNA_struct_identifier(but->rnapoin.type), RNA_property_identifier(but->rnaprop), but->rnaindex);
- }
-
-}
-
-static void ui_intro_items(DynStr *ds, ListBase *lb)
-{
- uiItem *item;
-
- BLI_dynstr_append(ds, "[");
-
- for (item = lb->first; item; item = item->next) {
-
- BLI_dynstr_append(ds, "{");
-
- /* could also use the INT but this is nicer*/
- switch (item->type) {
- case ITEM_BUTTON: BLI_dynstr_append(ds, "'type':'BUTTON', "); break;
- case ITEM_LAYOUT_ROW: BLI_dynstr_append(ds, "'type':'UI_BTYPE_ROW', "); break;
- case ITEM_LAYOUT_COLUMN: BLI_dynstr_append(ds, "'type':'COLUMN', "); break;
- case ITEM_LAYOUT_COLUMN_FLOW: BLI_dynstr_append(ds, "'type':'COLUMN_FLOW', "); break;
- case ITEM_LAYOUT_ROW_FLOW: BLI_dynstr_append(ds, "'type':'ROW_FLOW', "); break;
- case ITEM_LAYOUT_BOX: BLI_dynstr_append(ds, "'type':'BOX', "); break;
- case ITEM_LAYOUT_ABSOLUTE: BLI_dynstr_append(ds, "'type':'ABSOLUTE', "); break;
- case ITEM_LAYOUT_SPLIT: BLI_dynstr_append(ds, "'type':'SPLIT', "); break;
- case ITEM_LAYOUT_OVERLAP: BLI_dynstr_append(ds, "'type':'OVERLAP', "); break;
- case ITEM_LAYOUT_ROOT: BLI_dynstr_append(ds, "'type':'ROOT', "); break;
- default: BLI_dynstr_append(ds, "'type':'UNKNOWN', "); break;
- }
-
- switch (item->type) {
- case ITEM_BUTTON:
- ui_intro_button(ds, (uiButtonItem *)item);
- break;
- default:
- BLI_dynstr_append(ds, "'items':");
- ui_intro_items(ds, &((uiLayout *)item)->items);
- break;
- }
-
- BLI_dynstr_append(ds, "}");
-
- if (item != lb->last)
- BLI_dynstr_append(ds, ", ");
- }
- BLI_dynstr_append(ds, "], ");
-}
-
-static void ui_intro_uiLayout(DynStr *ds, uiLayout *layout)
-{
- ui_intro_items(ds, &layout->items);
-}
-
-static char *str = NULL; /* XXX, constant re-freeing, far from ideal. */
-const char *uiLayoutIntrospect(uiLayout *layout)
-{
- DynStr *ds = BLI_dynstr_new();
-
- if (str) {
- MEM_freeN(str);
- }
-
- ui_intro_uiLayout(ds, layout);
-
- str = BLI_dynstr_get_cstring(ds);
- BLI_dynstr_free(ds);
-
- return str;
-}
-
/* this is a bit of a hack but best keep it in one place at least */
MenuType *UI_but_menutype_get(uiBut *but)
{
@@ -3804,31 +4178,58 @@ void UI_menutype_draw(bContext *C, MenuType *mt, struct uiLayout *layout)
}
}
+
+static void ui_paneltype_draw_impl(
+ bContext *C, PanelType *pt, uiLayout *layout, bool show_header)
+{
+ Panel *panel = MEM_callocN(sizeof(Panel), "popover panel");
+ panel->type = pt;
+ panel->flag = PNL_POPOVER;
+
+ if (show_header) {
+ uiLayout *row = uiLayoutRow(layout, false);
+ if (pt->draw_header) {
+ panel->layout = row;
+ pt->draw_header(C, panel);
+ panel->layout = NULL;
+ }
+ uiItemL(row, pt->label, ICON_NONE);
+ }
+
+ panel->layout = layout;
+ pt->draw(C, panel);
+ panel->layout = NULL;
+
+ MEM_freeN(panel);
+
+ PanelType *pt_iter = pt;
+ while (pt_iter->prev) {
+ pt_iter = pt_iter->prev;
+ }
+ do {
+ if (pt_iter != pt && STREQ(pt_iter->parent_id, pt->idname)) {
+ if (pt_iter->poll == NULL || pt_iter->poll(C, pt_iter)) {
+ uiItemS(layout);
+ uiLayout *col = uiLayoutColumn(layout, false);
+ ui_paneltype_draw_impl(C, pt_iter, col, true);
+ }
+ }
+ } while ((pt_iter = pt_iter->next));
+}
+
/**
* Used for popup panels only.
*/
void UI_paneltype_draw(bContext *C, PanelType *pt, uiLayout *layout)
{
- Panel *panel = MEM_callocN(sizeof(Panel), "popover panel");
- panel->type = pt;
-
if (layout->context) {
CTX_store_set(C, layout->context);
}
- if (pt->draw_header) {
- panel->layout = uiLayoutRow(layout, false);
- pt->draw_header(C, panel);
- panel->layout = NULL;
- }
-
- panel->layout = layout;
- pt->draw(C, panel);
- panel->layout = NULL;
+ ui_paneltype_draw_impl(C, pt, layout, false);
if (layout->context) {
CTX_store_set(C, NULL);
}
- MEM_freeN(panel);
}
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 5c2fb0e7aaa..6fcede58737 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -957,7 +957,7 @@ static int editsource_text_edit(
}
if (text == NULL) {
- text = BKE_text_load(bmain, filepath, bmain->name);
+ text = BKE_text_load(bmain, filepath, BKE_main_blendfile_path(bmain));
id_us_ensure_real(&text->id);
}
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 5711f76e3e9..dbdf2a0863c 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -110,6 +110,7 @@ typedef struct uiHandlePanelData {
int startsizex, startsizey;
} uiHandlePanelData;
+static int get_panel_real_size_y(Panel *pa);
static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelState state);
/*********************** space specific code ************************/
@@ -133,45 +134,80 @@ static int panel_aligned(ScrArea *sa, ARegion *ar)
return 0;
}
-static int panels_re_align(ScrArea *sa, ARegion *ar, Panel **r_pa)
+static bool panel_active_animation_changed(ListBase *lb, Panel **pa_animation, bool *no_animation)
{
- Panel *pa;
- int active = 0;
+ for (Panel *pa = lb->first; pa; pa = pa->next) {
+ /* Detect panel active flag changes. */
+ if (!(pa->type && pa->type->parent)) {
+ if ((pa->runtime_flag & PNL_WAS_ACTIVE) && !(pa->runtime_flag & PNL_ACTIVE)) {
+ return true;
+ }
+ if (!(pa->runtime_flag & PNL_WAS_ACTIVE) && (pa->runtime_flag & PNL_ACTIVE)) {
+ return true;
+ }
+ }
- *r_pa = NULL;
+ if ((pa->runtime_flag & PNL_ACTIVE) && !(pa->flag & PNL_CLOSED)) {
+ if (panel_active_animation_changed(&pa->children, pa_animation, no_animation)) {
+ return true;
+ }
+ }
+
+ /* Detect animation. */
+ if (pa->activedata) {
+ uiHandlePanelData *data = pa->activedata;
+ if (data->state == PANEL_STATE_ANIMATION) {
+ *pa_animation = pa;
+ }
+ else {
+ /* Don't animate while handling other interaction. */
+ *no_animation = true;
+ }
+ }
+ if ((pa->runtime_flag & PNL_ANIM_ALIGN) && !(*pa_animation)) {
+ *pa_animation = pa;
+ }
+ }
+
+ return false;
+}
+
+static bool panels_need_realign(ScrArea *sa, ARegion *ar, Panel **pa_animate)
+{
+ *pa_animate = NULL;
if (sa->spacetype == SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) {
SpaceButs *sbuts = sa->spacedata.first;
- if (sbuts->align)
- if (sbuts->re_align || sbuts->mainbo != sbuts->mainb)
- return 1;
+ if (sbuts->align) {
+ if (sbuts->re_align || sbuts->mainbo != sbuts->mainb) {
+ return true;
+ }
+ }
+ }
+ else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW) {
+ return true;
+ }
+ else if (sa->spacetype == SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) {
+ return true;
}
- else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW)
- return 1;
- else if (sa->spacetype == SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS)
- return 1;
- /* in case panel is added or disappears */
- for (pa = ar->panels.first; pa; pa = pa->next) {
- if ((pa->runtime_flag & PNL_WAS_ACTIVE) && !(pa->runtime_flag & PNL_ACTIVE))
- return 1;
- if (!(pa->runtime_flag & PNL_WAS_ACTIVE) && (pa->runtime_flag & PNL_ACTIVE))
- return 1;
- if (pa->activedata)
- active = 1;
+ /* Detect if a panel was added or removed. */
+ Panel *pa_animation = NULL;
+ bool no_animation = false;
+ if (panel_active_animation_changed(&ar->panels, &pa_animation, &no_animation)) {
+ return true;
}
- /* in case we need to do an animation (size changes) */
- for (pa = ar->panels.first; pa; pa = pa->next) {
- if (pa->runtime_flag & PNL_ANIM_ALIGN) {
- if (!active)
- *r_pa = pa;
- return 1;
+ /* Detect panel marked for animation, if we're not already animating. */
+ if (pa_animation) {
+ if (!no_animation) {
+ *pa_animate = pa_animation;
}
+ return true;
}
- return 0;
+ return false;
}
/****************************** panels ******************************/
@@ -215,14 +251,14 @@ static void ui_panel_copy_offset(Panel *pa, Panel *papar)
*/
/* #define UI_USE_PANELTAB */
-Panel *UI_panel_find_by_type(ARegion *ar, PanelType *pt)
+Panel *UI_panel_find_by_type(ListBase *lb, PanelType *pt)
{
Panel *pa;
const char *idname = pt->idname;
#ifdef UI_USE_PANELTAB
const char *tabname = pt->idname;
- for (pa = ar->panels.first; pa; pa = pa->next) {
+ for (pa = lb->first; pa; pa = pa->next) {
if (STREQLEN(pa->panelname, idname, sizeof(pa->panelname))) {
if (STREQLEN(pa->tabname, tabname, sizeof(pa->tabname))) {
return pa;
@@ -230,7 +266,7 @@ Panel *UI_panel_find_by_type(ARegion *ar, PanelType *pt)
}
}
#else
- for (pa = ar->panels.first; pa; pa = pa->next) {
+ for (pa = lb->first; pa; pa = pa->next) {
if (STREQLEN(pa->panelname, idname, sizeof(pa->panelname))) {
return pa;
}
@@ -243,7 +279,7 @@ Panel *UI_panel_find_by_type(ARegion *ar, PanelType *pt)
/**
* \note \a pa should be return value from #UI_panel_find_by_type and can be NULL.
*/
-Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, Panel *pa, bool *r_open)
+Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, ListBase *lb, uiBlock *block, PanelType *pt, Panel *pa, bool *r_open)
{
Panel *palast, *panext;
const char *drawname = CTX_IFACE_(pt->translation_context, pt->label);
@@ -275,9 +311,11 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, P
pa->ofsy = 0;
pa->sizex = 0;
pa->sizey = 0;
+ pa->blocksizex = 0;
+ pa->blocksizey = 0;
pa->runtime_flag |= PNL_NEW_ADDED;
- BLI_addtail(&ar->panels, pa);
+ BLI_addtail(lb, pa);
#ifdef UI_USE_PANELTAB
BLI_strncpy(pa->tabname, tabname, sizeof(pa->tabname));
@@ -285,7 +323,7 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, P
/* make new Panel tabbed? */
if (hookname) {
Panel *patab;
- for (patab = ar->panels.first; patab; patab = patab->next) {
+ for (patab = lb->first; patab; patab = patab->next) {
if ((patab->runtime_flag & PNL_ACTIVE) && patab->paneltab == NULL) {
if (STREQLEN(hookname, patab->panelname, sizeof(patab->panelname))) {
if (STREQLEN(tabname, patab->tabname, sizeof(patab->tabname))) {
@@ -308,6 +346,8 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, P
/* Force update of panels' positions! */
pa->sizex = 0;
pa->sizey = 0;
+ pa->blocksizex = 0;
+ pa->blocksizey = 0;
}
BLI_strncpy(pa->drawname, drawname, sizeof(pa->drawname));
@@ -315,14 +355,18 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, P
/* if a new panel is added, we insert it right after the panel
* that was last added. this way new panels are inserted in the
* right place between versions */
- for (palast = ar->panels.first; palast; palast = palast->next)
- if (palast->runtime_flag & PNL_LAST_ADDED)
+ for (palast = lb->first; palast; palast = palast->next) {
+ if (palast->runtime_flag & PNL_LAST_ADDED) {
+ BLI_remlink(lb, pa);
+ BLI_insertlinkafter(lb, palast, pa);
break;
+ }
+ }
if (newpanel) {
pa->sortorder = (palast) ? palast->sortorder + 1 : 0;
- for (panext = ar->panels.first; panext; panext = panext->next)
+ for (panext = lb->first; panext; panext = panext->next)
if (panext != pa && panext->sortorder >= pa->sortorder)
panext->sortorder++;
}
@@ -348,6 +392,19 @@ void UI_panel_end(uiBlock *block, int width, int height)
{
Panel *pa = block->panel;
+ /* Set panel size excluding children. */
+ pa->blocksizex = width;
+ pa->blocksizey = height;
+
+ /* Compute total panel size including children. */
+ for (Panel *pachild = pa->children.first; pachild; pachild = pachild->next) {
+ if (pachild->runtime_flag & PNL_ACTIVE) {
+ width = max_ii(width, pachild->sizex);
+ height += get_panel_real_size_y(pachild);
+ }
+ }
+
+ /* Update total panel size. */
if (pa->runtime_flag & PNL_NEW_ADDED) {
pa->runtime_flag &= ~PNL_NEW_ADDED;
pa->sizex = width;
@@ -372,15 +429,13 @@ void UI_panel_end(uiBlock *block, int width, int height)
static void ui_offset_panel_block(uiBlock *block)
{
uiStyle *style = UI_style_get_dpi();
- uiBut *but;
- int ofsy;
/* compute bounds and offset */
ui_block_bounds_calc(block);
- ofsy = block->panel->sizey - style->panelspace;
+ int ofsy = block->panel->sizey - style->panelspace;
- for (but = block->buttons.first; but; but = but->next) {
+ for (uiBut *but = block->buttons.first; but; but = but->next) {
but->rect.ymin += ofsy;
but->rect.ymax += ofsy;
}
@@ -557,6 +612,20 @@ static void ui_draw_panel_dragwidget(unsigned int pos, unsigned int col, const r
immEnd();
}
+/* For button layout next to label. */
+void UI_panel_label_offset(uiBlock *block, int *x, int *y)
+{
+ Panel *panel = block->panel;
+ uiStyle *style = UI_style_get_dpi();
+ const bool is_subpanel = (panel->type && panel->type->parent);
+
+ *x = UI_UNIT_X * 1.1f;
+ *y = (UI_UNIT_Y * 1.1f) + style->panelspace;
+
+ if (is_subpanel) {
+ *x += 5.0f / block->aspect;
+ }
+}
static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, const rcti *rect, char dir)
{
@@ -564,6 +633,8 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, const r
rcti hrect;
int pnl_icons;
const char *activename = panel->drawname[0] ? panel->drawname : panel->panelname;
+ const bool is_subpanel = (panel->type && panel->type->parent);
+ uiFontStyle *fontstyle = (is_subpanel) ? &style->widgetlabel : &style->paneltitle;
unsigned char col_title[4];
/* + 0.001f to avoid flirting with float inaccuracy */
@@ -580,14 +651,14 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, const r
if (dir == 'h') {
hrect.xmin = rect->xmin + pnl_icons;
hrect.ymin += 2.0f / block->aspect;
- UI_fontstyle_draw(&style->paneltitle, &hrect, activename, col_title);
+ UI_fontstyle_draw(fontstyle, &hrect, activename, col_title);
}
else {
/* ignore 'pnl_icons', otherwise the text gets offset horizontally
* + 0.001f to avoid flirting with float inaccuracy
*/
hrect.xmin = rect->xmin + (PNL_ICON + 5) / block->aspect + 0.001f;
- UI_fontstyle_draw_rotated(&style->paneltitle, &hrect, activename, col_title);
+ UI_fontstyle_draw_rotated(fontstyle, &hrect, activename, col_title);
}
}
@@ -600,6 +671,8 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
float color[4];
const bool is_closed_x = (panel->flag & PNL_CLOSEDX) ? true : false;
const bool is_closed_y = (panel->flag & PNL_CLOSEDY) ? true : false;
+ const bool is_subpanel = (panel->type && panel->type->parent);
+ const bool show_drag = !is_subpanel;
if (panel->paneltab) return;
if (panel->type && (panel->type->flag & PNL_NO_HEADER)) return;
@@ -610,10 +683,15 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
headrect.ymin = headrect.ymax;
headrect.ymax = headrect.ymin + floor(PNL_HEADER / block->aspect + 0.001f);
+ rcti titlerect = headrect;
+ if (is_subpanel) {
+ titlerect.xmin += 5.0f / block->aspect;
+ }
+
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- {
+ if (!is_subpanel) {
float minx = rect->xmin;
float maxx = is_closed_x ? (minx + PNL_HEADER / block->aspect) : rect->xmax;
float y = headrect.ymax;
@@ -681,25 +759,28 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
/* horizontal title */
if (is_closed_x == false) {
- unsigned int col;
- ui_draw_aligned_panel_header(style, block, &headrect, 'h');
- Gwn_VertFormat *format = immVertexFormat();
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
-
- /* itemrect smaller */
- itemrect.xmax = headrect.xmax - 5.0f / block->aspect;
- itemrect.xmin = itemrect.xmax - BLI_rcti_size_y(&headrect);
- itemrect.ymin = headrect.ymin;
- itemrect.ymax = headrect.ymax;
-
- BLI_rctf_scale(&itemrect, 0.7f);
- immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- ui_draw_panel_dragwidget(pos, col, &itemrect);
- immUnbindProgram();
+ ui_draw_aligned_panel_header(style, block, &titlerect, 'h');
+
+ if (show_drag) {
+ unsigned int col;
+ Gwn_VertFormat *format = immVertexFormat();
+ pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+
+ /* itemrect smaller */
+ itemrect.xmax = headrect.xmax - 5.0f / block->aspect;
+ itemrect.xmin = itemrect.xmax - BLI_rcti_size_y(&headrect);
+ itemrect.ymin = headrect.ymin;
+ itemrect.ymax = headrect.ymax;
+
+ BLI_rctf_scale(&itemrect, 0.7f);
+ immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+ ui_draw_panel_dragwidget(pos, col, &itemrect);
+ immUnbindProgram();
- /* Restore format for the following draws. */
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ /* Restore format for the following draws. */
+ pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ }
}
/* if the panel is minimized vertically:
@@ -727,8 +808,12 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* panel backdrop */
- if (UI_GetThemeValue(TH_PANEL_SHOW_BACK)) {
- /* draw with background color */
+ if (is_subpanel) {
+ glEnable(GL_BLEND);
+ immUniformThemeColor(TH_PANEL_SUB_BACK);
+ immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+ }
+ else if (UI_GetThemeValue(TH_PANEL_SHOW_BACK)) {
glEnable(GL_BLEND);
immUniformThemeColor(TH_PANEL_BACK);
immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
@@ -753,10 +838,10 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
/* draw collapse icon */
/* itemrect smaller */
- itemrect.xmin = headrect.xmin + 3.0f / block->aspect;
- itemrect.xmax = itemrect.xmin + BLI_rcti_size_y(&headrect);
- itemrect.ymin = headrect.ymin;
- itemrect.ymax = headrect.ymax;
+ itemrect.xmin = titlerect.xmin + 3.0f / block->aspect;
+ itemrect.xmax = itemrect.xmin + BLI_rcti_size_y(&titlerect);
+ itemrect.ymin = titlerect.ymin;
+ itemrect.ymax = titlerect.ymax;
BLI_rctf_scale(&itemrect, 0.25f);
@@ -786,6 +871,16 @@ static int get_panel_size_y(Panel *pa)
return PNL_HEADER + pa->sizey;
}
+static int get_panel_real_size_y(Panel *pa)
+{
+ int sizey = (pa->flag & PNL_CLOSED) ? 0 : pa->sizey;
+
+ if (pa->type && (pa->type->flag & PNL_NO_HEADER))
+ return sizey;
+
+ return PNL_HEADER + sizey;
+}
+
/* this function is needed because uiBlock and Panel itself don't
* change sizey or location when closed */
static int get_panel_real_ofsy(Panel *pa)
@@ -858,6 +953,24 @@ static int compare_panel(const void *a1, const void *a2)
return 0;
}
+static void align_sub_panels(Panel *pa)
+{
+ /* Position sub panels. */
+ int ofsy = get_panel_real_ofsy(pa) + pa->sizey - pa->blocksizey;
+
+ for (Panel *pachild = pa->children.first; pachild; pachild = pachild->next) {
+ if (pachild->runtime_flag & PNL_ACTIVE) {
+ pachild->ofsx = pa->ofsx;
+ pachild->ofsy = ofsy - get_panel_size_y(pachild);
+ ofsy -= get_panel_real_size_y(pachild);
+
+ if (pachild->children.first) {
+ align_sub_panels(pachild);
+ }
+ }
+ }
+}
+
/* this doesnt draw */
/* returns 1 when it did something */
static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bool drag)
@@ -949,10 +1062,17 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
}
}
- /* copy locations to tabs */
- for (pa = ar->panels.first; pa; pa = pa->next)
- if (pa->paneltab && (pa->runtime_flag & PNL_ACTIVE))
- ui_panel_copy_offset(pa, pa->paneltab);
+ /* set locations for tabbed and sub panels */
+ for (pa = ar->panels.first; pa; pa = pa->next) {
+ if (pa->runtime_flag & PNL_ACTIVE) {
+ if (pa->paneltab) {
+ ui_panel_copy_offset(pa, pa->paneltab);
+ }
+ if (pa->children.first) {
+ align_sub_panels(pa);
+ }
+ }
+ }
/* free panelsort array */
for (ps = panelsort, a = 0; a < tot; a++, ps++) {
@@ -1022,20 +1142,27 @@ static void ui_do_animate(const bContext *C, Panel *panel)
}
}
-void UI_panels_begin(const bContext *UNUSED(C), ARegion *ar)
+static void panel_list_clear_active(ListBase *lb)
{
- Panel *pa;
-
/* set all panels as inactive, so that at the end we know
* which ones were used */
- for (pa = ar->panels.first; pa; pa = pa->next) {
- if (pa->runtime_flag & PNL_ACTIVE)
+ for (Panel *pa = lb->first; pa; pa = pa->next) {
+ if (pa->runtime_flag & PNL_ACTIVE) {
pa->runtime_flag = PNL_WAS_ACTIVE;
- else
+ }
+ else {
pa->runtime_flag = 0;
+ }
+
+ panel_list_clear_active(&pa->children);
}
}
+void UI_panels_begin(const bContext *UNUSED(C), ARegion *ar)
+{
+ panel_list_clear_active(&ar->panels);
+}
+
/* only draws blocks with panels */
void UI_panels_end(const bContext *C, ARegion *ar, int *x, int *y)
{
@@ -1074,8 +1201,7 @@ void UI_panels_end(const bContext *C, ARegion *ar, int *x, int *y)
}
/* re-align, possibly with animation */
- if (panels_re_align(sa, ar, &pa)) {
- /* XXX code never gets here... PNL_ANIM_ALIGN flag is never set */
+ if (panels_need_realign(sa, ar, &pa)) {
if (pa)
panel_activate_state(C, pa, PANEL_STATE_ANIMATION);
else
@@ -1102,14 +1228,16 @@ void UI_panels_draw(const bContext *C, ARegion *ar)
UI_ThemeClearColor(TH_BACK);
- /* draw panels, selected on top */
- for (block = ar->uiblocks.first; block; block = block->next) {
+ /* Draw panels, selected on top. Also in reverse order, because
+ * UI blocks are added in reverse order and we need child panels
+ * to draw on top. */
+ for (block = ar->uiblocks.last; block; block = block->prev) {
if (block->active && block->panel && !(block->panel->flag & PNL_SELECT)) {
UI_block_draw(C, block);
}
}
- for (block = ar->uiblocks.first; block; block = block->next) {
+ for (block = ar->uiblocks.last; block; block = block->prev) {
if (block->active && block->panel && (block->panel->flag & PNL_SELECT)) {
UI_block_draw(C, block);
}
@@ -1371,6 +1499,8 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
#else
const bool show_pin = UI_panel_category_is_visible(ar);
#endif
+ const bool is_subpanel = (block->panel->type && block->panel->type->parent);
+ const bool show_drag = !is_subpanel;
int align = panel_aligned(sa, ar), button = 0;
@@ -1465,7 +1595,7 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
else
ED_region_tag_redraw(ar);
}
- else if (BLI_rctf_isect_x(&rect_drag, mx)) {
+ else if (show_drag && BLI_rctf_isect_x(&rect_drag, mx)) {
panel_activate_state(C, block->panel, PANEL_STATE_DRAG);
}
else if (show_pin && BLI_rctf_isect_x(&rect_pin, mx)) {
@@ -2175,7 +2305,7 @@ static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata)
uiHandlePanelData *data = panel->activedata;
/* verify if we can stop */
- if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
int align = panel_aligned(sa, ar);
diff --git a/source/blender/editors/interface/interface_region_menu_pie.c b/source/blender/editors/interface/interface_region_menu_pie.c
index 0c43b787a84..504e1807a8f 100644
--- a/source/blender/editors/interface/interface_region_menu_pie.c
+++ b/source/blender/editors/interface/interface_region_menu_pie.c
@@ -150,8 +150,16 @@ uiPieMenu *UI_pie_menu_begin(struct bContext *C, const char *title, int icon, co
}
pie->layout = UI_block_layout(pie->block_radial, UI_LAYOUT_VERTICAL, UI_LAYOUT_PIEMENU, 0, 0, 200, 0, 0, style);
- pie->mx = event->x;
- pie->my = event->y;
+
+ /* Open from where we started dragging. */
+ if (event->val == KM_CLICK_DRAG) {
+ pie->mx = event->prevclickx;
+ pie->my = event->prevclicky;
+ }
+ else {
+ pie->mx = event->x;
+ pie->my = event->y;
+ }
/* create title button */
if (title[0]) {
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index 9d10713c868..e769d367b45 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -87,7 +87,7 @@ struct uiPopover {
uiMenuCreateFunc menu_func;
void *menu_arg;
-#ifdef USE_POPOVER_ONCE
+#ifdef USE_UI_POPOVER_ONCE
bool is_once;
#endif
};
@@ -135,8 +135,8 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
UI_block_region_set(block, handle->region);
UI_block_layout_resolve(block, &width, &height);
- UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_KEEP_OPEN | UI_BLOCK_POPOVER);
-#ifdef USE_POPOVER_ONCE
+ UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_POPOVER);
+#ifdef USE_UI_POPOVER_ONCE
if (pup->is_once) {
UI_block_flag_enable(block, UI_BLOCK_POPOVER_ONCE);
}
@@ -231,7 +231,7 @@ uiPopupBlockHandle *ui_popover_panel_create(
pup->menu_func = menu_func;
pup->menu_arg = arg;
-#ifdef USE_POPOVER_ONCE
+#ifdef USE_UI_POPOVER_ONCE
pup->is_once = true;
#endif
@@ -365,7 +365,7 @@ uiLayout *UI_popover_layout(uiPopover *pup)
return pup->layout;
}
-#ifdef USE_POPOVER_ONCE
+#ifdef USE_UI_POPOVER_ONCE
void UI_popover_once_clear(uiPopover *pup)
{
pup->is_once = false;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index d934d4dd1e4..9978726fa74 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -3970,7 +3970,9 @@ eAutoPropButsReturn uiTemplateOperatorPropertyButs(
#endif
/* set various special settings for buttons */
- {
+
+ /* Only do this if we're not refreshing an existing UI. */
+ if (block->oldblock == NULL) {
const bool is_popup = (block->flag & UI_BLOCK_KEEP_OPEN) != 0;
uiBut *but;
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index e4faac5129e..ac8d900f560 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -2008,11 +2008,20 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
else if (but->flag & UI_HAS_ICON || show_menu_icon) {
const bool is_tool = UI_but_is_tool(but);
+ /* XXX add way to draw icons at a different size!
+ * Use small icons for popup. */
+#ifdef USE_UI_TOOLBAR_HACK
+ const float aspect_orig = but->block->aspect;
+ if (is_tool && (but->block->flag & UI_BLOCK_POPOVER)) {
+ but->block->aspect *= 2.0f;
+ }
+#endif
+
const BIFIconID icon = (but->flag & UI_HAS_ICON) ? but->icon + but->iconadd : ICON_NONE;
int icon_size_init = is_tool ? ICON_DEFAULT_HEIGHT_TOOLBAR : ICON_DEFAULT_HEIGHT;
const float icon_size = icon_size_init / (but->block->aspect / UI_DPI_FAC);
-#ifdef USE_TOOLBAR_HACK
+#ifdef USE_UI_TOOLBAR_HACK
if (is_tool) {
/* pass (even if its a menu toolbar) */
but->drawflag |= UI_BUT_TEXT_LEFT;
@@ -2034,6 +2043,10 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
widget_draw_icon(but, icon, alpha, rect, show_menu_icon);
+#ifdef USE_UI_TOOLBAR_HACK
+ but->block->aspect = aspect_orig;
+#endif
+
rect->xmin += icon_size;
/* without this menu keybindings will overlap the arrow icon [#38083] */
if (show_menu_icon) {
@@ -2626,15 +2639,9 @@ static void widget_state_nothing(uiWidgetType *wt, int UNUSED(state))
}
/* special case, button that calls pulldown */
-static void widget_state_pulldown(uiWidgetType *wt, int state)
+static void widget_state_pulldown(uiWidgetType *wt, int UNUSED(state))
{
wt->wcol = *(wt->wcol_theme);
-
- copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
- copy_v3_v3_char(wt->wcol.outline, wt->wcol.inner);
-
- if (state & UI_ACTIVE)
- copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel);
}
/* special case, pie menu items */
@@ -3812,10 +3819,23 @@ static void widget_menunodebut(uiWidgetColors *wcol, rcti *rect, int UNUSED(stat
static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
- if (state & UI_ACTIVE) {
+ float back[4];
+ UI_GetThemeColor4fv(TH_BACK, back);
+
+ if ((state & UI_ACTIVE) || (back[3] < 1.0f)) {
uiWidgetBase wtb;
const float rad = wcol->roundness * U.widget_unit;
+ if (state & UI_ACTIVE) {
+ copy_v4_v4_char(wcol->inner, wcol->inner_sel);
+ copy_v3_v3_char(wcol->text, wcol->text_sel);
+ copy_v3_v3_char(wcol->outline, wcol->inner);
+ }
+ else {
+ wcol->inner[3] *= 1.0f - back[3];
+ wcol->outline[3] = 0.0f;
+ }
+
widget_init(&wtb);
/* half rounded */
@@ -4352,7 +4372,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
uiFontStyle *fstyle = &style->widget;
uiWidgetType *wt = NULL;
-#ifdef USE_POPOVER_ONCE
+#ifdef USE_UI_POPOVER_ONCE
const rcti rect_orig = *rect;
#endif
@@ -4403,10 +4423,11 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
case UI_BTYPE_SEPR:
case UI_BTYPE_SEPR_LINE:
+ case UI_BTYPE_SEPR_SPACER:
break;
case UI_BTYPE_BUT:
-#ifdef USE_TOOLBAR_HACK
+#ifdef USE_UI_TOOLBAR_HACK
if (UI_but_is_tool(but)) {
wt = widget_type(UI_WTYPE_TOOLBAR_ITEM);
}
@@ -4632,7 +4653,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
if (disabled)
glEnable(GL_BLEND);
-#ifdef USE_POPOVER_ONCE
+#ifdef USE_UI_POPOVER_ONCE
if (but->block->flag & UI_BLOCK_POPOVER_ONCE) {
if ((state & UI_ACTIVE) && ui_but_is_popover_once_compat(but)) {
uiWidgetType wt_back = *wt;
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 979a2164199..2a61be21589 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -56,6 +56,8 @@
#include "BLF_api.h"
+#include "ED_screen.h"
+
#include "UI_interface.h"
#include "UI_interface_icons.h"
@@ -96,6 +98,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
static char error[4] = {240, 0, 240, 255};
static char alert[4] = {240, 60, 60, 255};
static char headerdesel[4] = {0, 0, 0, 255};
+ static char back[4] = {0, 0, 0, 255};
static char setting = 0;
const char *cp = error;
@@ -183,6 +186,12 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
cp = ts->header;
else
cp = ts->button;
+
+ copy_v4_v4_char(back, cp);
+ if (!ED_region_is_overlap(spacetype, theme_regionid)) {
+ back[3] = 255;
+ }
+ cp = back;
break;
case TH_LOW_GRAD:
cp = ts->gradients.gradient;
@@ -245,6 +254,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
cp = ts->panelcolors.header; break;
case TH_PANEL_BACK:
cp = ts->panelcolors.back; break;
+ case TH_PANEL_SUB_BACK:
+ cp = ts->panelcolors.sub_back; break;
case TH_PANEL_SHOW_HEADER:
cp = &setting;
setting = ts->panelcolors.show_header;
@@ -812,6 +823,7 @@ static void ui_theme_init_new_do(ThemeSpace *ts)
ts->panelcolors.show_header = false;
rgba_char_args_set(ts->panelcolors.back, 114, 114, 114, 128);
rgba_char_args_set(ts->panelcolors.header, 0, 0, 0, 25);
+ rgba_char_args_set(ts->panelcolors.sub_back, 0, 0, 0, 25);
rgba_char_args_set(ts->button, 145, 145, 145, 245);
rgba_char_args_set(ts->button_title, 0, 0, 0, 255);
@@ -1806,10 +1818,8 @@ void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3]
/* ************************************************************* */
/* patching UserDef struct and Themes */
-void init_userdef_do_versions(void)
+void init_userdef_do_versions(Main *bmain)
{
- Main *bmain = G.main;
-
#define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST(bmain, ver, subver)
/* the UserDef struct is not corrected with do_versions() .... ugh! */
@@ -3013,6 +3023,16 @@ void init_userdef_do_versions(void)
}
}
+ if (!USER_VERSION_ATLEAST(280, 17)) {
+ for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) {
+ ThemeSpace *ts;
+
+ for (ts = UI_THEMESPACE_START(btheme); ts != UI_THEMESPACE_END(btheme); ts++) {
+ rgba_char_args_set(ts->panelcolors.sub_back, 0, 0, 0, 25);
+ }
+ }
+ }
+
/**
* Include next version bump.
*/
diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c
index b584782e183..4440b99f211 100644
--- a/source/blender/editors/io/io_alembic.c
+++ b/source/blender/editors/io/io_alembic.c
@@ -79,11 +79,11 @@ static int wm_alembic_export_invoke(bContext *C, wmOperator *op, const wmEvent *
Main *bmain = CTX_data_main(C);
char filepath[FILE_MAX];
- if (bmain->name[0] == '\0') {
+ if (BKE_main_blendfile_path(bmain)[0] == '\0') {
BLI_strncpy(filepath, "untitled", sizeof(filepath));
}
else {
- BLI_strncpy(filepath, bmain->name, sizeof(filepath));
+ BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath));
}
BLI_replace_extension(filepath, sizeof(filepath), ".abc");
@@ -422,12 +422,12 @@ static int get_sequence_len(char *filename, int *ofs)
}
char path[FILE_MAX];
- BLI_path_abs(filename, G.main->name);
+ BLI_path_abs(filename, BKE_main_blendfile_path_from_global());
BLI_split_dir_part(filename, path, FILE_MAX);
if (path[0] == '\0') {
/* The filename had no path, so just use the blend file path. */
- BLI_split_dir_part(G.main->name, path, FILE_MAX);
+ BLI_split_dir_part(BKE_main_blendfile_path_from_global(), path, FILE_MAX);
}
DIR *dir = opendir(path);
diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.c
index eb79d0bec13..b13eaced843 100644
--- a/source/blender/editors/io/io_cache.c
+++ b/source/blender/editors/io/io_cache.c
@@ -60,7 +60,7 @@ static int cachefile_open_invoke(bContext *C, wmOperator *op, const wmEvent *eve
char filepath[FILE_MAX];
Main *bmain = CTX_data_main(C);
- BLI_strncpy(filepath, bmain->name, sizeof(filepath));
+ BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath));
BLI_replace_extension(filepath, sizeof(filepath), ".abc");
RNA_string_set(op->ptr, "filepath", filepath);
}
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index a3cbdb57fed..aca380c3123 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -60,14 +60,17 @@
#include "io_collada.h"
static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
+{
+ Main *bmain = CTX_data_main(C);
+
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
char filepath[FILE_MAX];
+ const char *blendfile_path = BKE_main_blendfile_path(bmain);
- if (G.main->name[0] == 0)
+ if (blendfile_path[0] == '\0')
BLI_strncpy(filepath, "untitled", sizeof(filepath));
else
- BLI_strncpy(filepath, G.main->name, sizeof(filepath));
+ BLI_strncpy(filepath, blendfile_path, sizeof(filepath));
BLI_replace_extension(filepath, sizeof(filepath), ".dae");
RNA_string_set(op->ptr, "filepath", filepath);
@@ -164,8 +167,10 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
limit_precision = RNA_boolean_get(op->ptr, "limit_precision");
keep_bind_info = RNA_boolean_get(op->ptr, "keep_bind_info");
+ Main *bmain = CTX_data_main(C);
+
/* get editmode results */
- ED_object_editmode_load(CTX_data_edit_object(C));
+ ED_object_editmode_load(bmain, CTX_data_edit_object(C));
Scene *scene = CTX_data_scene(C);
@@ -200,9 +205,11 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
if (export_settings.include_armatures) includeFilter |= OB_REL_MOD_ARMATURE;
if (export_settings.include_children) includeFilter |= OB_REL_CHILDREN_RECURSIVE;
- export_count = collada_export(CTX_data_depsgraph(C),
- scene,
- &export_settings
+ export_count = collada_export(
+ C,
+ CTX_data_depsgraph(C),
+ scene,
+ &export_settings
);
if (export_count == 0) {
@@ -584,8 +591,8 @@ void WM_OT_collada_import(wmOperatorType *ot)
0,
INT_MAX);
- RNA_def_boolean(ot->srna,
- "keep_bind_info", 0, "Keep Bind Info",
+ RNA_def_boolean(ot->srna,
+ "keep_bind_info", 0, "Keep Bind Info",
"Store Bindpose information in custom bone properties for later use during Collada export");
}
diff --git a/source/blender/editors/io/io_collada.h b/source/blender/editors/io/io_collada.h
index 4bb1475a3b2..ba122630aec 100644
--- a/source/blender/editors/io/io_collada.h
+++ b/source/blender/editors/io/io_collada.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.c
index d1e933517a9..26414661f52 100644
--- a/source/blender/editors/io/io_ops.c
+++ b/source/blender/editors/io/io_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -42,7 +42,7 @@
#include "io_cache.h"
-void ED_operatortypes_io(void)
+void ED_operatortypes_io(void)
{
#ifdef WITH_COLLADA
/* Collada operators: */
diff --git a/source/blender/editors/io/io_ops.h b/source/blender/editors/io/io_ops.h
index 4fffca4607c..677ce40cc38 100644
--- a/source/blender/editors/io/io_ops.h
+++ b/source/blender/editors/io/io_ops.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/lattice/lattice_ops.c b/source/blender/editors/lattice/lattice_ops.c
index d3d57a0b510..4f2e87c11c1 100644
--- a/source/blender/editors/lattice/lattice_ops.c
+++ b/source/blender/editors/lattice/lattice_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c
index 16147bdc7f8..364800ed1a2 100644
--- a/source/blender/editors/mask/mask_editaction.c
+++ b/source/blender/editors/mask/mask_editaction.c
@@ -205,21 +205,21 @@ void ED_masklayer_frames_select_border(MaskLayer *masklay, float min, float max,
void ED_masklayer_frames_select_region(KeyframeEditData *ked, MaskLayer *masklay, short tool, short select_mode)
{
MaskLayerShape *masklay_shape;
-
+
if (masklay == NULL)
return;
-
+
/* only select frames which are within the region */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) {
/* construct a dummy point coordinate to do this testing with */
float pt[2] = {0};
-
+
pt[0] = masklay_shape->frame;
pt[1] = ked->channel_y;
-
+
/* check the necessary regions */
if (tool == BEZT_OK_CHANNEL_LASSO) {
- /* Lasso */
+ /* Lasso */
if (keyframe_region_lasso_test(ked->data, pt))
masklayshape_select(masklay_shape, select_mode);
}
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 6d1f478249a..7e31b6a3774 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -64,7 +64,7 @@ void paintface_flush_flags(Object *ob, short flag)
const int *index_array = NULL;
int totpoly;
int i;
-
+
BLI_assert((flag & ~(SELECT | ME_HIDE)) == 0);
if (me == NULL)
@@ -106,7 +106,7 @@ void paintface_hide(Object *ob, const bool unselected)
Mesh *me;
MPoly *mpoly;
int a;
-
+
me = BKE_mesh_from_object(ob);
if (me == NULL || me->totpoly == 0) return;
@@ -122,10 +122,10 @@ void paintface_hide(Object *ob, const bool unselected)
if (mpoly->flag & ME_HIDE) {
mpoly->flag &= ~ME_FACE_SEL;
}
-
+
mpoly++;
}
-
+
BKE_mesh_flush_hidden_from_polys(me);
paintface_flush_flags(ob, SELECT | ME_HIDE);
@@ -258,7 +258,7 @@ void paintface_deselect_all_visible(Object *ob, int action, bool flush_flags)
me = BKE_mesh_from_object(ob);
if (me == NULL) return;
-
+
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
@@ -311,7 +311,7 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3])
if (!me || !me->mloopuv) {
return ok;
}
-
+
copy_m3_m4(bmat, ob->obmat);
mvert = me->mvert;
@@ -338,19 +338,19 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b
Mesh *me;
MPoly *mpoly, *mpoly_sel;
unsigned int a, index;
-
+
/* Get the face under the cursor */
me = BKE_mesh_from_object(ob);
if (!ED_mesh_pick_face(C, ob, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE))
return false;
-
+
if (index >= me->totpoly)
return false;
mpoly_sel = me->mpoly + index;
if (mpoly_sel->flag & ME_HIDE) return false;
-
+
/* clear flags */
mpoly = me->mpoly;
a = me->totpoly;
@@ -360,7 +360,7 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b
mpoly++;
}
}
-
+
me->act_face = (int)index;
if (extend) {
@@ -378,7 +378,7 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b
else {
mpoly_sel->flag |= ME_FACE_SEL;
}
-
+
/* image window redraw */
paintface_flush_flags(ob, SELECT);
@@ -399,7 +399,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten
const int size[2] = {
BLI_rcti_size_x(rect) + 1,
BLI_rcti_size_y(rect) + 1};
-
+
me = BKE_mesh_from_object(ob);
if ((me == NULL) || (me->totpoly == 0) || (size[0] * size[1] <= 0)) {
@@ -455,7 +455,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten
IMB_freeImBuf(ibuf);
MEM_freeN(selar);
-#ifdef __APPLE__
+#ifdef __APPLE__
glReadBuffer(GL_BACK);
#endif
@@ -520,7 +520,7 @@ void paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
me = BKE_mesh_from_object(ob);
if (me == NULL) return;
-
+
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index 859b0942e55..1daf020dc7b 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -87,7 +87,7 @@ typedef struct {
typedef struct {
float initial_length[NUM_VALUE_KINDS];
float scale[NUM_VALUE_KINDS];
- NumInput num_input[NUM_VALUE_KINDS];
+ NumInput num_input[NUM_VALUE_KINDS];
float shift_value[NUM_VALUE_KINDS]; /* The current value when shift is pressed. Negative when shift not active. */
bool is_modal;
@@ -258,7 +258,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
opdata->shift_value[i] = -1.0f;
opdata->initial_length[i] = -1.0f;
/* note: scale for OFFSET_VALUE will get overwritten in edbm_bevel_invoke */
- opdata->scale[i] = value_scale_per_inch[i] / pixels_per_inch;
+ opdata->scale[i] = value_scale_per_inch[i] / pixels_per_inch;
initNumInput(&opdata->num_input[i]);
opdata->num_input[i].idx_max = 0;
@@ -428,7 +428,7 @@ static void edbm_bevel_calc_initial_length(wmOperator *op, const wmEvent *event,
len = len_v2(mlen);
vmode = opdata->value_mode;
if (mode_changed || opdata->initial_length[vmode] == -1.0f) {
- /* If current value is not default start value, adjust len so that
+ /* If current value is not default start value, adjust len so that
* the scaling and offset in edbm_bevel_mouse_set_value will
* start at current value */
value = (vmode == SEGMENTS_VALUE) ?
@@ -642,7 +642,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
(opdata->value_mode == OFFSET_VALUE || opdata->value_mode == OFFSET_VALUE_PERCENT))
{
edbm_bevel_mouse_set_value(op, event);
- }
+ }
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
handled = true;
@@ -684,7 +684,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
case VKEY:
if (event->val == KM_RELEASE)
break;
-
+
{
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "vertex_only");
RNA_property_boolean_set(op->ptr, prop, !RNA_property_boolean_get(op->ptr, prop));
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 80fed05a0b5..be54bba7aa4 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Joseph Eagar, Joshua Leung, Howard Trickey,
* Campbell Barton
*
@@ -1806,7 +1806,7 @@ static void knife_input_ray_segment(KnifeTool_OpData *kcd, const float mval[2],
ED_view3d_unproject(kcd->vc.ar, mval[0], mval[1], ofs, r_origin_ofs);
/* transform into object space */
- invert_m4_m4(kcd->ob->imat, kcd->ob->obmat);
+ invert_m4_m4(kcd->ob->imat, kcd->ob->obmat);
mul_m4_v3(kcd->ob->imat, r_origin);
mul_m4_v3(kcd->ob->imat, r_origin_ofs);
diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c
index ba030c42a04..5ccbcf063ad 100644
--- a/source/blender/editors/mesh/editmesh_knife_project.c
+++ b/source/blender/editors/mesh/editmesh_knife_project.c
@@ -40,6 +40,7 @@
#include "BKE_curve.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_editmesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_report.h"
#include "DEG_depsgraph.h"
@@ -62,27 +63,28 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C, Scene *scene,
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
ARegion *ar = CTX_wm_region(C);
- DerivedMesh *dm;
- bool dm_needsFree;
+ struct Mesh *me_eval;
+ bool me_eval_needs_free;
if (ob->type == OB_MESH || ob->derivedFinal) {
- dm = ob->derivedFinal ? ob->derivedFinal : mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
- dm_needsFree = false;
+ me_eval = (ob->runtime.mesh_eval ?
+ ob->runtime.mesh_eval : mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH));
+ me_eval_needs_free = false;
}
else if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
- dm = CDDM_from_curve(ob);
- dm_needsFree = true;
+ me_eval = BKE_mesh_new_nomain_from_curve(ob);
+ me_eval_needs_free = true;
}
else {
- dm = NULL;
+ me_eval = NULL;
}
- if (dm) {
+ if (me_eval) {
ListBase nurbslist = {NULL, NULL};
float projmat[4][4];
- BKE_mesh_to_curve_nurblist(dm, &nurbslist, 0); /* wire */
- BKE_mesh_to_curve_nurblist(dm, &nurbslist, 1); /* boundary */
+ BKE_mesh_to_curve_nurblist(me_eval, &nurbslist, 0); /* wire */
+ BKE_mesh_to_curve_nurblist(me_eval, &nurbslist, 1); /* boundary */
ED_view3d_ob_project_mat_get(ar->regiondata, ob, projmat);
@@ -109,12 +111,11 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C, Scene *scene,
BKE_nurbList_free(&nurbslist);
- if (dm_needsFree) {
- dm->release(dm);
+ if (me_eval_needs_free) {
+ BKE_mesh_free(me_eval);
}
}
-
return polys;
}
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index 37b85ae9f09..3e787b2055a 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Joseph Eagar, Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
@@ -77,7 +77,7 @@
typedef struct RingSelOpData {
ARegion *ar; /* region that ringsel was activated in */
void *draw_handle; /* for drawing preview loop */
-
+
float (*edges)[2][3];
int totedge;
@@ -109,7 +109,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
{
View3D *v3d = CTX_wm_view3d(C);
RingSelOpData *lcd = arg;
-
+
if ((lcd->totedge > 0) || (lcd->totpoint > 0)) {
if (v3d && v3d->zbuf)
glDisable(GL_DEPTH_TEST);
@@ -172,7 +172,7 @@ static void edgering_find_order(BMEdge *lasteed, BMEdge *eed,
break;
}
}
-
+
/* this should never happen */
if (!l) {
v[0][0] = eed->v1;
@@ -181,7 +181,7 @@ static void edgering_find_order(BMEdge *lasteed, BMEdge *eed,
v[1][1] = lasteed->v2;
return;
}
-
+
l2 = BM_loop_other_edge_loop(l, eed->v1);
rev = (l2 == l->prev);
while (l2->v != lasteed->v1 && l2->v != lasteed->v2) {
@@ -446,7 +446,7 @@ static void ringsel_finish(bContext *C, wmOperator *op)
BMVert *v_eed_orig[2] = {lcd->eed->v1, lcd->eed->v2};
edgering_select(lcd);
-
+
if (lcd->do_cut) {
const bool is_macro = (op->opm != NULL);
/* a single edge (rare, but better support) */
@@ -494,7 +494,7 @@ static void ringsel_finish(bContext *C, wmOperator *op)
BM_select_history_store(em->bm, lcd->eed->v1); /* low priority TODO, get vertrex close to mouse */
if (em->selectmode & SCE_SELECT_EDGE)
BM_select_history_store(em->bm, lcd->eed);
-
+
EDBM_selectmode_flush(lcd->em);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, lcd->ob->data);
}
@@ -508,7 +508,7 @@ static void ringsel_exit(bContext *UNUSED(C), wmOperator *op)
/* deactivate the extra drawing stuff in 3D-View */
ED_region_draw_cb_exit(lcd->ar->type, lcd->draw_handle);
-
+
edgering_preview_free(lcd);
MEM_freeN(lcd->objects);
@@ -776,7 +776,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
case LEFTMOUSE: /* confirm */ // XXX hardcoded
if (event->val == KM_PRESS)
return loopcut_finish(lcd, C, op);
-
+
ED_region_tag_redraw(lcd->ar);
handled = true;
break;
@@ -791,11 +791,11 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* cancel */
ED_region_tag_redraw(lcd->ar);
ED_area_headerprint(CTX_wm_area(C), NULL);
-
+
ringcut_cancel(C, op);
return OPERATOR_CANCELLED;
}
-
+
ED_region_tag_redraw(lcd->ar);
handled = true;
break;
@@ -897,7 +897,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
str_rep, str_rep + NUM_STR_REP_LEN);
ED_area_headerprint(CTX_wm_area(C), buf);
}
-
+
/* keep going until the user confirms */
return OPERATOR_RUNNING_MODAL;
}
@@ -911,11 +911,11 @@ void MESH_OT_edgering_select(wmOperatorType *ot)
ot->name = "Edge Ring Select";
ot->idname = "MESH_OT_edgering_select";
ot->description = "Select an edge ring";
-
+
/* callbacks */
ot->invoke = ringsel_invoke;
- ot->poll = ED_operator_editmesh_region_view3d;
-
+ ot->poll = ED_operator_editmesh_region_view3d;
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -932,14 +932,14 @@ void MESH_OT_loopcut(wmOperatorType *ot)
ot->name = "Loop Cut";
ot->idname = "MESH_OT_loopcut";
ot->description = "Add a new loop between existing loops";
-
+
/* callbacks */
ot->invoke = ringcut_invoke;
ot->exec = loopcut_exec;
ot->modal = loopcut_modal;
ot->cancel = ringcut_cancel;
ot->poll = ED_operator_editmesh_region_view3d;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index fd8efcd84e3..634c65485e9 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -678,10 +678,10 @@ BMEdge *EDBM_edge_find_nearest_ex(
{
FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_EDGE);
ED_view3d_backbuf_validate_with_select_mode(vc, select_mode);
-
+
index = ED_view3d_backbuf_sample_rect(vc, vc->mval, dist_px, bm_solidoffs, bm_wireoffs, &dist_test);
eed = index ? BM_edge_at_index_find_or_table(bm, index - 1) : NULL;
-
+
FAKE_SELECT_MODE_END(vc, fake_select_mode);
}
@@ -1061,7 +1061,7 @@ static bool unified_findnearest(
mval_prev[0] = vc->mval[0];
mval_prev[1] = vc->mval[1];
-
+
/* Only one element type will be non-null. */
BLI_assert(((hit.v.ele != NULL) + (hit.e.ele != NULL) + (hit.f.ele != NULL)) <= 1);
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index afa89b11974..bbeb80fa8af 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -365,6 +365,7 @@ void MESH_OT_unsubdivide(wmOperatorType *ot)
void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
{
+ Main *bmain = CTX_data_main(C);
Object *obedit = em->ob;
BMIter iter;
BMVert *eve;
@@ -372,7 +373,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
ED_view3d_init_mats_rv3d(obedit, ar->regiondata);
struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
- CTX_data_scene(C), CTX_data_depsgraph(C), 0,
+ bmain, CTX_data_scene(C), CTX_data_depsgraph(C), 0,
ar, CTX_wm_view3d(C));
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
@@ -3630,7 +3631,7 @@ static Base *mesh_separate_tagged(Main *bmain, Scene *scene, ViewLayer *view_lay
base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_old, USER_DUP_MESH);
/* DAG_relations_tag_update(bmain); */ /* normally would call directly after but in this case delay recalc */
- assign_matarar(base_new->object, give_matarar(obedit), *give_totcolp(obedit)); /* new in 2.5 */
+ assign_matarar(bmain, base_new->object, give_matarar(obedit), *give_totcolp(obedit)); /* new in 2.5 */
ED_object_base_select(base_new, BA_SELECT);
@@ -5316,7 +5317,7 @@ static int edbm_dissolve_degenerate_exec(bContext *C, wmOperator *op)
} /* objects */
const float thresh = RNA_float_get(op->ptr, "threshold");
-
+
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 676af4fea5b..d2410c7d97b 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -255,7 +255,7 @@ void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
CustomData *ldata = GET_CD_DATA(me, ldata);
const int layernum = CustomData_get_active_layer(ldata, CD_MLOOPUV);
ED_mesh_uv_loop_reset_ex(me, layernum);
-
+
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
}
@@ -301,7 +301,7 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set)
CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, name);
CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface, name);
}
-
+
if (active_set || layernum_dst == 0) {
CustomData_set_layer_active(&me->ldata, CD_MLOOPUV, layernum_dst);
CustomData_set_layer_active(&me->fdata, CD_MTFACE, layernum_dst);
@@ -517,7 +517,7 @@ static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op))
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
}
-
+
return OPERATOR_FINISHED;
}
@@ -527,7 +527,7 @@ void MESH_OT_uv_texture_add(wmOperatorType *ot)
ot->name = "Add UV Map";
ot->description = "Add UV Map";
ot->idname = "MESH_OT_uv_texture_add";
-
+
/* api callbacks */
ot->poll = layers_poll;
ot->exec = mesh_uv_texture_add_exec;
@@ -545,7 +545,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e
Mesh *me;
Object *obedit;
int exitmode = 0;
-
+
if (v3d == NULL) {
BKE_report(op->reports, RPT_ERROR, "No 3D View Available");
return OPERATOR_CANCELLED;
@@ -558,7 +558,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e
BKE_report(op->reports, RPT_ERROR, "Not an object or mesh");
return OPERATOR_CANCELLED;
}
-
+
ima = (Image *)WM_operator_drop_load_path(C, op, ID_IM);
if (!ima) {
return OPERATOR_CANCELLED;
@@ -576,7 +576,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e
}
if (me->edit_btmesh == NULL)
return OPERATOR_CANCELLED;
-
+
if (exitmode) {
EDBM_mesh_load(obedit);
EDBM_mesh_free(me->edit_btmesh);
@@ -591,9 +591,9 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e
/* dummie drop support; ensure view shows a result :) */
if (v3d)
v3d->flag2 |= V3D_SOLID_TEX;
-
+
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-
+
return OPERATOR_FINISHED;
}
@@ -603,14 +603,14 @@ void MESH_OT_drop_named_image(wmOperatorType *ot)
ot->name = "Drop Image to Mesh UV Map";
ot->description = "Assign Image to active UV Map, or create an UV Map";
ot->idname = "MESH_OT_drop_named_image";
-
+
/* api callbacks */
ot->poll = layers_poll;
ot->invoke = drop_named_image_invoke;
-
+
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
-
+
/* properties */
RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Image name to assign");
RNA_def_string(ot->srna, "filepath", "Path", FILE_MAX, "Filepath", "Path to image file");
@@ -630,7 +630,7 @@ static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op))
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
}
-
+
return OPERATOR_FINISHED;
}
@@ -640,7 +640,7 @@ void MESH_OT_uv_texture_remove(wmOperatorType *ot)
ot->name = "Remove UV Map";
ot->description = "Remove UV Map";
ot->idname = "MESH_OT_uv_texture_remove";
-
+
/* api callbacks */
ot->poll = layers_poll;
ot->exec = mesh_uv_texture_remove_exec;
@@ -668,7 +668,7 @@ void MESH_OT_vertex_color_add(wmOperatorType *ot)
ot->name = "Add Vertex Color";
ot->description = "Add vertex color layer";
ot->idname = "MESH_OT_vertex_color_add";
-
+
/* api callbacks */
ot->poll = layers_poll;
ot->exec = mesh_vertex_color_add_exec;
@@ -694,7 +694,7 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot)
ot->name = "Remove Vertex Color";
ot->description = "Remove vertex color layer";
ot->idname = "MESH_OT_vertex_color_remove";
-
+
/* api callbacks */
ot->exec = mesh_vertex_color_remove_exec;
ot->poll = layers_poll;
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index e585f407052..eb04d62452c 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -48,7 +48,7 @@ struct LinkNode;
/* *** editmesh_utils.c *** */
/*
- * ok: the EDBM module is for editmode bmesh stuff. in contrast, the
+ * ok: the EDBM module is for editmode bmesh stuff. in contrast, the
* BMEdit module is for code shared with blenkernel that concerns
* the BMEditMesh structure. */
diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c
index 0d6c7320a95..5cfb269cbc3 100644
--- a/source/blender/editors/mesh/mesh_navmesh.c
+++ b/source/blender/editors/mesh/mesh_navmesh.c
@@ -383,7 +383,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh,
/* create custom data layer to save polygon idx */
CustomData_add_layer_named(&em->bm->pdata, CD_RECAST, CD_CALLOC, NULL, 0, "createRepresentation recastData");
CustomData_bmesh_init_pool(&em->bm->pdata, 0, BM_FACE);
-
+
/* create verts and faces for detailed mesh */
meshes = recast_polyMeshDetailGetMeshes(dmesh, &nmeshes);
polys = recast_polyMeshGetPolys(pmesh, NULL, &nvp);
@@ -445,7 +445,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh,
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
- ED_object_editmode_exit(C, EM_FREEDATA);
+ ED_object_editmode_exit(C, EM_FREEDATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
if (createob) {
@@ -616,14 +616,14 @@ static int navmesh_face_add_exec(bContext *C, wmOperator *UNUSED(op))
BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMFace *ef;
BMIter iter;
-
+
if (CustomData_has_layer(&em->bm->pdata, CD_RECAST)) {
int targetPolyIdx = findFreeNavPolyIndex(em);
if (targetPolyIdx > 0) {
/* set target poly idx to selected faces */
/*XXX this originally went last to first, but that isn't possible anymore*/
-
+
BM_ITER_MESH (ef, &iter, em->bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(ef, BM_ELEM_SELECT)) {
int *recastDataBlock = (int *)CustomData_bmesh_get(&em->bm->pdata, ef->head.data, CD_RECAST);
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 60200313b8c..546c000d726 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -98,12 +98,12 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_loop_to_region);
WM_operatortype_append(MESH_OT_region_to_loop);
WM_operatortype_append(MESH_OT_select_axis);
-
+
WM_operatortype_append(MESH_OT_uvs_rotate);
WM_operatortype_append(MESH_OT_uvs_reverse);
WM_operatortype_append(MESH_OT_colors_rotate);
WM_operatortype_append(MESH_OT_colors_reverse);
-
+
WM_operatortype_append(MESH_OT_fill);
WM_operatortype_append(MESH_OT_fill_grid);
WM_operatortype_append(MESH_OT_fill_holes);
@@ -229,7 +229,7 @@ void ED_operatormacros_mesh(void)
{
wmOperatorType *ot;
wmOperatorTypeMacro *otmacro;
-
+
ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", "Cut mesh loop and slide it",
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MESH_OT_loopcut");
@@ -326,14 +326,14 @@ void ED_operatormacros_mesh(void)
/* note mesh keymap also for other space? */
void ED_keymap_mesh(wmKeyConfig *keyconf)
-{
+{
wmKeyMap *keymap;
wmKeyMapItem *kmi;
int i;
-
+
keymap = WM_keymap_find(keyconf, "Mesh", 0, 0);
keymap->poll = ED_operator_editmesh;
-
+
WM_keymap_add_item(keymap, "MESH_OT_loopcut_slide", RKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "MESH_OT_offset_edge_loops_slide", RKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
WM_keymap_add_item(keymap, "MESH_OT_inset", IKEY, KM_PRESS, 0, 0);
@@ -344,6 +344,24 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "vertex_only", true);
/* selecting */
+
+ kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", ONEKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "type", SCE_SELECT_VERTEX);
+ kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", TWOKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "type", SCE_SELECT_EDGE);
+ kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", THREEKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "type", SCE_SELECT_FACE);
+
+ kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", ONEKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_enum_set(kmi->ptr, "type", SCE_SELECT_VERTEX);
+ RNA_boolean_set(kmi->ptr, "use_extend", true);
+ kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", TWOKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_enum_set(kmi->ptr, "type", SCE_SELECT_EDGE);
+ RNA_boolean_set(kmi->ptr, "use_extend", true);
+ kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", THREEKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_enum_set(kmi->ptr, "type", SCE_SELECT_FACE);
+ RNA_boolean_set(kmi->ptr, "use_extend", true);
+
/* standard mouse selection goes via space_view3d */
kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "extend", false);
@@ -381,20 +399,17 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MESH_OT_select_prev_item", PADMINUS, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
WM_keymap_add_item(keymap, "MESH_OT_select_non_manifold", MKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0);
-
+
WM_keymap_add_item(keymap, "MESH_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "deselect", false);
kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "deselect", true);
-
+
WM_keymap_add_item(keymap, "MESH_OT_faces_select_linked_flat", FKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0);
-
- /* selection mode */
- WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_select_mode", TABKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* hide */
kmi = WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "unselected", false);
@@ -407,14 +422,14 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "inside", false);
kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "inside", true);
-
+
WM_keymap_add_item(keymap, "VIEW3D_OT_edit_mesh_extrude_move_normal", EKEY, KM_PRESS, 0, 0); /* python operator */
WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_extrude", EKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_item(keymap, "TRANSFORM_OT_edge_crease", EKEY, KM_PRESS, KM_SHIFT, 0);
-
+
WM_keymap_add_item(keymap, "MESH_OT_spin", RKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_item(keymap, "MESH_OT_fill", FKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "MESH_OT_beautify_fill", FKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
@@ -448,9 +463,9 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MESH_OT_edge_face_add", FKEY, KM_PRESS, 0, 0);
// WM_keymap_add_item(keymap, "MESH_OT_skin", FKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); /* python, removed */
WM_keymap_add_item(keymap, "MESH_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
-
+
WM_keymap_add_menu(keymap, "INFO_MT_mesh_add", AKEY, KM_PRESS, KM_SHIFT, 0);
-
+
WM_keymap_add_item(keymap, "MESH_OT_separate", PKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MESH_OT_split", YKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MESH_OT_vert_connect_path", JKEY, KM_PRESS, 0, 0);
@@ -470,7 +485,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MESH_OT_dissolve_mode", XKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "MESH_OT_dissolve_mode", DELKEY, KM_PRESS, KM_CTRL, 0);
-
+
kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "use_occlude_geometry", true);
RNA_boolean_set(kmi->ptr, "only_selected", false);
@@ -478,7 +493,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "use_occlude_geometry", false);
RNA_boolean_set(kmi->ptr, "only_selected", true);
-
+
WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
/* menus */
@@ -489,13 +504,13 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_uv_map", UKEY, KM_PRESS, 0, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_vertex_group", GKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* useful stuff from object-mode */
for (i = 0; i <= 5; i++) {
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0);
RNA_int_set(kmi->ptr, "level", i);
}
-
+
ED_keymap_proportional_cycle(keyconf, keymap);
ED_keymap_proportional_editmode(keyconf, keymap, true);
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 9b86f904161..41e1ca13b79 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -54,6 +54,7 @@
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_material.h"
#include "BKE_object.h"
#include "BKE_object_deform.h"
@@ -286,7 +287,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_WARNING, "Cannot join while in edit mode");
return OPERATOR_CANCELLED;
}
-
+
/* ob is the object we are adding geometry to */
if (!ob || ob->type != OB_MESH) {
BKE_report(op->reports, RPT_WARNING, "Active object is not a mesh");
@@ -306,23 +307,23 @@ int join_mesh_exec(bContext *C, wmOperator *op)
totloop += me->totloop;
totpoly += me->totpoly;
totmat += base->object->totcol;
-
+
if (base->object == ob)
ok = true;
-
+
/* check for shapekeys */
if (me->key)
haskey++;
}
}
CTX_DATA_END;
-
- /* that way the active object is always selected */
+
+ /* that way the active object is always selected */
if (ok == false) {
BKE_report(op->reports, RPT_WARNING, "Active object is not a selected mesh");
return OPERATOR_CANCELLED;
}
-
+
/* only join meshes if there are verts to join, there aren't too many, and we only had one mesh selected */
me = (Mesh *)ob->data;
key = me->key;
@@ -331,7 +332,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_WARNING, "No mesh data to join");
return OPERATOR_CANCELLED;
}
-
+
if (totvert > MESH_MAX_VERTS) {
BKE_reportf(op->reports, RPT_WARNING, "Joining results in %d vertices, limit is %ld", totvert, MESH_MAX_VERTS);
return OPERATOR_CANCELLED;
@@ -346,23 +347,23 @@ int join_mesh_exec(bContext *C, wmOperator *op)
matmap = MEM_callocN(sizeof(*matmap) * totmat, "join_mesh matmap");
}
totcol = ob->totcol;
-
+
/* obact materials in new main array, is nicer start! */
for (a = 0; a < ob->totcol; a++) {
matar[a] = give_current_material(ob, a + 1);
id_us_plus((ID *)matar[a]);
/* increase id->us : will be lowered later */
}
-
+
/* - if destination mesh had shapekeys, move them somewhere safe, and set up placeholders
* with arrays that are large enough to hold shapekey data for all meshes
- * - if destination mesh didn't have shapekeys, but we encountered some in the meshes we're
+ * - if destination mesh didn't have shapekeys, but we encountered some in the meshes we're
* joining, set up a new keyblock and assign to the mesh
*/
if (key) {
/* make a duplicate copy that will only be used here... (must remember to free it!) */
nkey = BKE_key_copy(bmain, key);
-
+
/* for all keys in old block, clear data-arrays */
for (kb = key->block.first; kb; kb = kb->next) {
if (kb->data) MEM_freeN(kb->data);
@@ -375,14 +376,14 @@ int join_mesh_exec(bContext *C, wmOperator *op)
key = me->key = BKE_key_add((ID *)me);
key->type = KEY_RELATIVE;
}
-
+
/* first pass over objects - copying materials and vertexgroups across */
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
{
/* only act if a mesh, and not the one we're joining to */
if ((ob != base->object) && (base->object->type == OB_MESH)) {
me = base->object->data;
-
+
/* Join this object's vertex groups to the base one's */
for (dg = base->object->defbase.first; dg; dg = dg->next) {
/* See if this group exists in the object (if it doesn't, add it to the end) */
@@ -394,8 +395,8 @@ int join_mesh_exec(bContext *C, wmOperator *op)
}
if (ob->defbase.first && ob->actdef == 0)
ob->actdef = 1;
-
-
+
+
if (me->totvert) {
/* Add this object's materials to the base one's if they don't exist already (but only if limits not exceeded yet) */
if (totcol < MAXMAT) {
@@ -419,7 +420,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
}
}
}
-
+
/* if this mesh has shapekeys, check if destination mesh already has matching entries too */
if (me->key && key) {
/* for remapping KeyBlock.relative */
@@ -481,7 +482,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
edgeofs = 0;
loopofs = 0;
polyofs = 0;
-
+
/* inverse transform for all selected meshes in this object */
invert_m4_m4(imat, ob->obmat);
@@ -522,10 +523,10 @@ int join_mesh_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_END;
-
+
/* return to mesh we're merging to */
me = ob->data;
-
+
CustomData_free(&me->vdata, me->totvert);
CustomData_free(&me->edata, me->totedge);
CustomData_free(&me->ldata, me->totloop);
@@ -546,7 +547,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* update normals in case objects with non-uniform scale are joined */
BKE_mesh_calc_normals(me);
-
+
/* old material array */
for (a = 1; a <= ob->totcol; a++) {
ma = ob->mat[a - 1];
@@ -573,13 +574,13 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* other mesh users */
test_all_objects_materials(bmain, (ID *)me);
-
+
/* free temp copy of destination shapekeys (if applicable) */
if (nkey) {
/* We can assume nobody is using that ID currently. */
BKE_libblock_free_ex(bmain, nkey, false, false);
}
-
+
/* ensure newly inserted keys are time sorted */
if (key && (key->type != KEY_RELATIVE)) {
BKE_key_sort(key);
@@ -599,7 +600,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/*********************** JOIN AS SHAPES ***************************/
-/* Append selected meshes vertex locations as shapes of the active mesh,
+/* Append selected meshes vertex locations as shapes of the active mesh,
* return 0 if no join is made (error) and 1 of the join is done */
int join_mesh_shapes_exec(bContext *C, wmOperator *op)
@@ -613,14 +614,14 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
Key *key = me->key;
KeyBlock *kb;
bool ok = false, nonequal_verts = false;
-
+
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
{
if (base->object == ob) continue;
-
+
if (base->object->type == OB_MESH) {
selme = (Mesh *)base->object->data;
-
+
if (selme->totvert == me->totvert)
ok = true;
else
@@ -628,7 +629,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_END;
-
+
if (!ok) {
if (nonequal_verts)
BKE_report(op->reports, RPT_WARNING, "Selected meshes must have equal numbers of vertices");
@@ -636,7 +637,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_WARNING, "No additional selected meshes with equal vertex count to join");
return OPERATOR_CANCELLED;
}
-
+
if (key == NULL) {
key = me->key = BKE_key_add((ID *)me);
key->type = KEY_RELATIVE;
@@ -645,32 +646,32 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
kb = BKE_keyblock_add(key, NULL);
BKE_keyblock_convert_from_mesh(me, kb);
}
-
+
/* now ready to add new keys from selected meshes */
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
{
if (base->object == ob) continue;
-
+
if (base->object->type == OB_MESH) {
selme = (Mesh *)base->object->data;
-
+
if (selme->totvert == me->totvert) {
dm = mesh_get_derived_deform(depsgraph, scene, base->object, CD_MASK_BAREMESH);
-
+
if (!dm) continue;
-
+
kb = BKE_keyblock_add(key, base->object->id.name + 2);
-
+
DM_to_meshkey(dm, me, kb);
-
+
dm->release(dm);
}
}
}
CTX_DATA_END;
-
+
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -739,12 +740,12 @@ static int mesh_get_x_mirror_vert_spatial(Object *ob, DerivedMesh *dm, int index
Mesh *me = ob->data;
MVert *mvert = dm ? dm->getVertArray(dm) : me->mvert;
float vec[3];
-
+
mvert = &mvert[index];
vec[0] = -mvert->co[0];
vec[1] = mvert->co[1];
vec[2] = mvert->co[2];
-
+
return ED_mesh_mirror_spatial_table(ob, NULL, dm, vec, 'u');
}
@@ -802,7 +803,7 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c
{
float vec[3];
int i;
-
+
/* ignore nan verts */
if ((isfinite(co[0]) == false) ||
(isfinite(co[1]) == false) ||
@@ -810,11 +811,11 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c
{
return NULL;
}
-
+
vec[0] = -co[0];
vec[1] = co[1];
vec[2] = co[2];
-
+
i = ED_mesh_mirror_spatial_table(ob, em, NULL, vec, 'u');
if (i != -1) {
return BM_vert_at_index(em->bm, i);
@@ -831,14 +832,14 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, struct BMEditMesh *e
if (index == -1) {
BMIter iter;
BMVert *v;
-
+
index = 0;
BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
if (v == eve)
break;
index++;
}
-
+
if (index == em->bm->totvert) {
return NULL;
}
@@ -849,7 +850,7 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, struct BMEditMesh *e
if (poinval != -1)
return (BMVert *)(poinval);
return NULL;
-}
+}
BMVert *editbmesh_get_x_mirror_vert(Object *ob, struct BMEditMesh *em, BMVert *eve, const float co[3], int index, const bool use_topology)
{
@@ -921,19 +922,19 @@ static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float
{
BMIter iter;
BMFace *efa;
-
+
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
uv_poly_center(efa, cent, cd_loop_uv_offset);
-
+
if ( (fabsf(cent[0] - cent_vec[0]) < 0.001f) && (fabsf(cent[1] - cent_vec[1]) < 0.001f) ) {
BMIter liter;
BMLoop *l;
-
+
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
if ( (fabsf(luv->uv[0] - vec[0]) < 0.001f) && (fabsf(luv->uv[1] - vec[1]) < 0.001f) ) {
return luv->uv;
-
+
}
}
}
@@ -982,7 +983,7 @@ static int mirror_facerotation(MFace *a, MFace *b)
else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v1 == b->v3)
return 2;
}
-
+
return -1;
}
@@ -1154,21 +1155,22 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int
static void ed_mesh_pick_face_vert__mpoly_find(
/* context */
struct ARegion *ar, const float mval[2],
- /* mesh data */
- DerivedMesh *dm, MPoly *mp, MLoop *mloop,
+ /* mesh data (evaluated) */
+ const MPoly *mp,
+ const MVert *mvert, const MLoop *mloop,
/* return values */
float *r_len_best, int *r_v_idx_best)
{
const MLoop *ml;
int j = mp->totloop;
for (ml = &mloop[mp->loopstart]; j--; ml++) {
- float co[3], sco[2], len;
+ float sco[2];
const int v_idx = ml->v;
- dm->getVertCo(dm, v_idx, co);
+ const float *co = mvert[v_idx].co;
if (ED_view3d_project_float_object(ar, co, sco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
- len = len_manhattan_v2v2(mval, sco);
- if (len < *r_len_best) {
- *r_len_best = len;
+ const float len_test = len_manhattan_v2v2(mval, sco);
+ if (len_test < *r_len_best) {
+ *r_len_best = len_test;
*r_v_idx_best = v_idx;
}
}
@@ -1191,7 +1193,7 @@ bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned
struct ARegion *ar = CTX_wm_region(C);
/* derived mesh to find deformed locations */
- DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
int v_idx_best = ORIGINDEX_NONE;
@@ -1199,36 +1201,38 @@ bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned
const float mval_f[2] = {UNPACK2(mval)};
float len_best = FLT_MAX;
- MPoly *dm_mpoly;
- MLoop *dm_mloop;
- unsigned int dm_mpoly_tot;
+ MPoly *me_eval_mpoly;
+ MLoop *me_eval_mloop;
+ MVert *me_eval_mvert;
+ unsigned int me_eval_mpoly_len;
const int *index_mp_to_orig;
- dm_mpoly = dm->getPolyArray(dm);
- dm_mloop = dm->getLoopArray(dm);
+ me_eval_mpoly = me_eval->mpoly;
+ me_eval_mloop = me_eval->mloop;
+ me_eval_mvert = me_eval->mvert;
- dm_mpoly_tot = dm->getNumPolys(dm);
+ me_eval_mpoly_len = me_eval->totpoly;
- index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+ index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX);
/* tag all verts using this face */
if (index_mp_to_orig) {
unsigned int i;
- for (i = 0; i < dm_mpoly_tot; i++) {
+ for (i = 0; i < me_eval_mpoly_len; i++) {
if (index_mp_to_orig[i] == poly_index) {
ed_mesh_pick_face_vert__mpoly_find(
ar, mval_f,
- dm, &dm_mpoly[i], dm_mloop,
+ &me_eval_mpoly[i], me_eval_mvert, me_eval_mloop,
&len_best, &v_idx_best);
}
}
}
else {
- if (poly_index < dm_mpoly_tot) {
+ if (poly_index < me_eval_mpoly_len) {
ed_mesh_pick_face_vert__mpoly_find(
ar, mval_f,
- dm, &dm_mpoly[poly_index], dm_mloop,
+ &me_eval_mpoly[poly_index], me_eval_mvert, me_eval_mloop,
&len_best, &v_idx_best);
}
}
@@ -1236,15 +1240,12 @@ bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned
/* map 'dm -> me' index if possible */
if (v_idx_best != ORIGINDEX_NONE) {
const int *index_mv_to_orig;
-
- index_mv_to_orig = dm->getVertDataArray(dm, CD_ORIGINDEX);
+ index_mv_to_orig = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX);
if (index_mv_to_orig) {
v_idx_best = index_mv_to_orig[v_idx_best];
}
}
- dm->release(dm);
-
if ((v_idx_best != ORIGINDEX_NONE) && (v_idx_best < me->totvert)) {
*index = v_idx_best;
return true;
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index 0835618043d..65bf258f334 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -19,7 +19,7 @@
* All rights reserved.
*
* The Original Code is: all of this file.
-
+
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
@@ -79,7 +79,7 @@ void ED_mball_editmball_make(Object *obedit)
MetaElem *ml; /*, *newml;*/
ml = mb->elems.first;
-
+
while (ml) {
if (ml->flag & SELECT) mb->lastelem = ml;
ml = ml->next;
@@ -107,7 +107,7 @@ MetaElem *ED_mball_add_primitive(bContext *UNUSED(C), Object *obedit, float mat[
ml->flag &= ~SELECT;
ml = ml->next;
}
-
+
ml = BKE_mball_element_add(mball, type);
ml->rad *= dia;
mball->wiresize *= dia;
@@ -371,7 +371,7 @@ static int select_random_metaelems_exec(bContext *C, wmOperator *op)
const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f;
const int seed = WM_operator_properties_select_random_seed_increment_get(op);
-
+
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
@@ -415,14 +415,14 @@ void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot)
ot->name = "Select Random";
ot->description = "Randomly select metaelements";
ot->idname = "MBALL_OT_select_random_metaelems";
-
+
/* callback functions */
ot->exec = select_random_metaelems_exec;
ot->poll = ED_operator_editmball;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
WM_operator_properties_select_random(ot);
}
@@ -435,7 +435,7 @@ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op))
Object *obedit = CTX_data_edit_object(C);
MetaBall *mb = (MetaBall *)obedit->data;
MetaElem *ml, *newml;
-
+
ml = mb->editelems->last;
if (ml) {
while (ml) {
@@ -477,7 +477,7 @@ static int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op))
Object *obedit = CTX_data_edit_object(C);
MetaBall *mb = (MetaBall *)obedit->data;
MetaElem *ml, *next;
-
+
ml = mb->editelems->first;
if (ml) {
while (ml) {
@@ -549,7 +549,7 @@ void MBALL_OT_hide_metaelems(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
RNA_def_boolean(ot->srna, "unselected", false, "Unselected", "Hide unselected rather than selected");
}
@@ -575,7 +575,7 @@ static int reveal_metaelems_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb);
DEG_id_tag_update(obedit->data, 0);
}
-
+
return OPERATOR_FINISHED;
}
@@ -585,11 +585,11 @@ void MBALL_OT_reveal_metaelems(wmOperatorType *ot)
ot->name = "Reveal";
ot->description = "Reveal all hidden metaelements";
ot->idname = "MBALL_OT_reveal_metaelems";
-
+
/* callback functions */
ot->exec = reveal_metaelems_exec;
ot->poll = ED_operator_editmball;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -624,7 +624,7 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
}
if (ml == NULL) startelem = mb->editelems->first;
-
+
if (hits > 0) {
ml = startelem;
while (ml) {
@@ -644,7 +644,7 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
if (ml == NULL) ml = mb->editelems->first;
if (ml == startelem) break;
}
-
+
/* When some metaelem was found, then it is necessary to select or
* deselect it. */
if (ml_act) {
@@ -667,9 +667,9 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
/* Select only metaelem clicked on */
ml_act->flag |= SELECT;
}
-
+
mb->lastelem = ml_act;
-
+
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb);
return true;
diff --git a/source/blender/editors/metaball/mball_intern.h b/source/blender/editors/metaball/mball_intern.h
index 24a4ea86d87..6e96514c022 100644
--- a/source/blender/editors/metaball/mball_intern.h
+++ b/source/blender/editors/metaball/mball_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c
index 3af85c33bcc..2e1b7299295 100644
--- a/source/blender/editors/metaball/mball_ops.c
+++ b/source/blender/editors/metaball/mball_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -45,10 +45,10 @@ void ED_operatortypes_metaball(void)
{
WM_operatortype_append(MBALL_OT_delete_metaelems);
WM_operatortype_append(MBALL_OT_duplicate_metaelems);
-
+
WM_operatortype_append(MBALL_OT_hide_metaelems);
WM_operatortype_append(MBALL_OT_reveal_metaelems);
-
+
WM_operatortype_append(MBALL_OT_select_all);
WM_operatortype_append(MBALL_OT_select_similar);
WM_operatortype_append(MBALL_OT_select_random_metaelems);
@@ -71,22 +71,22 @@ void ED_keymap_metaball(wmKeyConfig *keyconf)
{
wmKeyMap *keymap;
wmKeyMapItem *kmi;
-
+
keymap = WM_keymap_find(keyconf, "Metaball", 0, 0);
keymap->poll = ED_operator_editmball;
WM_keymap_add_item(keymap, "OBJECT_OT_metaball_add", AKEY, KM_PRESS, KM_SHIFT, 0);
-
+
WM_keymap_add_item(keymap, "MBALL_OT_reveal_metaelems", HKEY, KM_PRESS, KM_ALT, 0);
kmi = WM_keymap_add_item(keymap, "MBALL_OT_hide_metaelems", HKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "unselected", false);
kmi = WM_keymap_add_item(keymap, "MBALL_OT_hide_metaelems", HKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "unselected", true);
-
+
WM_keymap_add_item(keymap, "MBALL_OT_delete_metaelems", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MBALL_OT_delete_metaelems", DELKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MBALL_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
-
+
kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", AKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 8d64d8b67e9..9ce7f556448 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -82,6 +82,7 @@
#include "BKE_material.h"
#include "BKE_mball.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_nla.h"
#include "BKE_object.h"
#include "BKE_particle.h"
@@ -1051,16 +1052,17 @@ void OBJECT_OT_lamp_add(wmOperatorType *ot)
static int collection_instance_add_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Collection *collection;
unsigned int layer;
float loc[3], rot[3];
-
+
if (RNA_struct_property_is_set(op->ptr, "name")) {
char name[MAX_ID_NAME - 2];
-
+
RNA_string_get(op->ptr, "name", name);
- collection = (Collection *)BKE_libblock_find_name(ID_GR, name);
-
+ collection = (Collection *)BKE_libblock_find_name(bmain, ID_GR, name);
+
if (0 == RNA_struct_property_is_set(op->ptr, "location")) {
const wmEvent *event = CTX_wm_window(C)->eventstate;
ARegion *ar = CTX_wm_region(C);
@@ -1078,7 +1080,6 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
if (collection) {
- Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -1216,7 +1217,7 @@ static int object_delete_exec(bContext *C, wmOperator *op)
const bool use_global = RNA_boolean_get(op->ptr, "use_global");
bool changed = false;
- if (CTX_data_edit_object(C))
+ if (CTX_data_edit_object(C))
return OPERATOR_CANCELLED;
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
@@ -1290,7 +1291,7 @@ static int object_delete_exec(bContext *C, wmOperator *op)
if (scene->id.tag & LIB_TAG_DOIT) {
scene->id.tag &= ~LIB_TAG_DOIT;
-
+
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
@@ -1634,10 +1635,10 @@ static void convert_ensure_curve_cache(Depsgraph *depsgraph, Scene *scene, Objec
}
}
-static void curvetomesh(Depsgraph *depsgraph, Scene *scene, Object *ob)
+static void curvetomesh(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob)
{
convert_ensure_curve_cache(depsgraph, scene, ob);
- BKE_mesh_from_nurbs(ob); /* also does users */
+ BKE_mesh_from_nurbs(bmain, ob); /* also does users */
if (ob->type == OB_MESH) {
BKE_object_free_modifiers(ob, 0);
@@ -1784,7 +1785,7 @@ static int convert_exec(bContext *C, wmOperator *op)
newob = ob;
}
- BKE_mesh_to_curve(depsgraph, scene, newob);
+ BKE_mesh_to_curve(bmain, depsgraph, scene, newob);
if (newob->type == OB_CURVE) {
BKE_object_free_modifiers(newob, 0); /* after derivedmesh calls! */
@@ -1886,7 +1887,7 @@ static int convert_exec(bContext *C, wmOperator *op)
BKE_curve_curve_dimension_update(cu);
if (target == OB_MESH) {
- curvetomesh(depsgraph, scene, newob);
+ curvetomesh(bmain, depsgraph, scene, newob);
/* meshes doesn't use displist */
BKE_object_free_curve_cache(newob);
@@ -1910,7 +1911,7 @@ static int convert_exec(bContext *C, wmOperator *op)
newob = ob;
}
- curvetomesh(depsgraph, scene, newob);
+ curvetomesh(bmain, depsgraph, scene, newob);
/* meshes doesn't use displist */
BKE_object_free_curve_cache(newob);
@@ -2046,7 +2047,7 @@ void OBJECT_OT_convert(wmOperatorType *ot)
/**************************** Duplicate ************************/
-/*
+/*
* dupflag: a flag made from constants declared in DNA_userdef_types.h
* The flag tells adduplicate() whether to copy data linked to the object, or to reference the existing data.
* U.dupflag for default operations or you can construct a flag as python does
@@ -2071,7 +2072,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, ViewLayer
}
else {
obn = ID_NEW_SET(ob, BKE_object_copy(bmain, ob));
- DEG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA);
base = BKE_view_layer_base_find(view_layer, ob);
if ((base != NULL) && (base->flag & BASE_VISIBLED)) {
@@ -2353,7 +2354,7 @@ static int duplicate_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(bmain);
/* TODO(sergey): Use proper flag for tagging here. */
- DEG_id_tag_update(&CTX_data_scene(C)->id, 0);
+ DEG_id_tag_update(&scene->id, 0);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
@@ -2399,7 +2400,7 @@ static int add_named_exec(bContext *C, wmOperator *op)
/* find object, create fake base */
RNA_string_get(op->ptr, "name", name);
- ob = (Object *)BKE_libblock_find_name(ID_OB, name);
+ ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, name);
if (ob == NULL) {
BKE_report(op->reports, RPT_ERROR, "Object not found");
@@ -2424,7 +2425,7 @@ static int add_named_exec(bContext *C, wmOperator *op)
ED_object_location_from_view(C, basen->object->loc);
ED_view3d_cursor3d_position(C, basen->object->loc, mval);
}
-
+
ED_object_base_select(basen, BA_SELECT);
ED_object_base_activate(C, basen);
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 9af8169ae41..5210182510f 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -276,7 +276,7 @@ static void refresh_images(BakeImages *bake_images)
Image *ima = bake_images->data[i].image;
if (ima->ok == IMA_OK_LOADED) {
GPU_free_image(ima);
- DEG_id_tag_update(&ima->id, 0);
+ DEG_id_tag_update(&ima->id, 0);
}
}
}
@@ -625,7 +625,7 @@ static size_t initialize_internal_images(BakeImages *bake_images, ReportList *re
/* create new mesh with edit mode changes and modifiers applied */
static Mesh *bake_mesh_new_from_object(Depsgraph *depsgraph, Main *bmain, Scene *scene, Object *ob)
{
- ED_object_editmode_load(ob);
+ ED_object_editmode_load(bmain, ob);
Mesh *me = BKE_mesh_new_from_object(depsgraph, bmain, scene, ob, 1, 0, 0);
if (me->flag & ME_AUTOSMOOTH) {
@@ -1021,7 +1021,8 @@ cage_cleanup:
BakeData *bake = &scene->r.bake;
char name[FILE_MAX];
- BKE_image_path_from_imtype(name, filepath, bmain->name, 0, bake->im_format.imtype, true, false, NULL);
+ BKE_image_path_from_imtype(name, filepath, BKE_main_blendfile_path(bmain),
+ 0, bake->im_format.imtype, true, false, NULL);
if (is_automatic_name) {
BLI_path_suffix(name, FILE_MAX, ob_low->id.name + 2, "_");
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 28ff1ffab1c..3b5a8d190ff 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -91,17 +91,17 @@ ListBase *get_active_constraints(Object *ob)
{
if (ob == NULL)
return NULL;
-
+
if (ob->mode & OB_MODE_POSE) {
bPoseChannel *pchan;
-
+
pchan = BKE_pose_channel_active(ob);
if (pchan)
return &pchan->constraints;
}
- else
+ else
return &ob->constraints;
-
+
return NULL;
}
@@ -110,33 +110,33 @@ ListBase *get_constraint_lb(Object *ob, bConstraint *con, bPoseChannel **r_pchan
{
if (r_pchan)
*r_pchan = NULL;
-
+
if (ELEM(NULL, ob, con))
return NULL;
-
+
/* try object constraints first */
if ((BLI_findindex(&ob->constraints, con) != -1)) {
return &ob->constraints;
}
-
+
/* if armature, try pose bones too */
if (ob->pose) {
bPoseChannel *pchan;
-
- /* try each bone in order
+
+ /* try each bone in order
* NOTE: it's not possible to directly look up the active bone yet, so this will have to do
*/
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if ((BLI_findindex(&pchan->constraints, con) != -1)) {
-
+
if (r_pchan)
*r_pchan = pchan;
-
+
return &pchan->constraints;
}
}
}
-
+
/* done */
return NULL;
}
@@ -152,59 +152,59 @@ bConstraint *get_active_constraint(Object *ob)
/* ------------- PyConstraints ------------------ */
/* this callback sets the text-file to be used for selected menu item */
-static void validate_pyconstraint_cb(void *arg1, void *arg2)
+static void validate_pyconstraint_cb(Main *bmain, void *arg1, void *arg2)
{
bPythonConstraint *data = arg1;
Text *text = NULL;
int index = *((int *)arg2);
int i;
-
+
/* exception for no script */
if (index) {
/* innovative use of a for...loop to search */
- for (text = G.main->text.first, i = 1; text && index != i; i++, text = text->id.next) ;
+ for (text = bmain->text.first, i = 1; text && index != i; i++, text = text->id.next) ;
}
data->text = text;
}
/* this returns a string for the list of usable pyconstraint script names */
-static char *buildmenu_pyconstraints(Text *con_text, int *pyconindex)
+static char *buildmenu_pyconstraints(Main *bmain, Text *con_text, int *pyconindex)
{
DynStr *pupds = BLI_dynstr_new();
Text *text;
char *str;
char buf[64];
int i;
-
+
/* add title first */
sprintf(buf, "Scripts: %%t|[None]%%x0|");
BLI_dynstr_append(pupds, buf);
-
+
/* init active-index first */
if (con_text == NULL)
*pyconindex = 0;
-
+
/* loop through markers, adding them */
- for (text = G.main->text.first, i = 1; text; i++, text = text->id.next) {
+ for (text = bmain->text.first, i = 1; text; i++, text = text->id.next) {
/* this is important to ensure that right script is shown as active */
if (text == con_text) *pyconindex = i;
-
+
/* only include valid pyconstraint scripts */
if (BPY_is_pyconstraint(text)) {
BLI_dynstr_append(pupds, text->id.name + 2);
-
+
sprintf(buf, "%%x%d", i);
BLI_dynstr_append(pupds, buf);
-
+
if (text->id.next)
BLI_dynstr_append(pupds, "|");
}
}
-
+
/* convert to normal MEM_malloc'd string */
str = BLI_dynstr_get_cstring(pupds);
BLI_dynstr_free(pupds);
-
+
return str;
}
#endif /* WITH_PYTHON */
@@ -232,11 +232,11 @@ static void set_constraint_nth_target(bConstraint *con, Object *target, const ch
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
int num_targets, i;
-
+
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
num_targets = BLI_listbase_count(&targets);
-
+
if (index < 0) {
if (abs(index) < num_targets)
index = num_targets - abs(index);
@@ -246,7 +246,7 @@ static void set_constraint_nth_target(bConstraint *con, Object *target, const ch
else if (index >= num_targets) {
index = num_targets - 1;
}
-
+
for (ct = targets.first, i = 0; ct; ct = ct->next, i++) {
if (i == index) {
ct->tar = target;
@@ -254,7 +254,7 @@ static void set_constraint_nth_target(bConstraint *con, Object *target, const ch
break;
}
}
-
+
if (cti->flush_constraint_targets)
cti->flush_constraint_targets(con, &targets, 0);
}
@@ -262,7 +262,7 @@ static void set_constraint_nth_target(bConstraint *con, Object *target, const ch
/* ------------- Constraint Sanity Testing ------------------- */
-static void test_constraint(Object *owner, bPoseChannel *pchan, bConstraint *con, int type)
+static void test_constraint(Main *bmain, Object *owner, bPoseChannel *pchan, bConstraint *con, int type)
{
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
@@ -280,7 +280,7 @@ static void test_constraint(Object *owner, bPoseChannel *pchan, bConstraint *con
* the constraint is deemed invalid
*/
/* default IK check ... */
- if (BKE_object_exists_check(data->tar) == 0) {
+ if (BKE_object_exists_check(bmain, data->tar) == 0) {
data->tar = NULL;
con->flag |= CONSTRAINT_DISABLE;
}
@@ -291,7 +291,7 @@ static void test_constraint(Object *owner, bPoseChannel *pchan, bConstraint *con
}
if (data->poletar) {
- if (BKE_object_exists_check(data->poletar) == 0) {
+ if (BKE_object_exists_check(bmain, data->poletar) == 0) {
data->poletar = NULL;
con->flag |= CONSTRAINT_DISABLE;
}
@@ -310,7 +310,7 @@ static void test_constraint(Object *owner, bPoseChannel *pchan, bConstraint *con
bPivotConstraint *data = con->data;
/* target doesn't have to exist, but if it is non-null, it must exist! */
- if (data->tar && BKE_object_exists_check(data->tar) == 0) {
+ if (data->tar && BKE_object_exists_check(bmain, data->tar) == 0) {
data->tar = NULL;
con->flag |= CONSTRAINT_DISABLE;
}
@@ -433,7 +433,7 @@ static void test_constraint(Object *owner, bPoseChannel *pchan, bConstraint *con
/* disable and clear constraints targets that are incorrect */
for (ct = targets.first; ct; ct = ct->next) {
/* general validity checks (for those constraints that need this) */
- if (BKE_object_exists_check(ct->tar) == 0) {
+ if (BKE_object_exists_check(bmain, ct->tar) == 0) {
/* object doesn't exist, but constraint requires target */
ct->tar = NULL;
con->flag |= CONSTRAINT_DISABLE;
@@ -503,12 +503,12 @@ static int constraint_type_get(Object *owner, bPoseChannel *pchan)
/* checks validity of object pointers, and NULLs,
* if Bone doesnt exist it sets the CONSTRAINT_DISABLE flag.
*/
-static void test_constraints(Object *owner, bPoseChannel *pchan)
+static void test_constraints(Main *bmain, Object *owner, bPoseChannel *pchan)
{
bConstraint *curcon;
ListBase *conlist = NULL;
int type;
-
+
if (owner == NULL) return;
type = constraint_type_get(owner, pchan);
@@ -522,48 +522,48 @@ static void test_constraints(Object *owner, bPoseChannel *pchan)
conlist = &pchan->constraints;
break;
}
-
+
/* Check all constraints - is constraint valid? */
if (conlist) {
for (curcon = conlist->first; curcon; curcon = curcon->next) {
- test_constraint(owner, pchan, curcon, type);
+ test_constraint(bmain, owner, pchan, curcon, type);
}
}
}
-void object_test_constraints(Object *owner)
+void object_test_constraints(Main *bmain, Object *owner)
{
if (owner->constraints.first)
- test_constraints(owner, NULL);
-
+ test_constraints(bmain, owner, NULL);
+
if (owner->type == OB_ARMATURE && owner->pose) {
bPoseChannel *pchan;
-
+
for (pchan = owner->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->constraints.first)
- test_constraints(owner, pchan);
+ test_constraints(bmain, owner, pchan);
}
}
}
-static void object_test_constraint(Object *owner, bConstraint *con)
+static void object_test_constraint(Main *bmain, Object *owner, bConstraint *con)
{
if (owner->type == OB_ARMATURE && owner->pose) {
if (BLI_findindex(&owner->constraints, con) != -1) {
- test_constraint(owner, NULL, con, CONSTRAINT_OBTYPE_OBJECT);
+ test_constraint(bmain, owner, NULL, con, CONSTRAINT_OBTYPE_OBJECT);
}
else {
bPoseChannel *pchan;
for (pchan = owner->pose->chanbase.first; pchan; pchan = pchan->next) {
if (BLI_findindex(&pchan->constraints, con) != -1) {
- test_constraint(owner, pchan, con, CONSTRAINT_OBTYPE_BONE);
+ test_constraint(bmain, owner, pchan, con, CONSTRAINT_OBTYPE_BONE);
break;
}
}
}
}
else {
- test_constraint(owner, NULL, con, CONSTRAINT_OBTYPE_OBJECT);
+ test_constraint(bmain, owner, NULL, con, CONSTRAINT_OBTYPE_OBJECT);
}
}
@@ -623,24 +623,24 @@ static int edit_constraint_invoke_properties(bContext *C, wmOperator *op)
Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C);
bConstraint *con;
ListBase *list;
-
+
if (RNA_struct_property_is_set(op->ptr, "constraint") && RNA_struct_property_is_set(op->ptr, "owner"))
return 1;
-
+
if (ptr.data) {
con = ptr.data;
RNA_string_set(op->ptr, "constraint", con->name);
-
+
list = get_constraint_lb(ob, con, NULL);
-
+
if (&ob->constraints == list)
RNA_enum_set(op->ptr, "owner", EDIT_CONSTRAINT_OWNER_OBJECT);
else
RNA_enum_set(op->ptr, "owner", EDIT_CONSTRAINT_OWNER_BONE);
-
+
return 1;
}
-
+
return 0;
}
@@ -650,9 +650,9 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
int owner = RNA_enum_get(op->ptr, "owner");
bConstraint *con;
ListBase *list = NULL;
-
+
RNA_string_get(op->ptr, "constraint", constraint_name);
-
+
if (owner == EDIT_CONSTRAINT_OWNER_OBJECT) {
list = &ob->constraints;
}
@@ -671,14 +671,14 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
//printf("edit_constraint_property_get: defaulting to getting list in the standard way\n");
list = get_active_constraints(ob);
}
-
+
con = BKE_constraints_find_name(list, constraint_name);
//if (G.debug & G_DEBUG)
//printf("constraint found = %p, %s\n", (void *)con, (con) ? con->name : "<Not found>");
if (con && (type != 0) && (con->type != type))
con = NULL;
-
+
return con;
}
@@ -689,18 +689,19 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
static int stretchto_reset_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_STRETCHTO);
bStretchToConstraint *data = (con) ? (bStretchToConstraint *)con->data : NULL;
-
+
/* despite 3 layers of checks, we may still not be able to find a constraint */
if (data == NULL)
return OPERATOR_CANCELLED;
-
+
/* just set original length to 0.0, which will cause a reset on next recalc */
data->orglength = 0.0f;
- ED_object_constraint_update(ob);
-
+ ED_object_constraint_update(bmain, ob);
+
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL);
return OPERATOR_FINISHED;
}
@@ -719,15 +720,15 @@ void CONSTRAINT_OT_stretchto_reset(wmOperatorType *ot)
ot->name = "Reset Original Length";
ot->idname = "CONSTRAINT_OT_stretchto_reset";
ot->description = "Reset original length of bone for Stretch To Constraint";
-
+
/* callbacks */
ot->invoke = stretchto_reset_invoke;
ot->exec = stretchto_reset_exec;
ot->poll = edit_constraint_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
edit_constraint_properties(ot);
}
@@ -735,18 +736,19 @@ void CONSTRAINT_OT_stretchto_reset(wmOperatorType *ot)
static int limitdistance_reset_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_DISTLIMIT);
bDistLimitConstraint *data = (con) ? (bDistLimitConstraint *)con->data : NULL;
-
+
/* despite 3 layers of checks, we may still not be able to find a constraint */
if (data == NULL)
return OPERATOR_CANCELLED;
-
+
/* just set original length to 0.0, which will cause a reset on next recalc */
data->dist = 0.0f;
- ED_object_constraint_update(ob);
-
+ ED_object_constraint_update(bmain, ob);
+
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL);
return OPERATOR_FINISHED;
}
@@ -765,15 +767,15 @@ void CONSTRAINT_OT_limitdistance_reset(wmOperatorType *ot)
ot->name = "Reset Distance";
ot->idname = "CONSTRAINT_OT_limitdistance_reset";
ot->description = "Reset limiting distance for Limit Distance Constraint";
-
+
/* callbacks */
ot->invoke = limitdistance_reset_invoke;
ot->exec = limitdistance_reset_exec;
ot->poll = edit_constraint_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
edit_constraint_properties(ot);
}
@@ -786,7 +788,7 @@ static void child_get_inverse_matrix(const bContext *C, Scene *scene, Object *ob
/* nullify inverse matrix first */
unit_m4(invmat);
-
+
if (owner == EDIT_CONSTRAINT_OWNER_BONE) {
bPoseChannel *pchan;
/* try to find a pose channel - assume that this is the constraint owner */
@@ -881,11 +883,11 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Could not find constraint data for Child-Of Set Inverse");
return OPERATOR_CANCELLED;
}
-
+
child_get_inverse_matrix(C, scene, ob, con, data->invmat, owner);
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -903,15 +905,15 @@ void CONSTRAINT_OT_childof_set_inverse(wmOperatorType *ot)
ot->name = "Set Inverse";
ot->idname = "CONSTRAINT_OT_childof_set_inverse";
ot->description = "Set inverse correction for ChildOf constraint";
-
+
/* callbacks */
ot->invoke = childof_set_inverse_invoke;
ot->exec = childof_set_inverse_exec;
ot->poll = edit_constraint_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
edit_constraint_properties(ot);
}
@@ -922,17 +924,17 @@ static int childof_clear_inverse_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF);
bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL;
-
+
if (data == NULL) {
BKE_report(op->reports, RPT_ERROR, "Child Of constraint not found");
return OPERATOR_CANCELLED;
}
-
+
/* simply clear the matrix */
unit_m4(data->invmat);
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -950,15 +952,15 @@ void CONSTRAINT_OT_childof_clear_inverse(wmOperatorType *ot)
ot->name = "Clear Inverse";
ot->idname = "CONSTRAINT_OT_childof_clear_inverse";
ot->description = "Clear inverse correction for ChildOf constraint";
-
+
/* callbacks */
ot->invoke = childof_clear_inverse_invoke;
ot->exec = childof_clear_inverse_exec;
ot->poll = edit_constraint_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
edit_constraint_properties(ot);
}
@@ -967,33 +969,34 @@ void CONSTRAINT_OT_childof_clear_inverse(wmOperatorType *ot)
static int followpath_path_animate_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_FOLLOWPATH);
bFollowPathConstraint *data = (con) ? (bFollowPathConstraint *)con->data : NULL;
-
+
bAction *act = NULL;
FCurve *fcu = NULL;
int sfra = RNA_int_get(op->ptr, "frame_start");
int len = RNA_int_get(op->ptr, "length");
float standardRange = 1.0;
-
+
/* nearly impossible sanity check */
if (data == NULL) {
BKE_report(op->reports, RPT_ERROR, "Follow Path constraint not found");
return OPERATOR_CANCELLED;
}
-
+
/* add F-Curve as appropriate */
if (data->tar) {
Curve *cu = (Curve *)data->tar->data;
-
+
if (ELEM(NULL, cu->adt, cu->adt->action) ||
(list_find_fcurve(&cu->adt->action->curves, "eval_time", 0) == NULL))
{
/* create F-Curve for path animation */
- act = verify_adt_action(&cu->id, 1);
+ act = verify_adt_action(bmain, &cu->id, 1);
fcu = verify_fcurve(act, NULL, NULL, "eval_time", 0, 1);
-
+
/* standard vertical range - 1:1 = 100 frames */
standardRange = 100.0f;
}
@@ -1008,46 +1011,46 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op)
PointerRNA ptr;
PropertyRNA *prop;
char *path;
-
+
/* get RNA pointer to constraint's "offset_factor" property - to build RNA path */
RNA_pointer_create(&ob->id, &RNA_FollowPathConstraint, con, &ptr);
prop = RNA_struct_find_property(&ptr, "offset_factor");
-
+
path = RNA_path_from_ID_to_property(&ptr, prop);
-
+
/* create F-Curve for constraint */
- act = verify_adt_action(&ob->id, 1);
+ act = verify_adt_action(bmain, &ob->id, 1);
fcu = verify_fcurve(act, NULL, NULL, path, 0, 1);
-
+
/* standard vertical range - 0.0 to 1.0 */
standardRange = 1.0f;
-
+
/* enable "Use Fixed Position" so that animating this has effect */
data->followflag |= FOLLOWPATH_STATIC;
-
+
/* path needs to be freed */
- if (path)
+ if (path)
MEM_freeN(path);
}
-
+
/* setup dummy 'generator' modifier here to get 1-1 correspondence still working
* and define basic slope of this curve based on the properties
*/
if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) {
FModifier *fcm = add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu);
FMod_Generator *gen = fcm->data;
-
+
/* Assume that we have the following equation:
* y = Ax + B
* 1 0 <-- coefficients array indices
*/
float A = standardRange / (float)(len);
float B = (float)(-sfra) * A;
-
+
gen->coefficients[1] = A;
gen->coefficients[0] = B;
}
-
+
/* updates... */
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
return OPERATOR_FINISHED;
@@ -1070,20 +1073,20 @@ void CONSTRAINT_OT_followpath_path_animate(wmOperatorType *ot)
ot->name = "Auto Animate Path";
ot->idname = "CONSTRAINT_OT_followpath_path_animate";
ot->description = "Add default animation for path used by constraint if it isn't animated already";
-
+
/* callbacks */
ot->invoke = followpath_path_animate_invoke;
ot->exec = followpath_path_animate_exec;
ot->poll = edit_constraint_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
edit_constraint_properties(ot);
- RNA_def_int(ot->srna, "frame_start", 1, MINAFRAME, MAXFRAME, "Start Frame",
+ RNA_def_int(ot->srna, "frame_start", 1, MINAFRAME, MAXFRAME, "Start Frame",
"First frame of path animation", MINAFRAME, MAXFRAME);
- RNA_def_int(ot->srna, "length", 100, 0, MAXFRAME, "Length",
+ RNA_def_int(ot->srna, "length", 100, 0, MAXFRAME, "Length",
"Number of frames that path animation should take", 0, MAXFRAME);
}
@@ -1125,7 +1128,7 @@ void CONSTRAINT_OT_objectsolver_set_inverse(wmOperatorType *ot)
ot->name = "Set Inverse";
ot->idname = "CONSTRAINT_OT_objectsolver_set_inverse";
ot->description = "Set inverse correction for ObjectSolver constraint";
-
+
/* callbacks */
ot->invoke = objectsolver_set_inverse_invoke;
ot->exec = objectsolver_set_inverse_exec;
@@ -1133,7 +1136,7 @@ void CONSTRAINT_OT_objectsolver_set_inverse(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
edit_constraint_properties(ot);
}
@@ -1171,7 +1174,7 @@ void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot)
ot->name = "Clear Inverse";
ot->idname = "CONSTRAINT_OT_objectsolver_clear_inverse";
ot->description = "Clear inverse correction for ObjectSolver constraint";
-
+
/* callbacks */
ot->invoke = objectsolver_clear_inverse_invoke;
ot->exec = objectsolver_clear_inverse_exec;
@@ -1179,7 +1182,7 @@ void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
edit_constraint_properties(ot);
}
@@ -1187,26 +1190,26 @@ void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot)
/***************************** BUTTONS ****************************/
void ED_object_constraint_set_active(Object *ob, bConstraint *con)
-{
+{
ListBase *lb = get_constraint_lb(ob, con, NULL);
-
+
/* lets be nice and escape if its active already */
/* NOTE: this assumes that the stack doesn't have other active ones set... */
if ((lb && con) && (con->flag & CONSTRAINT_ACTIVE))
return;
-
+
BKE_constraints_active_set(lb, con);
}
-void ED_object_constraint_update(Object *ob)
+void ED_object_constraint_update(Main *bmain, Object *ob)
{
if (ob->pose) BKE_pose_update_constraint_flags(ob->pose);
- object_test_constraints(ob);
+ object_test_constraints(bmain, ob);
- if (ob->type == OB_ARMATURE)
+ if (ob->type == OB_ARMATURE)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
- else
+ else
DEG_id_tag_update(&ob->id, OB_RECALC_OB);
}
@@ -1225,7 +1228,7 @@ static void object_pose_tag_update(Main *bmain, Object *ob)
void ED_object_constraint_dependency_update(Main *bmain, Object *ob)
{
- ED_object_constraint_update(ob);
+ ED_object_constraint_update(bmain, ob);
if (ob->pose) {
object_pose_tag_update(bmain, ob);
@@ -1233,13 +1236,13 @@ void ED_object_constraint_dependency_update(Main *bmain, Object *ob)
DEG_relations_tag_update(bmain);
}
-void ED_object_constraint_tag_update(Object *ob, bConstraint *con)
+void ED_object_constraint_tag_update(Main *bmain, Object *ob, bConstraint *con)
{
if (ob->pose) {
BKE_pose_tag_update_constraint_flags(ob->pose);
}
- object_test_constraint(ob, con);
+ object_test_constraint(bmain, ob, con);
if (ob->type == OB_ARMATURE)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
@@ -1254,7 +1257,7 @@ void ED_object_constraint_tag_update(Object *ob, bConstraint *con)
void ED_object_constraint_dependency_tag_update(Main *bmain, Object *ob, bConstraint *con)
{
- ED_object_constraint_tag_update(ob, con);
+ ED_object_constraint_tag_update(bmain, ob, con);
if (ob->pose) {
object_pose_tag_update(bmain, ob);
@@ -1271,6 +1274,7 @@ static int constraint_poll(bContext *C)
static int constraint_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Main *bmain = CTX_data_main(C);
PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint);
Object *ob = ptr.id.data;
bConstraint *con = ptr.data;
@@ -1280,14 +1284,14 @@ static int constraint_delete_exec(bContext *C, wmOperator *UNUSED(op))
if (BKE_constraint_remove_ex(lb, ob, con, true)) {
/* there's no active constraint now, so make sure this is the case */
BKE_constraints_active_set(&ob->constraints, NULL);
- ED_object_constraint_update(ob); /* needed to set the flags on posebones correctly */
+ ED_object_constraint_update(bmain, ob); /* needed to set the flags on posebones correctly */
/* relatiols */
DEG_relations_tag_update(CTX_data_main(C));
/* notifiers */
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob);
-
+
return OPERATOR_FINISHED;
}
else {
@@ -1302,11 +1306,11 @@ void CONSTRAINT_OT_delete(wmOperatorType *ot)
ot->name = "Delete Constraint";
ot->idname = "CONSTRAINT_OT_delete";
ot->description = "Remove constraint from constraint stack";
-
+
/* callbacks */
ot->exec = constraint_delete_exec;
ot->poll = constraint_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1316,20 +1320,20 @@ static int constraint_move_down_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, 0);
-
+
if (con && con->next) {
ListBase *conlist = get_constraint_lb(ob, con, NULL);
bConstraint *nextCon = con->next;
-
+
/* insert the nominated constraint after the one that used to be after it */
BLI_remlink(conlist, con);
BLI_insertlinkafter(conlist, nextCon, con);
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
-
+
return OPERATOR_FINISHED;
}
-
+
return OPERATOR_CANCELLED;
}
@@ -1347,15 +1351,15 @@ void CONSTRAINT_OT_move_down(wmOperatorType *ot)
ot->name = "Move Constraint Down";
ot->idname = "CONSTRAINT_OT_move_down";
ot->description = "Move constraint down in constraint stack";
-
+
/* callbacks */
ot->invoke = constraint_move_down_invoke;
ot->exec = constraint_move_down_exec;
ot->poll = edit_constraint_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
edit_constraint_properties(ot);
}
@@ -1365,20 +1369,20 @@ static int constraint_move_up_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, 0);
-
+
if (con && con->prev) {
ListBase *conlist = get_constraint_lb(ob, con, NULL);
bConstraint *prevCon = con->prev;
-
+
/* insert the nominated constraint before the one that used to be before it */
BLI_remlink(conlist, con);
BLI_insertlinkbefore(conlist, prevCon, con);
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
-
+
return OPERATOR_FINISHED;
}
-
+
return OPERATOR_CANCELLED;
}
@@ -1396,12 +1400,12 @@ void CONSTRAINT_OT_move_up(wmOperatorType *ot)
ot->name = "Move Constraint Up";
ot->idname = "CONSTRAINT_OT_move_up";
ot->description = "Move constraint up in constraint stack";
-
+
/* callbacks */
ot->exec = constraint_move_up_exec;
ot->invoke = constraint_move_up_invoke;
ot->poll = edit_constraint_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
edit_constraint_properties(ot);
@@ -1415,7 +1419,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
+
/* free constraints for all selected bones */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
@@ -1423,16 +1427,16 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_SPLINEIK | PCHAN_HAS_CONST);
}
CTX_DATA_END;
-
+
/* force depsgraph to get recalculated since relationships removed */
DEG_relations_tag_update(bmain);
-
+
/* note, calling BIK_clear_data() isn't needed here */
/* do updates */
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1442,7 +1446,7 @@ void POSE_OT_constraints_clear(wmOperatorType *ot)
ot->name = "Clear Pose Constraints";
ot->idname = "POSE_OT_constraints_clear";
ot->description = "Clear all the constraints for the selected bones";
-
+
/* callbacks */
ot->exec = pose_constraints_clear_exec;
ot->poll = ED_operator_posemode_exclusive; // XXX - do we want to ensure there are selected bones too?
@@ -1452,7 +1456,7 @@ void POSE_OT_constraints_clear(wmOperatorType *ot)
static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
-
+
/* do freeing */
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
@@ -1460,13 +1464,13 @@ static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, OB_RECALC_OB);
}
CTX_DATA_END;
-
+
/* force depsgraph to get recalculated since relationships removed */
DEG_relations_tag_update(bmain);
-
+
/* do updates */
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1476,7 +1480,7 @@ void OBJECT_OT_constraints_clear(wmOperatorType *ot)
ot->name = "Clear Object Constraints";
ot->idname = "OBJECT_OT_constraints_clear";
ot->description = "Clear all the constraints for the active Object only";
-
+
/* callbacks */
ot->exec = object_constraints_clear_exec;
ot->poll = ED_operator_object_active_editable;
@@ -1490,19 +1494,19 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op)
bPoseChannel *pchan = CTX_data_active_pose_bone(C);
ListBase lb;
CollectionPointerLink *link;
-
+
/* don't do anything if bone doesn't exist or doesn't have any constraints */
if (ELEM(NULL, pchan, pchan->constraints.first)) {
BKE_report(op->reports, RPT_ERROR, "No active bone with constraints for copying");
return OPERATOR_CANCELLED;
}
-
+
/* copy all constraints from active posebone to all selected posebones */
CTX_data_selected_pose_bones(C, &lb);
for (link = lb.first; link; link = link->next) {
Object *ob = link->ptr.id.data;
bPoseChannel *chan = link->ptr.data;
-
+
/* if we're not handling the object we're copying from, copy all constraints over */
if (pchan != chan) {
BKE_constraints_copy(&chan->constraints, &pchan->constraints, true);
@@ -1514,12 +1518,12 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op)
}
}
BLI_freelistN(&lb);
-
+
/* force depsgraph to get recalculated since new relationships added */
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1529,7 +1533,7 @@ void POSE_OT_constraints_copy(wmOperatorType *ot)
ot->name = "Copy Constraints to Selected Bones";
ot->idname = "POSE_OT_constraints_copy";
ot->description = "Copy constraints to other selected bones";
-
+
/* api callbacks */
ot->exec = pose_constraint_copy_exec;
ot->poll = ED_operator_posemode_exclusive;
@@ -1542,7 +1546,7 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
Object *obact = ED_object_active_context(C);
-
+
/* copy all constraints from active object to all selected objects */
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
@@ -1553,13 +1557,13 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op))
}
}
CTX_DATA_END;
-
+
/* force depsgraph to get recalculated since new relationships added */
DEG_relations_tag_update(bmain);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1569,7 +1573,7 @@ void OBJECT_OT_constraints_copy(wmOperatorType *ot)
ot->name = "Copy Constraints to Selected Objects";
ot->idname = "OBJECT_OT_constraints_copy";
ot->description = "Copy constraints to other selected objects";
-
+
/* api callbacks */
ot->exec = object_constraint_copy_exec;
ot->poll = ED_operator_object_active_editable;
@@ -1587,15 +1591,15 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob
bPoseChannel *pchanact = BKE_pose_channel_active(obact);
bool only_curve = false, only_mesh = false, only_ob = false;
bool found = false;
-
- /* clear tar_ob and tar_pchan fields before use
+
+ /* clear tar_ob and tar_pchan fields before use
* - assume for now that both always exist...
*/
*tar_ob = NULL;
*tar_pchan = NULL;
-
+
/* check if constraint type doesn't requires a target
- * - if so, no need to get any targets
+ * - if so, no need to get any targets
*/
switch (con_type) {
/* no-target constraints --------------------------- */
@@ -1607,7 +1611,7 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob
case CONSTRAINT_TYPE_SIZELIMIT:
case CONSTRAINT_TYPE_SAMEVOL:
return false;
-
+
/* restricted target-type constraints -------------- */
/* NOTE: for these, we cannot try to add a target object if no valid ones are found, since that doesn't work */
/* curve-based constraints - set the only_curve and only_ob flags */
@@ -1618,7 +1622,7 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob
only_ob = true;
add = false;
break;
-
+
/* mesh only? */
case CONSTRAINT_TYPE_SHRINKWRAP:
only_mesh = true;
@@ -1626,7 +1630,7 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob
add = false;
break;
}
-
+
/* if the active Object is Armature, and we can search for bones, do so... */
if ((obact->type == OB_ARMATURE) && (only_ob == false)) {
/* search in list of selected Pose-Channels for target */
@@ -1637,20 +1641,20 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob
*tar_ob = obact;
*tar_pchan = pchan;
found = true;
-
+
break;
}
}
CTX_DATA_END;
}
-
+
/* if not yet found, try selected Objects... */
if (found == false) {
/* search in selected objects context */
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
{
- /* just use the first object we encounter (that isn't the active object)
- * and which fulfills the criteria for the object-target that we've got
+ /* just use the first object we encounter (that isn't the active object)
+ * and which fulfills the criteria for the object-target that we've got
*/
if (ob != obact) {
/* for armatures in pose mode, look inside the armature for the active bone
@@ -1663,7 +1667,7 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob
*tar_ob = ob;
*tar_pchan = BKE_pose_channel_active(ob);
found = true;
-
+
break;
}
else if (((!only_curve) || (ob->type == OB_CURVE)) &&
@@ -1672,21 +1676,21 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob
/* set target */
*tar_ob = ob;
found = true;
-
+
/* perform some special operations on the target */
if (only_curve) {
/* Curve-Path option must be enabled for follow-path constraints to be able to work */
Curve *cu = (Curve *)ob->data;
cu->flag |= CU_PATH;
}
-
+
break;
}
}
}
CTX_DATA_END;
}
-
+
/* if still not found, add a new empty to act as a target (if allowed) */
if ((found == false) && (add)) {
Main *bmain = CTX_data_main(C);
@@ -1694,18 +1698,18 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob
ViewLayer *view_layer = CTX_data_view_layer(C);
Base *base = BASACT(view_layer), *newbase = NULL;
Object *obt;
-
+
/* add new target object */
obt = BKE_object_add(bmain, scene, view_layer, OB_EMPTY, NULL);
-
+
/* set layers OK */
newbase = BASACT(view_layer);
newbase->lay = base->lay;
obt->lay = newbase->lay;
-
+
/* transform cent to global coords for loc */
if (pchanact) {
- /* since by default, IK targets the tip of the last bone, use the tip of the active PoseChannel
+ /* since by default, IK targets the tip of the last bone, use the tip of the active PoseChannel
* if adding a target for an IK Constraint
*/
if (con_type == CONSTRAINT_TYPE_KINEMATIC)
@@ -1720,12 +1724,12 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob
/* restore, BKE_object_add sets active */
BASACT(view_layer) = base;
base->flag |= BASE_SELECTED;
-
+
/* make our new target the new object */
*tar_ob = obt;
found = true;
}
-
+
/* return whether there's any target */
return found;
}
@@ -1736,13 +1740,13 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
Main *bmain = CTX_data_main(C);
bPoseChannel *pchan;
bConstraint *con;
-
+
if (list == &ob->constraints) {
pchan = NULL;
}
else {
pchan = BKE_pose_channel_active(ob);
-
+
/* ensure not to confuse object/pose adding */
if (pchan == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active pose bone to add a constraint to");
@@ -1761,23 +1765,23 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
BKE_report(op->reports, RPT_ERROR, "Spline IK constraint can only be added to bones");
return OPERATOR_CANCELLED;
}
-
+
/* create a new constraint of the type requried, and add it to the active/given constraints list */
if (pchan)
con = BKE_constraint_add_for_pose(ob, pchan, NULL, type);
else
con = BKE_constraint_add_for_object(ob, NULL, type);
-
+
/* get the first selected object/bone, and make that the target
* - apart from the buttons-window add buttons, we shouldn't add in this way
*/
if (setTarget) {
Object *tar_ob = NULL;
bPoseChannel *tar_pchan = NULL;
-
+
/* get the target objects, adding them as need be */
if (get_new_constraint_target(C, type, &tar_ob, &tar_pchan, 1)) {
- /* method of setting target depends on the type of target we've got
+ /* method of setting target depends on the type of target we've got
* - by default, just set the first target (distinction here is only for multiple-targeted constraints)
*/
if (tar_pchan)
@@ -1786,7 +1790,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
set_constraint_nth_target(con, tar_ob, "", 0);
}
}
-
+
/* do type-specific tweaking to the constraint settings */
switch (type) {
case CONSTRAINT_TYPE_PYTHON: /* FIXME: this code is not really valid anymore */
@@ -1795,15 +1799,15 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
char *menustr;
int scriptint = 0;
/* popup a list of usable scripts */
- menustr = buildmenu_pyconstraints(NULL, &scriptint);
+ menustr = buildmenu_pyconstraints(bmain, NULL, &scriptint);
/* XXX scriptint = pupmenu(menustr); */
MEM_freeN(menustr);
/* only add constraint if a script was chosen */
if (scriptint) {
/* add constraint */
- validate_pyconstraint_cb(con->data, &scriptint);
-
+ validate_pyconstraint_cb(bmain, con->data, &scriptint);
+
/* make sure target allowance is set correctly */
BPY_pyconstraint_update(ob, con);
}
@@ -1814,9 +1818,9 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
default:
break;
}
-
+
/* make sure all settings are valid - similar to above checks, but sometimes can be wrong */
- object_test_constraints(ob);
+ object_test_constraints(bmain, ob);
if (pchan)
BKE_pose_update_constraint_flags(ob->pose);
@@ -1824,7 +1828,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
/* force depsgraph to get recalculated since new relationships added */
DEG_relations_tag_update(bmain);
-
+
if ((ob->type == OB_ARMATURE) && (pchan)) {
BKE_pose_tag_recalc(bmain, ob->pose); /* sort pose channels */
if (BKE_constraints_proxylocked_owner(ob, pchan) && ob->adt) {
@@ -1837,10 +1841,10 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
}
else
DEG_id_tag_update(&ob->id, OB_RECALC_OB);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1852,12 +1856,12 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
int type = RNA_enum_get(op->ptr, "type");
short with_targets = 0;
-
+
if (!ob) {
BKE_report(op->reports, RPT_ERROR, "No active object to add constraint to");
return OPERATOR_CANCELLED;
}
-
+
/* hack: set constraint targets from selected objects in context is allowed when
* operator name included 'with_targets', since the menu doesn't allow multiple properties
*/
@@ -1873,18 +1877,18 @@ static int pose_constraint_add_exec(bContext *C, wmOperator *op)
Object *ob = BKE_object_pose_armature_get(ED_object_active_context(C));
int type = RNA_enum_get(op->ptr, "type");
short with_targets = 0;
-
+
if (!ob) {
BKE_report(op->reports, RPT_ERROR, "No active object to add constraint to");
return OPERATOR_CANCELLED;
}
-
+
/* hack: set constraint targets from selected objects in context is allowed when
* operator name included 'with_targets', since the menu doesn't allow multiple properties
*/
if (strstr(op->idname, "with_targets"))
with_targets = 1;
-
+
return constraint_add_exec(C, op, ob, get_active_constraints(ob), type, with_targets);
}
@@ -1896,15 +1900,15 @@ void OBJECT_OT_constraint_add(wmOperatorType *ot)
ot->name = "Add Constraint";
ot->description = "Add a constraint to the active object";
ot->idname = "OBJECT_OT_constraint_add";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = object_constraint_add_exec;
ot->poll = ED_operator_object_active_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", "");
}
@@ -1915,15 +1919,15 @@ void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot)
ot->name = "Add Constraint (with Targets)";
ot->description = "Add a constraint to the active object, with target (where applicable) set to the selected Objects/Bones";
ot->idname = "OBJECT_OT_constraint_add_with_targets";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = object_constraint_add_exec;
ot->poll = ED_operator_object_active_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", "");
}
@@ -1934,15 +1938,15 @@ void POSE_OT_constraint_add(wmOperatorType *ot)
ot->name = "Add Constraint";
ot->description = "Add a constraint to the active bone";
ot->idname = "POSE_OT_constraint_add";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = pose_constraint_add_exec;
ot->poll = ED_operator_posemode_exclusive;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", "");
}
@@ -1953,15 +1957,15 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot)
ot->name = "Add Constraint (with Targets)";
ot->description = "Add a constraint to the active bone, with target (where applicable) set to the selected Objects/Bones";
ot->idname = "POSE_OT_constraint_add_with_targets";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = pose_constraint_add_exec;
ot->poll = ED_operator_posemode_exclusive;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", "");
}
@@ -1976,18 +1980,18 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
bPoseChannel *pchan = BKE_pose_channel_active(ob);
bConstraint *con = NULL;
-
+
uiPopupMenu *pup;
uiLayout *layout;
Object *tar_ob = NULL;
bPoseChannel *tar_pchan = NULL;
-
+
/* must have active bone */
if (ELEM(NULL, ob, pchan)) {
BKE_report(op->reports, RPT_ERROR, "Must have an active bone to add IK constraint to");
return OPERATOR_CANCELLED;
}
-
+
/* bone must not have any constraints already */
for (con = pchan->constraints.first; con; con = con->next) {
if (con->type == CONSTRAINT_TYPE_KINEMATIC) break;
@@ -1996,14 +2000,14 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED
BKE_report(op->reports, RPT_ERROR, "Bone already has an IK constraint");
return OPERATOR_CANCELLED;
}
-
+
/* prepare popup menu to choose targetting options */
pup = UI_popup_menu_begin(C, IFACE_("Add IK"), ICON_NONE);
layout = UI_popup_menu_layout(pup);
-
+
/* the type of targets we'll set determines the menu entries to show... */
if (get_new_constraint_target(C, CONSTRAINT_TYPE_KINEMATIC, &tar_ob, &tar_pchan, 0)) {
- /* bone target, or object target?
+ /* bone target, or object target?
* - the only thing that matters is that we want a target...
*/
if (tar_pchan)
@@ -2016,10 +2020,10 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED
uiItemBooleanO(layout, IFACE_("To New Empty Object"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 1);
uiItemBooleanO(layout, IFACE_("Without Targets"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 0);
}
-
+
/* finish building the menu, and process it (should result in calling self again) */
UI_popup_menu_end(C, pup);
-
+
return OPERATOR_INTERFACE;
}
@@ -2028,7 +2032,7 @@ static int pose_ik_add_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
const bool with_targets = RNA_boolean_get(op->ptr, "with_targets");
-
+
/* add the constraint - all necessary checks should have been done by the invoke() callback already... */
return constraint_add_exec(C, op, ob, get_active_constraints(ob), CONSTRAINT_TYPE_KINEMATIC, with_targets);
}
@@ -2039,15 +2043,15 @@ void POSE_OT_ik_add(wmOperatorType *ot)
ot->name = "Add IK to Bone";
ot->description = "Add IK Constraint to the active Bone";
ot->idname = "POSE_OT_ik_add";
-
+
/* api callbacks */
ot->invoke = pose_ik_add_invoke;
ot->exec = pose_ik_add_exec;
ot->poll = ED_operator_posemode_exclusive;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "with_targets", 1, "With Targets", "Assign IK Constraint with targets derived from the select bones/objects");
}
@@ -2058,12 +2062,12 @@ void POSE_OT_ik_add(wmOperatorType *ot)
static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
+
/* only remove IK Constraints */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
bConstraint *con, *next;
-
+
/* TODO: should we be checking if these contraints were local before we try and remove them? */
for (con = pchan->constraints.first; con; con = next) {
next = con->next;
@@ -2074,13 +2078,13 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op))
pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_TARGET);
}
CTX_DATA_END;
-
+
/* refresh depsgraph */
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -2090,11 +2094,11 @@ void POSE_OT_ik_clear(wmOperatorType *ot)
ot->name = "Remove IK";
ot->description = "Remove all IK Constraints from selected bones";
ot->idname = "POSE_OT_ik_clear";
-
+
/* api callbacks */
ot->exec = pose_ik_clear_exec;
ot->poll = ED_operator_posemode_exclusive;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c
index d4e8955b38e..db81c51cc90 100644
--- a/source/blender/editors/object/object_data_transfer.c
+++ b/source/blender/editors/object/object_data_transfer.c
@@ -43,6 +43,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_mesh_remap.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_object.h"
#include "BKE_report.h"
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 7a4898ec287..b7f59285186 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -96,6 +96,7 @@
#include "ED_mball.h"
#include "ED_lattice.h"
#include "ED_object.h"
+#include "ED_outliner.h"
#include "ED_screen.h"
#include "ED_undo.h"
#include "ED_image.h"
@@ -148,13 +149,13 @@ Object *ED_object_active_context(bContext *C)
/* ******************* toggle editmode operator ***************** */
-static bool mesh_needs_keyindex(const Mesh *me)
+static bool mesh_needs_keyindex(Main *bmain, const Mesh *me)
{
if (me->key) {
return false; /* will be added */
}
- for (const Object *ob = G.main->object.first; ob; ob = ob->id.next) {
+ for (const Object *ob = bmain->object.first; ob; ob = ob->id.next) {
if ((ob->parent) && (ob->parent->data == me) && ELEM(ob->partype, PARVERT1, PARVERT3)) {
return true;
}
@@ -208,7 +209,7 @@ static bool ED_object_editmode_load_ex(Main *bmain, Object *obedit, const bool f
if (arm->edbo == NULL) {
return false;
}
- ED_armature_from_edit(obedit->data);
+ ED_armature_from_edit(bmain, obedit->data);
if (freedata) {
ED_armature_edit_free(obedit->data);
}
@@ -223,7 +224,7 @@ static bool ED_object_editmode_load_ex(Main *bmain, Object *obedit, const bool f
if (cu->editnurb == NULL) {
return false;
}
- ED_curve_editnurb_load(obedit);
+ ED_curve_editnurb_load(bmain, obedit);
if (freedata) {
ED_curve_editnurb_free(obedit);
}
@@ -262,30 +263,29 @@ static bool ED_object_editmode_load_ex(Main *bmain, Object *obedit, const bool f
return true;
}
-bool ED_object_editmode_load(Object *obedit)
+bool ED_object_editmode_load(Main *bmain, Object *obedit)
{
- /* TODO(sergey): use proper main here? */
- return ED_object_editmode_load_ex(G.main, obedit, false);
+ return ED_object_editmode_load_ex(bmain, obedit, false);
}
/**
* \param flag:
* - If #EM_FREEDATA isn't in the flag, use ED_object_editmode_load directly.
*/
-void ED_object_editmode_exit_ex(Scene *scene, Object *obedit, int flag)
+bool ED_object_editmode_exit_ex(Main *bmain, Scene *scene, Object *obedit, int flag)
{
const bool freedata = (flag & EM_FREEDATA) != 0;
if (flag & EM_WAITCURSOR) waitcursor(1);
- if (ED_object_editmode_load_ex(G.main, obedit, freedata) == false) {
+ if (ED_object_editmode_load_ex(bmain, obedit, freedata) == false) {
/* in rare cases (background mode) its possible active object
* is flagged for editmode, without 'obedit' being set [#35489] */
if (UNLIKELY(obedit && obedit->mode & OB_MODE_EDIT)) {
obedit->mode &= ~OB_MODE_EDIT;
}
if (flag & EM_WAITCURSOR) waitcursor(0);
- return;
+ return true;
}
/* freedata only 0 now on file saves and render */
@@ -300,7 +300,7 @@ void ED_object_editmode_exit_ex(Scene *scene, Object *obedit, int flag)
pid->cache->flag |= PTCACHE_OUTDATED;
}
BLI_freelistN(&pidlist);
-
+
BKE_ptcache_object_reset(scene, obedit, PTCACHE_RESET_OUTDATED);
/* also flush ob recalc, doesn't take much overhead, but used for particles */
@@ -308,34 +308,38 @@ void ED_object_editmode_exit_ex(Scene *scene, Object *obedit, int flag)
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
-
obedit->mode &= ~OB_MODE_EDIT;
}
if (flag & EM_WAITCURSOR) waitcursor(0);
+
+ return (obedit->mode & OB_MODE_EDIT) == 0;
}
-void ED_object_editmode_exit(bContext *C, int flag)
+bool ED_object_editmode_exit(bContext *C, int flag)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
- ED_object_editmode_exit_ex(scene, obedit, flag);
+ return ED_object_editmode_exit_ex(bmain, scene, obedit, flag);
}
-void ED_object_editmode_enter_ex(Scene *scene, Object *ob, int flag)
+bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag)
{
bool ok = false;
- if (ELEM(NULL, ob, ob->data)) return;
- if (ID_IS_LINKED(ob)) return;
+ if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED(ob)) {
+ return false;
+ }
/* this checks actual object->data, for cases when other scenes have it in editmode context */
- if (BKE_object_is_in_editmode(ob))
- return;
-
+ if (BKE_object_is_in_editmode(ob)) {
+ return true;
+ }
+
if (BKE_object_obdata_is_libdata(ob)) {
error_libdata();
- return;
+ return false;
}
if (flag & EM_WAITCURSOR) waitcursor(1);
@@ -347,7 +351,8 @@ void ED_object_editmode_enter_ex(Scene *scene, Object *ob, int flag)
if (ob->type == OB_MESH) {
BMEditMesh *em;
ok = 1;
- const bool use_key_index = mesh_needs_keyindex(ob->data);
+
+ const bool use_key_index = mesh_needs_keyindex(bmain, ob->data);
EDBM_mesh_make(ob, scene->toolsettings->selectmode, use_key_index);
@@ -361,22 +366,8 @@ void ED_object_editmode_enter_ex(Scene *scene, Object *ob, int flag)
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_MESH, NULL);
}
else if (ob->type == OB_ARMATURE) {
- bArmature *arm = ob->data;
- if (!arm) return;
- /*
- * The function BKE_object_obdata_is_libdata make a problem here, the
- * check for ob->proxy return 0 and let blender enter to edit mode
- * this causes a crash when you try leave the edit mode.
- * The problem is that i can't remove the ob->proxy check from
- * BKE_object_obdata_is_libdata that prevent the bugfix #6614, so
- * i add this little hack here.
- */
- if (ID_IS_LINKED(arm)) {
- error_libdata();
- return;
- }
ok = 1;
- ED_armature_to_edit(arm);
+ ED_armature_to_edit(ob->data);
/* to ensure all goes in restposition and without striding */
DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); /* XXX: should this be OB_RECALC_DATA? */
@@ -418,10 +409,13 @@ void ED_object_editmode_enter_ex(Scene *scene, Object *ob, int flag)
}
if (flag & EM_WAITCURSOR) waitcursor(0);
+
+ return (ob->mode & OB_MODE_EDIT) != 0;
}
-void ED_object_editmode_enter(bContext *C, int flag)
+bool ED_object_editmode_enter(bContext *C, int flag)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob;
@@ -432,10 +426,10 @@ void ED_object_editmode_enter(bContext *C, int flag)
else {
ob = view_layer->basact->object;
}
- if (ob == NULL) return;
- if (ID_IS_LINKED(ob)) return;
-
- ED_object_editmode_enter_ex(scene, ob, flag);
+ if ((ob == NULL) || ID_IS_LINKED(ob)) {
+ return false;
+ }
+ return ED_object_editmode_enter_ex(bmain, scene, ob, flag);
}
static int editmode_toggle_exec(bContext *C, wmOperator *op)
@@ -443,6 +437,7 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op)
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
const int mode_flag = OB_MODE_EDIT;
const bool is_mode_set = (CTX_data_edit_object(C) != NULL);
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *obact = OBACT(view_layer);
@@ -459,7 +454,7 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op)
FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob)
{
if ((ob != obact) && (ob->type == obact->type)) {
- ED_object_editmode_enter_ex(scene, ob, EM_WAITCURSOR | EM_NO_CONTEXT);
+ ED_object_editmode_enter_ex(bmain, scene, ob, EM_WAITCURSOR | EM_NO_CONTEXT);
}
}
FOREACH_SELECTED_OBJECT_END;
@@ -468,17 +463,17 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op)
else {
ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR);
if ((obact->mode & mode_flag) == 0) {
- FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob)
+ FOREACH_OBJECT_BEGIN(view_layer, ob)
{
if ((ob != obact) && (ob->type == obact->type)) {
- ED_object_editmode_exit_ex(scene, ob, EM_FREEDATA | EM_WAITCURSOR);
+ ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA | EM_WAITCURSOR);
}
}
- FOREACH_SELECTED_OBJECT_END;
+ FOREACH_OBJECT_END;
}
}
-
- ED_space_image_uv_sculpt_update(CTX_wm_manager(C), scene);
+
+ ED_space_image_uv_sculpt_update(bmain, CTX_wm_manager(C), scene);
WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode);
@@ -505,16 +500,16 @@ static int editmode_toggle_poll(bContext *C)
void OBJECT_OT_editmode_toggle(wmOperatorType *ot)
{
-
+
/* identifiers */
ot->name = "Toggle Editmode";
ot->description = "Toggle object's editmode";
ot->idname = "OBJECT_OT_editmode_toggle";
-
+
/* api callbacks */
ot->exec = editmode_toggle_exec;
ot->poll = editmode_toggle_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -528,7 +523,7 @@ static int posemode_exec(bContext *C, wmOperator *op)
Object *obact = base->object;
const int mode_flag = OB_MODE_POSE;
bool is_mode_set = (obact->mode & mode_flag) != 0;
-
+
if (!is_mode_set) {
if (!ED_object_mode_compat_set(C, obact, mode_flag, op->reports)) {
return OPERATOR_CANCELLED;
@@ -549,7 +544,7 @@ static int posemode_exec(bContext *C, wmOperator *op)
if (ok) {
struct Main *bmain = CTX_data_main(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob)
+ FOREACH_OBJECT_BEGIN(view_layer, ob)
{
if ((ob != obact) &&
(ob->type == OB_ARMATURE) &&
@@ -558,7 +553,7 @@ static int posemode_exec(bContext *C, wmOperator *op)
ED_object_posemode_exit_ex(bmain, ob);
}
}
- FOREACH_SELECTED_OBJECT_END;
+ FOREACH_OBJECT_END;
}
}
else {
@@ -587,17 +582,17 @@ static int posemode_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-void OBJECT_OT_posemode_toggle(wmOperatorType *ot)
+void OBJECT_OT_posemode_toggle(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Toggle Pose Mode";
ot->idname = "OBJECT_OT_posemode_toggle";
ot->description = "Enable or disable posing/selecting bones";
-
+
/* api callbacks */
ot->exec = posemode_exec;
ot->poll = ED_operator_object_active_editable;
-
+
/* flag */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -607,7 +602,7 @@ static void copy_texture_space(Object *to, Object *ob)
{
float *poin1 = NULL, *poin2 = NULL;
short texflag = 0;
-
+
if (ob->type == OB_MESH) {
texflag = ((Mesh *)ob->data)->texflag;
poin2 = ((Mesh *)ob->data)->loc;
@@ -622,7 +617,7 @@ static void copy_texture_space(Object *to, Object *ob)
}
else
return;
-
+
if (to->type == OB_MESH) {
((Mesh *)to->data)->texflag = texflag;
poin1 = ((Mesh *)to->data)->loc;
@@ -637,9 +632,9 @@ static void copy_texture_space(Object *to, Object *ob)
}
else
return;
-
+
memcpy(poin1, poin2, 9 * sizeof(float)); /* this was noted in DNA_mesh, curve, mball */
-
+
if (to->type == OB_MESH) {
/* pass */
}
@@ -649,7 +644,7 @@ static void copy_texture_space(Object *to, Object *ob)
else {
BKE_curve_texspace_calc(to->data);
}
-
+
}
/* UNUSED, keep in case we want to copy functionality for use elsewhere */
@@ -660,11 +655,11 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
Curve *cu, *cu1;
Nurb *nu;
bool do_depgraph_update = false;
-
+
if (ID_IS_LINKED(scene)) return;
if (!(ob = OBACT(view_layer))) return;
-
+
if (BKE_object_is_in_editmode(ob)) {
/* obedit_copymenu(); */
return;
@@ -680,7 +675,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
if (base != BASACT(view_layer)) {
if (TESTBASELIB(base)) {
DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
-
+
if (event == 1) { /* loc */
copy_v3_v3(base->object->loc, ob->loc);
copy_v3_v3(base->object->dloc, ob->dloc);
@@ -710,7 +705,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
base->object->dupoff = ob->dupoff;
base->object->dupsta = ob->dupsta;
base->object->dupend = ob->dupend;
-
+
base->object->transflag &= ~OB_DUPLI;
base->object->transflag |= (ob->transflag & OB_DUPLI);
@@ -722,7 +717,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
copy_texture_space(base->object, ob);
}
else if (event == 18) { /* font settings */
-
+
if (base->object->type == ob->type) {
cu = ob->data;
cu1 = base->object->data;
@@ -755,25 +750,25 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
id_us_min(&cu1->vfontbi->id);
cu1->vfontbi = cu->vfontbi;
id_us_plus((ID *)cu1->vfontbi);
-
+
BLI_strncpy(cu1->family, cu->family, sizeof(cu1->family));
-
+
DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
}
}
else if (event == 19) { /* bevel settings */
-
+
if (ELEM(base->object->type, OB_CURVE, OB_FONT)) {
cu = ob->data;
cu1 = base->object->data;
-
+
cu1->bevobj = cu->bevobj;
cu1->taperobj = cu->taperobj;
cu1->width = cu->width;
cu1->bevresol = cu->bevresol;
cu1->ext1 = cu->ext1;
cu1->ext2 = cu->ext2;
-
+
DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
}
}
@@ -782,17 +777,17 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
if (ELEM(base->object->type, OB_CURVE, OB_FONT)) {
cu = ob->data;
cu1 = base->object->data;
-
+
cu1->resolu = cu->resolu;
cu1->resolu_ren = cu->resolu_ren;
-
+
nu = cu1->nurb.first;
-
+
while (nu) {
nu->resolu = cu1->resolu;
nu = nu->next;
}
-
+
DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
}
}
@@ -816,13 +811,13 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
else if (event == 22) {
/* Copy the constraint channels over */
BKE_constraints_copy(&base->object->constraints, &ob->constraints, true);
-
+
do_depgraph_update = true;
}
else if (event == 23) {
base->object->softflag = ob->softflag;
if (base->object->soft) sbFree(base->object->soft);
-
+
base->object->soft = copy_softbody(ob->soft, 0);
if (!modifiers_findByType(base->object, eModifierType_Softbody)) {
@@ -849,7 +844,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
if (ELEM(base->object->type, OB_CURVE, OB_SURF)) {
cu = ob->data;
cu1 = base->object->data;
-
+
if (cu->flag & CU_UV_ORCO)
cu1->flag |= CU_UV_ORCO;
else
@@ -868,7 +863,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
}
}
}
-
+
if (do_depgraph_update)
DEG_relations_tag_update(bmain);
}
@@ -878,36 +873,36 @@ static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, ViewLaye
Object *ob;
short event;
char str[512];
-
+
if (!(ob = OBACT(view_layer))) return;
-
+
if (obedit) {
/* if (ob->type == OB_MESH) */
/* XXX mesh_copy_menu(); */
return;
}
-
+
/* Object Mode */
-
+
/* If you change this menu, don't forget to update the menu in header_view3d.c
* view3d_edit_object_copyattrmenu() and in toolbox.c
*/
-
+
strcpy(str,
"Copy Attributes %t|Location %x1|Rotation %x2|Size %x3|Draw Options %x4|"
"Time Offset %x5|Dupli %x6|Object Color %x31|%l|Mass %x7|Damping %x8|All Physical Attributes %x11|Properties %x9|"
"Logic Bricks %x10|Protected Transform %x29|%l");
-
+
strcat(str, "|Object Constraints %x22");
strcat(str, "|NLA Strips %x26");
-
+
/* XXX if (OB_TYPE_SUPPORT_MATERIAL(ob->type)) { */
/* strcat(str, "|Texture Space %x17"); */
/* } */
-
+
if (ob->type == OB_FONT) strcat(str, "|Font Settings %x18|Bevel Settings %x19");
if (ob->type == OB_CURVE) strcat(str, "|Bevel Settings %x19|UV Orco %x28");
-
+
if ((ob->type == OB_FONT) || (ob->type == OB_CURVE)) {
strcat(str, "|Curve Resolution %x25");
}
@@ -917,16 +912,16 @@ static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, ViewLaye
}
if (ob->soft) strcat(str, "|Soft Body Settings %x23");
-
+
strcat(str, "|Pass Index %x30");
-
+
if (ob->type == OB_MESH || ob->type == OB_CURVE || ob->type == OB_LATTICE || ob->type == OB_SURF) {
strcat(str, "|Modifiers ... %x24");
}
event = pupmenu(str);
if (event <= 0) return;
-
+
copy_attr(bmain, scene, view_layer, event);
}
@@ -972,16 +967,16 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_forcefield_toggle(wmOperatorType *ot)
{
-
+
/* identifiers */
ot->name = "Toggle Force Field";
ot->description = "Toggle object's force field";
ot->idname = "OBJECT_OT_forcefield_toggle";
-
+
/* api callbacks */
ot->exec = forcefield_toggle_exec;
ot->poll = ED_operator_object_active_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -992,14 +987,14 @@ void OBJECT_OT_forcefield_toggle(wmOperatorType *ot)
/* For the objects with animation: update paths for those that have got them
* This should selectively update paths that exist...
*
- * To be called from various tools that do incremental updates
+ * To be called from various tools that do incremental updates
*/
void ED_objects_recalculate_paths(bContext *C, Scene *scene)
{
struct Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
ListBase targets = {NULL, NULL};
-
+
/* loop over objects in scene */
CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
{
@@ -1008,10 +1003,19 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene)
animviz_get_object_motionpaths(ob, &targets);
}
CTX_DATA_END;
-
+
/* recalculate paths, then free */
animviz_calc_motionpaths(depsgraph, bmain, scene, &targets);
BLI_freelistN(&targets);
+
+ /* tag objects for copy on write - so paths will draw/redraw */
+ CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
+ {
+ if (ob->mpath) {
+ DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ }
+ }
+ CTX_DATA_END;
}
@@ -1019,18 +1023,18 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene)
static int object_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
Object *ob = CTX_data_active_object(C);
-
+
if (ob == NULL)
return OPERATOR_CANCELLED;
-
+
/* set default settings from existing/stored settings */
{
bAnimVizSettings *avs = &ob->avs;
-
+
RNA_int_set(op->ptr, "start_frame", avs->path_sf);
RNA_int_set(op->ptr, "end_frame", avs->path_ef);
}
-
+
/* show popup dialog to allow editing of range... */
/* FIXME: hardcoded dimensions here are just arbitrary */
return WM_operator_props_dialog_popup(C, op, 10 * UI_UNIT_X, 10 * UI_UNIT_Y);
@@ -1042,28 +1046,28 @@ static int object_calculate_paths_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
int start = RNA_int_get(op->ptr, "start_frame");
int end = RNA_int_get(op->ptr, "end_frame");
-
+
/* set up path data for bones being calculated */
CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
{
bAnimVizSettings *avs = &ob->avs;
-
+
/* grab baking settings from operator settings */
avs->path_sf = start;
avs->path_ef = end;
-
+
/* verify that the selected object has the appropriate settings */
animviz_verify_motionpaths(op->reports, scene, ob, NULL);
}
CTX_DATA_END;
-
+
/* calculate the paths for objects that have them (and are tagged to get refreshed) */
ED_objects_recalculate_paths(C, scene);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
-
- return OPERATOR_FINISHED;
+
+ return OPERATOR_FINISHED;
}
void OBJECT_OT_paths_calculate(wmOperatorType *ot)
@@ -1072,19 +1076,19 @@ void OBJECT_OT_paths_calculate(wmOperatorType *ot)
ot->name = "Calculate Object Paths";
ot->idname = "OBJECT_OT_paths_calculate";
ot->description = "Calculate motion paths for the selected objects";
-
+
/* api callbacks */
ot->invoke = object_calculate_paths_invoke;
ot->exec = object_calculate_paths_exec;
ot->poll = ED_operator_object_active_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
- RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start",
+ RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start",
"First frame to calculate object paths on", MINFRAME, MAXFRAME / 2.0);
- RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End",
+ RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End",
"Last frame to calculate object paths on", MINFRAME, MAXFRAME / 2.0);
}
@@ -1096,23 +1100,23 @@ static int object_update_paths_poll(bContext *C)
Object *ob = ED_object_active_context(C);
return (ob->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) != 0;
}
-
+
return false;
}
static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
-
+
if (scene == NULL)
return OPERATOR_CANCELLED;
-
+
/* calculate the paths for objects that have them (and are tagged to get refreshed) */
ED_objects_recalculate_paths(C, scene);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1122,11 +1126,11 @@ void OBJECT_OT_paths_update(wmOperatorType *ot)
ot->name = "Update Object Paths";
ot->idname = "OBJECT_OT_paths_update";
ot->description = "Recalculate paths for selected objects";
-
+
/* api callbakcs */
ot->exec = object_update_paths_exec;
ot->poll = object_update_paths_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1168,14 +1172,14 @@ void ED_objects_clear_paths(bContext *C, bool only_selected)
static int object_clear_paths_exec(bContext *C, wmOperator *op)
{
bool only_selected = RNA_boolean_get(op->ptr, "only_selected");
-
+
/* use the backend function for this */
ED_objects_clear_paths(C, only_selected);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
-
- return OPERATOR_FINISHED;
+
+ return OPERATOR_FINISHED;
}
/* operator callback/wrapper */
@@ -1193,15 +1197,15 @@ void OBJECT_OT_paths_clear(wmOperatorType *ot)
ot->name = "Clear Object Paths";
ot->idname = "OBJECT_OT_paths_clear";
ot->description = "Clear path caches for all objects, hold Shift key for selected objects only";
-
+
/* api callbacks */
ot->invoke = object_clear_paths_invoke;
ot->exec = object_clear_paths_exec;
ot->poll = ED_operator_object_active_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected",
"Only clear paths from selected objects");
@@ -1270,7 +1274,7 @@ void OBJECT_OT_shade_flat(wmOperatorType *ot)
ot->name = "Shade Flat";
ot->description = "Render and display faces uniform, using Face Normals";
ot->idname = "OBJECT_OT_shade_flat";
-
+
/* api callbacks */
ot->poll = shade_poll;
ot->exec = shade_smooth_exec;
@@ -1285,11 +1289,11 @@ void OBJECT_OT_shade_smooth(wmOperatorType *ot)
ot->name = "Shade Smooth";
ot->description = "Render and display faces smooth, using interpolated Vertex Normals";
ot->idname = "OBJECT_OT_shade_smooth";
-
+
/* api callbacks */
ot->poll = shade_poll;
ot->exec = shade_smooth_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1330,7 +1334,7 @@ static const EnumPropertyItem *object_mode_set_itemsf(
/* We need at least this one! */
RNA_enum_items_add_value(&item, &totitem, input, OB_MODE_OBJECT);
}
-
+
/* On top of all the rest, GPencil Stroke Edit Mode
* is available if there's a valid gp datablock...
*/
@@ -1361,12 +1365,28 @@ static int object_mode_set_poll(bContext *C)
static int object_mode_set_exec(bContext *C, wmOperator *op)
{
+ bool use_submode = STREQ(op->idname, "OBJECT_OT_mode_set_or_submode");
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = CTX_data_gpencil_data(C);
eObjectMode mode = RNA_enum_get(op->ptr, "mode");
eObjectMode restore_mode = (ob) ? ob->mode : OB_MODE_OBJECT;
const bool toggle = RNA_boolean_get(op->ptr, "toggle");
-
+
+ if (use_submode) {
+ /* When not changing modes use submodes, see: T55162. */
+ if (toggle == false) {
+ if (mode == restore_mode) {
+ switch (mode) {
+ case OB_MODE_EDIT:
+ WM_menu_name_call(C, "VIEW3D_MT_edit_mesh_select_mode", WM_OP_INVOKE_REGION_WIN);
+ return OPERATOR_INTERFACE;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
if (gpd) {
/* GP Mode is not bound to a specific object. Therefore,
* we don't want it to be actually saved on any objects,
@@ -1384,7 +1404,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
WM_operator_name_call(C, "GPENCIL_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
}
}
-
+
if (!ob || !ED_object_mode_compat_test(ob, mode))
return OPERATOR_PASS_THROUGH;
@@ -1419,20 +1439,45 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
void OBJECT_OT_mode_set(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Set Object Mode";
ot->description = "Sets the object interaction mode";
ot->idname = "OBJECT_OT_mode_set";
-
+
+ /* api callbacks */
+ ot->exec = object_mode_set_exec;
+
+ ot->poll = object_mode_set_poll; //ED_operator_object_active_editable;
+
+ /* flags */
+ ot->flag = 0; /* no register/undo here, leave it to operators being called */
+
+ ot->prop = RNA_def_enum(ot->srna, "mode", rna_enum_object_mode_items, OB_MODE_OBJECT, "Mode", "");
+ RNA_def_enum_funcs(ot->prop, object_mode_set_itemsf);
+ RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
+
+ prop = RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", "");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+}
+
+void OBJECT_OT_mode_set_or_submode(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name = "Set Object Mode or Submode";
+ ot->description = "Sets the object interaction mode";
+ ot->idname = "OBJECT_OT_mode_set_or_submode";
+
/* api callbacks */
ot->exec = object_mode_set_exec;
-
+
ot->poll = object_mode_set_poll; //ED_operator_object_active_editable;
-
+
/* flags */
ot->flag = 0; /* no register/undo here, leave it to operators being called */
-
+
ot->prop = RNA_def_enum(ot->srna, "mode", rna_enum_object_mode_items, OB_MODE_OBJECT, "Mode", "");
RNA_def_enum_funcs(ot->prop, object_mode_set_itemsf);
RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
@@ -1505,6 +1550,16 @@ bool ED_object_editmode_calc_active_center(Object *obedit, const bool select_onl
#define COLLECTION_INVALID_INDEX -1
+static int move_to_collection_poll(bContext *C)
+{
+ if (CTX_wm_space_outliner(C) != NULL) {
+ return ED_outliner_collections_editor_poll(C);
+ }
+ else {
+ return ED_operator_object_active_editable(C);
+ }
+}
+
static int move_to_collection_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
@@ -1513,6 +1568,7 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
const bool is_link = STREQ(op->idname, "OBJECT_OT_link_to_collection");
const bool is_new = RNA_boolean_get(op->ptr, "is_new");
Collection *collection;
+ ListBase objects = {NULL};
if (!RNA_property_is_set(op->ptr, prop)) {
BKE_report(op->reports, RPT_ERROR, "No collection selected");
@@ -1526,18 +1582,16 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- Object *single_object = NULL;
- CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
- {
- if (single_object != NULL) {
- single_object = NULL;
- break;
- }
- else {
- single_object = ob;
+ if (CTX_wm_space_outliner(C) != NULL) {
+ ED_outliner_selected_objects_get(C, &objects);
+ }
+ else {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
+ {
+ BLI_addtail(&objects, BLI_genericNodeN(ob));
}
+ CTX_DATA_END;
}
- CTX_DATA_END;
if (is_new) {
char new_collection_name[MAX_NAME];
@@ -1545,16 +1599,21 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
collection = BKE_collection_add(bmain, collection, new_collection_name);
}
+ Object *single_object = BLI_listbase_is_single(&objects) ?
+ ((LinkData *)objects.first)->data : NULL;
+
if ((single_object != NULL) &&
is_link &&
BLI_findptr(&collection->gobject, single_object, offsetof(CollectionObject, ob)))
{
BKE_reportf(op->reports, RPT_ERROR, "%s already in %s", single_object->id.name + 2, collection->id.name + 2);
+ BLI_freelistN(&objects);
return OPERATOR_CANCELLED;
}
- CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
- {
+ for (LinkData *link = objects.first; link; link = link->next) {
+ Object *ob = link->data;
+
if (!is_link) {
BKE_collection_object_move(bmain, scene, collection, NULL, ob);
}
@@ -1562,7 +1621,7 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
BKE_collection_object_add(bmain, collection, ob);
}
}
- CTX_DATA_END;
+ BLI_freelistN(&objects);
BKE_reportf(op->reports,
RPT_INFO,
@@ -1769,7 +1828,7 @@ void OBJECT_OT_move_to_collection(wmOperatorType *ot)
/* api callbacks */
ot->exec = move_to_collection_exec;
ot->invoke = move_to_collection_invoke;
- ot->poll = ED_operator_object_active_editable;
+ ot->poll = move_to_collection_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1796,7 +1855,7 @@ void OBJECT_OT_link_to_collection(wmOperatorType *ot)
/* api callbacks */
ot->exec = move_to_collection_exec;
ot->invoke = move_to_collection_invoke;
- ot->poll = ED_operator_object_active_editable;
+ ot->poll = move_to_collection_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c
index 0a6a81d99da..8a52b6c5ef5 100644
--- a/source/blender/editors/object/object_group.c
+++ b/source/blender/editors/object/object_group.c
@@ -182,7 +182,7 @@ void COLLECTION_OT_objects_add_active(wmOperatorType *ot)
ot->name = "Add Selected To Active Collection";
ot->description = "Add the object to an object collection that contains the active object";
ot->idname = "COLLECTION_OT_objects_add_active";
-
+
/* api callbacks */
ot->exec = objects_add_active_exec;
ot->invoke = WM_menu_invoke;
@@ -207,10 +207,10 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
Collection *single_collection = collection_object_active_find_index(bmain, ob, single_collection_index);
Collection *collection;
bool ok = false;
-
+
if (ob == NULL)
return OPERATOR_CANCELLED;
-
+
/* linking to same collection requires its own loop so we can avoid
* looking up the active objects collections each time */
@@ -228,13 +228,13 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
}
}
-
+
if (!ok)
BKE_report(op->reports, RPT_ERROR, "Active object contains no collections");
-
+
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -246,12 +246,12 @@ void COLLECTION_OT_objects_remove_active(wmOperatorType *ot)
ot->name = "Remove Selected From Active Collection";
ot->description = "Remove the object from an object collection that contains the active object";
ot->idname = "COLLECTION_OT_objects_remove_active";
-
+
/* api callbacks */
ot->exec = objects_remove_active_exec;
ot->invoke = WM_menu_invoke;
ot->poll = ED_operator_objectmode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -274,7 +274,7 @@ static int collection_objects_remove_all_exec(bContext *C, wmOperator *UNUSED(op
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -284,11 +284,11 @@ void COLLECTION_OT_objects_remove_all(wmOperatorType *ot)
ot->name = "Remove From All Unlinked Collections";
ot->description = "Remove selected objects from all collections not used in a scene";
ot->idname = "COLLECTION_OT_objects_remove_all";
-
+
/* api callbacks */
ot->exec = collection_objects_remove_all_exec;
ot->poll = ED_operator_objectmode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -357,11 +357,12 @@ static int collection_create_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
char name[MAX_ID_NAME - 2]; /* id name */
-
+
RNA_string_get(op->ptr, "name", name);
-
+
Collection *collection = BKE_collection_add(bmain, NULL, name);
-
+ id_fake_user_set(&collection->id);
+
CTX_DATA_BEGIN (C, Base *, base, selected_bases)
{
BKE_collection_object_add(bmain, collection, base->object);
@@ -370,7 +371,7 @@ static int collection_create_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -380,14 +381,14 @@ void COLLECTION_OT_create(wmOperatorType *ot)
ot->name = "Create New Collection";
ot->description = "Create an object collection from selected objects";
ot->idname = "COLLECTION_OT_create";
-
+
/* api callbacks */
ot->exec = collection_create_exec;
ot->poll = ED_operator_objectmode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_string(ot->srna, "name", "Collection", MAX_ID_NAME - 2, "Name", "Name of the new collection");
}
@@ -402,6 +403,7 @@ static int collection_add_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
Collection *collection = BKE_collection_add(bmain, NULL, "Collection");
+ id_fake_user_set(&collection->id);
BKE_collection_object_add(bmain, collection, ob);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -415,7 +417,7 @@ void OBJECT_OT_collection_add(wmOperatorType *ot)
ot->name = "Add to Collection";
ot->idname = "OBJECT_OT_collection_add";
ot->description = "Add an object to a new collection";
-
+
/* api callbacks */
ot->exec = collection_add_exec;
ot->poll = ED_operator_objectmode;
@@ -466,7 +468,7 @@ void OBJECT_OT_collection_link(wmOperatorType *ot)
ot->name = "Link to Collection";
ot->idname = "OBJECT_OT_collection_link";
ot->description = "Add an object to an existing collection";
-
+
/* api callbacks */
ot->exec = collection_link_exec;
ot->invoke = WM_enum_search_invoke;
@@ -494,7 +496,7 @@ static int collection_remove_exec(bContext *C, wmOperator *UNUSED(op))
BKE_collection_object_remove(bmain, collection, ob, false);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -504,7 +506,7 @@ void OBJECT_OT_collection_remove(wmOperatorType *ot)
ot->name = "Remove Collection";
ot->idname = "OBJECT_OT_collection_remove";
ot->description = "Remove the active object from this collection";
-
+
/* api callbacks */
ot->exec = collection_remove_exec;
ot->poll = ED_operator_objectmode;
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index 8c68431c19a..31e8685e323 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -82,17 +82,17 @@ static int return_editmesh_indexar(
BMVert *eve;
BMIter iter;
int *index, nr, totvert = 0;
-
+
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) totvert++;
}
if (totvert == 0) return 0;
-
+
*r_indexar = index = MEM_mallocN(4 * totvert, "hook indexar");
*r_tot = totvert;
nr = 0;
zero_v3(r_cent);
-
+
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
*index = nr; index++;
@@ -100,9 +100,9 @@ static int return_editmesh_indexar(
}
nr++;
}
-
+
mul_v3_fl(r_cent, 1.0f / (float)totvert);
-
+
return totvert;
}
@@ -136,9 +136,9 @@ static bool return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *r_name,
return true;
}
}
-
+
return false;
-}
+}
static void select_editbmesh_hook(Object *ob, HookModifierData *hmd)
{
@@ -147,10 +147,10 @@ static void select_editbmesh_hook(Object *ob, HookModifierData *hmd)
BMVert *eve;
BMIter iter;
int index = 0, nr = 0;
-
+
if (hmd->indexar == NULL)
return;
-
+
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (nr == hmd->indexar[index]) {
BM_vert_select_set(em->bm, eve, true);
@@ -169,7 +169,7 @@ static int return_editlattice_indexar(
{
BPoint *bp;
int *index, nr, totvert = 0, a;
-
+
/* count */
a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw;
bp = editlatt->def;
@@ -181,12 +181,12 @@ static int return_editlattice_indexar(
}
if (totvert == 0) return 0;
-
+
*r_indexar = index = MEM_mallocN(4 * totvert, "hook indexar");
*r_tot = totvert;
nr = 0;
zero_v3(r_cent);
-
+
a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw;
bp = editlatt->def;
while (a--) {
@@ -199,9 +199,9 @@ static int return_editlattice_indexar(
bp++;
nr++;
}
-
+
mul_v3_fl(r_cent, 1.0f / (float)totvert);
-
+
return totvert;
}
@@ -234,7 +234,7 @@ static int return_editcurve_indexar(
BPoint *bp;
BezTriple *bezt;
int *index, a, nr, totvert = 0;
-
+
for (nu = editnurb->first; nu; nu = nu->next) {
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
@@ -256,12 +256,12 @@ static int return_editcurve_indexar(
}
}
if (totvert == 0) return 0;
-
+
*r_indexar = index = MEM_mallocN(sizeof(*index) * totvert, "hook indexar");
*r_tot = totvert;
nr = 0;
zero_v3(r_cent);
-
+
for (nu = editnurb->first; nu; nu = nu->next) {
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
@@ -298,19 +298,19 @@ static int return_editcurve_indexar(
}
}
}
-
+
mul_v3_fl(r_cent, 1.0f / (float)totvert);
-
+
return totvert;
}
-static bool object_hook_index_array(Scene *scene, Object *obedit,
+static bool object_hook_index_array(Main *bmain, Scene *scene, Object *obedit,
int *r_tot, int **r_indexar, char *r_name, float r_cent[3])
{
*r_indexar = NULL;
*r_tot = 0;
r_name[0] = 0;
-
+
switch (obedit->type) {
case OB_MESH:
{
@@ -336,7 +336,7 @@ static bool object_hook_index_array(Scene *scene, Object *obedit,
}
case OB_CURVE:
case OB_SURF:
- ED_curve_editnurb_load(obedit);
+ ED_curve_editnurb_load(bmain, obedit);
ED_curve_editnurb_make(obedit);
return return_editcurve_indexar(obedit, r_tot, r_indexar, r_cent);
case OB_LATTICE:
@@ -356,7 +356,7 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd)
BPoint *bp;
BezTriple *bezt;
int index = 0, a, nr = 0;
-
+
for (nu = editnurb->first; nu; nu = nu->next) {
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
@@ -377,7 +377,7 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd)
if (index < hmd->totindex - 1) index++;
}
nr++;
-
+
bezt++;
}
}
@@ -421,11 +421,11 @@ static void object_hook_from_context(bContext *C, PointerRNA *ptr, const int num
}
}
-static void object_hook_select(Object *ob, HookModifierData *hmd)
+static void object_hook_select(Object *ob, HookModifierData *hmd)
{
if (hmd->indexar == NULL)
return;
-
+
if (ob->type == OB_MESH) select_editbmesh_hook(ob, hmd);
else if (ob->type == OB_LATTICE) select_editlattice_hook(ob, hmd);
else if (ob->type == OB_CURVE) select_editcurve_hook(ob, hmd);
@@ -437,14 +437,14 @@ static void object_hook_select(Object *ob, HookModifierData *hmd)
static int hook_op_edit_poll(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
-
+
if (obedit) {
if (ED_operator_editmesh(C)) return 1;
if (ED_operator_editsurfcurve(C)) return 1;
if (ED_operator_editlattice(C)) return 1;
//if (ED_operator_editmball(C)) return 1;
}
-
+
return 0;
}
@@ -454,12 +454,12 @@ static Object *add_hook_object_new(Main *bmain, Scene *scene, ViewLayer *view_la
Object *ob;
ob = BKE_object_add(bmain, scene, view_layer, OB_EMPTY, NULL);
-
+
basedit = BKE_view_layer_base_find(view_layer, obedit);
base = view_layer->basact;
base->lay = ob->lay = obedit->lay;
BLI_assert(view_layer->basact->object == ob);
-
+
/* icky, BKE_object_add sets new base as active.
* so set it back to the original edit object */
view_layer->basact = basedit;
@@ -475,8 +475,8 @@ static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, ViewLay
float pose_mat[4][4];
int tot, ok, *indexar;
char name[MAX_NAME];
-
- ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent);
+
+ ok = object_hook_index_array(bmain, scene, obedit, &tot, &indexar, name, cent);
if (!ok) {
BKE_report(reports, RPT_ERROR, "Requires selected vertices or active vertex group");
@@ -484,29 +484,29 @@ static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, ViewLay
}
if (mode == OBJECT_ADDHOOK_NEWOB && !ob) {
-
+
ob = add_hook_object_new(bmain, scene, view_layer, obedit);
-
+
/* transform cent to global coords for loc */
mul_v3_m4v3(ob->loc, obedit->obmat, cent);
}
-
+
md = obedit->modifiers.first;
while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) {
md = md->next;
}
-
+
hmd = (HookModifierData *) modifier_new(eModifierType_Hook);
BLI_insertlinkbefore(&obedit->modifiers, md, hmd);
BLI_snprintf(hmd->modifier.name, sizeof(hmd->modifier.name), "Hook-%s", ob->id.name + 2);
modifier_unique_name(&obedit->modifiers, (ModifierData *)hmd);
-
+
hmd->object = ob;
hmd->indexar = indexar;
copy_v3_v3(hmd->cent, cent);
hmd->totindex = tot;
BLI_strncpy(hmd->name, name, sizeof(hmd->name));
-
+
unit_m4(pose_mat);
invert_m4_m4(obedit->imat, obedit->obmat);
@@ -545,11 +545,11 @@ static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, ViewLay
/* vert x (obmat x hook->imat) x hook->obmat x ob->imat */
/* (parentinv ) */
BKE_object_where_is_calc(CTX_data_depsgraph(C), scene, ob);
-
+
invert_m4_m4(ob->imat, ob->obmat);
/* apparently this call goes from right to left... */
mul_m4_series(hmd->parentinv, pose_mat, ob->imat, obedit->obmat);
-
+
DEG_relations_tag_update(bmain);
return true;
@@ -564,7 +564,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op)
Object *obsel = NULL;
const bool use_bone = RNA_boolean_get(op->ptr, "use_bone");
const int mode = use_bone ? OBJECT_ADDHOOK_SELOB_BONE : OBJECT_ADDHOOK_SELOB;
-
+
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
{
if (ob != obedit) {
@@ -573,7 +573,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_END;
-
+
if (!obsel) {
BKE_report(op->reports, RPT_ERROR, "Cannot add hook with no other selected objects");
return OPERATOR_CANCELLED;
@@ -583,7 +583,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Cannot add hook bone for a non armature object");
return OPERATOR_CANCELLED;
}
-
+
if (add_hook_object(C, bmain, scene, view_layer, obedit, obsel, mode, op->reports)) {
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit);
return OPERATOR_FINISHED;
@@ -599,11 +599,11 @@ void OBJECT_OT_hook_add_selob(wmOperatorType *ot)
ot->name = "Hook to Selected Object";
ot->description = "Hook selected vertices to the first selected object";
ot->idname = "OBJECT_OT_hook_add_selob";
-
+
/* api callbacks */
ot->exec = object_add_hook_selob_exec;
ot->poll = hook_op_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -634,11 +634,11 @@ void OBJECT_OT_hook_add_newob(wmOperatorType *ot)
ot->name = "Hook to New Object";
ot->description = "Hook selected vertices to a newly created object";
ot->idname = "OBJECT_OT_hook_add_newob";
-
+
/* api callbacks */
ot->exec = object_add_hook_newob_exec;
ot->poll = hook_op_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -654,29 +654,29 @@ static int object_hook_remove_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier");
return OPERATOR_CANCELLED;
}
-
+
/* remove functionality */
-
+
BLI_remlink(&ob->modifiers, (ModifierData *)hmd);
modifier_free((ModifierData *)hmd);
-
+
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
static const EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
-{
+{
Object *ob = CTX_data_edit_object(C);
EnumPropertyItem tmp = {0, "", 0, "", ""};
EnumPropertyItem *item = NULL;
ModifierData *md = NULL;
int a, totitem = 0;
-
+
if (!ob)
return DummyRNA_NULL_items;
-
+
for (a = 0, md = ob->modifiers.first; md; md = md->next, a++) {
if (md->type == eModifierType_Hook) {
tmp.value = a;
@@ -686,32 +686,32 @@ static const EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *UNUSED(pt
RNA_enum_item_add(&item, &totitem, &tmp);
}
}
-
+
RNA_enum_item_end(&item, &totitem);
*r_free = true;
-
+
return item;
}
void OBJECT_OT_hook_remove(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Remove Hook";
ot->idname = "OBJECT_OT_hook_remove";
ot->description = "Remove a hook from the active object";
-
+
/* api callbacks */
ot->exec = object_hook_remove_exec;
ot->invoke = WM_menu_invoke;
ot->poll = hook_op_edit_poll;
-
+
/* flags */
/* this operator removes modifier which isn't stored in local undo stack,
* so redoing it from redo panel gives totally weird results */
ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO;
-
+
/* properties */
prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to remove");
RNA_def_enum_funcs(prop, hook_mod_itemf);
@@ -736,26 +736,26 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
void OBJECT_OT_hook_reset(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Reset Hook";
ot->description = "Recalculate and clear offset transformation";
ot->idname = "OBJECT_OT_hook_reset";
-
+
/* callbacks */
ot->exec = object_hook_reset_exec;
ot->poll = hook_op_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to");
RNA_def_enum_funcs(prop, hook_mod_itemf);
@@ -770,42 +770,42 @@ static int object_hook_recenter_exec(bContext *C, wmOperator *op)
HookModifierData *hmd = NULL;
Scene *scene = CTX_data_scene(C);
float bmat[3][3], imat[3][3];
-
+
object_hook_from_context(C, &ptr, num, &ob, &hmd);
if (hmd == NULL) {
BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier");
return OPERATOR_CANCELLED;
}
-
+
/* recenter functionality */
copy_m3_m4(bmat, ob->obmat);
invert_m3_m3(imat, bmat);
-
+
sub_v3_v3v3(hmd->cent, scene->cursor.location, ob->obmat[3]);
mul_m3_v3(imat, hmd->cent);
-
+
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
void OBJECT_OT_hook_recenter(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Recenter Hook";
ot->description = "Set hook center to cursor position";
ot->idname = "OBJECT_OT_hook_recenter";
-
+
/* callbacks */
ot->exec = object_hook_recenter_exec;
ot->poll = hook_op_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to");
RNA_def_enum_funcs(prop, hook_mod_itemf);
@@ -814,6 +814,7 @@ void OBJECT_OT_hook_recenter(wmOperatorType *ot)
static int object_hook_assign_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier);
int num = RNA_enum_get(op->ptr, "modifier");
@@ -822,50 +823,50 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op)
float cent[3];
char name[MAX_NAME];
int *indexar, tot;
-
+
object_hook_from_context(C, &ptr, num, &ob, &hmd);
if (hmd == NULL) {
BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier");
return OPERATOR_CANCELLED;
}
-
+
/* assign functionality */
-
- if (!object_hook_index_array(scene, ob, &tot, &indexar, name, cent)) {
+
+ if (!object_hook_index_array(bmain, scene, ob, &tot, &indexar, name, cent)) {
BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group");
return OPERATOR_CANCELLED;
}
if (hmd->indexar)
MEM_freeN(hmd->indexar);
-
+
copy_v3_v3(hmd->cent, cent);
hmd->indexar = indexar;
hmd->totindex = tot;
-
+
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
void OBJECT_OT_hook_assign(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Assign to Hook";
ot->description = "Assign the selected vertices to a hook";
ot->idname = "OBJECT_OT_hook_assign";
-
+
/* callbacks */
ot->exec = object_hook_assign_exec;
ot->poll = hook_op_edit_poll;
-
+
/* flags */
/* this operator changes data stored in modifier which doesn't get pushed to undo stack,
* so redoing it from redo panel gives totally weird results */
ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO;
-
+
/* properties */
prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to");
RNA_def_enum_funcs(prop, hook_mod_itemf);
@@ -878,37 +879,37 @@ static int object_hook_select_exec(bContext *C, wmOperator *op)
int num = RNA_enum_get(op->ptr, "modifier");
Object *ob = NULL;
HookModifierData *hmd = NULL;
-
+
object_hook_from_context(C, &ptr, num, &ob, &hmd);
if (hmd == NULL) {
BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier");
return OPERATOR_CANCELLED;
}
-
+
/* select functionality */
object_hook_select(ob, hmd);
-
+
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
-
+
return OPERATOR_FINISHED;
}
void OBJECT_OT_hook_select(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Select Hook";
ot->description = "Select affected vertices on mesh";
ot->idname = "OBJECT_OT_hook_select";
-
+
/* callbacks */
ot->exec = object_hook_select_exec;
ot->poll = hook_op_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to remove");
RNA_def_enum_funcs(prop, hook_mod_itemf);
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 445b14982ee..18251a25b73 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -77,6 +77,7 @@ void OBJECT_OT_unlink_data(struct wmOperatorType *ot);
/* object_edit.c */
void OBJECT_OT_mode_set(struct wmOperatorType *ot);
+void OBJECT_OT_mode_set_or_submode(struct wmOperatorType *ot);
void OBJECT_OT_editmode_toggle(struct wmOperatorType *ot);
void OBJECT_OT_posemode_toggle(struct wmOperatorType *ot);
void OBJECT_OT_proxy_make(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c
index 7a30c154f23..e9bd6fbce8f 100644
--- a/source/blender/editors/object/object_modes.c
+++ b/source/blender/editors/object/object_modes.c
@@ -45,6 +45,7 @@
#include "DEG_depsgraph.h"
+#include "ED_armature.h"
#include "ED_screen.h"
#include "ED_object.h" /* own include */
@@ -197,16 +198,18 @@ bool ED_object_mode_generic_enter(
* Caller can check #OB_MODE_ALL_MODE_DATA to test if this needs to be run.
*/
static bool ed_object_mode_generic_exit_ex(
+ struct Main *bmain,
struct Depsgraph *depsgraph,
struct Scene *scene, struct Object *ob,
bool only_test)
{
+ BLI_assert((bmain == NULL) == only_test);
if (ob->mode & OB_MODE_EDIT) {
if (BKE_object_is_in_editmode(ob)) {
if (only_test) {
return true;
}
- ED_object_editmode_exit_ex(scene, ob, EM_FREEDATA);
+ ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA);
}
}
else if (ob->mode & OB_MODE_VERTEX_PAINT) {
@@ -233,6 +236,14 @@ static bool ed_object_mode_generic_exit_ex(
ED_object_sculptmode_exit_ex(depsgraph, scene, ob);
}
}
+ else if (ob->mode & OB_MODE_POSE) {
+ if (ob->pose != NULL) {
+ if (only_test) {
+ return true;
+ }
+ ED_object_posemode_exit_ex(bmain, ob);
+ }
+ }
else {
if (only_test) {
return false;
@@ -244,17 +255,18 @@ static bool ed_object_mode_generic_exit_ex(
}
void ED_object_mode_generic_exit(
+ struct Main *bmain,
struct Depsgraph *depsgraph,
struct Scene *scene, struct Object *ob)
{
- ed_object_mode_generic_exit_ex(depsgraph, scene, ob, false);
+ ed_object_mode_generic_exit_ex(bmain, depsgraph, scene, ob, false);
}
bool ED_object_mode_generic_has_data(
struct Depsgraph *depsgraph,
struct Object *ob)
{
- return ed_object_mode_generic_exit_ex(depsgraph, NULL, ob, true);
+ return ed_object_mode_generic_exit_ex(NULL, depsgraph, NULL, ob, true);
}
/** \} */
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 43cd65c55cd..1b9af3725ca 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -63,6 +63,7 @@
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_multires.h"
#include "BKE_report.h"
@@ -100,7 +101,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
{
ModifierData *md = NULL, *new_md = NULL;
const ModifierTypeInfo *mti = modifierType_getInfo(type);
-
+
/* Check compatibility of modifier [T25291, T50373]. */
if (!BKE_object_support_modifier_type_check(ob, type)) {
BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to object '%s'", ob->id.name + 2);
@@ -113,23 +114,23 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
return NULL;
}
}
-
+
if (type == eModifierType_ParticleSystem) {
/* don't need to worry about the new modifier's name, since that is set to the number
- * of particle systems which shouldn't have too many duplicates
+ * of particle systems which shouldn't have too many duplicates
*/
new_md = object_add_particle_system(scene, ob, name);
}
else {
/* get new modifier data to add */
new_md = modifier_new(type);
-
+
if (mti->flags & eModifierTypeFlag_RequiresOriginalData) {
md = ob->modifiers.first;
-
+
while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform)
md = md->next;
-
+
BLI_insertlinkbefore(&ob->modifiers, md, new_md);
}
else
@@ -142,7 +143,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
/* make sure modifier data has unique name */
modifier_unique_name(&ob->modifiers, new_md);
-
+
/* special cases */
if (type == eModifierType_Softbody) {
if (!ob->soft) {
@@ -153,7 +154,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
else if (type == eModifierType_Collision) {
if (!ob->pd)
ob->pd = object_add_collision_fields(0);
-
+
ob->pd->deflect = 1;
}
else if (type == eModifierType_Surface) {
@@ -199,7 +200,7 @@ static bool object_has_modifier(const Object *ob, const ModifierData *exclude,
* each of them.
*
* If include_orig is true, the callback will run on 'orig_ob' too.
- *
+ *
* If the callback ever returns true, iteration will stop and the
* function value will be true. Otherwise the function returns false.
*/
@@ -468,14 +469,14 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene *
/* add new mesh */
obn = BKE_object_add(bmain, scene, view_layer, OB_MESH, NULL);
me = obn->data;
-
+
me->totvert = totvert;
me->totedge = totedge;
-
+
me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, totvert);
me->medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
me->mface = CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, 0);
-
+
mvert = me->mvert;
medge = me->medge;
@@ -546,22 +547,22 @@ static int modifier_apply_shape(ReportList *reports, Depsgraph *depsgraph, Scene
*/
if (ob->type == OB_MESH) {
- DerivedMesh *dm;
+ Mesh *mesh_applied;
Mesh *me = ob->data;
Key *key = me->key;
KeyBlock *kb;
-
+
if (!modifier_isSameTopology(md) || mti->type == eModifierTypeType_NonGeometrical) {
BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to shapes");
return 0;
}
-
- dm = mesh_create_derived_for_modifier(depsgraph, scene, ob, md, 0);
- if (!dm) {
+
+ mesh_applied = BKE_mesh_create_derived_for_modifier(depsgraph, scene, ob, md, 0);
+ if (!mesh_applied) {
BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply");
return 0;
}
-
+
if (key == NULL) {
key = me->key = BKE_key_add((ID *)me);
key->type = KEY_RELATIVE;
@@ -572,9 +573,9 @@ static int modifier_apply_shape(ReportList *reports, Depsgraph *depsgraph, Scene
}
kb = BKE_keyblock_add(key, md->name);
- DM_to_meshkey(dm, me, kb);
-
- dm->release(dm);
+ BKE_mesh_nomain_to_meshkey(mesh_applied, me, kb);
+
+ BKE_id_free(NULL, mesh_applied);
}
else {
BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type");
@@ -595,7 +596,7 @@ static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scen
}
if (ob->type == OB_MESH) {
- DerivedMesh *dm;
+ Mesh *mesh_applied;
Mesh *me = ob->data;
MultiresModifierData *mmd = find_multires_modifier_before(scene, md);
@@ -615,13 +616,13 @@ static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scen
}
}
else {
- dm = mesh_create_derived_for_modifier(depsgraph, scene, ob, md, 1);
- if (!dm) {
+ mesh_applied = BKE_mesh_create_derived_for_modifier(depsgraph, scene, ob, md, 1);
+ if (!mesh_applied) {
BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping apply");
return 0;
}
- DM_to_mesh(dm, me, ob, CD_MASK_MESH, true);
+ BKE_mesh_nomain_to_mesh(mesh_applied, me, ob, CD_MASK_MESH, true);
if (md->type == eModifierType_Multires)
multires_customdata_delete(me);
@@ -660,7 +661,7 @@ static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scen
ParticleSystem *psys = ob->particlesystem.first;
for (; psys; psys = psys->next) {
-
+
if (psys->part->type != PART_HAIR)
continue;
@@ -724,7 +725,7 @@ int ED_object_modifier_apply(
int ED_object_modifier_copy(ReportList *UNUSED(reports), Object *ob, ModifierData *md)
{
ModifierData *nmd;
-
+
nmd = modifier_new(md->type);
modifier_copyData(md, nmd);
BLI_insertlinkafter(&ob->modifiers, md, nmd);
@@ -746,19 +747,19 @@ static int modifier_add_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
static const EnumPropertyItem *modifier_add_itemf(
bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
-{
+{
Object *ob = ED_object_active_context(C);
EnumPropertyItem *item = NULL;
const EnumPropertyItem *md_item, *group_item = NULL;
const ModifierTypeInfo *mti;
int totitem = 0, a;
-
+
if (!ob)
return rna_enum_object_modifier_type_items;
@@ -803,15 +804,15 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot)
ot->name = "Add Modifier";
ot->description = "Add a procedural operation/effect to the active object";
ot->idname = "OBJECT_OT_modifier_add";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = modifier_add_exec;
ot->poll = ED_operator_object_active_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
prop = RNA_def_enum(ot->srna, "type", rna_enum_object_modifier_type_items, eModifierType_Subsurf, "Type", "");
RNA_def_enum_funcs(prop, modifier_add_itemf);
@@ -824,7 +825,7 @@ int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type);
Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C);
-
+
if (!ptr.data) {
CTX_wm_operator_poll_msg_set(C, "Context missing 'modifier'");
return 0;
@@ -838,7 +839,7 @@ int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag
CTX_wm_operator_poll_msg_set(C, "Cannot edit modifiers comming from static override");
return (((ModifierData *)ptr.data)->flag & eModifierFlag_StaticOverride_Local) != 0;
}
-
+
return 1;
}
@@ -855,7 +856,7 @@ void edit_modifier_properties(wmOperatorType *ot)
int edit_modifier_invoke_properties(bContext *C, wmOperator *op)
{
ModifierData *md;
-
+
if (RNA_struct_property_is_set(op->ptr, "modifier")) {
return true;
}
@@ -876,9 +877,9 @@ ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type)
char modifier_name[MAX_NAME];
ModifierData *md;
RNA_string_get(op->ptr, "modifier", modifier_name);
-
+
md = modifiers_findByName(ob, modifier_name);
-
+
if (md && type != 0 && md->type != type)
md = NULL;
@@ -894,7 +895,7 @@ static int modifier_remove_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
int mode_orig = ob->mode;
-
+
if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md))
return OPERATOR_CANCELLED;
@@ -928,7 +929,7 @@ void OBJECT_OT_modifier_remove(wmOperatorType *ot)
ot->invoke = modifier_remove_invoke;
ot->exec = modifier_remove_exec;
ot->poll = edit_modifier_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
@@ -946,7 +947,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -967,7 +968,7 @@ void OBJECT_OT_modifier_move_up(wmOperatorType *ot)
ot->invoke = modifier_move_up_invoke;
ot->exec = modifier_move_up_exec;
ot->poll = edit_modifier_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
@@ -985,7 +986,7 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1006,7 +1007,7 @@ void OBJECT_OT_modifier_move_down(wmOperatorType *ot)
ot->invoke = modifier_move_down_invoke;
ot->exec = modifier_move_down_exec;
ot->poll = edit_modifier_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
@@ -1028,7 +1029,7 @@ static int modifier_apply_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1055,10 +1056,10 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot)
ot->invoke = modifier_apply_invoke;
ot->exec = modifier_apply_exec;
ot->poll = edit_modifier_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
-
+
RNA_def_enum(ot->srna, "apply_as", modifier_apply_as_items, MODIFIER_APPLY_DATA, "Apply as", "How to apply the modifier to the geometry");
edit_modifier_properties(ot);
}
@@ -1072,13 +1073,13 @@ static int modifier_convert_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
-
+
if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, view_layer, ob, md))
return OPERATOR_CANCELLED;
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1099,7 +1100,7 @@ void OBJECT_OT_modifier_convert(wmOperatorType *ot)
ot->invoke = modifier_convert_invoke;
ot->exec = modifier_convert_exec;
ot->poll = edit_modifier_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
@@ -1117,7 +1118,7 @@ static int modifier_copy_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1138,7 +1139,7 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot)
ot->invoke = modifier_copy_invoke;
ot->exec = modifier_copy_exec;
ot->poll = edit_modifier_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
@@ -1155,18 +1156,18 @@ static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires);
-
+
if (!mmd)
return OPERATOR_CANCELLED;
-
+
multiresModifier_del_levels(mmd, ob, 1);
ED_object_iter_other(CTX_data_main(C), ob, true,
ED_object_multires_update_totlevels_cb,
&mmd->totlvl);
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1187,7 +1188,7 @@ void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot)
ot->poll = multires_poll;
ot->invoke = multires_higher_levels_delete_invoke;
ot->exec = multires_higher_levels_delete_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
@@ -1199,10 +1200,10 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires);
-
+
if (!mmd)
return OPERATOR_CANCELLED;
-
+
multiresModifier_subdivide(mmd, ob, 0, mmd->simple);
ED_object_iter_other(CTX_data_main(C), ob, true,
@@ -1216,7 +1217,7 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op)
/* ensure that grid paint mask layer is created */
BKE_sculpt_mask_layers_ensure(ob, mmd);
}
-
+
return OPERATOR_FINISHED;
}
@@ -1237,7 +1238,7 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot)
ot->poll = multires_poll;
ot->invoke = multires_subdivide_invoke;
ot->exec = multires_subdivide_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
@@ -1302,18 +1303,19 @@ void OBJECT_OT_multires_reshape(wmOperatorType *ot)
ot->poll = multires_poll;
ot->invoke = multires_reshape_invoke;
ot->exec = multires_reshape_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
}
-
+
/****************** multires save external operator *********************/
static int multires_external_save_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Object *ob = ED_object_active_context(C);
Mesh *me = (ob) ? ob->data : op->customdata;
char path[FILE_MAX];
@@ -1324,15 +1326,15 @@ static int multires_external_save_exec(bContext *C, wmOperator *op)
if (CustomData_external_test(&me->ldata, CD_MDISPS))
return OPERATOR_CANCELLED;
-
+
RNA_string_get(op->ptr, "filepath", path);
if (relative)
- BLI_path_rel(path, G.main->name);
+ BLI_path_rel(path, BKE_main_blendfile_path(bmain));
CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, path);
CustomData_external_write(&me->ldata, &me->id, CD_MASK_MESH, me->totloop, 0);
-
+
return OPERATOR_FINISHED;
}
@@ -1345,23 +1347,23 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, const wmEv
if (!edit_modifier_invoke_properties(C, op))
return OPERATOR_CANCELLED;
-
+
mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires);
-
+
if (!mmd)
return OPERATOR_CANCELLED;
-
+
if (CustomData_external_test(&me->ldata, CD_MDISPS))
return OPERATOR_CANCELLED;
if (RNA_struct_property_is_set(op->ptr, "filepath"))
return multires_external_save_exec(C, op);
-
+
op->customdata = me;
BLI_snprintf(path, sizeof(path), "//%s.btx", me->id.name + 2);
RNA_string_set(op->ptr, "filepath", path);
-
+
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
@@ -1377,7 +1379,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot)
ot->exec = multires_external_save_exec;
ot->invoke = multires_external_save_invoke;
ot->poll = multires_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -1399,7 +1401,7 @@ static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op))
/* XXX don't remove.. */
CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop);
-
+
return OPERATOR_FINISHED;
}
@@ -1411,7 +1413,7 @@ void OBJECT_OT_multires_external_pack(wmOperatorType *ot)
ot->poll = multires_poll;
ot->exec = multires_external_pack_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1421,15 +1423,15 @@ static int multires_base_apply_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires);
-
+
if (!mmd)
return OPERATOR_CANCELLED;
-
+
multiresModifier_base_apply(mmd, ob);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1451,7 +1453,7 @@ void OBJECT_OT_multires_base_apply(wmOperatorType *ot)
ot->poll = multires_poll;
ot->invoke = multires_base_apply_invoke;
ot->exec = multires_base_apply_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
@@ -1464,7 +1466,7 @@ static void modifier_skin_customdata_delete(Object *ob)
{
Mesh *me = ob->data;
BMEditMesh *em = me->edit_btmesh;
-
+
if (em)
BM_data_layer_free(em->bm, &em->bm->vdata, CD_MVERT_SKIN);
else
@@ -1487,7 +1489,7 @@ static void skin_root_clear(BMVert *bm_vert, GSet *visited, const int cd_vert_sk
{
BMEdge *bm_edge;
BMIter bm_iter;
-
+
BM_ITER_ELEM (bm_edge, &bm_iter, bm_vert, BM_EDGES_OF_VERT) {
BMVert *v2 = BM_edge_other_vert(bm_edge, bm_vert);
@@ -1535,7 +1537,7 @@ static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1547,7 +1549,7 @@ void OBJECT_OT_skin_root_mark(wmOperatorType *ot)
ot->poll = skin_edit_poll;
ot->exec = skin_root_mark_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1590,7 +1592,7 @@ static int skin_loose_mark_clear_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1608,7 +1610,7 @@ void OBJECT_OT_skin_loose_mark_clear(wmOperatorType *ot)
ot->poll = skin_edit_poll;
ot->exec = skin_loose_mark_clear_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1640,7 +1642,7 @@ static int skin_radii_equalize_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1652,7 +1654,7 @@ void OBJECT_OT_skin_radii_equalize(wmOperatorType *ot)
ot->poll = skin_edit_poll;
ot->exec = skin_radii_equalize_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1696,7 +1698,7 @@ static void skin_armature_bone_create(Object *skin_ob,
ED_vgroup_vert_add(skin_ob, dg, parent_v, 1, WEIGHT_REPLACE);
ED_vgroup_vert_add(skin_ob, dg, v, 1, WEIGHT_REPLACE);
}
-
+
skin_armature_bone_create(skin_ob,
mvert, medge,
arm,
@@ -1729,7 +1731,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain,
CD_CALLOC,
NULL,
me->totvert);
-
+
ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
arm_ob = BKE_object_add(bmain, scene, view_layer, OB_ARMATURE, NULL);
BKE_object_transform_copy(arm_ob, skin_ob);
@@ -1763,7 +1765,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain,
bone->head[1] = 1.0f;
bone->rad_head = bone->rad_tail = 0.25;
}
-
+
if (emap[v].count >= 1) {
skin_armature_bone_create(skin_ob,
mvert, me->medge,
@@ -1780,7 +1782,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain,
MEM_freeN(emap);
MEM_freeN(emap_mem);
- ED_armature_from_edit(arm);
+ ED_armature_from_edit(bmain, arm);
ED_armature_edit_free(arm);
return arm_ob;
@@ -1838,7 +1840,7 @@ void OBJECT_OT_skin_armature_create(wmOperatorType *ot)
ot->poll = skin_poll;
ot->invoke = skin_armature_create_invoke;
ot->exec = skin_armature_create_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
@@ -1924,7 +1926,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_MeshDeform);
-
+
if (!mmd)
return OPERATOR_CANCELLED;
@@ -1949,7 +1951,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
mmd->totvert = 0;
mmd->totcagevert = 0;
mmd->totinfluence = 0;
-
+
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
}
@@ -1978,7 +1980,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
mmd->bindfunc = NULL;
mmd->modifier.mode = mode;
}
-
+
return OPERATOR_FINISHED;
}
@@ -1986,7 +1988,7 @@ static int meshdeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UN
{
if (edit_modifier_invoke_properties(C, op))
return meshdeform_bind_exec(C, op);
- else
+ else
return OPERATOR_CANCELLED;
}
@@ -1996,12 +1998,12 @@ void OBJECT_OT_meshdeform_bind(wmOperatorType *ot)
ot->name = "Mesh Deform Bind";
ot->description = "Bind mesh to cage in mesh deform modifier";
ot->idname = "OBJECT_OT_meshdeform_bind";
-
+
/* api callbacks */
ot->poll = meshdeform_poll;
ot->invoke = meshdeform_bind_invoke;
ot->exec = meshdeform_bind_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
@@ -2018,7 +2020,7 @@ static int explode_refresh_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
ExplodeModifierData *emd = (ExplodeModifierData *)edit_modifier_property_get(op, ob, eModifierType_Explode);
-
+
if (!emd)
return OPERATOR_CANCELLED;
@@ -2026,7 +2028,7 @@ static int explode_refresh_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -2048,7 +2050,7 @@ void OBJECT_OT_explode_refresh(wmOperatorType *ot)
ot->poll = explode_poll;
ot->invoke = explode_refresh_invoke;
ot->exec = explode_refresh_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
@@ -2066,14 +2068,14 @@ static int ocean_bake_poll(bContext *C)
static void init_ocean_modifier_bake(struct Ocean *oc, struct OceanModifierData *omd)
{
int do_heightfield, do_chop, do_normals, do_jacobian;
-
- if (!omd || !oc) return;
-
+
+ if (!omd || !oc) return;
+
do_heightfield = true;
do_chop = (omd->chop_amount > 0);
do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS);
do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM);
-
+
BKE_ocean_init(oc, omd->resolution * omd->resolution, omd->resolution * omd->resolution, omd->spatial_size, omd->spatial_size,
omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment,
omd->depth, omd->time,
@@ -2103,8 +2105,8 @@ static int oceanbake_breakjob(void *UNUSED(customdata))
{
//OceanBakeJob *ob = (OceanBakeJob *)customdata;
//return *(ob->stop);
-
- /* this is not nice yet, need to make the jobs list template better
+
+ /* this is not nice yet, need to make the jobs list template better
* for identifying/acting upon various different jobs */
/* but for now we'll reuse the render break... */
return (G.is_break);
@@ -2114,10 +2116,10 @@ static int oceanbake_breakjob(void *UNUSED(customdata))
static void oceanbake_update(void *customdata, float progress, int *cancel)
{
OceanBakeJob *oj = customdata;
-
+
if (oceanbake_breakjob(oj))
*cancel = 1;
-
+
*(oj->do_update) = true;
*(oj->progress) = progress;
}
@@ -2125,15 +2127,15 @@ static void oceanbake_update(void *customdata, float progress, int *cancel)
static void oceanbake_startjob(void *customdata, short *stop, short *do_update, float *progress)
{
OceanBakeJob *oj = customdata;
-
+
oj->stop = stop;
oj->do_update = do_update;
oj->progress = progress;
-
+
G.is_break = false; /* XXX shared with render - replace with job 'stop' switch */
-
+
BKE_ocean_bake(oj->ocean, oj->och, oceanbake_update, (void *)oj);
-
+
*do_update = true;
*stop = 0;
}
@@ -2141,18 +2143,19 @@ static void oceanbake_startjob(void *customdata, short *stop, short *do_update,
static void oceanbake_endjob(void *customdata)
{
OceanBakeJob *oj = customdata;
-
+
if (oj->ocean) {
BKE_ocean_free(oj->ocean);
oj->ocean = NULL;
}
-
+
oj->omd->oceancache = oj->och;
oj->omd->cached = true;
}
static int ocean_bake_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Object *ob = ED_object_active_context(C);
OceanModifierData *omd = (OceanModifierData *)edit_modifier_property_get(op, ob, eModifierType_Ocean);
Scene *scene = CTX_data_scene(C);
@@ -2160,13 +2163,13 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
struct Ocean *ocean;
int f, cfra, i = 0;
const bool free = RNA_boolean_get(op->ptr, "free");
-
+
wmJob *wm_job;
OceanBakeJob *oj;
-
+
if (!omd)
return OPERATOR_CANCELLED;
-
+
if (free) {
omd->refresh |= MOD_OCEAN_REFRESH_CLEAR_CACHE;
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -2174,59 +2177,59 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
- och = BKE_ocean_init_cache(omd->cachepath, modifier_path_relbase(ob),
+ och = BKE_ocean_init_cache(omd->cachepath, modifier_path_relbase(bmain, ob),
omd->bakestart, omd->bakeend, omd->wave_scale,
omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution);
-
+
och->time = MEM_mallocN(och->duration * sizeof(float), "foam bake time");
-
+
cfra = scene->r.cfra;
-
+
/* precalculate time variable before baking */
for (f = omd->bakestart; f <= omd->bakeend; f++) {
/* from physics_fluid.c:
*
* XXX: This can't be used due to an anim sys optimization that ignores recalc object animation,
* leaving it for the depgraph (this ignores object animation such as modifier properties though... :/ )
- * --> BKE_animsys_evaluate_all_animation(G.main, eval_time);
+ * --> BKE_animsys_evaluate_all_animation(bmain, eval_time);
* This doesn't work with drivers:
* --> BKE_animsys_evaluate_animdata(&fsDomain->id, fsDomain->adt, eval_time, ADT_RECALC_ALL);
*/
-
- /* Modifying the global scene isn't nice, but we can do it in
+
+ /* Modifying the global scene isn't nice, but we can do it in
* this part of the process before a threaded job is created */
-
+
//scene->r.cfra = f;
- //ED_update_for_newframe(CTX_data_main(C), scene);
-
- /* ok, this doesn't work with drivers, but is way faster.
+ //ED_update_for_newframe(bmain, scene);
+
+ /* ok, this doesn't work with drivers, but is way faster.
* let's use this for now and hope nobody wants to drive the time value... */
- BKE_animsys_evaluate_animdata(scene, (ID *)ob, ob->adt, f, ADT_RECALC_ANIM);
-
+ BKE_animsys_evaluate_animdata(CTX_data_depsgraph(C), scene, (ID *)ob, ob->adt, f, ADT_RECALC_ANIM);
+
och->time[i] = omd->time;
i++;
}
-
+
/* make a copy of ocean to use for baking - threadsafety */
ocean = BKE_ocean_add();
init_ocean_modifier_bake(ocean, omd);
-
+
#if 0
BKE_ocean_bake(ocean, och);
-
+
omd->oceancache = och;
omd->cached = true;
-
+
scene->r.cfra = cfra;
-
+
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
#endif
-
+
/* job stuff */
-
+
scene->r.cfra = cfra;
-
+
/* setup job */
wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Ocean Simulation",
WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_OCEAN);
@@ -2234,15 +2237,15 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
oj->ocean = ocean;
oj->och = och;
oj->omd = omd;
-
+
WM_jobs_customdata_set(wm_job, oj, oceanbake_free);
WM_jobs_timer(wm_job, 0.1, NC_OBJECT | ND_MODIFIER, NC_OBJECT | ND_MODIFIER);
WM_jobs_callbacks(wm_job, oceanbake_startjob, NULL, NULL, oceanbake_endjob);
-
+
WM_jobs_start(CTX_wm_manager(C), wm_job);
-
-
-
+
+
+
return OPERATOR_FINISHED;
}
@@ -2260,15 +2263,15 @@ void OBJECT_OT_ocean_bake(wmOperatorType *ot)
ot->name = "Bake Ocean";
ot->description = "Bake an image sequence of ocean data";
ot->idname = "OBJECT_OT_ocean_bake";
-
+
ot->poll = ocean_bake_poll;
ot->invoke = ocean_bake_invoke;
ot->exec = ocean_bake_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
-
+
RNA_def_boolean(ot->srna, "free", false, "Free", "Free the bake, rather than generating it");
}
@@ -2327,7 +2330,7 @@ static int laplaciandeform_bind_invoke(bContext *C, wmOperator *op, const wmEven
{
if (edit_modifier_invoke_properties(C, op))
return laplaciandeform_bind_exec(C, op);
- else
+ else
return OPERATOR_CANCELLED;
}
@@ -2337,12 +2340,12 @@ void OBJECT_OT_laplaciandeform_bind(wmOperatorType *ot)
ot->name = "Laplacian Deform Bind";
ot->description = "Bind mesh to system in laplacian deform modifier";
ot->idname = "OBJECT_OT_laplaciandeform_bind";
-
+
/* api callbacks */
ot->poll = laplaciandeform_poll;
ot->invoke = laplaciandeform_bind_invoke;
ot->exec = laplaciandeform_bind_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index c47d741f818..af572824068 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -65,8 +65,9 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_transform_apply);
WM_operatortype_append(OBJECT_OT_transform_axis_target);
WM_operatortype_append(OBJECT_OT_origin_set);
-
+
WM_operatortype_append(OBJECT_OT_mode_set);
+ WM_operatortype_append(OBJECT_OT_mode_set_or_submode);
WM_operatortype_append(OBJECT_OT_editmode_toggle);
WM_operatortype_append(OBJECT_OT_posemode_toggle);
WM_operatortype_append(OBJECT_OT_proxy_make);
@@ -149,7 +150,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_meshdeform_bind);
WM_operatortype_append(OBJECT_OT_explode_refresh);
WM_operatortype_append(OBJECT_OT_ocean_bake);
-
+
WM_operatortype_append(OBJECT_OT_constraint_add);
WM_operatortype_append(OBJECT_OT_constraint_add_with_targets);
WM_operatortype_append(POSE_OT_constraint_add);
@@ -252,7 +253,7 @@ void ED_operatormacros_object(void)
{
wmOperatorType *ot;
wmOperatorTypeMacro *otmacro;
-
+
ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects",
"Duplicate selected objects and move them", OPTYPE_UNDO | OPTYPE_REGISTER);
if (ot) {
@@ -270,7 +271,7 @@ void ED_operatormacros_object(void)
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
}
-
+
}
static int object_mode_poll(bContext *C)
@@ -283,35 +284,24 @@ void ED_keymap_object(wmKeyConfig *keyconf)
{
wmKeyMap *keymap;
wmKeyMapItem *kmi;
- int i;
-
+
/* Objects, Regardless of Mode -------------------------------------------------- */
keymap = WM_keymap_find(keyconf, "Object Non-modal", 0, 0);
-
- /* Note: this keymap works disregarding mode */
- kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, 0, 0);
+
+ /* modes */
+ kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_RELEASE, 0, 0);
RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT);
RNA_boolean_set(kmi->ptr, "toggle", true);
- kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0);
- RNA_enum_set(kmi->ptr, "mode", OB_MODE_POSE);
- RNA_boolean_set(kmi->ptr, "toggle", true);
+ kmi = WM_keymap_add_menu_pie(keymap, "VIEW3D_PIE_object_mode", TABKEY, KM_CLICK_DRAG, 0, 0);
- kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", VKEY, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "mode", OB_MODE_VERTEX_PAINT);
- RNA_boolean_set(kmi->ptr, "toggle", true);
-
- kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0);
- RNA_enum_set(kmi->ptr, "mode", OB_MODE_WEIGHT_PAINT);
- RNA_boolean_set(kmi->ptr, "toggle", true);
-
WM_keymap_add_item(keymap, "OBJECT_OT_origin_set", CKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_CTRL, 0);
/* Object Mode ---------------------------------------------------------------- */
/* Note: this keymap gets disabled in non-objectmode, */
keymap = WM_keymap_find(keyconf, "Object Mode", 0, 0);
keymap->poll = object_mode_poll;
-
+
/* object mode supports PET now */
ED_keymap_proportional_cycle(keyconf, keymap);
ED_keymap_proportional_obmode(keyconf, keymap);
@@ -327,7 +317,7 @@ void ED_keymap_object(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "OBJECT_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "OBJECT_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "OBJECT_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
-
+
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
RNA_enum_set_identifier(NULL, kmi->ptr, "direction", "PARENT");
RNA_boolean_set(kmi->ptr, "extend", false);
@@ -349,20 +339,20 @@ void ED_keymap_object(wmKeyConfig *keyconf)
WM_keymap_verify_item(keymap, "OBJECT_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_verify_item(keymap, "OBJECT_OT_track_set", TKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_verify_item(keymap, "OBJECT_OT_track_clear", TKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_verify_item(keymap, "OBJECT_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
WM_keymap_verify_item(keymap, "OBJECT_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
-
-
+
+
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_location_clear", GKEY, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "clear_delta", false);
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_rotation_clear", RKEY, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "clear_delta", false);
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "clear_delta", false);
-
+
WM_keymap_verify_item(keymap, "OBJECT_OT_origin_clear", OKEY, KM_PRESS, KM_ALT, 0);
-
+
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "use_global", false);
@@ -384,7 +374,7 @@ void ED_keymap_object(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move_linked", DKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_item(keymap, "OBJECT_OT_join", JKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "OBJECT_OT_convert", CKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "OBJECT_OT_proxy_make", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
@@ -394,25 +384,26 @@ void ED_keymap_object(wmKeyConfig *keyconf)
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0);
-
+
WM_keymap_verify_item(keymap, "COLLECTION_OT_create", GKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_verify_item(keymap, "COLLECTION_OT_objects_remove", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
WM_keymap_verify_item(keymap, "COLLECTION_OT_objects_remove_all", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL | KM_ALT, 0);
WM_keymap_verify_item(keymap, "COLLECTION_OT_objects_add_active", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
WM_keymap_verify_item(keymap, "COLLECTION_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
-
+
WM_keymap_add_menu(keymap, "VIEW3D_MT_object_specials", WKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "OBJECT_OT_data_transfer", TKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
/* XXX No more available 'T' shortcuts... :/ */
/* WM_keymap_verify_item(keymap, "OBJECT_OT_datalayout_transfer", TKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); */
- for (i = 0; i <= 5; i++) {
+ for (int i = 0; i <= 5; i++) {
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0);
RNA_int_set(kmi->ptr, "level", i);
}
WM_keymap_add_item(keymap, "OBJECT_OT_move_to_collection", MKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "OBJECT_OT_link_to_collection", MKEY, KM_PRESS, KM_SHIFT, 0);
}
void ED_keymap_proportional_cycle(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyMap *keymap)
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 6925daa4b6c..4f441826bfd 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -640,7 +640,7 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene,
/* if follow, add F-Curve for ctime (i.e. "eval_time") so that path-follow works */
if (partype == PAR_FOLLOW) {
/* get or create F-Curve */
- bAction *act = verify_adt_action(&cu->id, 1);
+ bAction *act = verify_adt_action(bmain, &cu->id, 1);
FCurve *fcu = verify_fcurve(act, NULL, NULL, "eval_time", 0, 1);
/* setup dummy 'generator' modifier here to get 1-1 correspondence still working */
@@ -1454,7 +1454,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
ob_dst->data = obdata_id;
/* if amount of material indices changed: */
- test_object_materials(ob_dst, ob_dst->data);
+ test_object_materials(bmain, ob_dst, ob_dst->data);
DEG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
break;
@@ -1462,7 +1462,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
/* new approach, using functions from kernel */
for (a = 0; a < ob_src->totcol; a++) {
Material *ma = give_current_material(ob_src, a + 1);
- assign_material(ob_dst, ma, a + 1, BKE_MAT_ASSIGN_USERPREF); /* also works with ma==NULL */
+ assign_material(bmain, ob_dst, ma, a + 1, BKE_MAT_ASSIGN_USERPREF); /* also works with ma==NULL */
}
DEG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
break;
@@ -1875,7 +1875,7 @@ static void single_mat_users(Main *bmain, Scene *scene, ViewLayer *view_layer, c
BKE_animdata_copy_id_action(&man->id, false);
man->id.us = 0;
- assign_material(ob, man, a, BKE_MAT_ASSIGN_USERPREF);
+ assign_material(bmain, ob, man, a, BKE_MAT_ASSIGN_USERPREF);
}
}
}
@@ -2304,7 +2304,7 @@ static int make_override_static_exec(bContext *C, wmOperator *op)
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
- /* Then, we make static override of the whole set of objects in the collection. */
+ /* Then, we remove (untag) bone shape objects, you shall never want to override those (hopefully)... */
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(collection, ob)
{
if (ob->type == OB_ARMATURE && ob->pose != NULL) {
@@ -2325,18 +2325,16 @@ static int make_override_static_exec(bContext *C, wmOperator *op)
Collection *new_collection = (Collection *)collection->id.newid;
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(new_collection, new_ob)
{
- if (new_ob != NULL &&
- new_ob->id.override_static != NULL &&
- (base = BKE_view_layer_base_find(view_layer, new_ob)) == NULL)
- {
- BKE_collection_object_add_from(bmain, scene, obcollection, new_ob);
- DEG_id_tag_update_ex(bmain, &new_ob->id, OB_RECALC_OB | DEG_TAG_BASE_FLAGS_UPDATE);
+ if (new_ob != NULL && new_ob->id.override_static != NULL) {
+ if ((base = BKE_view_layer_base_find(view_layer, new_ob)) == NULL) {
+ BKE_collection_object_add_from(bmain, scene, obcollection, new_ob);
+ DEG_id_tag_update_ex(bmain, &new_ob->id, DEG_TAG_TRANSFORM | DEG_TAG_BASE_FLAGS_UPDATE);
+ }
/* parent to 'collection' empty */
if (new_ob->parent == NULL) {
new_ob->parent = obcollection;
}
if (new_ob == (Object *)obact->id.newid) {
- base = BKE_view_layer_base_find(view_layer, new_ob);
BKE_view_layer_base_select(view_layer, base);
}
else {
@@ -2504,16 +2502,17 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot)
static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
+ Main *bmain = CTX_data_main(C);
Base *base = ED_view3d_give_base_under_cursor(C, event->mval);
Material *ma;
char name[MAX_ID_NAME - 2];
RNA_string_get(op->ptr, "name", name);
- ma = (Material *)BKE_libblock_find_name(ID_MA, name);
+ ma = (Material *)BKE_libblock_find_name(bmain, ID_MA, name);
if (base == NULL || ma == NULL)
return OPERATOR_CANCELLED;
- assign_material(base->object, ma, 1, BKE_MAT_ASSIGN_USERPREF);
+ assign_material(CTX_data_main(C), base->object, ma, 1, BKE_MAT_ASSIGN_USERPREF);
DEG_id_tag_update(&base->object->id, OB_RECALC_OB);
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index d5e6f08352f..bac1ba0e37d 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -88,7 +88,7 @@
* this takes into account the 'restrict selection in 3d view' flag.
* deselect works always, the restriction just prevents selection */
-/* Note: send a NC_SCENE|ND_OB_SELECT notifier yourself! (or
+/* Note: send a NC_SCENE|ND_OB_SELECT notifier yourself! (or
* or a NC_SCENE|ND_OB_VISIBLE in case of visibility toggling */
void ED_object_base_select(Base *base, eObjectSelect_Mode mode)
@@ -143,7 +143,7 @@ static int objects_selectable_poll(bContext *C)
return 0;
if (obact && obact->mode)
return 0;
-
+
return 1;
}
@@ -152,10 +152,10 @@ static int objects_selectable_poll(bContext *C)
static int object_select_by_type_exec(bContext *C, wmOperator *op)
{
short obtype, extend;
-
+
obtype = RNA_enum_get(op->ptr, "type");
extend = RNA_boolean_get(op->ptr, "extend");
-
+
if (extend == 0) {
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
{
@@ -163,7 +163,7 @@ static int object_select_by_type_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
}
-
+
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
{
if (base->object->type == obtype) {
@@ -171,9 +171,9 @@ static int object_select_by_type_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_END;
-
+
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
-
+
return OPERATOR_FINISHED;
}
@@ -183,15 +183,15 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot)
ot->name = "Select By Type";
ot->description = "Select all visible objects that are of a type";
ot->idname = "OBJECT_OT_select_by_type";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = object_select_by_type_exec;
ot->poll = objects_selectable_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first");
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_object_type_items, 1, "Type", "");
@@ -294,7 +294,7 @@ static bool object_select_all_by_particle(bContext *C, Object *ob)
if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) {
/* loop through other particles*/
ParticleSystem *psys;
-
+
for (psys = base->object->particlesystem.first; psys; psys = psys->next) {
if (psys->part == psys_act->part) {
ED_object_base_select(base, BA_SELECT);
@@ -378,7 +378,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
bool changed = false, extend;
extend = RNA_boolean_get(op->ptr, "extend");
-
+
if (extend == 0) {
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
{
@@ -386,13 +386,13 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
}
-
+
ob = OBACT(view_layer);
if (ob == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active object");
return OPERATOR_CANCELLED;
}
-
+
if (nr == OBJECT_SELECT_LINKED_IPO) {
// XXX old animation system
//if (ob->ipo == 0) return OPERATOR_CANCELLED;
@@ -442,7 +442,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
}
-
+
return OPERATOR_CANCELLED;
}
@@ -452,15 +452,15 @@ void OBJECT_OT_select_linked(wmOperatorType *ot)
ot->name = "Select Linked";
ot->description = "Select all visible objects that are linked";
ot->idname = "OBJECT_OT_select_linked";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = object_select_linked_exec;
ot->poll = objects_selectable_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first");
ot->prop = RNA_def_enum(ot->srna, "type", prop_select_linked_types, 0, "Type", "");
@@ -694,7 +694,7 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList
{
KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C));
bool changed = false;
-
+
/* firstly, validate KeyingSet */
if (ks == NULL) {
BKE_report(reports, RPT_ERROR, "No active Keying Set to use");
@@ -703,7 +703,7 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList
else if (ANIM_validate_keyingset(C, NULL, ks) != 0) {
if (ks->paths.first == NULL) {
if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) {
- BKE_report(reports, RPT_ERROR,
+ BKE_report(reports, RPT_ERROR,
"Use another Keying Set, as the active one depends on the currently "
"selected objects or cannot find any targets due to unsuitable context");
}
@@ -713,7 +713,7 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList
}
return false;
}
-
+
/* select each object that Keying Set refers to */
/* TODO: perhaps to be more in line with the rest of these, we should only take objects
* if the passed in object is included in this too */
@@ -722,8 +722,8 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList
/* only check for this object if it isn't selected already, to limit time wasted */
if ((base->flag & BASE_SELECTED) == 0) {
KS_Path *ksp;
-
- /* this is the slow way... we could end up with > 500 items here,
+
+ /* this is the slow way... we could end up with > 500 items here,
* with none matching, but end up doing this on 1000 objects...
*/
for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
@@ -737,7 +737,7 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList
}
}
CTX_DATA_END;
-
+
return changed;
}
@@ -822,15 +822,15 @@ void OBJECT_OT_select_grouped(wmOperatorType *ot)
ot->name = "Select Grouped";
ot->description = "Select all visible objects grouped by various properties";
ot->idname = "OBJECT_OT_select_grouped";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = object_select_grouped_exec;
ot->poll = objects_selectable_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first");
ot->prop = RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", "");
@@ -841,7 +841,7 @@ void OBJECT_OT_select_grouped(wmOperatorType *ot)
static int object_select_all_exec(bContext *C, wmOperator *op)
{
int action = RNA_enum_get(op->ptr, "action");
-
+
/* passthrough if no objects are visible */
if (CTX_DATA_COUNT(C, visible_bases) == 0) return OPERATOR_PASS_THROUGH;
@@ -877,24 +877,24 @@ static int object_select_all_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_END;
-
+
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
-
+
return OPERATOR_FINISHED;
}
void OBJECT_OT_select_all(wmOperatorType *ot)
{
-
+
/* identifiers */
ot->name = "(De)select All";
ot->description = "Change selection of all visible objects in scene";
ot->idname = "OBJECT_OT_select_all";
-
+
/* api callbacks */
ot->exec = object_select_all_exec;
ot->poll = objects_selectable_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -905,6 +905,7 @@ void OBJECT_OT_select_all(wmOperatorType *ot)
static int object_select_same_collection_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Collection *collection;
char collection_name[MAX_ID_NAME];
@@ -913,7 +914,7 @@ static int object_select_same_collection_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "collection", collection_name);
- collection = (Collection *)BKE_libblock_find_name(ID_GR, collection_name);
+ collection = (Collection *)BKE_libblock_find_name(bmain, ID_GR, collection_name);
if (!collection) {
return OPERATOR_PASS_THROUGH;
@@ -930,22 +931,22 @@ static int object_select_same_collection_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
-
+
return OPERATOR_FINISHED;
}
void OBJECT_OT_select_same_collection(wmOperatorType *ot)
{
-
+
/* identifiers */
ot->name = "Select Same Collection";
ot->description = "Select object in the same collection";
ot->idname = "OBJECT_OT_select_same_collection";
-
+
/* api callbacks */
ot->exec = object_select_same_collection_exec;
ot->poll = objects_selectable_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -955,20 +956,21 @@ void OBJECT_OT_select_same_collection(wmOperatorType *ot)
/**************************** Select Mirror ****************************/
static int object_select_mirror_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
bool extend;
-
+
extend = RNA_boolean_get(op->ptr, "extend");
-
+
CTX_DATA_BEGIN (C, Base *, primbase, selected_bases)
{
char name_flip[MAXBONENAME];
BLI_string_flip_side_name(name_flip, primbase->object->id.name + 2, true, sizeof(name_flip));
-
+
if (!STREQ(name_flip, primbase->object->id.name + 2)) {
- Object *ob = (Object *)BKE_libblock_find_name(ID_OB, name_flip);
+ Object *ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, name_flip);
if (ob) {
Base *secbase = BKE_view_layer_base_find(view_layer, ob);
@@ -977,33 +979,33 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op)
}
}
}
-
+
if (extend == false) ED_object_base_select(primbase, BA_DESELECT);
-
+
}
CTX_DATA_END;
-
+
/* undo? */
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
-
+
return OPERATOR_FINISHED;
}
void OBJECT_OT_select_mirror(wmOperatorType *ot)
{
-
+
/* identifiers */
ot->name = "Select Mirror";
ot->description = "Select the Mirror objects of the selected object eg. L.sword -> R.sword";
ot->idname = "OBJECT_OT_select_mirror";
-
+
/* api callbacks */
ot->exec = object_select_mirror_exec;
ot->poll = objects_selectable_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first");
}
@@ -1128,7 +1130,7 @@ void OBJECT_OT_select_less(wmOperatorType *ot)
/**************************** Select Random ****************************/
static int object_select_random_exec(bContext *C, wmOperator *op)
-{
+{
const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f;
const int seed = WM_operator_properties_select_random_seed_increment_get(op);
const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
@@ -1146,7 +1148,7 @@ static int object_select_random_exec(bContext *C, wmOperator *op)
BLI_rng_free(rng);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
-
+
return OPERATOR_FINISHED;
}
@@ -1156,15 +1158,15 @@ void OBJECT_OT_select_random(wmOperatorType *ot)
ot->name = "Select Random";
ot->description = "Set select on random visible objects";
ot->idname = "OBJECT_OT_select_random";
-
+
/* api callbacks */
/*ot->invoke = object_select_random_invoke XXX - need a number popup ;*/
ot->exec = object_select_random_exec;
ot->poll = objects_selectable_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
WM_operator_properties_select_random(ot);
}
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c
index 1f80cb5f0bc..03fe6e9de65 100644
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@ -35,7 +35,7 @@
#include <unistd.h>
#else
#include <io.h>
-#endif
+#endif
#include "MEM_guardedalloc.h"
@@ -119,7 +119,7 @@ static bool object_shape_key_mirror(bContext *C, Object *ob,
key = BKE_key_from_object(ob);
if (key == NULL)
return 0;
-
+
kb = BLI_findlink(&key->block, ob->shapenr - 1);
if (kb) {
@@ -211,7 +211,7 @@ static bool object_shape_key_mirror(bContext *C, Object *ob,
MEM_freeN(tag_elem);
}
-
+
*r_totmirr = totmirr;
*r_totfail = totfail;
@@ -278,7 +278,7 @@ void OBJECT_OT_shape_key_add(wmOperatorType *ot)
ot->name = "Add Shape Key";
ot->idname = "OBJECT_OT_shape_key_add";
ot->description = "Add shape key to the object";
-
+
/* api callbacks */
ot->poll = shape_key_mode_poll;
ot->exec = shape_key_add_exec;
@@ -321,7 +321,7 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot)
ot->name = "Remove Shape Key";
ot->idname = "OBJECT_OT_shape_key_remove";
ot->description = "Remove shape key from the object";
-
+
/* api callbacks */
ot->poll = shape_key_mode_exists_poll;
ot->exec = shape_key_remove_exec;
@@ -341,13 +341,13 @@ static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op))
if (!key || !kb)
return OPERATOR_CANCELLED;
-
+
for (kb = key->block.first; kb; kb = kb->next)
kb->curval = 0.0f;
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -357,7 +357,7 @@ void OBJECT_OT_shape_key_clear(wmOperatorType *ot)
ot->name = "Clear Shape Keys";
ot->description = "Clear weights for all shape keys";
ot->idname = "OBJECT_OT_shape_key_clear";
-
+
/* api callbacks */
ot->poll = shape_key_poll;
ot->exec = shape_key_clear_exec;
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 77514ca1e8e..721d248ae4c 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -122,7 +122,7 @@ static void object_clear_rot(Object *ob, const bool clear_delta)
ob->rotAxis[2] = 0.0f;
if (clear_delta) ob->drotAxis[2] = 0.0f;
}
-
+
/* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */
if (IS_EQF(ob->rotAxis[0], ob->rotAxis[1]) && IS_EQF(ob->rotAxis[1], ob->rotAxis[2]))
ob->rotAxis[1] = 1.0f;
@@ -168,7 +168,7 @@ static void object_clear_rot(Object *ob, const bool clear_delta)
/* perform clamping using euler form (3-components) */
/* FIXME: deltas are not handled for these cases yet... */
float eul[3], oldeul[3], quat1[4] = {0};
-
+
if (ob->rotmode == ROT_MODE_QUAT) {
copy_qt_qt(quat1, ob->quat);
quat_to_eul(oldeul, ob->quat);
@@ -179,16 +179,16 @@ static void object_clear_rot(Object *ob, const bool clear_delta)
else {
copy_v3_v3(oldeul, ob->rot);
}
-
+
eul[0] = eul[1] = eul[2] = 0.0f;
-
+
if (ob->protectflag & OB_LOCK_ROTX)
eul[0] = oldeul[0];
if (ob->protectflag & OB_LOCK_ROTY)
eul[1] = oldeul[1];
if (ob->protectflag & OB_LOCK_ROTZ)
eul[2] = oldeul[2];
-
+
if (ob->rotmode == ROT_MODE_QUAT) {
eul_to_quat(ob->quat, eul);
/* quaternions flip w sign to accumulate rotations correctly */
@@ -241,24 +241,24 @@ static void object_clear_scale(Object *ob, const bool clear_delta)
/* --------------- */
/* generic exec for clear-transform operators */
-static int object_clear_transform_generic_exec(bContext *C, wmOperator *op,
+static int object_clear_transform_generic_exec(bContext *C, wmOperator *op,
void (*clear_func)(Object *, const bool),
const char default_ksName[])
{
Scene *scene = CTX_data_scene(C);
KeyingSet *ks;
const bool clear_delta = RNA_boolean_get(op->ptr, "clear_delta");
-
+
/* sanity checks */
if (ELEM(NULL, clear_func, default_ksName)) {
BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform function or keying set name");
return OPERATOR_CANCELLED;
}
-
+
/* get KeyingSet to use */
ks = ANIM_get_keyingset_for_autokeying(scene, default_ksName);
-
- /* operate on selected objects only if they aren't in weight-paint mode
+
+ /* operate on selected objects only if they aren't in weight-paint mode
* (so that object-transform clearing won't be applied at same time as bone-clearing)
*/
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
@@ -266,15 +266,15 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op,
if (!(ob->mode & OB_MODE_WEIGHT_PAINT)) {
/* run provided clearing function */
clear_func(ob, clear_delta);
-
+
ED_autokeyframe_object(C, scene, ob, ks);
-
+
/* tag for updates */
DEG_id_tag_update(&ob->id, OB_RECALC_OB);
}
}
CTX_DATA_END;
-
+
/* this is needed so children are also updated */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
@@ -295,15 +295,15 @@ void OBJECT_OT_location_clear(wmOperatorType *ot)
ot->name = "Clear Location";
ot->description = "Clear the object's location";
ot->idname = "OBJECT_OT_location_clear";
-
+
/* api callbacks */
ot->exec = object_location_clear_exec;
ot->poll = ED_operator_scene_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
-
+
+
/* properties */
ot->prop = RNA_def_boolean(ot->srna, "clear_delta", false, "Clear Delta",
"Clear delta location in addition to clearing the normal location transform");
@@ -320,14 +320,14 @@ void OBJECT_OT_rotation_clear(wmOperatorType *ot)
ot->name = "Clear Rotation";
ot->description = "Clear the object's rotation";
ot->idname = "OBJECT_OT_rotation_clear";
-
+
/* api callbacks */
ot->exec = object_rotation_clear_exec;
ot->poll = ED_operator_scene_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_boolean(ot->srna, "clear_delta", false, "Clear Delta",
"Clear delta rotation in addition to clearing the normal rotation transform");
@@ -344,14 +344,14 @@ void OBJECT_OT_scale_clear(wmOperatorType *ot)
ot->name = "Clear Scale";
ot->description = "Clear the object's scale";
ot->idname = "OBJECT_OT_scale_clear";
-
+
/* api callbacks */
ot->exec = object_scale_clear_exec;
ot->poll = ED_operator_scene_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_boolean(ot->srna, "clear_delta", false, "Clear Delta",
"Clear delta scale in addition to clearing the normal scale transform");
@@ -370,7 +370,7 @@ static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op))
/* vectors pointed to by v1 and v3 will get modified */
v1 = ob->loc;
v3 = ob->parentinv[3];
-
+
copy_m3_m4(mat, ob->parentinv);
negate_v3_v3(v3, v1);
mul_m3_v3(mat, v3);
@@ -381,7 +381,7 @@ static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op))
CTX_DATA_END;
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -391,11 +391,11 @@ void OBJECT_OT_origin_clear(wmOperatorType *ot)
ot->name = "Clear Origin";
ot->description = "Clear the object's origin";
ot->idname = "OBJECT_OT_origin_clear";
-
+
/* api callbacks */
ot->exec = object_origin_clear_exec;
ot->poll = ED_operator_scene_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -409,7 +409,7 @@ static void ignore_parent_tx(const bContext *C, Main *bmain, Scene *scene, Objec
Object workob;
Object *ob_child;
Depsgraph *depsgraph = CTX_data_depsgraph(C);
-
+
/* a change was made, adjust the children to compensate */
for (ob_child = bmain->object.first; ob_child; ob_child = ob_child->id.next) {
if (ob_child->parent == ob) {
@@ -493,7 +493,7 @@ static int apply_objects_internal(
}
}
CTX_DATA_END;
-
+
if (!changed)
return OPERATOR_CANCELLED;
@@ -545,15 +545,15 @@ static int apply_objects_internal(
if (apply_scale)
multiresModifier_scale_disp(depsgraph, scene, ob);
-
+
/* adjust data */
BKE_mesh_transform(me, mat, true);
-
+
/* update normals */
BKE_mesh_calc_normals(me);
}
else if (ob->type == OB_ARMATURE) {
- ED_armature_transform_apply(ob, mat, do_props);
+ ED_armature_transform_apply(bmain, ob, mat, do_props);
}
else if (ob->type == OB_LATTICE) {
Lattice *lt = ob->data;
@@ -600,12 +600,12 @@ static int apply_objects_internal(
BKE_tracking_reconstruction_scale(&clip->tracking, ob->size);
}
else if (ob->type == OB_EMPTY) {
- /* It's possible for empties too, even though they don't
+ /* It's possible for empties too, even though they don't
* really have obdata, since we can simply apply the maximum
* scaling to the empty's drawsize.
*
* Core Assumptions:
- * 1) Most scaled empties have uniform scaling
+ * 1) Most scaled empties have uniform scaling
* (i.e. for visibility reasons), AND/OR
* 2) Preserving non-uniform scaling is not that important,
* and is something that many users would be willing to
@@ -690,7 +690,7 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
/* update for any children that may get moved */
DEG_id_tag_update(&ob->id, OB_RECALC_OB);
-
+
changed = true;
}
CTX_DATA_END;
@@ -708,11 +708,11 @@ void OBJECT_OT_visual_transform_apply(wmOperatorType *ot)
ot->name = "Apply Visual Transform";
ot->description = "Apply the object's visual transformation to its data";
ot->idname = "OBJECT_OT_visual_transform_apply";
-
+
/* api callbacks */
ot->exec = visual_transform_apply_exec;
ot->poll = ED_operator_scene_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -803,7 +803,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
BMEditMesh *em = me->edit_btmesh;
BMVert *eve;
BMIter iter;
-
+
if (centermode == ORIGIN_TO_CURSOR) {
copy_v3_v3(cent, cursor);
invert_m4_m4(obedit->imat, obedit->obmat);
@@ -827,7 +827,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
mid_v3_v3v3(cent, min, max);
}
}
-
+
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
sub_v3_v3(eve->co, cent);
}
@@ -880,7 +880,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
invert_m4_m4(ob->imat, ob->obmat);
mul_m4_v3(ob->imat, cent);
}
-
+
if (ob->data == NULL) {
/* special support for dupligroups */
if ((ob->transflag & OB_DUPLICOLLECTION) && ob->dup_group && (ob->dup_group->id.tag & LIB_TAG_DOIT) == 0) {
@@ -900,7 +900,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
invert_m4_m4(ob->imat, ob->obmat);
mul_m4_v3(ob->imat, cent);
}
-
+
add_v3_v3(ob->dup_group->dupli_ofs, cent);
tot_change++;
@@ -1006,7 +1006,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
/* Function to recenter armatures in editarmature.c
* Bone + object locations are handled there.
*/
- ED_armature_origin_set(ob, cursor, centermode, around);
+ ED_armature_origin_set(bmain, ob, cursor, centermode, around);
tot_change++;
arm->id.tag |= LIB_TAG_DOIT;
@@ -1077,7 +1077,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
}
ignore_parent_tx(C, bmain, scene, ob);
-
+
/* other users? */
//CTX_DATA_BEGIN (C, Object *, ob_other, selected_editable_objects)
//{
@@ -1151,27 +1151,27 @@ void OBJECT_OT_origin_set(wmOperatorType *ot)
"Calculate the center of mass from the volume (must be manifold geometry with consistent normals)"},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem prop_set_bounds_types[] = {
{V3D_AROUND_CENTER_MEAN, "MEDIAN", 0, "Median Center", ""},
{V3D_AROUND_CENTER_BOUNDS, "BOUNDS", 0, "Bounds Center", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "Set Origin";
ot->description = "Set the object's origin, by either moving the data, or set to center of data, or use 3D cursor";
ot->idname = "OBJECT_OT_origin_set";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = object_origin_set_exec;
-
+
ot->poll = ED_operator_scene_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
ot->prop = RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", "");
RNA_def_enum(ot->srna, "center", prop_set_bounds_types, V3D_AROUND_CENTER_MEAN, "Center", "");
}
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index ff40aa07cd2..84786024160 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -58,6 +58,7 @@
#include "BKE_customdata.h"
#include "BKE_deform.h"
#include "BKE_mesh_mapping.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_editmesh.h"
#include "BKE_layer.h"
#include "BKE_modifier.h"
@@ -772,7 +773,7 @@ static void ED_vgroup_nr_vert_add(
/* get the vert */
BKE_object_defgroup_array_get(ob->data, &dvert, &tot);
-
+
if (dvert == NULL)
return;
@@ -937,7 +938,7 @@ static float get_vert_def_nr(Object *ob, const int def_nr, const int vertnum)
dv = &lt->dvert[vertnum];
}
}
-
+
if (dv) {
MDeformWeight *dw = defvert_find_index(dv, def_nr);
if (dw) {
@@ -1024,12 +1025,12 @@ static void vgroup_select_verts(Object *ob, int select)
}
else if (ob->type == OB_LATTICE) {
Lattice *lt = vgroup_edit_lattice(ob);
-
+
if (lt->dvert) {
MDeformVert *dv;
BPoint *bp, *actbp = BKE_lattice_active_point_get(lt);
int a, tot;
-
+
dv = lt->dvert;
tot = lt->pntsu * lt->pntsv * lt->pntsw;
@@ -1057,7 +1058,7 @@ static void vgroup_duplicate(Object *ob)
dg = BLI_findlink(&ob->defbase, (ob->actdef - 1));
if (!dg)
return;
-
+
if (!strstr(dg->name, "_copy")) {
BLI_snprintf(name, sizeof(name), "%s_copy", dg->name);
}
@@ -1127,7 +1128,7 @@ static bool vgroup_normalize(Object *ob)
if (weight_max > 0.0f) {
for (i = 0; i < dvert_tot; i++) {
-
+
/* in case its not selected */
if (!(dv = dvert_array[i])) {
continue;
@@ -1136,7 +1137,7 @@ static bool vgroup_normalize(Object *ob)
dw = defvert_find_index(dv, def_nr);
if (dw) {
dw->weight /= weight_max;
-
+
/* in case of division errors with very low weights */
CLAMP(dw->weight, 0.0f, 1.0f);
}
@@ -1461,7 +1462,7 @@ static void moveCloserToDistanceFromPlane(
MEM_freeN(dwIndices);
}
-/* this is used to try to smooth a surface by only adjusting the nonzero weights of a vertex
+/* this is used to try to smooth a surface by only adjusting the nonzero weights of a vertex
* but it could be used to raise or lower an existing 'bump.' */
static void vgroup_fix(const bContext *C, Scene *scene, Object *ob, float distToBe, float strength, float cp)
{
@@ -1487,7 +1488,7 @@ static void vgroup_fix(const bContext *C, Scene *scene, Object *ob, float distTo
dm->getVert(dm, verts[k], &m);
p[k] = m;
}
-
+
if (count >= 3) {
float d /*, dist */ /* UNUSED */, mag;
float coord[3];
@@ -2642,7 +2643,7 @@ static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -2652,7 +2653,7 @@ void OBJECT_OT_vertex_group_add(wmOperatorType *ot)
ot->name = "Add Vertex Group";
ot->idname = "OBJECT_OT_vertex_group_add";
ot->description = "Add a new vertex group to the active object";
-
+
/* api callbacks */
ot->poll = vertex_group_supported_poll;
ot->exec = vertex_group_add_exec;
@@ -2675,7 +2676,7 @@ static int vertex_group_remove_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -2685,7 +2686,7 @@ void OBJECT_OT_vertex_group_remove(wmOperatorType *ot)
ot->name = "Remove Vertex Group";
ot->idname = "OBJECT_OT_vertex_group_remove";
ot->description = "Delete the active or all vertex groups from the active object";
-
+
/* api callbacks */
ot->poll = vertex_group_poll;
ot->exec = vertex_group_remove_exec;
@@ -2705,11 +2706,11 @@ static int vertex_group_assign_exec(bContext *C, wmOperator *UNUSED(op))
{
ToolSettings *ts = CTX_data_tool_settings(C);
Object *ob = ED_object_context(C);
-
+
vgroup_assign_verts(ob, ts->vgroup_weight);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
-
+
return OPERATOR_FINISHED;
}
@@ -2719,7 +2720,7 @@ void OBJECT_OT_vertex_group_assign(wmOperatorType *ot)
ot->name = "Assign to Vertex Group";
ot->idname = "OBJECT_OT_vertex_group_assign";
ot->description = "Assign the selected vertices to the active vertex group";
-
+
/* api callbacks */
ot->poll = vertex_group_vert_select_unlocked_poll;
ot->exec = vertex_group_assign_exec;
@@ -2737,7 +2738,7 @@ static int vertex_group_assign_new_exec(bContext *C, wmOperator *op)
/* create new group... */
Object *ob = ED_object_context(C);
BKE_object_defgroup_add(ob);
-
+
/* assign selection to new group */
return vertex_group_assign_exec(C, op);
}
@@ -2748,11 +2749,11 @@ void OBJECT_OT_vertex_group_assign_new(wmOperatorType *ot)
ot->name = "Assign to New Group";
ot->idname = "OBJECT_OT_vertex_group_assign_new";
ot->description = "Assign the selected vertices to a new vertex group";
-
+
/* api callbacks */
ot->poll = vertex_group_vert_select_poll;
ot->exec = vertex_group_assign_new_exec;
-
+
/* flags */
/* redo operator will fail in this case because vertex group assignment
* isn't stored in local edit mode stack and toggling "new" property will
@@ -2894,7 +2895,7 @@ void OBJECT_OT_vertex_group_copy(wmOperatorType *ot)
static int vertex_group_levels_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
-
+
float offset = RNA_float_get(op->ptr, "offset");
float gain = RNA_float_get(op->ptr, "gain");
eVGroupSelect subset_type = RNA_enum_get(op->ptr, "group_select_mode");
@@ -2904,11 +2905,11 @@ static int vertex_group_levels_exec(bContext *C, wmOperator *op)
const bool *vgroup_validmap = BKE_object_defgroup_subset_from_select_type(ob, subset_type, &vgroup_tot, &subset_count);
vgroup_levels_subset(ob, vgroup_validmap, vgroup_tot, subset_count, offset, gain);
MEM_freeN((void *)vgroup_validmap);
-
+
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
-
+
return OPERATOR_FINISHED;
}
@@ -2918,14 +2919,14 @@ void OBJECT_OT_vertex_group_levels(wmOperatorType *ot)
ot->name = "Vertex Group Levels";
ot->idname = "OBJECT_OT_vertex_group_levels";
ot->description = "Add some offset and multiply with some gain the weights of the active vertex group";
-
+
/* api callbacks */
ot->poll = vertex_group_poll;
ot->exec = vertex_group_levels_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
vgroup_operator_subset_select_props(ot, true);
RNA_def_float(ot->srna, "offset", 0.f, -1.0, 1.0, "Offset", "Value to add to weights", -1.0f, 1.f);
RNA_def_float(ot->srna, "gain", 1.f, 0.f, FLT_MAX, "Gain", "Value to multiply weights by", 0.0f, 10.f);
@@ -3014,7 +3015,7 @@ static int vertex_group_fix_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);
-
+
float distToBe = RNA_float_get(op->ptr, "dist");
float strength = RNA_float_get(op->ptr, "strength");
float cp = RNA_float_get(op->ptr, "accuracy");
@@ -3026,17 +3027,17 @@ static int vertex_group_fix_exec(bContext *C, wmOperator *op)
}
md = md->next;
}
-
+
if (md && md->type == eModifierType_Mirror) {
BKE_report(op->reports, RPT_ERROR_INVALID_CONTEXT, "This operator does not support an active mirror modifier");
return OPERATOR_CANCELLED;
}
vgroup_fix(C, scene, ob, distToBe, strength, cp);
-
+
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
-
+
return OPERATOR_FINISHED;
}
@@ -3047,11 +3048,11 @@ void OBJECT_OT_vertex_group_fix(wmOperatorType *ot)
ot->idname = "OBJECT_OT_vertex_group_fix";
ot->description = "Modify the position of selected vertices by changing only their respective "
"groups' weights (this tool may be slow for many vertices)";
-
+
/* api callbacks */
ot->poll = vertex_group_mesh_poll;
ot->exec = vertex_group_fix_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_float(ot->srna, "dist", 0.0f, -FLT_MAX, FLT_MAX, "Distance", "The distance to move to", -10.0f, 10.0f);
@@ -3449,16 +3450,16 @@ static int set_active_group_exec(bContext *C, wmOperator *op)
}
static const EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
-{
+{
Object *ob = ED_object_context(C);
EnumPropertyItem tmp = {0, "", 0, "", ""};
EnumPropertyItem *item = NULL;
bDeformGroup *def;
int a, totitem = 0;
-
+
if (!ob)
return DummyRNA_NULL_items;
-
+
for (a = 0, def = ob->defbase.first; def; def = def->next, a++) {
tmp.value = a;
tmp.icon = ICON_GROUP_VERTEX;
@@ -3583,7 +3584,7 @@ static int vgroup_do_remap(Object *ob, const char *name_array, wmOperator *op)
BLI_assert(sort_map_update[ob->actdef] >= 0);
ob->actdef = sort_map_update[ob->actdef];
-
+
MEM_freeN(sort_map_update);
return OPERATOR_FINISHED;
@@ -3651,7 +3652,7 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op)
vgroup_sort_bone_hierarchy(ob, NULL);
break;
}
-
+
/*remap vgroup data to map to correct names*/
ret = vgroup_do_remap(ob, name_array, op);
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index 6dee6825b31..f45ee050ef9 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -102,7 +102,7 @@ void DPAINT_OT_surface_slot_add(wmOperatorType *ot)
ot->name = "Add Surface Slot";
ot->idname = "DPAINT_OT_surface_slot_add";
ot->description = "Add a new Dynamic Paint surface slot";
-
+
/* api callbacks */
ot->exec = surface_slot_add_exec;
ot->poll = ED_operator_object_active_editable;
@@ -150,7 +150,7 @@ void DPAINT_OT_surface_slot_remove(wmOperatorType *ot)
ot->name = "Remove Surface Slot";
ot->idname = "DPAINT_OT_surface_slot_remove";
ot->description = "Remove the selected surface slot";
-
+
/* api callbacks */
ot->exec = surface_slot_remove_exec;
ot->poll = ED_operator_object_active_editable;
@@ -181,7 +181,7 @@ static int type_toggle_exec(bContext *C, wmOperator *op)
if (!dynamicPaint_createType(pmd, type, scene))
return OPERATOR_CANCELLED;
}
-
+
/* update dependency */
DEG_id_tag_update(&cObject->id, OB_RECALC_DATA);
DEG_relations_tag_update(CTX_data_main(C));
@@ -198,14 +198,14 @@ void DPAINT_OT_type_toggle(wmOperatorType *ot)
ot->name = "Toggle Type Active";
ot->idname = "DPAINT_OT_type_toggle";
ot->description = "Toggle whether given type is active or not";
-
+
/* api callbacks */
ot->exec = type_toggle_exec;
ot->poll = ED_operator_object_active_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
prop = RNA_def_enum(ot->srna, "type", rna_enum_prop_dynamicpaint_type_items, MOD_DYNAMICPAINT_TYPE_CANVAS, "Type", "");
ot->prop = prop;
@@ -225,7 +225,7 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
int exists = dynamicPaint_outputLayerExists(surface, ob, output);
const char *name;
-
+
if (output == 0)
name = surface->output_name;
else
@@ -235,7 +235,7 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
if (!exists)
ED_mesh_color_add(ob->data, name, true);
- else
+ else
ED_mesh_color_remove_named(ob->data, name);
}
/* Vertex Weight Layer */
@@ -265,14 +265,14 @@ void DPAINT_OT_output_toggle(wmOperatorType *ot)
ot->name = "Toggle Output Layer";
ot->idname = "DPAINT_OT_output_toggle";
ot->description = "Add or remove Dynamic Paint output data layer";
-
+
/* api callbacks */
ot->exec = output_toggle_exec;
ot->poll = ED_operator_object_active_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "output", prop_output_toggle_types, 0, "Output Toggle", "");
}
@@ -509,7 +509,7 @@ void DPAINT_OT_bake(wmOperatorType *ot)
ot->name = "Dynamic Paint Bake";
ot->description = "Bake dynamic paint image sequence surface";
ot->idname = "DPAINT_OT_bake";
-
+
/* api callbacks */
ot->exec = dynamicpaint_bake_exec;
ot->poll = ED_operator_object_active_editable;
diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c
index 681ac75e847..57b22991f94 100644
--- a/source/blender/editors/physics/particle_boids.c
+++ b/source/blender/editors/physics/particle_boids.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -78,7 +78,7 @@ static int rule_add_exec(bContext *C, wmOperator *op)
BLI_addtail(&state->rules, rule);
DEG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
-
+
return OPERATOR_FINISHED;
}
@@ -88,14 +88,14 @@ void BOID_OT_rule_add(wmOperatorType *ot)
ot->name = "Add Boid Rule";
ot->description = "Add a boid rule to the current boid state";
ot->idname = "BOID_OT_rule_add";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = rule_add_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
-
+
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_boidrule_type_items, 0, "Type", "");
}
static int rule_del_exec(bContext *C, wmOperator *UNUSED(op))
@@ -135,7 +135,7 @@ void BOID_OT_rule_del(wmOperatorType *ot)
ot->name = "Remove Boid Rule";
ot->idname = "BOID_OT_rule_del";
ot->description = "Delete current boid rule";
-
+
/* api callbacks */
ot->exec = rule_del_exec;
@@ -153,7 +153,7 @@ static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op))
if (!part || part->phystype != PART_PHYS_BOIDS)
return OPERATOR_CANCELLED;
-
+
state = boid_get_current_state(part->boids);
for (rule = state->rules.first; rule; rule=rule->next) {
if (rule->flag & BOIDRULE_CURRENT && rule->prev) {
@@ -164,7 +164,7 @@ static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
-
+
return OPERATOR_FINISHED;
}
@@ -175,7 +175,7 @@ void BOID_OT_rule_move_up(wmOperatorType *ot)
ot->idname = "BOID_OT_rule_move_up";
ot->exec = rule_move_up_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -189,7 +189,7 @@ static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op))
if (!part || part->phystype != PART_PHYS_BOIDS)
return OPERATOR_CANCELLED;
-
+
state = boid_get_current_state(part->boids);
for (rule = state->rules.first; rule; rule=rule->next) {
if (rule->flag & BOIDRULE_CURRENT && rule->next) {
@@ -200,7 +200,7 @@ static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
-
+
return OPERATOR_FINISHED;
}
@@ -211,7 +211,7 @@ void BOID_OT_rule_move_down(wmOperatorType *ot)
ot->idname = "BOID_OT_rule_move_down";
ot->exec = rule_move_down_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -244,10 +244,10 @@ void BOID_OT_state_add(wmOperatorType *ot)
ot->name = "Add Boid State";
ot->description = "Add a boid state to the particle system";
ot->idname = "BOID_OT_state_add";
-
+
/* api callbacks */
ot->exec = state_add_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -281,7 +281,7 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
DEG_relations_tag_update(bmain);
DEG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
-
+
return OPERATOR_FINISHED;
}
@@ -291,7 +291,7 @@ void BOID_OT_state_del(wmOperatorType *ot)
ot->name = "Remove Boid State";
ot->idname = "BOID_OT_state_del";
ot->description = "Delete current boid state";
-
+
/* api callbacks */
ot->exec = state_del_exec;
@@ -311,7 +311,7 @@ static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
boids = part->boids;
-
+
for (state = boids->states.first; state; state=state->next) {
if (state->flag & BOIDSTATE_CURRENT && state->prev) {
BLI_remlink(&boids->states, state);
@@ -319,7 +319,7 @@ static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
-
+
return OPERATOR_FINISHED;
}
@@ -330,7 +330,7 @@ void BOID_OT_state_move_up(wmOperatorType *ot)
ot->idname = "BOID_OT_state_move_up";
ot->exec = state_move_up_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -346,7 +346,7 @@ static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
boids = part->boids;
-
+
for (state = boids->states.first; state; state=state->next) {
if (state->flag & BOIDSTATE_CURRENT && state->next) {
BLI_remlink(&boids->states, state);
@@ -355,7 +355,7 @@ static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
-
+
return OPERATOR_FINISHED;
}
@@ -366,7 +366,7 @@ void BOID_OT_state_move_down(wmOperatorType *ot)
ot->idname = "BOID_OT_state_move_down";
ot->exec = state_move_down_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index b8a5c138a57..359e9365ea7 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -57,9 +57,11 @@
#include "BKE_object.h"
#include "BKE_library.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_particle.h"
#include "BKE_report.h"
+#include "BKE_scene.h"
#include "BKE_bvhutils.h"
#include "BKE_pointcache.h"
@@ -189,7 +191,7 @@ static float pe_brush_size_get(const Scene *UNUSED(scene), ParticleBrushData *br
// here we can enable unified brush size, needs more work...
// UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
// float size = (ups->flag & UNIFIED_PAINT_SIZE) ? ups->size : brush->size;
-
+
return brush->size * U.pixelsize;
}
@@ -260,8 +262,7 @@ static PTCacheEdit *pe_get_current(
}
else {
if (create && !psys->edit) {
- ParticleSystem *psys_eval = psys_eval_get(depsgraph, ob, psys);
- if (psys_eval->flag & PSYS_HAIR_DONE) {
+ if (psys->flag & PSYS_HAIR_DONE) {
PE_create_particle_edit(depsgraph, scene, ob, NULL, psys);
}
}
@@ -353,7 +354,7 @@ static int pe_x_mirror(Object *ob)
{
if (ob->type == OB_MESH)
return (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X);
-
+
return 0;
}
@@ -361,7 +362,7 @@ static int pe_x_mirror(Object *ob)
typedef struct PEData {
ViewContext vc;
-
+
const bContext *context;
Scene *scene;
ViewLayer *view_layer;
@@ -428,18 +429,14 @@ static void PE_set_view3d_data(bContext *C, PEData *data)
static bool PE_create_shape_tree(PEData *data, Object *shapeob)
{
- ModifierEvalContext ctx = {
- .depsgraph = data->depsgraph,
- .flag = 0,
- };
- Mesh *mesh = BKE_modifier_get_evaluated_mesh_from_object(&ctx, shapeob);
-
+ Mesh *mesh = BKE_object_get_evaluated_mesh(data->depsgraph, shapeob);
+
memset(&data->shape_bvh, 0, sizeof(data->shape_bvh));
-
+
if (!mesh) {
return false;
}
-
+
return (BKE_bvhtree_from_mesh_get(&data->shape_bvh, mesh, BVHTREE_FROM_LOOPTRI, 4) != NULL);
}
@@ -510,7 +507,7 @@ static bool key_inside_circle(PEData *data, float rad, const float co[3], float
return 1;
}
-
+
return 0;
}
@@ -549,7 +546,7 @@ static bool point_is_selected(PTCacheEditPoint *point)
LOOP_SELECTED_KEYS {
return 1;
}
-
+
return 0;
}
@@ -647,11 +644,9 @@ static void foreach_mouse_hit_point(PEData *data, ForPointFunc func, int selecte
static void foreach_mouse_hit_key(PEData *data, ForKeyMatFunc func, int selected)
{
- Object *ob_eval = DEG_get_evaluated_object(data->depsgraph, data->ob);
PTCacheEdit *edit = data->edit;
ParticleSystem *psys = edit->psys;
ParticleSystemModifierData *psmd = NULL;
- ParticleSystemModifierData *psmd_eval = NULL;
ParticleEditSettings *pset= PE_settings(data->scene);
POINT_P; KEY_K;
float mat[4][4], imat[4][4];
@@ -662,10 +657,6 @@ static void foreach_mouse_hit_key(PEData *data, ForKeyMatFunc func, int selected
if (edit->psys)
psmd= psys_get_modifier(data->ob, edit->psys);
- if (psmd != NULL) {
- psmd_eval = (ParticleSystemModifierData *)modifiers_findByName(ob_eval, psmd->modifier.name);
- }
-
/* all is selected in path mode */
if (pset->selectmode==SCE_SELECT_PATH)
selected= 0;
@@ -679,7 +670,7 @@ static void foreach_mouse_hit_key(PEData *data, ForKeyMatFunc func, int selected
if (selected==0 || key->flag & PEK_SELECT) {
if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) {
if (edit->psys && !(edit->psys->flag & PSYS_GLOBAL_HAIR)) {
- psys_mat_hair_to_global(data->ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat);
+ psys_mat_hair_to_global(data->ob, psmd->mesh_final, psys->part->from, psys->particles + p, mat);
invert_m4_m4(imat, mat);
}
@@ -694,7 +685,7 @@ static void foreach_mouse_hit_key(PEData *data, ForKeyMatFunc func, int selected
if (selected==0 || key->flag & PEK_SELECT) {
if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) {
if (edit->psys && !(edit->psys->flag & PSYS_GLOBAL_HAIR)) {
- psys_mat_hair_to_global(data->ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat);
+ psys_mat_hair_to_global(data->ob, psmd->mesh_final, psys->part->from, psys->particles + p, mat);
invert_m4_m4(imat, mat);
}
@@ -800,7 +791,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
/* lookup particles and set in mirror cache */
if (!edit->mirror_cache)
edit->mirror_cache= MEM_callocN(sizeof(int)*totpart, "PE mirror cache");
-
+
LOOP_PARTICLES {
key = pa->hair;
psys_mat_hair_to_orco(ob, psmd->mesh_final, psys->part->from, pa, mat);
@@ -845,7 +836,7 @@ static void PE_mirror_particle(Object *ob, Mesh *mesh, ParticleSystem *psys, Par
if (!mpa) {
if (!edit->mirror_cache)
PE_update_mirror_cache(ob, psys);
-
+
if (!edit->mirror_cache)
return; /* something went wrong! */
@@ -971,7 +962,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
LOOP_EDITED_POINTS {
psys_mat_hair_to_object(ob, psmd->mesh_final, psys->part->from, psys->particles + p, hairmat);
-
+
LOOP_KEYS {
mul_m4_v3(hairmat, key->co);
}
@@ -983,7 +974,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
}
else {
index= BLI_kdtree_find_nearest(edit->emitter_field, key->co, NULL);
-
+
vec=edit->emitter_cosnos +index*6;
nor=vec+3;
@@ -1008,7 +999,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
dist_1st*=1.3333f;
}
}
-
+
invert_m4_m4(hairimat, hairmat);
LOOP_KEYS {
@@ -1019,7 +1010,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
/* force set distances between neighboring keys */
static void PE_apply_lengths(Scene *scene, PTCacheEdit *edit)
{
-
+
ParticleEditSettings *pset=PE_settings(scene);
POINT_P; KEY_K;
float dv1[3];
@@ -1113,11 +1104,9 @@ void recalc_lengths(PTCacheEdit *edit)
}
/* calculate a tree for finding nearest emitter's vertice */
-void recalc_emitter_field(Depsgraph *depsgraph, Object *ob, ParticleSystem *psys)
+void recalc_emitter_field(Depsgraph *UNUSED(depsgraph), Object *ob, ParticleSystem *psys)
{
- Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
- ParticleSystem *psys_eval = psys_eval_get(depsgraph, ob, psys);
- Mesh *mesh = psys_get_modifier(object_eval, psys_eval)->mesh_final;
+ Mesh *mesh = psys_get_modifier(ob, psys)->mesh_final;
PTCacheEdit *edit = psys->edit;
float *vec, *nor;
int i, totface /*, totvert*/;
@@ -1160,7 +1149,7 @@ void recalc_emitter_field(Depsgraph *depsgraph, Object *ob, ParticleSystem *psys
mvert = &mesh->mvert[mface->v4];
add_v3_v3v3(vec, vec, mvert->co);
VECADD(nor, nor, mvert->no);
-
+
mul_v3_fl(vec, 0.25);
}
else
@@ -1185,7 +1174,7 @@ static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob,
LOOP_POINTS
point->flag |= PEP_EDIT_RECALC;
- /* flush edit key flag to hair key flag to preserve selection
+ /* flush edit key flag to hair key flag to preserve selection
* on save */
if (edit->psys) LOOP_POINTS {
hkey = edit->psys->particles[p].hair;
@@ -1205,27 +1194,19 @@ static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob,
DEG_id_tag_update(&ob->id, DEG_TAG_SELECT_UPDATE);
}
-void update_world_cos(Depsgraph *depsgraph, Object *ob, PTCacheEdit *edit)
+void update_world_cos(Depsgraph *UNUSED(depsgraph), Object *ob, PTCacheEdit *edit)
{
- Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
ParticleSystem *psys = edit->psys;
- ParticleSystem *psys_eval = NULL;
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
- ParticleSystemModifierData *psmd_eval = NULL;
POINT_P; KEY_K;
float hairmat[4][4];
- if (psmd != NULL) {
- psmd_eval = (ParticleSystemModifierData *)modifiers_findByName(ob_eval, psmd->modifier.name);
- psys_eval = psmd_eval->psys;
- }
-
- if (psys == 0 || psys->edit == 0 || psmd_eval->mesh_final == NULL)
+ if (psys == 0 || psys->edit == 0 || psmd->mesh_final == NULL)
return;
LOOP_POINTS {
if (!(psys->flag & PSYS_GLOBAL_HAIR))
- psys_mat_hair_to_global(ob_eval, psmd_eval->mesh_final, psys->part->from, psys_eval->particles+p, hairmat);
+ psys_mat_hair_to_global(ob, psmd->mesh_final, psys->part->from, psys->particles+p, hairmat);
LOOP_KEYS {
copy_v3_v3(key->world_co, key->co);
@@ -1280,7 +1261,7 @@ static void update_velocities(PTCacheEdit *edit)
}
else {
dfra = *(key+1)->time - *(key-1)->time;
-
+
if (dfra <= 0.0f)
continue;
@@ -1468,7 +1449,7 @@ void PARTICLE_OT_select_all(wmOperatorType *ot)
ot->name = "(De)select All";
ot->idname = "PARTICLE_OT_select_all";
ot->description = "(De)select all particles' keys";
-
+
/* api callbacks */
ot->exec = pe_select_all_exec;
ot->poll = PE_poll;
@@ -1528,7 +1509,7 @@ static void select_root(PEData *data, int point_index)
if (point->flag & PEP_HIDE)
return;
-
+
if (data->select_action != SEL_TOGGLE)
select_action_apply(point, key, data->select_action);
else if (key->flag & PEK_SELECT)
@@ -1566,7 +1547,7 @@ void PARTICLE_OT_select_roots(wmOperatorType *ot)
ot->name = "Select Roots";
ot->idname = "PARTICLE_OT_select_roots";
ot->description = "Select roots of all visible particles";
-
+
/* api callbacks */
ot->exec = select_roots_exec;
ot->poll = PE_poll;
@@ -1590,10 +1571,10 @@ static void select_tip(PEData *data, int point_index)
}
key = &point->keys[point->totkey - 1];
-
+
if (point->flag & PEP_HIDE)
return;
-
+
if (data->select_action != SEL_TOGGLE)
select_action_apply(point, key, data->select_action);
else if (key->flag & PEK_SELECT)
@@ -1765,7 +1746,7 @@ void PARTICLE_OT_select_linked(wmOperatorType *ot)
ot->name = "Select Linked";
ot->idname = "PARTICLE_OT_select_linked";
ot->description = "Select nearest particle from mouse pointer";
-
+
/* api callbacks */
ot->exec = select_linked_exec;
ot->invoke = select_linked_invoke;
@@ -1973,7 +1954,7 @@ void PARTICLE_OT_hide(wmOperatorType *ot)
ot->name = "Hide Selected";
ot->idname = "PARTICLE_OT_hide";
ot->description = "Hide selected particles";
-
+
/* api callbacks */
ot->exec = hide_exec;
ot->poll = PE_poll;
@@ -2019,7 +2000,7 @@ void PARTICLE_OT_reveal(wmOperatorType *ot)
ot->name = "Reveal";
ot->idname = "PARTICLE_OT_reveal";
ot->description = "Show hidden particles";
-
+
/* api callbacks */
ot->exec = reveal_exec;
ot->poll = PE_poll;
@@ -2081,7 +2062,7 @@ void PARTICLE_OT_select_less(wmOperatorType *ot)
ot->name = "Select Less";
ot->idname = "PARTICLE_OT_select_less";
ot->description = "Deselect boundary selected keys of each particle";
-
+
/* api callbacks */
ot->exec = select_less_exec;
ot->poll = PE_poll;
@@ -2143,7 +2124,7 @@ void PARTICLE_OT_select_more(wmOperatorType *ot)
ot->name = "Select More";
ot->idname = "PARTICLE_OT_select_more";
ot->description = "Select keys linked to boundary selected keys of each particle";
-
+
/* api callbacks */
ot->exec = select_more_exec;
ot->poll = PE_poll;
@@ -2204,7 +2185,7 @@ static void rekey_particle(PEData *data, int pa_index)
if (point->keys)
MEM_freeN(point->keys);
ekey= point->keys= MEM_callocN(pa->totkey * sizeof(PTCacheEditKey), "Hair re-key edit keys");
-
+
for (k=0, key=pa->hair; k<pa->totkey; k++, key++, ekey++) {
ekey->co= key->co;
ekey->time= &key->time;
@@ -2227,7 +2208,7 @@ static int rekey_exec(bContext *C, wmOperator *op)
data.totrekey= RNA_int_get(op->ptr, "keys_number");
foreach_selected_point(&data, rekey_particle);
-
+
recalc_lengths(data.edit);
PE_update_object(data.depsgraph, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob);
@@ -2241,7 +2222,7 @@ void PARTICLE_OT_rekey(wmOperatorType *ot)
ot->name = "Rekey";
ot->idname = "PARTICLE_OT_rekey";
ot->description = "Change the number of keys of selected particles (root and tip keys included)";
-
+
/* api callbacks */
ot->exec = rekey_exec;
ot->invoke = WM_operator_props_popup;
@@ -2279,7 +2260,7 @@ static void rekey_particle_to_time(const bContext *C, Scene *scene, Object *ob,
pa->flag |= PARS_REKEY;
key= new_keys= MEM_dupallocN(pa->hair);
-
+
/* interpolate new keys from old ones (roots stay the same) */
for (k=1, key++; k < pa->totkey; k++, key++) {
state.time= path_time * (float)k / (float)(pa->totkey-1);
@@ -2438,7 +2419,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys)
nhkey->editflag = hkey->editflag;
nhkey->time= hkey->time;
nhkey->weight= hkey->weight;
-
+
nkey->co= nhkey->co;
nkey->time= &nhkey->time;
/* these can be copied from old edit keys */
@@ -2457,7 +2438,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys)
if (point->keys)
MEM_freeN(point->keys);
-
+
pa->hair= new_hkeys;
point->keys= new_keys;
@@ -2503,7 +2484,7 @@ static void subdivide_particle(PEData *data, int pa_index)
nkey= new_keys= MEM_callocN((pa->totkey+totnewkey)*(sizeof(HairKey)), "Hair subdivide keys");
nekey= new_ekeys= MEM_callocN((pa->totkey+totnewkey)*(sizeof(PTCacheEditKey)), "Hair subdivide edit keys");
-
+
key = pa->hair;
endtime= key[pa->totkey-1].time;
@@ -2560,7 +2541,7 @@ static int subdivide_exec(bContext *C, wmOperator *UNUSED(op))
PE_set_data(C, &data);
foreach_point(&data, subdivide_particle);
-
+
recalc_lengths(data.edit);
PE_update_object(data.depsgraph, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob);
@@ -2574,7 +2555,7 @@ void PARTICLE_OT_subdivide(wmOperatorType *ot)
ot->name = "Subdivide";
ot->idname = "PARTICLE_OT_subdivide";
ot->description = "Subdivide selected particles segments (adds keys)";
-
+
/* api callbacks */
ot->exec = subdivide_exec;
ot->poll = PE_hair_poll;
@@ -2609,7 +2590,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
removed= 0;
tree=BLI_kdtree_new(psys->totpart);
-
+
/* insert particles into kd tree */
LOOP_SELECTED_POINTS {
psys_mat_hair_to_object(ob, psmd->mesh_final, psys->part->from, psys->particles+p, mat);
@@ -2663,7 +2644,7 @@ void PARTICLE_OT_remove_doubles(wmOperatorType *ot)
ot->name = "Remove Doubles";
ot->idname = "PARTICLE_OT_remove_doubles";
ot->description = "Remove selected particles close enough of others";
-
+
/* api callbacks */
ot->exec = remove_doubles_exec;
ot->poll = PE_hair_poll;
@@ -2824,7 +2805,7 @@ void PARTICLE_OT_delete(wmOperatorType *ot)
ot->name = "Delete";
ot->idname = "PARTICLE_OT_delete";
ot->description = "Delete selected particles or keys";
-
+
/* api callbacks */
ot->exec = delete_exec;
ot->invoke = WM_menu_invoke;
@@ -2918,7 +2899,7 @@ static void PE_mirror_x(
}
edit->totpoint= psys->totpart= newtotpart;
-
+
/* create new elements */
newpa= psys->particles + totpart;
newpoint= edit->points + totpart;
@@ -2993,7 +2974,7 @@ static int mirror_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene= CTX_data_scene(C);
Object *ob= CTX_data_active_object(C);
PTCacheEdit *edit= PE_get_current(scene, ob);
-
+
PE_mirror_x(scene, ob, 0);
update_world_cos(CTX_data_depsgraph(C), ob, edit);
@@ -3009,7 +2990,7 @@ void PARTICLE_OT_mirror(wmOperatorType *ot)
ot->name = "Mirror";
ot->idname = "PARTICLE_OT_mirror";
ot->description = "Duplicate and mirror the selected particles along the local X axis";
-
+
/* api callbacks */
ot->exec = mirror_exec;
ot->poll = PE_hair_poll;
@@ -3068,7 +3049,7 @@ static void brush_cut(PEData *data, int pa_index)
o0= (float)data->mval[0];
o1= (float)data->mval[1];
-
+
xo0= x0 - o0;
xo1= x1 - o1;
@@ -3098,7 +3079,7 @@ static void brush_cut(PEData *data, int pa_index)
dv= v0*v0 + v1*v1;
d= (v0*xo1 - v1*xo0);
-
+
d= dv * rad2 - d*d;
if (d > 0.0f) {
@@ -3331,7 +3312,7 @@ static void BKE_brush_weight_get(PEData *data, float UNUSED(mat[4][4]), float UN
}
static void brush_smooth_get(PEData *data, float mat[4][4], float UNUSED(imat[4][4]), int UNUSED(point_index), int key_index, PTCacheEditKey *key)
-{
+{
if (key_index) {
float dvec[3];
@@ -3345,7 +3326,7 @@ static void brush_smooth_get(PEData *data, float mat[4][4], float UNUSED(imat[4]
static void brush_smooth_do(PEData *data, float UNUSED(mat[4][4]), float imat[4][4], int point_index, int key_index, PTCacheEditKey *key)
{
float vec[3], dvec[3];
-
+
if (key_index) {
copy_v3_v3(vec, data->vec);
mul_mat3_m4_v3(imat, vec);
@@ -3354,7 +3335,7 @@ static void brush_smooth_do(PEData *data, float UNUSED(mat[4][4]), float imat[4]
sub_v3_v3v3(dvec, vec, dvec);
mul_v3_fl(dvec, data->smoothfac);
-
+
add_v3_v3(key->co, dvec);
}
@@ -3392,7 +3373,7 @@ static int particle_intersect_mesh(const bContext *C, Scene *scene, Object *ob,
int i, totface, intersect=0;
float cur_d, cur_uv[2], v1[3], v2[3], v3[3], v4[3], min[3], max[3], p_min[3], p_max[3];
float cur_ipoint[3];
-
+
if (mesh == NULL) {
psys_disable_all(ob);
@@ -3412,7 +3393,7 @@ static int particle_intersect_mesh(const bContext *C, Scene *scene, Object *ob,
/* BMESH_ONLY, deform dm may not have tessface */
BKE_mesh_tessface_ensure(mesh);
-
+
if (pa_minmax==0) {
INIT_MINMAX(p_min, p_max);
@@ -3584,7 +3565,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
mul_m4_v3(imat, co1);
mul_m4_v3(imat, co2);
min_d=2.0;
-
+
/* warning, returns the derived mesh face */
if (particle_intersect_mesh(C, scene, ob, mesh, 0, co1, co2, &min_d, &add_pars[n].num_dmcache, add_pars[n].fuv, 0, 0, 0, 0)) {
if (psys->part->use_modifier_stack && !psmd->mesh_final->runtime.deformed_only) {
@@ -3635,7 +3616,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
/* create tree for interpolation */
if (pset->flag & PE_INTERPOLATE_ADDED && psys->totpart) {
tree=BLI_kdtree_new(psys->totpart);
-
+
for (i=0, pa=psys->particles; i<totpart; i++, pa++) {
psys_particle_on_dm(psmd->mesh_final, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, cur_co, 0, 0, 0, 0);
BLI_kdtree_insert(tree, i, cur_co);
@@ -3663,14 +3644,14 @@ static int brush_add(const bContext *C, PEData *data, short number)
if (!(psys->flag & PSYS_GLOBAL_HAIR))
key->flag |= PEK_USE_WCO;
}
-
+
pa->size= 1.0f;
initialize_particle(&sim, pa);
reset_particle(&sim, pa, 0.0, 1.0);
point->flag |= PEP_EDIT_RECALC;
if (pe_x_mirror(ob))
point->flag |= PEP_TAG; /* signal for duplicate */
-
+
framestep= pa->lifetime/(float)(pset->totaddkey-1);
if (tree) {
@@ -3685,7 +3666,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
maxw = BLI_kdtree_find_nearest_n(tree, co1, ptn, 3);
maxd= ptn[maxw-1].dist;
-
+
for (w=0; w<maxw; w++) {
weight[w] = (float)pow(2.0, (double)(-6.0f * ptn[w].dist / maxd));
totw += weight[w];
@@ -3712,10 +3693,10 @@ static int brush_add(const bContext *C, PEData *data, short number)
key3[0].time= thkey->time/ 100.0f;
psys_get_particle_on_path(&sim, ptn[0].index, key3, 0);
mul_v3_fl(key3[0].co, weight[0]);
-
+
/* TODO: interpolating the weight would be nicer */
thkey->weight= (ppa->hair+MIN2(k, ppa->totkey-1))->weight;
-
+
if (maxw>1) {
key3[1].time= key3[0].time;
psys_get_particle_on_path(&sim, ptn[1].index, &key3[1], 0);
@@ -3759,7 +3740,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
MEM_freeN(add_pars);
BLI_rng_free(rng);
-
+
return n;
}
@@ -3789,7 +3770,7 @@ static int brush_edit_init(bContext *C, wmOperator *op)
ARegion *ar= CTX_wm_region(C);
BrushEdit *bedit;
float min[3], max[3];
-
+
if (pset->brushtype < 0)
return 0;
@@ -3920,7 +3901,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
case PE_BRUSH_LENGTH:
{
data.mval= mval;
-
+
data.rad= pe_brush_size_get(scene, brush);
data.growfac= brush->strength / 50.0f;
@@ -4084,7 +4065,7 @@ static int brush_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
if (!brush_edit_init(C, op))
return OPERATOR_CANCELLED;
-
+
brush_edit_apply_event(C, op, event);
WM_event_add_modal_handler(C, op);
@@ -4119,7 +4100,7 @@ void PARTICLE_OT_brush_edit(wmOperatorType *ot)
ot->name = "Brush Edit";
ot->idname = "PARTICLE_OT_brush_edit";
ot->description = "Apply a stroke of brush to the particles";
-
+
/* api callbacks */
ot->exec = brush_edit_exec;
ot->invoke = brush_edit_invoke;
@@ -4143,12 +4124,12 @@ static int shape_cut_poll(bContext *C)
if (PE_hair_poll(C)) {
Scene *scene = CTX_data_scene(C);
ParticleEditSettings *pset = PE_settings(scene);
-
+
if (pset->shape_object && (pset->shape_object->type == OB_MESH)) {
return true;
}
}
-
+
return false;
}
@@ -4160,9 +4141,9 @@ typedef struct PointInsideBVH {
static void point_inside_bvh_cb(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
{
PointInsideBVH *data = userdata;
-
+
data->bvhdata.raycast_callback(&data->bvhdata, index, ray, hit);
-
+
if (hit->index != -1)
++data->num_hits;
}
@@ -4173,14 +4154,14 @@ static bool shape_cut_test_point(PEData *data, ParticleCacheKey *key)
BVHTreeFromMesh *shape_bvh = &data->shape_bvh;
const float dir[3] = {1.0f, 0.0f, 0.0f};
PointInsideBVH userdata;
-
+
userdata.bvhdata = data->shape_bvh;
userdata.num_hits = 0;
-
+
BLI_bvhtree_ray_cast_all(
shape_bvh->tree, key->co, dir, 0.0f, BVH_RAYCAST_DIST_MAX,
point_inside_bvh_cb, &userdata);
-
+
/* for any point inside a watertight mesh the number of hits is uneven */
return (userdata.num_hits % 2) == 1;
}
@@ -4191,17 +4172,17 @@ static void shape_cut(PEData *data, int pa_index)
Object *ob = data->ob;
ParticleEditSettings *pset = PE_settings(data->scene);
ParticleCacheKey *key;
-
+
bool cut;
float cut_time = 1.0;
int k, totkeys = 1 << pset->draw_step;
-
+
/* don't cut hidden */
if (edit->points[pa_index].flag & PEP_HIDE)
return;
-
+
cut = false;
-
+
/* check if root is inside the cut shape */
key = edit->pathcache[pa_index];
if (!shape_cut_test_point(data, key)) {
@@ -4213,10 +4194,10 @@ static void shape_cut(PEData *data, int pa_index)
BVHTreeRayHit hit;
float dir[3];
float len;
-
+
sub_v3_v3v3(dir, (key+1)->co, key->co);
len = normalize_v3(dir);
-
+
memset(&hit, 0, sizeof(hit));
hit.index = -1;
hit.dist = len;
@@ -4252,32 +4233,32 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
Object *shapeob = pset->shape_object;
int selected = count_selected_keys(scene, edit);
int lock_root = pset->flag & PE_LOCK_FIRST;
-
+
if (!PE_start_edit(edit))
return OPERATOR_CANCELLED;
-
+
/* disable locking temporatily for disconnected hair */
if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR)
pset->flag &= ~PE_LOCK_FIRST;
-
+
if (edit->psys && edit->pathcache) {
PEData data;
int removed;
-
+
PE_set_data(C, &data);
if (!PE_create_shape_tree(&data, shapeob)) {
/* shapeob may not have faces... */
return OPERATOR_CANCELLED;
}
-
+
if (selected)
foreach_selected_point(&data, shape_cut);
else
foreach_point(&data, shape_cut);
-
+
removed = remove_tagged_particles(ob, edit->psys, pe_x_mirror(ob));
recalc_lengths(edit);
-
+
if (removed) {
update_world_cos(depsgraph, ob, edit);
psys_free_path_cache(NULL, edit);
@@ -4286,7 +4267,7 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
else {
PE_update_object(data.depsgraph, scene, ob, 1);
}
-
+
if (edit->psys) {
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob);
BKE_particle_batch_cache_dirty(edit->psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
@@ -4296,12 +4277,12 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
}
-
+
PE_free_shape_tree(&data);
}
-
+
pset->flag |= lock_root;
-
+
return OPERATOR_FINISHED;
}
@@ -4311,7 +4292,7 @@ void PARTICLE_OT_shape_cut(wmOperatorType *ot)
ot->name = "Shape Cut";
ot->idname = "PARTICLE_OT_shape_cut";
ot->description = "Cut hair to conform to the set shape object";
-
+
/* api callbacks */
ot->exec = shape_cut_exec;
ot->poll = shape_cut_poll;
@@ -4366,20 +4347,14 @@ void PE_create_particle_edit(
Depsgraph *depsgraph, Scene *scene, Object *ob, PointCache *cache, ParticleSystem *psys)
{
PTCacheEdit *edit;
- Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
ParticleSystemModifierData *psmd = (psys) ? psys_get_modifier(ob, psys) : NULL;
- ParticleSystemModifierData *psmd_eval = NULL;
POINT_P; KEY_K;
ParticleData *pa = NULL;
HairKey *hkey;
int totpoint;
- if (psmd != NULL) {
- psmd_eval = (ParticleSystemModifierData *)modifiers_findByName(ob_eval, psmd->modifier.name);
- }
-
/* no psmd->dm happens in case particle system modifier is not enabled */
- if (!(psys && psmd_eval && psmd_eval->mesh_final) && !cache)
+ if (!(psys && psmd && psmd->mesh_final) && !cache)
return;
if (cache && cache->flag & PTCACHE_DISK_CACHE)
@@ -4509,14 +4484,23 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
if (!is_mode_set) {
PTCacheEdit *edit;
+ /* Particle edit mode requires original object to have all strands
+ * cached. A bit annoying to do update here, but is simpler than
+ * rewriting the while edit mode code.
+ */
+ ob->id.recalc |= (ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ BKE_scene_graph_update_tagged(depsgraph, CTX_data_main(C));
+ BKE_object_eval_transform_all(depsgraph, scene, ob);
+ BKE_object_handle_data_update(depsgraph, scene, ob);
ob->mode |= mode_flag;
+
edit= PE_create_current(depsgraph, scene, ob);
-
+
/* mesh may have changed since last entering editmode.
* note, this may have run before if the edit data was just created, so could avoid this and speed up a little */
if (edit && edit->psys)
recalc_emitter_field(depsgraph, ob, edit->psys);
-
+
toggle_particle_cursor(C, 1);
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_PARTICLE, NULL);
}
@@ -4543,7 +4527,7 @@ void PARTICLE_OT_particle_edit_toggle(wmOperatorType *ot)
ot->name = "Particle Edit Toggle";
ot->idname = "PARTICLE_OT_particle_edit_toggle";
ot->description = "Toggle particle edit mode";
-
+
/* api callbacks */
ot->exec = particle_edit_toggle_exec;
ot->poll = particle_edit_toggle_poll;
@@ -4559,7 +4543,7 @@ static int clear_edited_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= CTX_data_active_object(C);
ParticleSystem *psys = psys_get_current(ob);
-
+
if (psys->edit) {
if (psys->edit->edited || 1) {
PE_free_ptcache_edit(psys->edit);
@@ -4598,7 +4582,7 @@ void PARTICLE_OT_edited_clear(wmOperatorType *ot)
ot->name = "Clear Edited";
ot->idname = "PARTICLE_OT_edited_clear";
ot->description = "Undo all edition performed on the particle system";
-
+
/* api callbacks */
ot->exec = clear_edited_exec;
ot->poll = particle_edit_toggle_poll;
diff --git a/source/blender/editors/physics/particle_edit_undo.c b/source/blender/editors/physics/particle_edit_undo.c
index 5199b1c54fa..6576d692f70 100644
--- a/source/blender/editors/physics/particle_edit_undo.c
+++ b/source/blender/editors/physics/particle_edit_undo.c
@@ -233,7 +233,7 @@ static bool particle_undosys_poll(struct bContext *C)
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
PTCacheEdit *edit = PE_get_current(scene, ob);
-
+
return (edit != NULL);
}
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 55f518a2a8c..fbccdcfcdba 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -50,6 +50,7 @@
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_particle.h"
@@ -88,10 +89,10 @@ static int particle_system_add_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
object_add_particle_system(scene, ob, NULL);
-
+
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -101,11 +102,11 @@ void OBJECT_OT_particle_system_add(wmOperatorType *ot)
ot->name = "Add Particle System Slot";
ot->idname = "OBJECT_OT_particle_system_add";
ot->description = "Add a particle system";
-
+
/* api callbacks */
ot->poll = ED_operator_object_active_editable;
ot->exec = particle_system_add_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -136,7 +137,7 @@ static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op))
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -146,7 +147,7 @@ void OBJECT_OT_particle_system_remove(wmOperatorType *ot)
ot->name = "Remove Particle System Slot";
ot->idname = "OBJECT_OT_particle_system_remove";
ot->description = "Remove the selected particle system";
-
+
/* api callbacks */
ot->poll = ED_operator_object_active_editable;
ot->exec = particle_system_remove_exec;
@@ -194,7 +195,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -204,7 +205,7 @@ void PARTICLE_OT_new(wmOperatorType *ot)
ot->name = "New Particle Settings";
ot->idname = "PARTICLE_OT_new";
ot->description = "Add new particle settings";
-
+
/* api callbacks */
ot->exec = new_particle_settings_exec;
ot->poll = psys_poll;
@@ -242,7 +243,7 @@ static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -252,7 +253,7 @@ void PARTICLE_OT_new_target(wmOperatorType *ot)
ot->name = "New Particle Target";
ot->idname = "PARTICLE_OT_new_target";
ot->description = "Add a new particle target";
-
+
/* api callbacks */
ot->exec = new_particle_target_exec;
@@ -290,7 +291,7 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -300,7 +301,7 @@ void PARTICLE_OT_target_remove(wmOperatorType *ot)
ot->name = "Remove Particle Target";
ot->idname = "PARTICLE_OT_target_remove";
ot->description = "Remove the selected particle target";
-
+
/* api callbacks */
ot->exec = remove_particle_target_exec;
@@ -319,7 +320,7 @@ static int target_move_up_exec(bContext *C, wmOperator *UNUSED(op))
if (!psys)
return OPERATOR_CANCELLED;
-
+
pt = psys->targets.first;
for (; pt; pt=pt->next) {
if (pt->flag & PTARGET_CURRENT && pt->prev) {
@@ -331,7 +332,7 @@ static int target_move_up_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
-
+
return OPERATOR_FINISHED;
}
@@ -340,9 +341,9 @@ void PARTICLE_OT_target_move_up(wmOperatorType *ot)
ot->name = "Move Up Target";
ot->idname = "PARTICLE_OT_target_move_up";
ot->description = "Move particle target up in the list";
-
+
ot->exec = target_move_up_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -369,7 +370,7 @@ static int target_move_down_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
-
+
return OPERATOR_FINISHED;
}
@@ -378,9 +379,9 @@ void PARTICLE_OT_target_move_down(wmOperatorType *ot)
ot->name = "Move Down Target";
ot->idname = "PARTICLE_OT_target_move_down";
ot->description = "Move particle target down in the list";
-
+
ot->exec = target_move_down_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -407,7 +408,7 @@ static int dupliob_move_up_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
-
+
return OPERATOR_FINISHED;
}
@@ -416,9 +417,9 @@ void PARTICLE_OT_dupliob_move_up(wmOperatorType *ot)
ot->name = "Move Up Dupli Object";
ot->idname = "PARTICLE_OT_dupliob_move_up";
ot->description = "Move dupli object up in the list";
-
+
ot->exec = dupliob_move_up_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -446,7 +447,7 @@ static int copy_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
-
+
return OPERATOR_FINISHED;
}
@@ -456,7 +457,7 @@ void PARTICLE_OT_dupliob_copy(wmOperatorType *ot)
ot->name = "Copy Particle Dupliob";
ot->idname = "PARTICLE_OT_dupliob_copy";
ot->description = "Duplicate the current dupliobject";
-
+
/* api callbacks */
ot->exec = copy_particle_dupliob_exec;
@@ -489,7 +490,7 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
dw->flag |= PART_DUPLIW_CURRENT;
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -499,7 +500,7 @@ void PARTICLE_OT_dupliob_remove(wmOperatorType *ot)
ot->name = "Remove Particle Dupliobject";
ot->idname = "PARTICLE_OT_dupliob_remove";
ot->description = "Remove the selected dupliobject";
-
+
/* api callbacks */
ot->exec = remove_particle_dupliob_exec;
@@ -529,7 +530,7 @@ static int dupliob_move_down_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
-
+
return OPERATOR_FINISHED;
}
@@ -538,9 +539,9 @@ void PARTICLE_OT_dupliob_move_down(wmOperatorType *ot)
ot->name = "Move Down Dupli Object";
ot->idname = "PARTICLE_OT_dupliob_move_down";
ot->description = "Move dupli object down in the list";
-
+
ot->exec = dupliob_move_down_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -566,7 +567,7 @@ static void disconnect_hair(
if (!psys->part || psys->part->type != PART_HAIR)
return;
-
+
edit = psys->edit;
point= edit ? edit->points : NULL;
@@ -580,7 +581,7 @@ static void disconnect_hair(
for (k=0, key=pa->hair; k<pa->totkey; k++, key++) {
mul_m4_v3(hairmat, key->co);
-
+
if (ekey) {
ekey->flag &= ~PEK_USE_WCO;
ekey++;
@@ -630,9 +631,9 @@ void PARTICLE_OT_disconnect_hair(wmOperatorType *ot)
ot->name = "Disconnect Hair";
ot->description = "Disconnect hair from the emitter mesh";
ot->idname = "PARTICLE_OT_disconnect_hair";
-
+
ot->exec = disconnect_hair_exec;
-
+
/* flags */
ot->flag = OPTYPE_UNDO; /* No REGISTER, redo does not work due to missing update, see T47750. */
@@ -667,14 +668,14 @@ static bool remap_hair_emitter(
return false;
if (!target_psys->part || target_psys->part->type != PART_HAIR)
return false;
-
+
edit_point = target_edit ? target_edit->points : NULL;
-
+
invert_m4_m4(from_ob_imat, ob->obmat);
invert_m4_m4(to_ob_imat, target_ob->obmat);
invert_m4_m4(from_imat, from_mat);
invert_m4_m4(to_imat, to_mat);
-
+
if (target_psmd->mesh_final->runtime.deformed_only) {
/* we don't want to mess up target_psmd->dm when converting to global coordinates below */
mesh = target_psmd->mesh_final;
@@ -744,7 +745,7 @@ static bool remap_hair_emitter(
if (mface) {
float v[4][3];
-
+
mf = &mface[nearest.index];
copy_v3_v3(v[0], mvert[mf->v1].co);
@@ -780,7 +781,7 @@ static bool remap_hair_emitter(
HairKey *key, *tkey;
float hairmat[4][4], imat[4][4];
float offset[3];
-
+
if (to_global)
copy_m4_m4(imat, target_ob->obmat);
else {
@@ -789,41 +790,41 @@ static bool remap_hair_emitter(
invert_m4_m4(imat, hairmat);
}
mul_m4_m4m4(imat, imat, to_imat);
-
+
/* offset in world space */
sub_v3_v3v3(offset, nearest.co, from_co);
-
+
if (edit_point) {
for (k=0, key=pa->hair, tkey=tpa->hair, ekey = edit_point->keys; k<tpa->totkey; k++, key++, tkey++, ekey++) {
float co_orig[3];
-
+
if (from_global)
mul_v3_m4v3(co_orig, from_ob_imat, key->co);
else
mul_v3_m4v3(co_orig, from_ob_imat, key->world_co);
mul_m4_v3(from_mat, co_orig);
-
+
add_v3_v3v3(tkey->co, co_orig, offset);
-
+
mul_m4_v3(imat, tkey->co);
-
+
ekey->flag |= PEK_USE_WCO;
}
-
+
edit_point++;
}
else {
for (k=0, key=pa->hair, tkey=tpa->hair; k<tpa->totkey; k++, key++, tkey++) {
float co_orig[3];
-
+
if (from_global)
mul_v3_m4v3(co_orig, from_ob_imat, key->co);
else
mul_v3_m4v3(co_orig, from_ob_imat, key->world_co);
mul_m4_v3(from_mat, co_orig);
-
+
add_v3_v3v3(tkey->co, co_orig, offset);
-
+
mul_m4_v3(imat, tkey->co);
}
}
@@ -845,15 +846,15 @@ static bool connect_hair(
Object *ob, ParticleSystem *psys)
{
bool ok;
-
+
if (!psys)
return false;
-
+
ok = remap_hair_emitter(
depsgraph, scene, ob, psys, ob, psys, psys->edit,
ob->obmat, ob->obmat, psys->flag & PSYS_GLOBAL_HAIR, false);
psys->flag &= ~PSYS_GLOBAL_HAIR;
-
+
return ok;
}
@@ -896,9 +897,9 @@ void PARTICLE_OT_connect_hair(wmOperatorType *ot)
ot->name = "Connect Hair";
ot->description = "Connect hair to the emitter mesh";
ot->idname = "PARTICLE_OT_connect_hair";
-
+
ot->exec = connect_hair_exec;
-
+
/* flags */
ot->flag = OPTYPE_UNDO; /* No REGISTER, redo does not work due to missing update, see T47750. */
@@ -920,17 +921,17 @@ static void copy_particle_edit(
ParticleData *pa;
KEY_K;
POINT_P;
-
+
if (!edit_from)
return;
-
+
edit = MEM_dupallocN(edit_from);
edit->psys = psys;
psys->edit = edit;
-
+
edit->pathcache = NULL;
BLI_listbase_clear(&edit->pathcachebufs);
-
+
edit->emitter_field = NULL;
edit->emitter_cosnos = NULL;
@@ -938,7 +939,7 @@ static void copy_particle_edit(
pa = psys->particles;
LOOP_POINTS {
HairKey *hkey = pa->hair;
-
+
point->keys= MEM_dupallocN(point->keys);
LOOP_KEYS {
key->co = hkey->co;
@@ -948,17 +949,17 @@ static void copy_particle_edit(
key->flag |= PEK_USE_WCO;
hkey->editflag |= PEK_USE_WCO;
}
-
+
hkey++;
}
-
+
pa++;
}
update_world_cos(depsgraph, ob, edit);
-
+
UI_GetThemeColor3ubv(TH_EDGE_SELECT, edit->sel_col);
UI_GetThemeColor3ubv(TH_WIRE, edit->nosel_col);
-
+
recalc_lengths(edit);
recalc_emitter_field(depsgraph, ob, psys);
PE_update_object(depsgraph, scene, ob, true);
@@ -967,15 +968,15 @@ static void copy_particle_edit(
static void remove_particle_systems_from_object(Object *ob_to)
{
ModifierData *md, *md_next;
-
+
if (ob_to->type != OB_MESH)
return;
if (!ob_to->data || ID_IS_LINKED(ob_to->data))
return;
-
+
for (md = ob_to->modifiers.first; md; md = md_next) {
md_next = md->next;
-
+
/* remove all particle system modifiers as well,
* these need to sync to the particle system list
*/
@@ -984,7 +985,7 @@ static void remove_particle_systems_from_object(Object *ob_to)
modifier_free(md);
}
}
-
+
BKE_object_free_particlesystems(ob_to);
}
@@ -1010,7 +1011,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
return false;
if (!ob_to->data || ID_IS_LINKED(ob_to->data))
return false;
-
+
/* For remapping we need a valid DM.
* Because the modifiers are appended at the end it's safe to use
* the final DM of the object without particles.
@@ -1022,9 +1023,9 @@ static bool copy_particle_systems_to_object(const bContext *C,
#define PSYS_FROM_FIRST (single_psys_from ? single_psys_from : ob_from->particlesystem.first)
#define PSYS_FROM_NEXT(cur) (single_psys_from ? NULL : (cur)->next)
totpsys = single_psys_from ? 1 : BLI_listbase_count(&ob_from->particlesystem);
-
+
tmp_psys = MEM_mallocN(sizeof(ParticleSystem*) * totpsys, "temporary particle system array");
-
+
cdmask = 0;
for (psys_from = PSYS_FROM_FIRST, i = 0;
psys_from;
@@ -1032,19 +1033,19 @@ static bool copy_particle_systems_to_object(const bContext *C,
{
psys = BKE_object_copy_particlesystem(psys_from, 0);
tmp_psys[i] = psys;
-
+
if (psys_start == NULL)
psys_start = psys;
-
+
cdmask |= psys_emitter_customdata_mask(psys);
}
/* to iterate source and target psys in sync,
* we need to know where the newly added psys start
*/
psys_start = totpsys > 0 ? tmp_psys[0] : NULL;
-
+
/* get the DM (psys and their modifiers have not been appended yet) */
- /* TODO(Sybren): use mesh_evaluated instead */
+ /* TODO(Sybren): use mesh_eval instead */
DerivedMesh *final_dm = mesh_get_derived_final(depsgraph, scene, ob_to, cdmask);
final_mesh = BKE_id_new_nomain(ID_ME, NULL);
DM_to_mesh(final_dm, final_mesh, ob_to, CD_MASK_EVERYTHING, false);
@@ -1055,21 +1056,21 @@ static bool copy_particle_systems_to_object(const bContext *C,
++i, psys_from = PSYS_FROM_NEXT(psys_from))
{
ParticleSystemModifierData *psmd;
-
+
psys = tmp_psys[i];
-
+
/* append to the object */
BLI_addtail(&ob_to->particlesystem, psys);
-
+
/* add a particle system modifier for each system */
md = modifier_new(eModifierType_ParticleSystem);
psmd = (ParticleSystemModifierData *)md;
/* push on top of the stack, no use trying to reproduce old stack order */
BLI_addtail(&ob_to->modifiers, md);
-
+
BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", i);
modifier_unique_name(&ob_to->modifiers, (ModifierData *)psmd);
-
+
psmd->psys = psys;
BKE_id_copy_ex(
NULL, &final_mesh->id, (ID **)&psmd->mesh_final,
@@ -1092,7 +1093,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
}
}
MEM_freeN(tmp_psys);
-
+
/* note: do this after creating DM copies for all the particle system modifiers,
* the remapping otherwise makes final_dm invalid!
*/
@@ -1101,7 +1102,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
psys = psys->next, psys_from = PSYS_FROM_NEXT(psys_from), ++i)
{
float (*from_mat)[4], (*to_mat)[4];
-
+
switch (space) {
case PAR_COPY_SPACE_OBJECT:
from_mat = I;
@@ -1122,14 +1123,14 @@ static bool copy_particle_systems_to_object(const bContext *C,
depsgraph, scene, ob_from, psys_from, ob_to, psys, psys->edit,
from_mat, to_mat, psys_from->flag & PSYS_GLOBAL_HAIR, psys->flag & PSYS_GLOBAL_HAIR);
}
-
+
/* tag for recalc */
// psys->recalc |= PSYS_RECALC_RESET;
}
-
+
#undef PSYS_FROM_FIRST
#undef PSYS_FROM_NEXT
-
+
DEG_id_tag_update(&ob_to->id, OB_RECALC_DATA);
WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, ob_to);
return true;
@@ -1140,11 +1141,11 @@ static int copy_particle_systems_poll(bContext *C)
Object *ob;
if (!ED_operator_object_active_editable(C))
return false;
-
+
ob = ED_object_active_context(C);
if (BLI_listbase_is_empty(&ob->particlesystem))
return false;
-
+
return true;
}
@@ -1156,10 +1157,10 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *ob_from = ED_object_active_context(C);
ParticleSystem *psys_from = use_active ? CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data : NULL;
-
+
int changed_tot = 0;
int fail = 0;
-
+
CTX_DATA_BEGIN (C, Object *, ob_to, selected_editable_objects)
{
if (ob_from != ob_to) {
@@ -1172,19 +1173,19 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op)
changed = true;
else
fail++;
-
+
if (changed)
changed_tot++;
}
}
CTX_DATA_END;
-
+
if ((changed_tot == 0 && fail == 0) || fail) {
BKE_reportf(op->reports, RPT_ERROR,
"Copy particle systems to selected: %d done, %d failed",
changed_tot, fail);
}
-
+
return OPERATOR_FINISHED;
}
@@ -1195,17 +1196,17 @@ void PARTICLE_OT_copy_particle_systems(wmOperatorType *ot)
{PAR_COPY_SPACE_WORLD, "WORLD", 0, "World", "Copy in world space"},
{0, NULL, 0, NULL, NULL}
};
-
+
ot->name = "Copy Particle Systems";
ot->description = "Copy particle systems from the active object to selected objects";
ot->idname = "PARTICLE_OT_copy_particle_systems";
-
+
ot->poll = copy_particle_systems_poll;
ot->exec = copy_particle_systems_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_enum(ot->srna, "space", space_items, PAR_COPY_SPACE_OBJECT, "Space", "Space transform for copying from one object to another");
RNA_def_boolean(ot->srna, "remove_target_particles", true, "Remove Target Particles", "Remove particle systems on the target objects");
RNA_def_boolean(ot->srna, "use_active", false, "Use Active", "Use the active particle system from the context");
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 541242fdc09..130dcba060d 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -39,7 +39,7 @@
/* types */
#include "DNA_action_types.h"
#include "DNA_object_types.h"
-#include "DNA_object_fluidsim_types.h"
+#include "DNA_object_fluidsim_types.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
@@ -48,6 +48,7 @@
#include "BKE_context.h"
#include "BKE_customdata.h"
#include "BKE_fluidsim.h"
+#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_report.h"
@@ -83,12 +84,12 @@ static float get_fluid_viscosity(FluidsimSettings *settings)
static float get_fluid_rate(FluidsimSettings *settings)
{
float rate = 1.0f; /* default rate if not animated... */
-
+
rate = settings->animRate;
-
+
if (rate < 0.0f)
rate = 0.0f;
-
+
return rate;
}
@@ -110,10 +111,10 @@ static float get_fluid_size_m(Scene *scene, Object *domainob, FluidsimSettings *
else {
float dim[3];
float longest_axis;
-
+
BKE_object_dimensions_get(domainob, dim);
longest_axis = max_fff(dim[0], dim[1], dim[2]);
-
+
return longest_axis * scene->unit.scale_length;
}
}
@@ -139,9 +140,9 @@ void fluidsimGetGeometryObjFilename(Object *ob, char *dst) //, char *srcname)
typedef struct FluidAnimChannels {
int length;
-
+
double aniFrameTime;
-
+
float *timeAtFrame;
float *DomainTime;
float *DomainGravity;
@@ -150,21 +151,21 @@ typedef struct FluidAnimChannels {
typedef struct FluidObject {
struct FluidObject *next, *prev;
-
+
struct Object *object;
-
+
float *Translation;
float *Rotation;
float *Scale;
float *Active;
-
+
float *InitialVelocity;
-
+
float *AttractforceStrength;
float *AttractforceRadius;
float *VelocityforceStrength;
float *VelocityforceRadius;
-
+
float *VertexCache;
int numVerts, numTris;
} FluidObject;
@@ -176,10 +177,10 @@ typedef struct FluidObject {
// simplify channels before printing
// for API this is done anyway upon init
#if 0
-static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char *str, int entries)
-{
+static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char *str, int entries)
+{
int i, j;
- int channelSize = paramsize;
+ int channelSize = paramsize;
if (entries == 3) {
elbeemSimplifyChannelVec3(channel, &channelSize);
@@ -221,11 +222,11 @@ static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char
static void init_time(FluidsimSettings *domainSettings, FluidAnimChannels *channels)
{
int i;
-
+
channels->timeAtFrame = MEM_callocN((channels->length + 1) * sizeof(float), "timeAtFrame channel");
-
+
channels->timeAtFrame[0] = channels->timeAtFrame[1] = domainSettings->animStart; // start at index 1
-
+
for (i=2; i <= channels->length; i++) {
channels->timeAtFrame[i] = channels->timeAtFrame[i - 1] + (float)channels->aniFrameTime;
}
@@ -255,25 +256,25 @@ static void set_vertex_channel(Depsgraph *depsgraph, float *channel, float time,
int modifierIndex = BLI_findindex(&ob->modifiers, fluidmd);
int framesize = (3*fobj->numVerts) + 1;
int j;
-
+
if (channel == NULL)
return;
-
+
initElbeemMesh(depsgraph, scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex);
-
+
/* don't allow mesh to change number of verts in anim sequence */
if (numVerts != fobj->numVerts) {
MEM_freeN(channel);
channel = NULL;
return;
}
-
+
/* fill frame of channel with vertex locations */
for (j=0; j < (3*numVerts); j++) {
channel[i*framesize + j] = verts[j];
}
channel[i*framesize + framesize-1] = time;
-
+
MEM_freeN(verts);
MEM_freeN(tris);
}
@@ -295,7 +296,7 @@ static void free_domain_channels(FluidAnimChannels *channels)
static void free_all_fluidobject_channels(ListBase *fobjects)
{
FluidObject *fobj;
-
+
for (fobj=fobjects->first; fobj; fobj=fobj->next) {
if (fobj->Translation) {
MEM_freeN(fobj->Translation);
@@ -309,7 +310,7 @@ static void free_all_fluidobject_channels(ListBase *fobjects)
MEM_freeN(fobj->InitialVelocity);
fobj->InitialVelocity = NULL;
}
-
+
if (fobj->AttractforceStrength) {
MEM_freeN(fobj->AttractforceStrength);
fobj->AttractforceStrength = NULL;
@@ -320,7 +321,7 @@ static void free_all_fluidobject_channels(ListBase *fobjects)
MEM_freeN(fobj->VelocityforceRadius);
fobj->VelocityforceRadius = NULL;
}
-
+
if (fobj->VertexCache) {
MEM_freeN(fobj->VertexCache);
fobj->VertexCache = NULL;
@@ -340,105 +341,105 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
/* init time values (assuming that time moves at a constant speed; may be overridden later) */
init_time(domainSettings, channels);
-
+
/* allocate domain animation channels */
channels->DomainGravity = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "channel DomainGravity");
channels->DomainViscosity = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainViscosity");
channels->DomainTime = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainTime");
-
+
/* allocate fluid objects */
for (base = FIRSTBASE(view_layer); base; base = base->next) {
Object *ob = base->object;
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
-
+
if (fluidmd) {
FluidObject *fobj = MEM_callocN(sizeof(FluidObject), "Fluid Object");
fobj->object = ob;
-
+
if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) {
BLI_addtail(fobjects, fobj);
continue;
}
-
+
fobj->Translation = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject Translation");
fobj->Rotation = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject Rotation");
fobj->Scale = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject Scale");
fobj->Active = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject Active");
fobj->InitialVelocity = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject InitialVelocity");
-
+
if (fluidmd->fss->type == OB_FLUIDSIM_CONTROL) {
fobj->AttractforceStrength = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject AttractforceStrength");
fobj->AttractforceRadius = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject AttractforceRadius");
fobj->VelocityforceStrength = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject VelocityforceStrength");
fobj->VelocityforceRadius = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject VelocityforceRadius");
}
-
+
if (fluid_is_animated_mesh(fluidmd->fss)) {
float *verts=NULL;
int *tris=NULL, modifierIndex = BLI_findindex(&ob->modifiers, (ModifierData *)fluidmd);
initElbeemMesh(depsgraph, scene, ob, &fobj->numVerts, &verts, &fobj->numTris, &tris, 0, modifierIndex);
fobj->VertexCache = MEM_callocN(length *((fobj->numVerts*CHANNEL_VEC)+1) * sizeof(float), "fluidobject VertexCache");
-
+
MEM_freeN(verts);
MEM_freeN(tris);
}
-
+
BLI_addtail(fobjects, fobj);
}
}
-
+
/* now we loop over the frames and fill the allocated channels with data */
for (i=0; i < channels->length; i++) {
FluidObject *fobj;
float viscosity, gravity[3];
float timeAtFrame, time;
-
+
eval_time = domainSettings->bakeStart + i;
-
+
/* XXX: This can't be used due to an anim sys optimization that ignores recalc object animation,
* leaving it for the depgraph (this ignores object animation such as modifier properties though... :/ )
* --> BKE_animsys_evaluate_all_animation(G.main, eval_time);
* This doesn't work with drivers:
* --> BKE_animsys_evaluate_animdata(&fsDomain->id, fsDomain->adt, eval_time, ADT_RECALC_ALL);
*/
-
- /* Modifying the global scene isn't nice, but we can do it in
+
+ /* Modifying the global scene isn't nice, but we can do it in
* this part of the process before a threaded job is created */
scene->r.cfra = (int)eval_time;
ED_update_for_newframe(CTX_data_main(C), depsgraph);
-
+
/* now scene data should be current according to animation system, so we fill the channels */
-
+
/* Domain time */
// TODO: have option for not running sim, time mangling, in which case second case comes in handy
if (channels->DomainTime) {
time = get_fluid_rate(domainSettings) * (float)channels->aniFrameTime;
timeAtFrame = channels->timeAtFrame[i] + time;
-
+
channels->timeAtFrame[i+1] = timeAtFrame;
set_channel(channels->DomainTime, i, &time, i, CHANNEL_FLOAT);
}
else {
timeAtFrame = channels->timeAtFrame[i+1];
}
-
+
/* Domain properties - gravity/viscosity */
get_fluid_gravity(gravity, scene, domainSettings);
set_channel(channels->DomainGravity, timeAtFrame, gravity, i, CHANNEL_VEC);
viscosity = get_fluid_viscosity(domainSettings);
set_channel(channels->DomainViscosity, timeAtFrame, &viscosity, i, CHANNEL_FLOAT);
-
+
/* object movement */
for (fobj=fobjects->first; fobj; fobj=fobj->next) {
Object *ob = fobj->object;
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
float active= (float) ((fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE) > 0 ? 1 : 0);
float rot_d[3] = {0.f, 0.f, 0.f}, old_rot[3] = {0.f, 0.f, 0.f};
-
+
if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
continue;
-
+
/* init euler rotation values and convert to elbeem format */
/* get the rotation from ob->obmat rather than ob->rot to account for parent animations */
if (i) {
@@ -448,7 +449,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
mat4_to_compatible_eulO(rot_d, old_rot, 0, ob->obmat);
mul_v3_fl(rot_d, -180.0f / (float)M_PI);
-
+
set_channel(fobj->Translation, timeAtFrame, ob->loc, i, CHANNEL_VEC);
set_channel(fobj->Rotation, timeAtFrame, rot_d, i, CHANNEL_VEC);
set_channel(fobj->Scale, timeAtFrame, ob->size, i, CHANNEL_VEC);
@@ -456,14 +457,14 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
set_channel(fobj->InitialVelocity, timeAtFrame, &fluidmd->fss->iniVelx, i, CHANNEL_VEC);
// printf("Active: %f, Frame: %f\n", active, timeAtFrame);
-
+
if (fluidmd->fss->type == OB_FLUIDSIM_CONTROL) {
set_channel(fobj->AttractforceStrength, timeAtFrame, &fluidmd->fss->attractforceStrength, i, CHANNEL_FLOAT);
set_channel(fobj->AttractforceRadius, timeAtFrame, &fluidmd->fss->attractforceRadius, i, CHANNEL_FLOAT);
set_channel(fobj->VelocityforceStrength, timeAtFrame, &fluidmd->fss->velocityforceStrength, i, CHANNEL_FLOAT);
set_channel(fobj->VelocityforceRadius, timeAtFrame, &fluidmd->fss->velocityforceRadius, i, CHANNEL_FLOAT);
}
-
+
if (fluid_is_animated_mesh(fluidmd->fss)) {
set_vertex_channel(depsgraph, fobj->VertexCache, timeAtFrame, scene, fobj, i);
}
@@ -475,72 +476,72 @@ static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *s
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
FluidObject *fobj;
-
+
for (fobj=fobjects->first; fobj; fobj=fobj->next) {
Object *ob = fobj->object;
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
int modifierIndex = BLI_findindex(&ob->modifiers, fluidmd);
-
+
float *verts=NULL;
int *tris=NULL;
int numVerts=0, numTris=0;
bool deform = fluid_is_animated_mesh(fluidmd->fss);
-
+
elbeemMesh fsmesh;
-
+
if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
continue;
-
+
elbeemResetMesh(&fsmesh);
-
+
fsmesh.type = fluidmd->fss->type;
fsmesh.name = ob->id.name;
-
+
initElbeemMesh(depsgraph, scene, ob, &numVerts, &verts, &numTris, &tris, 0, modifierIndex);
-
+
fsmesh.numVertices = numVerts;
fsmesh.numTriangles = numTris;
fsmesh.vertices = verts;
fsmesh.triangles = tris;
-
- fsmesh.channelSizeTranslation =
- fsmesh.channelSizeRotation =
- fsmesh.channelSizeScale =
- fsmesh.channelSizeInitialVel =
+
+ fsmesh.channelSizeTranslation =
+ fsmesh.channelSizeRotation =
+ fsmesh.channelSizeScale =
+ fsmesh.channelSizeInitialVel =
fsmesh.channelSizeActive = length;
-
+
fsmesh.channelTranslation = fobj->Translation;
fsmesh.channelRotation = fobj->Rotation;
fsmesh.channelScale = fobj->Scale;
fsmesh.channelActive = fobj->Active;
-
+
if ( ELEM(fsmesh.type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) {
fsmesh.channelInitialVel = fobj->InitialVelocity;
fsmesh.localInivelCoords = ((fluidmd->fss->typeFlags & OB_FSINFLOW_LOCALCOORD) ? 1 : 0);
}
-
+
if (fluidmd->fss->typeFlags & OB_FSBND_NOSLIP)
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
else if (fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP)
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_PARTSLIP;
else if (fluidmd->fss->typeFlags & OB_FSBND_FREESLIP)
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_FREESLIP;
-
+
fsmesh.obstaclePartslip = fluidmd->fss->partSlipValue;
fsmesh.volumeInitType = fluidmd->fss->volumeInitType;
fsmesh.obstacleImpactFactor = fluidmd->fss->surfaceSmoothing; // misused value
-
+
if (fsmesh.type == OB_FLUIDSIM_CONTROL) {
fsmesh.cpsTimeStart = fluidmd->fss->cpsTimeStart;
fsmesh.cpsTimeEnd = fluidmd->fss->cpsTimeEnd;
fsmesh.cpsQuality = fluidmd->fss->cpsQuality;
fsmesh.obstacleType = (fluidmd->fss->flag & OB_FLUIDSIM_REVERSE);
-
- fsmesh.channelSizeAttractforceRadius =
- fsmesh.channelSizeVelocityforceStrength =
- fsmesh.channelSizeVelocityforceRadius =
+
+ fsmesh.channelSizeAttractforceRadius =
+ fsmesh.channelSizeVelocityforceStrength =
+ fsmesh.channelSizeVelocityforceRadius =
fsmesh.channelSizeAttractforceStrength = length;
-
+
fsmesh.channelAttractforceStrength = fobj->AttractforceStrength;
fsmesh.channelAttractforceRadius = fobj->AttractforceRadius;
fsmesh.channelVelocityforceStrength = fobj->VelocityforceStrength;
@@ -548,28 +549,28 @@ static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *s
}
else {
fsmesh.channelAttractforceStrength =
- fsmesh.channelAttractforceRadius =
- fsmesh.channelVelocityforceStrength =
- fsmesh.channelVelocityforceRadius = NULL;
+ fsmesh.channelAttractforceRadius =
+ fsmesh.channelVelocityforceStrength =
+ fsmesh.channelVelocityforceRadius = NULL;
}
-
+
/* animated meshes */
if (deform) {
fsmesh.channelSizeVertices = length;
fsmesh.channelVertices = fobj->VertexCache;
-
+
/* remove channels */
- fsmesh.channelTranslation =
- fsmesh.channelRotation =
+ fsmesh.channelTranslation =
+ fsmesh.channelRotation =
fsmesh.channelScale = NULL;
-
+
/* Override user settings, only noslip is supported here! */
if (fsmesh.type != OB_FLUIDSIM_CONTROL)
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
}
-
+
elbeemAddMesh(&fsmesh);
-
+
if (verts) MEM_freeN(verts);
if (tris) MEM_freeN(tris);
}
@@ -588,7 +589,7 @@ static int fluid_validate_scene(ReportList *reports, ViewLayer *view_layer, Obje
/* only find objects with fluid modifiers */
if (!fluidmdtmp || ob->type != OB_MESH) continue;
-
+
if (fluidmdtmp->fss->type == OB_FLUIDSIM_DOMAIN) {
/* if no initial domain object given, find another potential domain */
if (!fsDomain) {
@@ -600,11 +601,11 @@ static int fluid_validate_scene(ReportList *reports, ViewLayer *view_layer, Obje
return 0;
}
}
-
+
/* count number of objects needed for animation channels */
if ( !ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE) )
channelObjCount++;
-
+
/* count number of fluid input objects */
if (ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW))
fluidInputCount++;
@@ -612,22 +613,22 @@ static int fluid_validate_scene(ReportList *reports, ViewLayer *view_layer, Obje
if (newdomain)
fsDomain = newdomain;
-
+
if (!fsDomain) {
BKE_report(reports, RPT_ERROR, "No domain object found");
return 0;
}
-
+
if (channelObjCount >= 255) {
BKE_report(reports, RPT_ERROR, "Cannot bake with more than 256 objects");
return 0;
}
-
+
if (fluidInputCount == 0) {
BKE_report(reports, RPT_ERROR, "No fluid input objects in the scene");
return 0;
}
-
+
return 1;
}
@@ -637,13 +638,13 @@ static int fluid_validate_scene(ReportList *reports, ViewLayer *view_layer, Obje
#define FLUID_SUFFIX_SURFACE "fluidsurface"
static bool fluid_init_filepaths(
- ReportList *reports, FluidsimSettings *domainSettings, Object *fsDomain,
+ Main *bmain, ReportList *reports, FluidsimSettings *domainSettings, Object *fsDomain,
char *targetDir, char *targetFile)
{
const char *suffixConfigTmp = FLUID_SUFFIX_CONFIG_TMP;
/* prepare names... */
- const char *relbase = modifier_path_relbase(fsDomain);
+ const char *relbase = modifier_path_relbase(bmain, fsDomain);
/* We do not accept empty paths, they can end in random places silently, see T51176. */
if (domainSettings->surfdataPath[0] == '\0') {
@@ -721,8 +722,8 @@ static int fluidbake_breakjob(void *customdata)
if (fb->stop && *(fb->stop))
return 1;
-
- /* this is not nice yet, need to make the jobs list template better
+
+ /* this is not nice yet, need to make the jobs list template better
* for identifying/acting upon various different jobs */
/* but for now we'll reuse the render break... */
return (G.is_break);
@@ -732,7 +733,7 @@ static int fluidbake_breakjob(void *customdata)
static void fluidbake_updatejob(void *customdata, float progress)
{
FluidBakeJob *fb= (FluidBakeJob *)customdata;
-
+
*(fb->do_update) = true;
*(fb->progress) = progress;
}
@@ -740,13 +741,13 @@ static void fluidbake_updatejob(void *customdata, float progress)
static void fluidbake_startjob(void *customdata, short *stop, short *do_update, float *progress)
{
FluidBakeJob *fb= (FluidBakeJob *)customdata;
-
+
fb->stop= stop;
fb->do_update = do_update;
fb->progress = progress;
-
+
G.is_break = false; /* XXX shared with render - replace with job 'stop' switch */
-
+
elbeemSimulate();
*do_update = true;
*stop = 0;
@@ -755,7 +756,7 @@ static void fluidbake_startjob(void *customdata, short *stop, short *do_update,
static void fluidbake_endjob(void *customdata)
{
FluidBakeJob *fb= (FluidBakeJob *)customdata;
-
+
if (fb->settings) {
MEM_freeN(fb->settings);
fb->settings = NULL;
@@ -766,16 +767,16 @@ static int runSimulationCallback(void *data, int status, int frame)
{
FluidBakeJob *fb = (FluidBakeJob *)data;
elbeemSimulationSettings *settings = fb->settings;
-
+
if (status == FLUIDSIM_CBSTATUS_NEWFRAME) {
fluidbake_updatejob(fb, frame / (float)settings->noOfFrames);
//printf("elbeem blender cb s%d, f%d, domainid:%d noOfFrames: %d\n", status, frame, settings->domainId, settings->noOfFrames ); // DEBUG
}
-
+
if (fluidbake_breakjob(fb)) {
return FLUIDSIM_CBRET_ABORT;
}
-
+
return FLUIDSIM_CBRET_CONTINUE;
}
@@ -789,12 +790,12 @@ static void fluidbake_free_data(FluidAnimChannels *channels, ListBase *fobjects,
BLI_freelistN(fobjects);
MEM_freeN(fobjects);
fobjects = NULL;
-
+
if (fsset) {
MEM_freeN(fsset);
fsset = NULL;
}
-
+
if (fb) {
MEM_freeN(fb);
fb = NULL;
@@ -840,6 +841,7 @@ static void fluidsim_delete_until_lastframe(FluidsimSettings *fss, const char *r
static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, short do_job)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
@@ -847,9 +849,9 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
FluidsimSettings *domainSettings;
char debugStrBuffer[256];
-
+
int gridlevels = 0;
- const char *relbase= modifier_path_relbase(fsDomain);
+ const char *relbase= modifier_path_relbase(bmain, fsDomain);
const char *strEnvName = "BLENDER_ELBEEMDEBUG"; // from blendercall.cpp
const char *suffixConfigTmp = FLUID_SUFFIX_CONFIG_TMP;
const char *suffixSurface = FLUID_SUFFIX_SURFACE;
@@ -862,7 +864,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
int noFrames;
int origFrame = scene->r.cfra;
-
+
FluidAnimChannels *channels = MEM_callocN(sizeof(FluidAnimChannels), "fluid domain animation channels");
ListBase *fobjects = MEM_callocN(sizeof(ListBase), "fluid objects");
FluidsimModifierData *fluidmd = NULL;
@@ -872,14 +874,14 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
elbeemSimulationSettings *fsset= MEM_callocN(sizeof(elbeemSimulationSettings), "Fluid sim settings");
fb= MEM_callocN(sizeof(FluidBakeJob), "fluid bake job");
-
+
if (getenv(strEnvName)) {
int dlevel = atoi(getenv(strEnvName));
elbeemSetDebugLevel(dlevel);
BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::msg: Debug messages activated due to envvar '%s'\n", strEnvName);
elbeemDebugOut(debugStrBuffer);
}
-
+
/* make sure it corresponds to startFrame setting (old: noFrames = scene->r.efra - scene->r.sfra +1) */;
noFrames = scene->r.efra - 0;
if (noFrames<=0) {
@@ -887,30 +889,30 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
fluidbake_free_data(channels, fobjects, fsset, fb);
return 0;
}
-
+
/* check scene for sane object/modifier settings */
if (!fluid_validate_scene(reports, view_layer, fsDomain)) {
fluidbake_free_data(channels, fobjects, fsset, fb);
return 0;
}
-
+
/* these both have to be valid, otherwise we wouldn't be here */
fluidmd = (FluidsimModifierData *)modifiers_findByType(fsDomain, eModifierType_Fluidsim);
domainSettings = fluidmd->fss;
mesh = fsDomain->data;
-
+
domainSettings->bakeStart = 1;
domainSettings->bakeEnd = scene->r.efra;
-
+
// calculate bounding box
fluid_get_bb(mesh->mvert, mesh->totvert, fsDomain->obmat, domainSettings->bbStart, domainSettings->bbSize);
-
+
// reset last valid frame
domainSettings->lastgoodframe = -1;
/* delete old baked files */
fluidsim_delete_until_lastframe(domainSettings, relbase);
-
+
/* rough check of settings... */
if (domainSettings->previewresxyz > domainSettings->resolutionxyz) {
BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", domainSettings->previewresxyz, domainSettings->resolutionxyz);
@@ -937,31 +939,31 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
}
BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name, gridlevels);
elbeemDebugOut(debugStrBuffer);
-
-
-
+
+
+
/* ******** prepare output file paths ******** */
- if (!fluid_init_filepaths(reports, domainSettings, fsDomain, targetDir, targetFile)) {
+ if (!fluid_init_filepaths(bmain, reports, domainSettings, fsDomain, targetDir, targetFile)) {
fluidbake_free_data(channels, fobjects, fsset, fb);
return false;
}
channels->length = scene->r.efra; // DG TODO: why using endframe and not "noFrames" here? .. because "noFrames" is buggy too? (not using sfra)
channels->aniFrameTime = (double)((double)domainSettings->animEnd - (double)domainSettings->animStart) / (double)noFrames;
-
+
/* ******** initialize and allocate animation channels ******** */
fluid_init_all_channels(C, fsDomain, domainSettings, channels, fobjects);
/* reset to original current frame */
scene->r.cfra = origFrame;
ED_update_for_newframe(CTX_data_main(C), depsgraph);
-
+
/* ******** init domain object's matrix ******** */
copy_m4_m4(domainMat, fsDomain->obmat);
if (!invert_m4_m4(invDomMat, domainMat)) {
BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::error - Invalid obj matrix?\n");
elbeemDebugOut(debugStrBuffer);
- BKE_report(reports, RPT_ERROR, "Invalid object matrix");
+ BKE_report(reports, RPT_ERROR, "Invalid object matrix");
fluidbake_free_data(channels, fobjects, fsset, fb);
return 0;
@@ -978,7 +980,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
// setup global settings
copy_v3_v3(fsset->geoStart, domainSettings->bbStart);
copy_v3_v3(fsset->geoSize, domainSettings->bbSize);
-
+
// simulate with 50^3
fsset->resolutionxyz = (int)domainSettings->resolutionxyz;
fsset->previewresxyz = (int)domainSettings->previewresxyz;
@@ -997,21 +999,21 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
// defaults for compressibility and adaptive grids
fsset->gstar = domainSettings->gstar;
fsset->maxRefine = domainSettings->maxRefine; // check <-> gridlevels
- fsset->generateParticles = domainSettings->generateParticles;
- fsset->numTracerParticles = domainSettings->generateTracers;
- fsset->surfaceSmoothing = domainSettings->surfaceSmoothing;
- fsset->surfaceSubdivs = domainSettings->surfaceSubdivs;
- fsset->farFieldSize = domainSettings->farFieldSize;
+ fsset->generateParticles = domainSettings->generateParticles;
+ fsset->numTracerParticles = domainSettings->generateTracers;
+ fsset->surfaceSmoothing = domainSettings->surfaceSmoothing;
+ fsset->surfaceSubdivs = domainSettings->surfaceSubdivs;
+ fsset->farFieldSize = domainSettings->farFieldSize;
BLI_strncpy(fsset->outputPath, targetFile, sizeof(fsset->outputPath));
// domain channels
- fsset->channelSizeFrameTime =
- fsset->channelSizeViscosity =
+ fsset->channelSizeFrameTime =
+ fsset->channelSizeViscosity =
fsset->channelSizeGravity = channels->length;
fsset->channelFrameTime = channels->DomainTime;
fsset->channelViscosity = channels->DomainViscosity;
fsset->channelGravity = channels->DomainGravity;
-
+
fsset->runsimCallback = &runSimulationCallback;
fsset->runsimUserData = fb;
@@ -1039,13 +1041,13 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
/* ******** init solver with settings ******** */
elbeemInit();
elbeemAddDomain(fsset);
-
+
/* ******** export all fluid objects to elbeem ******** */
export_fluid_objects(C, fobjects, scene, channels->length);
-
+
/* custom data for fluid bake job */
fb->settings = fsset;
-
+
if (do_job) {
wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation",
WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_FLUID);
@@ -1117,7 +1119,7 @@ void FLUID_OT_bake(wmOperatorType *ot)
ot->name = "Fluid Simulation Bake";
ot->description = "Bake fluid simulation";
ot->idname = "FLUID_OT_bake";
-
+
/* api callbacks */
ot->invoke = fluid_bake_invoke;
ot->exec = fluid_bake_exec;
diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c
index 758ef43590e..ffa73b41bd9 100644
--- a/source/blender/editors/physics/physics_ops.c
+++ b/source/blender/editors/physics/physics_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -111,10 +111,10 @@ static void keymap_particle(wmKeyConfig *keyconf)
{
wmKeyMapItem *kmi;
wmKeyMap *keymap;
-
+
keymap = WM_keymap_find(keyconf, "Particle", 0, 0);
keymap->poll = PE_poll;
-
+
kmi = WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", AKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
kmi = WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
@@ -149,7 +149,7 @@ static void keymap_particle(wmKeyConfig *keyconf)
RNA_string_set(kmi->ptr, "data_path_primary", "tool_settings.particle_edit.brush.strength");
WM_keymap_add_menu(keymap, "VIEW3D_MT_particle_specials", WKEY, KM_PRESS, 0, 0);
-
+
WM_keymap_add_item(keymap, "PARTICLE_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0);
ED_keymap_proportional_cycle(keyconf, keymap);
@@ -205,7 +205,7 @@ static void operatortypes_dynamicpaint(void)
//static void keymap_pointcache(wmWindowManager *wm)
//{
// wmKeyMap *keymap = WM_keymap_find(wm, "Pointcache", 0, 0);
-//
+//
// WM_keymap_add_item(keymap, "PHYSICS_OT_bake_all", AKEY, KM_PRESS, 0, 0);
// WM_keymap_add_item(keymap, "PHYSICS_OT_free_all", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
// WM_keymap_add_item(keymap, "PHYSICS_OT_bake_particle_system", PADMINUS, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c
index fdafd6c28ed..45172774d55 100644
--- a/source/blender/editors/physics/physics_pointcache.c
+++ b/source/blender/editors/physics/physics_pointcache.c
@@ -256,9 +256,9 @@ static int ptcache_free_bake_all_exec(bContext *C, wmOperator *UNUSED(op))
for (pid = pidlist.first; pid; pid = pid->next) {
ptcache_free_bake(pid->cache);
}
-
+
BLI_freelistN(&pidlist);
-
+
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
}
FOREACH_SCENE_OBJECT_END;
@@ -274,7 +274,7 @@ void PTCACHE_OT_bake_all(wmOperatorType *ot)
ot->name = "Bake All Physics";
ot->description = "Bake all physics";
ot->idname = "PTCACHE_OT_bake_all";
-
+
/* api callbacks */
ot->exec = ptcache_bake_exec;
ot->invoke = ptcache_bake_invoke;
@@ -293,7 +293,7 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot)
ot->name = "Free All Physics Bakes";
ot->idname = "PTCACHE_OT_free_bake_all";
ot->description = "Free all baked caches of all objects in the current scene";
-
+
/* api callbacks */
ot->exec = ptcache_free_bake_all_exec;
ot->poll = ptcache_bake_all_poll;
@@ -309,7 +309,7 @@ static int ptcache_free_bake_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob= ptr.id.data;
ptcache_free_bake(cache);
-
+
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
return OPERATOR_FINISHED;
@@ -319,9 +319,9 @@ static int ptcache_bake_from_cache_exec(bContext *C, wmOperator *UNUSED(op))
PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
PointCache *cache= ptr.data;
Object *ob= ptr.id.data;
-
+
cache->flag |= PTCACHE_BAKED;
-
+
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
return OPERATOR_FINISHED;
@@ -332,7 +332,7 @@ void PTCACHE_OT_bake(wmOperatorType *ot)
ot->name = "Bake Physics";
ot->description = "Bake physics";
ot->idname = "PTCACHE_OT_bake";
-
+
/* api callbacks */
ot->exec = ptcache_bake_exec;
ot->invoke = ptcache_bake_invoke;
@@ -351,7 +351,7 @@ void PTCACHE_OT_free_bake(wmOperatorType *ot)
ot->name = "Free Physics Bake";
ot->description = "Free physics bake";
ot->idname = "PTCACHE_OT_free_bake";
-
+
/* api callbacks */
ot->exec = ptcache_free_bake_exec;
ot->poll = ptcache_poll;
@@ -365,7 +365,7 @@ void PTCACHE_OT_bake_from_cache(wmOperatorType *ot)
ot->name = "Bake From Cache";
ot->description = "Bake from cache";
ot->idname = "PTCACHE_OT_bake_from_cache";
-
+
/* api callbacks */
ot->exec = ptcache_bake_from_cache_exec;
ot->poll = ptcache_poll;
@@ -418,7 +418,7 @@ void PTCACHE_OT_add(wmOperatorType *ot)
ot->name = "Add New Cache";
ot->description = "Add new cache";
ot->idname = "PTCACHE_OT_add";
-
+
/* api callbacks */
ot->exec = ptcache_add_new_exec;
ot->poll = ptcache_poll;
@@ -432,7 +432,7 @@ void PTCACHE_OT_remove(wmOperatorType *ot)
ot->name = "Delete Current Cache";
ot->description = "Delete current cache";
ot->idname = "PTCACHE_OT_remove";
-
+
/* api callbacks */
ot->exec = ptcache_remove_exec;
ot->poll = ptcache_poll;
diff --git a/source/blender/editors/physics/rigidbody_world.c b/source/blender/editors/physics/rigidbody_world.c
index bd8505fcf15..8d5258a7522 100644
--- a/source/blender/editors/physics/rigidbody_world.c
+++ b/source/blender/editors/physics/rigidbody_world.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -24,7 +24,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
/** \file rigidbody_world.c
* \ingroup editor_physics
* \brief Rigid Body world editing operators
@@ -174,7 +174,7 @@ static int rigidbody_world_export_invoke(bContext *C, wmOperator *op, const wmEv
// TODO: use the actual rigidbody world's name + .bullet instead of this temp crap
RNA_string_set(op->ptr, "filepath", "rigidbodyworld_export.bullet");
- WM_event_add_fileselect(C, op);
+ WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
}
diff --git a/source/blender/editors/render/render_intern.h b/source/blender/editors/render/render_intern.h
index a1f646aefc1..d7b92c00ed4 100644
--- a/source/blender/editors/render/render_intern.h
+++ b/source/blender/editors/render/render_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 4e44c9b1185..d990f0b34d0 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -272,7 +272,7 @@ static void screen_render_single_layer_set(wmOperator *op, Main *mainp, WorkSpac
RNA_string_get(op->ptr, "scene", scene_name);
scn = (Scene *)BLI_findstring(&mainp->scene, scene_name, offsetof(ID, name) + 2);
-
+
if (scn) {
/* camera switch wont have updated */
scn->r.cfra = (*scene)->r.cfra;
@@ -288,7 +288,7 @@ static void screen_render_single_layer_set(wmOperator *op, Main *mainp, WorkSpac
RNA_string_get(op->ptr, "layer", rl_name);
rl = (ViewLayer *)BLI_findstring(&(*scene)->view_layers, rl_name, offsetof(ViewLayer, name));
-
+
if (rl)
*single_layer = rl;
}
@@ -314,7 +314,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL;
/* Cannot do render if there is not this function. */
- if (re_type->render_to_image == NULL) {
+ if (re_type->render == NULL) {
return OPERATOR_CANCELLED;
}
@@ -332,8 +332,8 @@ static int screen_render_exec(bContext *C, wmOperator *op)
G.is_break = false;
RE_test_break_cb(re, NULL, render_break);
- ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
- BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
+ ima = BKE_image_verify_viewer(mainp, IMA_TYPE_R_RESULT, "Render Result");
+ BKE_image_signal(mainp, ima, NULL, IMA_SIGNAL_FREE);
BKE_image_backup_render(scene, ima, true);
/* cleanup sequencer caches before starting user triggered render.
@@ -445,7 +445,7 @@ static void make_renderinfo_string(const RenderStats *rs,
/* full sample */
if (rs->curfsa)
spos += sprintf(spos, IFACE_("| Full Sample %d "), rs->curfsa);
-
+
/* extra info */
if (rs->infostr && rs->infostr[0]) {
spos += sprintf(spos, "| %s ", rs->infostr);
@@ -487,7 +487,7 @@ static void image_renderinfo_cb(void *rjv, RenderStats *rs)
static void render_progress_update(void *rjv, float progress)
{
RenderJob *rj = rjv;
-
+
if (rj->progress && *rj->progress != progress) {
*rj->progress = progress;
@@ -570,14 +570,14 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec
else if (rj->image_outdated) {
/* update entire render */
rj->image_outdated = false;
- BKE_image_signal(ima, NULL, IMA_SIGNAL_COLORMANAGE);
+ BKE_image_signal(rj->main, ima, NULL, IMA_SIGNAL_COLORMANAGE);
*(rj->do_update) = true;
return;
}
-
+
if (rr == NULL)
return;
-
+
/* update part of render */
render_image_update_pass_and_layer(rj, rr, &rj->iuser);
ibuf = BKE_image_acquire_ibuf(ima, &rj->iuser, &lock);
@@ -596,7 +596,7 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec
{
image_buffer_rect_update(rj, rr, ibuf, &rj->iuser, renrect, viewname);
}
-
+
/* make jobs timer to send notifier */
*(rj->do_update) = true;
}
@@ -683,13 +683,13 @@ static void render_endjob(void *rjv)
ED_update_for_newframe(G.main, rj->depsgraph);
}
}
-
+
/* XXX above function sets all tags in nodes */
ntreeCompositClearTags(rj->scene->nodetree);
-
+
/* potentially set by caller */
rj->scene->r.scemode &= ~R_NO_FRAME_UPDATE;
-
+
if (rj->single_layer) {
nodeUpdateID(rj->scene->nodetree, &rj->scene->id);
WM_main_add_notifier(NC_NODE | NA_EDITED, rj->scene);
@@ -883,7 +883,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
ScrArea *sa;
/* Cannot do render if there is not this function. */
- if (re_type->render_to_image == NULL) {
+ if (re_type->render == NULL) {
return OPERATOR_CANCELLED;
}
@@ -902,14 +902,14 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
BKE_report(op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected");
return OPERATOR_CANCELLED;
}
-
+
/* stop all running jobs, except screen one. currently previews frustrate Render */
WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C));
/* cancel animation playback */
if (ED_screen_animation_playing(CTX_wm_manager(C)))
ED_screen_animation_play(C, 0, 0);
-
+
/* handle UI stuff */
WM_cursor_wait(1);
@@ -930,7 +930,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
sa = render_view_open(C, event->x, event->y, op->reports);
jobflag = WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS;
-
+
if (RNA_struct_property_is_set(op->ptr, "layer"))
jobflag |= WM_JOB_SUSPEND;
@@ -1002,8 +1002,8 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
WM_jobs_callbacks(wm_job, render_startjob, NULL, NULL, render_endjob);
/* get a render result image, and make sure it is empty */
- ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
- BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
+ ima = BKE_image_verify_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result");
+ BKE_image_signal(rj->main, ima, NULL, IMA_SIGNAL_FREE);
BKE_image_backup_render(rj->scene, ima, true);
rj->image = ima;
@@ -1015,6 +1015,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
RE_current_scene_update_cb(re, rj, current_scene_update);
RE_stats_draw_cb(re, rj, image_renderinfo_cb);
RE_progress_cb(re, rj, render_progress_update);
+ RE_gl_context_create(re);
rj->re = re;
G.is_break = false;
@@ -1075,10 +1076,10 @@ Scene *ED_render_job_get_scene(const bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
RenderJob *rj = (RenderJob *)WM_jobs_customdata_from_type(wm, WM_JOB_TYPE_RENDER);
-
+
if (rj)
return rj->scene;
-
+
return NULL;
}
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index bf6aa9c9675..fb007accaeb 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -404,7 +404,7 @@ static void screen_opengl_render_write(OGLRender *oglrender)
rr = RE_AcquireResultRead(oglrender->re);
BKE_image_path_from_imformat(
- name, scene->r.pic, oglrender->bmain->name, scene->r.cfra,
+ name, scene->r.pic, BKE_main_blendfile_path(oglrender->bmain), scene->r.cfra,
&scene->r.im_format, (scene->r.scemode & R_EXTENSION) != 0, false, NULL);
/* write images as individual images or stereo */
@@ -455,7 +455,7 @@ static void add_gpencil_renderpass(const bContext *C, OGLRender *oglrender, Rend
short oldalphamode = scene->r.alphamode;
/* set alpha transparent for gp */
scene->r.alphamode = R_ALPHAPREMUL;
-
+
/* saves layer status */
short *oldsts = MEM_mallocN(BLI_listbase_count(&gpd->layers) * sizeof(short), "temp_gplayers_flag");
int i = 0;
@@ -477,7 +477,7 @@ static void add_gpencil_renderpass(const bContext *C, OGLRender *oglrender, Rend
/* render this gp layer */
screen_opengl_render_doit(C, oglrender, rr);
-
+
/* add RendePass composite */
RenderPass *rp = RE_create_gp_pass(rr, gpl->info, rv->name);
@@ -532,7 +532,7 @@ static void screen_opengl_render_apply(const bContext *C, OGLRender *oglrender)
int chanshown = sseq ? sseq->chanshown : 0;
BKE_sequencer_new_render_data(
- oglrender->bmain, scene,
+ oglrender->bmain, oglrender->depsgraph, scene,
oglrender->sizex, oglrender->sizey, 100.0f, false,
&context);
@@ -705,8 +705,8 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
oglrender->re = RE_NewSceneRender(scene);
/* create image and image user */
- oglrender->ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
- BKE_image_signal(oglrender->ima, NULL, IMA_SIGNAL_FREE);
+ oglrender->ima = BKE_image_verify_viewer(oglrender->bmain, IMA_TYPE_R_RESULT, "Render Result");
+ BKE_image_signal(oglrender->bmain, oglrender->ima, NULL, IMA_SIGNAL_FREE);
BKE_image_backup_render(oglrender->scene, oglrender->ima, true);
oglrender->iuser.scene = scene;
@@ -943,7 +943,7 @@ static void write_result_func(TaskPool * __restrict pool,
char name[FILE_MAX];
BKE_image_path_from_imformat(name,
scene->r.pic,
- oglrender->bmain->name,
+ BKE_main_blendfile_path(oglrender->bmain),
cfra,
&scene->r.im_format,
(scene->r.scemode & R_EXTENSION) != 0,
@@ -1030,7 +1030,7 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
if (!is_movie) {
BKE_image_path_from_imformat(
- name, scene->r.pic, oglrender->bmain->name, scene->r.cfra,
+ name, scene->r.pic, BKE_main_blendfile_path(oglrender->bmain), scene->r.cfra,
&scene->r.im_format, (scene->r.scemode & R_EXTENSION) != 0, true, NULL);
if ((scene->r.mode & R_NO_OVERWRITE) && BLI_exists(name)) {
@@ -1108,7 +1108,7 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, const wmEvent
/* run first because screen_opengl_render_anim_step can free oglrender */
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, oglrender->scene);
-
+
if (anim == 0) {
screen_opengl_render_apply(C, op->customdata);
screen_opengl_render_end(C, op->customdata);
@@ -1138,16 +1138,16 @@ static int screen_opengl_render_invoke(bContext *C, wmOperator *op, const wmEven
if (!screen_opengl_render_anim_initialize(C, op))
return OPERATOR_CANCELLED;
}
-
+
oglrender = op->customdata;
render_view_open(C, event->x, event->y, op->reports);
-
+
/* view may be changed above (R_OUTPUT_WINDOW) */
oglrender->win = CTX_wm_window(C);
WM_event_add_modal_handler(C, op);
oglrender->timer = WM_event_add_timer(oglrender->wm, oglrender->win, TIMER, 0.01f);
-
+
return OPERATOR_RUNNING_MODAL;
}
diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c
index 13fe40e768a..dd5ed5b78f1 100644
--- a/source/blender/editors/render/render_ops.c
+++ b/source/blender/editors/render/render_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -52,7 +52,7 @@ void ED_operatortypes_render(void)
WM_operatortype_append(MATERIAL_OT_new);
WM_operatortype_append(TEXTURE_OT_new);
WM_operatortype_append(WORLD_OT_new);
-
+
WM_operatortype_append(MATERIAL_OT_copy);
WM_operatortype_append(MATERIAL_OT_paste);
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 946da6f1ed8..4a3c7a3fd4b 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -40,7 +40,7 @@
#include <unistd.h>
#else
#include <io.h>
-#endif
+#endif
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
@@ -122,7 +122,7 @@ ImBuf *get_brush_icon(Brush *brush)
// first use the path directly to try and load the file
BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath));
- BLI_path_abs(path, G.main->name);
+ BLI_path_abs(path, BKE_main_blendfile_path_from_global());
/* use default colorspaces for brushes */
brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);
@@ -131,7 +131,7 @@ ImBuf *get_brush_icon(Brush *brush)
if (!(brush->icon_imbuf)) {
folder = BKE_appdir_folder_id(BLENDER_DATAFILES, "brushicons");
- BLI_make_file_string(G.main->name, path, folder, brush->icon_filepath);
+ BLI_make_file_string(BKE_main_blendfile_path_from_global(), path, folder, brush->icon_filepath);
if (path[0]) {
/* use fefault color spaces */
@@ -155,21 +155,21 @@ typedef struct ShaderPreview {
/* from wmJob */
void *owner;
short *stop, *do_update;
-
+
Scene *scene;
Depsgraph *depsgraph;
ID *id;
ID *parent;
MTex *slot;
-
+
/* datablocks with nodes need full copy during preview render, glsl uses it too */
Material *matcopy;
Tex *texcopy;
Lamp *lampcopy;
World *worldcopy;
-
+
float col[4]; /* active object color */
-
+
int sizex, sizey;
unsigned int *pr_rect;
int pr_method;
@@ -249,7 +249,7 @@ void ED_preview_free_dbase(void)
static Scene *preview_get_scene(Main *pr_main)
{
if (pr_main == NULL) return NULL;
-
+
return pr_main->scene.first;
}
@@ -319,7 +319,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
Scene *sce;
Main *pr_main = sp->pr_main;
- memcpy(pr_main->name, bmain->name, sizeof(pr_main->name));
+ memcpy(pr_main->name, BKE_main_blendfile_path(bmain), sizeof(pr_main->name));
sce = preview_get_scene(pr_main);
if (sce) {
@@ -334,13 +334,13 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
sce->world->exp = scene->world->exp;
sce->world->range = scene->world->range;
}
-
+
sce->r.color_mgt_flag = scene->r.color_mgt_flag;
BKE_color_managed_display_settings_copy(&sce->display_settings, &scene->display_settings);
BKE_color_managed_view_settings_free(&sce->view_settings);
BKE_color_managed_view_settings_copy(&sce->view_settings, &scene->view_settings);
-
+
/* prevent overhead for small renders and icons (32) */
if (id && sp->sizex < 40) {
sce->r.tilex = sce->r.tiley = 64;
@@ -349,7 +349,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
sce->r.tilex = sce->r.xsch / 4;
sce->r.tiley = sce->r.ysch / 4;
}
-
+
if ((id && sp->pr_method == PR_ICON_RENDER) && id_type != ID_WO)
sce->r.alphamode = R_ALPHAPREMUL;
else
@@ -367,16 +367,16 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
else {
BLI_strncpy(sce->r.engine, scene->r.engine, sizeof(sce->r.engine));
}
-
+
if (id_type == ID_MA) {
Material *mat = NULL, *origmat = (Material *)id;
-
+
if (origmat) {
/* work on a copy */
mat = BKE_material_localize(origmat);
sp->matcopy = mat;
BLI_addtail(&pr_main->mat, mat);
-
+
/* use current scene world to light sphere */
if (mat->pr_type == MA_SPHERE_A && sp->pr_method == PR_BUTS_RENDER) {
/* Use current scene world to light sphere. */
@@ -390,7 +390,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
sce->world->horg = 0.5f;
sce->world->horb = 0.5f;
}
-
+
if (sp->pr_method == PR_ICON_RENDER) {
set_preview_collection(sce, view_layer, MA_SPHERE_A);
}
@@ -406,14 +406,14 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
}
else {
sce->r.mode &= ~(R_OSA);
-
+
}
-
+
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
if (base->object->id.name[2] == 'p') {
/* copy over object color, in case material uses it */
copy_v4_v4(base->object->col, sp->col);
-
+
if (OB_TYPE_SUPPORT_MATERIAL(base->object->type)) {
/* don't use assign_material, it changed mat->id.us, which shows in the UI */
Material ***matar = give_matarar(base->object);
@@ -430,14 +430,14 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
}
else if (id_type == ID_TE) {
Tex *tex = NULL, *origtex = (Tex *)id;
-
+
if (origtex) {
tex = BKE_texture_localize(origtex);
sp->texcopy = tex;
BLI_addtail(&pr_main->tex, tex);
}
set_preview_collection(sce, view_layer, MA_TEXTURE);
-
+
if (tex && tex->nodetree && sp->pr_method == PR_NODE_RENDER) {
/* two previews, they get copied by wmJob */
BKE_node_preview_init_tree(origtex->nodetree, sp->sizex, sp->sizey, true);
@@ -463,7 +463,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
sce->world->horg = 0.0f;
sce->world->horb = 0.0f;
}
-
+
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
if (base->object->id.name[2] == 'p') {
if (base->object->type == OB_LAMP)
@@ -498,7 +498,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
return sce;
}
-
+
return NULL;
}
@@ -547,7 +547,7 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect,
}
if (rv && rv->rectf) {
-
+
if (ABS(rres.rectx - newx) < 2 && ABS(rres.recty - newy) < 2) {
newrect->xmax = max_ii(newrect->xmax, rect->xmin + rres.rectx + offx);
@@ -565,9 +565,9 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect,
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
immDrawPixelsTex(&state, fx, fy, rres.rectx, rres.recty, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect_byte,
1.0f, 1.0f, NULL);
-
+
MEM_freeN(rect_byte);
-
+
ok = 1;
}
}
@@ -629,7 +629,7 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
static void shader_preview_update(void *spv, RenderResult *UNUSED(rr), volatile struct rcti *UNUSED(rect))
{
ShaderPreview *sp = spv;
-
+
*(sp->do_update) = true;
}
@@ -645,30 +645,30 @@ static int shader_preview_break(void *spv)
static void shader_preview_updatejob(void *spv)
{
ShaderPreview *sp = spv;
-
+
if (sp->id) {
if (sp->pr_method == PR_NODE_RENDER) {
if (GS(sp->id->name) == ID_MA) {
Material *mat = (Material *)sp->id;
-
+
if (sp->matcopy && mat->nodetree && sp->matcopy->nodetree)
ntreeLocalSync(sp->matcopy->nodetree, mat->nodetree);
}
else if (GS(sp->id->name) == ID_TE) {
Tex *tex = (Tex *)sp->id;
-
+
if (sp->texcopy && tex->nodetree && sp->texcopy->nodetree)
ntreeLocalSync(sp->texcopy->nodetree, tex->nodetree);
}
else if (GS(sp->id->name) == ID_WO) {
World *wrld = (World *)sp->id;
-
+
if (sp->worldcopy && wrld->nodetree && sp->worldcopy->nodetree)
ntreeLocalSync(sp->worldcopy->nodetree, wrld->nodetree);
}
else if (GS(sp->id->name) == ID_LA) {
Lamp *la = (Lamp *)sp->id;
-
+
if (sp->lampcopy && la->nodetree && sp->lampcopy->nodetree)
ntreeLocalSync(sp->lampcopy->nodetree, la->nodetree);
}
@@ -686,7 +686,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
int sizex;
Main *pr_main = sp->pr_main;
ID *id_eval = DEG_get_evaluated_id(sp->depsgraph, id);
-
+
/* in case of split preview, use border render */
if (split) {
if (first) sizex = sp->sizex / 2;
@@ -703,19 +703,19 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
sce->r.ysch = sp->sizey;
sce->r.size = 100;
}
-
+
/* get the stuff from the builtin preview dbase */
sce = preview_prepare_scene(sp->bmain, sp->scene, id_eval, idtype, sp);
if (sce == NULL) return;
-
+
if (!split || first) sprintf(name, "Preview %p", sp->owner);
else sprintf(name, "SecondPreview %p", sp->owner);
re = RE_GetRender(name);
-
+
/* full refreshed render from first tile */
if (re == NULL)
re = RE_NewRender(name);
-
+
/* sce->r gets copied in RE_InitState! */
sce->r.scemode &= ~(R_MATNODE_PREVIEW | R_TEXNODE_PREVIEW);
sce->r.scemode &= ~R_NO_IMAGE_LOAD;
@@ -740,7 +740,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
}
/* set this for all previews, default is react to G.is_break still */
RE_test_break_cb(re, sp, shader_preview_break);
-
+
/* lens adjust */
oldlens = ((Camera *)sce->camera->data)->lens;
if (sizex > sp->sizey)
@@ -754,14 +754,14 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
/* handle results */
if (sp->pr_method == PR_ICON_RENDER) {
// char *rct= (char *)(sp->pr_rect + 32*16 + 16);
-
+
if (sp->pr_rect)
RE_ResultGet32(re, sp->pr_rect);
}
/* unassign the pointers, reset vars */
preview_prepare_scene(sp->bmain, sp->scene, NULL, GS(id->name), sp);
-
+
/* XXX bad exception, end-exec is not being called in render, because it uses local main */
// if (idtype == ID_TE) {
// Tex *tex= (Tex *)id;
@@ -793,16 +793,16 @@ static void shader_preview_free(void *customdata)
{
ShaderPreview *sp = customdata;
Main *pr_main = sp->pr_main;
-
+
if (sp->matcopy) {
struct IDProperty *properties;
-
+
/* node previews */
shader_preview_updatejob(sp);
-
+
/* get rid of copied material */
BLI_remlink(&pr_main->mat, sp->matcopy);
-
+
BKE_material_free(sp->matcopy);
properties = IDP_GetProperties((ID *)sp->matcopy, false);
@@ -816,11 +816,11 @@ static void shader_preview_free(void *customdata)
struct IDProperty *properties;
/* node previews */
shader_preview_updatejob(sp);
-
+
/* get rid of copied texture */
BLI_remlink(&pr_main->tex, sp->texcopy);
BKE_texture_free(sp->texcopy);
-
+
properties = IDP_GetProperties((ID *)sp->texcopy, false);
if (properties) {
IDP_FreeProperty(properties);
@@ -832,11 +832,11 @@ static void shader_preview_free(void *customdata)
struct IDProperty *properties;
/* node previews */
shader_preview_updatejob(sp);
-
+
/* get rid of copied world */
BLI_remlink(&pr_main->world, sp->worldcopy);
BKE_world_free(sp->worldcopy);
-
+
properties = IDP_GetProperties((ID *)sp->worldcopy, false);
if (properties) {
IDP_FreeProperty(properties);
@@ -848,11 +848,11 @@ static void shader_preview_free(void *customdata)
struct IDProperty *properties;
/* node previews */
shader_preview_updatejob(sp);
-
+
/* get rid of copied lamp */
BLI_remlink(&pr_main->lamp, sp->lampcopy);
BKE_lamp_free(sp->lampcopy);
-
+
properties = IDP_GetProperties((ID *)sp->lampcopy, false);
if (properties) {
IDP_FreeProperty(properties);
@@ -860,7 +860,7 @@ static void shader_preview_free(void *customdata)
}
MEM_freeN(sp->lampcopy);
}
-
+
MEM_freeN(sp);
}
@@ -876,13 +876,13 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned
/* paranoia test */
if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL))
return;
-
+
/* waste of cpu cyles... but the imbuf API has no other way to scale fast (ton) */
ima = IMB_dupImBuf(ibuf);
-
- if (!ima)
+
+ if (!ima)
return;
-
+
if (ima->x > ima->y) {
scaledx = (float)w;
scaledy = ( (float)ima->y / (float)ima->x) * (float)w;
@@ -891,15 +891,15 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned
scaledx = ( (float)ima->x / (float)ima->y) * (float)h;
scaledy = (float)h;
}
-
+
ex = (short)scaledx;
ey = (short)scaledy;
-
+
dx = (w - ex) / 2;
dy = (h - ey) / 2;
-
+
IMB_scalefastImBuf(ima, ex, ey);
-
+
/* if needed, convert to 32 bits */
if (ima->rect == NULL)
IMB_rect_from_float(ima);
@@ -917,7 +917,7 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned
IMB_freeImBuf(ima);
}
-static void set_alpha(char *cp, int sizex, int sizey, char alpha)
+static void set_alpha(char *cp, int sizex, int sizey, char alpha)
{
int a, size = sizex * sizey;
@@ -1101,7 +1101,7 @@ static void icon_preview_endjob(void *customdata)
if (GS(ip->id->name) == ID_BR)
WM_main_add_notifier(NC_BRUSH | NA_EDITED, ip->id);
-#if 0
+#if 0
if (GS(ip->id->name) == ID_MA) {
Material *ma = (Material *)ip->id;
PreviewImage *prv_img = ma->preview;
@@ -1246,12 +1246,12 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M
if (ob && ob->totcol) copy_v4_v4(sp->col, ob->col);
else sp->col[0] = sp->col[1] = sp->col[2] = sp->col[3] = 1.0f;
-
+
/* setup job */
WM_jobs_customdata_set(wm_job, sp, shader_preview_free);
WM_jobs_timer(wm_job, 0.1, NC_MATERIAL, NC_MATERIAL);
WM_jobs_callbacks(wm_job, common_preview_startjob, NULL, shader_preview_updatejob, NULL);
-
+
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index e792de01e2c..3f32242cd1b 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -100,23 +100,24 @@
static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Main *bmain = CTX_data_main(C);
Object *ob = ED_object_context(C);
if (!ob)
return OPERATOR_CANCELLED;
-
- BKE_object_material_slot_add(ob);
+
+ BKE_object_material_slot_add(bmain, ob);
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
}
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob);
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_PREVIEW, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -126,7 +127,7 @@ void OBJECT_OT_material_slot_add(wmOperatorType *ot)
ot->name = "Add Material Slot";
ot->idname = "OBJECT_OT_material_slot_add";
ot->description = "Add a new material slot";
-
+
/* api callbacks */
ot->exec = material_slot_add_exec;
ot->poll = ED_operator_object_active_editable;
@@ -147,20 +148,20 @@ static int material_slot_remove_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Unable to remove material slot in edit mode");
return OPERATOR_CANCELLED;
}
-
- BKE_object_material_slot_remove(ob);
+
+ BKE_object_material_slot_remove(CTX_data_main(C), ob);
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
}
-
+
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob);
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_PREVIEW, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -170,7 +171,7 @@ void OBJECT_OT_material_slot_remove(wmOperatorType *ot)
ot->name = "Remove Material Slot";
ot->idname = "OBJECT_OT_material_slot_remove";
ot->description = "Remove the selected material slot";
-
+
/* api callbacks */
ot->exec = material_slot_remove_exec;
ot->poll = ED_operator_object_active_editable;
@@ -224,7 +225,7 @@ static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
-
+
return OPERATOR_FINISHED;
}
@@ -234,7 +235,7 @@ void OBJECT_OT_material_slot_assign(wmOperatorType *ot)
ot->name = "Assign Material Slot";
ot->idname = "OBJECT_OT_material_slot_assign";
ot->description = "Assign active material slot to selection";
-
+
/* api callbacks */
ot->exec = material_slot_assign_exec;
ot->poll = ED_operator_object_active_editable;
@@ -318,7 +319,7 @@ void OBJECT_OT_material_slot_select(wmOperatorType *ot)
ot->name = "Select Material Slot";
ot->idname = "OBJECT_OT_material_slot_select";
ot->description = "Select by active material slot";
-
+
/* api callbacks */
ot->exec = material_slot_select_exec;
@@ -337,7 +338,7 @@ void OBJECT_OT_material_slot_deselect(wmOperatorType *ot)
ot->name = "Deselect Material Slot";
ot->idname = "OBJECT_OT_material_slot_deselect";
ot->description = "Deselect by active material slot";
-
+
/* api callbacks */
ot->exec = material_slot_deselect_exec;
@@ -348,6 +349,7 @@ void OBJECT_OT_material_slot_deselect(wmOperatorType *ot)
static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Main *bmain = CTX_data_main(C);
Object *ob = ED_object_context(C);
Material ***matar;
@@ -358,8 +360,8 @@ static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op))
{
if (ob != ob_iter && give_matarar(ob_iter)) {
if (ob->data != ob_iter->data)
- assign_matarar(ob_iter, matar, ob->totcol);
-
+ assign_matarar(bmain, ob_iter, matar, ob->totcol);
+
if (ob_iter->totcol == ob->totcol) {
ob_iter->actcol = ob->actcol;
DEG_id_tag_update(&ob_iter->id, OB_RECALC_DATA);
@@ -490,7 +492,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
}
WM_event_add_notifier(C, NC_MATERIAL | NA_ADDED, ma);
-
+
return OPERATOR_FINISHED;
}
@@ -500,7 +502,7 @@ void MATERIAL_OT_new(wmOperatorType *ot)
ot->name = "New Material";
ot->idname = "MATERIAL_OT_new";
ot->description = "Add a new material";
-
+
/* api callbacks */
ot->exec = new_material_exec;
@@ -539,7 +541,7 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op))
}
WM_event_add_notifier(C, NC_TEXTURE | NA_ADDED, tex);
-
+
return OPERATOR_FINISHED;
}
@@ -549,7 +551,7 @@ void TEXTURE_OT_new(wmOperatorType *ot)
ot->name = "New Texture";
ot->idname = "TEXTURE_OT_new";
ot->description = "Add a new texture";
-
+
/* api callbacks */
ot->exec = new_texture_exec;
@@ -590,7 +592,7 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
}
WM_event_add_notifier(C, NC_WORLD | NA_ADDED, wo);
-
+
return OPERATOR_FINISHED;
}
@@ -600,7 +602,7 @@ void WORLD_OT_new(wmOperatorType *ot)
ot->name = "New World";
ot->idname = "WORLD_OT_new";
ot->description = "Create a new world Data-Block";
-
+
/* api callbacks */
ot->exec = new_world_exec;
@@ -623,7 +625,7 @@ static int view_layer_add_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&scene->id, 0);
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -633,7 +635,7 @@ void SCENE_OT_view_layer_add(wmOperatorType *ot)
ot->name = "Add View Layer";
ot->idname = "SCENE_OT_view_layer_add";
ot->description = "Add a view layer";
-
+
/* api callbacks */
ot->exec = view_layer_add_exec;
@@ -662,7 +664,7 @@ void SCENE_OT_view_layer_remove(wmOperatorType *ot)
ot->name = "Remove View Layer";
ot->idname = "SCENE_OT_view_layer_remove";
ot->description = "Remove the selected view layer";
-
+
/* api callbacks */
ot->exec = view_layer_remove_exec;
@@ -1431,11 +1433,11 @@ static int texture_slot_move_exec(bContext *C, wmOperator *op)
mtexswap = mtex_ar[act];
mtex_ar[act] = mtex_ar[act - 1];
mtex_ar[act - 1] = mtexswap;
-
+
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act - 1, -1, 0);
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act, act - 1, 0);
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, -1, act, 0);
-
+
set_active_mtex(id, act - 1);
}
}
@@ -1444,11 +1446,11 @@ static int texture_slot_move_exec(bContext *C, wmOperator *op)
mtexswap = mtex_ar[act];
mtex_ar[act] = mtex_ar[act + 1];
mtex_ar[act + 1] = mtexswap;
-
+
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act + 1, -1, 0);
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act, act + 1, 0);
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, -1, act, 0);
-
+
set_active_mtex(id, act + 1);
}
}
@@ -1494,7 +1496,7 @@ static int copy_material_exec(bContext *C, wmOperator *UNUSED(op))
if (ma == NULL)
return OPERATOR_CANCELLED;
- copy_matcopybuf(ma);
+ copy_matcopybuf(CTX_data_main(C), ma);
return OPERATOR_FINISHED;
}
@@ -1520,7 +1522,7 @@ static int paste_material_exec(bContext *C, wmOperator *UNUSED(op))
if (ma == NULL)
return OPERATOR_CANCELLED;
- paste_matcopybuf(ma);
+ paste_matcopybuf(CTX_data_main(C), ma);
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, ma);
@@ -1553,7 +1555,7 @@ void ED_render_clear_mtex_copybuf(void)
static void copy_mtex_copybuf(ID *id)
{
MTex **mtex = NULL;
-
+
switch (GS(id->name)) {
case ID_PA:
mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
@@ -1564,7 +1566,7 @@ static void copy_mtex_copybuf(ID *id)
default:
break;
}
-
+
if (mtex && *mtex) {
memcpy(&mtexcopybuf, *mtex, sizeof(MTex));
mtexcopied = 1;
@@ -1577,10 +1579,10 @@ static void copy_mtex_copybuf(ID *id)
static void paste_mtex_copybuf(ID *id)
{
MTex **mtex = NULL;
-
+
if (mtexcopied == 0 || mtexcopybuf.tex == NULL)
return;
-
+
switch (GS(id->name)) {
case ID_PA:
mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
@@ -1592,7 +1594,7 @@ static void paste_mtex_copybuf(ID *id)
BLI_assert(!"invalid id type");
return;
}
-
+
if (mtex) {
if (*mtex == NULL) {
*mtex = MEM_mallocN(sizeof(MTex), "mtex copy");
@@ -1600,9 +1602,9 @@ static void paste_mtex_copybuf(ID *id)
else if ((*mtex)->tex) {
id_us_min(&(*mtex)->tex->id);
}
-
+
memcpy(*mtex, &mtexcopybuf, sizeof(MTex));
-
+
id_us_plus((ID *)mtexcopybuf.tex);
}
}
@@ -1626,7 +1628,7 @@ static int copy_mtex_exec(bContext *C, wmOperator *UNUSED(op))
static int copy_mtex_poll(bContext *C)
{
ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
-
+
return (id != NULL);
}
@@ -1640,7 +1642,7 @@ void TEXTURE_OT_slot_copy(wmOperatorType *ot)
/* api callbacks */
ot->exec = copy_mtex_exec;
ot->poll = copy_mtex_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_INTERNAL; /* no undo needed since no changes are made to the mtex */
}
@@ -1666,7 +1668,7 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
id = &psys->part->id;
else if (linestyle)
id = &linestyle->id;
-
+
if (id == NULL)
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index 7da571f1941..b7e6508117e 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -111,12 +111,12 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update
CTX_wm_manager_set(C, bmain->wm.first);
wm = bmain->wm.first;
-
+
for (win = wm->windows.first; win; win = win->next) {
bScreen *sc = WM_window_get_active_screen(win);
ScrArea *sa;
ARegion *ar;
-
+
CTX_wm_window_set(C, win);
for (sa = sc->areabase.first; sa; sa = sa->next) {
@@ -220,22 +220,22 @@ static void render_engine_flag_changed(Main *bmain, int update_flag)
bScreen *sc;
ScrArea *sa;
ARegion *ar;
-
+
for (sc = bmain->screen.first; sc; sc = sc->id.next) {
for (sa = sc->areabase.first; sa; sa = sa->next) {
if (sa->spacetype != SPACE_VIEW3D)
continue;
-
+
for (ar = sa->regionbase.first; ar; ar = ar->next) {
RegionView3D *rv3d;
-
+
if (ar->regiontype != RGN_TYPE_WINDOW)
continue;
-
+
rv3d = ar->regiondata;
if (rv3d->render_engine)
rv3d->render_engine->update_flag |= update_flag;
-
+
}
}
}
diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c
index e4bae9d78ea..351ceda90e3 100644
--- a/source/blender/editors/render/render_view.c
+++ b/source/blender/editors/render/render_view.c
@@ -37,6 +37,7 @@
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_global.h"
+#include "BKE_main.h"
#include "BKE_screen.h"
#include "BKE_report.h"
@@ -104,7 +105,7 @@ static ScrArea *find_area_showing_r_result(bContext *C, Scene *scene, wmWindow *
break;
}
}
-
+
return sa;
}
@@ -131,6 +132,7 @@ static ScrArea *find_area_image_empty(bContext *C)
/* new window uses x,y to set position */
ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
wmWindow *win = NULL;
ScrArea *sa = NULL;
@@ -139,7 +141,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
if (scene->r.displaymode == R_OUTPUT_NONE)
return NULL;
-
+
if (scene->r.displaymode == R_OUTPUT_WINDOW) {
int sizex = 30 * UI_DPI_FAC + (scene->r.xsch * scene->r.size) / 100;
int sizey = 60 * UI_DPI_FAC + (scene->r.ysch * scene->r.size) / 100;
@@ -177,7 +179,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
sa = find_area_showing_r_result(C, scene, &win);
if (sa == NULL)
sa = find_area_image_empty(C);
-
+
/* if area found in other window, we make that one show in front */
if (win && win != CTX_wm_window(C))
wm_window_raise(win);
@@ -213,7 +215,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
sima = sa->spacedata.first;
/* get the correct image, and scale it */
- sima->image = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
+ sima->image = BKE_image_verify_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result");
/* if we're rendering to full screen, set appropriate hints on image editor
@@ -292,7 +294,7 @@ void RENDER_OT_view_cancel(struct wmOperatorType *ot)
static int render_view_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
wmWindow *wincur = CTX_wm_window(C);
-
+
/* test if we have currently a temp screen active */
if (WM_window_is_temp_screen(wincur)) {
wm_window_lower(wincur);
@@ -300,7 +302,7 @@ static int render_view_show_invoke(bContext *C, wmOperator *op, const wmEvent *e
else {
wmWindow *win, *winshow;
ScrArea *sa = find_area_showing_r_result(C, CTX_data_scene(C), &winshow);
-
+
/* is there another window on current scene showing result? */
for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) {
const bScreen *sc = WM_window_get_active_screen(win);
@@ -312,7 +314,7 @@ static int render_view_show_invoke(bContext *C, wmOperator *op, const wmEvent *e
return OPERATOR_FINISHED;
}
}
-
+
/* determine if render already shows */
if (sa) {
/* but don't close it when rendering */
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index e8192c4ce90..f73ce24c24b 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -311,7 +311,7 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2)
static void region_draw_azone_tab_plus(AZone *az)
{
glEnable(GL_BLEND);
-
+
/* add code to draw region hidden as 'too small' */
switch (az->edge) {
case AE_TOP_TO_BOTTOMRIGHT:
@@ -352,7 +352,7 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
gpuPushMatrix();
gpuTranslate2f(-ar->winrct.xmin, -ar->winrct.ymin);
-
+
for (az = sa->actionzones.first; az; az = az->next) {
/* test if action zone is over this region */
rcti azrct;
@@ -452,19 +452,19 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
return;
ar->do_draw |= RGN_DRAWING;
-
+
/* Set viewport, scissor, ortho and ar->drawrct. */
wmPartialViewport(&ar->drawrct, &ar->winrct, &ar->drawrct);
wmOrtho2_region_pixelspace(ar);
-
+
UI_SetTheme(sa ? sa->spacetype : 0, at->regionid);
-
+
/* optional header info instead? */
if (ar->headerstr) {
UI_ThemeClearColor(TH_HEADER);
glClear(GL_COLOR_BUFFER_BIT);
-
+
UI_FontThemeColor(BLF_default(), TH_TEXT);
BLF_draw_default(UI_UNIT_X, 0.4f * UI_UNIT_Y, 0.0f, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX);
}
@@ -493,7 +493,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
#endif
memset(&ar->drawrct, 0, sizeof(ar->drawrct));
-
+
UI_blocklist_free_inactive(C, &ar->uiblocks);
if (sa) {
@@ -602,7 +602,7 @@ void ED_region_tag_redraw_partial(ARegion *ar, const rcti *rct)
void ED_area_tag_redraw(ScrArea *sa)
{
ARegion *ar;
-
+
if (sa)
for (ar = sa->regionbase.first; ar; ar = ar->next)
ED_region_tag_redraw(ar);
@@ -620,7 +620,7 @@ void ED_area_tag_redraw_no_rebuild(ScrArea *sa)
void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype)
{
ARegion *ar;
-
+
if (sa) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == regiontype) {
@@ -669,7 +669,7 @@ void ED_area_headerprint(ScrArea *sa, const char *str)
static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea *sa)
{
AZone *az;
-
+
/* reinitalize entirely, regions and fullscreen add azones too */
BLI_freelistN(&sa->actionzones);
@@ -794,11 +794,11 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar)
{
AZone *azt;
int tot = 0, add;
-
+
for (azt = sa->actionzones.first; azt; azt = azt->next) {
if (azt->edge == az->edge) tot++;
}
-
+
switch (az->edge) {
case AE_TOP_TO_BOTTOMRIGHT:
add = (ar->winrct.ymax == sa->totrct.ymin) ? 1 : 0;
@@ -828,7 +828,7 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar)
}
/* rect needed for mouse pointer test */
BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
-}
+}
static void region_azone_edge_initialize(ScrArea *sa, ARegion *ar, AZEdge edge, const bool is_fullscreen)
{
@@ -848,7 +848,7 @@ static void region_azone_edge_initialize(ScrArea *sa, ARegion *ar, AZEdge edge,
if (is_hidden) {
region_azone_tab_plus(sa, az, ar);
}
- else {
+ else if (!is_hidden && (ar->regiontype != RGN_TYPE_HEADER)) {
region_azone_edge(az, ar);
}
}
@@ -1006,19 +1006,19 @@ static void region_overlap_fix(ScrArea *sa, ARegion *ar)
}
/* overlapping regions only in the following restricted cases */
-static bool region_is_overlap(ScrArea *sa, ARegion *ar)
+bool ED_region_is_overlap(int spacetype, int regiontype)
{
if (U.uiflag2 & USER_REGION_OVERLAP) {
- if (ELEM(sa->spacetype, SPACE_VIEW3D, SPACE_SEQ, SPACE_IMAGE)) {
- if (ELEM(ar->regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI, RGN_TYPE_TOOL_PROPS))
+ if (ELEM(spacetype, SPACE_VIEW3D, SPACE_SEQ, SPACE_IMAGE)) {
+ if (ELEM(regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI, RGN_TYPE_TOOL_PROPS))
return 1;
- if (ELEM(sa->spacetype, SPACE_VIEW3D, SPACE_IMAGE)) {
- if (ar->regiontype == RGN_TYPE_HEADER)
+ if (ELEM(spacetype, SPACE_VIEW3D, SPACE_IMAGE)) {
+ if (regiontype == RGN_TYPE_HEADER)
return 1;
}
- else if (sa->spacetype == SPACE_SEQ) {
- if (ar->regiontype == RGN_TYPE_PREVIEW)
+ else if (spacetype == SPACE_SEQ) {
+ if (regiontype == RGN_TYPE_PREVIEW)
return 1;
}
}
@@ -1032,22 +1032,22 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
rcti *remainder_prev = remainder;
int prefsizex, prefsizey;
int alignment;
-
+
if (ar == NULL)
return;
-
+
/* no returns in function, winrct gets set in the end again */
BLI_rcti_init(&ar->winrct, 0, 0, 0, 0);
-
+
/* for test; allow split of previously defined region */
if (ar->alignment & RGN_SPLIT_PREV)
if (ar->prev)
remainder = &ar->prev->winrct;
-
+
alignment = ar->alignment & ~RGN_SPLIT_PREV;
-
+
/* set here, assuming userpref switching forces to call this again */
- ar->overlap = region_is_overlap(sa, ar);
+ ar->overlap = ED_region_is_overlap(sa->spacetype, ar->regiontype);
/* clear state flags first */
ar->flag &= ~RGN_FLAG_TOO_SMALL;
@@ -1089,7 +1089,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
}
else if (alignment == RGN_ALIGN_TOP || alignment == RGN_ALIGN_BOTTOM) {
rcti *winrct = (ar->overlap) ? overlap_remainder : remainder;
-
+
if (rct_fits(winrct, 'v', prefsizey) < 0) {
ar->flag |= RGN_FLAG_TOO_SMALL;
}
@@ -1098,9 +1098,9 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
if (fac < 0)
prefsizey += fac;
-
+
ar->winrct = *winrct;
-
+
if (alignment == RGN_ALIGN_TOP) {
ar->winrct.ymin = ar->winrct.ymax - prefsizey + 1;
winrct->ymax = ar->winrct.ymin - 1;
@@ -1113,18 +1113,18 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
}
else if (ELEM(alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) {
rcti *winrct = (ar->overlap) ? overlap_remainder : remainder;
-
+
if (rct_fits(winrct, 'h', prefsizex) < 0) {
ar->flag |= RGN_FLAG_TOO_SMALL;
}
else {
int fac = rct_fits(winrct, 'h', prefsizex);
-
+
if (fac < 0)
prefsizex += fac;
-
+
ar->winrct = *winrct;
-
+
if (alignment == RGN_ALIGN_RIGHT) {
ar->winrct.xmin = ar->winrct.xmax - prefsizex + 1;
winrct->xmax = ar->winrct.xmin - 1;
@@ -1138,7 +1138,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
else if (alignment == RGN_ALIGN_VSPLIT || alignment == RGN_ALIGN_HSPLIT) {
/* percentage subdiv*/
ar->winrct = *remainder;
-
+
if (alignment == RGN_ALIGN_HSPLIT) {
if (rct_fits(remainder, 'h', prefsizex) > 4) {
ar->winrct.xmax = BLI_rcti_cent_x(remainder);
@@ -1160,18 +1160,18 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
}
else if (alignment == RGN_ALIGN_QSPLIT) {
ar->winrct = *remainder;
-
+
/* test if there's still 4 regions left */
if (quad == 0) {
ARegion *artest = ar->next;
int count = 1;
-
+
while (artest) {
artest->alignment = RGN_ALIGN_QSPLIT;
artest = artest->next;
count++;
}
-
+
if (count != 4) {
/* let's stop adding regions */
BLI_rcti_init(remainder, 0, 0, 0, 0);
@@ -1204,16 +1204,16 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
quad++;
}
}
-
+
/* for speedup */
ar->winx = BLI_rcti_size_x(&ar->winrct) + 1;
ar->winy = BLI_rcti_size_y(&ar->winrct) + 1;
-
+
/* if region opened normally, we store this for hide/reveal usage */
/* prevent rounding errors for UI_DPI_FAC mult and divide */
if (ar->winx > 1) ar->sizex = (ar->winx + 0.5f) / UI_DPI_FAC;
if (ar->winy > 1) ar->sizey = (ar->winy + 0.5f) / UI_DPI_FAC;
-
+
/* exception for multiple overlapping regions on same spot */
if (ar->overlap) {
region_overlap_fix(sa, ar);
@@ -1222,7 +1222,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
/* set winrect for azones */
if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) {
ar->winrct = (ar->overlap) ? *overlap_remainder : *remainder;
-
+
switch (alignment) {
case RGN_ALIGN_TOP:
ar->winrct.ymin = ar->winrct.ymax;
@@ -1328,7 +1328,7 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand
if (flag & ED_KEYMAP_MARKERS) {
/* time-markers */
wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Markers", 0, 0);
-
+
/* use a boundbox restricted map */
ARegion *ar;
/* same local check for all areas */
@@ -1351,16 +1351,16 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand
}
if (flag & ED_KEYMAP_GPENCIL) {
/* grease pencil */
- /* NOTE: This is now 2 keymaps - One for basic functionality,
- * and one that only applies when "Edit Mode" is enabled
+ /* NOTE: This is now 2 keymaps - One for basic functionality,
+ * and one that only applies when "Edit Mode" is enabled
* for strokes.
*
- * For now, it's easier to just include both,
+ * For now, it's easier to just include both,
* since you hardly want one without the other.
*/
wmKeyMap *keymap_general = WM_keymap_find(wm->defaultconf, "Grease Pencil", 0, 0);
wmKeyMap *keymap_edit = WM_keymap_find(wm->defaultconf, "Grease Pencil Stroke Edit Mode", 0, 0);
-
+
WM_event_add_keymap_handler(handlers, keymap_general);
WM_event_add_keymap_handler(handlers, keymap_edit);
}
@@ -1417,7 +1417,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
/* set typedefinitions */
sa->type = BKE_spacetype_from_id(sa->spacetype);
-
+
if (sa->type == NULL) {
sa->spacetype = SPACE_VIEW3D;
sa->type = BKE_spacetype_from_id(sa->spacetype);
@@ -1434,7 +1434,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
overlap_rect = rect;
region_rect_recursive(win, sa, sa->regionbase.first, &rect, &overlap_rect, 0);
sa->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
-
+
/* default area handlers */
ed_default_handlers(wm, sa, &sa->handlers, sa->type->keymapflag);
/* checks spacedata, adds own handlers */
@@ -1447,7 +1447,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
/* region windows, default and own handlers */
for (ar = sa->regionbase.first; ar; ar = ar->next) {
region_subwindow(ar);
-
+
if (ar->visible) {
/* default region handlers */
ed_default_handlers(wm, sa, &ar->handlers, ar->type->keymapflag);
@@ -1511,10 +1511,10 @@ void ED_region_cursor_set(wmWindow *win, ScrArea *sa, ARegion *ar)
void ED_region_visibility_change_update(bContext *C, ARegion *ar)
{
ScrArea *sa = CTX_wm_area(C);
-
+
if (ar->flag & RGN_FLAG_HIDDEN)
WM_event_remove_handlers(C, &ar->handlers);
-
+
ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
ED_area_tag_redraw(sa);
}
@@ -1523,9 +1523,9 @@ void ED_region_visibility_change_update(bContext *C, ARegion *ar)
void region_toggle_hidden(bContext *C, ARegion *ar, const bool do_fade)
{
ScrArea *sa = CTX_wm_area(C);
-
+
ar->flag ^= RGN_FLAG_HIDDEN;
-
+
if (do_fade && ar->overlap) {
/* starts a timer, and in end calls the stuff below itself (region_sblend_invoke()) */
region_blend_start(C, sa, ar);
@@ -1550,7 +1550,7 @@ void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free)
ARegion *ar;
const char spacetype = sa_dst->spacetype;
const short flag_copy = HEADER_NO_PULLDOWN;
-
+
sa_dst->spacetype = sa_src->spacetype;
sa_dst->type = sa_src->type;
@@ -1608,7 +1608,7 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2)
/* tell WM to refresh, cursor types etc */
WM_event_add_mousemove(C);
-
+
ED_area_tag_redraw(sa1);
ED_area_tag_refresh(sa1);
ED_area_tag_redraw(sa2);
@@ -1657,7 +1657,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
for (sl = sa->spacedata.first; sl; sl = sl->next)
if (sl->spacetype == type)
break;
-
+
/* old spacedata... happened during work on 2.50, remove */
if (sl && BLI_listbase_is_empty(&sl->regionbase)) {
st->free(sl);
@@ -1673,7 +1673,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
slold->regionbase = sa->regionbase;
sa->regionbase = sl->regionbase;
BLI_listbase_clear(&sl->regionbase);
-
+
/* put in front of list */
BLI_remlink(&sa->spacedata, sl);
BLI_addhead(&sa->spacedata, sl);
@@ -1694,7 +1694,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
Scene *scene = WM_window_get_active_scene(win);
sl = st->new(sa, scene);
BLI_addhead(&sa->spacedata, sl);
-
+
/* swap regions */
if (slold)
slold->regionbase = sa->regionbase;
@@ -1702,18 +1702,18 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
BLI_listbase_clear(&sl->regionbase);
}
}
-
+
ED_area_initialize(CTX_wm_manager(C), win, sa);
-
+
/* tell WM to refresh, cursor types etc */
WM_event_add_mousemove(C);
-
+
/* send space change notifier */
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, sa);
-
+
ED_area_tag_refresh(sa);
}
-
+
/* also redraw when re-used */
ED_area_tag_redraw(sa);
}
@@ -1753,7 +1753,7 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco)
RNA_pointer_create(&(scr->id), &RNA_Area, sa, &areaptr);
uiDefButR(block, UI_BTYPE_MENU, 0, "", xco, yco, 1.6 * U.widget_unit, U.widget_unit,
- &areaptr, "type", 0, 0.0f, 0.0f, 0.0f, 0.0f, "");
+ &areaptr, "ui_type", 0, 0.0f, 0.0f, 0.0f, 0.0f, "");
return xco + 1.7 * U.widget_unit;
}
@@ -1796,21 +1796,114 @@ static void region_clear_color(const bContext *C, const ARegion *ar, ThemeColorI
}
}
-void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int contextnr, const bool vertical)
+BLI_INLINE bool streq_array_any(const char *s, const char *arr[])
+{
+ for (uint i = 0; arr[i]; i++) {
+ if (STREQ(arr[i], s)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+static void ed_panel_draw(const bContext *C,
+ ScrArea *sa,
+ ARegion *ar,
+ ListBase *lb,
+ PanelType *pt,
+ Panel *panel,
+ int w,
+ int em,
+ bool vertical)
+{
+ uiStyle *style = UI_style_get_dpi();
+
+ /* draw panel */
+ uiBlock *block = UI_block_begin(C, ar, pt->idname, UI_EMBOSS);
+
+ bool open;
+ panel = UI_panel_begin(sa, ar, lb, block, pt, panel, &open);
+
+ /* bad fixed values */
+ int xco, yco, h = 0;
+
+ if (pt->draw_header && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) {
+ int labelx, labely;
+ UI_panel_label_offset(block, &labelx, &labely);
+
+ /* for enabled buttons */
+ panel->layout = UI_block_layout(
+ block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER,
+ labelx, labely, UI_UNIT_Y, 1, 0, style);
+
+ pt->draw_header(C, panel);
+
+ UI_block_layout_resolve(block, &xco, &yco);
+ panel->labelofs = xco - labelx;
+ panel->layout = NULL;
+ }
+ else {
+ panel->labelofs = 0;
+ }
+
+ if (open) {
+ short panelContext;
+
+ /* panel context can either be toolbar region or normal panels region */
+ if (ar->regiontype == RGN_TYPE_TOOLS)
+ panelContext = UI_LAYOUT_TOOLBAR;
+ else
+ panelContext = UI_LAYOUT_PANEL;
+
+ panel->layout = UI_block_layout(
+ block, UI_LAYOUT_VERTICAL, panelContext,
+ style->panelspace, 0, w - 2 * style->panelspace, em, 0, style);
+
+ pt->draw(C, panel);
+
+ UI_block_layout_resolve(block, &xco, &yco);
+ panel->layout = NULL;
+
+ if (yco != 0) {
+ h = -yco + 2 * style->panelspace;
+ }
+ }
+
+ UI_block_end(C, block);
+
+ /* Draw child panels. */
+ if (open) {
+ for (LinkData *link = pt->children.first; link; link = link->next) {
+ PanelType *child_pt = link->data;
+ Panel *child_panel = UI_panel_find_by_type(&panel->children, child_pt);
+
+ if (child_pt->draw && (!child_pt->poll || child_pt->poll(C, child_pt))) {
+ ed_panel_draw(C, sa, ar, &panel->children, child_pt, child_panel, w, em, vertical);
+ }
+ }
+ }
+
+ UI_panel_end(block, w, h);
+}
+
+/**
+ * \param contexts: A NULL terminated array of context strings to match against.
+ * Matching against any of these strings will draw the panel.
+ * Can be NULL to skip context checks.
+ */
+void ED_region_panels(const bContext *C, ARegion *ar, const char *contexts[], int contextnr, const bool vertical)
{
const WorkSpace *workspace = CTX_wm_workspace(C);
ScrArea *sa = CTX_wm_area(C);
- uiStyle *style = UI_style_get_dpi();
- uiBlock *block;
PanelType *pt;
- Panel *panel;
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
- int x, y, xco, yco, w, em, triangle;
+ int x, y, w, em;
bool is_context_new = 0;
int scroll;
- bool use_category_tabs = (ELEM(ar->regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI)); /* XXX, should use some better check? */
+ /* XXX, should use some better check? */
+ bool use_category_tabs = (ELEM(ar->regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI));
/* offset panels for small vertical tab area */
const char *category = NULL;
const int category_tabs_width = UI_PANEL_CATEGORY_MARGIN_WIDTH;
@@ -1820,7 +1913,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c
if (contextnr != -1)
is_context_new = UI_view2d_tab_set(v2d, contextnr);
-
+
/* before setting the view */
if (vertical) {
/* only allow scrolling in vertical direction */
@@ -1843,8 +1936,13 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c
/* collect panels to draw */
for (pt = ar->type->paneltypes.last; pt; pt = pt->prev) {
+ /* Only draw top level panels. */
+ if (pt->parent) {
+ continue;
+ }
+
/* verify context */
- if (context && pt->context[0] && !STREQ(context, pt->context)) {
+ if (contexts && pt->context[0] && !streq_array_any(pt->context, contexts)) {
continue;
}
@@ -1904,9 +2002,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c
BLI_SMALLSTACK_ITER_BEGIN(pt_stack, pt)
{
- bool open;
-
- panel = UI_panel_find_by_type(ar, pt);
+ Panel *panel = UI_panel_find_by_type(&ar->panels, pt);
if (use_category_tabs && pt->category[0] && !STREQ(category, pt->category)) {
if ((panel == NULL) || ((panel->flag & PNL_PIN) == 0)) {
@@ -1914,56 +2010,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c
}
}
- /* draw panel */
- block = UI_block_begin(C, ar, pt->idname, UI_EMBOSS);
- panel = UI_panel_begin(sa, ar, block, pt, panel, &open);
-
- /* bad fixed values */
- triangle = (int)(UI_UNIT_Y * 1.1f);
-
- if (pt->draw_header && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) {
- /* for enabled buttons */
- panel->layout = UI_block_layout(
- block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER,
- triangle, (UI_UNIT_Y * 1.1f) + style->panelspace, UI_UNIT_Y, 1, 0, style);
-
- pt->draw_header(C, panel);
-
- UI_block_layout_resolve(block, &xco, &yco);
- panel->labelofs = xco - triangle;
- panel->layout = NULL;
- }
- else {
- panel->labelofs = 0;
- }
-
- if (open) {
- short panelContext;
-
- /* panel context can either be toolbar region or normal panels region */
- if (ar->regiontype == RGN_TYPE_TOOLS)
- panelContext = UI_LAYOUT_TOOLBAR;
- else
- panelContext = UI_LAYOUT_PANEL;
-
- panel->layout = UI_block_layout(
- block, UI_LAYOUT_VERTICAL, panelContext,
- style->panelspace, 0, w - 2 * style->panelspace, em, 0, style);
-
- pt->draw(C, panel);
-
- UI_block_layout_resolve(block, &xco, &yco);
- panel->layout = NULL;
-
- yco -= 2 * style->panelspace;
- UI_panel_end(block, w, -yco);
- }
- else {
- yco = 0;
- UI_panel_end(block, w, 0);
- }
-
- UI_block_end(C, block);
+ ed_panel_draw(C, sa, ar, &ar->panels, pt, panel, w, em, vertical);
}
BLI_SMALLSTACK_ITER_END;
@@ -2013,7 +2060,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c
}
region_clear_color(C, ar, (ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK);
-
+
/* reset line width for drawing tabs */
glLineWidth(1.0f);
@@ -2025,7 +2072,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c
/* restore view matrix */
UI_view2d_view_restore(C);
-
+
if (use_category_tabs) {
UI_panel_category_draw_all(ar, category);
}
@@ -2055,7 +2102,7 @@ void ED_region_header_layout(const bContext *C, ARegion *ar)
Header header = {NULL};
int maxco, xco, yco;
int headery = ED_area_headersize();
- const int start_ofs = 0.4f * UI_UNIT_X;
+ const int start_ofs = UI_HEADER_OFFSET_START;
bool region_layout_based = ar->flag & RGN_FLAG_DYNAMIC_SIZE;
/* set view2d view matrix for scrolling (without scrollers) */
@@ -2079,7 +2126,7 @@ void ED_region_header_layout(const bContext *C, ARegion *ar)
header.type = ht;
header.layout = layout;
ht->draw(C, &header);
-
+
/* for view2d */
xco = uiLayoutGetWidth(layout);
if (xco > maxco)
@@ -2087,7 +2134,7 @@ void ED_region_header_layout(const bContext *C, ARegion *ar)
}
UI_block_layout_resolve(block, &xco, &yco);
-
+
/* for view2d */
if (xco > maxco)
maxco = xco;
@@ -2242,8 +2289,7 @@ void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float
}
}
- rect.ymin = BLI_rcti_size_y(&ar->winrct) - header_height * num_lines;
- rect.ymax = BLI_rcti_size_y(&ar->winrct);
+ rect.ymin = rect.ymax - header_height * num_lines;
/* setup scissor */
glGetIntegerv(GL_SCISSOR_BOX, scissor);
@@ -2387,7 +2433,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
if (metadata_is_valid(ibuf, temp_str, i, len)) {
BLF_position(fontid, xmin + ofs_x, ymin, 0.0f);
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
-
+
ofs_x += BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX) + UI_UNIT_X;
}
}
@@ -2527,7 +2573,7 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
Gwn_VertFormat *format = immVertexFormat();
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
-
+
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShade(TH_BACK, 20);
immRectf(pos, x1, y1, x2, y2);
@@ -2561,14 +2607,14 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
GWN_vertformat_clear(format);
pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
unsigned color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
+
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
immBegin(GWN_PRIM_LINES, 4 * count_fine + 4 * count_large);
-
+
float theme_color[3];
UI_GetThemeColorShade3fv(TH_BACK, (int)(20.0f * (1.0f - blendfac)), theme_color);
fac = 0.0f;
-
+
/* the fine resolution level */
for (int i = 0; i < count_fine; i++) {
immAttrib3fv(color, theme_color);
@@ -2585,7 +2631,7 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
if (count_large > 0) {
UI_GetThemeColor3fv(TH_BACK, theme_color);
fac = 0.0f;
-
+
/* the large resolution level */
for (int i = 0; i < count_large; i++) {
immAttrib3fv(color, theme_color);
@@ -2610,13 +2656,13 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
void ED_region_visible_rect(ARegion *ar, rcti *rect)
{
ARegion *arn = ar;
-
+
/* allow function to be called without area */
while (arn->prev)
arn = arn->prev;
-
+
*rect = ar->winrct;
-
+
/* check if a region overlaps with the current one */
for (; arn; arn = arn->next) {
if (ar != arn && arn->overlap) {
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 39178af9e4e..1d73566e5a8 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -62,7 +62,7 @@ void setlinestyle(int nr)
glDisable(GL_LINE_STIPPLE);
}
else {
-
+
glEnable(GL_LINE_STIPPLE);
if (U.pixelsize > 1.0f)
glLineStipple(nr, 0xCCCC);
@@ -72,10 +72,10 @@ void setlinestyle(int nr)
}
/* Invert line handling */
-
+
#define GL_TOGGLE(mode, onoff) (((onoff) ? glEnable : glDisable)(mode))
-void set_inverted_drawing(int enable)
+void set_inverted_drawing(int enable)
{
glLogicOp(enable ? GL_INVERT : GL_COPY);
GL_TOGGLE(GL_COLOR_LOGIC_OP, enable);
@@ -355,18 +355,18 @@ void immDrawPixelsTex_clipping(IMMDrawPixelsTexState *state,
void bglPolygonOffset(float viewdist, float dist)
{
static float winmat[16], offset = 0.0f;
-
+
if (dist != 0.0f) {
float offs;
-
+
// glEnable(GL_POLYGON_OFFSET_FILL);
// glPolygonOffset(-1.0, -1.0);
/* hack below is to mimic polygon offset */
gpuGetProjectionMatrix(winmat);
-
+
/* dist is from camera to center point */
-
+
if (winmat[15] > 0.5f) {
#if 1
offs = 0.00001f * dist * viewdist; // ortho tweaking
@@ -391,7 +391,7 @@ void bglPolygonOffset(float viewdist, float dist)
*/
offs = winmat[14] * -0.0025f * dist;
}
-
+
winmat[14] -= offs;
offset += offs;
}
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 85087d58276..864150be9da 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -80,7 +80,7 @@ const char *screen_context_dir[] = {
"sequences", "selected_sequences", "selected_editable_sequences", /* sequencer */
"gpencil_data", "gpencil_data_owner", /* grease pencil data */
"visible_gpencil_layers", "editable_gpencil_layers", "editable_gpencil_strokes",
- "active_gpencil_layer", "active_gpencil_frame", "active_gpencil_palette",
+ "active_gpencil_layer", "active_gpencil_frame", "active_gpencil_palette",
"active_gpencil_palettecolor", "active_gpencil_brush",
"active_operator", "selected_editable_fcurves",
NULL};
@@ -208,7 +208,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL;
EditBone *ebone, *flipbone = NULL;
const bool editable_bones = CTX_data_equals(member, "editable_bones");
-
+
if (arm && arm->edbo) {
uint objects_len;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
@@ -259,7 +259,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL;
EditBone *ebone, *flipbone = NULL;
const bool selected_editable_bones = CTX_data_equals(member, "selected_editable_bones");
-
+
if (arm && arm->edbo) {
uint objects_len;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
@@ -364,7 +364,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
else if (CTX_data_equals(member, "active_pose_bone")) {
bPoseChannel *pchan;
Object *obpose = BKE_object_pose_armature_get(obact);
-
+
pchan = BKE_pose_channel_active(obpose);
if (pchan) {
CTX_data_pointer_set(result, &obpose->id, &RNA_PoseBone, pchan);
@@ -393,7 +393,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
/* convenience for now, 1 object per scene in editmode */
if (obedit)
CTX_data_id_pointer_set(result, &obedit->id);
-
+
return 1;
}
else if (CTX_data_equals(member, "sculpt_object")) {
@@ -465,11 +465,11 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
else if (CTX_data_equals(member, "gpencil_data")) {
/* FIXME: for some reason, CTX_data_active_object(C) returns NULL when called from these situations
- * (as outlined above - see Campbell's #ifdefs). That causes the get_active function to fail when
+ * (as outlined above - see Campbell's #ifdefs). That causes the get_active function to fail when
* called from context. For that reason, we end up using an alternative where we pass everything in!
*/
bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, scene, sa, obact);
-
+
if (gpd) {
CTX_data_id_pointer_set(result, &gpd->id);
return 1;
@@ -477,14 +477,14 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
else if (CTX_data_equals(member, "gpencil_data_owner")) {
/* pointer to which data/datablock owns the reference to the Grease Pencil data being used (as gpencil_data)
- * XXX: see comment for gpencil_data case...
+ * XXX: see comment for gpencil_data case...
*/
bGPdata **gpd_ptr = NULL;
PointerRNA ptr;
-
+
/* get pointer to Grease Pencil Data */
gpd_ptr = ED_gpencil_data_get_pointers_direct((ID *)sc, scene, sa, obact, &ptr);
-
+
if (gpd_ptr) {
CTX_data_pointer_set(result, ptr.id.data, ptr.type, ptr.data);
return 1;
@@ -493,10 +493,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
else if (CTX_data_equals(member, "active_gpencil_layer")) {
/* XXX: see comment for gpencil_data case... */
bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, scene, sa, obact);
-
+
if (gpd) {
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
-
+
if (gpl) {
CTX_data_pointer_set(result, &gpd->id, &RNA_GPencilLayer, gpl);
return 1;
@@ -544,10 +544,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
else if (CTX_data_equals(member, "active_gpencil_frame")) {
/* XXX: see comment for gpencil_data case... */
bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, scene, sa, obact);
-
+
if (gpd) {
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
-
+
if (gpl) {
CTX_data_pointer_set(result, &gpd->id, &RNA_GPencilLayer, gpl->actframe);
return 1;
@@ -557,10 +557,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
else if (CTX_data_equals(member, "visible_gpencil_layers")) {
/* XXX: see comment for gpencil_data case... */
bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, scene, sa, obact);
-
+
if (gpd) {
bGPDlayer *gpl;
-
+
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if ((gpl->flag & GP_LAYER_HIDE) == 0) {
CTX_data_list_add(result, &gpd->id, &RNA_GPencilLayer, gpl);
@@ -573,10 +573,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
else if (CTX_data_equals(member, "editable_gpencil_layers")) {
/* XXX: see comment for gpencil_data case... */
bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, scene, sa, obact);
-
+
if (gpd) {
bGPDlayer *gpl;
-
+
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if (gpencil_layer_is_editable(gpl)) {
CTX_data_list_add(result, &gpd->id, &RNA_GPencilLayer, gpl);
@@ -589,15 +589,15 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
else if (CTX_data_equals(member, "editable_gpencil_strokes")) {
/* XXX: see comment for gpencil_data case... */
bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, scene, sa, obact);
-
+
if (gpd) {
bGPDlayer *gpl;
-
+
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if (gpencil_layer_is_editable(gpl) && (gpl->actframe)) {
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps;
-
+
for (gps = gpf->strokes.first; gps; gps = gps->next) {
if (ED_gpencil_stroke_can_use_direct(sa, gps)) {
/* check if the color is editable */
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index c7578741d24..ac4ab3461a3 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -81,7 +81,7 @@ static ScrVert *screen_addvert_ex(ScrAreaMap *area_map, short x, short y)
ScrVert *sv = MEM_callocN(sizeof(ScrVert), "addscrvert");
sv->vec.x = x;
sv->vec.y = y;
-
+
BLI_addtail(&area_map->vertbase, sv);
return sv;
}
@@ -129,7 +129,7 @@ ScrEdge *screen_area_map_find_active_scredge(
short min, max;
min = MIN2(se->v1->vec.x, se->v2->vec.x);
max = MAX2(se->v1->vec.x, se->v2->vec.x);
-
+
if (abs(my - se->v1->vec.y) <= safety && mx >= min && mx <= max)
return se;
}
@@ -139,7 +139,7 @@ ScrEdge *screen_area_map_find_active_scredge(
short min, max;
min = MIN2(se->v1->vec.y, se->v2->vec.y);
max = MAX2(se->v1->vec.y, se->v2->vec.y);
-
+
if (abs(mx - se->v1->vec.x) <= safety && my >= min && my <= max)
return se;
}
@@ -201,11 +201,11 @@ static ScrArea *screen_addarea(
static void screen_delarea(bContext *C, bScreen *sc, ScrArea *sa)
{
-
+
ED_area_exit(C, sa);
-
+
BKE_screen_area_free(sa);
-
+
BLI_remlink(&sc->areabase, sa);
MEM_freeN(sa);
}
@@ -217,34 +217,34 @@ static short testsplitpoint(ScrArea *sa, char dir, float fac)
short x, y;
const short area_min_x = AREAMINX;
const short area_min_y = ED_area_headersize();
-
+
// area big enough?
if (dir == 'v' && (sa->v4->vec.x - sa->v1->vec.x <= 2 * area_min_x)) return 0;
if (dir == 'h' && (sa->v2->vec.y - sa->v1->vec.y <= 2 * area_min_y)) return 0;
-
+
// to be sure
CLAMP(fac, 0.0f, 1.0f);
-
+
if (dir == 'h') {
- y = sa->v1->vec.y + fac * (sa->v2->vec.y - sa->v1->vec.y);
-
+ y = sa->v1->vec.y +
+ round_fl_to_short(fac * (float)(sa->v2->vec.y - sa->v1->vec.y));
+
if (y - sa->v1->vec.y < area_min_y)
y = sa->v1->vec.y + area_min_y;
else if (sa->v2->vec.y - y < area_min_y)
y = sa->v2->vec.y - area_min_y;
- else y -= (y % AREAGRID);
-
+
return y;
}
else {
- x = sa->v1->vec.x + fac * (sa->v4->vec.x - sa->v1->vec.x);
-
+ x = sa->v1->vec.x +
+ round_fl_to_short(fac * (float)(sa->v4->vec.x - sa->v1->vec.x));
+
if (x - sa->v1->vec.x < area_min_x)
x = sa->v1->vec.x + area_min_x;
else if (sa->v4->vec.x - x < area_min_x)
x = sa->v4->vec.x - area_min_x;
- else x -= (x % AREAGRID);
-
+
return x;
}
}
@@ -254,12 +254,12 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
ScrArea *newa = NULL;
ScrVert *sv1, *sv2;
short split;
-
+
if (sa == NULL) return NULL;
-
+
split = testsplitpoint(sa, dir, fac);
if (split == 0) return NULL;
-
+
/* note regarding (fac > 0.5f) checks below.
* normally it shouldn't matter which is used since the copy should match the original
* however with viewport rendering and python console this isn't the case. - campbell */
@@ -268,14 +268,14 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
/* new vertices */
sv1 = screen_addvert(sc, sa->v1->vec.x, split);
sv2 = screen_addvert(sc, sa->v4->vec.x, split);
-
+
/* new edges */
screen_addedge(sc, sa->v1, sv1);
screen_addedge(sc, sv1, sa->v2);
screen_addedge(sc, sa->v3, sv2);
screen_addedge(sc, sv2, sa->v4);
screen_addedge(sc, sv1, sv2);
-
+
if (fac > 0.5f) {
/* new areas: top */
newa = screen_addarea(sc, sv1, sa->v2, sa->v3, sv2, sa->spacetype);
@@ -294,20 +294,20 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
}
ED_area_data_copy(newa, sa, true);
-
+
}
else {
/* new vertices */
sv1 = screen_addvert(sc, split, sa->v1->vec.y);
sv2 = screen_addvert(sc, split, sa->v2->vec.y);
-
+
/* new edges */
screen_addedge(sc, sa->v1, sv1);
screen_addedge(sc, sv1, sa->v4);
screen_addedge(sc, sa->v2, sv2);
screen_addedge(sc, sv2, sa->v3);
screen_addedge(sc, sv1, sv2);
-
+
if (fac > 0.5f) {
/* new areas: right */
newa = screen_addarea(sc, sv1, sv2, sa->v3, sa->v4, sa->spacetype);
@@ -327,25 +327,25 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
ED_area_data_copy(newa, sa, true);
}
-
+
/* remove double vertices en edges */
if (merge)
BKE_screen_remove_double_scrverts(sc);
BKE_screen_remove_double_scredges(sc);
BKE_screen_remove_unused_scredges(sc);
-
+
return newa;
}
/**
* Empty screen, with 1 dummy area without spacedata. Uses window size.
*/
-bScreen *screen_add(const char *name, const rcti *rect)
+bScreen *screen_add(Main *bmain, const char *name, const rcti *rect)
{
bScreen *sc;
ScrVert *sv1, *sv2, *sv3, *sv4;
-
- sc = BKE_libblock_alloc(G.main, ID_SCR, name, 0);
+
+ sc = BKE_libblock_alloc(bmain, ID_SCR, name, 0);
sc->do_refresh = true;
sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN;
@@ -353,15 +353,15 @@ bScreen *screen_add(const char *name, const rcti *rect)
sv2 = screen_addvert(sc, rect->xmin, rect->ymax - 1);
sv3 = screen_addvert(sc, rect->xmax - 1, rect->ymax - 1);
sv4 = screen_addvert(sc, rect->xmax - 1, rect->ymin);
-
+
screen_addedge(sc, sv1, sv2);
screen_addedge(sc, sv2, sv3);
screen_addedge(sc, sv3, sv4);
screen_addedge(sc, sv4, sv1);
-
+
/* dummy type, no spacedata */
screen_addarea(sc, sv1, sv2, sv3, sv4, SPACE_EMPTY);
-
+
return sc;
}
@@ -370,26 +370,26 @@ void screen_data_copy(bScreen *to, bScreen *from)
ScrVert *s1, *s2;
ScrEdge *se;
ScrArea *sa, *saf;
-
+
/* free contents of 'to', is from blenkernel screen.c */
BKE_screen_free(to);
-
+
BLI_duplicatelist(&to->vertbase, &from->vertbase);
BLI_duplicatelist(&to->edgebase, &from->edgebase);
BLI_duplicatelist(&to->areabase, &from->areabase);
BLI_listbase_clear(&to->regionbase);
-
+
s2 = to->vertbase.first;
for (s1 = from->vertbase.first; s1; s1 = s1->next, s2 = s2->next) {
s1->newv = s2;
}
-
+
for (se = to->edgebase.first; se; se = se->next) {
se->v1 = se->v1->newv;
se->v2 = se->v2->newv;
BKE_screen_sort_scrvert(&(se->v1), &(se->v2));
}
-
+
saf = from->areabase.first;
for (sa = to->areabase.first; sa; sa = sa->next, saf = saf->next) {
sa->v1 = sa->v1->newv;
@@ -401,10 +401,10 @@ void screen_data_copy(bScreen *to, bScreen *from)
BLI_listbase_clear(&sa->regionbase);
BLI_listbase_clear(&sa->actionzones);
BLI_listbase_clear(&sa->handlers);
-
+
ED_area_data_copy(sa, saf, true);
}
-
+
/* put at zero (needed?) */
for (s1 = from->vertbase.first; s1; s1 = s1->next)
s1->newv = NULL;
@@ -439,7 +439,7 @@ int area_getorientation(ScrArea *sa, ScrArea *sb)
sbv2 = sb->v2;
sbv3 = sb->v3;
sbv4 = sb->v4;
-
+
if (sav1 == sbv4 && sav2 == sbv3) { /* sa to right of sb = W */
return 0;
}
@@ -452,7 +452,7 @@ int area_getorientation(ScrArea *sa, ScrArea *sb)
else if (sav1 == sbv2 && sav4 == sbv3) { /* sa on top of sb = S*/
return 3;
}
-
+
return -1;
}
@@ -462,14 +462,14 @@ int area_getorientation(ScrArea *sa, ScrArea *sb)
int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2)
{
int dir;
-
+
dir = area_getorientation(sa1, sa2);
/*printf("dir is : %i\n", dir);*/
-
+
if (dir == -1) {
return 0;
}
-
+
if (dir == 0) {
sa1->v1 = sa2->v1;
sa1->v2 = sa2->v2;
@@ -494,7 +494,7 @@ int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2)
screen_addedge(scr, sa1->v1, sa1->v2);
screen_addedge(scr, sa1->v3, sa1->v4);
}
-
+
screen_delarea(C, scr, sa2);
BKE_screen_remove_double_scrverts(scr);
/* Update preview thumbnail */
@@ -509,20 +509,20 @@ void select_connected_scredge(const wmWindow *win, ScrEdge *edge)
ScrEdge *se;
int oneselected;
char dir;
-
+
/* select connected, only in the right direction */
/* 'dir' is the direction of EDGE */
-
+
if (edge->v1->vec.x == edge->v2->vec.x) dir = 'v';
else dir = 'h';
-
+
ED_screen_verts_iter(win, sc, sv) {
sv->flag = 0;
}
edge->v1->flag = 1;
edge->v2->flag = 1;
-
+
oneselected = 1;
while (oneselected) {
se = sc->edgebase.first;
@@ -609,7 +609,7 @@ static void screen_vertices_scale(
if (screen_size_x_prev != screen_size_x || screen_size_y_prev != screen_size_y) {
const float facx = ((float)screen_size_x - 1) / ((float)screen_size_x_prev - 1);
- const float facy = ((float)screen_size_y) / ((float)screen_size_y_prev);
+ const float facy = ((float)screen_size_y - 1) / ((float)screen_size_y_prev - 1);
/* make sure it fits! */
for (sv = sc->vertbase.first; sv; sv = sv->next) {
@@ -617,7 +617,7 @@ static void screen_vertices_scale(
CLAMP(sv->vec.x, screen_rect->xmin, screen_rect->xmax - 1);
sv->vec.y = screen_rect->ymin + round_fl_to_short((sv->vec.y - min[1]) * facy);
- CLAMP(sv->vec.y, screen_rect->ymin, screen_rect->ymax);
+ CLAMP(sv->vec.y, screen_rect->ymin, screen_rect->ymax - 1);
}
}
@@ -675,7 +675,7 @@ static void screen_vertices_scale(
/* test for collapsed areas. This could happen in some blender version... */
/* ton: removed option now, it needs Context... */
-
+
/* make each window at least ED_area_headersize() high */
for (sa = sc->areabase.first; sa; sa = sa->next) {
int headery = headery_init;
@@ -784,7 +784,7 @@ static void screen_refresh_headersizes(void)
{
const ListBase *lb = BKE_spacetypes_list();
SpaceType *st;
-
+
for (st = lb->first; st; st = st->next) {
ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER);
if (art) art->prefsizey = ED_area_headersize();
@@ -815,7 +815,7 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
/* sets subwindows for regions, adds handlers */
ED_area_initialize(wm, win, area);
}
-
+
/* wake up animtimer */
if (screen->animtimer)
WM_event_timer_sleep(wm, win, screen->animtimer, false);
@@ -832,10 +832,10 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
}
/* file read, set all screens, ... */
-void ED_screens_initialize(wmWindowManager *wm)
+void ED_screens_initialize(Main *UNUSED(bmain), wmWindowManager *wm)
{
wmWindow *win;
-
+
for (win = wm->windows.first; win; win = win->next) {
if (WM_window_get_active_workspace(win) == NULL) {
WM_window_set_active_workspace(win, G.main->workspaces.first);
@@ -875,12 +875,12 @@ void ED_region_exit(bContext *C, ARegion *ar)
WM_event_remove_handlers(C, &ar->handlers);
WM_event_modal_handler_region_replace(win, ar, NULL);
WM_draw_region_free(ar);
-
+
if (ar->headerstr) {
MEM_freeN(ar->headerstr);
ar->headerstr = NULL;
}
-
+
if (ar->regiontimer) {
WM_event_remove_timer(wm, win, ar->regiontimer);
ar->regiontimer = NULL;
@@ -918,14 +918,14 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
wmWindow *prevwin = CTX_wm_window(C);
CTX_wm_window_set(C, window);
-
+
if (screen->animtimer)
WM_event_remove_timer(wm, window, screen->animtimer);
screen->animtimer = NULL;
screen->scrubbing = false;
screen->active_region = NULL;
-
+
for (ARegion *ar = screen->regionbase.first; ar; ar = ar->next) {
ED_region_exit(C, ar);
}
@@ -939,7 +939,7 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
/* mark it available for use for other windows */
screen->winid = 0;
-
+
if (!WM_window_is_temp_screen(prevwin)) {
/* use previous window if possible */
CTX_wm_window_set(C, prevwin);
@@ -948,7 +948,7 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
/* none otherwise */
CTX_wm_window_set(C, NULL);
}
-
+
}
/* *********************************** */
@@ -959,11 +959,11 @@ static void screen_cursor_set(wmWindow *win, const int xy[2])
const bScreen *screen = WM_window_get_active_screen(win);
AZone *az = NULL;
ScrArea *sa;
-
+
for (sa = screen->areabase.first; sa; sa = sa->next)
if ((az = is_in_area_actionzone(sa, xy)))
break;
-
+
if (sa) {
if (az->type == AZONE_AREA)
WM_cursor_set(win, CURSOR_EDIT);
@@ -1021,19 +1021,19 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
}
else
scr->active_region = NULL;
-
+
/* check for redraw headers */
if (old_ar != scr->active_region) {
ED_screen_areas_iter(win, scr, area_iter) {
bool do_draw = false;
-
+
for (ar = area_iter->regionbase.first; ar; ar = ar->next) {
if (ar == old_ar || ar == scr->active_region) {
do_draw = true;
}
}
-
+
if (do_draw) {
for (ar = area_iter->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_HEADER) {
@@ -1043,7 +1043,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
}
}
}
-
+
/* cursors, for time being set always on edges, otherwise aregion doesnt switch */
if (scr->active_region == NULL) {
screen_cursor_set(win, xy);
@@ -1075,10 +1075,10 @@ int ED_screen_area_active(const bContext *C)
if (win && sc && sa) {
AZone *az = is_in_area_actionzone(sa, &win->eventstate->x);
ARegion *ar;
-
+
if (az && az->type == AZONE_REGION)
return 1;
-
+
for (ar = sa->regionbase.first; ar; ar = ar->next)
if (ar == sc->active_region)
return 1;
@@ -1277,13 +1277,13 @@ static void screen_set_3dview_camera(Scene *scene, ViewLayer *view_layer, ScrAre
if (!v3d->camera) {
ARegion *ar;
ListBase *regionbase;
-
+
/* regionbase is in different place depending if space is active */
if (v3d == sa->spacedata.first)
regionbase = &sa->regionbase;
else
regionbase = &v3d->regionbase;
-
+
for (ar = regionbase->first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = ar->regiondata;
@@ -1316,7 +1316,7 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
if (!sa || sa->full == NULL) {
newsa = ED_screen_state_toggle(C, win, sa, SCREENMAXIMIZED);
}
-
+
if (!newsa) {
newsa = sa;
}
@@ -1373,10 +1373,10 @@ void ED_screen_full_restore(bContext *C, ScrArea *sa)
SpaceLink *sl = sa->spacedata.first;
bScreen *screen = CTX_wm_screen(C);
short state = (screen ? screen->state : SCREENMAXIMIZED);
-
+
/* if fullscreen area has a temporary space (such as a file browser or fullscreen render
* overlaid on top of an existing setup) then return to the previous space */
-
+
if (sl->next) {
if (sa->flag & AREA_FLAG_TEMP_TYPE) {
ED_screen_full_prevspace(C, sa);
@@ -1399,6 +1399,7 @@ void ED_screen_full_restore(bContext *C, ScrArea *sa)
*/
ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const short state)
{
+ Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
WorkSpace *workspace = WM_window_get_active_workspace(win);
bScreen *sc, *oldscreen;
@@ -1489,7 +1490,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
oldscreen->state = state;
BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name + 2, "nonnormal");
- layout_new = ED_workspace_layout_add(workspace, win, newname);
+ layout_new = ED_workspace_layout_add(bmain, workspace, win, newname);
sc = BKE_workspace_layout_screen_get(layout_new);
sc->state = state;
@@ -1502,7 +1503,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
/* use random area when we have no active one, e.g. when the
* mouse is outside of the window and we open a file browser */
- if (!sa) {
+ if (!sa || sa->global) {
sa = oldscreen->areabase.first;
}
@@ -1544,15 +1545,15 @@ void ED_refresh_viewport_fps(bContext *C)
{
wmTimer *animtimer = CTX_wm_screen(C)->animtimer;
Scene *scene = CTX_data_scene(C);
-
+
/* is anim playback running? */
if (animtimer && (U.uiflag & USER_SHOW_FPS)) {
ScreenFrameRateInfo *fpsi = scene->fps_info;
-
+
/* if there isn't any info, init it first */
if (fpsi == NULL)
fpsi = scene->fps_info = MEM_callocN(sizeof(ScreenFrameRateInfo), "refresh_viewport_fps fps_info");
-
+
/* update the values */
fpsi->redrawtime = fpsi->lredrawtime;
fpsi->lredrawtime = animtimer->ltime;
@@ -1565,7 +1566,7 @@ void ED_refresh_viewport_fps(bContext *C)
}
}
-/* redraws: uses defines from stime->redraws
+/* redraws: uses defines from stime->redraws
* enable: 1 - forward on, -1 - backwards on, 0 - off
*/
void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync, int enable)
@@ -1575,17 +1576,17 @@ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync,
wmWindow *win = CTX_wm_window(C);
Scene *scene = CTX_data_scene(C);
bScreen *stopscreen = ED_screen_animation_playing(wm);
-
+
if (stopscreen) {
WM_event_remove_timer(wm, win, stopscreen->animtimer);
stopscreen->animtimer = NULL;
}
-
+
if (enable) {
ScreenAnimData *sad = MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData");
-
+
screen->animtimer = WM_event_add_timer(wm, win, TIMER0, (1.0 / FPS));
-
+
sad->ar = CTX_wm_region(C);
/* if startframe is larger than current frame, we put currentframe on startframe.
* note: first frame then is not drawn! (ton) */
@@ -1620,7 +1621,7 @@ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync,
sad->from_anim_edit = (ELEM(spacetype, SPACE_IPO, SPACE_ACTION, SPACE_NLA));
screen->animtimer->customdata = sad;
-
+
}
/* notifier catched by top header, for button */
@@ -1633,7 +1634,7 @@ static ARegion *time_top_left_3dwindow(bScreen *screen)
ARegion *aret = NULL;
ScrArea *sa;
int min = 10000;
-
+
for (sa = screen->areabase.first; sa; sa = sa->next) {
if (sa->spacetype == SPACE_VIEW3D) {
ARegion *ar;
@@ -1656,7 +1657,7 @@ void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh)
if (screen && screen->animtimer) {
wmTimer *wt = screen->animtimer;
ScreenAnimData *sad = wt->customdata;
-
+
sad->redraws = redraws;
sad->refresh = refresh;
sad->ar = NULL;
@@ -1681,7 +1682,7 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph)
}
}
#endif
-
+
ED_clip_update_frame(bmain, scene->r.cfra);
/* this function applies the changes too */
@@ -1690,7 +1691,7 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph)
/* composite */
if (scene->use_nodes && scene->nodetree)
ntreeCompositTagAnimated(scene->nodetree);
-
+
/* update animated texture nodes */
{
Tex *tex;
@@ -1700,7 +1701,7 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph)
}
}
}
-
+
}
/*
diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h
index b54a5e04571..b02198764e0 100644
--- a/source/blender/editors/screen/screen_intern.h
+++ b/source/blender/editors/screen/screen_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -48,7 +48,7 @@ void screen_area_update_region_sizes(wmWindowManager *wm, wmWindow *win,
void region_toggle_hidden(struct bContext *C, ARegion *ar, const bool do_fade);
/* screen_edit.c */
-bScreen *screen_add(const char *name, const rcti *rect);
+bScreen *screen_add(struct Main *bmain, const char *name, const rcti *rect);
void screen_data_copy(bScreen *to, bScreen *from);
void screen_new_activate_prepare(const wmWindow *win, bScreen *screen_new);
void screen_change_update(struct bContext *C, wmWindow *win, bScreen *sc);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 9b7f767798f..1ecc3f72355 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -172,11 +172,11 @@ int ED_operator_objectmode(bContext *C)
return 0;
if (CTX_data_edit_object(C))
return 0;
-
+
/* add a check for ob->mode too? */
if (obact && (obact->mode != OB_MODE_OBJECT))
return 0;
-
+
return 1;
}
@@ -253,20 +253,20 @@ int ED_operator_buttons_active(bContext *C)
int ED_operator_node_active(bContext *C)
{
SpaceNode *snode = CTX_wm_space_node(C);
-
+
if (snode && snode->edittree)
return 1;
-
+
return 0;
}
int ED_operator_node_editable(bContext *C)
{
SpaceNode *snode = CTX_wm_space_node(C);
-
+
if (snode && snode->edittree && !ID_IS_LINKED(snode->edittree))
return 1;
-
+
return 0;
}
@@ -461,15 +461,15 @@ int ED_operator_uvmap(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = NULL;
-
+
if (obedit && obedit->type == OB_MESH) {
em = BKE_editmesh_from_object(obedit);
}
-
+
if (em && (em->bm->totface)) {
return true;
}
-
+
return false;
}
@@ -616,23 +616,23 @@ static ARegion *screen_find_region_type(bContext *C, int type)
/** \name Action Zone Operator
* \{ */
-/* operator state vars used:
+/* operator state vars used:
* none
- *
+ *
* functions:
- *
+ *
* apply() set actionzone event
- *
+ *
* exit() free customdata
- *
+ *
* callbacks:
- *
+ *
* exec() never used
- *
- * invoke() check if in zone
+ *
+ * invoke() check if in zone
* add customdata, put mouseco and area in it
* add modal handler
- *
+ *
* modal() accept modal events while doing it
* call apply() with gesture info, active window, nonactive window
* call exit() and remove handler when LMB confirm
@@ -649,11 +649,11 @@ static int actionzone_area_poll(bContext *C)
{
wmWindow *win = CTX_wm_window(C);
ScrArea *sa = CTX_wm_area(C);
-
+
if (sa && win && win->eventstate) {
const int *xy = &win->eventstate->x;
AZone *az;
-
+
for (az = sa->actionzones.first; az; az = az->next)
if (BLI_rcti_isect_pt_v(&az->rect, xy))
return 1;
@@ -682,13 +682,13 @@ static void fullscreen_click_rcti_init(rcti *rect, const short x1, const short y
AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2])
{
AZone *az = NULL;
-
+
for (az = sa->actionzones.first; az; az = az->next) {
if (BLI_rcti_isect_pt_v(&az->rect, xy)) {
if (az->type == AZONE_AREA) {
/* no triangle intersect but a hotspot circle based on corner */
int radius = (xy[0] - az->x1) * (xy[0] - az->x1) + (xy[1] - az->y1) * (xy[1] - az->y1);
-
+
if (radius <= AZONESPOT * AZONESPOT)
break;
}
@@ -786,7 +786,7 @@ AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2])
}
}
}
-
+
return az;
}
@@ -804,9 +804,9 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type)
wmEvent event;
wmWindow *win = CTX_wm_window(C);
sActionzoneData *sad = op->customdata;
-
+
sad->modifier = RNA_int_get(op->ptr, "modifier");
-
+
wm_event_init_from_window(win, &event);
if (type == AZONE_AREA)
@@ -820,7 +820,7 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type)
event.customdata = op->customdata;
event.customdatafree = true;
op->customdata = NULL;
-
+
wm_event_add(win, &event);
}
@@ -829,17 +829,17 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ScrArea *sa = CTX_wm_area(C);
AZone *az = is_in_area_actionzone(sa, &event->x);
sActionzoneData *sad;
-
+
/* quick escape */
if (az == NULL)
return OPERATOR_PASS_THROUGH;
-
+
/* ok we do the actionzone */
sad = op->customdata = MEM_callocN(sizeof(sActionzoneData), "sActionzoneData");
sad->sa1 = sa;
sad->az = az;
sad->x = event->x; sad->y = event->y;
-
+
/* region azone directly reacts on mouse clicks */
if (ELEM(sad->az->type, AZONE_REGION, AZONE_FULLSCREEN)) {
actionzone_apply(C, op, sad->az->type);
@@ -852,7 +852,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
else {
/* add modal handler */
WM_event_add_modal_handler(C, op);
-
+
return OPERATOR_RUNNING_MODAL;
}
}
@@ -880,7 +880,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
sad->gesture_dir = 's';
else
sad->gesture_dir = 'w';
-
+
if (sad->az->type == AZONE_AREA) {
const wmWindow *win = CTX_wm_window(C);
rcti screen_rect;
@@ -904,7 +904,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* apply sends event */
actionzone_apply(C, op, sad->az->type);
actionzone_exit(op);
-
+
return OPERATOR_FINISHED;
}
break;
@@ -915,9 +915,9 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
case LEFTMOUSE:
actionzone_exit(op);
return OPERATOR_CANCELLED;
-
+
}
-
+
return OPERATOR_RUNNING_MODAL;
}
@@ -932,15 +932,15 @@ static void SCREEN_OT_actionzone(wmOperatorType *ot)
ot->name = "Handle Area Action Zones";
ot->description = "Handle area action zones for mouse actions/gestures";
ot->idname = "SCREEN_OT_actionzone";
-
+
ot->invoke = actionzone_invoke;
ot->modal = actionzone_modal;
ot->poll = actionzone_area_poll;
ot->cancel = actionzone_cancel;
-
+
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL;
-
+
RNA_def_int(ot->srna, "modifier", 0, 0, 2, "Modifier", "Modifier state", 0, 2);
}
@@ -978,15 +978,15 @@ static int area_swap_init(wmOperator *op, const wmEvent *event)
{
sAreaSwapData *sd = NULL;
sActionzoneData *sad = event->customdata;
-
+
if (sad == NULL || sad->sa1 == NULL)
return 0;
-
+
sd = MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData");
sd->sa1 = sad->sa1;
sd->sa2 = sad->sa2;
op->customdata = sd;
-
+
return 1;
}
@@ -1006,22 +1006,22 @@ static void area_swap_cancel(bContext *C, wmOperator *op)
static int area_swap_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
-
+
if (!area_swap_init(op, event))
return OPERATOR_PASS_THROUGH;
-
+
/* add modal handler */
WM_cursor_modal_set(CTX_wm_window(C), BC_SWAPAREA_CURSOR);
WM_event_add_modal_handler(C, op);
-
+
return OPERATOR_RUNNING_MODAL;
-
+
}
static int area_swap_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
sActionzoneData *sad = op->customdata;
-
+
switch (event->type) {
case MOUSEMOVE:
/* second area, for join */
@@ -1038,15 +1038,15 @@ static int area_swap_modal(bContext *C, wmOperator *op, const wmEvent *event)
ED_area_tag_redraw(sad->sa2);
ED_area_swapspace(C, sad->sa1, sad->sa2);
-
+
area_swap_exit(C, op);
-
+
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
break;
-
+
case ESCKEY:
area_swap_cancel(C, op);
return OPERATOR_CANCELLED;
@@ -1059,12 +1059,12 @@ static void SCREEN_OT_area_swap(wmOperatorType *ot)
ot->name = "Swap Areas";
ot->description = "Swap selected areas screen positions";
ot->idname = "SCREEN_OT_area_swap";
-
+
ot->invoke = area_swap_invoke;
ot->modal = area_swap_modal;
ot->poll = ED_operator_areaactive;
ot->cancel = area_swap_cancel;
-
+
ot->flag = OPTYPE_BLOCKING;
}
@@ -1079,6 +1079,7 @@ static void SCREEN_OT_area_swap(wmOperatorType *ot)
/* operator callback */
static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
+ Main *bmain = CTX_data_main(C);
wmWindow *newwin, *win = CTX_wm_window(C);
Scene *scene;
WorkSpace *workspace = WM_window_get_active_workspace(win);
@@ -1087,18 +1088,18 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bScreen *newsc;
ScrArea *sa;
rcti rect;
-
+
win = CTX_wm_window(C);
scene = CTX_data_scene(C);
sa = CTX_wm_area(C);
-
+
/* XXX hrmf! */
if (event->type == EVT_ACTIONZONE_AREA) {
sActionzoneData *sad = event->customdata;
-
+
if (sad == NULL)
return OPERATOR_PASS_THROUGH;
-
+
sa = sad->sa1;
}
@@ -1120,7 +1121,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
WM_window_set_active_workspace(newwin, workspace);
/* allocs new screen and adds to newly created window, using window size */
- layout_new = ED_workspace_layout_add(workspace, newwin, BKE_workspace_layout_name_get(layout_old));
+ layout_new = ED_workspace_layout_add(bmain, workspace, newwin, BKE_workspace_layout_name_get(layout_old));
newsc = BKE_workspace_layout_screen_get(layout_new);
WM_window_set_active_layout(newwin, workspace, layout_new);
@@ -1136,7 +1137,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
finally:
if (event->type == EVT_ACTIONZONE_AREA)
actionzone_exit(op);
-
+
if (newwin) {
return OPERATOR_FINISHED;
}
@@ -1150,7 +1151,7 @@ static void SCREEN_OT_area_dupli(wmOperatorType *ot)
ot->name = "Duplicate Area into New Window";
ot->description = "Duplicate selected area into new window";
ot->idname = "SCREEN_OT_area_dupli";
-
+
ot->invoke = area_dupli_invoke;
ot->poll = ED_operator_areaactive;
}
@@ -1161,29 +1162,29 @@ static void SCREEN_OT_area_dupli(wmOperatorType *ot)
/** \name Move Area Edge Operator
* \{ */
-/* operator state vars used:
+/* operator state vars used:
* x, y mouse coord near edge
* delta movement of edge
- *
+ *
* functions:
- *
+ *
* init() set default property values, find edge based on mouse coords, test
* if the edge can be moved, select edges, calculate min and max movement
- *
+ *
* apply() apply delta on selection
- *
+ *
* exit() cleanup, send notifier
- *
+ *
* cancel() cancel moving
- *
+ *
* callbacks:
- *
+ *
* exec() execute without any user interaction, based on properties
* call init(), apply(), exit()
- *
+ *
* invoke() gets called on mouse click near edge
* call init(), add handler
- *
+ *
* modal() accept modal events while doing it
* call apply() with delta motion
* call exit() and remove handler
@@ -1195,6 +1196,8 @@ typedef struct sAreaMoveData {
enum AreaMoveSnapType {
/* Snapping disabled */
SNAP_NONE = 0,
+ /* Snap to an invisible grid with a unit defined in AREAGRID */
+ SNAP_AREAGRID,
/* Snap to mid-point and adjacent edges. */
SNAP_MIDPOINT_AND_ADJACENT,
/* Snap to either bigger or smaller, nothing in-between (used for
@@ -1260,14 +1263,14 @@ static void area_move_set_limits(
if (dir == 'h') {
int y1;
areamin = areaminy;
-
+
if (sa->v1->vec.y > screen_rect->ymin)
areamin += U.pixelsize;
if (sa->v2->vec.y < (screen_rect->ymax - 1))
areamin += U.pixelsize;
-
+
y1 = sa->v2->vec.y - sa->v1->vec.y + 1 - areamin;
-
+
/* if top or down edge selected, test height */
if (sa->v1->editflag && sa->v4->editflag)
*bigger = min_ii(*bigger, y1);
@@ -1277,14 +1280,14 @@ static void area_move_set_limits(
else {
int x1;
areamin = AREAMINX;
-
+
if (sa->v1->vec.x > screen_rect->xmin)
areamin += U.pixelsize;
if (sa->v4->vec.x < (screen_rect->xmax - 1))
areamin += U.pixelsize;
-
+
x1 = sa->v4->vec.x - sa->v1->vec.x + 1 - areamin;
-
+
/* if left or right edge selected, test width */
if (sa->v1->editflag && sa->v2->editflag)
*bigger = min_ii(*bigger, x1);
@@ -1304,22 +1307,22 @@ static int area_move_init(bContext *C, wmOperator *op)
sAreaMoveData *md;
rcti screen_rect;
int x, y;
-
+
/* required properties */
x = RNA_int_get(op->ptr, "x");
y = RNA_int_get(op->ptr, "y");
-
+
/* setup */
actedge = screen_find_active_scredge(win, sc, x, y);
if (actedge == NULL) return 0;
-
+
md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData");
op->customdata = md;
-
+
md->dir = scredge_is_horizontal(actedge) ? 'h' : 'v';
if (md->dir == 'h') md->origval = actedge->v1->vec.y;
else md->origval = actedge->v1->vec.x;
-
+
select_connected_scredge(win, actedge);
/* now all vertices with 'flag == 1' are the ones that can be moved. Move this to editflag */
ED_screen_verts_iter(win, sc, v1) {
@@ -1333,7 +1336,7 @@ static int area_move_init(bContext *C, wmOperator *op)
&md->bigger, &md->smaller,
&use_bigger_smaller_snap);
- md->snap_type = use_bigger_smaller_snap ? SNAP_BIGGER_SMALLER_ONLY : SNAP_NONE;
+ md->snap_type = use_bigger_smaller_snap ? SNAP_BIGGER_SMALLER_ONLY : SNAP_AREAGRID;
return 1;
}
@@ -1344,30 +1347,43 @@ static int area_snap_calc_location(
const int bigger, const int smaller)
{
BLI_assert(snap_type != SNAP_NONE);
- if (snap_type == SNAP_BIGGER_SMALLER_ONLY) {
- return ((origval + delta) >= bigger) ? bigger : smaller;
- }
-
int final_loc = -1;
const int m_loc = origval + delta;
- const int axis = (dir == 'v') ? 0 : 1;
- int snap_dist;
- int dist;
- {
- /* Test the snap to middle. */
- int middle = origval + (bigger - smaller) / 2;
- middle -= (middle % AREAGRID);
- snap_dist = abs(m_loc - middle);
- final_loc = middle;
- }
+ switch (snap_type) {
+ case SNAP_AREAGRID:
+ final_loc = m_loc;
+ if (delta != bigger && delta != -smaller) {
+ final_loc -= (m_loc % AREAGRID);
+ }
+ break;
- for (const ScrVert *v1 = sc->vertbase.first; v1; v1 = v1->next) {
- if (v1->editflag) {
- const int v_loc = (&v1->vec.x)[!axis];
+ case SNAP_BIGGER_SMALLER_ONLY:
+ final_loc = (m_loc >= bigger) ? bigger : smaller;
+ break;
+
+ case SNAP_MIDPOINT_AND_ADJACENT:
+ {
+ const int axis = (dir == 'v') ? 0 : 1;
+ int snap_dist;
+ int dist;
+ {
+ /* Test the snap to middle. */
+ int middle = origval + (bigger - smaller) / 2;
+ snap_dist = abs(m_loc - middle);
+ final_loc = middle;
+ }
+
+ for (const ScrVert *v1 = sc->vertbase.first; v1; v1 = v1->next) {
+ if (!v1->editflag) {
+ continue;
+ }
+ const int v_loc = (&v1->vec.x)[!axis];
- for (const ScrVert *v2 = sc->vertbase.first; v2; v2 = v2->next) {
- if (!v2->editflag) {
+ for (const ScrVert *v2 = sc->vertbase.first; v2; v2 = v2->next) {
+ if (v2->editflag) {
+ continue;
+ }
if (v_loc == (&v2->vec.x)[!axis]) {
const int v_loc2 = (&v2->vec.x)[axis];
/* Do not snap to the vertices at the ends. */
@@ -1381,7 +1397,10 @@ static int area_snap_calc_location(
}
}
}
+ break;
}
+ case SNAP_NONE:
+ break;
}
return final_loc;
@@ -1403,9 +1422,6 @@ static void area_move_apply_do(
if (snap_type == SNAP_NONE) {
final_loc = origval + delta;
- if (delta != bigger && delta != -smaller) {
- final_loc -= (final_loc % AREAGRID);
- }
}
else {
final_loc = area_snap_calc_location(sc, snap_type, delta, origval, dir, bigger, smaller);
@@ -1465,7 +1481,7 @@ static void area_move_exit(bContext *C, wmOperator *op)
if (op->customdata)
MEM_freeN(op->customdata);
op->customdata = NULL;
-
+
/* this makes sure aligned edges will result in aligned grabbing */
BKE_screen_remove_double_scrverts(CTX_wm_screen(C));
BKE_screen_remove_double_scredges(CTX_wm_screen(C));
@@ -1475,10 +1491,10 @@ static int area_move_exec(bContext *C, wmOperator *op)
{
if (!area_move_init(C, op))
return OPERATOR_CANCELLED;
-
+
area_move_apply(C, op);
area_move_exit(C, op);
-
+
return OPERATOR_FINISHED;
}
@@ -1487,19 +1503,19 @@ static int area_move_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
RNA_int_set(op->ptr, "x", event->x);
RNA_int_set(op->ptr, "y", event->y);
-
- if (!area_move_init(C, op))
+
+ if (!area_move_init(C, op))
return OPERATOR_PASS_THROUGH;
-
+
/* add temp handler */
WM_event_add_modal_handler(C, op);
-
+
return OPERATOR_RUNNING_MODAL;
}
static void area_move_cancel(bContext *C, wmOperator *op)
{
-
+
RNA_int_set(op->ptr, "delta", 0);
area_move_apply(C, op);
area_move_exit(C, op);
@@ -1510,17 +1526,17 @@ static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
sAreaMoveData *md = op->customdata;
int delta, x, y;
-
+
/* execute the events */
switch (event->type) {
case MOUSEMOVE:
{
x = RNA_int_get(op->ptr, "x");
y = RNA_int_get(op->ptr, "y");
-
+
delta = (md->dir == 'v') ? event->x - x : event->y - y;
RNA_int_set(op->ptr, "delta", delta);
-
+
area_move_apply(C, op);
break;
}
@@ -1530,26 +1546,27 @@ static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event)
case KM_MODAL_APPLY:
area_move_exit(C, op);
return OPERATOR_FINISHED;
-
+
case KM_MODAL_CANCEL:
area_move_cancel(C, op);
return OPERATOR_CANCELLED;
case KM_MODAL_SNAP_ON:
- if (md->snap_type == SNAP_NONE) {
+ if (md->snap_type != SNAP_BIGGER_SMALLER_ONLY) {
md->snap_type = SNAP_MIDPOINT_AND_ADJACENT;
}
break;
+
case KM_MODAL_SNAP_OFF:
- if (md->snap_type == SNAP_MIDPOINT_AND_ADJACENT) {
- md->snap_type = SNAP_NONE;
+ if (md->snap_type != SNAP_BIGGER_SMALLER_ONLY) {
+ md->snap_type = SNAP_AREAGRID;
}
break;
}
break;
}
}
-
+
return OPERATOR_RUNNING_MODAL;
}
@@ -1559,16 +1576,16 @@ static void SCREEN_OT_area_move(wmOperatorType *ot)
ot->name = "Move Area Edges";
ot->description = "Move selected area edges";
ot->idname = "SCREEN_OT_area_move";
-
+
ot->exec = area_move_exec;
ot->invoke = area_move_invoke;
ot->cancel = area_move_cancel;
ot->modal = area_move_modal;
ot->poll = ED_operator_screen_mainwinactive; /* when mouse is over area-edge */
-
+
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL;
-
+
/* rna */
RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
@@ -1627,7 +1644,7 @@ typedef struct sAreaSplitData {
ScrEdge *nedge; /* new edge */
ScrArea *sarea; /* start area */
ScrArea *narea; /* new area */
-
+
} sAreaSplitData;
static void area_split_draw_cb(const struct wmWindow *UNUSED(win), void *userdata)
@@ -1647,11 +1664,11 @@ static void area_split_draw_cb(const struct wmWindow *UNUSED(win), void *userdat
static int area_split_menu_init(bContext *C, wmOperator *op)
{
sAreaSplitData *sd;
-
+
/* custom data */
sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split");
op->customdata = sd;
-
+
sd->sarea = CTX_wm_area(C);
return 1;
@@ -1662,27 +1679,33 @@ static int area_split_init(bContext *C, wmOperator *op)
{
ScrArea *sa = CTX_wm_area(C);
sAreaSplitData *sd;
- int areaminy = ED_area_headersize() + 1;
+ int areaminy = ED_area_headersize();
int dir;
-
+
/* required context */
if (sa == NULL) return 0;
-
+
/* required properties */
dir = RNA_enum_get(op->ptr, "direction");
-
+
/* minimal size */
if (dir == 'v' && sa->winx < 2 * AREAMINX) return 0;
if (dir == 'h' && sa->winy < 2 * areaminy) return 0;
-
+
/* custom data */
sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split");
op->customdata = sd;
-
+
sd->sarea = sa;
- sd->origsize = dir == 'v' ? sa->winx : sa->winy;
- sd->origmin = dir == 'v' ? sa->totrct.xmin : sa->totrct.ymin;
-
+ if (dir == 'v') {
+ sd->origmin = sa->v1->vec.x;
+ sd->origsize = sa->v4->vec.x - sd->origmin;
+ }
+ else {
+ sd->origmin = sa->v1->vec.y;
+ sd->origsize = sa->v2->vec.y - sd->origmin;
+ }
+
return 1;
}
@@ -1698,7 +1721,7 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb)
ScrVert *sbv2 = sb->v2;
ScrVert *sbv3 = sb->v3;
ScrVert *sbv4 = sb->v4;
-
+
if (sav1 == sbv4 && sav2 == sbv3) { /* sa to right of sb = W */
return BKE_screen_find_edge(screen, sav1, sav2);
}
@@ -1711,7 +1734,7 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb)
else if (sav1 == sbv2 && sav4 == sbv3) { /* sa on top of sb = S*/
return BKE_screen_find_edge(screen, sav1, sav4);
}
-
+
return NULL;
}
@@ -1723,24 +1746,24 @@ static int area_split_apply(bContext *C, wmOperator *op)
sAreaSplitData *sd = (sAreaSplitData *)op->customdata;
float fac;
int dir;
-
+
fac = RNA_float_get(op->ptr, "factor");
dir = RNA_enum_get(op->ptr, "direction");
-
+
sd->narea = area_split(sc, sd->sarea, dir, fac, 0); /* 0 = no merge */
-
+
if (sd->narea) {
ScrVert *sv;
-
+
sd->nedge = area_findsharededge(sc, sd->sarea, sd->narea);
-
+
/* select newly created edge, prepare for moving edge */
for (sv = sc->vertbase.first; sv; sv = sv->next)
sv->editflag = 0;
-
+
sd->nedge->v1->editflag = 1;
sd->nedge->v2->editflag = 1;
-
+
if (dir == 'h') sd->origval = sd->nedge->v1->vec.y;
else sd->origval = sd->nedge->v1->vec.x;
@@ -1753,7 +1776,7 @@ static int area_split_apply(bContext *C, wmOperator *op)
return 1;
}
-
+
return 0;
}
@@ -1770,10 +1793,10 @@ static void area_split_exit(bContext *C, wmOperator *op)
MEM_freeN(op->customdata);
op->customdata = NULL;
}
-
+
WM_cursor_modal_restore(CTX_wm_window(C));
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
-
+
/* this makes sure aligned edges will result in aligned grabbing */
BKE_screen_remove_double_scrverts(CTX_wm_screen(C));
BKE_screen_remove_double_scredges(CTX_wm_screen(C));
@@ -1794,7 +1817,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
sAreaSplitData *sd;
rcti screen_rect;
int dir;
-
+
/* no full window splitting allowed */
if (sc->state != SCREENNORMAL)
return OPERATOR_CANCELLED;
@@ -1803,19 +1826,19 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (event->type == EVT_ACTIONZONE_AREA) {
sActionzoneData *sad = event->customdata;
-
+
if (sad == NULL || sad->modifier > 0) {
return OPERATOR_PASS_THROUGH;
}
-
+
/* verify *sad itself */
if (sad->sa1 == NULL || sad->az == NULL)
return OPERATOR_PASS_THROUGH;
-
+
/* is this our *sad? if areas not equal it should be passed on */
if (CTX_wm_area(C) != sad->sa1 || sad->sa1 != sad->sa2)
return OPERATOR_PASS_THROUGH;
-
+
/* prepare operator state vars */
if (sad->gesture_dir == 'n' || sad->gesture_dir == 's') {
dir = 'h';
@@ -1826,22 +1849,22 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
RNA_float_set(op->ptr, "factor", ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy);
}
RNA_enum_set(op->ptr, "direction", dir);
-
+
/* general init, also non-UI case, adds customdata, sets area and defaults */
if (!area_split_init(C, op))
return OPERATOR_PASS_THROUGH;
-
+
}
else {
ScrEdge *actedge;
int x, y;
-
+
/* retrieve initial mouse coord, so we can find the active edge */
if (RNA_struct_property_is_set(op->ptr, "mouse_x"))
x = RNA_int_get(op->ptr, "mouse_x");
else
x = event->x;
-
+
if (RNA_struct_property_is_set(op->ptr, "mouse_y"))
y = RNA_int_get(op->ptr, "mouse_y");
else
@@ -1850,28 +1873,28 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
actedge = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(sc), &screen_rect, x, y);
if (actedge == NULL)
return OPERATOR_CANCELLED;
-
+
dir = scredge_is_horizontal(actedge) ? 'v' : 'h';
-
+
RNA_enum_set(op->ptr, "direction", dir);
-
+
/* special case, adds customdata, sets defaults */
if (!area_split_menu_init(C, op))
return OPERATOR_CANCELLED;
-
+
}
-
+
sd = (sAreaSplitData *)op->customdata;
-
+
if (event->type == EVT_ACTIONZONE_AREA) {
-
+
/* do the split */
if (area_split_apply(C, op)) {
area_move_set_limits(win, sc, dir, &screen_rect, &sd->bigger, &sd->smaller, NULL);
/* add temp handler for edge move or cancel */
WM_event_add_modal_handler(C, op);
-
+
return OPERATOR_RUNNING_MODAL;
}
}
@@ -1883,22 +1906,22 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
area_split_preview_update_cursor(C, op);
return OPERATOR_RUNNING_MODAL;
-
+
}
-
+
return OPERATOR_PASS_THROUGH;
}
/* function to be called outside UI context, or for redo */
static int area_split_exec(bContext *C, wmOperator *op)
{
-
+
if (!area_split_init(C, op))
return OPERATOR_CANCELLED;
-
+
area_split_apply(C, op);
area_split_exit(C, op);
-
+
return OPERATOR_FINISHED;
}
@@ -1906,7 +1929,7 @@ static int area_split_exec(bContext *C, wmOperator *op)
static void area_split_cancel(bContext *C, wmOperator *op)
{
sAreaSplitData *sd = (sAreaSplitData *)op->customdata;
-
+
if (sd->previewmode) {
/* pass */
}
@@ -1947,7 +1970,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
break;
-
+
case MIDDLEMOUSE:
case TABKEY:
if (sd->previewmode == 0) {
@@ -1963,9 +1986,9 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
}
-
+
break;
-
+
case RIGHTMOUSE: /* cancel operation */
case ESCKEY:
area_split_cancel(C, op);
@@ -2001,12 +2024,12 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (sd->sarea) {
ScrArea *sa = sd->sarea;
if (dir == 'v') {
- sd->origsize = sa->winx;
- sd->origmin = sa->totrct.xmin;
+ sd->origmin = sa->v1->vec.x;
+ sd->origsize = sa->v4->vec.x - sd->origmin;
}
else {
- sd->origsize = sa->winy;
- sd->origmin = sa->totrct.ymin;
+ sd->origmin = sa->v1->vec.y;
+ sd->origsize = sa->v2->vec.y - sd->origmin;
}
if (sd->do_snap) {
@@ -2044,17 +2067,17 @@ static void SCREEN_OT_area_split(wmOperatorType *ot)
ot->name = "Split Area";
ot->description = "Split selected area into new windows";
ot->idname = "SCREEN_OT_area_split";
-
+
ot->exec = area_split_exec;
ot->invoke = area_split_invoke;
ot->modal = area_split_modal;
ot->cancel = area_split_cancel;
-
+
ot->poll = screen_active_editable;
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL;
-
+
/* rna */
RNA_def_enum(ot->srna, "direction", prop_direction_items, 'h', "Direction", "");
RNA_def_float(ot->srna, "factor", 0.5f, 0.0, 1.0, "Factor", "", 0.0, 1.0);
@@ -2076,7 +2099,7 @@ typedef struct RegionMoveData {
int origx, origy;
int maxsize;
AZEdge edge;
-
+
} RegionMoveData;
@@ -2084,20 +2107,20 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
{
ARegion *ar;
int dist;
-
+
if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) {
dist = BLI_rcti_size_x(&sa->totrct);
}
else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */
dist = BLI_rcti_size_y(&sa->totrct);
}
-
- /* subtractwidth of regions on opposite side
+
+ /* subtractwidth of regions on opposite side
* prevents dragging regions into other opposite regions */
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar == scalear)
continue;
-
+
if (scalear->alignment == RGN_ALIGN_TOP && ar->alignment == RGN_ALIGN_BOTTOM)
dist -= ar->winy;
else if (scalear->alignment == RGN_ALIGN_BOTTOM && ar->alignment == RGN_ALIGN_TOP)
@@ -2106,7 +2129,7 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
dist -= ar->winx;
else if (scalear->alignment == RGN_ALIGN_RIGHT && ar->alignment == RGN_ALIGN_LEFT)
dist -= ar->winx;
-
+
/* case of regions in regions, like operator properties panel */
/* these can sit on top of other regions such as headers, so account for this */
else if (edge == AE_BOTTOM_TO_TOPLEFT && scalear->alignment & RGN_ALIGN_TOP &&
@@ -2128,20 +2151,20 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event
{
sActionzoneData *sad = event->customdata;
AZone *az;
-
+
if (event->type != EVT_ACTIONZONE_REGION) {
BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone");
return OPERATOR_CANCELLED;
}
-
+
az = sad->az;
-
+
if (az->ar) {
RegionMoveData *rmd = MEM_callocN(sizeof(RegionMoveData), "RegionMoveData");
int maxsize;
-
+
op->customdata = rmd;
-
+
rmd->az = az;
rmd->ar = az->ar;
rmd->sa = sad->sa1;
@@ -2149,13 +2172,13 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event
rmd->origx = event->x;
rmd->origy = event->y;
rmd->maxsize = area_max_regionsize(rmd->sa, rmd->ar, rmd->edge);
-
+
/* if not set we do now, otherwise it uses type */
if (rmd->ar->sizex == 0)
rmd->ar->sizex = rmd->ar->winx;
if (rmd->ar->sizey == 0)
rmd->ar->sizey = rmd->ar->winy;
-
+
/* now copy to regionmovedata */
if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
rmd->origval = rmd->ar->sizex;
@@ -2163,21 +2186,21 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event
else {
rmd->origval = rmd->ar->sizey;
}
-
+
/* limit headers to standard height for now */
if (rmd->ar->regiontype == RGN_TYPE_HEADER)
maxsize = ED_area_headersize();
else
maxsize = 1000;
-
+
CLAMP(rmd->maxsize, 0, maxsize);
-
+
/* add temp handler */
WM_event_add_modal_handler(C, op);
-
+
return OPERATOR_RUNNING_MODAL;
}
-
+
return OPERATOR_FINISHED;
}
@@ -2233,7 +2256,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
RegionMoveData *rmd = op->customdata;
int delta;
-
+
/* execute the events */
switch (event->type) {
case MOUSEMOVE:
@@ -2243,10 +2266,10 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
delta = event->x - rmd->origx;
if (rmd->edge == AE_LEFT_TO_TOPRIGHT) delta = -delta;
-
+
/* region sizes now get multiplied */
delta /= UI_DPI_FAC;
-
+
rmd->ar->sizex = rmd->origval + delta;
if (rmd->ar->type->snap_size) {
@@ -2269,7 +2292,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
int maxsize = region_scale_get_maxsize(rmd);
delta = event->y - rmd->origy;
if (rmd->edge == AE_BOTTOM_TO_TOPLEFT) delta = -delta;
-
+
/* region sizes now get multiplied */
delta /= UI_DPI_FAC;
@@ -2291,19 +2314,19 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (!(rmd->ar->flag & RGN_FLAG_HIDDEN))
region_scale_toggle_hidden(C, rmd);
}
- else if (maxsize > 0 && (rmd->ar->sizey > maxsize))
+ else if (maxsize > 0 && (rmd->ar->sizey > maxsize))
rmd->ar->sizey = maxsize;
else if (rmd->ar->flag & RGN_FLAG_HIDDEN)
region_scale_toggle_hidden(C, rmd);
}
ED_area_tag_redraw(rmd->sa);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
-
+
break;
}
case LEFTMOUSE:
if (event->val == KM_RELEASE) {
-
+
if (ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) {
if (rmd->ar->flag & RGN_FLAG_HIDDEN) {
region_scale_toggle_hidden(C, rmd);
@@ -2317,15 +2340,15 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
MEM_freeN(op->customdata);
op->customdata = NULL;
-
+
return OPERATOR_FINISHED;
}
break;
-
+
case ESCKEY:
break;
}
-
+
return OPERATOR_RUNNING_MODAL;
}
@@ -2341,13 +2364,13 @@ static void SCREEN_OT_region_scale(wmOperatorType *ot)
ot->name = "Scale Region Size";
ot->description = "Scale selected area";
ot->idname = "SCREEN_OT_region_scale";
-
+
ot->invoke = region_scale_invoke;
ot->modal = region_scale_modal;
ot->cancel = region_scale_cancel;
-
+
ot->poll = ED_operator_areaactive;
-
+
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL;
}
@@ -2405,19 +2428,19 @@ static int frame_offset_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
int delta;
-
+
delta = RNA_int_get(op->ptr, "delta");
CFRA += delta;
FRAMENUMBER_MIN_CLAMP(CFRA);
SUBFRA = 0.f;
-
+
areas_do_frame_follow(C, false);
BKE_sound_seek_scene(bmain, scene);
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -2426,13 +2449,13 @@ static void SCREEN_OT_frame_offset(wmOperatorType *ot)
ot->name = "Frame Offset";
ot->idname = "SCREEN_OT_frame_offset";
ot->description = "Move current frame forward/backward by a given number";
-
+
ot->exec = frame_offset_exec;
-
+
ot->poll = ED_operator_screenactive_norender;
ot->flag = OPTYPE_UNDO_GROUPED;
ot->undo_group = "FRAME_CHANGE";
-
+
/* rna */
RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX);
}
@@ -2456,9 +2479,9 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
*/
if (animtimer) {
ScreenAnimData *sad = animtimer->customdata;
-
+
sad->flag |= ANIMPLAY_FLAG_USE_NEXT_FRAME;
-
+
if (RNA_boolean_get(op->ptr, "end"))
sad->nextfra = PEFRA;
else
@@ -2469,14 +2492,14 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
CFRA = PEFRA;
else
CFRA = PSFRA;
-
+
areas_do_frame_follow(C, true);
BKE_sound_seek_scene(bmain, scene);
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
-
+
return OPERATOR_FINISHED;
}
@@ -2485,13 +2508,13 @@ static void SCREEN_OT_frame_jump(wmOperatorType *ot)
ot->name = "Jump to Endpoint";
ot->description = "Jump to first/last frame in frame range";
ot->idname = "SCREEN_OT_frame_jump";
-
+
ot->exec = frame_jump_exec;
-
+
ot->poll = ED_operator_screenactive_norender;
ot->flag = OPTYPE_UNDO_GROUPED;
ot->undo_group = "FRAME_CHANGE";
-
+
/* rna */
RNA_def_boolean(ot->srna, "end", 0, "Last Frame", "Jump to the last frame of the frame range");
}
@@ -2514,7 +2537,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
float cfra;
const bool next = RNA_boolean_get(op->ptr, "next");
bool done = false;
-
+
/* sanity checks */
if (scene == NULL)
return OPERATOR_CANCELLED;
@@ -2523,13 +2546,13 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
/* init binarytree-list for getting keyframes */
BLI_dlrbTree_init(&keys);
-
+
/* seed up dummy dopesheet context with flags to perform necessary filtering */
if ((scene->flag & SCE_KEYS_NO_SELONLY) == 0) {
/* only selected channels are included */
ads.filterflag |= ADS_FILTER_ONLYSEL;
}
-
+
/* populate tree with keyframe nodes */
scene_to_keylist(&ads, scene, &keys, NULL);
gpencil_to_keylist(&ads, scene->gpd, &keys);
@@ -2538,7 +2561,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
ob_to_keylist(&ads, ob, &keys, NULL);
gpencil_to_keylist(&ads, ob->gpd, &keys);
}
-
+
{
Mask *mask = CTX_data_edit_mask(C);
if (mask) {
@@ -2549,13 +2572,13 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
/* build linked-list for searching */
BLI_dlrbTree_linkedlist_sync(&keys);
-
+
/* find matching keyframe in the right direction */
if (next)
ak = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra);
else
ak = (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra);
-
+
while ((ak != NULL) && (done == false)) {
if (CFRA != (int)ak->cfra) {
/* this changes the frame, so set the frame and we're done */
@@ -2572,7 +2595,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
}
}
}
-
+
/* free temp stuff */
BLI_dlrbTree_free(&keys);
@@ -2598,13 +2621,13 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot)
ot->name = "Jump to Keyframe";
ot->description = "Jump to previous/next keyframe";
ot->idname = "SCREEN_OT_keyframe_jump";
-
+
ot->exec = keyframe_jump_exec;
-
+
ot->poll = ED_operator_screenactive_norender;
ot->flag = OPTYPE_UNDO_GROUPED;
ot->undo_group = "FRAME_CHANGE";
-
+
/* properties */
RNA_def_boolean(ot->srna, "next", true, "Next Keyframe", "");
}
@@ -2700,7 +2723,7 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot)
ot->name = "Set Screen";
ot->description = "Cycle through available screens";
ot->idname = "SCREEN_OT_screen_set";
-
+
ot->exec = screen_set_exec;
ot->poll = ED_operator_screenactive;
@@ -2720,17 +2743,17 @@ static int screen_maximize_area_exec(bContext *C, wmOperator *op)
bScreen *screen = CTX_wm_screen(C);
ScrArea *sa = NULL;
const bool hide_panels = RNA_boolean_get(op->ptr, "use_hide_panels");
-
+
/* search current screen for 'fullscreen' areas */
/* prevents restoring info header, when mouse is over it */
for (sa = screen->areabase.first; sa; sa = sa->next) {
if (sa->full) break;
}
-
+
if (sa == NULL) {
sa = CTX_wm_area(C);
}
-
+
if (hide_panels) {
if (!ELEM(screen->state, SCREENNORMAL, SCREENFULL)) {
return OPERATOR_CANCELLED;
@@ -2763,7 +2786,7 @@ static void SCREEN_OT_screen_full_area(wmOperatorType *ot)
ot->name = "Toggle Maximize Area";
ot->description = "Toggle display selected area as fullscreen/maximized";
ot->idname = "SCREEN_OT_screen_full_area";
-
+
ot->exec = screen_maximize_area_exec;
ot->poll = screen_maximize_area_poll;
ot->flag = 0;
@@ -2778,28 +2801,28 @@ static void SCREEN_OT_screen_full_area(wmOperatorType *ot)
/** \name Screen Join-Area Operator
* \{ */
-/* operator state vars used:
+/* operator state vars used:
* x1, y1 mouse coord in first area, which will disappear
* x2, y2 mouse coord in 2nd area, which will become joined
- *
+ *
* functions:
- *
- * init() find edge based on state vars
- * test if the edge divides two areas,
+ *
+ * init() find edge based on state vars
+ * test if the edge divides two areas,
* store active and nonactive area,
- *
+ *
* apply() do the actual join
- *
+ *
* exit() cleanup, send notifier
- *
+ *
* callbacks:
- *
- * exec() calls init, apply, exit
- *
+ *
+ * exec() calls init, apply, exit
+ *
* invoke() sets mouse coords in x,y
* call init()
* add modal handler
- *
+ *
* modal() accept modal events while doing it
* call apply() with active window and nonactive window
* call exit() and remove handler when LMB confirm
@@ -2833,18 +2856,18 @@ static int area_join_init(bContext *C, wmOperator *op)
int x1, y1;
int x2, y2;
int shared = 0;
-
+
/* required properties, make negative to get return 0 if not set by caller */
x1 = RNA_int_get(op->ptr, "min_x");
y1 = RNA_int_get(op->ptr, "min_y");
x2 = RNA_int_get(op->ptr, "max_x");
y2 = RNA_int_get(op->ptr, "max_y");
-
+
sa1 = BKE_screen_find_area_xy(CTX_wm_screen(C), SPACE_TYPE_ANY, x1, y1);
sa2 = BKE_screen_find_area_xy(CTX_wm_screen(C), SPACE_TYPE_ANY, x2, y2);
if (sa1 == NULL || sa2 == NULL || sa1 == sa2)
return 0;
-
+
/* do areas share an edge? */
if (sa1->v1 == sa2->v1 || sa1->v1 == sa2->v2 || sa1->v1 == sa2->v3 || sa1->v1 == sa2->v4) shared++;
if (sa1->v2 == sa2->v1 || sa1->v2 == sa2->v2 || sa1->v2 == sa2->v3 || sa1->v2 == sa2->v4) shared++;
@@ -2854,7 +2877,7 @@ static int area_join_init(bContext *C, wmOperator *op)
printf("areas don't share edge\n");
return 0;
}
-
+
jd = (sAreaJoinData *)MEM_callocN(sizeof(sAreaJoinData), "op_area_join");
jd->sa1 = sa1;
@@ -2872,7 +2895,7 @@ static int area_join_apply(bContext *C, wmOperator *op)
{
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
if (!jd) return 0;
-
+
if (!screen_area_join(C, CTX_wm_screen(C), jd->sa1, jd->sa2)) {
return 0;
}
@@ -2880,7 +2903,7 @@ static int area_join_apply(bContext *C, wmOperator *op)
CTX_wm_area_set(C, NULL);
CTX_wm_region_set(C, NULL);
}
-
+
return 1;
}
@@ -2896,7 +2919,7 @@ static void area_join_exit(bContext *C, wmOperator *op)
MEM_freeN(jd);
op->customdata = NULL;
}
-
+
/* this makes sure aligned edges will result in aligned grabbing */
BKE_screen_remove_double_scredges(CTX_wm_screen(C));
BKE_screen_remove_unused_scredges(CTX_wm_screen(C));
@@ -2905,55 +2928,55 @@ static void area_join_exit(bContext *C, wmOperator *op)
static int area_join_exec(bContext *C, wmOperator *op)
{
- if (!area_join_init(C, op))
+ if (!area_join_init(C, op))
return OPERATOR_CANCELLED;
-
+
area_join_apply(C, op);
area_join_exit(C, op);
-
+
return OPERATOR_FINISHED;
}
/* interaction callback */
static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
-
+
if (event->type == EVT_ACTIONZONE_AREA) {
sActionzoneData *sad = event->customdata;
-
+
if (sad == NULL || sad->modifier > 0) {
return OPERATOR_PASS_THROUGH;
}
-
+
/* verify *sad itself */
if (sad->sa1 == NULL || sad->sa2 == NULL)
return OPERATOR_PASS_THROUGH;
-
+
/* is this our *sad? if areas equal it should be passed on */
if (sad->sa1 == sad->sa2)
return OPERATOR_PASS_THROUGH;
-
+
/* prepare operator state vars */
RNA_int_set(op->ptr, "min_x", sad->x);
RNA_int_set(op->ptr, "min_y", sad->y);
RNA_int_set(op->ptr, "max_x", event->x);
RNA_int_set(op->ptr, "max_y", event->y);
}
-
-
- if (!area_join_init(C, op))
+
+
+ if (!area_join_init(C, op))
return OPERATOR_PASS_THROUGH;
-
+
/* add temp handler */
WM_event_add_modal_handler(C, op);
-
+
return OPERATOR_RUNNING_MODAL;
}
static void area_join_cancel(bContext *C, wmOperator *op)
{
WM_event_add_notifier(C, NC_WINDOW, NULL);
-
+
area_join_exit(C, op);
}
@@ -2962,15 +2985,15 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
bScreen *sc = CTX_wm_screen(C);
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
-
+
/* execute the events */
switch (event->type) {
-
- case MOUSEMOVE:
+
+ case MOUSEMOVE:
{
ScrArea *sa = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, event->x, event->y);
int dir;
-
+
if (sa) {
if (jd->sa1 != sa) {
dir = area_getorientation(jd->sa1, sa);
@@ -2978,7 +3001,7 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
jd->sa2 = sa;
}
else {
- /* we are not bordering on the previously selected area
+ /* we are not bordering on the previously selected area
* we check if area has common border with the one marked for removal
* in this case we can swap areas.
*/
@@ -2994,7 +3017,7 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
WM_event_add_notifier(C, NC_WINDOW, NULL);
}
else {
- /* we are back in the area previously selected for keeping
+ /* we are back in the area previously selected for keeping
* we swap the areas if possible to allow user to choose */
if (jd->sa2 != NULL) {
jd->sa1 = jd->sa2;
@@ -3026,13 +3049,13 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_FINISHED;
}
break;
-
+
case RIGHTMOUSE:
case ESCKEY:
area_join_cancel(C, op);
return OPERATOR_CANCELLED;
}
-
+
return OPERATOR_RUNNING_MODAL;
}
@@ -3043,17 +3066,17 @@ static void SCREEN_OT_area_join(wmOperatorType *ot)
ot->name = "Join Area";
ot->description = "Join selected areas into new window";
ot->idname = "SCREEN_OT_area_join";
-
+
/* api callbacks */
ot->exec = area_join_exec;
ot->invoke = area_join_invoke;
ot->modal = area_join_modal;
ot->poll = screen_active_editable;
ot->cancel = area_join_cancel;
-
+
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL;
-
+
/* rna */
RNA_def_int(ot->srna, "min_x", -100, INT_MIN, INT_MAX, "X 1", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "min_y", -100, INT_MIN, INT_MAX, "Y 1", "", INT_MIN, INT_MAX);
@@ -3079,12 +3102,12 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
WM_window_screen_rect_calc(win, &screen_rect);
actedge = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(sc), &screen_rect, event->x, event->y);
-
+
if (actedge == NULL) return OPERATOR_CANCELLED;
-
+
pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE);
layout = UI_popup_menu_layout(pup);
-
+
uiItemFullO(layout, "SCREEN_OT_area_split", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &ptr);
/* store initial mouse cursor position */
RNA_int_set(&ptr, "mouse_x", event->x);
@@ -3096,9 +3119,9 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
RNA_int_set(&ptr, "min_y", event->y + 4);
RNA_int_set(&ptr, "max_x", event->x - 4);
RNA_int_set(&ptr, "max_y", event->y - 4);
-
+
UI_popup_menu_end(C, pup);
-
+
return OPERATOR_INTERFACE;
}
@@ -3108,10 +3131,10 @@ static void SCREEN_OT_area_options(wmOperatorType *ot)
ot->name = "Area Options";
ot->description = "Operations for splitting and merging";
ot->idname = "SCREEN_OT_area_options";
-
+
/* api callbacks */
ot->invoke = screen_area_options_invoke;
-
+
ot->poll = ED_operator_screen_mainwinactive;
/* flags */
@@ -3130,7 +3153,7 @@ static int spacedata_cleanup_exec(bContext *C, wmOperator *op)
bScreen *screen;
ScrArea *sa;
int tot = 0;
-
+
for (screen = bmain->screen.first; screen; screen = screen->id.next) {
for (sa = screen->areabase.first; sa; sa = sa->next) {
if (sa->spacedata.first != sa->spacedata.last) {
@@ -3144,7 +3167,7 @@ static int spacedata_cleanup_exec(bContext *C, wmOperator *op)
}
}
BKE_reportf(op->reports, RPT_INFO, "Removed amount of editors: %d", tot);
-
+
return OPERATOR_FINISHED;
}
@@ -3154,11 +3177,11 @@ static void SCREEN_OT_spacedata_cleanup(wmOperatorType *ot)
ot->name = "Clean-up Space-data";
ot->description = "Remove unused settings for invisible editors";
ot->idname = "SCREEN_OT_spacedata_cleanup";
-
+
/* api callbacks */
ot->exec = spacedata_cleanup_exec;
ot->poll = WM_operator_winactive;
-
+
}
/** \} */
@@ -3186,7 +3209,7 @@ static int repeat_last_exec(bContext *C, wmOperator *UNUSED(op))
WM_operator_free_all_after(wm, lastop);
WM_operator_repeat(C, lastop);
}
-
+
return OPERATOR_CANCELLED;
}
@@ -3196,12 +3219,12 @@ static void SCREEN_OT_repeat_last(wmOperatorType *ot)
ot->name = "Repeat Last";
ot->description = "Repeat last action";
ot->idname = "SCREEN_OT_repeat_last";
-
+
/* api callbacks */
ot->exec = repeat_last_exec;
-
+
ot->poll = ED_operator_screenactive;
-
+
}
/** \} */
@@ -3217,37 +3240,37 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNU
uiPopupMenu *pup;
uiLayout *layout;
int items, i;
-
+
items = BLI_listbase_count(&wm->operators);
if (items == 0)
return OPERATOR_CANCELLED;
-
+
pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE);
layout = UI_popup_menu_layout(pup);
-
+
for (i = items - 1, lastop = wm->operators.last; lastop; lastop = lastop->prev, i--)
if ((lastop->type->flag & OPTYPE_REGISTER) && WM_operator_repeat_check(C, lastop)) {
uiItemIntO(layout, RNA_struct_ui_name(lastop->type->srna), ICON_NONE, op->type->idname, "index", i);
}
-
+
UI_popup_menu_end(C, pup);
-
+
return OPERATOR_INTERFACE;
}
static int repeat_history_exec(bContext *C, wmOperator *op)
{
wmWindowManager *wm = CTX_wm_manager(C);
-
+
op = BLI_findlink(&wm->operators, RNA_int_get(op->ptr, "index"));
if (op) {
/* let's put it as last operator in list */
BLI_remlink(&wm->operators, op);
BLI_addtail(&wm->operators, op);
-
+
WM_operator_repeat(C, op);
}
-
+
return OPERATOR_FINISHED;
}
@@ -3257,13 +3280,13 @@ static void SCREEN_OT_repeat_history(wmOperatorType *ot)
ot->name = "Repeat History";
ot->description = "Display menu for previous actions performed";
ot->idname = "SCREEN_OT_repeat_history";
-
+
/* api callbacks */
ot->invoke = repeat_history_invoke;
ot->exec = repeat_history_exec;
-
+
ot->poll = ED_operator_screenactive;
-
+
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000);
}
@@ -3276,10 +3299,10 @@ static void SCREEN_OT_repeat_history(wmOperatorType *ot)
static int redo_last_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
{
wmOperator *lastop = WM_operator_last_redo(C);
-
+
if (lastop)
WM_operator_redo_popup(C, lastop);
-
+
return OPERATOR_CANCELLED;
}
@@ -3289,10 +3312,10 @@ static void SCREEN_OT_redo_last(wmOperatorType *ot)
ot->name = "Redo Last";
ot->description = "Display menu for last action performed";
ot->idname = "SCREEN_OT_redo_last";
-
+
/* api callbacks */
ot->invoke = redo_last_invoke;
-
+
ot->poll = ED_operator_screenactive;
}
@@ -3335,7 +3358,7 @@ static void region_quadview_init_rv3d(ScrArea *sa, ARegion *ar,
static int region_quadview_exec(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
-
+
/* some rules... */
if (ar->regiontype != RGN_TYPE_WINDOW) {
BKE_report(op->reports, RPT_ERROR, "Only window region can be 4-splitted");
@@ -3344,10 +3367,10 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
/* Exit quad-view */
ScrArea *sa = CTX_wm_area(C);
ARegion *arn;
-
+
/* keep current region */
ar->alignment = 0;
-
+
if (sa->spacetype == SPACE_VIEW3D) {
ARegion *ar_iter;
RegionView3D *rv3d = ar->regiondata;
@@ -3377,7 +3400,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
}
}
}
-
+
for (ar = sa->regionbase.first; ar; ar = arn) {
arn = ar->next;
if (ar->alignment == RGN_ALIGN_QSPLIT) {
@@ -3398,14 +3421,14 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
ScrArea *sa = CTX_wm_area(C);
ARegion *newar;
int count;
-
+
ar->alignment = RGN_ALIGN_QSPLIT;
-
+
for (count = 0; count < 3; count++) {
newar = BKE_area_region_copy(sa->type, ar);
BLI_addtail(&sa->regionbase, newar);
}
-
+
/* lock views and set them */
if (sa->spacetype == SPACE_VIEW3D) {
View3D *v3d = sa->spacedata.first;
@@ -3435,8 +3458,8 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
ED_area_tag_redraw(sa);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
}
-
-
+
+
return OPERATOR_FINISHED;
}
@@ -3446,7 +3469,7 @@ static void SCREEN_OT_region_quadview(wmOperatorType *ot)
ot->name = "Toggle Quad View";
ot->description = "Split selected area into camera, front, right & top views";
ot->idname = "SCREEN_OT_region_quadview";
-
+
/* api callbacks */
ot->exec = region_quadview_exec;
ot->poll = ED_operator_region_view3d_active;
@@ -3463,10 +3486,10 @@ static void SCREEN_OT_region_quadview(wmOperatorType *ot)
static int region_flip_exec(bContext *C, wmOperator *UNUSED(op))
{
ARegion *ar = CTX_wm_region(C);
-
+
if (!ar)
return OPERATOR_CANCELLED;
-
+
if (ar->alignment == RGN_ALIGN_TOP)
ar->alignment = RGN_ALIGN_BOTTOM;
else if (ar->alignment == RGN_ALIGN_BOTTOM)
@@ -3478,7 +3501,7 @@ static int region_flip_exec(bContext *C, wmOperator *UNUSED(op))
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -3501,7 +3524,7 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot)
ot->name = "Flip Region";
ot->idname = "SCREEN_OT_region_flip";
ot->description = "Toggle the region's alignment (left/right or top/bottom)";
-
+
/* api callbacks */
ot->exec = region_flip_exec;
ot->poll = region_flip_poll;
@@ -3568,7 +3591,7 @@ static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot)
ot->name = "Expand/Collapse Header Menus";
ot->idname = "SCREEN_OT_header_toggle_menus";
ot->description = "Expand or collapse the header pulldown menus";
-
+
/* api callbacks */
ot->exec = header_toggle_menus_exec;
ot->poll = ED_operator_areaactive;
@@ -3587,6 +3610,8 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN
ARegion *ar = CTX_wm_region(C);
const char *but_flip_str = (ar->alignment == RGN_ALIGN_TOP) ? IFACE_("Flip to Bottom") : IFACE_("Flip to Top");
+ uiItemO(layout, IFACE_("Toggle Header"), ICON_NONE, "SCREEN_OT_header");
+
/* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
@@ -3626,7 +3651,7 @@ static void SCREEN_OT_header_toolbox(wmOperatorType *ot)
ot->name = "Header Toolbox";
ot->description = "Display header region toolbox";
ot->idname = "SCREEN_OT_header_toolbox";
-
+
/* api callbacks */
ot->invoke = header_toolbox_invoke;
}
@@ -3647,14 +3672,14 @@ static int match_area_with_refresh(int spacetype, int refresh)
return 1;
break;
}
-
+
return 0;
}
static int match_region_with_redraws(int spacetype, int regiontype, int redraws, bool from_anim_edit)
{
if (regiontype == RGN_TYPE_WINDOW) {
-
+
switch (spacetype) {
case SPACE_VIEW3D:
if ((redraws & TIME_ALL_3D_WIN) || from_anim_edit)
@@ -3692,7 +3717,7 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws,
if ((redraws & TIME_CLIPS) || from_anim_edit)
return 1;
break;
-
+
}
}
else if (regiontype == RGN_TYPE_CHANNELS) {
@@ -3757,12 +3782,12 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
ScrArea *sa;
int sync;
float time;
-
+
/* sync, don't sync, or follow scene setting */
if (sad->flag & ANIMPLAY_FLAG_SYNC) sync = 1;
else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC) sync = 0;
else sync = (scene->flag & SCE_FRAME_DROP);
-
+
if ((scene->audio.flag & AUDIO_SYNC) &&
(sad->flag & ANIMPLAY_FLAG_REVERSE) == false &&
isfinite(time = BKE_sound_sync_scene(scene)))
@@ -3808,12 +3833,12 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
scene->r.cfra++;
}
}
-
+
sad->last_duration = wt->duration;
/* reset 'jumped' flag before checking if we need to jump... */
sad->flag &= ~ANIMPLAY_FLAG_JUMPED;
-
+
if (sad->flag & ANIMPLAY_FLAG_REVERSE) {
/* jump back to end? */
if (PRVRANGEON) {
@@ -3851,14 +3876,14 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
sad->flag &= ~ANIMPLAY_FLAG_USE_NEXT_FRAME;
sad->flag |= ANIMPLAY_FLAG_JUMPED;
}
-
+
if (sad->flag & ANIMPLAY_FLAG_JUMPED) {
BKE_sound_seek_scene(bmain, scene);
#ifdef PROFILE_AUDIO_SYNCH
old_frame = CFRA;
#endif
}
-
+
/* since we follow drawflags, we can't send notifier but tag regions ourselves */
ED_update_for_newframe(bmain, depsgraph);
@@ -3897,24 +3922,24 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
}
}
}
-
+
if (match_area_with_refresh(sa->spacetype, sad->refresh))
ED_area_tag_refresh(sa);
}
}
-
- /* update frame rate info too
- * NOTE: this may not be accurate enough, since we might need this after modifiers/etc.
+
+ /* update frame rate info too
+ * NOTE: this may not be accurate enough, since we might need this after modifiers/etc.
* have been calculated instead of just before updates have been done?
*/
ED_refresh_viewport_fps(C);
-
+
/* recalculate the timestep for the timer now that we've finished calculating this,
* since the frames-per-second value may have been changed
*/
/* TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this? */
wt->timestep = (1.0 / FPS);
-
+
return OPERATOR_FINISHED;
}
return OPERATOR_PASS_THROUGH;
@@ -3926,12 +3951,12 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot)
ot->name = "Animation Step";
ot->description = "Step through animation by position";
ot->idname = "SCREEN_OT_animation_step";
-
+
/* api callbacks */
ot->invoke = screen_animation_step;
-
+
ot->poll = ED_operator_screenactive_norender;
-
+
}
/** \} */
@@ -3985,16 +4010,16 @@ int ED_screen_animation_play(bContext *C, int sync, int mode)
}
else {
int refresh = SPACE_ACTION; /* these settings are currently only available from a menu in the TimeLine */
-
+
if (mode == 1) /* XXX only play audio forwards!? */
BKE_sound_play_scene(scene);
-
+
ED_screen_animation_timer(C, screen->redraws_flag, refresh, sync, mode);
-
+
if (screen->animtimer) {
wmTimer *wt = screen->animtimer;
ScreenAnimData *sad = wt->customdata;
-
+
sad->ar = CTX_wm_region(C);
}
}
@@ -4006,10 +4031,10 @@ static int screen_animation_play_exec(bContext *C, wmOperator *op)
{
int mode = (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1;
int sync = -1;
-
+
if (RNA_struct_property_is_set(op->ptr, "sync"))
sync = (RNA_boolean_get(op->ptr, "sync"));
-
+
return ED_screen_animation_play(C, sync, mode);
}
@@ -4021,12 +4046,12 @@ static void SCREEN_OT_animation_play(wmOperatorType *ot)
ot->name = "Play Animation";
ot->description = "Play animation";
ot->idname = "SCREEN_OT_animation_play";
-
+
/* api callbacks */
ot->exec = screen_animation_play_exec;
-
+
ot->poll = ED_operator_screenactive_norender;
-
+
prop = RNA_def_boolean(ot->srna, "reverse", 0, "Play in Reverse", "Animation is played backwards");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "sync", 0, "Sync", "Drop frames to maintain framerate");
@@ -4069,10 +4094,10 @@ static void SCREEN_OT_animation_cancel(wmOperatorType *ot)
ot->name = "Cancel Animation";
ot->description = "Cancel animation, returning to the original frame";
ot->idname = "SCREEN_OT_animation_cancel";
-
+
/* api callbacks */
ot->exec = screen_animation_cancel_exec;
-
+
ot->poll = ED_operator_screenactive;
RNA_def_boolean(ot->srna, "restore_frame", true, "Restore Frame", "Restore the frame when animation was initialized");
@@ -4084,36 +4109,36 @@ static void SCREEN_OT_animation_cancel(wmOperatorType *ot)
/** \name Border Select Operator (Template)
* \{ */
-/* operator state vars used: (added by default WM callbacks)
- * xmin, ymin
- * xmax, ymax
- *
+/* operator state vars used: (added by default WM callbacks)
+ * xmin, ymin
+ * xmax, ymax
+ *
* customdata: the wmGesture pointer
- *
+ *
* callbacks:
- *
+ *
* exec() has to be filled in by user
- *
+ *
* invoke() default WM function
* adds modal handler
- *
- * modal() default WM function
+ *
+ * modal() default WM function
* accept modal events while doing it, calls exec(), handles ESC and border drawing
- *
+ *
* poll() has to be filled in by user for context
*/
#if 0
static int border_select_exec(bContext *C, wmOperator *op)
{
int event_type = RNA_int_get(op->ptr, "event_type");
-
+
if (event_type == LEFTMOUSE)
printf("border select do select\n");
else if (event_type == RIGHTMOUSE)
printf("border select deselect\n");
- else
+ else
printf("border select do something\n");
-
+
return 1;
}
@@ -4122,15 +4147,15 @@ static void SCREEN_OT_border_select(wmOperatorType *ot)
/* identifiers */
ot->name = "Border Select";
ot->idname = "SCREEN_OT_border_select";
-
+
/* api callbacks */
ot->exec = border_select_exec;
ot->invoke = WM_gesture_border_invoke;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
-
+
ot->poll = ED_operator_areaactive;
-
+
/* rna */
RNA_def_int(ot->srna, "event_type", 0, INT_MIN, INT_MAX, "Event Type", "", INT_MIN, INT_MAX);
WM_operator_properties_border(ot);
@@ -4150,7 +4175,7 @@ static int fullscreen_back_exec(bContext *C, wmOperator *op)
{
bScreen *screen = CTX_wm_screen(C);
ScrArea *sa = NULL;
-
+
/* search current screen for 'fullscreen' areas */
for (sa = screen->areabase.first; sa; sa = sa->next) {
if (sa->full) break;
@@ -4171,7 +4196,7 @@ static void SCREEN_OT_back_to_previous(struct wmOperatorType *ot)
ot->name = "Back to Previous Screen";
ot->description = "Revert back to the original screen layout, before fullscreen area overlay";
ot->idname = "SCREEN_OT_back_to_previous";
-
+
/* api callbacks */
ot->exec = fullscreen_back_exec;
ot->poll = ED_operator_screenactive;
@@ -4187,7 +4212,7 @@ static int userpref_show_invoke(bContext *C, wmOperator *op, const wmEvent *even
{
int sizex = 800 * UI_DPI_FAC;
int sizey = 500 * UI_DPI_FAC;
-
+
/* changes context! */
if (WM_window_open_temp(C, event->x, event->y, sizex, sizey, WM_WINDOW_USERPREFS) != NULL) {
return OPERATOR_FINISHED;
@@ -4205,7 +4230,7 @@ static void SCREEN_OT_userpref_show(struct wmOperatorType *ot)
ot->name = "Show User Preferences";
ot->description = "Show user preferences";
ot->idname = "SCREEN_OT_userpref_show";
-
+
/* api callbacks */
ot->invoke = userpref_show_invoke;
ot->poll = ED_operator_screenactive;
@@ -4223,23 +4248,23 @@ static int drivers_editor_show_invoke(bContext *C, wmOperator *op, const wmEvent
PropertyRNA *prop = NULL;
int index = -1;
uiBut *but = NULL;
-
+
int sizex = 900 * UI_DPI_FAC;
int sizey = 580 * UI_DPI_FAC;
-
+
/* Get active property to show driver for
* - Need to grab it first, or else this info disappears
* after we've created the window
*/
but = UI_context_active_but_prop_get(C, &ptr, &prop, &index);
-
+
/* changes context! */
if (WM_window_open_temp(C, event->x, event->y, sizex, sizey, WM_WINDOW_DRIVERS) != NULL) {
/* activate driver F-Curve for the property under the cursor */
if (but) {
FCurve *fcu;
bool driven, special;
-
+
fcu = rna_get_fcurve_context_ui(C,
&ptr, prop, index,
NULL, NULL, &driven, &special);
@@ -4257,7 +4282,7 @@ static int drivers_editor_show_invoke(bContext *C, wmOperator *op, const wmEvent
}
}
}
-
+
return OPERATOR_FINISHED;
}
else {
@@ -4273,7 +4298,7 @@ static void SCREEN_OT_drivers_editor_show(struct wmOperatorType *ot)
ot->name = "Show Drivers Editor";
ot->description = "Show drivers editor in a separate window";
ot->idname = "SCREEN_OT_drivers_editor_show";
-
+
/* api callbacks */
ot->invoke = drivers_editor_show_invoke;
ot->poll = ED_operator_screenactive;
@@ -4287,12 +4312,13 @@ static void SCREEN_OT_drivers_editor_show(struct wmOperatorType *ot)
static int screen_new_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Main *bmain = CTX_data_main(C);
wmWindow *win = CTX_wm_window(C);
WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
WorkSpaceLayout *layout_old = BKE_workspace_active_layout_get(win->workspace_hook);
WorkSpaceLayout *layout_new;
- layout_new = ED_workspace_layout_duplicate(workspace, layout_old, win);
+ layout_new = ED_workspace_layout_duplicate(bmain, workspace, layout_old, win);
WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTBROWSE, layout_new);
return OPERATOR_FINISHED;
@@ -4304,7 +4330,7 @@ static void SCREEN_OT_new(wmOperatorType *ot)
ot->name = "New Screen";
ot->description = "Add a new screen";
ot->idname = "SCREEN_OT_new";
-
+
/* api callbacks */
ot->exec = screen_new_exec;
ot->poll = WM_operator_winactive;
@@ -4333,7 +4359,7 @@ static void SCREEN_OT_delete(wmOperatorType *ot)
ot->name = "Delete Screen";
ot->description = "Delete active screen";
ot->idname = "SCREEN_OT_delete";
-
+
/* api callbacks */
ot->exec = screen_delete_exec;
}
@@ -4371,7 +4397,7 @@ float ED_region_blend_alpha(ARegion *ar)
alpha = (float)ar->regiontimer->duration / TIMEOUT;
/* makes sure the blend out works 100% - without area redraws */
if (rgi->hidden) alpha = 0.9f - TIMESTEP - alpha;
-
+
CLAMP(alpha, 0.0f, 1.0f);
return alpha;
}
@@ -4382,12 +4408,12 @@ float ED_region_blend_alpha(ARegion *ar)
static void region_blend_end(bContext *C, ARegion *ar, const bool is_running)
{
RegionAlphaInfo *rgi = ar->regiontimer->customdata;
-
+
/* always send redraw */
ED_region_tag_redraw(ar);
if (rgi->child_ar)
ED_region_tag_redraw(rgi->child_ar);
-
+
/* if running timer was hiding, the flag toggle went wrong */
if (is_running) {
if (rgi->hidden)
@@ -4411,14 +4437,14 @@ void region_blend_start(bContext *C, ScrArea *sa, ARegion *ar)
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
RegionAlphaInfo *rgi;
-
+
/* end running timer */
if (ar->regiontimer) {
region_blend_end(C, ar, true);
}
rgi = MEM_callocN(sizeof(RegionAlphaInfo), "RegionAlphaInfo");
-
+
rgi->hidden = ar->flag & RGN_FLAG_HIDDEN;
rgi->sa = sa;
rgi->ar = ar;
@@ -4447,18 +4473,18 @@ static int region_blend_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven
{
RegionAlphaInfo *rgi;
wmTimer *timer = event->customdata;
-
+
/* event type is TIMERREGION, but we better check */
if (event->type != TIMERREGION || timer == NULL)
return OPERATOR_PASS_THROUGH;
-
+
rgi = timer->customdata;
-
+
/* always send redraws */
ED_region_tag_redraw(rgi->ar);
if (rgi->child_ar)
ED_region_tag_redraw(rgi->child_ar);
-
+
/* end timer? */
if (rgi->ar->regiontimer->duration > (double)TIMEOUT) {
region_blend_end(C, rgi->ar, false);
@@ -4474,13 +4500,13 @@ static void SCREEN_OT_region_blend(wmOperatorType *ot)
ot->name = "Region Alpha";
ot->idname = "SCREEN_OT_region_blend";
ot->description = "Blend in and out overlapping region";
-
+
/* api callbacks */
ot->invoke = region_blend_invoke;
-
+
/* flags */
ot->flag = OPTYPE_INTERNAL;
-
+
/* properties */
}
@@ -4543,11 +4569,10 @@ static int space_context_cycle_invoke(bContext *C, wmOperator *op, const wmEvent
PointerRNA ptr;
PropertyRNA *prop;
context_cycle_prop_get(CTX_wm_screen(C), CTX_wm_area(C), &ptr, &prop);
-
const int old_context = RNA_property_enum_get(&ptr, prop);
const int new_context = RNA_property_enum_step(
- C, &ptr, prop, old_context,
- direction == SPACE_CONTEXT_CYCLE_PREV ? -1 : 1);
+ C, &ptr, prop, old_context,
+ direction == SPACE_CONTEXT_CYCLE_PREV ? -1 : 1);
RNA_property_enum_set(&ptr, prop, new_context);
RNA_property_update(C, &ptr, prop);
@@ -4574,6 +4599,51 @@ static void SCREEN_OT_space_context_cycle(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Workspace Cycle Operator
+ * \{ */
+
+static int space_workspace_cycle_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ wmWindow *win = CTX_wm_window(C);
+ if (WM_window_is_temp_screen(win)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ Main *bmain = CTX_data_main(C);
+ const int direction = RNA_enum_get(op->ptr, "direction");
+ WorkSpace *workspace_src = WM_window_get_active_workspace(win);
+ WorkSpace *workspace_dst = (direction == SPACE_CONTEXT_CYCLE_PREV) ? workspace_src->id.prev : workspace_src->id.next;
+ if (workspace_dst == NULL) {
+ workspace_dst = (direction == SPACE_CONTEXT_CYCLE_PREV) ? bmain->workspaces.last : bmain->workspaces.first;
+ }
+ if (workspace_src != workspace_dst) {
+ win->workspace_hook->temp_workspace_store = workspace_dst;
+ WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_SET, workspace_dst);
+ win->workspace_hook->temp_workspace_store = NULL;
+ }
+ return OPERATOR_FINISHED;
+}
+
+static void SCREEN_OT_workspace_cycle(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Cycle Workspace";
+ ot->description = "Cycle through workspaces";
+ ot->idname = "SCREEN_OT_workspace_cycle";
+
+ /* api callbacks */
+ ot->invoke = space_workspace_cycle_invoke;
+ ot->poll = ED_operator_screenactive;;
+
+ ot->flag = 0;
+
+ RNA_def_enum(ot->srna, "direction", space_context_cycle_direction, SPACE_CONTEXT_CYCLE_NEXT, "Direction",
+ "Direction to cycle through");
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Assigning Operator Types
* \{ */
@@ -4585,7 +4655,7 @@ void ED_operatortypes_screen(void)
WM_operatortype_append(SCREEN_OT_repeat_last);
WM_operatortype_append(SCREEN_OT_repeat_history);
WM_operatortype_append(SCREEN_OT_redo_last);
-
+
/* screen tools */
WM_operatortype_append(SCREEN_OT_area_move);
WM_operatortype_append(SCREEN_OT_area_split);
@@ -4609,13 +4679,14 @@ void ED_operatortypes_screen(void)
WM_operatortype_append(SCREEN_OT_drivers_editor_show);
WM_operatortype_append(SCREEN_OT_region_blend);
WM_operatortype_append(SCREEN_OT_space_context_cycle);
-
+ WM_operatortype_append(SCREEN_OT_workspace_cycle);
+
/*frame changes*/
WM_operatortype_append(SCREEN_OT_frame_offset);
WM_operatortype_append(SCREEN_OT_frame_jump);
WM_operatortype_append(SCREEN_OT_keyframe_jump);
WM_operatortype_append(SCREEN_OT_marker_jump);
-
+
WM_operatortype_append(SCREEN_OT_animation_step);
WM_operatortype_append(SCREEN_OT_animation_play);
WM_operatortype_append(SCREEN_OT_animation_cancel);
@@ -4632,7 +4703,7 @@ void ED_operatortypes_screen(void)
WM_operatortype_append(ED_OT_undo_history);
WM_operatortype_append(ED_OT_flush_edits);
-
+
}
/** \} */
@@ -4650,20 +4721,20 @@ static void keymap_modal_set(wmKeyConfig *keyconf)
{KM_MODAL_SNAP_OFF, "SNAP_OFF", 0, "Snap off", ""},
{0, NULL, 0, NULL, NULL}};
wmKeyMap *keymap;
-
+
/* Standard Modal keymap ------------------------------------------------ */
keymap = WM_modalkeymap_add(keyconf, "Standard Modal Map", modal_items);
-
+
WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, KM_MODAL_CANCEL);
WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_ANY, KM_ANY, 0, KM_MODAL_APPLY);
WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, KM_MODAL_APPLY);
WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, KM_MODAL_APPLY);
-
+
WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, KM_MODAL_SNAP_ON);
WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, KM_MODAL_SNAP_OFF);
-
+
WM_modalkeymap_assign(keymap, "SCREEN_OT_area_move");
-
+
}
static int open_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event))
@@ -4689,14 +4760,14 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
ListBase *lb;
wmKeyMap *keymap;
wmKeyMapItem *kmi;
-
+
/* Screen Editing ------------------------------------------------ */
keymap = WM_keymap_find(keyconf, "Screen Editing", 0, 0);
-
+
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "modifier", 0);
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "modifier", 1);
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "modifier", 2);
-
+
/* screen tools */
WM_keymap_verify_item(keymap, "SCREEN_OT_area_split", EVT_ACTIONZONE_AREA, 0, 0, 0);
WM_keymap_verify_item(keymap, "SCREEN_OT_area_join", EVT_ACTIONZONE_AREA, 0, 0, 0);
@@ -4707,7 +4778,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "use_hide_panels", true);
/* area move after action zones */
WM_keymap_verify_item(keymap, "SCREEN_OT_area_move", LEFTMOUSE, KM_PRESS, 0, 0);
-
+
WM_keymap_verify_item(keymap, "SCREEN_OT_area_options", RIGHTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SCREEN_OT_header", F9KEY, KM_PRESS, KM_ALT, 0);
@@ -4720,12 +4791,12 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
/* Screen General ------------------------------------------------ */
keymap = WM_keymap_find(keyconf, "Screen", 0, 0);
-
+
/* standard timers */
WM_keymap_add_item(keymap, "SCREEN_OT_animation_step", TIMER0, KM_ANY, KM_ANY, 0);
WM_keymap_add_item(keymap, "SCREEN_OT_region_blend", TIMERREGION, KM_ANY, KM_ANY, 0);
-
-
+
+
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1);
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1);
WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_SHIFT, 0);
@@ -4740,6 +4811,11 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_space_context_cycle", TABKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "direction", SPACE_CONTEXT_CYCLE_PREV);
+ kmi = WM_keymap_add_item(keymap, "SCREEN_OT_workspace_cycle", TABKEY, KM_PRESS, KM_CTRL, 0);
+ RNA_enum_set(kmi->ptr, "direction", SPACE_CONTEXT_CYCLE_NEXT);
+ kmi = WM_keymap_add_item(keymap, "SCREEN_OT_workspace_cycle", TABKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
+ RNA_enum_set(kmi->ptr, "direction", SPACE_CONTEXT_CYCLE_PREV);
+
/* tests */
WM_keymap_add_item(keymap, "SCREEN_OT_region_quadview", QKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", F3KEY, KM_PRESS, 0, 0);
@@ -4747,12 +4823,12 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
WM_keymap_verify_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "SCRIPT_OT_reload", F8KEY, KM_PRESS, 0, 0);
-
+
/* files */
WM_keymap_add_item(keymap, "FILE_OT_execute", RETKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "FILE_OT_execute", PADENTER, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "FILE_OT_cancel", ESCKEY, KM_PRESS, 0, 0);
-
+
/* undo */
#ifdef __APPLE__
WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_OSKEY, 0);
@@ -4762,8 +4838,8 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT | KM_CTRL, 0);
-
-
+
+
/* render */
kmi = WM_keymap_add_item(keymap, "RENDER_OT_render", F12KEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "use_viewport", true);
@@ -4773,62 +4849,62 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "RENDER_OT_view_cancel", ESCKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "RENDER_OT_view_show", F11KEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "RENDER_OT_play_rendered_anim", F11KEY, KM_PRESS, KM_CTRL, 0);
-
+
/* user prefs */
#ifdef __APPLE__
WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", COMMAKEY, KM_PRESS, KM_OSKEY, 0);
#endif
WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", UKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
-
-
+
+
/* Anim Playback ------------------------------------------------ */
keymap = WM_keymap_find(keyconf, "Frames", 0, 0);
-
+
/* frame offsets */
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", UPARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "delta", 10);
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "delta", -10);
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -1);
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 1);
-
+
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", WHEELDOWNMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "delta", 1);
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", WHEELUPMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "delta", -1);
-
+
RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", UPARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "end", true);
RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", DOWNARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "end", false);
RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", true);
RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", false);
-
+
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", UPARROWKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "next", true);
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", DOWNARROWKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "next", false);
-
+
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", MEDIALAST, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "next", true);
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", MEDIAFIRST, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "next", false);
-
+
/* play (forward and backwards) */
WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0)->ptr, "reverse", true);
WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", ESCKEY, KM_PRESS, 0, 0);
-
+
WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", MEDIAPLAY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", MEDIASTOP, KM_PRESS, 0, 0);
-
+
/* Alternative keys for animation and sequencer playing */
#if 0 /* XXX: disabled for restoring later... bad implementation */
keymap = WM_keymap_find(keyconf, "Frames", 0, 0);
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "cycle_speed", true);
-
+
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", LEFTARROWKEY, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "reverse", true);
RNA_boolean_set(kmi->ptr, "cycle_speed", true);
-
+
WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", DOWNARROWKEY, KM_PRESS, KM_ALT, 0);
#endif
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index 2c1cbc3d21d..7e50f8d41c4 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -104,7 +104,7 @@ static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy)
*dumpsy = WM_window_pixels_y(win);
if (*dumpsx && *dumpsy) {
-
+
dumprect = MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect");
glReadBuffer(GL_FRONT);
screenshot_read_pixels(x, y, *dumpsx, *dumpsy, (unsigned char *)dumprect);
@@ -122,13 +122,13 @@ static int screenshot_data_create(bContext *C, wmOperator *op)
/* do redraw so we don't show popups/menus */
WM_redraw_windows(C);
-
+
dumprect = screenshot(C, &dumpsx, &dumpsy);
if (dumprect) {
ScreenshotData *scd = MEM_callocN(sizeof(ScreenshotData), "screenshot");
ScrArea *sa = CTX_wm_area(C);
-
+
scd->dumpsx = dumpsx;
scd->dumpsy = dumpsy;
scd->dumprect = dumprect;
@@ -194,7 +194,7 @@ static int screenshot_exec(bContext *C, wmOperator *op)
char path[FILE_MAX];
RNA_string_get(op->ptr, "filepath", path);
- BLI_path_abs(path, G.main->name);
+ BLI_path_abs(path, BKE_main_blendfile_path_from_global());
/* operator ensures the extension */
ibuf = IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0);
@@ -233,13 +233,13 @@ static int screenshot_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
/* extension is added by 'screenshot_check' after */
char filepath[FILE_MAX] = "//screen";
if (G.relbase_valid) {
- BLI_strncpy(filepath, G.main->name, sizeof(filepath));
+ BLI_strncpy(filepath, BKE_main_blendfile_path_from_global(), sizeof(filepath));
BLI_replace_extension(filepath, sizeof(filepath), ""); /* strip '.blend' */
}
RNA_string_set(op->ptr, "filepath", filepath);
-
+
WM_event_add_fileselect(C, op);
-
+
return OPERATOR_RUNNING_MODAL;
}
return OPERATOR_CANCELLED;
@@ -291,16 +291,16 @@ void SCREEN_OT_screenshot(wmOperatorType *ot)
ot->name = "Save Screenshot"; /* weak: opname starting with 'save' makes filewindow give save-over */
ot->idname = "SCREEN_OT_screenshot";
ot->description = "Capture a picture of the active area or whole Blender window";
-
+
ot->invoke = screenshot_invoke;
ot->check = screenshot_check;
ot->exec = screenshot_exec;
ot->cancel = screenshot_cancel;
ot->ui = screenshot_draw;
ot->poll = screenshot_poll;
-
+
ot->flag = 0;
-
+
WM_operator_properties_filesel(
ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE, FILE_SPECIAL, FILE_SAVE,
WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
@@ -328,7 +328,7 @@ typedef struct ScreenshotJob {
static void screenshot_freejob(void *sjv)
{
ScreenshotJob *sj = sjv;
-
+
if (sj->dumprect)
MEM_freeN(sj->dumprect);
@@ -347,11 +347,11 @@ static void screenshot_updatejob(void *sjv)
{
ScreenshotJob *sj = sjv;
unsigned int *dumprect;
-
+
if (sj->dumprect == NULL) {
dumprect = MEM_mallocN(sizeof(int) * sj->dumpsx * sj->dumpsy, "dumprect");
screenshot_read_pixels(sj->x, sj->y, sj->dumpsx, sj->dumpsy, (unsigned char *)dumprect);
-
+
sj->dumprect = dumprect;
}
}
@@ -367,7 +367,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
/* we need this as local variables for renderdata */
rd.frs_sec = U.scrcastfps;
rd.frs_sec_base = 1.0f;
-
+
if (BKE_imtype_is_movie(rd.im_format.imtype)) {
mh = BKE_movie_handle_get(sj->scene->r.im_format.imtype);
if (mh == NULL) {
@@ -382,16 +382,16 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
return;
}
}
-
+
sj->stop = stop;
sj->do_update = do_update;
-
+
*do_update = true; /* wait for opengl rect */
-
+
while (*stop == 0) {
-
+
if (sj->dumprect) {
-
+
if (mh) {
if (mh->append_movie(sj->movie_ctx, &rd, rd.sfra, rd.cfra, (int *)sj->dumprect,
sj->dumpsx, sj->dumpsy, "", &sj->reports))
@@ -407,14 +407,14 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
ImBuf *ibuf = IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.im_format.planes, 0);
char name[FILE_MAX];
int ok;
-
+
BKE_image_path_from_imformat(
- name, rd.pic, sj->bmain->name, rd.cfra,
+ name, rd.pic, BKE_main_blendfile_path(sj->bmain), rd.cfra,
&rd.im_format, (rd.scemode & R_EXTENSION) != 0, true, NULL);
-
+
ibuf->rect = sj->dumprect;
ok = BKE_imbuf_write(ibuf, name, &rd.im_format);
-
+
if (ok == 0) {
printf("Write error: cannot save %s\n", name);
BKE_reportf(&sj->reports, RPT_INFO, "Write error: cannot save %s", name);
@@ -424,23 +424,23 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
printf("Saved file: %s\n", name);
BKE_reportf(&sj->reports, RPT_INFO, "Saved file: %s", name);
}
-
+
/* imbuf knows which rects are not part of ibuf */
IMB_freeImBuf(ibuf);
}
-
+
MEM_freeN(sj->dumprect);
sj->dumprect = NULL;
-
+
*do_update = true;
-
+
rd.cfra++;
}
- else
+ else
PIL_sleep_ms(U.scrcastwait);
}
-
+
if (mh) {
mh->end_movie(sj->movie_ctx);
mh->context_free(sj->movie_ctx);
@@ -468,7 +468,7 @@ static void screencast_draw_cursor(bContext *UNUSED(C), int x, int y, void *UNUS
imm_draw_circle_wire_2d(pos, (float)x, (float)y, 20, 40);
immUnbindProgram();
-
+
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
}
@@ -477,7 +477,7 @@ static void screencast_draw_cursor(bContext *UNUSED(C), int x, int y, void *UNUS
static void screencast_cursor_toggle(wmWindowManager *wm, short enable)
{
static void *cursor = NULL;
-
+
if (cursor && !enable) {
/* clear cursor */
WM_paint_cursor_end(wm, cursor);
@@ -492,7 +492,7 @@ static void screencast_cursor_toggle(wmWindowManager *wm, short enable)
static void screenshot_endjob(void *sjv)
{
ScreenshotJob *sj = sjv;
-
+
screencast_cursor_toggle(sj->wm, 0);
}
@@ -508,10 +508,10 @@ static int screencast_exec(bContext *C, wmOperator *op)
/* if called again, stop the running job */
if (WM_jobs_test(wm, screen, WM_JOB_TYPE_SCREENCAST))
WM_jobs_stop(wm, screen, screenshot_startjob);
-
+
wm_job = WM_jobs_get(wm, win, screen, "Screencast", 0, WM_JOB_TYPE_SCREENCAST);
sj = MEM_callocN(sizeof(ScreenshotJob), "screenshot job");
-
+
/* setup sj */
if (RNA_boolean_get(op->ptr, "full")) {
sj->x = 0;
@@ -529,20 +529,20 @@ static int screencast_exec(bContext *C, wmOperator *op)
sj->bmain = CTX_data_main(C);
sj->scene = CTX_data_scene(C);
sj->wm = wm;
-
+
BKE_reports_init(&sj->reports, RPT_PRINT);
/* setup job */
WM_jobs_customdata_set(wm_job, sj, screenshot_freejob);
WM_jobs_timer(wm_job, 0.1, 0, NC_SCREEN | ND_SCREENCAST);
WM_jobs_callbacks(wm_job, screenshot_startjob, NULL, screenshot_updatejob, screenshot_endjob);
-
+
WM_jobs_start(sj->wm, wm_job);
-
+
screencast_cursor_toggle(sj->wm, 1);
-
+
WM_event_add_notifier(C, NC_SCREEN | ND_SCREENCAST, screen);
-
+
return OPERATOR_FINISHED;
}
@@ -551,13 +551,13 @@ void SCREEN_OT_screencast(wmOperatorType *ot)
ot->name = "Make Screencast";
ot->idname = "SCREEN_OT_screencast";
ot->description = "Capture a video of the active area or whole Blender window";
-
+
ot->invoke = WM_operator_confirm;
ot->exec = screencast_exec;
ot->poll = screenshot_poll; /* shared poll */
-
+
ot->flag = 0;
-
+
RNA_def_property(ot->srna, "filepath", PROP_STRING, PROP_FILEPATH);
RNA_def_boolean(ot->srna, "full", 1, "Full Screen",
"Capture the whole window (otherwise only capture the active area)");
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index d54996bad59..a044a7d377a 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -131,7 +131,7 @@ static bool workspace_change_find_new_layout_cb(const WorkSpaceLayout *layout, v
}
static WorkSpaceLayout *workspace_change_get_new_layout(
- WorkSpace *workspace_new, wmWindow *win)
+ Main *bmain, WorkSpace *workspace_new, wmWindow *win)
{
/* ED_workspace_duplicate may have stored a layout to activate once the workspace gets activated. */
WorkSpaceLayout *layout_new;
@@ -155,7 +155,7 @@ static WorkSpaceLayout *workspace_change_get_new_layout(
NULL, false);
if (!layout_temp) {
/* fallback solution: duplicate layout */
- layout_temp = ED_workspace_layout_duplicate(workspace_new, layout_new, win);
+ layout_temp = ED_workspace_layout_duplicate(bmain, workspace_new, layout_new, win);
}
layout_new = layout_temp;
}
@@ -177,7 +177,7 @@ bool ED_workspace_change(
{
Main *bmain = CTX_data_main(C);
WorkSpace *workspace_old = WM_window_get_active_workspace(win);
- WorkSpaceLayout *layout_new = workspace_change_get_new_layout(workspace_new, win);
+ WorkSpaceLayout *layout_new = workspace_change_get_new_layout(bmain, workspace_new, win);
bScreen *screen_new = BKE_workspace_layout_screen_get(layout_new);
bScreen *screen_old = BKE_workspace_active_screen_get(win->workspace_hook);
@@ -228,7 +228,7 @@ WorkSpace *ED_workspace_duplicate(
/* TODO(campbell): tools */
for (WorkSpaceLayout *layout_old = layouts_old->first; layout_old; layout_old = layout_old->next) {
- WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(workspace_new, layout_old, win);
+ WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(bmain, workspace_new, layout_old, win);
if (layout_active_old == layout_old) {
win->workspace_hook->temp_layout_store = layout_new;
diff --git a/source/blender/editors/screen/workspace_layout_edit.c b/source/blender/editors/screen/workspace_layout_edit.c
index 6285f031836..0c7431cb2e7 100644
--- a/source/blender/editors/screen/workspace_layout_edit.c
+++ b/source/blender/editors/screen/workspace_layout_edit.c
@@ -46,6 +46,7 @@
* Empty screen, with 1 dummy area without spacedata. Uses window size.
*/
WorkSpaceLayout *ED_workspace_layout_add(
+ Main *bmain,
WorkSpace *workspace,
wmWindow *win,
const char *name)
@@ -54,12 +55,13 @@ WorkSpaceLayout *ED_workspace_layout_add(
rcti screen_rect;
WM_window_screen_rect_calc(win, &screen_rect);
- screen = screen_add(name, &screen_rect);
+ screen = screen_add(bmain, name, &screen_rect);
return BKE_workspace_layout_add(workspace, screen, name);
}
WorkSpaceLayout *ED_workspace_layout_duplicate(
+ Main *bmain,
WorkSpace *workspace, const WorkSpaceLayout *layout_old,
wmWindow *win)
{
@@ -72,7 +74,7 @@ WorkSpaceLayout *ED_workspace_layout_duplicate(
return NULL; /* XXX handle this case! */
}
- layout_new = ED_workspace_layout_add(workspace, win, name);
+ layout_new = ED_workspace_layout_add(bmain, workspace, win, name);
screen_new = BKE_workspace_layout_screen_get(layout_new);
screen_data_copy(screen_new, screen_old);
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 8d941078c5f..848d12bcfaa 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -262,7 +262,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
target = (primary) ? &primary_snap : &secondary_snap;
- refresh =
+ refresh =
!target->overlay_texture ||
(invalid != 0) ||
!same_tex_snap(target, mtex, vc, col, zoom);
@@ -1001,7 +1001,7 @@ static void paint_cursor_on_hit(UnifiedPaintSettings *ups, Brush *brush, ViewCon
else
projected_radius = BKE_brush_size_get(vc->scene, brush);
}
-
+
/* convert brush radius from 2D to 3D */
unprojected_radius = paint_calc_object_space_radius(vc, location,
projected_radius);
diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c
index 049d8ff8c0b..af0b828ae39 100644
--- a/source/blender/editors/sculpt_paint/paint_curve.c
+++ b/source/blender/editors/sculpt_paint/paint_curve.c
@@ -697,17 +697,17 @@ void PAINTCURVE_OT_draw(wmOperatorType *ot)
static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
-
+
switch (mode) {
case ePaintTexture2D:
{
ARegion *ar = CTX_wm_region(C);
SpaceImage *sima = CTX_wm_space_image(C);
float location[2];
-
+
if (!sima)
return OPERATOR_CANCELLED;
-
+
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
copy_v2_v2(sima->cursor, location);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL);
@@ -717,7 +717,7 @@ static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const w
ED_view3d_cursor3d_update(C, event->mval);
break;
}
-
+
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index 4dd770d79b9..ac5b0624d56 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -48,6 +48,7 @@
#include "BKE_context.h"
#include "BKE_DerivedMesh.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_multires.h"
#include "BKE_paint.h"
#include "BKE_subsurf.h"
@@ -101,7 +102,7 @@ static void partialvis_update_mesh(Object *ob,
const int *vert_indices;
int totvert, i;
bool any_changed = false, any_visible = false;
-
+
BKE_pbvh_node_num_verts(pbvh, node, NULL, &totvert);
BKE_pbvh_node_get_verts(pbvh, node, &vert_indices, &mvert);
paint_mask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK);
@@ -153,7 +154,7 @@ static void partialvis_update_grids(Object *ob,
&grids);
grid_hidden = BKE_pbvh_grid_hidden(pbvh);
BKE_pbvh_get_grid_key(pbvh, &key);
-
+
sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN);
for (i = 0; i < totgrid; i++) {
@@ -323,7 +324,7 @@ static void clip_planes_from_rect(bContext *C,
{
ViewContext vc;
BoundBox bb;
-
+
view3d_operator_needs_opengl(C);
ED_view3d_viewcontext_init(C, &vc);
ED_view3d_clipping_calc(&bb, clip_planes, vc.ar, vc.obact, rect);
@@ -354,7 +355,7 @@ static void get_pbvh_nodes(PBVH *pbvh,
case PARTIALVIS_MASKED:
break;
}
-
+
BKE_pbvh_search_gather(pbvh, cb, clip_planes, nodes, totnode);
}
@@ -368,7 +369,6 @@ static int hide_show_exec(bContext *C, wmOperator *op)
PartialVisArea area;
PBVH *pbvh;
PBVHNode **nodes;
- DerivedMesh *dm;
PBVHType pbvh_type;
float clip_planes[4][4];
rcti rect;
@@ -381,9 +381,9 @@ static int hide_show_exec(bContext *C, wmOperator *op)
clip_planes_from_rect(C, clip_planes, &rect);
- dm = mesh_get_derived_final(depsgraph, CTX_data_scene(C), ob, CD_MASK_BAREMESH);
- pbvh = dm->getPBVH(ob, dm);
- ob->sculpt->pbvh = pbvh;
+ Mesh *me_eval_deform = mesh_get_eval_deform(depsgraph, CTX_data_scene(C), ob, CD_MASK_BAREMESH);
+ pbvh = BKE_sculpt_object_pbvh_ensure(ob, me_eval_deform);
+ BLI_assert(ob->sculpt->pbvh == pbvh);
get_pbvh_nodes(pbvh, &nodes, &totnode, clip_planes, area);
pbvh_type = BKE_pbvh_type(pbvh);
@@ -414,7 +414,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
if (nodes)
MEM_freeN(nodes);
-
+
/* end undo */
sculpt_undo_push_end();
@@ -425,7 +425,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
}
ED_region_tag_redraw(ar);
-
+
return OPERATOR_FINISHED;
}
@@ -454,7 +454,7 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot)
{PARTIALVIS_MASKED, "MASKED", 0, "Masked", "Hide or show vertices that are masked (minimum mask value of 0.5)"},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "Hide/Show";
ot->idname = "PAINT_OT_hide_show";
@@ -474,6 +474,6 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot)
"Action", "Whether to hide or show vertices");
RNA_def_enum(ot->srna, "area", area_items, PARTIALVIS_INSIDE,
"Area", "Which vertices to hide or show");
-
+
WM_operator_properties_border(ot);
}
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 9ecdc44cd10..93fa3aac0d7 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -169,7 +169,7 @@ void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short te
IMB_partial_display_buffer_update_delayed(ibuf, imapaintpartial.x1, imapaintpartial.y1,
imapaintpartial.x2, imapaintpartial.y2);
}
-
+
if (ibuf->mipmap[0])
ibuf->userflags |= IB_MIPMAP_INVALID;
@@ -195,7 +195,7 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj)
if (proj) {
radius = 0.5f;
-
+
side = kernel->side = 2;
kernel->side_squared = kernel->side * kernel->side;
kernel->wdata = MEM_mallocN(sizeof(float) * kernel->side_squared, "blur kernel data");
@@ -204,15 +204,15 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj)
else {
if (br->blur_kernel_radius <= 0)
br->blur_kernel_radius = 1;
-
+
radius = br->blur_kernel_radius;
-
+
side = kernel->side = radius * 2 + 1;
kernel->side_squared = kernel->side * kernel->side;
kernel->wdata = MEM_mallocN(sizeof(float) * kernel->side_squared, "blur kernel data");
kernel->pixel_len = br->blur_kernel_radius;
}
-
+
switch (type) {
case KERNEL_BOX:
for (i = 0; i < kernel->side_squared; i++)
@@ -221,9 +221,9 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj)
case KERNEL_GAUSSIAN:
{
- /* at 3.0 standard deviations distance, kernel is about zero */
- float standard_dev = radius / 3.0f;
-
+ /* at 3.0 standard deviations distance, kernel is about zero */
+ float standard_dev = radius / 3.0f;
+
/* make the necessary adjustment to the value for use in the normal distribution formula */
standard_dev = -standard_dev * standard_dev * 2;
@@ -232,7 +232,7 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj)
float idist = radius - i;
float jdist = radius - j;
float value = exp((idist * idist + jdist * jdist) / standard_dev);
-
+
kernel->wdata[i + j * side] = value;
}
}
@@ -312,7 +312,7 @@ static int image_paint_2d_clone_poll(bContext *C)
if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE))
if (brush->clone.image)
return 1;
-
+
return 0;
}
@@ -465,7 +465,7 @@ static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, const flo
BKE_paint_data_warning(op->reports, uvs, mat, tex, stencil);
MEM_freeN(pop);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
- return NULL;
+ return NULL;
}
pop->mode = PAINT_MODE_3D_PROJECT;
pop->custom_paint = paint_proj_new_stroke(C, ob, mouse, mode);
@@ -483,7 +483,7 @@ static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, const flo
if ((brush->imagepaint_tool == PAINT_TOOL_FILL) && (brush->flag & BRUSH_USE_GRADIENT)) {
pop->cursor = WM_paint_cursor_activate(CTX_wm_manager(C), image_paint_poll, gradient_draw_line, pop);
}
-
+
settings->imapaint.flag |= IMAGEPAINT_DRAWING;
ED_image_undo_push_begin(op->type->name);
@@ -739,7 +739,7 @@ static void toggle_paint_cursor(bContext *C, int enable)
* purpose is to make sure the paint cursor is shown if paint
* mode is enabled in the image editor. the paint poll will
* ensure that the cursor is hidden when not in paint mode */
-void ED_space_image_paint_update(wmWindowManager *wm, Scene *scene)
+void ED_space_image_paint_update(Main *bmain, wmWindowManager *wm, Scene *scene)
{
ToolSettings *settings = scene->toolsettings;
ImagePaintSettings *imapaint = &settings->imapaint;
@@ -758,7 +758,7 @@ void ED_space_image_paint_update(wmWindowManager *wm, Scene *scene)
}
if (enabled) {
- BKE_paint_init(scene, ePaintTexture2D, PAINT_CURSOR_TEXTURE_PAINT);
+ BKE_paint_init(bmain, scene, ePaintTexture2D, PAINT_CURSOR_TEXTURE_PAINT);
paint_cursor_start_explicit(&imapaint->paint, wm, image_paint_poll);
}
@@ -850,7 +850,7 @@ void PAINT_OT_grab_clone(wmOperatorType *ot)
ot->name = "Grab Clone";
ot->idname = "PAINT_OT_grab_clone";
ot->description = "Move the clone source image";
-
+
/* api callbacks */
ot->exec = grab_clone_exec;
ot->invoke = grab_clone_invoke;
@@ -915,7 +915,7 @@ static int sample_color_exec(bContext *C, wmOperator *op)
}
WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
-
+
return OPERATOR_FINISHED;
}
@@ -1017,7 +1017,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot)
ot->name = "Sample Color";
ot->idname = "PAINT_OT_sample_color";
ot->description = "Use the mouse to sample a color in the image";
-
+
/* api callbacks */
ot->exec = sample_color_exec;
ot->invoke = sample_color_invoke;
@@ -1086,7 +1086,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
BKE_texpaint_slots_refresh_object(scene, ob);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
-
+
/* entering paint mode also sets image to editors */
if (imapaint->mode == IMAGEPAINT_MODE_MATERIAL) {
Material *ma = give_current_material(ob, ob->actcol); /* set the current material active paint slot on image editor */
@@ -1096,8 +1096,8 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
}
else if (imapaint->mode == IMAGEPAINT_MODE_IMAGE) {
ima = imapaint->canvas;
- }
-
+ }
+
if (ima) {
for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
@@ -1106,20 +1106,20 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
-
+
if (!sima->pin) {
Object *obedit = CTX_data_edit_object(C);
- ED_space_image_set(sima, scene, obedit, ima);
+ ED_space_image_set(bmain, sima, scene, obedit, ima);
}
}
}
}
}
}
-
+
ob->mode |= mode_flag;
- BKE_paint_init(scene, ePaintTextureProjective, PAINT_CURSOR_TEXTURE_PAINT);
+ BKE_paint_init(bmain, scene, ePaintTextureProjective, PAINT_CURSOR_TEXTURE_PAINT);
if (U.glreslimit != 0)
GPU_free_images();
@@ -1143,7 +1143,7 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot)
ot->name = "Texture Paint Toggle";
ot->idname = "PAINT_OT_texture_paint_toggle";
ot->description = "Toggle texture paint mode in 3D view";
-
+
/* api callbacks */
ot->exec = texture_paint_toggle_exec;
ot->poll = texture_paint_toggle_poll;
@@ -1163,7 +1163,7 @@ static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op))
br = image_paint_brush(C);
}
else {
- /* At the moment, wpaint does not support the color flipper.
+ /* At the moment, wpaint does not support the color flipper.
* So for now we're only handling vpaint */
ToolSettings *ts = CTX_data_tool_settings(C);
VPaint *vp = ts->vpaint;
@@ -1236,7 +1236,7 @@ static int texture_paint_poll(bContext *C)
if (texture_paint_toggle_poll(C))
if (CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT)
return 1;
-
+
return 0;
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index c2ce9d83782..a75d6344849 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -582,7 +582,7 @@ static void brush_painter_imbuf_partial_update(BrushPainter *painter, const floa
destx = desty = 0;
w = h = 0;
}
-
+
x1 = min_ii(destx, ibuf->x);
y1 = min_ii(desty, ibuf->y);
x2 = min_ii(destx + w, ibuf->x);
@@ -1132,13 +1132,13 @@ static int paint_2d_op(void *state, ImBuf *ibufb, unsigned short *curveb, unsign
paint_2d_set_region(region, bpos[0], bpos[1], 0, 0, frombuf->x, frombuf->y);
tot = 1;
}
-
+
/* blend into canvas */
for (a = 0; a < tot; a++) {
ED_imapaint_dirty_region(s->image, s->canvas,
region[a].destx, region[a].desty,
region[a].width, region[a].height, true);
-
+
if (s->do_masking) {
/* masking, find original pixels tiles from undo buffer to composite over */
int tilex, tiley, tilew, tileh;
@@ -1232,7 +1232,7 @@ static int paint_2d_canvas_set(ImagePaintState *s, Image *ima)
/* set masking */
s->do_masking = paint_use_opacity_masking(s->brush);
-
+
return 1;
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 76449b61d4d..f6cf0f56764 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -74,6 +74,7 @@
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_node.h"
#include "BKE_paint.h"
#include "BKE_report.h"
@@ -85,6 +86,7 @@
#include "UI_interface.h"
+#include "ED_object.h"
#include "ED_mesh.h"
#include "ED_node.h"
#include "ED_paint.h"
@@ -1055,7 +1057,7 @@ static bool check_seam(
/* set up the other face */
*other_face = tri_index;
-
+
/* we check if difference is 1 here, else we might have a case of edge 2-0 for a tri */
*orig_fidx = (i1_fidx < i2_fidx && (i2_fidx - i1_fidx == 1)) ? i1_fidx : i2_fidx;
@@ -2117,7 +2119,7 @@ static void project_bucket_clip_face(
int inside_face_flag = 0;
int flip;
bool collinear = false;
-
+
float bucket_bounds_ss[4][2];
/* detect pathological case where face the three vertices are almost collinear in screen space.
@@ -2128,12 +2130,12 @@ static void project_bucket_clip_face(
{
collinear = true;
}
-
+
/* get the UV space bounding box */
inside_bucket_flag |= BLI_rctf_isect_pt_v(bucket_bounds, v1coSS);
inside_bucket_flag |= BLI_rctf_isect_pt_v(bucket_bounds, v2coSS) << 1;
inside_bucket_flag |= BLI_rctf_isect_pt_v(bucket_bounds, v3coSS) << 2;
-
+
if (inside_bucket_flag == ISECT_ALL3) {
/* is_flip_object is used here because we use the face winding */
flip = (((line_point_side_v2(v1coSS, v2coSS, v3coSS) > 0.0f) != is_flip_object) !=
@@ -2150,20 +2152,20 @@ static void project_bucket_clip_face(
copy_v2_v2(bucket_bounds_uv[0], uv1co);
copy_v2_v2(bucket_bounds_uv[1], uv2co);
copy_v2_v2(bucket_bounds_uv[2], uv3co);
- }
-
+ }
+
*tot = 3;
return;
}
/* handle pathological case here, no need for further intersections below since tringle area is almost zero */
if (collinear) {
int flag;
-
+
(*tot) = 0;
if (cull)
return;
-
+
if (inside_bucket_flag & ISECT_1) { copy_v2_v2(bucket_bounds_uv[*tot], uv1co); (*tot)++; }
flag = inside_bucket_flag & (ISECT_1 | ISECT_2);
@@ -2171,9 +2173,9 @@ static void project_bucket_clip_face(
if (line_rect_clip(bucket_bounds, v1coSS, v2coSS, uv1co, uv2co, bucket_bounds_uv[*tot], is_ortho))
(*tot)++;
}
-
+
if (inside_bucket_flag & ISECT_2) { copy_v2_v2(bucket_bounds_uv[*tot], uv2co); (*tot)++; }
-
+
flag = inside_bucket_flag & (ISECT_2 | ISECT_3);
if (flag && flag != (ISECT_2 | ISECT_3)) {
if (line_rect_clip(bucket_bounds, v2coSS, v3coSS, uv2co, uv3co, bucket_bounds_uv[*tot], is_ortho))
@@ -2187,7 +2189,7 @@ static void project_bucket_clip_face(
if (line_rect_clip(bucket_bounds, v3coSS, v1coSS, uv3co, uv1co, bucket_bounds_uv[*tot], is_ortho))
(*tot)++;
}
-
+
if ((*tot) < 3) {
/* no intersections to speak of, but more probable is that all face is just outside the
* rectangle and culled due to float precision issues. Since above tests have failed,
@@ -2352,7 +2354,7 @@ static void project_bucket_clip_face(
(*tot)--;
}
}
-
+
/* its possible there is only a few left after remove doubles */
if ((*tot) < 3) {
// printf("removed too many doubles B\n");
@@ -2976,7 +2978,7 @@ static bool project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int buck
int fidx;
project_bucket_bounds(ps, bucket_x, bucket_y, &bucket_bounds);
-
+
/* Is one of the faces verts in the bucket bounds? */
fidx = 2;
@@ -3487,7 +3489,7 @@ static void proj_paint_layer_clone_init(
/* get active instead */
mloopuv_clone_base = CustomData_get_layer(&ps->dm->loopData, CD_MLOOPUV);
}
-
+
}
memset(layer_clone, 0, sizeof(*layer_clone));
@@ -3513,7 +3515,7 @@ static bool project_paint_clone_face_skip(
if (ps->do_material_slots) {
if (lc->slot_clone != lc->slot_last_clone) {
- if (!slot->uvname ||
+ if (!slot->uvname ||
!(lc->mloopuv_clone_base = CustomData_get_layer_named(
&ps->dm->loopData, CD_MLOOPUV,
lc->slot_clone->uvname)))
@@ -3707,7 +3709,7 @@ static void project_paint_prepare_all_faces(
ps->dm_mloopuv[lt->poly] = mloopuv_base;
continue;
}
-
+
tpage = slot->ima;
}
}
@@ -4399,7 +4401,7 @@ static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, con
if (ps->is_texbrush)
mul_v3_v3(rgba, texrgb);
-
+
mul_v3_fl(rgba, mask);
rgba[3] = mask;
@@ -4608,7 +4610,7 @@ static void *do_projectpaint_thread(void *ph_v)
projPixel->newColor.ch, ps->blend);
}
}
-
+
if (lock_alpha) {
if (is_floatbuf) {
/* slightly more involved case since floats are in premultiplied space we need
@@ -4686,7 +4688,7 @@ static void *do_projectpaint_thread(void *ph_v)
/* masking to keep brush contribution to a pixel limited. note we do not do
* a simple max(mask, mask_accum), as this is very sensitive to spacing and
* gives poor results for strokes crossing themselves.
- *
+ *
* Instead we use a formula that adds up but approaches brush_alpha slowly
* and never exceeds it, which gives nice smooth results. */
float mask_accum = *projPixel->mask_accum;
@@ -4919,14 +4921,14 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po
touch_any = 1;
}
}
-
+
/* calculate pivot for rotation around seletion if needed */
if (U.uiflag & USER_ORBIT_SELECTION) {
float w[3];
int tri_index;
-
+
tri_index = project_paint_PickFace(ps, pos, w);
-
+
if (tri_index != -1) {
const MLoopTri *lt = &ps->dm_mlooptri[tri_index];
const int lt_vtri[3] = { PS_LOOPTRI_AS_VERT_INDEX_3(ps, lt) };
@@ -4939,14 +4941,14 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po
ps->dm_mvert[lt_vtri[1]].co,
ps->dm_mvert[lt_vtri[2]].co,
w);
-
+
ups->average_stroke_counter++;
mul_m4_v3(ps->obmat, world);
add_v3_v3(ups->average_stroke_accum, world);
ups->last_stroke_valid = true;
}
}
-
+
return touch_any;
}
@@ -5013,7 +5015,7 @@ void paint_proj_stroke(
/* clone gets special treatment here to avoid going through image initialization */
if (ps_handle->is_clone_cursor_pick) {
Scene *scene = ps_handle->scene;
- struct Depsgraph *graph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
float *cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
@@ -5021,7 +5023,7 @@ void paint_proj_stroke(
view3d_operator_needs_opengl(C);
- if (!ED_view3d_autodist(graph, ar, v3d, mval_i, cursor, false, NULL)) {
+ if (!ED_view3d_autodist(depsgraph, ar, v3d, mval_i, cursor, false, NULL)) {
return;
}
@@ -5085,9 +5087,9 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
ps->do_material_slots = (settings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL);
ps->stencil_ima = settings->imapaint.stencil;
- ps->canvas_ima = (!ps->do_material_slots) ?
+ ps->canvas_ima = (!ps->do_material_slots) ?
settings->imapaint.canvas : NULL;
- ps->clone_ima = (!ps->do_material_slots) ?
+ ps->clone_ima = (!ps->do_material_slots) ?
settings->imapaint.clone : NULL;
ps->do_mask_cavity = (settings->imapaint.paint.flags & PAINT_USE_CAVITY_MASK) ? true : false;
@@ -5319,7 +5321,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
if (!BKE_paint_proj_mesh_data_check(scene, ob, &uvs, &mat, &tex, NULL)) {
BKE_paint_data_warning(op->reports, uvs, mat, tex, true);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
- return OPERATOR_CANCELLED;
+ return OPERATOR_CANCELLED;
}
project_state_init(C, ob, &ps, BRUSH_STROKE_NORMAL);
@@ -5435,6 +5437,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
ImBuf *ibuf;
char filename[FILE_MAX];
+ Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *settings = scene->toolsettings;
@@ -5464,7 +5467,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- image = BKE_image_add_from_imbuf(ibuf, "image_view");
+ image = BKE_image_add_from_imbuf(bmain, ibuf, "image_view");
/* Drop reference to ibuf so that the image owns it */
IMB_freeImBuf(ibuf);
@@ -5519,7 +5522,7 @@ void PAINT_OT_image_from_view(wmOperatorType *ot)
void BKE_paint_data_warning(struct ReportList *reports, bool uvs, bool mat, bool tex, bool stencil)
{
- BKE_reportf(reports, RPT_WARNING, "Missing%s%s%s%s detected!",
+ BKE_reportf(reports, RPT_WARNING, "Missing%s%s%s%s detected!",
!uvs ? " UVs," : "",
!mat ? " Materials," : "",
!tex ? " Textures," : "",
@@ -5540,7 +5543,7 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m
bool hasuvs = true;
imapaint->missing_data = 0;
-
+
BLI_assert(ob->type == OB_MESH);
if (imapaint->mode == IMAGEPAINT_MODE_MATERIAL) {
@@ -5554,16 +5557,16 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m
int i;
hasmat = false;
hastex = false;
-
+
for (i = 1; i < ob->totcol + 1; i++) {
Material *ma = give_current_material(ob, i);
-
+
if (ma) {
hasmat = true;
if (!ma->texpaintslot) {
/* refresh here just in case */
BKE_texpaint_slot_refresh_cache(scene, ma);
-
+
/* if still no slots, we have to add */
if (ma->texpaintslot) {
hastex = true;
@@ -5583,7 +5586,7 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m
hastex = false;
}
}
-
+
me = BKE_mesh_from_object(ob);
layernum = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
@@ -5604,7 +5607,7 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m
if (!hasmat) imapaint->missing_data |= IMAGEPAINT_MISSING_MATERIAL;
if (!hastex) imapaint->missing_data |= IMAGEPAINT_MISSING_TEX;
if (!hasstencil) imapaint->missing_data |= IMAGEPAINT_MISSING_STENCIL;
-
+
if (uvs) {
*uvs = hasuvs;
}
@@ -5617,7 +5620,7 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m
if (stencil) {
*stencil = hasstencil;
}
-
+
return hasuvs && hasmat && hastex && hasstencil;
}
@@ -5654,13 +5657,13 @@ static Image *proj_paint_image_create(wmOperator *op, Main *bmain)
}
ima = BKE_image_add_generated(bmain, width, height, imagename, alpha ? 32 : 24, use_float,
gen_type, color, false);
-
+
return ima;
}
static bool proj_paint_add_slot(bContext *C, wmOperator *op)
{
- Object *ob = CTX_data_active_object(C);
+ Object *ob = ED_object_active_context(C);
Scene *scene = CTX_data_scene(C);
Material *ma;
Image *ima = NULL;
@@ -5681,32 +5684,32 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op)
ED_node_shader_default(C, &ma->id);
ntree = ma->nodetree;
}
-
+
ma->use_nodes = true;
-
+
/* try to add an image node */
imanode = nodeAddStaticNode(C, ntree, SH_NODE_TEX_IMAGE);
-
+
ima = proj_paint_image_create(op, bmain);
imanode->id = &ima->id;
-
+
nodeSetActive(ntree, imanode);
-
+
ntreeUpdateTree(CTX_data_main(C), ntree);
-
+
if (ima) {
BKE_texpaint_slot_refresh_cache(scene, ma);
- BKE_image_signal(ima, NULL, IMA_SIGNAL_USER_NEW_IMAGE);
+ BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_USER_NEW_IMAGE);
WM_event_add_notifier(C, NC_IMAGE | NA_ADDED, ima);
DEG_id_tag_update(&ma->id, 0);
ED_area_tag_redraw(CTX_wm_area(C));
-
+
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
-
+
return true;
}
}
-
+
return false;
}
@@ -5724,16 +5727,17 @@ static int texture_paint_add_texture_paint_slot_exec(bContext *C, wmOperator *op
static int texture_paint_add_texture_paint_slot_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
char imagename[MAX_ID_NAME - 2];
- Object *ob = CTX_data_active_object(C);
+ Main *bmain = CTX_data_main(C);
+ Object *ob = ED_object_active_context(C);
Material *ma = give_current_material(ob, ob->actcol);
int type = RNA_enum_get(op->ptr, "type");
if (!ma) {
- ma = BKE_material_add(CTX_data_main(C), "Material");
+ ma = BKE_material_add(bmain, "Material");
/* no material found, just assign to first slot */
- assign_material(ob, ma, ob->actcol, BKE_MAT_ASSIGN_USERPREF);
+ assign_material(bmain, ob, ma, ob->actcol, BKE_MAT_ASSIGN_USERPREF);
}
-
+
type = RNA_enum_from_value(layer_type_items, type);
/* get the name of the texture layer type */
@@ -5818,7 +5822,7 @@ static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op))
scene->toolsettings->uv_flag |= UV_SYNC_SELECTION;
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
-
+
DEG_id_tag_update(ob->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, scene);
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index a6d8a90e95a..8d94978f5c6 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 3afff02ec52..3a8ab12b96d 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -47,6 +47,7 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "WM_toolsystem.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -87,10 +88,10 @@ static void BRUSH_OT_add(wmOperatorType *ot)
ot->name = "Add Brush";
ot->description = "Add brush by mode type";
ot->idname = "BRUSH_OT_add";
-
+
/* api callbacks */
ot->exec = brush_add_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -144,10 +145,10 @@ static void BRUSH_OT_scale_size(wmOperatorType *ot)
ot->name = "Scale Sculpt/Paint Brush Size";
ot->description = "Change brush size by a scalar";
ot->idname = "BRUSH_OT_scale_size";
-
+
/* api callbacks */
ot->exec = brush_scale_size_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -285,10 +286,10 @@ static void BRUSH_OT_reset(wmOperatorType *ot)
ot->name = "Reset Brush";
ot->description = "Return brush to defaults based on current tool";
ot->idname = "BRUSH_OT_reset";
-
+
/* api callbacks */
ot->exec = brush_reset_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -353,7 +354,7 @@ static Brush *brush_tool_toggle(Main *bmain, Brush *brush_orig, const int tool,
/* store the previously-selected brush */
if (br)
br->toggle_brush = brush_orig;
-
+
return br;
}
else if (brush_orig->toggle_brush) {
@@ -452,9 +453,23 @@ static int brush_select_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- return brush_generic_tool_set(bmain, paint, tool, tool_offset,
- paint_mode, tool_name, create_missing,
- toggle);
+ /* TODO(campbell): Use the toolsystem for now, ideally the toolsystem will display brushes directly
+ * so we don't need to sync between tools and brushes. */
+ if (false) {
+ return brush_generic_tool_set(
+ bmain, paint, tool, tool_offset,
+ paint_mode, tool_name, create_missing,
+ toggle);
+ }
+ else {
+ WorkSpace *workspace = CTX_wm_workspace(C);
+ if (WM_toolsystem_ref_set_by_name(C, workspace, NULL, tool_name, true)) {
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+ }
}
static void PAINT_OT_brush_select(wmOperatorType *ot)
@@ -493,16 +508,17 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
-static wmKeyMapItem *keymap_brush_select(wmKeyMap *keymap, int paint_mode,
- int tool, int keymap_type,
- int keymap_modifier)
+static wmKeyMapItem *keymap_brush_select(
+ wmKeyMap *keymap, int paint_mode,
+ int tool, int keymap_type,
+ int keymap_modifier)
{
wmKeyMapItem *kmi;
kmi = WM_keymap_add_item(keymap, "PAINT_OT_brush_select",
keymap_type, KM_PRESS, keymap_modifier, 0);
RNA_enum_set(kmi->ptr, "paint_mode", paint_mode);
-
+
switch (paint_mode) {
case OB_MODE_SCULPT:
RNA_enum_set(kmi->ptr, "sculpt_tool", tool);
@@ -914,7 +930,7 @@ static int stencil_reset_transform_exec(bContext *C, wmOperator *op)
if (!br)
return OPERATOR_CANCELLED;
-
+
if (do_mask) {
br->mask_stencil_pos[0] = 256;
br->mask_stencil_pos[1] = 256;
@@ -1080,20 +1096,6 @@ void ED_operatortypes_paint(void)
WM_operatortype_append(PAINT_OT_mask_lasso_gesture);
}
-
-static void ed_keymap_paint_brush_switch(wmKeyMap *keymap, const char *mode)
-{
- wmKeyMapItem *kmi;
- int i;
- /* index 0-9 (zero key is tenth), shift key for index 10-19 */
- for (i = 0; i < 20; i++) {
- kmi = WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set",
- ZEROKEY + ((i + 1) % 10), KM_PRESS, i < 10 ? 0 : KM_SHIFT, 0);
- RNA_string_set(kmi->ptr, "mode", mode);
- RNA_int_set(kmi->ptr, "index", i);
- }
-}
-
static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path))
{
wmKeyMapItem *kmi;
@@ -1199,7 +1201,7 @@ static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *p
static void paint_partial_visibility_keys(wmKeyMap *keymap)
{
wmKeyMapItem *kmi;
-
+
/* Partial visibility */
kmi = WM_keymap_add_item(keymap, "PAINT_OT_hide_show", HKEY, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "action", PARTIALVIS_SHOW);
@@ -1245,7 +1247,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
wmKeyMap *keymap;
wmKeyMapItem *kmi;
int i;
-
+
keymap = WM_keymap_find(keyconf, "Paint Curve", 0, 0);
keymap->poll = paint_curve_poll;
@@ -1284,7 +1286,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "SCULPT_OT_dynamic_topology_toggle", DKEY, KM_PRESS, KM_CTRL, 0);
/* Dynamic-topology detail size
- *
+ *
* This should be improved further, perhaps by showing a triangle
* grid rather than brush alpha */
kmi = WM_keymap_add_item(keymap, "SCULPT_OT_set_detail_size", DKEY, KM_PRESS, KM_SHIFT, 0);
@@ -1298,7 +1300,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
RNA_int_set(kmi->ptr, "level", -1);
RNA_boolean_set(kmi->ptr, "relative", true);
- ed_keymap_paint_brush_switch(keymap, "sculpt");
ed_keymap_paint_brush_size(keymap, "tool_settings.sculpt.brush.size");
ed_keymap_paint_brush_radial_control(keymap, "sculpt", RC_ROTATION);
@@ -1338,7 +1339,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap,
"PAINT_OT_vertex_color_set", KKEY, KM_PRESS, KM_SHIFT, 0);
- ed_keymap_paint_brush_switch(keymap, "vertex_paint");
ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_paint.brush.size");
ed_keymap_paint_brush_radial_control(keymap, "vertex_paint", RC_COLOR | RC_COLOR_OVERRIDE | RC_ROTATION);
@@ -1371,7 +1371,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap,
"PAINT_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0);
- ed_keymap_paint_brush_switch(keymap, "weight_paint");
ed_keymap_paint_brush_size(keymap, "tool_settings.weight_paint.brush.size");
ed_keymap_paint_brush_radial_control(keymap, "weight_paint", RC_WEIGHT);
@@ -1412,7 +1411,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "PAINT_OT_grab_clone", RIGHTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "PAINT_OT_sample_color", SKEY, KM_PRESS, 0, 0);
- ed_keymap_paint_brush_switch(keymap, "image_paint");
ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size");
ed_keymap_paint_brush_radial_control(
keymap, "image_paint",
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 3ded6326c67..b63f9461401 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -126,7 +126,7 @@ typedef struct PaintStroke {
float zoom_2d;
int pen_flip;
-
+
/* line constraint */
bool constrain_line;
float constrained_pos[2];
@@ -735,10 +735,10 @@ PaintStroke *paint_stroke_new(bContext *C,
/* initialize here */
ups->overlap_factor = 1.0;
ups->stroke_active = true;
-
+
zero_v3(ups->average_stroke_accum);
ups->average_stroke_counter = 0;
-
+
/* initialize here to avoid initialization conflict with threaded strokes */
curvemapping_initialize(br->curve);
if (p->flags & PAINT_USE_CAVITY_MASK)
@@ -928,11 +928,11 @@ static void paint_stroke_sample_average(const PaintStroke *stroke,
PaintSample *average)
{
int i;
-
+
memset(average, 0, sizeof(*average));
BLI_assert(stroke->num_samples > 0);
-
+
for (i = 0; i < stroke->num_samples; i++) {
add_v2_v2(average->mouse, stroke->samples[i].mouse);
average->pressure += stroke->samples[i].pressure;
@@ -1096,17 +1096,17 @@ static void paint_stroke_line_constrain(PaintStroke *stroke, float mouse[2])
if (stroke->constrain_line) {
float line[2];
float angle, len, res;
-
+
sub_v2_v2v2(line, mouse, stroke->last_mouse_position);
angle = atan2f(line[1], line[0]);
len = len_v2(line);
-
+
/* divide angle by PI/4 */
angle = 4.0f * angle / (float)M_PI;
-
+
/* now take residue */
res = angle - floorf(angle);
-
+
/* residue decides how close we are at a certain angle */
if (res <= 0.5f) {
angle = floorf(angle) * (float)M_PI_4;
@@ -1114,7 +1114,7 @@ static void paint_stroke_line_constrain(PaintStroke *stroke, float mouse[2])
else {
angle = (floorf(angle) + 1.0f) * (float)M_PI_4;
}
-
+
mouse[0] = stroke->constrained_pos[0] = len * cosf(angle) + stroke->last_mouse_position[0];
mouse[1] = stroke->constrained_pos[1] = len * sinf(angle) + stroke->last_mouse_position[1];
}
@@ -1209,12 +1209,12 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
else if (br->flag & BRUSH_LINE) {
if (event->alt)
stroke->constrain_line = true;
- else
+ else
stroke->constrain_line = false;
copy_v2_fl2(mouse, event->mval[0], event->mval[1]);
paint_stroke_line_constrain(stroke, mouse);
-
+
if (stroke->stroke_started && (first_modal || (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)))) {
if ((br->mtex.brush_angle_mode & MTEX_ANGLE_RAKE) || (br->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) {
copy_v2_v2(stroke->ups->last_rake, stroke->last_mouse_position);
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index b2f3c49cb00..80c4d4099a2 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -221,10 +221,10 @@ void paint_stroke_operator_properties(wmOperatorType *ot)
prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
- RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL,
+ RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL,
"Stroke Mode",
"Action taken when a paint stroke is made");
-
+
}
/* 3D Paint */
@@ -436,7 +436,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
CLAMP(x, 0, ar->winx);
CLAMP(y, 0, ar->winy);
-
+
if (use_palette) {
if (!palette) {
palette = BKE_palette_add(CTX_data_main(C), "Palette");
@@ -459,7 +459,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
if (ob) {
Mesh *me = (Mesh *)ob->data;
- Mesh *me_eval = BKE_object_get_evaluated_mesh(depsgraph, ob); /* Or shall we just do ob_eval->mesh_evaluated ? */
+ Mesh *me_eval = BKE_object_get_evaluated_mesh(depsgraph, ob); /* Or shall we just do ob_eval->mesh_eval ? */
ViewContext vc;
const int mval[2] = {x, y};
@@ -473,12 +473,12 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
if (imapaint_pick_face(&vc, mval, &faceindex, totpoly)) {
Image *image;
-
- if (use_material)
+
+ if (use_material)
image = imapaint_face_image(ob_eval, me_eval, faceindex);
else
image = imapaint->canvas;
-
+
if (image) {
ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL);
if (ibuf && ibuf->rect) {
@@ -486,16 +486,16 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
float u, v;
imapaint_pick_uv(me_eval, scene, ob_eval, faceindex, mval, uv);
sample_success = true;
-
+
u = fmodf(uv[0], 1.0f);
v = fmodf(uv[1], 1.0f);
-
+
if (u < 0.0f) u += 1.0f;
if (v < 0.0f) v += 1.0f;
-
+
u = u * ibuf->x;
v = v * ibuf->y;
-
+
if (ibuf->rect_float) {
float rgba_f[4];
bilinear_interpolation_color_wrap(ibuf, NULL, rgba_f, u, v);
@@ -521,7 +521,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
}
}
}
-
+
BKE_image_release_ibuf(image, ibuf, NULL);
}
}
@@ -542,7 +542,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
glReadBuffer(GL_BACK);
}
cp = (unsigned char *)&col;
-
+
if (use_palette) {
rgb_uchar_to_float(color->rgb, cp);
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 311587d6b53..ac6bfe019a1 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -55,10 +55,10 @@
#include "BKE_brush.h"
#include "BKE_context.h"
#include "BKE_deform.h"
-#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
+#include "BKE_object.h"
#include "BKE_object_deform.h"
#include "BKE_paint.h"
#include "BKE_report.h"
@@ -974,7 +974,7 @@ static void vertex_paint_init_session(Depsgraph *depsgraph, Scene *scene, Object
if (ob->sculpt == NULL) {
ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
- BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, 0, false);
+ BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, false, false);
}
}
@@ -1061,12 +1061,18 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
* \{ */
static void ed_vwpaintmode_enter_generic(
- Depsgraph *depsgraph, wmWindowManager *wm, Scene *scene,
+ Main *bmain, Depsgraph *depsgraph,
+ wmWindowManager *wm, Scene *scene,
Object *ob, const eObjectMode mode_flag)
{
ob->mode |= mode_flag;
Mesh *me = BKE_mesh_from_object(ob);
+ /* Same as sculpt mode, make sure we don't have cached derived mesh which
+ * points to freed arrays.
+ */
+ BKE_object_free_derived_caches(ob);
+
if (mode_flag == OB_MODE_VERTEX_PAINT) {
const ePaintMode paint_mode = ePaintVertex;
ED_mesh_color_ensure(me, NULL);
@@ -1077,7 +1083,7 @@ static void ed_vwpaintmode_enter_generic(
Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
paint_cursor_start_explicit(paint, wm, vertex_paint_poll);
- BKE_paint_init(scene, paint_mode, PAINT_CURSOR_VERTEX_PAINT);
+ BKE_paint_init(bmain, scene, paint_mode, PAINT_CURSOR_VERTEX_PAINT);
}
else if (mode_flag == OB_MODE_WEIGHT_PAINT) {
const ePaintMode paint_mode = ePaintWeight;
@@ -1088,7 +1094,7 @@ static void ed_vwpaintmode_enter_generic(
Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
paint_cursor_start_explicit(paint, wm, weight_paint_poll);
- BKE_paint_init(scene, paint_mode, PAINT_CURSOR_WEIGHT_PAINT);
+ BKE_paint_init(bmain, scene, paint_mode, PAINT_CURSOR_WEIGHT_PAINT);
/* weight paint specific */
ED_mesh_mirror_spatial_table(ob, NULL, NULL, NULL, 's');
@@ -1108,38 +1114,43 @@ static void ed_vwpaintmode_enter_generic(
}
vertex_paint_init_session(depsgraph, scene, ob);
+
+ /* Flush object mode. */
+ DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
}
void ED_object_vpaintmode_enter_ex(
- Depsgraph *depsgraph, wmWindowManager *wm,
+ Main *bmain, Depsgraph *depsgraph, wmWindowManager *wm,
Scene *scene, Object *ob)
{
ed_vwpaintmode_enter_generic(
- depsgraph, wm, scene, ob, OB_MODE_VERTEX_PAINT);
+ bmain, depsgraph, wm, scene, ob, OB_MODE_VERTEX_PAINT);
}
void ED_object_vpaintmode_enter(struct bContext *C)
{
+ Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
wmWindowManager *wm = CTX_wm_manager(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
- ED_object_vpaintmode_enter_ex(depsgraph, wm, scene, ob);
+ ED_object_vpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob);
}
void ED_object_wpaintmode_enter_ex(
- Depsgraph *depsgraph, wmWindowManager *wm,
+ Main *bmain, Depsgraph *depsgraph, wmWindowManager *wm,
Scene *scene, Object *ob)
{
ed_vwpaintmode_enter_generic(
- depsgraph, wm, scene, ob, OB_MODE_WEIGHT_PAINT);
+ bmain, depsgraph, wm, scene, ob, OB_MODE_WEIGHT_PAINT);
}
void ED_object_wpaintmode_enter(struct bContext *C)
{
+ Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
wmWindowManager *wm = CTX_wm_manager(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
- ED_object_wpaintmode_enter_ex(depsgraph, wm, scene, ob);
+ ED_object_wpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob);
}
/** \} */
@@ -1188,6 +1199,12 @@ static void ed_vwpaintmode_exit_generic(
ED_mesh_mirror_spatial_table(NULL, NULL, NULL, NULL, 'e');
ED_mesh_mirror_topo_table(NULL, NULL, 'e');
}
+
+ /* Never leave derived meshes behind. */
+ BKE_object_free_derived_caches(ob);
+
+ /* Flush object mode. */
+ DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
}
void ED_object_vpaintmode_exit_ex(Object *ob)
@@ -1219,6 +1236,7 @@ void ED_object_wpaintmode_exit(struct bContext *C)
*/
static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
Object *ob = CTX_data_active_object(C);
const int mode_flag = OB_MODE_WEIGHT_PAINT;
@@ -1239,7 +1257,7 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
else {
Depsgraph *depsgraph = CTX_data_depsgraph_on_load(C);
wmWindowManager *wm = CTX_wm_manager(C);
- ED_object_wpaintmode_enter_ex(depsgraph, wm, scene, ob);
+ ED_object_wpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob);
}
/* Weightpaint works by overriding colors in mesh,
@@ -2356,6 +2374,7 @@ void PAINT_OT_weight_paint(wmOperatorType *ot)
*/
static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
Object *ob = CTX_data_active_object(C);
const int mode_flag = OB_MODE_VERTEX_PAINT;
@@ -2377,7 +2396,7 @@ static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op)
else {
Depsgraph *depsgraph = CTX_data_depsgraph_on_load(C);
wmWindowManager *wm = CTX_wm_manager(C);
- ED_object_vpaintmode_enter_ex(depsgraph, wm, scene, ob);
+ ED_object_vpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob);
}
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
@@ -2602,7 +2621,7 @@ static float tex_color_alpha_ubyte(
}
static void do_vpaint_brush_draw_task_cb_ex(
- void *__restrict userdata,
+ void *__restrict userdata,
const int n,
const ParallelRangeTLS *__restrict UNUSED(tls))
{
@@ -3137,6 +3156,10 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
* avoid this if we can! */
DEG_id_tag_update(ob->data, 0);
}
+ else {
+ /* Flush changes through DEG. */
+ DEG_id_tag_update(ob->data, DEG_TAG_COPY_ON_WRITE);
+ }
}
static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
index d7668a48139..8516d92214d 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
@@ -152,6 +152,7 @@ static bool vertex_paint_from_weight(Object *ob)
}
/* TODO: respect selection. */
+ /* TODO: Do we want to take weights from evaluated mesh instead? 2.7x was not doing it anyway... */
mp = me->mpoly;
vgroup_active = ob->actdef - 1;
for (int i = 0; i < me->totpoly; i++, mp++) {
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_proj.c b/source/blender/editors/sculpt_paint/paint_vertex_proj.c
index c5c9aa48760..cacfdc2dbba 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_proj.c
@@ -41,6 +41,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_context.h"
+#include "BKE_mesh_runtime.h"
#include "DEG_depsgraph.h"
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
index e560a4cddff..7c2977a0788 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -52,6 +52,7 @@
#include "BKE_deform.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_object_deform.h"
#include "BKE_paint.h"
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 5acc1cd0c6a..1c76f20d45c 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -631,7 +631,7 @@ bool sculpt_brush_test_cube(SculptBrushTest *test, const float co[3], float loca
if (local_co[0] <= side && local_co[1] <= side && local_co[2] <= side) {
float p = 4.0f;
-
+
test->dist = ((powf(local_co[0], p) +
powf(local_co[1], p) +
powf(local_co[2], p)) / powf(side, p));
@@ -730,7 +730,7 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis,
{
float mirror[3];
float distsq;
-
+
/* flip_v3_v3(mirror, cache->traced_location, symm); */
flip_v3_v3(mirror, cache->true_location, symm);
@@ -1119,7 +1119,7 @@ static float brush_strength(
case SCULPT_TOOL_DRAW:
case SCULPT_TOOL_LAYER:
return alpha * flip * pressure * overlap * feather;
-
+
case SCULPT_TOOL_MASK:
overlap = (1 + overlap) / 2;
switch ((BrushMaskTool)brush->mask_tool) {
@@ -1152,7 +1152,7 @@ static float brush_strength(
}
else {
/* reduce strength for DEEPEN, PEAKS, and CONTRAST */
- return 0.5f * alpha * flip * pressure * overlap * feather;
+ return 0.5f * alpha * flip * pressure * overlap * feather;
}
case SCULPT_TOOL_SMOOTH:
@@ -1209,7 +1209,7 @@ float tex_strength(SculptSession *ss, const Brush *br,
avg = 1;
}
else if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) {
- /* Get strength by feeding the vertex
+ /* Get strength by feeding the vertex
* location directly into a texture */
avg = BKE_brush_sample_tex_3D(scene, br, point, rgba, 0, ss->tex_pool);
}
@@ -1219,7 +1219,7 @@ float tex_strength(SculptSession *ss, const Brush *br,
/* if the active area is being applied for symmetry, flip it
* across the symmetry axis and rotate it back to the original
- * position in order to project it. This insures that the
+ * position in order to project it. This insures that the
* brush texture will be oriented correctly. */
flip_v3_v3(symm_point, point, cache->mirror_symmetry_pass);
@@ -1279,16 +1279,16 @@ bool sculpt_search_sphere_cb(PBVHNode *node, void *data_v)
BKE_pbvh_node_get_original_BB(node, bb_min, bb_max);
else
BKE_pbvh_node_get_BB(node, bb_min, bb_max);
-
+
for (i = 0; i < 3; ++i) {
if (bb_min[i] > center[i])
nearest[i] = bb_min[i];
else if (bb_max[i] < center[i])
nearest[i] = bb_max[i];
else
- nearest[i] = center[i];
+ nearest[i] = center[i];
}
-
+
sub_v3_v3v3(t, center, nearest);
return len_squared_v3(t) < data->radius_squared;
@@ -1399,7 +1399,7 @@ static void update_sculpt_normal(Sculpt *sd, Object *ob,
{
const Brush *brush = BKE_paint_brush(&sd->paint);
StrokeCache *cache = ob->sculpt->cache;
-
+
if (cache->mirror_symmetry_pass == 0 &&
cache->radial_symmetry_pass == 0 &&
(cache->first_time || !(brush->flag & BRUSH_ORIGINAL_NORMAL)))
@@ -2041,7 +2041,7 @@ static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
Brush *brush = BKE_paint_brush(&sd->paint);
-
+
switch ((BrushMaskTool)brush->mask_tool) {
case BRUSH_MASK_DRAW:
do_mask_brush_draw(sd, ob, nodes, totnode);
@@ -2192,7 +2192,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius);
mul_v3_v3(offset, ss->cache->scale);
mul_v3_fl(offset, bstrength);
-
+
/* we divide out the squared alpha and multiply by the squared crease to give us the pinch strength */
crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor;
brush_alpha = BKE_brush_alpha_get(scene, brush);
@@ -4040,7 +4040,7 @@ static void do_symmetrical_brush_actions(
cache->bstrength = brush_strength(sd, cache, feather, ups);
cache->symmetry = symm;
- /* symm is a bit combination of XYZ - 1 is mirror X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
+ /* symm is a bit combination of XYZ - 1 is mirror X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
for (i = 0; i <= symm; ++i) {
if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) {
cache->mirror_symmetry_pass = i;
@@ -4175,14 +4175,14 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss)
(md->mode & eModifierMode_Realtime))
{
MirrorModifierData *mmd = (MirrorModifierData *)md;
-
+
if (mmd->flag & MOD_MIR_CLIPPING) {
/* check each axis for mirroring */
for (i = 0; i < 3; ++i) {
if (mmd->flag & (MOD_MIR_AXIS_X << i)) {
/* enable sculpt clipping */
ss->cache->flag |= CLIP_X << i;
-
+
/* update the clip tolerance */
if (mmd->tolerance >
ss->cache->clip_tolerance[i])
@@ -4203,6 +4203,7 @@ static void sculpt_update_cache_invariants(
wmOperator *op, const float mouse[2])
{
StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache");
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
Brush *brush = BKE_paint_brush(&sd->paint);
@@ -4270,11 +4271,11 @@ static void sculpt_update_cache_invariants(
Paint *p = &sd->paint;
Brush *br;
int size = BKE_brush_size_get(scene, brush);
-
+
BLI_strncpy(cache->saved_active_brush_name, brush->id.name + 2,
sizeof(cache->saved_active_brush_name));
- br = (Brush *)BKE_libblock_find_name(ID_BR, "Smooth");
+ br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Smooth");
if (br) {
BKE_paint_brush_set(p, br);
brush = br;
@@ -4366,7 +4367,7 @@ static void sculpt_update_cache_invariants(
#define PIXEL_INPUT_THRESHHOLD 5
if (brush->sculpt_tool == SCULPT_TOOL_ROTATE)
cache->dial = BLI_dial_initialize(cache->initial_mouse, PIXEL_INPUT_THRESHHOLD);
-
+
#undef PIXEL_INPUT_THRESHHOLD
}
@@ -4948,7 +4949,7 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *UNUSED(st
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
const Brush *brush = BKE_paint_brush(&sd->paint);
-
+
sculpt_stroke_modifiers_check(C, ob, brush);
sculpt_update_cache_variants(C, sd, ob, itemptr);
sculpt_restore_mesh(sd, ob);
@@ -5012,6 +5013,7 @@ static void sculpt_brush_exit_tex(Sculpt *sd)
static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(stroke))
{
+ Main *bmain = CTX_data_main(C);
Object *ob = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);
SculptSession *ss = ob->sculpt;
@@ -5033,7 +5035,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
}
else {
BKE_brush_size_set(scene, brush, ss->cache->saved_smooth_size);
- brush = (Brush *)BKE_libblock_find_name(ID_BR, ss->cache->saved_active_brush_name);
+ brush = (Brush *)BKE_libblock_find_name(bmain, ID_BR, ss->cache->saved_active_brush_name);
if (brush) {
BKE_paint_brush_set(&sd->paint, brush);
}
@@ -5046,7 +5048,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
sculpt_undo_push_end();
BKE_pbvh_update(ss->pbvh, PBVH_UpdateOriginalBB, NULL);
-
+
if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH)
BKE_pbvh_bmesh_after_stroke(ss->pbvh);
@@ -5090,7 +5092,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent
paint_stroke_data_free(op);
return OPERATOR_PASS_THROUGH;
}
-
+
if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) {
paint_stroke_data_free(op);
return OPERATOR_FINISHED;
@@ -5100,7 +5102,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent
OPERATOR_RETVAL_CHECK(retval);
BLI_assert(retval == OPERATOR_RUNNING_MODAL);
-
+
return OPERATOR_RUNNING_MODAL;
}
@@ -5147,7 +5149,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
ot->name = "Sculpt";
ot->idname = "SCULPT_OT_brush_stroke";
ot->description = "Sculpt a stroke into the geometry";
-
+
/* api callbacks */
ot->invoke = sculpt_brush_stroke_invoke;
ot->modal = paint_stroke_modal;
@@ -5164,7 +5166,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "ignore_background_click", 0,
"Ignore Background Click",
- "Clicks on the background do not start the stroke");
+ "Clicks on the background do not start the stroke");
}
/**** Reset the copy of the mesh that is being sculpted on (currently just for the layer brush) ****/
@@ -5188,11 +5190,11 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot)
ot->name = "Set Persistent Base";
ot->idname = "SCULPT_OT_set_persistent_base";
ot->description = "Reset the copy of the mesh that is being sculpted on";
-
+
/* api callbacks */
ot->exec = sculpt_set_persistent_base_exec;
ot->poll = sculpt_mode_poll;
-
+
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -5208,14 +5210,12 @@ static void sculpt_dynamic_topology_triangulate(BMesh *bm)
void sculpt_pbvh_clear(Object *ob)
{
SculptSession *ss = ob->sculpt;
- DerivedMesh *dm = ob->derivedFinal;
/* Clear out any existing DM and PBVH */
- if (ss->pbvh)
+ if (ss->pbvh) {
BKE_pbvh_free(ss->pbvh);
+ }
ss->pbvh = NULL;
- if (dm)
- dm->getPBVH(NULL, dm);
BKE_object_free_derived_caches(ob);
}
@@ -5296,7 +5296,7 @@ void sculpt_dynamic_topology_enable_ex(
/* Enable dynamic topology */
me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY;
-
+
/* Enable logging for undo/redo */
ss->bm_log = BM_log_create(ss->bm);
@@ -5520,12 +5520,12 @@ static void SCULPT_OT_dynamic_topology_toggle(wmOperatorType *ot)
ot->name = "Dynamic Topology Toggle";
ot->idname = "SCULPT_OT_dynamic_topology_toggle";
ot->description = "Dynamic topology alters the mesh topology while sculpting";
-
+
/* api callbacks */
ot->invoke = sculpt_dynamic_topology_toggle_invoke;
ot->exec = sculpt_dynamic_topology_toggle_exec;
ot->poll = sculpt_mode_poll;
-
+
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -5558,11 +5558,11 @@ static void SCULPT_OT_optimize(wmOperatorType *ot)
ot->name = "Optimize";
ot->idname = "SCULPT_OT_optimize";
ot->description = "Recalculate the sculpt BVH to improve performance";
-
+
/* api callbacks */
ot->exec = sculpt_optimize_exec;
ot->poll = sculpt_and_dynamic_topology_poll;
-
+
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -5612,7 +5612,7 @@ static void SCULPT_OT_symmetrize(wmOperatorType *ot)
ot->name = "Symmetrize";
ot->idname = "SCULPT_OT_symmetrize";
ot->description = "Symmetrize the topology modifications";
-
+
/* api callbacks */
ot->exec = sculpt_symmetrize_exec;
ot->poll = sculpt_and_dynamic_topology_poll;
@@ -5627,7 +5627,7 @@ static void sculpt_init_session(Depsgraph *depsgraph, Scene *scene, Object *ob)
ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
ob->sculpt->mode_type = OB_MODE_SCULPT;
- BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, 0, false);
+ BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, false, false);
}
static int ed_object_sculptmode_flush_recalc_flag(Scene *scene, Object *ob, MultiresModifierData *mmd)
@@ -5641,7 +5641,7 @@ static int ed_object_sculptmode_flush_recalc_flag(Scene *scene, Object *ob, Mult
}
void ED_object_sculptmode_enter_ex(
- Depsgraph *depsgraph,
+ Main *bmain, Depsgraph *depsgraph,
Scene *scene, Object *ob,
ReportList *reports)
{
@@ -5663,6 +5663,11 @@ void ED_object_sculptmode_enter_ex(
BKE_sculptsession_free(ob);
}
+ /* Make sure derived final from original object does not reference possibly
+ * freed memory.
+ */
+ BKE_object_free_derived_mesh_caches(ob);
+
sculpt_init_session(depsgraph, scene, ob);
/* Mask layer is required */
@@ -5682,9 +5687,9 @@ void ED_object_sculptmode_enter_ex(
}
Paint *paint = BKE_paint_get_active_from_paintmode(scene, ePaintSculpt);
- BKE_paint_init(scene, ePaintSculpt, PAINT_CURSOR_SCULPT);
+ BKE_paint_init(bmain, scene, ePaintSculpt, PAINT_CURSOR_SCULPT);
- paint_cursor_start_explicit(paint, G.main->wm.first, sculpt_poll_view3d);
+ paint_cursor_start_explicit(paint, bmain->wm.first, sculpt_poll_view3d);
/* Check dynamic-topology flag; re-enter dynamic-topology mode when changing modes,
* As long as no data was added that is not supported. */
@@ -5733,14 +5738,18 @@ void ED_object_sculptmode_enter_ex(
}
// ED_workspace_object_mode_sync_from_object(G.main->wm.first, workspace, ob);
+
+ /* Flush object mode. */
+ DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
}
void ED_object_sculptmode_enter(struct bContext *C, ReportList *reports)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
- ED_object_sculptmode_enter_ex(depsgraph, scene, ob, reports);
+ ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, reports);
}
void ED_object_sculptmode_exit_ex(
@@ -5785,6 +5794,12 @@ void ED_object_sculptmode_exit_ex(
BKE_sculptsession_free(ob);
paint_cursor_delete_textures();
+
+ /* Never leave derived meshes behind. */
+ BKE_object_free_derived_mesh_caches(ob);
+
+ /* Flush object mode. */
+ DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
}
void ED_object_sculptmode_exit(bContext *C)
@@ -5798,6 +5813,7 @@ void ED_object_sculptmode_exit(bContext *C)
static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
{
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
+ Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_depsgraph_on_load(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
@@ -5814,7 +5830,7 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
ED_object_sculptmode_exit_ex(depsgraph, scene, ob);
}
else {
- ED_object_sculptmode_enter_ex(depsgraph, scene, ob, op->reports);
+ ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, op->reports);
}
WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene);
@@ -5832,11 +5848,11 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot)
ot->name = "Sculpt Mode";
ot->idname = "SCULPT_OT_sculptmode_toggle";
ot->description = "Toggle sculpt mode in 3D view";
-
+
/* api callbacks */
ot->exec = sculpt_mode_toggle_exec;
ot->poll = ED_operator_object_active_editable_mesh;
-
+
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index bca33ad8014..ff6b5a6f374 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -28,7 +28,7 @@
/** \file blender/editors/sculpt_paint/sculpt_intern.h
* \ingroup edsculpt
*/
-
+
#ifndef __SCULPT_INTERN_H__
#define __SCULPT_INTERN_H__
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index b819fe8e97d..2872ad4fb9c 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -58,6 +58,7 @@
#include "BKE_paint.h"
#include "BKE_key.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_subsurf.h"
#include "BKE_undo_system.h"
@@ -144,7 +145,7 @@ static bool sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoN
SculptSession *ss = ob->sculpt;
MVert *mvert;
int *index;
-
+
if (unode->maxvert) {
/* regular mesh restore */
@@ -157,7 +158,7 @@ static bool sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoN
if (kb) {
ob->shapenr = BLI_findindex(&key->block, kb) + 1;
- BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, 0, false);
+ BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, false);
WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob);
}
else {
@@ -197,7 +198,7 @@ static bool sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoN
/* pbvh uses it's own mvert array, so coords should be */
/* propagated to pbvh here */
- BKE_pbvh_apply_vertCos(ss->pbvh, vertCos);
+ BKE_pbvh_apply_vertCos(ss->pbvh, vertCos, unode->totvert);
MEM_freeN(vertCos);
}
@@ -261,7 +262,7 @@ static bool sculpt_undo_restore_hidden(
if (unode->maxvert) {
MVert *mvert = ss->mvert;
-
+
for (i = 0; i < unode->totvert; i++) {
MVert *v = &mvert[unode->index[i]];
if ((BLI_BITMAP_TEST(unode->vert_hidden, i) != 0) != ((v->flag & ME_HIDE) != 0)) {
@@ -273,12 +274,12 @@ static bool sculpt_undo_restore_hidden(
}
else if (unode->maxgrid && dm->getGridData) {
BLI_bitmap **grid_hidden = dm->getGridHidden(dm);
-
+
for (i = 0; i < unode->totgrid; i++) {
SWAP(BLI_bitmap *,
unode->grid_hidden[i],
grid_hidden[unode->grids[i]]);
-
+
}
}
@@ -292,7 +293,7 @@ static bool sculpt_undo_restore_mask(bContext *C, DerivedMesh *dm, SculptUndoNod
MVert *mvert;
float *vmask;
int *index, i, j;
-
+
if (unode->maxvert) {
/* regular mesh restore */
@@ -492,7 +493,9 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
}
}
- BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, 0, need_mask);
+ DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+
+ BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, need_mask);
/* call _after_ sculpt_update_mesh_elements() which may update 'ob->derivedFinal' */
dm = mesh_get_derived_final(depsgraph, scene, ob, 0);
@@ -671,10 +674,10 @@ static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh,
BKE_pbvh_node_get_grids(pbvh, node, &grid_indices, &totgrid,
NULL, NULL, NULL);
-
+
unode->grid_hidden = MEM_mapallocN(sizeof(*unode->grid_hidden) * totgrid,
"unode->grid_hidden");
-
+
for (i = 0; i < totgrid; i++) {
if (grid_hidden[grid_indices[i]])
unode->grid_hidden[i] = MEM_dupallocN(grid_hidden[grid_indices[i]]);
@@ -691,7 +694,7 @@ static SculptUndoNode *sculpt_undo_alloc_node(
SculptUndoNode *unode;
SculptSession *ss = ob->sculpt;
int totvert, allvert, totgrid, maxgrid, gridsize, *grids;
-
+
unode = MEM_callocN(sizeof(SculptUndoNode), "SculptUndoNode");
BLI_strncpy(unode->idname, ob->id.name, sizeof(unode->idname));
unode->type = type;
@@ -706,7 +709,7 @@ static SculptUndoNode *sculpt_undo_alloc_node(
}
else
maxgrid = 0;
-
+
/* we will use this while sculpting, is mapalloc slow to access then? */
/* general TODO, fix count_alloc */
@@ -722,7 +725,7 @@ static SculptUndoNode *sculpt_undo_alloc_node(
sculpt_undo_alloc_and_store_hidden(ss->pbvh, unode);
else
unode->vert_hidden = BLI_BITMAP_NEW(allvert, "SculptUndoNode.vert_hidden");
-
+
break;
case SCULPT_UNDO_MASK:
unode->mask = MEM_mapallocN(sizeof(float) * allvert, "SculptUndoNode.mask");
@@ -736,7 +739,7 @@ static SculptUndoNode *sculpt_undo_alloc_node(
BLI_assert(!"Dynamic topology should've already been handled");
break;
}
-
+
BLI_addtail(&usculpt->nodes, unode);
if (maxgrid) {
@@ -788,7 +791,7 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode)
const int *vert_indices;
int allvert;
int i;
-
+
BKE_pbvh_node_num_verts(pbvh, node, NULL, &allvert);
BKE_pbvh_node_get_verts(pbvh, node, &vert_indices, &mvert);
for (i = 0; i < allvert; i++) {
@@ -927,7 +930,7 @@ SculptUndoNode *sculpt_undo_push_node(
}
unode = sculpt_undo_alloc_node(ob, node, type);
-
+
BLI_thread_unlock(LOCK_CUSTOM1);
/* copy threaded, hopefully this is the performance critical part */
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index 6928610f280..cf9feae62b5 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -43,12 +43,13 @@
#include "DNA_meshdata_types.h"
#include "BKE_brush.h"
-#include "BKE_paint.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
-#include "BKE_mesh_mapping.h"
#include "BKE_customdata.h"
#include "BKE_editmesh.h"
+#include "BKE_main.h"
+#include "BKE_mesh_mapping.h"
+#include "BKE_paint.h"
#include "DEG_depsgraph.h"
@@ -138,7 +139,7 @@ typedef struct UvSculptData {
/* uvsmooth Paint for fast reference */
Paint *uvsculpt;
-
+
/* tool to use. duplicating here to change if modifier keys are pressed */
char tool;
@@ -230,7 +231,7 @@ static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(cu
}
-void ED_space_image_uv_sculpt_update(wmWindowManager *wm, Scene *scene)
+void ED_space_image_uv_sculpt_update(Main *bmain, wmWindowManager *wm, Scene *scene)
{
ToolSettings *settings = scene->toolsettings;
if (settings->use_uv_sculpt) {
@@ -243,7 +244,7 @@ void ED_space_image_uv_sculpt_update(wmWindowManager *wm, Scene *scene)
settings->uvsculpt->paint.flags |= PAINT_SHOW_BRUSH;
}
- BKE_paint_init(scene, ePaintSculptUV, PAINT_CURSOR_SCULPT);
+ BKE_paint_init(bmain, scene, ePaintSculptUV, PAINT_CURSOR_SCULPT);
settings->uvsculpt->paint.paint_cursor = WM_paint_cursor_activate(wm, uv_sculpt_brush_poll,
brush_drawcursor_uvsculpt, NULL);
diff --git a/source/blender/editors/sound/sound_intern.h b/source/blender/editors/sound/sound_intern.h
index ace173abdee..c1516c0f25e 100644
--- a/source/blender/editors/sound/sound_intern.h
+++ b/source/blender/editors/sound/sound_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index eaf101b1083..b7a80a92998 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -375,7 +375,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
specs.rate = scene->r.ffcodecdata.audio_mixrate;
BLI_strncpy(filename, path, sizeof(filename));
- BLI_path_abs(filename, bmain->name);
+ BLI_path_abs(filename, BKE_main_blendfile_path(bmain));
if (split)
result = AUD_mixdown_per_channel(scene->sound_scene, SFRA * specs.rate / FPS, (EFRA - SFRA + 1) * specs.rate / FPS,
diff --git a/source/blender/editors/space_action/action_buttons.c b/source/blender/editors/space_action/action_buttons.c
index 3ba59b3be75..a5cc66add87 100644
--- a/source/blender/editors/space_action/action_buttons.c
+++ b/source/blender/editors/space_action/action_buttons.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2016 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation, Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
@@ -75,9 +75,9 @@ void action_buttons_register(ARegionType *UNUSED(art))
{
#if 0
PanelType *pt;
-
+
// TODO: AnimData / Actions List
-
+
pt = MEM_callocN(sizeof(PanelType), "spacetype action panel properties");
strcpy(pt->idname, "ACTION_PT_properties");
strcpy(pt->label, N_("Active F-Curve"));
@@ -85,7 +85,7 @@ void action_buttons_register(ARegionType *UNUSED(art))
pt->draw = action_anim_panel_properties;
pt->poll = action_anim_panel_poll;
BLI_addtail(&art->paneltypes, pt);
-
+
pt = MEM_callocN(sizeof(PanelType), "spacetype action panel properties");
strcpy(pt->idname, "ACTION_PT_key_properties");
strcpy(pt->label, N_("Active Keyframe"));
@@ -93,7 +93,7 @@ void action_buttons_register(ARegionType *UNUSED(art))
pt->draw = action_anim_panel_key_properties;
pt->poll = action_anim_panel_poll;
BLI_addtail(&art->paneltypes, pt);
-
+
pt = MEM_callocN(sizeof(PanelType), "spacetype action panel modifiers");
strcpy(pt->idname, "ACTION_PT_modifiers");
strcpy(pt->label, N_("Modifiers"));
@@ -108,7 +108,7 @@ static int action_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = action_has_buttons_region(sa);
-
+
if (ar)
ED_region_toggle_hidden(C, ar);
@@ -120,7 +120,7 @@ void ACTION_OT_properties(wmOperatorType *ot)
ot->name = "Properties";
ot->idname = "ACTION_OT_properties";
ot->description = "Toggle the properties region visibility";
-
+
ot->exec = action_properties_toggle_exec;
ot->poll = ED_operator_action_active;
diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c
index f1153b5bed0..74c9f2f8cfb 100644
--- a/source/blender/editors/space_action/action_data.c
+++ b/source/blender/editors/space_action/action_data.c
@@ -87,7 +87,7 @@ AnimData *ED_actedit_animdata_from_context(bContext *C)
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
Object *ob = CTX_data_active_object(C);
AnimData *adt = NULL;
-
+
/* Get AnimData block to use */
if (saction->mode == SACTCONT_ACTION) {
/* Currently, "Action Editor" means object-level only... */
@@ -101,7 +101,7 @@ AnimData *ED_actedit_animdata_from_context(bContext *C)
adt = key->adt;
}
}
-
+
return adt;
}
@@ -112,7 +112,7 @@ static bAction *action_create_new(bContext *C, bAction *oldact)
{
ScrArea *sa = CTX_wm_area(C);
bAction *action;
-
+
/* create action - the way to do this depends on whether we've got an
* existing one there already, in which case we make a copy of it
* (which is useful for "versioning" actions within the same file)
@@ -125,24 +125,24 @@ static bAction *action_create_new(bContext *C, bAction *oldact)
/* just make a new (empty) action */
action = BKE_action_add(CTX_data_main(C), "Action");
}
-
- /* when creating new ID blocks, there is already 1 user (as for all new datablocks),
+
+ /* when creating new ID blocks, there is already 1 user (as for all new datablocks),
* but the RNA pointer code will assign all the proper users instead, so we compensate
* for that here
*/
BLI_assert(action->id.us == 1);
id_us_min(&action->id);
-
+
/* set ID-Root type */
if (sa->spacetype == SPACE_ACTION) {
SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
-
+
if (saction->mode == SACTCONT_SHAPEKEY)
action->idroot = ID_KE;
else
action->idroot = ID_OB;
}
-
+
return action;
}
@@ -151,17 +151,17 @@ static void actedit_change_action(bContext *C, bAction *act)
{
bScreen *screen = CTX_wm_screen(C);
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
-
+
PointerRNA ptr, idptr;
PropertyRNA *prop;
-
+
/* create RNA pointers and get the property */
RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, saction, &ptr);
prop = RNA_struct_find_property(&ptr, "action");
-
+
/* NOTE: act may be NULL here, so better to just use a cast here */
RNA_id_pointer_create((ID *)act, &idptr);
-
+
/* set the new pointer, and force a refresh */
RNA_property_pointer_set(&ptr, prop, idptr);
RNA_property_update(C, &ptr, prop);
@@ -178,13 +178,13 @@ static void actedit_change_action(bContext *C, bAction *act)
static int action_new_poll(bContext *C)
{
Scene *scene = CTX_data_scene(C);
-
+
/* Check tweakmode is off (as you don't want to be tampering with the action in that case) */
- /* NOTE: unlike for pushdown, this operator needs to be run when creating an action from nothing... */
+ /* NOTE: unlike for pushdown, this operator needs to be run when creating an action from nothing... */
if (ED_operator_action_active(C)) {
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
Object *ob = CTX_data_active_object(C);
-
+
/* For now, actions are only for the active object, and on object and shapekey levels... */
if (saction->mode == SACTCONT_ACTION) {
/* XXX: This assumes that actions are assigned to the active object in this mode */
@@ -206,7 +206,7 @@ static int action_new_poll(bContext *C)
return true;
}
}
-
+
/* something failed... */
return false;
}
@@ -215,18 +215,18 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
{
PointerRNA ptr, idptr;
PropertyRNA *prop;
-
+
/* hook into UI */
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
-
+
if (prop) {
bAction *action = NULL, *oldact = NULL;
AnimData *adt = NULL;
PointerRNA oldptr;
-
+
oldptr = RNA_property_pointer_get(&ptr, prop);
oldact = (bAction *)oldptr.id.data;
-
+
/* stash the old action to prevent it from being lost */
if (ptr.type == &RNA_AnimData) {
adt = ptr.data;
@@ -234,7 +234,7 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
else if (ptr.type == &RNA_SpaceDopeSheetEditor) {
adt = ED_actedit_animdata_from_context(C);
}
-
+
/* Perform stashing operation - But only if there is an action */
if (adt && oldact) {
/* stash the action */
@@ -255,10 +255,10 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
//printf("WARNING: Failed to stash %s. It may already exist in the NLA stack though\n", oldact->id.name);
}
}
-
+
/* create action */
action = action_create_new(C, oldact);
-
+
/* set this new action
* NOTE: we can't use actedit_change_action, as this function is also called from the NLA
*/
@@ -266,24 +266,24 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
RNA_property_pointer_set(&ptr, prop, idptr);
RNA_property_update(C, &ptr, prop);
}
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_new(wmOperatorType *ot)
{
/* identifiers */
ot->name = "New Action";
ot->idname = "ACTION_OT_new";
ot->description = "Create new action";
-
+
/* api callbacks */
ot->exec = action_new_exec;
ot->poll = action_new_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -291,7 +291,7 @@ void ACTION_OT_new(wmOperatorType *ot)
/* ******************* Action Push-Down Operator ******************** */
/* Criteria:
- * 1) There must be an dopesheet/action editor, and it must be in a mode which uses actions
+ * 1) There must be an dopesheet/action editor, and it must be in a mode which uses actions
* 2) There must be an action active
* 3) The associated AnimData block must not be in tweakmode
*/
@@ -300,7 +300,7 @@ static int action_pushdown_poll(bContext *C)
if (ED_operator_action_active(C)) {
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
AnimData *adt = ED_actedit_animdata_from_context(C);
-
+
/* Check for AnimData, Actions, and that tweakmode is off */
if (adt && saction->action) {
/* NOTE: We check this for the AnimData block in question and not the global flag,
@@ -310,7 +310,7 @@ static int action_pushdown_poll(bContext *C)
return true;
}
}
-
+
/* something failed... */
return false;
}
@@ -319,7 +319,7 @@ static int action_pushdown_exec(bContext *C, wmOperator *op)
{
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
AnimData *adt = ED_actedit_animdata_from_context(C);
-
+
/* Do the deed... */
if (adt) {
/* Perform the pushdown operation
@@ -334,13 +334,13 @@ static int action_pushdown_exec(bContext *C, wmOperator *op)
/* action can be safely added */
BKE_nla_action_pushdown(adt);
}
-
+
/* Stop displaying this action in this editor
* NOTE: The editor itself doesn't set a user...
*/
saction->action = NULL;
}
-
+
/* Send notifiers that stuff has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
return OPERATOR_FINISHED;
@@ -352,11 +352,11 @@ void ACTION_OT_push_down(wmOperatorType *ot)
ot->name = "Push Down Action";
ot->idname = "ACTION_OT_push_down";
ot->description = "Push action down on to the NLA stack as a new strip";
-
+
/* callbacks */
ot->exec = action_pushdown_exec;
ot->poll = action_pushdown_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -367,7 +367,7 @@ static int action_stash_exec(bContext *C, wmOperator *op)
{
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
AnimData *adt = ED_actedit_animdata_from_context(C);
-
+
/* Perform stashing operation */
if (adt) {
/* don't do anything if this action is empty... */
@@ -390,12 +390,12 @@ static int action_stash_exec(bContext *C, wmOperator *op)
/* action has already been added - simply warn about this, and clear */
BKE_report(op->reports, RPT_ERROR, "Action has already been stashed");
}
-
+
/* clear action refs from editor, and then also the backing data (not necessary) */
actedit_change_action(C, NULL);
}
}
-
+
/* Send notifiers that stuff has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
return OPERATOR_FINISHED;
@@ -407,30 +407,30 @@ void ACTION_OT_stash(wmOperatorType *ot)
ot->name = "Stash Action";
ot->idname = "ACTION_OT_stash";
ot->description = "Store this action in the NLA stack as a non-contributing strip for later use";
-
+
/* callbacks */
ot->exec = action_stash_exec;
ot->poll = action_pushdown_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
- ot->prop = RNA_def_boolean(ot->srna, "create_new", true, "Create New Action",
+ ot->prop = RNA_def_boolean(ot->srna, "create_new", true, "Create New Action",
"Create a new action once the existing one has been safely stored");
}
/* ----------------- */
/* Criteria:
- * 1) There must be an dopesheet/action editor, and it must be in a mode which uses actions
+ * 1) There must be an dopesheet/action editor, and it must be in a mode which uses actions
* 2) The associated AnimData block must not be in tweakmode
*/
static int action_stash_create_poll(bContext *C)
{
if (ED_operator_action_active(C)) {
AnimData *adt = ED_actedit_animdata_from_context(C);
-
+
/* Check tweakmode is off (as you don't want to be tampering with the action in that case) */
/* NOTE: unlike for pushdown, this operator needs to be run when creating an action from nothing... */
if (adt) {
@@ -439,19 +439,19 @@ static int action_stash_create_poll(bContext *C)
}
else {
/* There may not be any action/animdata yet, so, just fallback to the global setting
- * (which may not be totally valid yet if the action editor was used and things are
+ * (which may not be totally valid yet if the action editor was used and things are
* now in an inconsistent state)
*/
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
Scene *scene = CTX_data_scene(C);
-
+
if (!(scene->flag & SCE_NLA_EDIT_ON)) {
/* For now, actions are only for the active object, and on object and shapekey levels... */
return ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY);
}
}
}
-
+
/* something failed... */
return false;
}
@@ -460,7 +460,7 @@ static int action_stash_create_exec(bContext *C, wmOperator *op)
{
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
AnimData *adt = ED_actedit_animdata_from_context(C);
-
+
/* Check for no action... */
if (saction->action == NULL) {
/* just create a new action */
@@ -478,10 +478,10 @@ static int action_stash_create_exec(bContext *C, wmOperator *op)
/* stash the action */
if (BKE_nla_action_stash(adt)) {
bAction *new_action = NULL;
-
+
/* create new action not based on the old one (since the "new" operator already does that) */
new_action = action_create_new(C, NULL);
-
+
/* The stash operation will remove the user already,
* so the flushing step later shouldn't double up
* the usercount fixes. Hence, we must unset this ref
@@ -497,7 +497,7 @@ static int action_stash_create_exec(bContext *C, wmOperator *op)
}
}
}
-
+
/* Send notifiers that stuff has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
return OPERATOR_FINISHED;
@@ -509,11 +509,11 @@ void ACTION_OT_stash_and_create(wmOperatorType *ot)
ot->name = "Stash Action";
ot->idname = "ACTION_OT_stash_and_create";
ot->description = "Store this action in the NLA stack as a non-contributing strip for later use, and create a new action";
-
+
/* callbacks */
ot->exec = action_stash_create_exec;
ot->poll = action_stash_create_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -533,7 +533,7 @@ void ACTION_OT_stash_and_create(wmOperatorType *ot)
void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act, ReportList *reports, bool force_delete)
{
ScrArea *sa = CTX_wm_area(C);
-
+
/* If the old action only has a single user (that it's about to lose),
* warn user about it
*
@@ -545,7 +545,7 @@ void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act,
"Action '%s' will not be saved, create Fake User or Stash in NLA Stack to retain",
act->id.name + 2);
}
-
+
/* Clear Fake User and remove action stashing strip (if present) */
if (force_delete) {
/* Remove stashed strip binding this action to this datablock */
@@ -556,18 +556,18 @@ void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act,
if (adt) {
NlaTrack *nlt, *nlt_next;
NlaStrip *strip, *nstrip;
-
+
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt_next) {
nlt_next = nlt->next;
-
+
if (strstr(nlt->name, DATA_("[Action Stash]"))) {
for (strip = nlt->strips.first; strip; strip = nstrip) {
nstrip = strip->next;
-
+
if (strip->act == act) {
/* Remove this strip, and the track too if it doesn't have anything else */
BKE_nlastrip_free(&nlt->strips, strip);
-
+
if (nlt->strips.first == NULL) {
BLI_assert(nstrip == NULL);
BKE_nlatrack_free(&adt->nla_tracks, nlt);
@@ -577,18 +577,18 @@ void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act,
}
}
}
-
+
/* Clear Fake User */
id_fake_user_clear(&act->id);
}
-
- /* If in Tweak Mode, don't unlink. Instead, this
+
+ /* If in Tweak Mode, don't unlink. Instead, this
* becomes a shortcut to exit Tweak Mode instead
*/
if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) {
/* Exit Tweak Mode */
BKE_nla_tweakmode_exit(adt);
-
+
/* Flush this to the Action Editor (if that's where this change was initiated) */
if (sa->spacetype == SPACE_ACTION) {
actedit_change_action(C, NULL);
@@ -604,11 +604,11 @@ void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act,
/* clear AnimData -> action */
PointerRNA ptr;
PropertyRNA *prop;
-
+
/* create AnimData RNA pointers */
RNA_pointer_create(id, &RNA_AnimData, adt, &ptr);
prop = RNA_struct_find_property(&ptr, "action");
-
+
/* clear... */
RNA_property_pointer_set(&ptr, prop, PointerRNA_NULL);
RNA_property_update(C, &ptr, prop);
@@ -623,12 +623,12 @@ static int action_unlink_poll(bContext *C)
if (ED_operator_action_active(C)) {
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
AnimData *adt = ED_actedit_animdata_from_context(C);
-
+
/* Only when there's an active action, in the right modes... */
if (saction->action && adt)
return true;
}
-
+
/* something failed... */
return false;
}
@@ -637,11 +637,11 @@ static int action_unlink_exec(bContext *C, wmOperator *op)
{
AnimData *adt = ED_actedit_animdata_from_context(C);
bool force_delete = RNA_boolean_get(op->ptr, "force_delete");
-
+
if (adt && adt->action) {
ED_animedit_unlink_action(C, NULL, adt, adt->action, op->reports, force_delete);
}
-
+
return OPERATOR_FINISHED;
}
@@ -655,17 +655,17 @@ static int action_unlink_invoke(bContext *C, wmOperator *op, const wmEvent *evt)
void ACTION_OT_unlink(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Unlink Action";
ot->idname = "ACTION_OT_unlink";
ot->description = "Unlink this action from the active action slot (and/or exit Tweak Mode)";
-
+
/* callbacks */
ot->invoke = action_unlink_invoke;
ot->exec = action_unlink_exec;
ot->poll = action_unlink_poll;
-
+
/* properties */
prop = RNA_def_boolean(ot->srna, "force_delete", false, "Force Delete", "Clear Fake User and remove "
"copy stashed in this data-block's NLA stack");
@@ -679,7 +679,7 @@ void ACTION_OT_unlink(wmOperatorType *ot)
static NlaStrip *action_layer_get_nlastrip(ListBase *strips, float ctime)
{
NlaStrip *strip;
-
+
for (strip = strips->first; strip; strip = strip->next) {
/* Can we use this? */
if (IN_RANGE_INCL(ctime, strip->start, strip->end)) {
@@ -695,7 +695,7 @@ static NlaStrip *action_layer_get_nlastrip(ListBase *strips, float ctime)
return strip;
}
}
-
+
/* nothing suitable found... */
return NULL;
}
@@ -709,18 +709,18 @@ static void action_layer_switch_strip(AnimData *adt,
* NOTE: We need to manually clear this stuff ourselves, as tweakmode exit doesn't do it
*/
BKE_nla_tweakmode_exit(adt);
-
+
if (old_strip) {
old_strip->flag &= ~(NLASTRIP_FLAG_ACTIVE | NLASTRIP_FLAG_SELECT);
}
if (old_track) {
old_track->flag &= ~(NLATRACK_ACTIVE | NLATRACK_SELECTED);
}
-
+
/* Make this one the active one instead */
strip->flag |= (NLASTRIP_FLAG_ACTIVE | NLASTRIP_FLAG_SELECT);
nlt->flag |= NLATRACK_ACTIVE;
-
+
/* Copy over "solo" flag - This is useful for stashed actions... */
if (old_track) {
if (old_track->flag & NLATRACK_SOLO) {
@@ -733,15 +733,15 @@ static void action_layer_switch_strip(AnimData *adt,
if (adt->flag & ADT_NLA_EVAL_OFF) {
/* disable NLA muting */
adt->flag &= ~ADT_NLA_EVAL_OFF;
-
+
/* mark this track as being solo */
adt->flag |= ADT_NLA_SOLO_TRACK;
nlt->flag |= NLATRACK_SOLO;
-
+
// TODO: Needs restpose flushing (when we get reference track)
}
}
-
+
/* Enter tweakmode again - hopefully we're now "it" */
BKE_nla_tweakmode_enter(adt);
BLI_assert(adt->actstrip == strip);
@@ -762,7 +762,7 @@ static int action_layer_next_poll(bContext *C)
*/
if (adt->nla_tracks.last) {
NlaTrack *nlt = (NlaTrack *)adt->nla_tracks.last;
-
+
if (nlt->flag & NLATRACK_DISABLED) {
/* A disabled track will either be the track itself,
* or one of the ones above it.
@@ -780,7 +780,7 @@ static int action_layer_next_poll(bContext *C)
}
}
}
-
+
/* something failed... */
return false;
}
@@ -789,26 +789,26 @@ static int action_layer_next_exec(bContext *C, wmOperator *op)
{
AnimData *adt = ED_actedit_animdata_from_context(C);
NlaTrack *act_track;
-
+
Scene *scene = CTX_data_scene(C);
float ctime = BKE_scene_frame_get(scene);
-
+
/* Get active track */
act_track = BKE_nlatrack_find_tweaked(adt);
-
+
if (act_track == NULL) {
BKE_report(op->reports, RPT_ERROR, "Could not find current NLA Track");
return OPERATOR_CANCELLED;
}
-
+
/* Find next action, and hook it up */
if (act_track->next) {
NlaTrack *nlt;
-
+
/* Find next action to use */
for (nlt = act_track->next; nlt; nlt = nlt->next) {
NlaStrip *strip = action_layer_get_nlastrip(&nlt->strips, ctime);
-
+
if (strip) {
action_layer_switch_strip(adt, act_track, adt->actstrip, nlt, strip);
break;
@@ -820,7 +820,7 @@ static int action_layer_next_exec(bContext *C, wmOperator *op)
* NOTE: This will mean exiting tweakmode...
*/
BKE_nla_tweakmode_exit(adt);
-
+
/* Deal with solo flags...
* Assume: Solo Track == NLA Muting
*/
@@ -828,14 +828,14 @@ static int action_layer_next_exec(bContext *C, wmOperator *op)
/* turn off solo flags on tracks */
act_track->flag &= ~NLATRACK_SOLO;
adt->flag &= ~ADT_NLA_SOLO_TRACK;
-
+
/* turn on NLA muting (to keep same effect) */
adt->flag |= ADT_NLA_EVAL_OFF;
-
+
// TODO: Needs restpose flushing (when we get reference track)
}
}
-
+
/* Update the action that this editor now uses
* NOTE: The calls above have already handled the usercount/animdata side of things
*/
@@ -849,11 +849,11 @@ void ACTION_OT_layer_next(wmOperatorType *ot)
ot->name = "Next Layer";
ot->idname = "ACTION_OT_layer_next";
ot->description = "Switch to editing action in animation layer above the current action in the NLA Stack";
-
+
/* callbacks */
ot->exec = action_layer_next_exec;
ot->poll = action_layer_next_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -870,7 +870,7 @@ static int action_layer_prev_poll(bContext *C)
/* Tweak Mode: We need to check if there are any tracks below the active one that we can move to */
if (adt->nla_tracks.first) {
NlaTrack *nlt = (NlaTrack *)adt->nla_tracks.first;
-
+
/* Since the first disabled track is the track being tweaked/edited,
* we can simplify things by only checking the first track:
* - If it is disabled, this is the track being tweaked,
@@ -890,7 +890,7 @@ static int action_layer_prev_poll(bContext *C)
}
}
}
-
+
/* something failed... */
return false;
}
@@ -900,19 +900,19 @@ static int action_layer_prev_exec(bContext *C, wmOperator *op)
AnimData *adt = ED_actedit_animdata_from_context(C);
NlaTrack *act_track;
NlaTrack *nlt;
-
+
Scene *scene = CTX_data_scene(C);
float ctime = BKE_scene_frame_get(scene);
-
+
/* Sanity Check */
if (adt == NULL) {
BKE_report(op->reports, RPT_ERROR, "Internal Error: Could not find Animation Data/NLA Stack to use");
return OPERATOR_CANCELLED;
}
-
+
/* Get active track */
act_track = BKE_nlatrack_find_tweaked(adt);
-
+
/* If there is no active track, that means we are using the active action... */
if (act_track) {
/* Active Track - Start from the one below it */
@@ -922,17 +922,17 @@ static int action_layer_prev_exec(bContext *C, wmOperator *op)
/* Active Action - Use the top-most track */
nlt = adt->nla_tracks.last;
}
-
+
/* Find previous action and hook it up */
for (; nlt; nlt = nlt->prev) {
NlaStrip *strip = action_layer_get_nlastrip(&nlt->strips, ctime);
-
+
if (strip) {
action_layer_switch_strip(adt, act_track, adt->actstrip, nlt, strip);
break;
}
}
-
+
/* Update the action that this editor now uses
* NOTE: The calls above have already handled the usercount/animdata side of things
*/
@@ -946,11 +946,11 @@ void ACTION_OT_layer_prev(wmOperatorType *ot)
ot->name = "Previous Layer";
ot->idname = "ACTION_OT_layer_prev";
ot->description = "Switch to editing action in animation layer below the current action in the NLA Stack";
-
+
/* callbacks */
ot->exec = action_layer_prev_exec;
ot->poll = action_layer_prev_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 3e9b742480a..7c8be943a87 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -53,7 +53,7 @@
#include "BKE_pointcache.h"
-/* Everything from source (BIF, BDR, BSE) ------------------------------ */
+/* Everything from source (BIF, BDR, BSE) ------------------------------ */
#include "BIF_gl.h"
@@ -73,41 +73,41 @@
/* Channel List */
/* left hand part */
-void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
+void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
View2D *v2d = &ar->v2d;
float y = 0.0f;
size_t items;
int height;
-
+
/* build list of channels to draw */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
height = ((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac)));
if (height > BLI_rcti_size_y(&v2d->mask)) {
- /* don't use totrect set, as the width stays the same
- * (NOTE: this is ok here, the configuration is pretty straightforward)
+ /* don't use totrect set, as the width stays the same
+ * (NOTE: this is ok here, the configuration is pretty straightforward)
*/
v2d->tot.ymin = (float)(-height);
}
/* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */
UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY);
-
+
/* loop through channels, and set up drawing depending on their type */
{ /* first pass: just the standard GL-drawing for backdrop + text */
size_t channel_index = 0;
-
+
y = (float)ACHANNEL_FIRST(ac);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
-
+
/* check if visible */
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
@@ -115,7 +115,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
/* draw all channels using standard channel-drawing API */
ANIM_channel_draw(ac, ale, yminc, ymaxc, channel_index);
}
-
+
/* adjust y-position for next one */
y -= ACHANNEL_STEP(ac);
channel_index++;
@@ -124,13 +124,13 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
{ /* second pass: widgets */
uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
size_t channel_index = 0;
-
+
y = (float)ACHANNEL_FIRST(ac);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
-
+
/* check if visible */
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
@@ -138,16 +138,16 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
/* draw all channels using standard channel-drawing API */
ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index);
}
-
+
/* adjust y-position for next one */
y -= ACHANNEL_STEP(ac);
channel_index++;
}
-
+
UI_block_end(C, block);
UI_block_draw(C, block);
}
-
+
/* free tempolary channels */
ANIM_animdata_freelist(&anim_data);
}
@@ -163,50 +163,50 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
-
+
View2D *v2d = &ar->v2d;
bDopeSheet *ads = &saction->ads;
AnimData *adt = NULL;
-
+
float act_start, act_end, y;
-
+
unsigned char col1[3], col2[3];
unsigned char col1a[3], col2a[3];
unsigned char col1b[3], col2b[3];
-
+
const bool show_group_colors = !(saction->flag & SACTION_NODRAWGCOLORS);
-
-
+
+
/* get theme colors */
UI_GetThemeColor3ubv(TH_BACK, col2);
UI_GetThemeColor3ubv(TH_HILITE, col1);
-
+
UI_GetThemeColor3ubv(TH_GROUP, col2a);
UI_GetThemeColor3ubv(TH_GROUP_ACTIVE, col1a);
-
+
UI_GetThemeColor3ubv(TH_DOPESHEET_CHANNELOB, col1b);
UI_GetThemeColor3ubv(TH_DOPESHEET_CHANNELSUBOB, col2b);
-
+
/* set view-mapping rect (only used for x-axis), for NLA-scaling mapping with less calculation */
/* if in NLA there's a strip active, map the view */
if (ac->datatype == ANIMCONT_ACTION) {
/* adt = ANIM_nla_mapping_get(ac, NULL); */ /* UNUSED */
-
+
/* start and end of action itself */
calc_action_range(ac->data, &act_start, &act_end, 0);
}
-
+
/* build list of channels to draw */
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
int height = ((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac)));
- /* don't use totrect set, as the width stays the same
- * (NOTE: this is ok here, the configuration is pretty straightforward)
+ /* don't use totrect set, as the width stays the same
+ * (NOTE: this is ok here, the configuration is pretty straightforward)
*/
v2d->tot.ymin = (float)(-height);
-
+
/* first backdrop strips */
y = (float)(-ACHANNEL_HEIGHT(ac));
@@ -216,18 +216,18 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
glEnable(GL_BLEND);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
-
+
/* check if visible */
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
int sel = 0;
-
+
/* determine if any need to draw channel */
if (ale->datatype != ALE_NONE) {
/* determine if channel is selected */
@@ -287,10 +287,10 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
immUniformColor3ubvAlpha(sel ? col1 : col2, 0x22);
}
}
-
+
/* draw region twice: firstly backdrop, then the current range */
immRectf(pos, v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF(ac));
-
+
if (ac->datatype == ANIMCONT_ACTION)
immRectf(pos, act_start, (float)y - ACHANNEL_HEIGHT_HALF(ac), act_end, (float)y + ACHANNEL_HEIGHT_HALF(ac));
}
@@ -298,7 +298,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* frames less than one get less saturated background */
immUniformColor3ubvAlpha(sel ? col1 : col2, 0x22);
immRectf(pos, 0.0f, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF(ac));
-
+
/* frames one and higher get a saturated background */
immUniformColor3ubvAlpha(sel ? col1 : col2, 0x44);
immRectf(pos, v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF(ac));
@@ -315,7 +315,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
}
}
}
-
+
/* Increment the step */
y -= ACHANNEL_STEP(ac);
}
@@ -335,7 +335,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* Draw keyframes
* 1) Only channels that are visible in the Action Editor get drawn/evaluated.
* This is to try to optimize this for heavier data sets
- * 2) Keyframes which are out of view horizontally are disregarded
+ * 2) Keyframes which are out of view horizontally are disregarded
*/
y = (float)(-ACHANNEL_HEIGHT(ac));
@@ -397,7 +397,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
ListBase pidlist;
const float cache_draw_height = (4.0f * UI_DPI_FAC * U.pixelsize);
float yoffs = 0.f;
-
+
if (!(saction->cache_display & TIME_CACHE_DISPLAY) || (!ob))
return;
@@ -438,7 +438,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
gpuPushMatrix();
gpuTranslate2f(0.0, (float)V2D_SCROLL_HEIGHT + yoffs);
gpuScale2f(1.0, cache_draw_height);
-
+
switch (pid->type) {
case PTCACHE_TYPE_SOFTBODY:
col[0] = 1.0; col[1] = 0.4; col[2] = 0.02;
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index f7c668ac929..a9f9488d049 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -57,8 +57,9 @@
#include "BKE_fcurve.h"
#include "BKE_gpencil.h"
#include "BKE_global.h"
-#include "BKE_library.h"
#include "BKE_key.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
#include "BKE_nla.h"
#include "BKE_context.h"
#include "BKE_report.h"
@@ -95,56 +96,56 @@
static int act_markers_make_local_poll(bContext *C)
{
SpaceAction *sact = CTX_wm_space_action(C);
-
+
/* 1) */
if (sact == NULL)
return 0;
-
+
/* 2) */
if (ELEM(sact->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) == 0)
return 0;
if (sact->action == NULL)
return 0;
-
+
/* 3) */
if (sact->flag & SACTION_POSEMARKERS_SHOW)
return 0;
-
+
/* 4) */
return ED_markers_get_first_selected(ED_context_get_markers(C)) != NULL;
}
static int act_markers_make_local_exec(bContext *C, wmOperator *UNUSED(op))
-{
+{
ListBase *markers = ED_context_get_markers(C);
-
+
SpaceAction *sact = CTX_wm_space_action(C);
bAction *act = (sact) ? sact->action : NULL;
-
+
TimeMarker *marker, *markern = NULL;
-
+
/* sanity checks */
if (ELEM(NULL, markers, act))
return OPERATOR_CANCELLED;
-
+
/* migrate markers */
for (marker = markers->first; marker; marker = markern) {
markern = marker->next;
-
+
/* move if marker is selected */
if (marker->flag & SELECT) {
BLI_remlink(markers, marker);
BLI_addtail(&act->markers, marker);
}
}
-
+
/* now enable the "show posemarkers only" setting, so that we can see that something did happen */
sact->flag |= SACTION_POSEMARKERS_SHOW;
-
+
/* notifiers - both sets, as this change affects both */
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -154,11 +155,11 @@ void ACTION_OT_markers_make_local(wmOperatorType *ot)
ot->name = "Make Markers Local";
ot->idname = "ACTION_OT_markers_make_local";
ot->description = "Move selected scene markers to the active Action as local 'pose' markers";
-
+
/* callbacks */
ot->exec = act_markers_make_local_exec;
ot->poll = act_markers_make_local_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -175,17 +176,17 @@ static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const
bAnimListElem *ale;
int filter;
bool found = false;
-
+
/* get data to filter, from Action or Dopesheet */
/* XXX: what is sel doing here?!
* Commented it, was breaking things (eg. the "auto preview range" tool). */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_SEL *//*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* set large values to try to override */
*min = 999999999.0f;
*max = -999999999.0f;
-
+
/* check if any channels to set range with */
if (anim_data.first) {
/* go through channels, finding max extents */
@@ -268,7 +269,7 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
Scene *scene;
float min, max;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
@@ -276,7 +277,7 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
else
scene = ac.scene;
-
+
/* set the range directly */
get_keyframe_extents(&ac, &min, &max, false);
scene->r.flag |= SCER_PRV_RANGE;
@@ -286,25 +287,25 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
if (scene->r.psfra == scene->r.pefra) {
scene->r.pefra = scene->r.psfra + 1;
}
-
+
/* set notifier that things have changed */
// XXX err... there's nothing for frame ranges yet, but this should do fine too
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_previewrange_set(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Auto-Set Preview Range";
ot->idname = "ACTION_OT_previewrange_set";
ot->description = "Set Preview Range based on extents of selected Keyframes";
-
+
/* api callbacks */
ot->exec = actkeys_previewrange_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -323,31 +324,31 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min,
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
short found = 0; /* NOTE: not bool, since we want prioritise individual channels over expanders */
float y;
-
+
/* get all items - we need to do it this way */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through all channels, finding the first one that's selected */
y = (float)ACHANNEL_FIRST(ac);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
-
+
/* must be selected... */
- if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) &&
+ if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) &&
ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT))
{
/* update best estimate */
*min = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
*max = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
-
+
/* is this high enough priority yet? */
found = acf->channel_role;
-
+
/* only stop our search when we've found an actual channel
* - datablock expanders get less priority so that we don't abort prematurely
*/
@@ -355,14 +356,14 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min,
break;
}
}
-
+
/* adjust y-position for next one */
y -= ACHANNEL_STEP(ac);
}
-
+
/* free all temp data */
ANIM_animdata_freelist(&anim_data);
-
+
return (found != 0);
}
@@ -372,25 +373,35 @@ static int actkeys_viewall(bContext *C, const bool only_sel)
View2D *v2d;
float extra, min, max;
bool found;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
v2d = &ac.ar->v2d;
-
+
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
found = get_keyframe_extents(&ac, &min, &max, only_sel);
if (only_sel && (found == false))
return OPERATOR_CANCELLED;
- v2d->cur.xmin = min;
- v2d->cur.xmax = max;
+ if (fabsf(max - min) < 1.0f) {
+ /* Exception - center the single keyfrme */
+ float xwidth = BLI_rctf_size_x(&v2d->cur);
+
+ v2d->cur.xmin = min - xwidth / 2.0f;
+ v2d->cur.xmax = max + xwidth / 2.0f;
+ }
+ else {
+ /* Normal case - stretch the two keyframes out to fill the space, with extra spacing */
+ v2d->cur.xmin = min;
+ v2d->cur.xmax = max;
+
+ extra = 0.125f * BLI_rctf_size_x(&v2d->cur);
+ v2d->cur.xmin -= extra;
+ v2d->cur.xmax += extra;
+ }
- extra = 0.1f * BLI_rctf_size_x(&v2d->cur);
- v2d->cur.xmin -= extra;
- v2d->cur.xmax += extra;
-
/* set vertical range */
if (only_sel == false) {
/* view all -> the summary channel is usually the shows everything, and resides right at the top... */
@@ -401,30 +412,30 @@ static int actkeys_viewall(bContext *C, const bool only_sel)
/* locate first selected channel (or the active one), and frame those */
float ymin = v2d->cur.ymin;
float ymax = v2d->cur.ymax;
-
+
if (actkeys_channels_get_selected_extents(&ac, &ymin, &ymax)) {
/* recenter the view so that this range is in the middle */
float ymid = (ymax - ymin) / 2.0f + ymin;
float x_center;
-
+
UI_view2d_center_get(v2d, &x_center, NULL);
UI_view2d_center_set(v2d, x_center, ymid);
}
}
-
+
/* do View2D syncing */
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
-
+
/* just redraw this view */
ED_area_tag_redraw(CTX_wm_area(C));
-
+
return OPERATOR_FINISHED;
}
/* ......... */
static int actkeys_viewall_exec(bContext *C, wmOperator *UNUSED(op))
-{
+{
/* whole range */
return actkeys_viewall(C, false);
}
@@ -443,11 +454,11 @@ void ACTION_OT_view_all(wmOperatorType *ot)
ot->name = "View All";
ot->idname = "ACTION_OT_view_all";
ot->description = "Reset viewable area to show full keyframe range";
-
+
/* api callbacks */
ot->exec = actkeys_viewall_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -458,11 +469,11 @@ void ACTION_OT_view_selected(wmOperatorType *ot)
ot->name = "View Selected";
ot->idname = "ACTION_OT_view_selected";
ot->description = "Reset viewable area to show selected keyframes range";
-
+
/* api callbacks */
ot->exec = actkeys_viewsel_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -473,7 +484,7 @@ static int actkeys_view_frame_exec(bContext *C, wmOperator *op)
{
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
ANIM_center_frame(C, smooth_viewtx);
-
+
return OPERATOR_FINISHED;
}
@@ -483,11 +494,11 @@ void ACTION_OT_view_frame(wmOperatorType *ot)
ot->name = "View Frame";
ot->idname = "ACTION_OT_view_frame";
ot->description = "Reset viewable area to show range around current frame";
-
+
/* api callbacks */
ot->exec = actkeys_view_frame_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -499,20 +510,20 @@ void ACTION_OT_view_frame(wmOperatorType *ot)
/* NOTE: the backend code for this is shared with the graph editor */
static short copy_action_keys(bAnimContext *ac)
-{
+{
ListBase anim_data = {NULL, NULL};
int filter, ok = 0;
-
+
/* clear buffer first */
ANIM_fcurves_copybuf_free();
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* copy keyframes */
ok = copy_animedit_keys(ac, &anim_data);
-
+
/* clean up */
ANIM_animdata_freelist(&anim_data);
@@ -522,21 +533,21 @@ static short copy_action_keys(bAnimContext *ac)
static short paste_action_keys(bAnimContext *ac,
const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode, bool flip)
-{
+{
ListBase anim_data = {NULL, NULL};
int filter, ok = 0;
-
- /* filter data
- * - First time we try to filter more strictly, allowing only selected channels
+
+ /* filter data
+ * - First time we try to filter more strictly, allowing only selected channels
* to allow copying animation between channels
* - Second time, we loosen things up if nothing was found the first time, allowing
* users to just paste keyframes back into the original curve again [#31670]
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
-
+
if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0)
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* paste keyframes */
ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode, flip);
@@ -551,7 +562,7 @@ static short paste_action_keys(bAnimContext *ac,
static int actkeys_copy_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
@@ -574,17 +585,17 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
}
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_copy(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Copy Keyframes";
ot->idname = "ACTION_OT_copy";
ot->description = "Copy selected keyframes to the copy/paste buffer";
-
+
/* api callbacks */
ot->exec = actkeys_copy_exec;
ot->poll = ED_operator_action_active;
@@ -600,14 +611,14 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op)
const eKeyPasteOffset offset_mode = RNA_enum_get(op->ptr, "offset");
const eKeyMergeMode merge_mode = RNA_enum_get(op->ptr, "merge");
const bool flipped = RNA_boolean_get(op->ptr, "flipped");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* ac.reports by default will be the global reports list, which won't show warnings */
ac.reports = op->reports;
-
+
/* paste keyframes */
if (ac.datatype == ANIMCONT_GPENCIL) {
if (ED_gpencil_anim_copybuf_paste(&ac, offset_mode) == false) {
@@ -629,10 +640,10 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op)
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_paste(wmOperatorType *ot)
{
PropertyRNA *prop;
@@ -640,15 +651,15 @@ void ACTION_OT_paste(wmOperatorType *ot)
ot->name = "Paste Keyframes";
ot->idname = "ACTION_OT_paste";
ot->description = "Paste keyframes from copy/paste buffer for the selected channels, starting on the current frame";
-
+
/* api callbacks */
// ot->invoke = WM_operator_props_popup; // better wait for action redo panel
ot->exec = actkeys_paste_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
RNA_def_enum(ot->srna, "offset", rna_enum_keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys");
RNA_def_enum(ot->srna, "merge", rna_enum_keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merging pasted keys and existing");
@@ -667,40 +678,40 @@ static const EnumPropertyItem prop_actkeys_insertkey_types[] = {
};
/* this function is responsible for inserting new keyframes */
-static void insert_action_keys(bAnimContext *ac, short mode)
+static void insert_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
struct Depsgraph *depsgraph = ac->depsgraph;
ReportList *reports = ac->reports;
Scene *scene = ac->scene;
ToolSettings *ts = scene->toolsettings;
short flag = 0;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
if (mode == 2) filter |= ANIMFILTER_SEL;
else if (mode == 3) filter |= ANIMFILTER_ACTGROUPED;
-
+
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* init keyframing flag */
flag = ANIM_get_keyframing_flags(scene, 1);
-
+
/* insert keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
FCurve *fcu = (FCurve *)ale->key_data;
float cfra;
-
+
/* adjust current frame for NLA-scaling */
if (adt)
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
- else
+ else
cfra = (float)CFRA;
-
+
/* read value from property the F-Curve represents, or from the curve only?
* - ale->id != NULL: Typically, this means that we have enough info to try resolving the path
* - ale->owner != NULL: If this is set, then the path may not be resolvable from the ID alone,
@@ -708,16 +719,17 @@ static void insert_action_keys(bAnimContext *ac, short mode)
* (TODO: add the full-blown PointerRNA relative parsing case here...)
*/
if (ale->id && !ale->owner) {
- insert_keyframe(depsgraph, reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag);
+ insert_keyframe(ac->bmain, depsgraph, reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)),
+ fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag);
}
else {
const float curval = evaluate_fcurve(fcu, cfra);
insert_vert_fcurve(fcu, cfra, curval, ts->keyframe_type, 0);
}
-
+
ale->update |= ANIM_UPDATE_DEFAULT;
}
-
+
ANIM_animdata_update(ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
}
@@ -728,31 +740,31 @@ static void insert_gpencil_keys(bAnimContext *ac, short mode)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
Scene *scene = ac->scene;
ToolSettings *ts = scene->toolsettings;
eGP_GetFrame_Mode add_frame_mode;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
if (mode == 2) filter |= ANIMFILTER_SEL;
-
+
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
-
+
+
/* add a copy or a blank frame? */
if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST)
add_frame_mode = GP_GETFRAME_ADD_COPY; /* XXX: actframe may not be what we want? */
else
add_frame_mode = GP_GETFRAME_ADD_NEW;
-
-
+
+
/* insert gp frames */
for (ale = anim_data.first; ale; ale = ale->next) {
bGPDlayer *gpl = (bGPDlayer *)ale->data;
BKE_gpencil_layer_getframe(gpl, CFRA, add_frame_mode);
}
-
+
ANIM_animdata_update(ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
}
@@ -763,19 +775,19 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
if (ac.datatype == ANIMCONT_MASK) {
BKE_report(op->reports, RPT_ERROR, "Insert Keyframes is not yet implemented for this mode");
return OPERATOR_CANCELLED;
}
-
+
/* what channels to affect? */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* insert keyframes */
if (ac.datatype == ANIMCONT_GPENCIL) {
insert_gpencil_keys(&ac, mode);
@@ -786,7 +798,7 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op)
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -796,15 +808,15 @@ void ACTION_OT_keyframe_insert(wmOperatorType *ot)
ot->name = "Insert Keyframes";
ot->idname = "ACTION_OT_keyframe_insert";
ot->description = "Insert keyframes for the specified channels";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = actkeys_insertkey_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_insertkey_types, 0, "Type", "");
}
@@ -816,14 +828,14 @@ static void duplicate_action_keys(bAnimContext *ac)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
else
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through filtered data and delete selected keys */
for (ale = anim_data.first; ale; ale = ale->next) {
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE))
@@ -847,31 +859,31 @@ static void duplicate_action_keys(bAnimContext *ac)
static int actkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* duplicate keyframes */
duplicate_action_keys(&ac);
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_duplicate(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Duplicate Keyframes";
ot->idname = "ACTION_OT_duplicate";
ot->description = "Make a copy of all selected keyframes";
-
+
/* api callbacks */
ot->exec = actkeys_duplicate_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -905,26 +917,26 @@ static bool delete_action_keys(bAnimContext *ac)
else {
FCurve *fcu = (FCurve *)ale->key_data;
AnimData *adt = ale->adt;
-
+
/* delete selected keyframes only */
changed = delete_fcurve_keys(fcu);
-
+
/* Only delete curve too if it won't be doing anything anymore */
if ((fcu->totvert == 0) && (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0)) {
ANIM_fcurve_delete_from_animdata(ac, adt, fcu);
ale->key_data = NULL;
}
}
-
+
if (changed) {
ale->update |= ANIM_UPDATE_DEFAULT;
changed_final = true;
}
}
-
+
ANIM_animdata_update(ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
-
+
return changed_final;
}
@@ -933,33 +945,33 @@ static bool delete_action_keys(bAnimContext *ac)
static int actkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* delete keyframes */
if (!delete_action_keys(&ac))
return OPERATOR_CANCELLED;
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_delete(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Delete Keyframes";
ot->idname = "ACTION_OT_delete";
ot->description = "Remove all selected keyframes";
-
+
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = actkeys_delete_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -967,15 +979,15 @@ void ACTION_OT_delete(wmOperatorType *ot)
/* ******************** Clean Keyframes Operator ************************* */
static void clean_action_keys(bAnimContext *ac, float thresh, bool clean_chan)
-{
+{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through filtered data and clean curves */
for (ale = anim_data.first; ale; ale = ale->next) {
clean_fcurve(ac, ale, thresh, clean_chan);
@@ -994,44 +1006,44 @@ static int actkeys_clean_exec(bContext *C, wmOperator *op)
bAnimContext ac;
float thresh;
bool clean_chan;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
return OPERATOR_PASS_THROUGH;
}
-
+
/* get cleaning threshold */
thresh = RNA_float_get(op->ptr, "threshold");
clean_chan = RNA_boolean_get(op->ptr, "channels");
-
+
/* clean keyframes */
clean_action_keys(&ac, thresh, clean_chan);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_clean(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Clean Keyframes";
ot->idname = "ACTION_OT_clean";
ot->description = "Simplify F-Curves by removing closely spaced keyframes";
-
+
/* api callbacks */
- //ot->invoke = // XXX we need that number popup for this!
+ //ot->invoke = // XXX we need that number popup for this!
ot->exec = actkeys_clean_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f);
RNA_def_boolean(ot->srna, "channels", false, "Channels", "");
@@ -1041,15 +1053,15 @@ void ACTION_OT_clean(wmOperatorType *ot)
/* Evaluates the curves between each selected keyframe on each frame, and keys the value */
static void sample_action_keys(bAnimContext *ac)
-{
+{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through filtered data and add keys between selected keyframes on every frame */
for (ale = anim_data.first; ale; ale = ale->next) {
sample_fcurve((FCurve *)ale->key_data);
@@ -1066,36 +1078,36 @@ static void sample_action_keys(bAnimContext *ac)
static int actkeys_sample_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
return OPERATOR_PASS_THROUGH;
}
-
+
/* sample keyframes */
sample_action_keys(&ac);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_sample(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Sample Keyframes";
ot->idname = "ACTION_OT_sample";
ot->description = "Add keyframes on every frame between the selected keyframes";
-
+
/* api callbacks */
ot->exec = actkeys_sample_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1113,33 +1125,33 @@ void ACTION_OT_sample(wmOperatorType *ot)
static const EnumPropertyItem prop_actkeys_expo_types[] = {
{FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant Extrapolation", "Values on endpoint keyframes are held"},
{FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear Extrapolation", "Straight-line slope of end segments are extended past the endpoint keyframes"},
-
+
{MAKE_CYCLIC_EXPO, "MAKE_CYCLIC", 0, "Make Cyclic (F-Modifier)", "Add Cycles F-Modifier if one doesn't exist already"},
{CLEAR_CYCLIC_EXPO, "CLEAR_CYCLIC", 0, "Clear Cyclic (F-Modifier)", "Remove Cycles F-Modifier if not needed anymore"},
{0, NULL, 0, NULL, NULL}
};
/* this function is responsible for setting extrapolation mode for keyframes */
-static void setexpo_action_keys(bAnimContext *ac, short mode)
+static void setexpo_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through setting mode per F-Curve */
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
-
+
if (mode >= 0) {
/* just set mode setting */
fcu->extend = mode;
}
else {
- /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation
+ /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation
* without having to go through FModifier UI in Graph Editor to do so
*/
if (mode == MAKE_CYCLIC_EXPO) {
@@ -1152,10 +1164,10 @@ static void setexpo_action_keys(bAnimContext *ac, short mode)
else if (mode == CLEAR_CYCLIC_EXPO) {
/* remove all the modifiers fitting this description */
FModifier *fcm, *fcn = NULL;
-
+
for (fcm = fcu->modifiers.first; fcm; fcm = fcn) {
fcn = fcm->next;
-
+
if (fcm->type == FMODIFIER_TYPE_CYCLES)
remove_fmodifier(&fcu->modifiers, fcm);
}
@@ -1175,43 +1187,43 @@ static int actkeys_expo_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
return OPERATOR_PASS_THROUGH;
}
-
+
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* set handle type */
setexpo_action_keys(&ac, mode);
-
+
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_extrapolation_type(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Keyframe Extrapolation";
ot->idname = "ACTION_OT_extrapolation_type";
ot->description = "Set extrapolation mode for selected F-Curves";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = actkeys_expo_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_expo_types, 0, "Type", "");
}
@@ -1219,17 +1231,17 @@ void ACTION_OT_extrapolation_type(wmOperatorType *ot)
/* ******************** Set Interpolation-Type Operator *********************** */
/* this function is responsible for setting interpolation mode for keyframes */
-static void setipo_action_keys(bAnimContext *ac, short mode)
+static void setipo_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
KeyframeEditFunc set_cb = ANIM_editkeyframes_ipo(mode);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through setting BezTriple interpolation
* Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
*/
@@ -1249,43 +1261,43 @@ static int actkeys_ipo_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
return OPERATOR_PASS_THROUGH;
}
-
+
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* set handle type */
setipo_action_keys(&ac, mode);
-
+
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_interpolation_type(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Keyframe Interpolation";
ot->idname = "ACTION_OT_interpolation_type";
ot->description = "Set interpolation mode for the F-Curve segments starting from the selected keyframes";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = actkeys_ipo_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_beztriple_interpolation_mode_items, 0, "Type", "");
}
@@ -1293,25 +1305,25 @@ void ACTION_OT_interpolation_type(wmOperatorType *ot)
/* ******************** Set Handle-Type Operator *********************** */
/* this function is responsible for setting handle-type of selected keyframes */
-static void sethandles_action_keys(bAnimContext *ac, short mode)
+static void sethandles_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditFunc edit_cb = ANIM_editkeyframes_handles(mode);
KeyframeEditFunc sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
- /* loop through setting flags for handles
+
+ /* loop through setting flags for handles
* Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
*/
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
-
+
/* any selected keyframes for editing? */
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) {
/* change type of selected handles */
@@ -1331,43 +1343,43 @@ static int actkeys_handletype_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
return OPERATOR_PASS_THROUGH;
}
-
+
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* set handle type */
sethandles_action_keys(&ac, mode);
-
+
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_handle_type(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Keyframe Handle Type";
ot->idname = "ACTION_OT_handle_type";
ot->description = "Set type of handle for selected keyframes";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = actkeys_handletype_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_keyframe_handle_type_items, 0, "Type", "");
}
@@ -1375,17 +1387,17 @@ void ACTION_OT_handle_type(wmOperatorType *ot)
/* ******************** Set Keyframe-Type Operator *********************** */
/* this function is responsible for setting keyframe type for keyframes */
-static void setkeytype_action_keys(bAnimContext *ac, short mode)
+static void setkeytype_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
KeyframeEditFunc set_cb = ANIM_editkeyframes_keytype(mode);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through setting BezTriple interpolation
* Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
*/
@@ -1405,11 +1417,11 @@ static void setkeytype_gpencil_keys(bAnimContext *ac, short mode)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through each layer */
for (ale = anim_data.first; ale; ale = ale->next) {
if (ale->type == ANIMTYPE_GPLAYER) {
@@ -1428,19 +1440,19 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
if (ac.datatype == ANIMCONT_MASK) {
BKE_report(op->reports, RPT_ERROR, "Not implemented for Masks");
return OPERATOR_PASS_THROUGH;
}
-
+
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* set handle type */
if (ac.datatype == ANIMCONT_GPENCIL) {
setkeytype_gpencil_keys(&ac, mode);
@@ -1448,28 +1460,28 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op)
else {
setkeytype_action_keys(&ac, mode);
}
-
+
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_keyframe_type(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Keyframe Type";
ot->idname = "ACTION_OT_keyframe_type";
ot->description = "Set type of keyframe for the selected keyframes";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = actkeys_keytype_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_beztriple_keyframe_type_items, 0, "Type", "");
}
@@ -1496,39 +1508,39 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
bAnimListElem *ale;
int filter;
KeyframeEditData ked = {{NULL}};
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* init edit data */
/* loop over action data, averaging values */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
if (adt) {
- ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
else
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
}
-
+
ANIM_animdata_freelist(&anim_data);
-
+
/* set the new current frame value, based on the average time */
if (ked.i1) {
Scene *scene = ac.scene;
CFRA = round_fl_to_int(ked.f1 / ked.i1);
SUBFRA = 0.f;
}
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
-
+
return OPERATOR_FINISHED;
}
@@ -1538,11 +1550,11 @@ void ACTION_OT_frame_jump(wmOperatorType *ot)
ot->name = "Jump to Keyframes";
ot->idname = "ACTION_OT_frame_jump";
ot->description = "Set the current frame to the average frame value of selected keyframes";
-
+
/* api callbacks */
ot->exec = actkeys_framejump_exec;
ot->poll = actkeys_framejump_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1563,22 +1575,22 @@ static const EnumPropertyItem prop_actkeys_snap_types[] = {
};
/* this function is responsible for snapping keyframes to frame-times */
-static void snap_action_keys(bAnimContext *ac, short mode)
+static void snap_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditData ked = {{NULL}};
KeyframeEditFunc edit_cb;
-
+
/* filter data */
if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
else
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* get beztriple editing callbacks */
edit_cb = ANIM_editkeyframes_snap(mode);
@@ -1587,11 +1599,11 @@ static void snap_action_keys(bAnimContext *ac, short mode)
ked.list.first = (ac->markers) ? ac->markers->first : NULL;
ked.list.last = (ac->markers) ? ac->markers->last : NULL;
}
-
+
/* snap keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gplayer_snap_frames(ale->data, ac->scene, mode);
}
@@ -1599,7 +1611,7 @@ static void snap_action_keys(bAnimContext *ac, short mode)
ED_masklayer_snap_frames(ale->data, ac->scene, mode);
}
else if (adt) {
- ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
@@ -1620,38 +1632,38 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get snapping mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* snap keyframes */
snap_action_keys(&ac, mode);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_snap(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Snap Keys";
ot->idname = "ACTION_OT_snap";
ot->description = "Snap selected keyframes to the times specified";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = actkeys_snap_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_snap_types, 0, "Type", "");
}
@@ -1670,42 +1682,42 @@ static const EnumPropertyItem prop_actkeys_mirror_types[] = {
};
/* this function is responsible for mirroring keyframes */
-static void mirror_action_keys(bAnimContext *ac, short mode)
+static void mirror_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditData ked = {{NULL}};
KeyframeEditFunc edit_cb;
-
+
/* get beztriple editing callbacks */
edit_cb = ANIM_editkeyframes_mirror(mode);
ked.scene = ac->scene;
-
+
/* for 'first selected marker' mode, need to find first selected marker first! */
/* XXX should this be made into a helper func in the API? */
if (mode == ACTKEYS_MIRROR_MARKER) {
TimeMarker *marker = ED_markers_get_first_selected(ac->markers);
-
+
if (marker)
ked.f1 = (float)marker->frame;
else
return;
}
-
+
/* filter data */
if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
else
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* mirror keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gplayer_mirror_frames(ale->data, ac->scene, mode);
}
@@ -1713,14 +1725,14 @@ static void mirror_action_keys(bAnimContext *ac, short mode)
/* TODO */
}
else if (adt) {
- ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
}
-
+
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -1734,38 +1746,38 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get mirroring mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* mirror keyframes */
mirror_action_keys(&ac, mode);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_mirror(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Mirror Keys";
ot->idname = "ACTION_OT_mirror";
ot->description = "Flip selected keyframes over the selected mirror line";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = actkeys_mirror_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_mirror_types, 0, "Type", "");
}
diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h
index 6ec6f0561c2..25d3560b175 100644
--- a/source/blender/editors/space_action/action_intern.h
+++ b/source/blender/editors/space_action/action_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -54,7 +54,7 @@ void ACTION_OT_properties(struct wmOperatorType *ot);
/* ***************************************** */
/* action_draw.c */
-void draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct ARegion *ar);
+void draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct ARegion *ar);
void draw_channel_strips(struct bAnimContext *ac, struct SpaceAction *saction, struct ARegion *ar);
void timeline_draw_cache(struct SpaceAction *saction, struct Object *ob, struct Scene *scene);
@@ -127,7 +127,7 @@ void ACTION_OT_layer_prev(struct wmOperatorType *ot);
void ACTION_OT_markers_make_local(struct wmOperatorType *ot);
-/* defines for snap keyframes
+/* defines for snap keyframes
* NOTE: keep in sync with eEditKeyframes_Snap (in ED_keyframes_edit.h)
*/
enum eActKeys_Snap_Mode {
@@ -137,7 +137,7 @@ enum eActKeys_Snap_Mode {
ACTKEYS_SNAP_NEAREST_MARKER,
};
-/* defines for mirror keyframes
+/* defines for mirror keyframes
* NOTE: keep in sync with eEditKeyframes_Mirror (in ED_keyframes_edit.h)
*/
enum eActKeys_Mirror_Mode {
@@ -146,7 +146,7 @@ enum eActKeys_Mirror_Mode {
ACTKEYS_MIRROR_XAXIS,
ACTKEYS_MIRROR_MARKER,
};
-
+
/* ***************************************** */
/* action_ops.c */
void action_operatortypes(void);
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index 718a4fd3c38..bf7f75db95c 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -53,7 +53,7 @@ void action_operatortypes(void)
{
/* view */
WM_operatortype_append(ACTION_OT_properties);
-
+
/* keyframes */
/* selection */
WM_operatortype_append(ACTION_OT_clickselect);
@@ -66,7 +66,7 @@ void action_operatortypes(void)
WM_operatortype_append(ACTION_OT_select_more);
WM_operatortype_append(ACTION_OT_select_less);
WM_operatortype_append(ACTION_OT_select_leftright);
-
+
/* editing */
WM_operatortype_append(ACTION_OT_snap);
WM_operatortype_append(ACTION_OT_mirror);
@@ -82,17 +82,17 @@ void action_operatortypes(void)
WM_operatortype_append(ACTION_OT_keyframe_insert);
WM_operatortype_append(ACTION_OT_copy);
WM_operatortype_append(ACTION_OT_paste);
-
+
WM_operatortype_append(ACTION_OT_new);
WM_operatortype_append(ACTION_OT_unlink);
-
+
WM_operatortype_append(ACTION_OT_push_down);
WM_operatortype_append(ACTION_OT_stash);
WM_operatortype_append(ACTION_OT_stash_and_create);
-
+
WM_operatortype_append(ACTION_OT_layer_next);
WM_operatortype_append(ACTION_OT_layer_prev);
-
+
WM_operatortype_append(ACTION_OT_previewrange_set);
WM_operatortype_append(ACTION_OT_view_all);
WM_operatortype_append(ACTION_OT_view_selected);
@@ -105,7 +105,7 @@ void ED_operatormacros_action(void)
{
wmOperatorType *ot;
wmOperatorTypeMacro *otmacro;
-
+
ot = WM_operatortype_append_macro("ACTION_OT_duplicate_move", "Duplicate",
"Make a copy of all selected keyframes and move them",
OPTYPE_UNDO | OPTYPE_REGISTER);
@@ -120,7 +120,7 @@ void ED_operatormacros_action(void)
static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
{
wmKeyMapItem *kmi;
-
+
/* action_select.c - selection tools */
/* click-select: keyframe (replace) */
kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0);
@@ -152,7 +152,7 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
RNA_boolean_set(kmi->ptr, "extend", true);
RNA_boolean_set(kmi->ptr, "column", false);
RNA_boolean_set(kmi->ptr, "channel", true);
-
+
/* click-select: left/right */
kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "extend", false);
@@ -160,71 +160,74 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", true);
RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_TEST);
-
+
kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "extend", false);
RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_LEFT);
kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "extend", false);
RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_RIGHT);
-
+
/* deselect all */
kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "invert", false);
kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "invert", true);
-
+
/* borderselect */
kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "axis_range", false);
kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "axis_range", true);
-
+
/* region select */
kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "deselect", false);
kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "deselect", true);
-
+
WM_keymap_add_item(keymap, "ACTION_OT_select_circle", CKEY, KM_PRESS, 0, 0);
-
+
/* column select */
RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_KEYS);
RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_CFRA);
RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_COLUMN);
RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_BETWEEN);
-
+
/* select more/less */
WM_keymap_add_item(keymap, "ACTION_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ACTION_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
-
+
/* select linked */
WM_keymap_add_item(keymap, "ACTION_OT_select_linked", LKEY, KM_PRESS, 0, 0);
-
-
+
+
/* action_edit.c */
/* jump to selected keyframes */
WM_keymap_add_item(keymap, "ACTION_OT_frame_jump", GKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* menu + single-step transform */
WM_keymap_add_item(keymap, "ACTION_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "ACTION_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0);
-
+
/* menu + set setting */
WM_keymap_add_item(keymap, "ACTION_OT_handle_type", VKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ACTION_OT_interpolation_type", TKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "ACTION_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0);
- WM_keymap_add_item(keymap, "ACTION_OT_keyframe_type", RKEY, KM_PRESS, 0, 0);
-
+ WM_keymap_add_item(keymap, "ACTION_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "ACTION_OT_keyframe_type", RKEY, KM_PRESS, 0, 0);
+
+ /* specials */
+ WM_keymap_add_menu(keymap, "DOPESHEET_MT_specials", WKEY, KM_PRESS, 0, 0);
+
/* destructive */
WM_keymap_add_item(keymap, "ACTION_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0);
-
+
WM_keymap_add_menu(keymap, "DOPESHEET_MT_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_menu(keymap, "DOPESHEET_MT_delete", DELKEY, KM_PRESS, 0, 0);
-
+
WM_keymap_add_item(keymap, "ACTION_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "ACTION_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0);
-
+
/* copy/paste */
WM_keymap_add_item(keymap, "ACTION_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ACTION_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
@@ -246,19 +249,19 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
WM_keymap_add_item(keymap, "ACTION_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ACTION_OT_view_frame", PAD0, KM_PRESS, 0, 0);
-
+
/* animation module */
/* channels list
* NOTE: these operators were originally for the channels list, but are added here too for convenience...
*/
WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0);
-
+
/* find (i.e. a shortcut for setting the name filter) */
WM_keymap_add_item(keymap, "ANIM_OT_channels_find", FKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* transform system */
transform_keymap_for_space(keyconf, keymap, SPACE_ACTION);
-
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_action");
@@ -271,22 +274,21 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
void action_keymap(wmKeyConfig *keyconf)
{
wmKeyMap *keymap;
-
+
/* keymap for all regions */
keymap = WM_keymap_find(keyconf, "Dopesheet Generic", SPACE_ACTION, 0);
-
+
/* region management... */
WM_keymap_add_item(keymap, "ACTION_OT_properties", NKEY, KM_PRESS, 0, 0);
-
-
+
+
/* channels */
- /* Channels are not directly handled by the Action Editor module, but are inherited from the Animation module.
+ /* Channels are not directly handled by the Action Editor module, but are inherited from the Animation module.
* All the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as these
* are all used for the Graph-Editor too.
*/
-
+
/* keyframes */
keymap = WM_keymap_find(keyconf, "Dopesheet", SPACE_ACTION, 0);
action_keymap_keyframes(keyconf, keymap);
}
-
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 2b974ac73d7..83bda4d63a5 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -89,22 +89,22 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditData ked = {{NULL}};
KeyframeEditFunc test_cb, sel_cb;
-
+
/* determine type-based settings */
if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
else
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
-
+
/* filter data */
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* init BezTriple looping data */
test_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
-
+
/* See if we should be selecting or deselecting */
if (test) {
for (ale = anim_data.first; ale; ale = ale->next) {
@@ -128,10 +128,10 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel)
}
}
}
-
+
/* convert sel to selectmode, and use that to get editor */
sel_cb = ANIM_editkeyframes_select(sel);
-
+
/* Now set the flags */
for (ale = anim_data.first; ale; ale = ale->next) {
if (ale->type == ANIMTYPE_GPLAYER)
@@ -139,9 +139,9 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel)
else if (ale->type == ANIMTYPE_MASKLAYER)
ED_masklayer_frame_select_set(ale->data, sel);
else
- ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL);
+ ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL);
}
-
+
/* Cleanup */
ANIM_animdata_freelist(&anim_data);
}
@@ -151,37 +151,37 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel)
static int actkeys_deselectall_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* 'standard' behavior - check if selected, then apply relevant selection */
if (RNA_boolean_get(op->ptr, "invert"))
deselect_action_keys(&ac, 0, SELECT_INVERT);
else
deselect_action_keys(&ac, 1, SELECT_ADD);
-
+
/* set notifier that keyframe selection have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_select_all_toggle(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Select All";
ot->idname = "ACTION_OT_select_all_toggle";
ot->description = "Toggle selection of all keyframes";
-
+
/* api callbacks */
ot->exec = actkeys_deselectall_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
@@ -208,39 +208,39 @@ static void borderselect_action(bAnimContext *ac, const rcti rect, short mode, s
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditData ked;
KeyframeEditFunc ok_cb, select_cb;
View2D *v2d = &ac->ar->v2d;
rctf rectf;
float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF(ac));
-
+
/* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */
UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin + 2, &rectf.xmin, &rectf.ymin);
UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax - 2, &rectf.xmax, &rectf.ymax);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* get beztriple editing/validation funcs */
select_cb = ANIM_editkeyframes_select(selectmode);
-
+
if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS))
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
else
ok_cb = NULL;
-
+
/* init editing data */
memset(&ked, 0, sizeof(KeyframeEditData));
-
+
/* loop over data, doing border select */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
/* get new vertical minimum extent of channel */
ymin = ymax - ACHANNEL_STEP(ac);
-
+
/* set horizontal range (if applicable) */
if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) {
/* if channel is mapped in NLA, apply correction */
@@ -255,7 +255,7 @@ static void borderselect_action(bAnimContext *ac, const rcti rect, short mode, s
ked.f2 = rectf.xmax;
}
}
-
+
/* perform vertical suitability check (if applicable) */
if ((mode == ACTKEYS_BORDERSEL_FRAMERANGE) ||
!((ymax < rectf.ymin) || (ymin > rectf.ymax)))
@@ -293,11 +293,11 @@ static void borderselect_action(bAnimContext *ac, const rcti rect, short mode, s
break;
}
}
-
+
/* set minimum extent to be the maximum of the next channel */
ymax = ymin;
}
-
+
/* cleanup */
ANIM_animdata_freelist(&anim_data);
}
@@ -311,7 +311,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op)
short mode = 0, selectmode = 0;
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
@@ -320,7 +320,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op)
if (!extend) {
deselect_action_keys(&ac, 1, SELECT_SUBTRACT);
}
-
+
/* get settings from operator */
WM_operator_properties_border_to_rcti(op, &rect);
@@ -330,10 +330,10 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op)
else {
selectmode = SELECT_SUBTRACT;
}
-
+
/* selection 'mode' depends on whether borderselect region only matters on one axis */
if (RNA_boolean_get(op->ptr, "axis_range")) {
- /* mode depends on which axis of the range is larger to determine which axis to use
+ /* mode depends on which axis of the range is larger to determine which axis to use
* - checking this in region-space is fine, as it's fundamentally still going to be a different rect size
* - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
* used for tweaking timing when "blocking", while channels is not that useful...
@@ -343,17 +343,17 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op)
else
mode = ACTKEYS_BORDERSEL_CHANNELS;
}
- else
+ else
mode = ACTKEYS_BORDERSEL_ALLKEYS;
-
+
/* apply borderselect action */
borderselect_action(&ac, rect, mode, selectmode);
-
+
/* set notifier that keyframe selection have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
-}
+}
void ACTION_OT_select_border(wmOperatorType *ot)
{
@@ -361,27 +361,27 @@ void ACTION_OT_select_border(wmOperatorType *ot)
ot->name = "Border Select";
ot->idname = "ACTION_OT_select_border";
ot->description = "Select all keyframes within the specified region";
-
+
/* api callbacks */
ot->invoke = WM_gesture_border_invoke;
ot->exec = actkeys_borderselect_exec;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
-
+
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* rna */
WM_operator_properties_gesture_border_select(ot);
-
+
ot->prop = RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", "");
}
/* ******************** Region Select Operators ***************************** */
/* "Region Select" operators include the Lasso and Circle Select operators.
- * These two ended up being lumped together, as it was easier in the
+ * These two ended up being lumped together, as it was easier in the
* original Graph Editor implementation of these to do it this way.
*/
@@ -390,24 +390,24 @@ static void region_select_action_keys(bAnimContext *ac, const rctf *rectf_view,
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditData ked;
KeyframeEditFunc ok_cb, select_cb;
View2D *v2d = &ac->ar->v2d;
rctf rectf, scaled_rectf;
float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF(ac));
-
+
/* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */
UI_view2d_region_to_view_rctf(v2d, rectf_view, &rectf);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* get beztriple editing/validation funcs */
select_cb = ANIM_editkeyframes_select(selectmode);
ok_cb = ANIM_editkeyframes_ok(mode);
-
+
/* init editing data */
memset(&ked, 0, sizeof(KeyframeEditData));
if (mode == BEZT_OK_CHANNEL_LASSO) {
@@ -423,17 +423,17 @@ static void region_select_action_keys(bAnimContext *ac, const rctf *rectf_view,
else {
ked.data = &scaled_rectf;
}
-
+
/* loop over data, doing region select */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
/* get new vertical minimum extent of channel */
ymin = ymax - ACHANNEL_STEP(ac);
-
+
/* compute midpoint of channel (used for testing if the key is in the region or not) */
ked.channel_y = ymin + ACHANNEL_HEIGHT_HALF(ac);
-
+
/* if channel is mapped in NLA, apply correction
* - Apply to the bounds being checked, not all the keyframe points,
* to avoid having scaling everything
@@ -450,16 +450,16 @@ static void region_select_action_keys(bAnimContext *ac, const rctf *rectf_view,
ked.f1 = rectf.xmin;
ked.f2 = rectf.xmax;
}
-
+
/* Update values for scaled_rectf - which is used to compute the mapping in the callbacks
- * NOTE: Since summary tracks need late-binding remapping, the callbacks may overwrite these
+ * NOTE: Since summary tracks need late-binding remapping, the callbacks may overwrite these
* with the properly remapped ked.f1/f2 values, when needed
*/
scaled_rectf.xmin = ked.f1;
scaled_rectf.xmax = ked.f2;
scaled_rectf.ymin = ymin;
scaled_rectf.ymax = ymax;
-
+
/* perform vertical suitability check (if applicable) */
if ((mode == ACTKEYS_BORDERSEL_FRAMERANGE) ||
!((ymax < rectf.ymin) || (ymin > rectf.ymax)))
@@ -501,59 +501,59 @@ static void region_select_action_keys(bAnimContext *ac, const rctf *rectf_view,
break;
}
}
-
+
/* set minimum extent to be the maximum of the next channel */
ymax = ymin;
}
-
+
/* cleanup */
ANIM_animdata_freelist(&anim_data);
}
-
+
/* ----------------------------------- */
-
+
static int actkeys_lassoselect_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
KeyframeEdit_LassoData data_lasso;
rcti rect;
rctf rect_fl;
-
+
short selectmode;
bool extend;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
data_lasso.rectf_view = &rect_fl;
data_lasso.mcords = WM_gesture_lasso_path_to_array(C, op, &data_lasso.mcords_tot);
if (data_lasso.mcords == NULL)
return OPERATOR_CANCELLED;
-
+
/* clear all selection if not extending selection */
extend = RNA_boolean_get(op->ptr, "extend");
if (!extend)
deselect_action_keys(&ac, 1, SELECT_SUBTRACT);
-
+
if (!RNA_boolean_get(op->ptr, "deselect"))
selectmode = SELECT_ADD;
else
selectmode = SELECT_SUBTRACT;
-
+
/* get settings from operator */
BLI_lasso_boundbox(&rect, data_lasso.mcords, data_lasso.mcords_tot);
BLI_rctf_rcti_copy(&rect_fl, &rect);
-
+
/* apply borderselect action */
region_select_action_keys(&ac, &rect_fl, BEZT_OK_CHANNEL_LASSO, selectmode, &data_lasso);
-
+
MEM_freeN((void *)data_lasso.mcords);
-
+
/* send notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -563,17 +563,17 @@ void ACTION_OT_select_lasso(wmOperatorType *ot)
ot->name = "Lasso Select";
ot->description = "Select keyframe points using lasso selection";
ot->idname = "ACTION_OT_select_lasso";
-
+
/* api callbacks */
ot->invoke = WM_gesture_lasso_invoke;
ot->modal = WM_gesture_lasso_modal;
ot->exec = actkeys_lassoselect_exec;
ot->poll = ED_operator_action_active;
ot->cancel = WM_gesture_lasso_cancel;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
-
+
/* properties */
WM_operator_properties_gesture_lasso_select(ot);
}
@@ -585,10 +585,10 @@ static int action_circle_select_exec(bContext *C, wmOperator *op)
bAnimContext ac;
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const short selectmode = select ? SELECT_ADD : SELECT_SUBTRACT;
-
+
KeyframeEdit_CircleData data = {0};
rctf rect_fl;
-
+
float x = RNA_int_get(op->ptr, "x");
float y = RNA_int_get(op->ptr, "y");
float radius = RNA_int_get(op->ptr, "radius");
@@ -596,23 +596,23 @@ static int action_circle_select_exec(bContext *C, wmOperator *op)
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
data.mval[0] = x;
data.mval[1] = y;
data.radius_squared = radius * radius;
data.rectf_view = &rect_fl;
-
+
rect_fl.xmin = x - radius;
rect_fl.xmax = x + radius;
rect_fl.ymin = y - radius;
rect_fl.ymax = y + radius;
-
+
/* apply region select action */
region_select_action_keys(&ac, &rect_fl, BEZT_OK_CHANNEL_CIRCLE, selectmode, &data);
-
+
/* send notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -621,13 +621,13 @@ void ACTION_OT_select_circle(wmOperatorType *ot)
ot->name = "Circle Select";
ot->description = "Select keyframe points using circle selection";
ot->idname = "ACTION_OT_select_circle";
-
+
ot->invoke = WM_gesture_circle_invoke;
ot->modal = WM_gesture_circle_modal;
ot->exec = action_circle_select_exec;
ot->poll = ED_operator_action_active;
ot->cancel = WM_gesture_circle_cancel;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
@@ -652,7 +652,7 @@ static const EnumPropertyItem prop_column_select_types[] = {
{0, NULL, 0, NULL, NULL}
};
-/* ------------------- */
+/* ------------------- */
/* Selects all visible keyframes between the specified markers */
/* TODO, this is almost an _exact_ duplicate of a function of the same name in graph_select.c
@@ -662,31 +662,31 @@ static void markers_selectkeys_between(bAnimContext *ac)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditFunc ok_cb, select_cb;
KeyframeEditData ked = {{NULL}};
float min, max;
-
+
/* get extreme markers */
ED_markers_get_minmax(ac->markers, 1, &min, &max);
min -= 0.5f;
max += 0.5f;
-
+
/* get editing funcs + data */
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
select_cb = ANIM_editkeyframes_select(SELECT_ADD);
ked.f1 = min;
ked.f2 = max;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* select keys in-between */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
@@ -702,7 +702,7 @@ static void markers_selectkeys_between(bAnimContext *ac)
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
}
}
-
+
/* Cleanup */
ANIM_animdata_freelist(&anim_data);
}
@@ -714,52 +714,52 @@ static void columnselect_action_keys(bAnimContext *ac, short mode)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
Scene *scene = ac->scene;
CfraElem *ce;
KeyframeEditFunc select_cb, ok_cb;
KeyframeEditData ked = {{NULL}};
-
+
/* build list of columns */
switch (mode) {
case ACTKEYS_COLUMNSEL_KEYS: /* list of selected keys */
if (ac->datatype == ANIMCONT_GPENCIL) {
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next)
ED_gplayer_make_cfra_list(ale->data, &ked.list, 1);
}
else {
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next)
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL);
}
ANIM_animdata_freelist(&anim_data);
break;
-
+
case ACTKEYS_COLUMNSEL_CFRA: /* current frame */
/* make a single CfraElem for storing this */
ce = MEM_callocN(sizeof(CfraElem), "cfraElem");
BLI_addtail(&ked.list, ce);
-
+
ce->cfra = (float)CFRA;
break;
-
+
case ACTKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */
ED_markers_make_cfra_list(ac->markers, &ked.list, SELECT);
break;
-
+
default: /* invalid option */
return;
}
-
+
/* set up BezTriple edit callbacks */
select_cb = ANIM_editkeyframes_select(SELECT_ADD);
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME);
-
+
/* loop through all of the keys and select additional keyframes
* based on the keys found to be selected above
*/
@@ -768,10 +768,10 @@ static void columnselect_action_keys(bAnimContext *ac, short mode)
else
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
/* loop over cfraelems (stored in the KeyframeEditData->list)
* - we need to do this here, as we can apply fewer NLA-mapping conversions
*/
@@ -781,7 +781,7 @@ static void columnselect_action_keys(bAnimContext *ac, short mode)
ked.f1 = BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP);
else
ked.f1 = ce->cfra;
-
+
/* select elements with frame number matching cfraelem */
if (ale->type == ANIMTYPE_GPLAYER)
ED_gpencil_select_frame(ale->data, ce->cfra, SELECT_ADD);
@@ -791,7 +791,7 @@ static void columnselect_action_keys(bAnimContext *ac, short mode)
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
}
}
-
+
/* free elements */
BLI_freelistN(&ked.list);
ANIM_animdata_freelist(&anim_data);
@@ -803,39 +803,39 @@ static int actkeys_columnselect_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* action to take depends on the mode */
mode = RNA_enum_get(op->ptr, "mode");
-
+
if (mode == ACTKEYS_COLUMNSEL_MARKERS_BETWEEN)
markers_selectkeys_between(&ac);
else
columnselect_action_keys(&ac, mode);
-
+
/* set notifier that keyframe selection have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_select_column(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Select All";
ot->idname = "ACTION_OT_select_column";
ot->description = "Select all keyframes on the specified frame(s)";
-
+
/* api callbacks */
ot->exec = actkeys_columnselect_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
ot->prop = RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", "");
}
@@ -845,38 +845,38 @@ void ACTION_OT_select_column(wmOperatorType *ot)
static int actkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditFunc ok_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
KeyframeEditFunc sel_cb = ANIM_editkeyframes_select(SELECT_ADD);
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* loop through all of the keys and select additional keyframes based on these */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
-
+
/* check if anything selected? */
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) {
/* select every keyframe in this curve then */
ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL);
}
}
-
+
/* Cleanup */
ANIM_animdata_freelist(&anim_data);
-
+
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -886,11 +886,11 @@ void ACTION_OT_select_linked(wmOperatorType *ot)
ot->name = "Select Linked";
ot->idname = "ACTION_OT_select_linked";
ot->description = "Select keyframes occurring in the same F-Curves as selected ones";
-
+
/* api callbacks */
ot->exec = actkeys_select_linked_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -903,37 +903,37 @@ static void select_moreless_action_keys(bAnimContext *ac, short mode)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditData ked = {{NULL}};
KeyframeEditFunc build_cb;
-
-
+
+
/* init selmap building data */
build_cb = ANIM_editkeyframes_buildselmap(mode);
-
+
/* loop through all of the keys and select additional keyframes based on these */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
-
+
/* only continue if F-Curve has keyframes */
if (fcu->bezt == NULL)
continue;
-
+
/* build up map of whether F-Curve's keyframes should be selected or not */
ked.data = MEM_callocN(fcu->totvert, "selmap actEdit more");
ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, build_cb, NULL);
-
+
/* based on this map, adjust the selection status of the keyframes */
ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, bezt_selmap_flush, NULL);
-
+
/* free the selmap used here */
MEM_freeN(ked.data);
ked.data = NULL;
}
-
+
/* Cleanup */
ANIM_animdata_freelist(&anim_data);
}
@@ -943,17 +943,17 @@ static void select_moreless_action_keys(bAnimContext *ac, short mode)
static int actkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* perform select changes */
select_moreless_action_keys(&ac, SELMAP_MORE);
-
+
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -963,11 +963,11 @@ void ACTION_OT_select_more(wmOperatorType *ot)
ot->name = "Select More";
ot->idname = "ACTION_OT_select_more";
ot->description = "Select keyframes beside already selected ones";
-
+
/* api callbacks */
ot->exec = actkeys_select_more_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -977,17 +977,17 @@ void ACTION_OT_select_more(wmOperatorType *ot)
static int actkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* perform select changes */
select_moreless_action_keys(&ac, SELMAP_LESS);
-
+
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -997,11 +997,11 @@ void ACTION_OT_select_less(wmOperatorType *ot)
ot->name = "Select Less";
ot->idname = "ACTION_OT_select_less";
ot->description = "Deselect keyframes on ends of selection islands";
-
+
/* api callbacks */
ot->exec = actkeys_select_less_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1024,25 +1024,25 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditFunc ok_cb, select_cb;
KeyframeEditData ked = {{NULL}};
Scene *scene = ac->scene;
-
+
/* if select mode is replace, deselect all keyframes (and channels) first */
if (select_mode == SELECT_REPLACE) {
select_mode = SELECT_ADD;
-
+
/* - deselect all other keyframes, so that just the newly selected remain
* - channels aren't deselected, since we don't re-select any as a consequence
*/
deselect_action_keys(ac, 0, SELECT_SUBTRACT);
}
-
+
/* set callbacks and editing data */
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
select_cb = ANIM_editkeyframes_select(select_mode);
-
+
if (leftright == ACTKEYS_LRSEL_LEFT) {
ked.f1 = MINAFRAMEF;
ked.f2 = (float)(CFRA + 0.1f);
@@ -1051,18 +1051,18 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se
ked.f1 = (float)(CFRA - 0.1f);
ked.f2 = MAXFRAMEF;
}
-
+
/* filter data */
if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
else
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* select keys */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
@@ -1075,15 +1075,15 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se
else
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
}
-
+
/* Sync marker support */
if (select_mode == SELECT_ADD) {
SpaceAction *saction = (SpaceAction *)ac->sl;
-
+
if ((saction) && (saction->flag & SACTION_MARKERS_MOVE)) {
ListBase *markers = ED_animcontext_get_markers(ac);
TimeMarker *marker;
-
+
for (marker = markers->first; marker; marker = marker->next) {
if (((leftright == ACTKEYS_LRSEL_LEFT) && (marker->frame < CFRA)) ||
((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= CFRA)))
@@ -1108,28 +1108,28 @@ static int actkeys_select_leftright_exec(bContext *C, wmOperator *op)
bAnimContext ac;
short leftright = RNA_enum_get(op->ptr, "mode");
short selectmode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* select mode is either replace (deselect all, then add) or add/extend */
if (RNA_boolean_get(op->ptr, "extend"))
selectmode = SELECT_INVERT;
else
selectmode = SELECT_REPLACE;
-
+
/* if "test" mode is set, we don't have any info to set this with */
if (leftright == ACTKEYS_LRSEL_TEST)
return OPERATOR_CANCELLED;
-
+
/* do the selecting now */
actkeys_select_leftright(&ac, leftright, selectmode);
-
+
/* set notifier that keyframe selection (and channels too) have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1137,11 +1137,11 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wm
{
bAnimContext ac;
short leftright = RNA_enum_get(op->ptr, "mode");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* handle mode-based testing */
if (leftright == ACTKEYS_LRSEL_TEST) {
Scene *scene = ac.scene;
@@ -1156,7 +1156,7 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wm
else
RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_RIGHT);
}
-
+
/* perform selection */
return actkeys_select_leftright_exec(C, op);
}
@@ -1164,24 +1164,24 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wm
void ACTION_OT_select_leftright(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Select Left/Right";
ot->idname = "ACTION_OT_select_leftright";
ot->description = "Select keyframes to the left or the right of the current frame";
-
+
/* api callbacks */
ot->invoke = actkeys_select_leftright_invoke;
ot->exec = actkeys_select_leftright_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "mode", prop_actkeys_leftright_select_types, ACTKEYS_LRSEL_TEST, "Mode", "");
RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
-
+
prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", "");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
@@ -1193,24 +1193,24 @@ void ACTION_OT_select_leftright(wmOperatorType *ot)
* - 3) column select all keyframes in frame under mouse - CTRL modifier
* - 4) all keyframes in channel under mouse - CTRL+ALT modifiers
*
- * In addition to these basic options, the SHIFT modifier can be used to toggle the
+ * In addition to these basic options, the SHIFT modifier can be used to toggle the
* selection mode between replacing the selection (without) and inverting the selection (with).
*/
/* ------------------- */
-
+
/* option 1) select keyframe directly under mouse */
static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short select_mode, float selx)
{
KeyframeEditData ked = {{NULL}};
KeyframeEditFunc select_cb, ok_cb;
-
+
/* get functions for selecting keyframes */
select_cb = ANIM_editkeyframes_select(select_mode);
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME);
ked.f1 = selx;
ked.iterflags |= KED_F1_NLA_UNMAP;
-
+
/* select the nominated keyframe on the given frame */
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gpencil_select_frame(ale->data, selx, select_mode);
@@ -1224,10 +1224,10 @@ static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short s
{
ListBase anim_data = {NULL, NULL};
int filter;
-
+
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gpencil_select_frame(ale->data, selx, select_mode);
@@ -1236,7 +1236,7 @@ static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short s
ED_mask_select_frame(ale->data, selx, select_mode);
}
}
-
+
ANIM_animdata_freelist(&anim_data);
}
else {
@@ -1254,14 +1254,14 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditFunc select_cb, ok_cb;
KeyframeEditData ked = {{NULL}};
-
+
/* set up BezTriple edit callbacks */
select_cb = ANIM_editkeyframes_select(select_mode);
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME);
-
+
/* loop through all of the keys and select additional keyframes
* based on the keys found to be selected above
*/
@@ -1270,16 +1270,16 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se
else
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
/* set frame for validation callback to refer to */
if (adt)
ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP);
else
ked.f1 = selx;
-
+
/* select elements with frame number matching cfra */
if (ale->type == ANIMTYPE_GPLAYER)
ED_gpencil_select_frame(ale->key_data, selx, select_mode);
@@ -1288,7 +1288,7 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se
else
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
}
-
+
/* free elements */
BLI_freelistN(&ked.list);
ANIM_animdata_freelist(&anim_data);
@@ -1298,10 +1298,10 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se
static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, short select_mode)
{
KeyframeEditFunc select_cb;
-
+
/* get functions for selecting keyframes */
select_cb = ANIM_editkeyframes_select(select_mode);
-
+
/* select all keyframes in this channel */
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gpencil_select_frames(ale->data, select_mode);
@@ -1315,10 +1315,10 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s
{
ListBase anim_data = {NULL, NULL};
int filter;
-
+
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gpencil_select_frames(ale->data, select_mode);
@@ -1327,7 +1327,7 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s
ED_mask_select_frames(ale->data, select_mode);
}
}
-
+
ANIM_animdata_freelist(&anim_data);
}
else {
@@ -1335,7 +1335,7 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s
}
}
}
-
+
/* ------------------- */
static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_mode, bool column, bool same_channel)
@@ -1344,7 +1344,7 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_
DLRBT_Tree anim_keys;
bAnimListElem *ale;
int filter;
-
+
View2D *v2d = &ac->ar->v2d;
bDopeSheet *ads = NULL;
int channel_index;
@@ -1354,28 +1354,28 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_
float key_hsize;
float x, y;
rctf rectf;
-
+
/* get dopesheet info */
if (ac->datatype == ANIMCONT_DOPESHEET)
ads = ac->data;
-
+
/* use View2D to determine the index of the channel (i.e a row in the list) where keyframe was */
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
UI_view2d_listview_view_to_cell(v2d, 0, ACHANNEL_STEP(ac), 0, (float)ACHANNEL_HEIGHT_HALF(ac), x, y, NULL, &channel_index);
-
+
/* x-range to check is +/- 7px for standard keyframe under standard dpi/y-scale (in screen/region-space),
* on either side of mouse click (size of keyframe icon)
*/
key_hsize = ACHANNEL_HEIGHT(ac) * 0.8f; /* standard channel height (to allow for some slop) */
key_hsize = roundf(key_hsize / 2.0f); /* half-size (for either side), but rounded up to nearest int (for easier targetting) */
-
+
UI_view2d_region_to_view(v2d, mval[0] - (int)key_hsize, mval[1], &rectf.xmin, &rectf.ymin);
UI_view2d_region_to_view(v2d, mval[0] + (int)key_hsize, mval[1], &rectf.xmax, &rectf.ymax);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* try to get channel */
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
@@ -1388,10 +1388,10 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_
/* found match - must return here... */
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
ActKeyColumn *ak, *akn = NULL;
-
+
/* make list of keyframes */
BLI_dlrbTree_init(&anim_keys);
-
+
if (ale->key_data) {
switch (ale->datatype) {
case ALE_SCE:
@@ -1443,7 +1443,7 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_
/* start from keyframe at root of BST, traversing until we find one within the range that was clicked on */
for (ak = anim_keys.root; ak; ak = akn) {
if (IN_RANGE(ak->cfra, rectf.xmin, rectf.xmax)) {
- /* set the frame to use, and apply inverse-correction for NLA-mapping
+ /* set the frame to use, and apply inverse-correction for NLA-mapping
* so that the frame will get selected by the selection functions without
* requiring to map each frame once again...
*/
@@ -1457,41 +1457,41 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_
else
akn = ak->left;
}
-
+
/* remove active channel from list of channels for separate treatment (since it's needed later on) */
BLI_remlink(&anim_data, ale);
-
+
/* cleanup temporary lists */
BLI_dlrbTree_free(&anim_keys);
-
+
/* free list of channels, since it's not used anymore */
ANIM_animdata_freelist(&anim_data);
}
-
+
/* for replacing selection, firstly need to clear existing selection */
if (select_mode == SELECT_REPLACE) {
/* reset selection mode for next steps */
select_mode = SELECT_ADD;
-
+
/* deselect all keyframes */
deselect_action_keys(ac, 0, SELECT_SUBTRACT);
-
+
/* highlight channel clicked on */
if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET)) {
/* deselect all other channels first */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
-
+
/* Highlight Action-Group or F-Curve? */
if (ale && ale->data) {
if (ale->type == ANIMTYPE_GROUP) {
bActionGroup *agrp = ale->data;
-
+
agrp->flag |= AGRP_SELECTED;
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
}
else if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
FCurve *fcu = ale->data;
-
+
fcu->flag |= FCURVE_SELECTED;
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ale->type);
}
@@ -1500,11 +1500,11 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_
else if (ac->datatype == ANIMCONT_GPENCIL) {
/* deselect all other channels first */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
-
+
/* Highlight GPencil Layer */
if ((ale && ale->data) && (ale->type == ANIMTYPE_GPLAYER)) {
bGPDlayer *gpl = ale->data;
-
+
gpl->flag |= GP_LAYER_SELECT;
//gpencil_layer_setactive(gpd, gpl);
}
@@ -1522,28 +1522,28 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_
}
}
}
-
+
/* only select keyframes if we clicked on a valid channel and hit something */
if (ale) {
if (found) {
/* apply selection to keyframes */
if (column) {
- /* select all keyframes in the same frame as the one we hit on the active channel
+ /* select all keyframes in the same frame as the one we hit on the active channel
* [T41077]: "frame" not "selx" here (i.e. no NLA corrections yet) as the code here
- * does that itself again as it needs to work on multiple datablocks
+ * does that itself again as it needs to work on multiple datablocks
*/
actkeys_mselect_column(ac, select_mode, frame);
}
else if (same_channel) {
/* select all keyframes in the active channel */
- actkeys_mselect_channel_only(ac, ale, select_mode);
+ actkeys_mselect_channel_only(ac, ale, select_mode);
}
else {
/* select the nominated keyframe on the given frame */
actkeys_mselect_single(ac, ale, select_mode, selx);
}
}
-
+
/* free this channel */
MEM_freeN(ale);
}
@@ -1556,11 +1556,11 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent
/* ARegion *ar; */ /* UNUSED */
short selectmode;
bool column, channel;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get useful pointers from animation context data */
/* ar = ac.ar; */ /* UNUSED */
@@ -1569,48 +1569,48 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent
selectmode = SELECT_INVERT;
else
selectmode = SELECT_REPLACE;
-
+
/* column selection */
column = RNA_boolean_get(op->ptr, "column");
channel = RNA_boolean_get(op->ptr, "channel");
-
+
/* select keyframe(s) based upon mouse position*/
mouse_action_keys(&ac, event->mval, selectmode, column, channel);
-
+
/* set notifier that keyframe selection (and channels too) have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
-
+
/* for tweak grab to work */
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
}
-
+
void ACTION_OT_clickselect(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Mouse Select Keys";
ot->idname = "ACTION_OT_clickselect";
ot->description = "Select keyframes by clicking on them";
-
+
/* callbacks */
ot->invoke = actkeys_clickselect_invoke;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
-
+
/* properties */
- prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select",
+ prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select",
"Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-
- prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select",
+
+ prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select",
"Select all keyframes that occur on the same frame as the one under the mouse"); // ALTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-
- prop = RNA_def_boolean(ot->srna, "channel", 0, "Only Channel",
+
+ prop = RNA_def_boolean(ot->srna, "channel", 0, "Only Channel",
"Select all the keyframes in the channel under the mouse"); // CTRLKEY + ALTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index cb826d86a21..e130ea9369c 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -69,24 +69,24 @@
ARegion *action_has_buttons_region(ScrArea *sa)
{
ARegion *ar, *arnew;
-
+
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
if (ar) return ar;
-
+
/* add subdiv level; after main */
ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
-
+
/* is error! */
if (ar == NULL) return NULL;
-
+
arnew = MEM_callocN(sizeof(ARegion), "buttons for action");
-
+
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
arnew->regiontype = RGN_TYPE_UI;
arnew->alignment = RGN_ALIGN_RIGHT;
-
+
arnew->flag = RGN_FLAG_HIDDEN;
-
+
return arnew;
}
@@ -96,62 +96,62 @@ static SpaceLink *action_new(const ScrArea *sa, const Scene *scene)
{
SpaceAction *saction;
ARegion *ar;
-
+
saction = MEM_callocN(sizeof(SpaceAction), "initaction");
saction->spacetype = SPACE_ACTION;
-
+
saction->autosnap = SACTSNAP_FRAME;
saction->mode = SACTCONT_DOPESHEET;
-
+
saction->ads.filterflag |= ADS_FILTER_SUMMARY;
-
+
/* enable all cache display */
saction->cache_display |= TIME_CACHE_DISPLAY;
saction->cache_display |= (TIME_CACHE_SOFTBODY | TIME_CACHE_PARTICLES);
saction->cache_display |= (TIME_CACHE_CLOTH | TIME_CACHE_SMOKE | TIME_CACHE_DYNAMICPAINT);
saction->cache_display |= TIME_CACHE_RIGIDBODY;
-
+
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for action");
-
+
BLI_addtail(&saction->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_BOTTOM;
-
+
/* channel list region */
ar = MEM_callocN(sizeof(ARegion), "channel region for action");
BLI_addtail(&saction->regionbase, ar);
ar->regiontype = RGN_TYPE_CHANNELS;
ar->alignment = RGN_ALIGN_LEFT;
-
+
/* only need to set scroll settings, as this will use 'listview' v2d configuration */
ar->v2d.scroll = V2D_SCROLL_BOTTOM;
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
-
+
/* ui buttons */
ar = MEM_callocN(sizeof(ARegion), "buttons region for action");
-
+
BLI_addtail(&saction->regionbase, ar);
ar->regiontype = RGN_TYPE_UI;
ar->alignment = RGN_ALIGN_RIGHT;
ar->flag = RGN_FLAG_HIDDEN;
-
+
/* main region */
ar = MEM_callocN(sizeof(ARegion), "main region for action");
-
+
BLI_addtail(&saction->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
-
+
ar->v2d.tot.xmin = (float)(SFRA - 10);
ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
ar->v2d.tot.xmax = (float)(EFRA + 10);
ar->v2d.tot.ymax = 0.0f;
-
+
ar->v2d.cur = ar->v2d.tot;
-
+
ar->v2d.min[0] = 0.0f;
ar->v2d.min[1] = 0.0f;
-
+
ar->v2d.max[0] = MAXFRAMEF;
ar->v2d.max[1] = FLT_MAX;
@@ -163,13 +163,13 @@ static SpaceLink *action_new(const ScrArea *sa, const Scene *scene)
ar->v2d.keepofs = V2D_KEEPOFS_Y;
ar->v2d.align = V2D_ALIGN_NO_POS_Y;
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
-
+
return (SpaceLink *)saction;
}
/* not spacelink itself */
static void action_free(SpaceLink *UNUSED(sl))
-{
+{
// SpaceAction *saction = (SpaceAction *) sl;
}
@@ -178,16 +178,16 @@ static void action_free(SpaceLink *UNUSED(sl))
static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
{
SpaceAction *saction = sa->spacedata.first;
-
+
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
}
static SpaceLink *action_duplicate(SpaceLink *sl)
{
SpaceAction *sactionn = MEM_dupallocN(sl);
-
+
/* clear or remove stuff from old */
-
+
return (SpaceLink *)sactionn;
}
@@ -197,9 +197,9 @@ static SpaceLink *action_duplicate(SpaceLink *sl)
static void action_main_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
-
+
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
-
+
/* own keymap */
keymap = WM_keymap_find(wm->defaultconf, "Dopesheet", SPACE_ACTION, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
@@ -220,44 +220,44 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
short marker_flag = 0;
short cfra_flag = 0;
short unit = 0;
-
+
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
glClear(GL_COLOR_BUFFER_BIT);
-
+
UI_view2d_view_ortho(v2d);
-
+
/* time grid */
unit = (saction->flag & SACTION_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
UI_view2d_grid_free(grid);
-
+
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
-
+
/* start and end frame */
ANIM_draw_framerange(scene, v2d);
-
+
/* data */
if (ANIM_animdata_get_context(C, &ac)) {
draw_channel_strips(&ac, saction, ar);
}
-
+
/* current frame */
if (saction->flag & SACTION_DRAWTIME) cfra_flag |= DRAWCFRA_UNIT_SECONDS;
ANIM_draw_cfra(C, v2d, cfra_flag);
-
+
/* markers */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
-
+
marker_flag = ((ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0) | DRAW_MARKERS_MARGIN;
ED_markers_draw(C, marker_flag);
-
+
/* caches */
if (saction->mode == SACTCONT_TIMELINE) {
timeline_draw_cache(saction, obact, scene);
}
-
+
/* preview range */
UI_view2d_view_ortho(v2d);
ANIM_draw_previewrange(C, v2d, 0);
@@ -265,15 +265,15 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
/* callback */
UI_view2d_view_ortho(v2d);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
-
+
/* reset view matrix */
UI_view2d_view_restore(C);
-
+
/* scrollers */
scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
-
+
/* draw current frame number-indicator on top of scrollers */
if ((saction->flag & SACTION_NODRAWCFRANUM) == 0) {
UI_view2d_view_orthoSpecial(ar, v2d, 1);
@@ -285,16 +285,18 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
static void action_channel_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
-
+
/* ensure the 2d view sync works - main region has bottom scroller */
ar->v2d.scroll = V2D_SCROLL_BOTTOM;
-
+
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
-
+
/* own keymap */
keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
-
+
+ WM_keymap_add_menu(keymap, "DOPESHEET_MT_specials_channels", WKEY, KM_PRESS, 0, 0);
+
keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
@@ -304,21 +306,21 @@ static void action_channel_region_draw(const bContext *C, ARegion *ar)
/* draw entirely, view changes should be handled here */
bAnimContext ac;
View2D *v2d = &ar->v2d;
-
+
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
glClear(GL_COLOR_BUFFER_BIT);
-
+
UI_view2d_view_ortho(v2d);
-
+
/* data */
if (ANIM_animdata_get_context(C, &ac)) {
draw_channel_names((bContext *)C, &ac, ar);
}
-
+
/* reset view matrix */
UI_view2d_view_restore(C);
-
+
/* no scrollers here */
}
@@ -393,7 +395,7 @@ static void saction_channel_region_message_subscribe(
.user_data = ar,
.notify = ED_region_do_msg_notify_tag_redraw,
};
-
+
/* All dopesheet filter settings, etc. affect the drawing of this editor,
* also same applies for all animation-related datatypes that may appear here,
* so just whitelist the entire structs for updates
@@ -402,13 +404,13 @@ static void saction_channel_region_message_subscribe(
wmMsgParams_RNA msg_key_params = {{{0}}};
StructRNA *type_array[] = {
&RNA_DopeSheet, /* dopesheet filters */
-
+
&RNA_ActionGroup, /* channel groups */
-
+
&RNA_FCurve, /* F-Curve */
&RNA_Keyframe,
&RNA_FCurveSample,
-
+
&RNA_GreasePencil, /* Grease Pencil */
&RNA_GPencilLayer,
&RNA_GPencilFrame,
@@ -518,7 +520,7 @@ static void saction_main_region_message_subscribe(
WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
}
}
-
+
/* Now run the general "channels region" one - since channels and main should be in sync */
saction_channel_region_message_subscribe(C, workspace, scene, screen, sa, ar, mbus);
}
@@ -529,7 +531,7 @@ static void action_listener(
WorkSpace *UNUSED(workspace))
{
SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
-
+
/* context changes */
switch (wmn->category) {
case NC_GPENCIL:
@@ -550,7 +552,7 @@ static void action_listener(
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
ED_area_tag_refresh(sa);
}
- /* autocolor only really needs to change when channels are added/removed, or previously hidden stuff appears
+ /* autocolor only really needs to change when channels are added/removed, or previously hidden stuff appears
* (assume for now that if just adding these works, that will be fine)
*/
else if (((wmn->data == ND_KEYFRAME) && ELEM(wmn->action, NA_ADDED, NA_REMOVED)) ||
@@ -558,7 +560,7 @@ static void action_listener(
{
ED_area_tag_refresh(sa);
}
- /* for simple edits to the curve data though (or just plain selections), a simple redraw should work
+ /* for simple edits to the curve data though (or just plain selections), a simple redraw should work
* (see T39851 for an example of how this can go wrong)
*/
else {
@@ -598,7 +600,7 @@ static void action_listener(
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
ED_area_tag_refresh(sa);
break;
-
+
default: /* just redrawing the view will do */
ED_area_tag_redraw(sa);
break;
@@ -721,12 +723,12 @@ static void action_header_region_listener(
case NC_ANIMATION:
switch (wmn->data) {
case ND_ANIMCHAN: /* set of visible animchannels changed */
- /* NOTE: for now, this should usually just mean that the filters changed
+ /* NOTE: for now, this should usually just mean that the filters changed
* It may be better if we had a dedicated flag for that though
*/
ED_region_tag_redraw(ar);
break;
-
+
case ND_KEYFRAME: /* new keyframed added -> active action may have changed */
//saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
ED_region_tag_redraw(ar);
@@ -741,9 +743,9 @@ static void action_header_region_listener(
static void action_buttons_area_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
-
+
ED_region_panels_init(wm, ar);
-
+
keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
@@ -790,19 +792,19 @@ static void action_region_listener(
static void action_refresh(const bContext *C, ScrArea *sa)
{
SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
-
- /* update the state of the animchannels in response to changes from the data they represent
+
+ /* update the state of the animchannels in response to changes from the data they represent
* NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled
*/
if (saction->flag & SACTION_TEMP_NEEDCHANSYNC) {
ARegion *ar;
-
+
/* Perform syncing of channel state incl. selection
* Active action setting also occurs here (as part of anim channel filtering in anim_filter.c)
*/
ANIM_sync_animchannels_to_data(C);
saction->flag &= ~SACTION_TEMP_NEEDCHANSYNC;
-
+
/* Tag everything for redraw
* - Regions (such as header) need to be manually tagged for redraw too
* or else they don't update [#28962]
@@ -811,7 +813,7 @@ static void action_refresh(const bContext *C, ScrArea *sa)
for (ar = sa->regionbase.first; ar; ar = ar->next)
ED_region_tag_redraw(ar);
}
-
+
/* region updates? */
// XXX re-sizing y-extents of tot should go here?
}
@@ -838,10 +840,10 @@ void ED_spacetype_action(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype action");
ARegionType *art;
-
+
st->spaceid = SPACE_ACTION;
strncpy(st->name, "Action", BKE_ST_MAXNAME);
-
+
st->new = action_new;
st->free = action_free;
st->init = action_init;
@@ -862,32 +864,32 @@ void ED_spacetype_action(void)
art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
-
+
art->init = action_header_region_init;
art->draw = action_header_region_draw;
art->listener = action_header_region_listener;
-
+
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: channels */
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
art->regionid = RGN_TYPE_CHANNELS;
art->prefsizex = 200;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
-
+
art->init = action_channel_region_init;
art->draw = action_channel_region_draw;
art->listener = action_channel_region_listener;
art->message_subscribe = saction_channel_region_message_subscribe;
-
+
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: UI buttons */
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
art->regionid = RGN_TYPE_UI;
@@ -896,11 +898,10 @@ void ED_spacetype_action(void)
art->listener = action_region_listener;
art->init = action_buttons_area_init;
art->draw = action_buttons_area_draw;
-
+
BLI_addhead(&st->regiontypes, art);
-
+
action_buttons_register(art);
-
+
BKE_spacetype_register(st);
}
-
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 4d4bcf4dffc..33ec7f771ba 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -79,7 +79,7 @@ void ED_spacetypes_init(void)
/* UI_UNIT_X is now a variable, is used in some spacetype inits? */
U.widget_unit = 20;
-
+
/* create space types */
ED_spacetype_outliner();
ED_spacetype_view3d();
@@ -123,7 +123,7 @@ void ED_spacetypes_init(void)
ED_operatortypes_render();
ED_operatortypes_mask();
ED_operatortypes_io();
-
+
ED_operatortypes_view2d();
ED_operatortypes_ui();
@@ -223,32 +223,32 @@ void ED_spacetypes_keymap(wmKeyConfig *keyconf)
typedef struct RegionDrawCB {
struct RegionDrawCB *next, *prev;
-
+
void (*draw)(const struct bContext *, struct ARegion *, void *);
void *customdata;
-
+
int type;
-
+
} RegionDrawCB;
-void *ED_region_draw_cb_activate(ARegionType *art,
+void *ED_region_draw_cb_activate(ARegionType *art,
void (*draw)(const struct bContext *, struct ARegion *, void *),
void *customdata, int type)
{
RegionDrawCB *rdc = MEM_callocN(sizeof(RegionDrawCB), "RegionDrawCB");
-
+
BLI_addtail(&art->drawcalls, rdc);
rdc->draw = draw;
rdc->customdata = customdata;
rdc->type = type;
-
+
return rdc;
}
void ED_region_draw_cb_exit(ARegionType *art, void *handle)
{
RegionDrawCB *rdc;
-
+
for (rdc = art->drawcalls.first; rdc; rdc = rdc->next) {
if (rdc == (RegionDrawCB *)handle) {
BLI_remlink(&art->drawcalls, rdc);
@@ -266,7 +266,7 @@ void *ED_region_draw_cb_customdata(void *handle)
void ED_region_draw_cb_draw(const bContext *C, ARegion *ar, int type)
{
RegionDrawCB *rdc;
-
+
for (rdc = ar->type->drawcalls.first; rdc; rdc = rdc->next) {
if (rdc->type == type) {
rdc->draw(C, ar, rdc->customdata);
@@ -295,17 +295,17 @@ static void xxx_free(SpaceLink *UNUSED(sl))
/* spacetype; init callback for usage, should be redoable */
static void xxx_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
{
-
+
/* link area to SpaceXXX struct */
-
+
/* define how many regions, the order and types */
-
+
/* add types to regions */
}
static SpaceLink *xxx_duplicate(SpaceLink *UNUSED(sl))
{
-
+
return NULL;
}
@@ -323,16 +323,16 @@ static void xxx_keymap(wmKeyConfig *UNUSED(keyconf))
void ED_spacetype_xxx(void)
{
static SpaceType st;
-
+
st.spaceid = SPACE_VIEW3D;
-
+
st.new = xxx_new;
st.free = xxx_free;
st.init = xxx_init;
st.duplicate = xxx_duplicate;
st.operatortypes = xxx_operatortypes;
st.keymap = xxx_keymap;
-
+
BKE_spacetype_register(&st);
}
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 207e08c9a44..dd943e7988d 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -144,7 +144,7 @@ static int buttons_context_path_world(ButsContextPath *path)
else if (buttons_context_path_scene(path)) {
scene = path->ptr[path->len - 1].data;
world = scene->world;
-
+
if (world) {
RNA_id_pointer_create(&scene->world->id, &path->ptr[path->len]);
path->len++;
@@ -421,7 +421,7 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path
if (!ct->user)
return 0;
-
+
id = ct->user->id;
if (id) {
@@ -489,7 +489,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
}
/* No pinned root, use scene as initial root. */
else {
- if (mainb == BCONTEXT_WORKSPACE) {
+ if (ELEM(mainb, BCONTEXT_WORKSPACE, BCONTEXT_TOOL)) {
RNA_id_pointer_create(&workspace->id, &path->ptr[0]);
path->len++;
}
@@ -525,6 +525,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
case BCONTEXT_WORLD:
found = buttons_context_path_world(path);
break;
+ case BCONTEXT_TOOL:
case BCONTEXT_WORKSPACE:
found = buttons_context_path_workspace(path);
break;
@@ -572,7 +573,7 @@ static int buttons_shading_context(const bContext *C, int mainb)
return 1;
if (mainb == BCONTEXT_DATA && ob && ELEM(ob->type, OB_LAMP, OB_CAMERA))
return 1;
-
+
return 0;
}
@@ -586,7 +587,7 @@ static int buttons_shading_new_context(const bContext *C, int flag)
return BCONTEXT_DATA;
else if (flag & (1 << BCONTEXT_WORLD))
return BCONTEXT_WORLD;
-
+
return BCONTEXT_RENDER;
}
@@ -858,7 +859,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
else if (CTX_data_equals(member, "particle_settings")) {
/* only available when pinned */
PointerRNA *ptr = get_pointer_type(path, &RNA_ParticleSettings);
-
+
if (ptr && ptr->data) {
CTX_data_pointer_set(result, ptr->id.data, &RNA_ParticleSettings, ptr->data);
return 1;
@@ -866,7 +867,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
else {
/* get settings from active particle system instead */
ptr = get_pointer_type(path, &RNA_ParticleSystem);
-
+
if (ptr && ptr->data) {
ParticleSettings *part = ((ParticleSystem *)ptr->data)->part;
CTX_data_pointer_set(result, ptr->id.data, &RNA_ParticleSettings, part);
@@ -906,7 +907,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
return 1;
}
}
-
+
else if (CTX_data_equals(member, "smoke")) {
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);
@@ -963,7 +964,7 @@ static void pin_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
}
else
sbuts->pinid = NULL;
-
+
ED_area_tag_redraw(CTX_wm_area(C));
}
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h
index 84c935dd737..2219b2a932c 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -45,19 +45,6 @@ struct bNodeTree;
struct uiLayout;
struct wmOperatorType;
-/* buts->scaflag */
-#define BUTS_SENS_SEL 1
-#define BUTS_SENS_ACT 2
-#define BUTS_SENS_LINK 4
-#define BUTS_CONT_SEL 8
-#define BUTS_CONT_ACT 16
-#define BUTS_CONT_LINK 32
-#define BUTS_ACT_SEL 64
-#define BUTS_ACT_ACT 128
-#define BUTS_ACT_LINK 256
-#define BUTS_SENS_STATE 512
-#define BUTS_ACT_STATE 1024
-
/* context data */
typedef struct ButsContextPath {
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index 2a703ebb46c..47f97b8087f 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -86,7 +86,7 @@ void BUTTONS_OT_toolbox(wmOperatorType *ot)
ot->name = "Toolbox";
ot->description = "Display button panel toolbox";
ot->idname = "BUTTONS_OT_toolbox";
-
+
/* api callbacks */
ot->invoke = toolbox_invoke;
ot->poll = ED_operator_buttons_active;
@@ -102,14 +102,15 @@ typedef struct FileBrowseOp {
static int file_browse_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
FileBrowseOp *fbo = op->customdata;
ID *id;
char *str, path[FILE_MAX];
const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath";
-
+
if (RNA_struct_property_is_set(op->ptr, path_prop) == 0 || fbo == NULL)
return OPERATOR_CANCELLED;
-
+
str = RNA_string_get_alloc(op->ptr, path_prop, NULL, 0);
/* add slash for directories, important for some properties */
@@ -118,14 +119,14 @@ static int file_browse_exec(bContext *C, wmOperator *op)
id = fbo->ptr.id.data;
BLI_strncpy(path, str, FILE_MAX);
- BLI_path_abs(path, id ? ID_BLEND_PATH(G.main, id) : G.main->name);
-
+ BLI_path_abs(path, id ? ID_BLEND_PATH(bmain, id) : BKE_main_blendfile_path(bmain));
+
if (BLI_is_dir(path)) {
/* do this first so '//' isnt converted to '//\' on windows */
BLI_add_slash(path);
if (is_relative) {
BLI_strncpy(path, str, FILE_MAX);
- BLI_path_rel(path, G.main->name);
+ BLI_path_rel(path, BKE_main_blendfile_path(bmain));
str = MEM_reallocN(str, strlen(path) + 2);
BLI_strncpy(str, path, FILE_MAX);
}
@@ -255,7 +256,7 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot)
ot->name = "Accept";
ot->description = "Open a file browser, Hold Shift to open the file, Alt to browse containing directory";
ot->idname = "BUTTONS_OT_file_browse";
-
+
/* api callbacks */
ot->invoke = file_browse_invoke;
ot->exec = file_browse_exec;
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c
index 078ab540ace..5feb74edef7 100644
--- a/source/blender/editors/space_buttons/buttons_texture.c
+++ b/source/blender/editors/space_buttons/buttons_texture.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -78,7 +78,7 @@
/************************* Texture User **************************/
-static void buttons_texture_user_property_add(ListBase *users, ID *id,
+static void buttons_texture_user_property_add(ListBase *users, ID *id,
PointerRNA ptr, PropertyRNA *prop,
const char *category, int icon, const char *name)
{
@@ -95,7 +95,7 @@ static void buttons_texture_user_property_add(ListBase *users, ID *id,
BLI_addtail(users, user);
}
-static void buttons_texture_user_node_add(ListBase *users, ID *id,
+static void buttons_texture_user_node_add(ListBase *users, ID *id,
bNodeTree *ntree, bNode *node,
const char *category, int icon, const char *name)
{
@@ -122,10 +122,10 @@ static void buttons_texture_users_find_nodetree(ListBase *users, ID *id,
if (node->typeinfo->nclass == NODE_CLASS_TEXTURE) {
PointerRNA ptr;
/* PropertyRNA *prop; */ /* UNUSED */
-
+
RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr);
/* prop = RNA_struct_find_property(&ptr, "texture"); */ /* UNUSED */
-
+
buttons_texture_user_node_add(users, id, ntree, node,
category, RNA_struct_ui_icon(ptr.type), node->name);
}
@@ -449,7 +449,7 @@ static void template_texture_show(bContext *C, void *data_p, void *prop_p)
for (user = ct->users.first; user; user = user->next)
if (user->ptr.data == data_p && user->prop == prop_p)
break;
-
+
if (user) {
/* select texture */
template_texture_select(C, user, NULL);
@@ -479,12 +479,12 @@ void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, Prope
for (user = ct->users.first; user; user = user->next)
if (user->ptr.data == ptr->data && user->prop == prop)
break;
-
+
/* draw button */
if (user) {
uiBlock *block = uiLayoutGetBlock(layout);
uiBut *but;
-
+
but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_BUTS, 0, 0, UI_UNIT_X, UI_UNIT_Y,
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Show texture in texture tab"));
UI_but_func_set(but, template_texture_show, user->ptr.data, user->prop);
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 05304ecbf94..be687d365f3 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -47,6 +47,12 @@
#include "WM_message.h"
#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+
+#include "UI_resources.h"
+
+#include "GPU_glew.h"
#include "buttons_intern.h" /* own include */
@@ -56,7 +62,7 @@ static SpaceLink *buttons_new(const ScrArea *UNUSED(area), const Scene *UNUSED(s
{
ARegion *ar;
SpaceButs *sbuts;
-
+
sbuts = MEM_callocN(sizeof(SpaceButs), "initbuts");
sbuts->spacetype = SPACE_BUTS;
sbuts->align = BUT_VERTICAL;
@@ -65,11 +71,11 @@ static SpaceLink *buttons_new(const ScrArea *UNUSED(area), const Scene *UNUSED(s
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for buts");
-
+
BLI_addtail(&sbuts->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_TOP;
-
+
#if 0
/* context region */
ar = MEM_callocN(sizeof(ARegion), "context region for buts");
@@ -80,7 +86,7 @@ static SpaceLink *buttons_new(const ScrArea *UNUSED(area), const Scene *UNUSED(s
/* main region */
ar = MEM_callocN(sizeof(ARegion), "main region for buts");
-
+
BLI_addtail(&sbuts->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
@@ -89,12 +95,12 @@ static SpaceLink *buttons_new(const ScrArea *UNUSED(area), const Scene *UNUSED(s
/* not spacelink itself */
static void buttons_free(SpaceLink *sl)
-{
+{
SpaceButs *sbuts = (SpaceButs *) sl;
if (sbuts->path)
MEM_freeN(sbuts->path);
-
+
if (sbuts->texuser) {
ButsContextTexture *ct = sbuts->texuser;
BLI_freelistN(&ct->users);
@@ -119,11 +125,11 @@ static void buttons_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
static SpaceLink *buttons_duplicate(SpaceLink *sl)
{
SpaceButs *sbutsn = MEM_dupallocN(sl);
-
+
/* clear or remove stuff from old */
sbutsn->path = NULL;
sbutsn->texuser = NULL;
-
+
return (SpaceLink *)sbutsn;
}
@@ -138,44 +144,147 @@ static void buttons_main_region_init(wmWindowManager *wm, ARegion *ar)
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
-static void buttons_main_region_draw(const bContext *C, ARegion *ar)
+static void buttons_main_region_draw_properties(const bContext *C, SpaceButs *sbuts, ARegion *ar)
{
- /* draw entirely, view changes should be handled here */
- SpaceButs *sbuts = CTX_wm_space_buts(C);
const bool vertical = (sbuts->align == BUT_VERTICAL);
buttons_context_compute(C, sbuts);
- if (sbuts->mainb == BCONTEXT_SCENE)
- ED_region_panels(C, ar, "scene", sbuts->mainb, vertical);
- else if (sbuts->mainb == BCONTEXT_RENDER)
- ED_region_panels(C, ar, "render", sbuts->mainb, vertical);
- else if (sbuts->mainb == BCONTEXT_VIEW_LAYER)
- ED_region_panels(C, ar, "view_layer", sbuts->mainb, vertical);
- else if (sbuts->mainb == BCONTEXT_WORLD)
- ED_region_panels(C, ar, "world", sbuts->mainb, vertical);
- else if (sbuts->mainb == BCONTEXT_WORKSPACE)
- ED_region_panels(C, ar, "workspace", sbuts->mainb, vertical);
- else if (sbuts->mainb == BCONTEXT_OBJECT)
- ED_region_panels(C, ar, "object", sbuts->mainb, vertical);
- else if (sbuts->mainb == BCONTEXT_DATA)
- ED_region_panels(C, ar, "data", sbuts->mainb, vertical);
- else if (sbuts->mainb == BCONTEXT_MATERIAL)
- ED_region_panels(C, ar, "material", sbuts->mainb, vertical);
- else if (sbuts->mainb == BCONTEXT_TEXTURE)
- ED_region_panels(C, ar, "texture", sbuts->mainb, vertical);
- else if (sbuts->mainb == BCONTEXT_PARTICLE)
- ED_region_panels(C, ar, "particle", sbuts->mainb, vertical);
- else if (sbuts->mainb == BCONTEXT_PHYSICS)
- ED_region_panels(C, ar, "physics", sbuts->mainb, vertical);
- else if (sbuts->mainb == BCONTEXT_BONE)
- ED_region_panels(C, ar, "bone", sbuts->mainb, vertical);
- else if (sbuts->mainb == BCONTEXT_MODIFIER)
- ED_region_panels(C, ar, "modifier", sbuts->mainb, vertical);
- else if (sbuts->mainb == BCONTEXT_CONSTRAINT)
- ED_region_panels(C, ar, "constraint", sbuts->mainb, vertical);
- else if (sbuts->mainb == BCONTEXT_BONE_CONSTRAINT)
- ED_region_panels(C, ar, "bone_constraint", sbuts->mainb, vertical);
+ const char *contexts[2] = {NULL, NULL};
+
+ switch (sbuts->mainb) {
+ case BCONTEXT_SCENE:
+ contexts[0] = "scene";
+ break;
+ case BCONTEXT_RENDER:
+ contexts[0] = "render";
+ break;
+ case BCONTEXT_VIEW_LAYER:
+ contexts[0] = "view_layer";
+ break;
+ case BCONTEXT_WORLD:
+ contexts[0] = "world";
+ break;
+ case BCONTEXT_WORKSPACE:
+ contexts[0] = "workspace";
+ break;
+ case BCONTEXT_OBJECT:
+ contexts[0] = "object";
+ break;
+ case BCONTEXT_DATA:
+ contexts[0] = "data";
+ break;
+ case BCONTEXT_MATERIAL:
+ contexts[0] = "material";
+ break;
+ case BCONTEXT_TEXTURE:
+ contexts[0] = "texture";
+ break;
+ case BCONTEXT_PARTICLE:
+ contexts[0] = "particle";
+ break;
+ case BCONTEXT_PHYSICS:
+ contexts[0] = "physics";
+ break;
+ case BCONTEXT_BONE:
+ contexts[0] = "bone";
+ break;
+ case BCONTEXT_MODIFIER:
+ contexts[0] = "modifier";
+ break;
+ case BCONTEXT_CONSTRAINT:
+ contexts[0] = "constraint";
+ break;
+ case BCONTEXT_BONE_CONSTRAINT:
+ contexts[0] = "bone_constraint";
+ break;
+ case BCONTEXT_TOOL:
+ contexts[0] = "tool";
+ break;
+ }
+
+ if (contexts[0]) {
+ ED_region_panels(C, ar, contexts, sbuts->mainb, vertical);
+ }
+}
+
+static void buttons_main_region_draw_tool(const bContext *C, SpaceButs *sbuts, ARegion *ar)
+{
+ const bool vertical = (sbuts->align == BUT_VERTICAL);
+ const char *contexts[3] = {NULL};
+
+ const WorkSpace *workspace = CTX_wm_workspace(C);
+ if (workspace->tools_space_type == SPACE_VIEW3D) {
+ const int mode = CTX_data_mode_enum(C);
+ switch (mode) {
+ case CTX_MODE_EDIT_MESH:
+ ARRAY_SET_ITEMS(contexts, ".mesh_edit");
+ break;
+ case CTX_MODE_EDIT_CURVE:
+ ARRAY_SET_ITEMS(contexts, ".curve_edit");
+ break;
+ case CTX_MODE_EDIT_SURFACE:
+ ARRAY_SET_ITEMS(contexts, ".curve_edit");
+ break;
+ case CTX_MODE_EDIT_TEXT:
+ ARRAY_SET_ITEMS(contexts, ".todo");
+ break;
+ case CTX_MODE_EDIT_ARMATURE:
+ ARRAY_SET_ITEMS(contexts, ".armature_edit");
+ break;
+ case CTX_MODE_EDIT_METABALL:
+ ARRAY_SET_ITEMS(contexts, ".todo");
+ break;
+ case CTX_MODE_EDIT_LATTICE:
+ ARRAY_SET_ITEMS(contexts, ".todo");
+ break;
+ case CTX_MODE_POSE:
+ ARRAY_SET_ITEMS(contexts, ".posemode");
+ break;
+ case CTX_MODE_SCULPT:
+ ARRAY_SET_ITEMS(contexts, ".paint_common", ".sculpt_mode");
+ break;
+ case CTX_MODE_PAINT_WEIGHT:
+ ARRAY_SET_ITEMS(contexts, ".paint_common", ".weightpaint");
+ break;
+ case CTX_MODE_PAINT_VERTEX:
+ ARRAY_SET_ITEMS(contexts, ".paint_common", ".vertexpaint");
+ break;
+ case CTX_MODE_PAINT_TEXTURE:
+ ARRAY_SET_ITEMS(contexts, ".paint_common", ".imagepaint");
+ break;
+ case CTX_MODE_PARTICLE:
+ ARRAY_SET_ITEMS(contexts, ".particlemode");
+ break;
+ case CTX_MODE_OBJECT:
+ ARRAY_SET_ITEMS(contexts, ".todo");
+ break;
+ }
+ if (contexts[0]) {
+ ED_region_panels(C, ar, contexts, -1, vertical);
+ }
+ }
+ else if (workspace->tools_space_type == SPACE_IMAGE) {
+ /* TODO */
+ }
+
+ if (contexts[0] == NULL) {
+ UI_ThemeClearColor(TH_BACK);
+ glClear(GL_COLOR_BUFFER_BIT);
+ }
+}
+
+static void buttons_main_region_draw(const bContext *C, ARegion *ar)
+{
+ /* draw entirely, view changes should be handled here */
+ SpaceButs *sbuts = CTX_wm_space_buts(C);
+
+ if (sbuts->mainb == BCONTEXT_TOOL) {
+ buttons_main_region_draw_tool(C, sbuts, ar);
+ }
+ else {
+ buttons_main_region_draw_properties(C, sbuts, ar);
+ }
sbuts->re_align = 0;
sbuts->mainbo = sbuts->mainb;
@@ -205,7 +314,7 @@ static void buttons_operatortypes(void)
static void buttons_keymap(struct wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_find(keyconf, "Property Editor", SPACE_BUTS, 0);
-
+
WM_keymap_add_item(keymap, "BUTTONS_OT_toolbox", RIGHTMOUSE, KM_PRESS, 0, 0);
}
@@ -252,7 +361,7 @@ static void buttons_header_region_message_subscribe(
static void buttons_area_redraw(ScrArea *sa, short buttons)
{
SpaceButs *sbuts = sa->spacedata.first;
-
+
/* if the area's current button set is equal to the one to redraw */
if (sbuts->mainb == buttons)
ED_area_tag_redraw(sa);
@@ -492,10 +601,10 @@ void ED_spacetype_buttons(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype buttons");
ARegionType *art;
-
+
st->spaceid = SPACE_BUTS;
strncpy(st->name, "Buttons", BKE_ST_MAXNAME);
-
+
st->new = buttons_new;
st->free = buttons_free;
st->init = buttons_init;
@@ -516,13 +625,13 @@ void ED_spacetype_buttons(void)
BLI_addhead(&st->regiontypes, art);
buttons_context_register(art);
-
+
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype buttons region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
-
+
art->init = buttons_header_region_init;
art->draw = buttons_header_region_draw;
art->message_subscribe = buttons_header_region_message_subscribe;
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
index 7ff7ea73628..bc2aa3ae67f 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_draw.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c
@@ -91,7 +91,7 @@ static void clip_draw_dopesheet_background(ARegion *ar, MovieClip *clip, unsigne
MovieTracking *tracking = &clip->tracking;
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
MovieTrackingDopesheetCoverageSegment *coverage_segment;
-
+
for (coverage_segment = dopesheet->coverage_segments.first;
coverage_segment;
coverage_segment = coverage_segment->next)
@@ -291,7 +291,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
MovieClip *clip = ED_space_clip_get_clip(sc);
uiStyle *style = UI_style_get();
int fontid = style->widget.uifont_id;
-
+
if (!clip)
return;
diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c
index d2f2fdd0b46..c8675fc390b 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_ops.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 942bc2661c3..67aa7e19de7 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -297,7 +297,7 @@ bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *ar, int mval[2], float r
ret = true;
}
}
-
+
IMB_freeImBuf(ibuf);
return ret;
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index e5a3cb6b57b..02ea340eb57 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 0d9371a7784..498a4d6fbbd 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -318,7 +318,7 @@ static int reload_exec(bContext *C, wmOperator *UNUSED(op))
if (!clip)
return OPERATOR_CANCELLED;
- BKE_movieclip_reload(clip);
+ BKE_movieclip_reload(CTX_data_main(C), clip);
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
@@ -1315,7 +1315,7 @@ static void proxy_endjob(void *pjv)
if (pj->clip->source == MCLIP_SRC_MOVIE) {
/* Timecode might have changed, so do a full reload to deal with this. */
- BKE_movieclip_reload(pj->clip);
+ BKE_movieclip_reload(pj->main, pj->clip);
}
else {
/* For image sequences we'll preserve original cache. */
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index eeb2526921f..a666b20dfa4 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 42832d24bb3..f022bb7e6f8 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -1273,7 +1273,7 @@ static void graph_region_draw(const bContext *C, ARegion *ar)
scrollers = UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP);
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
-
+
/* currnt frame indicator */
if (sc->flag & SC_SHOW_SECONDS) cfra_flag |= DRAWCFRA_UNIT_SECONDS;
UI_view2d_view_orthoSpecial(ar, v2d, 1);
@@ -1320,7 +1320,7 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar)
scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
-
+
/* currnt frame number indicator */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
ANIM_draw_cfra_number(C, v2d, cfra_flag);
diff --git a/source/blender/editors/space_clip/tracking_ops_intern.h b/source/blender/editors/space_clip/tracking_ops_intern.h
index 6ac9287c914..b53799b88d8 100644
--- a/source/blender/editors/space_clip/tracking_ops_intern.h
+++ b/source/blender/editors/space_clip/tracking_ops_intern.h
@@ -50,4 +50,4 @@ void clip_tracking_hide_cursor(struct bContext *C);
void ed_tracking_delect_all_tracks(struct ListBase *tracks_base);
void ed_tracking_delect_all_plane_tracks(struct ListBase *plane_tracks_base);
-#endif /* __TRACKING_OPS_INTERN_H__ */ \ No newline at end of file
+#endif /* __TRACKING_OPS_INTERN_H__ */
diff --git a/source/blender/editors/space_clip/tracking_ops_orient.c b/source/blender/editors/space_clip/tracking_ops_orient.c
index 2c6ef20f1c4..3db52e6a39b 100644
--- a/source/blender/editors/space_clip/tracking_ops_orient.c
+++ b/source/blender/editors/space_clip/tracking_ops_orient.c
@@ -145,7 +145,8 @@ static int count_selected_bundles(bContext *C)
return tot;
}
-static void object_solver_inverted_matrix(Scene *scene,
+static void object_solver_inverted_matrix(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
float invmat[4][4])
{
@@ -162,7 +163,7 @@ static void object_solver_inverted_matrix(Scene *scene,
bObjectSolverConstraint *data = (bObjectSolverConstraint *)con->data;
if (!found) {
Object *cam = data->camera ? data->camera : scene->camera;
- BKE_object_where_is_calc_mat4(scene, cam, invmat);
+ BKE_object_where_is_calc_mat4(depsgraph, scene, cam, invmat);
}
mul_m4_m4m4(invmat, invmat, data->invmat);
found = true;
@@ -200,6 +201,7 @@ static int set_origin_exec(bContext *C, wmOperator *op)
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
Scene *scene = CTX_data_scene(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *camera = get_camera_with_movieclip(scene, clip);
int selected_count = count_selected_bundles(C);
@@ -236,14 +238,14 @@ static int set_origin_exec(bContext *C, wmOperator *op)
mul_v3_fl(median, 1.0f / selected_count);
float mat[4][4], vec[3];
- BKE_tracking_get_camera_object_matrix(scene, camera, mat);
+ BKE_tracking_get_camera_object_matrix(depsgraph, scene, camera, mat);
mul_v3_m4v3(vec, mat, median);
if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
sub_v3_v3(object->loc, vec);
}
else {
- object_solver_inverted_matrix(scene, object, mat);
+ object_solver_inverted_matrix(depsgraph, scene, object, mat);
mul_v3_m4v3(vec, mat, vec);
copy_v3_v3(object->loc, vec);
}
@@ -278,7 +280,8 @@ void CLIP_OT_set_origin(wmOperatorType *ot)
/********************** set floor operator *********************/
-static void set_axis(Scene *scene,
+static void set_axis(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
MovieClip *clip,
MovieTrackingObject *tracking_object,
@@ -292,14 +295,14 @@ static void set_axis(Scene *scene,
BKE_object_to_mat4(ob, obmat);
- BKE_tracking_get_camera_object_matrix(scene, camera, mat);
+ BKE_tracking_get_camera_object_matrix(depsgraph, scene, camera, mat);
mul_v3_m4v3(vec, mat, track->bundle_pos);
copy_v3_v3(dvec, vec);
if (!is_camera) {
float imat[4][4];
- object_solver_inverted_matrix(scene, ob, imat);
+ object_solver_inverted_matrix(depsgraph, scene, ob, imat);
mul_v3_m4v3(vec, imat, vec);
invert_m4_m4(imat, obmat);
@@ -430,7 +433,7 @@ static int set_plane_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- BKE_tracking_get_camera_object_matrix(scene, camera, mat);
+ BKE_tracking_get_camera_object_matrix(depsgraph, scene, camera, mat);
/* Get 3 bundles to use as reference. */
track = tracksbase->first;
@@ -493,7 +496,7 @@ static int set_plane_exec(bContext *C, wmOperator *op)
}
BKE_object_where_is_calc(depsgraph, scene, object);
- set_axis(scene, object, clip, tracking_object, axis_track, 'X');
+ set_axis(depsgraph, scene, object, clip, tracking_object, axis_track, 'X');
DEG_id_tag_update(&clip->id, 0);
DEG_id_tag_update(&object->id, OB_RECALC_OB);
@@ -539,6 +542,7 @@ static int set_axis_exec(bContext *C, wmOperator *op)
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
Scene *scene = CTX_data_scene(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *object;
int axis = RNA_enum_get(op->ptr, "axis");
@@ -567,7 +571,7 @@ static int set_axis_exec(bContext *C, wmOperator *op)
track = track->next;
}
- set_axis(scene, object, clip, tracking_object, track, axis == 0 ? 'X' : 'Y');
+ set_axis(depsgraph, scene, object, clip, tracking_object, track, axis == 0 ? 'X' : 'Y');
DEG_id_tag_update(&clip->id, 0);
DEG_id_tag_update(&object->id, OB_RECALC_OB);
@@ -618,6 +622,7 @@ static int do_set_scale(bContext *C,
MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
MovieTrackingTrack *track;
Scene *scene = CTX_data_scene(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *object = NULL;
Object *camera = get_camera_with_movieclip(scene, clip);
ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
@@ -642,7 +647,7 @@ static int do_set_scale(bContext *C,
}
}
- BKE_tracking_get_camera_object_matrix(scene, camera, mat);
+ BKE_tracking_get_camera_object_matrix(depsgraph, scene, camera, mat);
track = tracksbase->first;
while (track) {
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index c8a06545e0f..66b203ff612 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -74,7 +74,7 @@ void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_du
/* fake the edit line being in the scroll buffer */
ConsoleLine *cl = sc->history.last;
int prompt_len = strlen(sc->prompt);
-
+
cl_dummy->type = CONSOLE_LINE_INPUT;
cl_dummy->len = prompt_len + cl->len;
cl_dummy->len_alloc = cl_dummy->len + 1;
@@ -83,7 +83,7 @@ void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_du
memcpy(cl_dummy->line + prompt_len, cl->line, cl->len + 1);
BLI_addtail(&sc->scrollback, cl_dummy);
}
-void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dummy)
+void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dummy)
{
MEM_freeN(cl_dummy->line);
BLI_remlink(&sc->scrollback, cl_dummy);
@@ -98,10 +98,10 @@ static int console_textview_begin(TextViewContext *tvc)
tvc->lheight = sc->lheight * UI_DPI_FAC;
tvc->sel_start = sc->sel_start;
tvc->sel_end = sc->sel_end;
-
+
/* iterator */
tvc->iter = sc->scrollback.last;
-
+
return (tvc->iter != NULL);
}
@@ -109,7 +109,7 @@ static void console_textview_end(TextViewContext *tvc)
{
SpaceConsole *sc = (SpaceConsole *)tvc->arg1;
(void)sc;
-
+
}
static int console_textview_step(TextViewContext *tvc)
@@ -199,7 +199,7 @@ static int console_textview_main__internal(struct SpaceConsole *sc, ARegion *ar,
{
ConsoleLine cl_dummy = {NULL};
int ret = 0;
-
+
View2D *v2d = &ar->v2d;
TextViewContext tvc = {0};
diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h
index f523cf0d476..c0ef6e95d2e 100644
--- a/source/blender/editors/space_console/console_intern.h
+++ b/source/blender/editors/space_console/console_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index b740ff4b397..32cf5ea2055 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -92,9 +92,9 @@ void console_scrollback_free(SpaceConsole *sc, ConsoleLine *cl)
static void console_scrollback_limit(SpaceConsole *sc)
{
int tot;
-
+
if (U.scrollback < 32) U.scrollback = 256; // XXX - save in user defaults
-
+
for (tot = BLI_listbase_count(&sc->scrollback); tot > U.scrollback; tot--)
console_scrollback_free(sc, sc->scrollback.first);
}
@@ -122,16 +122,16 @@ static bool console_line_cursor_set(ConsoleLine *cl, int cursor)
if (cursor < 0) cursor_new = 0;
else if (cursor > cl->len) cursor_new = cl->len;
else cursor_new = cursor;
-
+
if (cursor_new == cl->cursor) {
return false;
}
-
+
cl->cursor = cursor_new;
return true;
}
-#if 0 // XXX unused
+#if 0 // XXX unused
static void console_lb_debug__internal(ListBase *lb)
{
ConsoleLine *cl;
@@ -147,7 +147,7 @@ static void console_history_debug(const bContext *C)
{
SpaceConsole *sc = CTX_wm_space_console(C);
-
+
console_lb_debug__internal(&sc->history);
}
#endif
@@ -155,7 +155,7 @@ static void console_history_debug(const bContext *C)
static ConsoleLine *console_lb_add__internal(ListBase *lb, ConsoleLine *from)
{
ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add");
-
+
if (from) {
BLI_assert(strlen(from->line) == from->len);
ci->line = BLI_strdupn(from->line, from->len);
@@ -168,7 +168,7 @@ static ConsoleLine *console_lb_add__internal(ListBase *lb, ConsoleLine *from)
ci->len_alloc = 64;
ci->len = 0;
}
-
+
BLI_addtail(lb, ci);
return ci;
}
@@ -182,7 +182,7 @@ static ConsoleLine *console_history_add(SpaceConsole *sc, ConsoleLine *from)
static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from)
{
SpaceConsole *sc = CTX_wm_space_console(C);
-
+
return console_lb_add__internal(&sc->scrollback, from);
}
#endif
@@ -192,9 +192,9 @@ static ConsoleLine *console_lb_add_str__internal(ListBase *lb, char *str, bool o
ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add");
if (own) ci->line = str;
else ci->line = BLI_strdup(str);
-
+
ci->len = ci->len_alloc = strlen(str);
-
+
BLI_addtail(lb, ci);
return ci;
}
@@ -215,7 +215,7 @@ ConsoleLine *console_history_verify(const bContext *C)
ConsoleLine *ci = sc->history.last;
if (ci == NULL)
ci = console_history_add(sc, NULL);
-
+
return ci;
}
@@ -233,7 +233,7 @@ static void console_line_verify_length(ConsoleLine *ci, int len)
char *new_line = MEM_callocN(new_len, "console line");
memcpy(new_line, ci->line, ci->len);
MEM_freeN(ci->line);
-
+
ci->line = new_line;
ci->len_alloc = new_len;
}
@@ -242,7 +242,7 @@ static void console_line_verify_length(ConsoleLine *ci, int len)
static int console_line_insert(ConsoleLine *ci, char *str)
{
int len = strlen(str);
-
+
if (len > 0 && str[len - 1] == '\n') { /* stop new lines being pasted at the end of lines */
str[len - 1] = '\0';
len--;
@@ -250,15 +250,15 @@ static int console_line_insert(ConsoleLine *ci, char *str)
if (len == 0)
return 0;
-
+
console_line_verify_length(ci, len + ci->len);
-
+
memmove(ci->line + ci->cursor + len, ci->line + ci->cursor, (ci->len - ci->cursor) + 1);
memcpy(ci->line + ci->cursor, str, len);
-
+
ci->len += len;
ci->cursor += len;
-
+
return len;
}
@@ -312,11 +312,11 @@ static const EnumPropertyItem console_move_type_items[] = {
static int console_move_exec(bContext *C, wmOperator *op)
{
ConsoleLine *ci = console_history_verify(C);
-
+
int type = RNA_enum_get(op->ptr, "type");
bool done = false;
int pos;
-
+
switch (type) {
case LINE_BEGIN:
pos = ci->cursor;
@@ -364,7 +364,7 @@ static int console_move_exec(bContext *C, wmOperator *op)
done = console_line_cursor_set(ci, pos);
break;
}
-
+
if (done) {
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
@@ -383,7 +383,7 @@ void CONSOLE_OT_move(wmOperatorType *ot)
ot->name = "Move Cursor";
ot->description = "Move cursor position";
ot->idname = "CONSOLE_OT_move";
-
+
/* api callbacks */
ot->exec = console_move_exec;
ot->poll = ED_operator_console_active;
@@ -410,9 +410,9 @@ static int console_insert_exec(bContext *C, wmOperator *op)
}
len = console_line_insert(ci, str);
-
+
MEM_freeN(str);
-
+
if (len == 0) {
return OPERATOR_CANCELLED;
}
@@ -442,7 +442,7 @@ static int console_insert_invoke(bContext *C, wmOperator *op, const wmEvent *eve
else {
char str[BLI_UTF8_MAX + 1];
size_t len;
-
+
if (event->utf8_buf[0]) {
len = BLI_str_utf8_size_safe(event->utf8_buf);
memcpy(str, event->utf8_buf, len);
@@ -466,7 +466,7 @@ void CONSOLE_OT_insert(wmOperatorType *ot)
ot->name = "Insert";
ot->description = "Insert text at cursor position";
ot->idname = "CONSOLE_OT_insert";
-
+
/* api callbacks */
ot->exec = console_insert_exec;
ot->invoke = console_insert_invoke;
@@ -588,11 +588,11 @@ static int console_delete_exec(bContext *C, wmOperator *op)
const short type = RNA_enum_get(op->ptr, "type");
bool done = false;
-
+
if (ci->len == 0) {
return OPERATOR_CANCELLED;
}
-
+
switch (type) {
case DEL_NEXT_CHAR:
case DEL_NEXT_WORD:
@@ -640,7 +640,7 @@ static int console_delete_exec(bContext *C, wmOperator *op)
ED_area_tag_redraw(CTX_wm_area(C));
console_scroll_bottom(ar);
-
+
return OPERATOR_FINISHED;
}
@@ -651,7 +651,7 @@ void CONSOLE_OT_delete(wmOperatorType *ot)
ot->name = "Delete";
ot->description = "Delete text by cursor position";
ot->idname = "CONSOLE_OT_delete";
-
+
/* api callbacks */
ot->exec = console_delete_exec;
ot->poll = ED_operator_console_active;
@@ -700,17 +700,17 @@ static int console_clear_exec(bContext *C, wmOperator *op)
{
SpaceConsole *sc = CTX_wm_space_console(C);
ARegion *ar = CTX_wm_region(C);
-
+
const bool scrollback = RNA_boolean_get(op->ptr, "scrollback");
const bool history = RNA_boolean_get(op->ptr, "history");
-
+
/*ConsoleLine *ci = */ console_history_verify(C);
-
+
if (scrollback) { /* last item in mistory */
while (sc->scrollback.first)
console_scrollback_free(sc, sc->scrollback.first);
}
-
+
if (history) {
while (sc->history.first)
console_history_free(sc, sc->history.first);
@@ -729,11 +729,11 @@ void CONSOLE_OT_clear(wmOperatorType *ot)
ot->name = "Clear";
ot->description = "Clear text by type";
ot->idname = "CONSOLE_OT_clear";
-
+
/* api callbacks */
ot->exec = console_clear_exec;
ot->poll = ED_operator_console_active;
-
+
/* properties */
RNA_def_boolean(ot->srna, "scrollback", 1, "Scrollback", "Clear the scrollback history");
RNA_def_boolean(ot->srna, "history", 0, "History", "Clear the command history");
@@ -778,7 +778,7 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op)
console_history_add(sc, (ConsoleLine *)sc->history.last);
}
-
+
ci = sc->history.last;
console_select_offset(sc, ci->len - prev_len);
@@ -797,11 +797,11 @@ void CONSOLE_OT_history_cycle(wmOperatorType *ot)
ot->name = "History Cycle";
ot->description = "Cycle through history";
ot->idname = "CONSOLE_OT_history_cycle";
-
+
/* api callbacks */
ot->exec = console_history_cycle_exec;
ot->poll = ED_operator_console_active;
-
+
/* properties */
RNA_def_boolean(ot->srna, "reverse", 0, "Reverse", "Reverse cycle history");
}
@@ -852,11 +852,11 @@ void CONSOLE_OT_history_append(wmOperatorType *ot)
ot->name = "History Append";
ot->description = "Append history at cursor position";
ot->idname = "CONSOLE_OT_history_append";
-
+
/* api callbacks */
ot->exec = console_history_append_exec;
ot->poll = ED_operator_console_active;
-
+
/* properties */
RNA_def_string(ot->srna, "text", NULL, 0, "Text", "Text to insert at the cursor position");
RNA_def_int(ot->srna, "current_character", 0, 0, INT_MAX, "Cursor", "The index of the cursor", 0, 10000);
@@ -870,15 +870,15 @@ static int console_scrollback_append_exec(bContext *C, wmOperator *op)
SpaceConsole *sc = CTX_wm_space_console(C);
ARegion *ar = CTX_wm_region(C);
ConsoleLine *ci;
-
+
char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, don't free */
int type = RNA_enum_get(op->ptr, "type");
console_history_verify(C);
-
+
ci = console_scrollback_add_str(sc, str, 1); /* own the string */
ci->type = type;
-
+
console_scrollback_limit(sc);
/* 'ar' can be null depending on the operator that runs
@@ -888,7 +888,7 @@ static int console_scrollback_append_exec(bContext *C, wmOperator *op)
}
ED_area_tag_redraw(CTX_wm_area(C));
-
+
return OPERATOR_FINISHED;
}
@@ -907,11 +907,11 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot)
ot->name = "Scrollback Append";
ot->description = "Append scrollback text by type";
ot->idname = "CONSOLE_OT_scrollback_append";
-
+
/* api callbacks */
ot->exec = console_scrollback_append_exec;
ot->poll = ED_operator_console_active;
-
+
/* properties */
RNA_def_string(ot->srna, "text", NULL, 0, "Text", "Text to insert at the cursor position");
RNA_def_enum(ot->srna, "type", console_line_type_items, CONSOLE_LINE_OUTPUT, "Type", "Console output type");
@@ -924,7 +924,7 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op))
DynStr *buf_dyn;
char *buf_str;
-
+
ConsoleLine *cl;
int sel[2];
int offset = 0;
@@ -1088,7 +1088,7 @@ static void console_modal_select_apply(bContext *C, wmOperator *op, const wmEven
sel_prev[0] = sc->sel_start;
sel_prev[1] = sc->sel_end;
-
+
console_cursor_set_to_pos(sc, ar, scu, mval, true);
/* only redraw if the selection changed */
@@ -1140,8 +1140,11 @@ static int console_modal_select(bContext *C, wmOperator *op, const wmEvent *even
case LEFTMOUSE:
case MIDDLEMOUSE:
case RIGHTMOUSE:
- console_cursor_set_exit(C, op);
- return OPERATOR_FINISHED;
+ if (event->val == KM_RELEASE) {
+ console_cursor_set_exit(C, op);
+ return OPERATOR_FINISHED;
+ }
+ break;
case MOUSEMOVE:
console_modal_select_apply(C, op, event);
break;
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index ff5f030b5c2..c65c9a175a0 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
+ *
* Contributor(s): Campbell Barton
*
* ***** END GPL LICENSE BLOCK *****
@@ -56,26 +56,26 @@ static SpaceLink *console_new(const ScrArea *UNUSED(area), const Scene *UNUSED(s
{
ARegion *ar;
SpaceConsole *sconsole;
-
+
sconsole = MEM_callocN(sizeof(SpaceConsole), "initconsole");
sconsole->spacetype = SPACE_CONSOLE;
-
+
sconsole->lheight = 14;
-
+
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for console");
-
+
BLI_addtail(&sconsole->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_TOP;
-
-
+
+
/* main region */
ar = MEM_callocN(sizeof(ARegion), "main region for text");
-
+
BLI_addtail(&sconsole->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
-
+
/* keep in sync with info */
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
ar->v2d.align |= V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y; /* align bottom left */
@@ -94,10 +94,10 @@ static SpaceLink *console_new(const ScrArea *UNUSED(area), const Scene *UNUSED(s
static void console_free(SpaceLink *sl)
{
SpaceConsole *sc = (SpaceConsole *) sl;
-
+
while (sc->scrollback.first)
console_scrollback_free(sc, sc->scrollback.first);
-
+
while (sc->history.first)
console_history_free(sc, sc->history.first);
}
@@ -112,13 +112,13 @@ static void console_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)
static SpaceLink *console_duplicate(SpaceLink *sl)
{
SpaceConsole *sconsolen = MEM_dupallocN(sl);
-
+
/* clear or remove stuff from old */
-
+
/* TODO - duplicate?, then we also need to duplicate the py namespace */
BLI_listbase_clear(&sconsolen->scrollback);
BLI_listbase_clear(&sconsolen->history);
-
+
return (SpaceLink *)sconsolen;
}
@@ -147,10 +147,10 @@ static void console_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_find(wm->defaultconf, "Console", SPACE_CONSOLE, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
-
+
/* add drop boxes */
lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
-
+
WM_event_add_dropbox_handler(&ar->handlers, lb);
}
@@ -208,7 +208,7 @@ static void path_drop_copy(wmDrag *drag, wmDropBox *drop)
static void console_dropboxes(void)
{
ListBase *lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
-
+
WM_dropbox_add(lb, "CONSOLE_OT_insert", id_drop_poll, id_drop_copy);
WM_dropbox_add(lb, "CONSOLE_OT_insert", path_drop_poll, path_drop_copy);
}
@@ -236,10 +236,10 @@ static void console_main_region_draw(const bContext *C, ARegion *ar)
console_history_verify(C); /* make sure we have some command line */
console_textview_main(sc, ar);
-
+
/* reset view matrix */
UI_view2d_view_restore(C);
-
+
/* scrollers */
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP);
UI_view2d_scrollers_draw(C, v2d, scrollers);
@@ -255,9 +255,9 @@ static void console_operatortypes(void)
WM_operatortype_append(CONSOLE_OT_indent);
WM_operatortype_append(CONSOLE_OT_unindent);
-
+
/* for use by python only */
- WM_operatortype_append(CONSOLE_OT_history_append);
+ WM_operatortype_append(CONSOLE_OT_history_append);
WM_operatortype_append(CONSOLE_OT_scrollback_append);
WM_operatortype_append(CONSOLE_OT_clear);
@@ -273,7 +273,7 @@ static void console_keymap(struct wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_find(keyconf, "Console", SPACE_CONSOLE, 0);
wmKeyMapItem *kmi;
-
+
#ifdef __APPLE__
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_BEGIN);
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_END);
@@ -281,14 +281,14 @@ static void console_keymap(struct wmKeyConfig *keyconf)
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", PREV_WORD);
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", NEXT_WORD);
-
+
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", HOMEKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_BEGIN);
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", ENDKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_END);
-
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
RNA_boolean_set(kmi->ptr, "reverse", false);
-
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
RNA_boolean_set(kmi->ptr, "reverse", true);
@@ -296,17 +296,17 @@ static void console_keymap(struct wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
RNA_boolean_set(kmi->ptr, "reverse", false);
-
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", PADMINUS, KM_PRESS, KM_CTRL, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
RNA_boolean_set(kmi->ptr, "reverse", true);
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_CHAR);
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_CHAR);
-
+
RNA_boolean_set(WM_keymap_add_item(keymap, "CONSOLE_OT_history_cycle", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "reverse", true);
RNA_boolean_set(WM_keymap_add_item(keymap, "CONSOLE_OT_history_cycle", DOWNARROWKEY, KM_PRESS, 0, 0)->ptr, "reverse", false);
-
+
#if 0
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", PREV_WORD);
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", NEXT_WORD);
@@ -315,7 +315,7 @@ static void console_keymap(struct wmKeyConfig *keyconf)
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", PAGEUPKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_PAGE);
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", PAGEDOWNKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_PAGE);
#endif
-
+
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_CHAR);
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_CHAR);
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", DEL_PREV_CHAR); /* same as above [#26623] */
@@ -331,7 +331,7 @@ static void console_keymap(struct wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "interactive", true);
kmi = WM_keymap_add_item(keymap, "CONSOLE_OT_execute", PADENTER, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "interactive", true);
-
+
//WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", TABKEY, KM_PRESS, 0, 0); /* python operator - space_text.py */
WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* python operator - space_text.py */
#endif
@@ -343,7 +343,7 @@ static void console_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "CONSOLE_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0);
WM_keymap_add_item(keymap, "CONSOLE_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0);
#endif
-
+
WM_keymap_add_item(keymap, "CONSOLE_OT_select_set", LEFTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "CONSOLE_OT_select_word", LEFTMOUSE, KM_DBL_CLICK, 0, 0);
@@ -401,10 +401,10 @@ void ED_spacetype_console(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype console");
ARegionType *art;
-
+
st->spaceid = SPACE_CONSOLE;
strncpy(st->name, "Console", BKE_ST_MAXNAME);
-
+
st->new = console_new;
st->free = console_free;
st->init = console_init;
@@ -412,7 +412,7 @@ void ED_spacetype_console(void)
st->operatortypes = console_operatortypes;
st->keymap = console_keymap;
st->dropboxes = console_dropboxes;
-
+
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype console region");
art->regionid = RGN_TYPE_WINDOW;
@@ -422,20 +422,20 @@ void ED_spacetype_console(void)
art->draw = console_main_region_draw;
art->cursor = console_cursor;
art->listener = console_main_region_listener;
-
-
+
+
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype console region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
-
+
art->init = console_header_region_init;
art->draw = console_header_region_draw;
-
+
BLI_addhead(&st->regiontypes, art);
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 043f32c56e7..360009d3ea4 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -86,7 +86,7 @@ static char *file_draw_tooltip_func(bContext *UNUSED(C), void *argN, const char
return BLI_strdup(dyn_tooltip);
}
-/* Note: This function uses pixelspace (0, 0, winx, winy), not view2d.
+/* Note: This function uses pixelspace (0, 0, winx, winy), not view2d.
* The controls are laid out as follows:
*
* -------------------------------------------
@@ -121,14 +121,14 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
int available_w = max_x - min_x;
int line1_w = available_w;
int line2_w = available_w;
-
+
uiBut *but;
uiBlock *block;
SpaceFile *sfile = CTX_wm_space_file(C);
FileSelectParams *params = ED_fileselect_get_params(sfile);
ARegion *artmp;
const bool is_browse_only = (sfile->op == NULL);
-
+
/* Initialize UI block. */
BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar);
block = UI_block_begin(C, ar, uiblockstr, UI_EMBOSS);
@@ -212,11 +212,11 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
UI_but_flag_enable(but, UI_BUT_REDALERT);
}
}
-
+
/* clear func */
UI_block_func_set(block, NULL, NULL, NULL);
}
-
+
/* Filename number increment / decrement buttons. */
if (fnumbuttons && (params->flag & FILE_DIRSEL_ONLY) == 0) {
UI_block_align_begin(block);
@@ -233,7 +233,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
RNA_int_set(UI_but_operator_ptr_get(but), "increment", 1);
UI_block_align_end(block);
}
-
+
/* Execute / cancel buttons. */
if (loadbutton) {
const struct FileDirEntry *file = sfile->files ? filelist_file(sfile->files, params->active_file) : NULL;
@@ -254,7 +254,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
uiDefButO(block, UI_BTYPE_BUT, "FILE_OT_cancel", WM_OP_EXEC_REGION_WIN, IFACE_("Cancel"),
max_x - loadbutton, line2_y, loadbutton, btn_h, "");
}
-
+
UI_block_end(C, block);
UI_block_draw(C, block);
}
@@ -274,10 +274,10 @@ static void file_draw_icon(uiBlock *block, const char *path, int sx, int sy, int
uiBut *but;
int x, y;
// float alpha = 1.0f;
-
+
x = sx;
y = sy - height;
-
+
/*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/
but = uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, NULL);
@@ -323,7 +323,7 @@ void file_calc_previews(const bContext *C, ARegion *ar)
{
SpaceFile *sfile = CTX_wm_space_file(C);
View2D *v2d = &ar->v2d;
-
+
ED_fileselect_init_layout(sfile, ar);
UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height);
}
@@ -424,6 +424,7 @@ static void file_draw_preview(
static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname)
{
+ Main *bmain = CTX_data_main(C);
char newname[FILE_MAX + 12];
char orgname[FILE_MAX + 12];
char filename[FILE_MAX + 12];
@@ -432,10 +433,11 @@ static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname)
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
- BLI_make_file_string(G.main->name, orgname, sfile->params->dir, oldname);
+ const char *blendfile_path = BKE_main_blendfile_path(bmain);
+ BLI_make_file_string(blendfile_path, orgname, sfile->params->dir, oldname);
BLI_strncpy(filename, sfile->params->renameedit, sizeof(filename));
BLI_filename_make_safe(filename);
- BLI_make_file_string(G.main->name, newname, sfile->params->dir, filename);
+ BLI_make_file_string(blendfile_path, newname, sfile->params->dir, filename);
if (!STREQ(orgname, newname)) {
if (!BLI_exists(newname)) {
@@ -556,11 +558,11 @@ void file_draw_list(const bContext *C, ARegion *ar)
const float thumb_icon_aspect = sqrtf(64.0f / (float)(params->thumbnail_size));
numfiles = filelist_files_ensure(files);
-
+
if (params->display != FILE_IMGDISPLAY) {
draw_background(layout, v2d);
-
+
draw_dividers(layout, v2d);
}
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index 71e38f72a7a..742715039cf 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -109,9 +109,9 @@ void file_filename_enter_handle(bContext *C, void *arg_unused, void *arg_but);
int file_highlight_set(struct SpaceFile *sfile, struct ARegion *ar, int mx, int my);
void file_sfile_filepath_set(struct SpaceFile *sfile, const char *filepath);
-void file_sfile_to_operator_ex(struct wmOperator *op, struct SpaceFile *sfile, char *filepath);
-void file_sfile_to_operator(struct wmOperator *op, struct SpaceFile *sfile);
-void file_operator_to_sfile(struct SpaceFile *sfile, struct wmOperator *op);
+void file_sfile_to_operator_ex(bContext *C, struct wmOperator *op, struct SpaceFile *sfile, char *filepath);
+void file_sfile_to_operator(bContext *C, struct wmOperator *op, struct SpaceFile *sfile);
+void file_operator_to_sfile(bContext *C, struct SpaceFile *sfile, struct wmOperator *op);
/* filesel.c */
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index fd998807106..0cd31ce7ca5 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Andrea Weikert (c) 2008 Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -75,7 +75,7 @@
static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const rcti *rect_region)
{
FileSelection sel;
-
+
View2D *v2d = &ar->v2d;
rcti rect_view;
rctf rect_view_fl;
@@ -92,7 +92,7 @@ static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const r
(int)(v2d->tot.ymax - rect_view_fl.ymax));
sel = ED_fileselect_layout_offset_rect(sfile->layout, &rect_view);
-
+
return sel;
}
@@ -101,14 +101,14 @@ static void file_deselect_all(SpaceFile *sfile, unsigned int flag)
FileSelection sel;
sel.first = 0;
sel.last = filelist_files_ensure(sfile->files) - 1;
-
+
filelist_entries_select_index_range_set(sfile->files, &sel, FILE_SEL_REMOVE, flag, CHECK_ALL);
}
typedef enum FileSelect {
FILE_SELECT_NOTHING = 0,
- FILE_SELECT_DIR = 1,
- FILE_SELECT_FILE = 2
+ FILE_SELECT_DIR = 1,
+ FILE_SELECT_FILE = 2
} FileSelect;
static void clamp_to_filelist(int numfiles, FileSelection *sel)
@@ -122,7 +122,7 @@ static void clamp_to_filelist(int numfiles, FileSelection *sel)
sel->first = -1;
sel->last = -1;
}
-
+
/* fix if last file invalid */
if ( (sel->first > 0) && (sel->last < 0) )
sel->last = numfiles - 1;
@@ -176,6 +176,7 @@ static FileSelection file_selection_get(bContext *C, const rcti *rect, bool fill
static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen)
{
+ Main *bmain = CTX_data_main(C);
FileSelect retval = FILE_SELECT_NOTHING;
SpaceFile *sfile = CTX_wm_space_file(C);
FileSelectParams *params = ED_fileselect_get_params(sfile);
@@ -213,7 +214,7 @@ static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen)
}
}
else {
- BLI_cleanup_dir(G.main->name, params->dir);
+ BLI_cleanup_dir(BKE_main_blendfile_path(bmain), params->dir);
strcat(params->dir, file->relpath);
BLI_add_slash(params->dir);
}
@@ -298,10 +299,10 @@ static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select,
FileSelect retval = FILE_SELECT_NOTHING;
FileSelection sel = file_selection_get(C, rect, fill); /* get the selection */
const FileCheckType check_type = (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_ALL;
-
+
/* flag the files as selected in the filelist */
filelist_entries_select_index_range_set(sfile->files, &sel, select, FILE_SEL_SELECTED, check_type);
-
+
/* Don't act on multiple selected files */
if (sel.first != sel.last) select = 0;
@@ -333,7 +334,7 @@ static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select,
/* update operator for name change event */
file_draw_check(C);
-
+
return retval;
}
@@ -460,7 +461,7 @@ void FILE_OT_select_border(wmOperatorType *ot)
ot->name = "Activate/Select File";
ot->description = "Activate/select the file(s) contained in the border";
ot->idname = "FILE_OT_select_border";
-
+
/* api callbacks */
ot->invoke = WM_gesture_border_invoke;
ot->exec = file_border_select_exec;
@@ -529,7 +530,7 @@ void FILE_OT_select(wmOperatorType *ot)
ot->name = "Activate/Select File";
ot->description = "Activate/select file";
ot->idname = "FILE_OT_select";
-
+
/* api callbacks */
ot->invoke = file_select_invoke;
ot->poll = ED_operator_file_active;
@@ -777,7 +778,7 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op))
const int numfiles = filelist_files_ensure(sfile->files);
const bool has_selection = file_is_any_selected(sfile->files);
- sel.first = 0;
+ sel.first = 0;
sel.last = numfiles - 1;
/* select all only if previously no file was selected */
@@ -813,7 +814,7 @@ void FILE_OT_select_all_toggle(wmOperatorType *ot)
ot->name = "(De)select All Files";
ot->description = "Select or deselect all files";
ot->idname = "FILE_OT_select_all_toggle";
-
+
/* api callbacks */
ot->exec = file_select_all_exec;
ot->poll = ED_operator_file_active;
@@ -826,6 +827,7 @@ void FILE_OT_select_all_toggle(wmOperatorType *ot)
/* Note we could get rid of this one, but it's used by some addon so... Does not hurt keeping it around for now. */
static int bookmark_select_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
SpaceFile *sfile = CTX_wm_space_file(C);
PropertyRNA *prop;
@@ -835,12 +837,12 @@ static int bookmark_select_exec(bContext *C, wmOperator *op)
RNA_property_string_get(op->ptr, prop, entry);
BLI_strncpy(params->dir, entry, sizeof(params->dir));
- BLI_cleanup_dir(G.main->name, params->dir);
+ BLI_cleanup_dir(BKE_main_blendfile_path(bmain), params->dir);
ED_file_change_dir(C);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
}
-
+
return OPERATOR_FINISHED;
}
@@ -852,7 +854,7 @@ void FILE_OT_select_bookmark(wmOperatorType *ot)
ot->name = "Select Directory";
ot->description = "Select a bookmarked directory";
ot->idname = "FILE_OT_select_bookmark";
-
+
/* api callbacks */
ot->exec = bookmark_select_exec;
ot->poll = ED_operator_file_active;
@@ -871,7 +873,7 @@ static int bookmark_add_exec(bContext *C, wmOperator *UNUSED(op))
if (params->dir[0] != '\0') {
char name[FILE_MAX];
-
+
fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, NULL, FS_INSERT_SAVE);
BLI_make_file_string("/", name, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu, name);
@@ -888,7 +890,7 @@ void FILE_OT_bookmark_add(wmOperatorType *ot)
ot->name = "Add Bookmark";
ot->description = "Add a bookmark for the selected/active directory";
ot->idname = "FILE_OT_bookmark_add";
-
+
/* api callbacks */
ot->exec = bookmark_add_exec;
ot->poll = ED_operator_file_active;
@@ -913,7 +915,7 @@ static int bookmark_delete_exec(bContext *C, wmOperator *op)
}
if ((index > -1) && (index < nentries)) {
char name[FILE_MAX];
-
+
fsmenu_remove_entry(fsmenu, FS_CATEGORY_BOOKMARKS, index);
BLI_make_file_string("/", name, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu, name);
@@ -933,7 +935,7 @@ void FILE_OT_bookmark_delete(wmOperatorType *ot)
ot->name = "Delete Bookmark";
ot->description = "Delete selected bookmark";
ot->idname = "FILE_OT_bookmark_delete";
-
+
/* api callbacks */
ot->exec = bookmark_delete_exec;
ot->poll = ED_operator_file_active;
@@ -1080,7 +1082,7 @@ static int reset_recent_exec(bContext *C, wmOperator *UNUSED(op))
ScrArea *sa = CTX_wm_area(C);
char name[FILE_MAX];
struct FSMenu *fsmenu = ED_fsmenu_get();
-
+
while (ED_fsmenu_get_entry(fsmenu, FS_CATEGORY_RECENT, 0) != NULL) {
fsmenu_remove_entry(fsmenu, FS_CATEGORY_RECENT, 0);
}
@@ -1097,7 +1099,7 @@ void FILE_OT_reset_recent(wmOperatorType *ot)
ot->name = "Reset Recent";
ot->description = "Reset Recent files";
ot->idname = "FILE_OT_reset_recent";
-
+
/* api callbacks */
ot->exec = reset_recent_exec;
ot->poll = ED_operator_file_active;
@@ -1148,7 +1150,7 @@ static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv
return OPERATOR_CANCELLED;
ED_area_tag_redraw(CTX_wm_area(C));
-
+
return OPERATOR_FINISHED;
}
@@ -1158,7 +1160,7 @@ void FILE_OT_highlight(struct wmOperatorType *ot)
ot->name = "Highlight File";
ot->description = "Highlight selected file(s)";
ot->idname = "FILE_OT_highlight";
-
+
/* api callbacks */
ot->invoke = file_highlight_invoke;
ot->poll = ED_operator_file_active;
@@ -1169,11 +1171,11 @@ int file_cancel_exec(bContext *C, wmOperator *UNUSED(unused))
wmWindowManager *wm = CTX_wm_manager(C);
SpaceFile *sfile = CTX_wm_space_file(C);
wmOperator *op = sfile->op;
-
+
sfile->op = NULL;
WM_event_fileselect_event(wm, op, EVT_FILESELECT_CANCEL);
-
+
return OPERATOR_FINISHED;
}
@@ -1193,22 +1195,23 @@ void FILE_OT_cancel(struct wmOperatorType *ot)
ot->name = "Cancel File Load";
ot->description = "Cancel loading of selected file";
ot->idname = "FILE_OT_cancel";
-
+
/* api callbacks */
ot->exec = file_cancel_exec;
ot->poll = file_operator_poll;
}
-void file_sfile_to_operator_ex(wmOperator *op, SpaceFile *sfile, char *filepath)
+void file_sfile_to_operator_ex(bContext *C, wmOperator *op, SpaceFile *sfile, char *filepath)
{
+ Main *bmain = CTX_data_main(C);
PropertyRNA *prop;
BLI_join_dirfile(filepath, FILE_MAX, sfile->params->dir, sfile->params->file); /* XXX, not real length */
if ((prop = RNA_struct_find_property(op->ptr, "relative_path"))) {
if (RNA_property_boolean_get(op->ptr, prop)) {
- BLI_path_rel(filepath, G.main->name);
+ BLI_path_rel(filepath, BKE_main_blendfile_path(bmain));
}
}
@@ -1221,7 +1224,7 @@ void file_sfile_to_operator_ex(wmOperator *op, SpaceFile *sfile, char *filepath)
if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) {
RNA_property_string_set(op->ptr, prop, filepath);
}
-
+
/* some ops have multiple files to select */
/* this is called on operators check() so clear collections first since
* they may be already set. */
@@ -1259,7 +1262,7 @@ void file_sfile_to_operator_ex(wmOperator *op, SpaceFile *sfile, char *filepath)
num_dirs++;
}
}
-
+
/* make sure the directory specified in the button is added even if no directory selected */
if (0 == num_dirs) {
RNA_property_collection_add(op->ptr, prop, &itemptr);
@@ -1270,15 +1273,16 @@ void file_sfile_to_operator_ex(wmOperator *op, SpaceFile *sfile, char *filepath)
}
}
-void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile)
+void file_sfile_to_operator(bContext *C, wmOperator *op, SpaceFile *sfile)
{
char filepath[FILE_MAX];
- file_sfile_to_operator_ex(op, sfile, filepath);
+ file_sfile_to_operator_ex(C, op, sfile, filepath);
}
-void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op)
+void file_operator_to_sfile(bContext *C, SpaceFile *sfile, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
PropertyRNA *prop;
/* If neither of the above are set, split the filepath back */
@@ -1295,10 +1299,10 @@ void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op)
RNA_property_string_get(op->ptr, prop, sfile->params->dir);
}
}
-
+
/* we could check for relative_path property which is used when converting
* in the other direction but doesnt hurt to do this every time */
- BLI_path_abs(sfile->params->dir, G.main->name);
+ BLI_path_abs(sfile->params->dir, BKE_main_blendfile_path(bmain));
/* XXX, files and dirs updates missing, not really so important though */
}
@@ -1330,12 +1334,12 @@ void file_draw_check(bContext *C)
wmOperator *op = sfile->op;
if (op) { /* fail on reload */
if (op->type->check) {
- file_sfile_to_operator(op, sfile);
-
+ file_sfile_to_operator(C, op, sfile);
+
/* redraw */
if (op->type->check(C, op)) {
- file_operator_to_sfile(sfile, op);
-
+ file_operator_to_sfile(C, sfile, op);
+
/* redraw, else the changed settings wont get updated */
ED_area_tag_redraw(CTX_wm_area(C));
}
@@ -1369,6 +1373,7 @@ bool file_draw_check_exists(SpaceFile *sfile)
int file_exec(bContext *C, wmOperator *exec_op)
{
+ Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
SpaceFile *sfile = CTX_wm_space_file(C);
const struct FileDirEntry *file = filelist_file(sfile->files, sfile->params->active_file);
@@ -1384,7 +1389,7 @@ int file_exec(bContext *C, wmOperator *exec_op)
BLI_parent_dir(sfile->params->dir);
}
else {
- BLI_cleanup_path(G.main->name, sfile->params->dir);
+ BLI_cleanup_path(BKE_main_blendfile_path(bmain), sfile->params->dir);
BLI_path_append(sfile->params->dir, sizeof(sfile->params->dir) - 1, file->relpath);
BLI_add_slash(sfile->params->dir);
}
@@ -1394,13 +1399,13 @@ int file_exec(bContext *C, wmOperator *exec_op)
/* opening file - sends events now, so things get handled on windowqueue level */
else if (sfile->op) {
wmOperator *op = sfile->op;
-
- /* when used as a macro, for doubleclick,
+
+ /* when used as a macro, for doubleclick,
* to prevent closing when doubleclicking on .. item */
if (RNA_boolean_get(exec_op->ptr, "need_active")) {
const int numfiles = filelist_files_ensure(sfile->files);
int i, active = 0;
-
+
for (i = 0; i < numfiles; i++) {
if (filelist_entry_select_index_get(sfile->files, i, CHECK_ALL)) {
active = 1;
@@ -1410,17 +1415,17 @@ int file_exec(bContext *C, wmOperator *exec_op)
if (active == 0)
return OPERATOR_CANCELLED;
}
-
+
sfile->op = NULL;
- file_sfile_to_operator_ex(op, sfile, filepath);
+ file_sfile_to_operator_ex(C, op, sfile, filepath);
if (BLI_exists(sfile->params->dir)) {
fsmenu_insert_entry(ED_fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, NULL,
FS_INSERT_SAVE | FS_INSERT_FIRST);
}
- BLI_make_file_string(G.main->name, filepath, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL),
+ BLI_make_file_string(BKE_main_blendfile_path(bmain), filepath, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL),
BLENDER_BOOKMARK_FILE);
fsmenu_write_file(ED_fsmenu_get(), filepath);
WM_event_fileselect_event(wm, op, EVT_FILESELECT_EXEC);
@@ -1438,10 +1443,10 @@ void FILE_OT_execute(struct wmOperatorType *ot)
ot->name = "Execute File Window";
ot->description = "Execute selected file";
ot->idname = "FILE_OT_execute";
-
+
/* api callbacks */
ot->exec = file_exec;
- ot->poll = file_operator_poll;
+ ot->poll = file_operator_poll;
/* properties */
prop = RNA_def_boolean(ot->srna, "need_active", 0, "Need Active",
@@ -1452,11 +1457,12 @@ void FILE_OT_execute(struct wmOperatorType *ot)
int file_parent_exec(bContext *C, wmOperator *UNUSED(unused))
{
+ Main *bmain = CTX_data_main(C);
SpaceFile *sfile = CTX_wm_space_file(C);
-
+
if (sfile->params) {
if (BLI_parent_dir(sfile->params->dir)) {
- BLI_cleanup_dir(G.main->name, sfile->params->dir);
+ BLI_cleanup_dir(BKE_main_blendfile_path(bmain), sfile->params->dir);
ED_file_change_dir(C);
if (sfile->params->recursion_level > 1) {
/* Disable 'dirtree' recursion when going up in tree. */
@@ -1466,7 +1472,7 @@ int file_parent_exec(bContext *C, wmOperator *UNUSED(unused))
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
}
}
-
+
return OPERATOR_FINISHED;
}
@@ -1478,7 +1484,7 @@ void FILE_OT_parent(struct wmOperatorType *ot)
ot->name = "Parent File";
ot->description = "Move to parent directory";
ot->idname = "FILE_OT_parent";
-
+
/* api callbacks */
ot->exec = file_parent_exec;
ot->poll = ED_operator_file_active; /* <- important, handler is on window level */
@@ -1509,7 +1515,7 @@ void FILE_OT_previous(struct wmOperatorType *ot)
ot->name = "Previous Folder";
ot->description = "Move to previous folder";
ot->idname = "FILE_OT_previous";
-
+
/* api callbacks */
ot->exec = file_previous_exec;
ot->poll = ED_operator_file_active; /* <- important, handler is on window level */
@@ -1540,7 +1546,7 @@ void FILE_OT_next(struct wmOperatorType *ot)
ot->name = "Next Folder";
ot->description = "Move to next folder";
ot->idname = "FILE_OT_next";
-
+
/* api callbacks */
ot->exec = file_next_exec;
ot->poll = ED_operator_file_active; /* <- important, handler is on window level */
@@ -1581,7 +1587,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
/* escape if not our timer */
if (sfile->smoothscroll_timer == NULL || sfile->smoothscroll_timer != event->customdata)
return OPERATOR_PASS_THROUGH;
-
+
numfiles = filelist_files_ensure(sfile->files);
/* check if we are editing a name */
@@ -1621,9 +1627,9 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->columns;
}
}
-
+
numfiles_layout = ED_fileselect_layout_numfiles(sfile->layout, ar);
-
+
/* check if we have reached our final scroll position */
if ( (sfile->scroll_offset >= offset) && (sfile->scroll_offset < offset + numfiles_layout) ) {
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer);
@@ -1631,10 +1637,10 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
return OPERATOR_FINISHED;
}
- /* temporarily set context to the main window region,
+ /* temporarily set context to the main window region,
* so the scroll operators work */
CTX_wm_region_set(C, ar);
-
+
/* scroll one step in the desired direction */
if (sfile->scroll_offset < offset) {
if (sfile->layout->flag & FILE_LAYOUT_HOR) {
@@ -1643,7 +1649,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
else {
WM_operator_name_call(C, "VIEW2D_OT_scroll_up", 0, NULL);
}
-
+
}
else {
if (sfile->layout->flag & FILE_LAYOUT_HOR) {
@@ -1653,27 +1659,27 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
WM_operator_name_call(C, "VIEW2D_OT_scroll_down", 0, NULL);
}
}
-
+
ED_region_tag_redraw(ar);
-
+
/* and restore context */
CTX_wm_region_set(C, oldar);
-
+
return OPERATOR_FINISHED;
}
void FILE_OT_smoothscroll(wmOperatorType *ot)
{
-
+
/* identifiers */
ot->name = "Smooth Scroll";
ot->idname = "FILE_OT_smoothscroll";
ot->description = "Smooth scroll to make editable file visible";
-
+
/* api callbacks */
ot->invoke = file_smoothscroll_invoke;
-
+
ot->poll = ED_operator_file_active;
}
@@ -1694,7 +1700,7 @@ static int filepath_drop_exec(bContext *C, wmOperator *op)
file_sfile_filepath_set(sfile, filepath);
if (sfile->op) {
- file_sfile_to_operator(sfile->op, sfile);
+ file_sfile_to_operator(C, sfile->op, sfile);
file_draw_check(C);
}
@@ -1749,12 +1755,12 @@ int file_directory_new_exec(bContext *C, wmOperator *op)
wmWindowManager *wm = CTX_wm_manager(C);
SpaceFile *sfile = CTX_wm_space_file(C);
ScrArea *sa = CTX_wm_area(C);
-
+
if (!sfile->params) {
BKE_report(op->reports, RPT_WARNING, "No parent directory given");
return OPERATOR_CANCELLED;
}
-
+
path[0] = '\0';
if ((prop = RNA_struct_find_property(op->ptr, "directory"))) {
@@ -1824,7 +1830,7 @@ void FILE_OT_directory_new(struct wmOperatorType *ot)
ot->name = "Create New Directory";
ot->description = "Create a new directory";
ot->idname = "FILE_OT_directory_new";
-
+
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = file_directory_new_exec;
@@ -1840,12 +1846,13 @@ void FILE_OT_directory_new(struct wmOperatorType *ot)
/* TODO This should go to BLI_path_utils. */
static void file_expand_directory(bContext *C)
{
+ Main *bmain = CTX_data_main(C);
SpaceFile *sfile = CTX_wm_space_file(C);
-
+
if (sfile->params) {
if (BLI_path_is_rel(sfile->params->dir)) {
/* Use of 'default' folder here is just to avoid an error message on '//' prefix. */
- BLI_path_abs(sfile->params->dir, G.relbase_valid ? G.main->name : BKE_appdir_folder_default());
+ BLI_path_abs(sfile->params->dir, G.relbase_valid ? BKE_main_blendfile_path(bmain) : BKE_appdir_folder_default());
}
else if (sfile->params->dir[0] == '~') {
char tmpstr[sizeof(sfile->params->dir) - 1];
@@ -1898,8 +1905,9 @@ static bool can_create_dir(const char *dir)
void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UNUSED(arg_but))
{
+ Main *bmain = CTX_data_main(C);
SpaceFile *sfile = CTX_wm_space_file(C);
-
+
if (sfile->params) {
file_expand_directory(C);
@@ -1928,7 +1936,7 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
}
}
- BLI_cleanup_dir(G.main->name, sfile->params->dir);
+ BLI_cleanup_dir(BKE_main_blendfile_path(bmain), sfile->params->dir);
if (filelist_is_dir(sfile->files, sfile->params->dir)) {
/* if directory exists, enter it immediately */
@@ -1975,6 +1983,7 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg_but)
{
+ Main *bmain = CTX_data_main(C);
SpaceFile *sfile = CTX_wm_space_file(C);
uiBut *but = arg_but;
char matched_file[FILE_MAX];
@@ -1995,7 +2004,7 @@ void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg
if (matches) {
/* replace the pattern (or filename that the user typed in, with the first selected file of the match */
BLI_strncpy(sfile->params->file, matched_file, sizeof(sfile->params->file));
-
+
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
}
@@ -2004,7 +2013,7 @@ void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg
/* if directory, open it and empty filename field */
if (filelist_is_dir(sfile->files, filepath)) {
- BLI_cleanup_dir(G.main->name, filepath);
+ BLI_cleanup_dir(BKE_main_blendfile_path(bmain), filepath);
BLI_strncpy(sfile->params->dir, filepath, sizeof(sfile->params->dir));
sfile->params->file[0] = '\0';
ED_file_change_dir(C);
@@ -2024,7 +2033,7 @@ void FILE_OT_refresh(struct wmOperatorType *ot)
ot->name = "Refresh Filelist";
ot->description = "Refresh the file list";
ot->idname = "FILE_OT_refresh";
-
+
/* api callbacks */
ot->exec = file_refresh_exec;
ot->poll = ED_operator_file_active; /* <- important, handler is on window level */
@@ -2035,13 +2044,13 @@ static int file_hidedot_exec(bContext *C, wmOperator *UNUSED(unused))
wmWindowManager *wm = CTX_wm_manager(C);
SpaceFile *sfile = CTX_wm_space_file(C);
ScrArea *sa = CTX_wm_area(C);
-
+
if (sfile->params) {
sfile->params->flag ^= FILE_HIDE_DOT;
ED_fileselect_clear(wm, sa, sfile);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
}
-
+
return OPERATOR_FINISHED;
}
@@ -2052,7 +2061,7 @@ void FILE_OT_hidedot(struct wmOperatorType *ot)
ot->name = "Toggle Hide Dot Files";
ot->description = "Toggle hide hidden dot files";
ot->idname = "FILE_OT_hidedot";
-
+
/* api callbacks */
ot->exec = file_hidedot_exec;
ot->poll = ED_operator_file_active; /* <- important, handler is on window level */
@@ -2067,11 +2076,11 @@ ARegion *file_tools_region(ScrArea *sa)
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
-
+
/* is error! */
if (ar == NULL)
return NULL;
-
+
arnew = MEM_callocN(sizeof(ARegion), "tools for file");
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
arnew->regiontype = RGN_TYPE_TOOLS;
@@ -2089,7 +2098,7 @@ static int file_bookmark_toggle_exec(bContext *C, wmOperator *UNUSED(unused))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = file_tools_region(sa);
-
+
if (ar)
ED_region_toggle_hidden(C, ar);
@@ -2102,7 +2111,7 @@ void FILE_OT_bookmark_toggle(struct wmOperatorType *ot)
ot->name = "Toggle Bookmarks";
ot->description = "Toggle bookmarks display";
ot->idname = "FILE_OT_bookmark_toggle";
-
+
/* api callbacks */
ot->exec = file_bookmark_toggle_exec;
ot->poll = ED_operator_file_active; /* <- important, handler is on window level */
@@ -2144,7 +2153,7 @@ static int file_filenum_exec(bContext *C, wmOperator *op)
{
SpaceFile *sfile = CTX_wm_space_file(C);
ScrArea *sa = CTX_wm_area(C);
-
+
int inc = RNA_int_get(op->ptr, "increment");
if (sfile->params && (inc != 0)) {
filenum_newname(sfile->params->file, sizeof(sfile->params->file), inc);
@@ -2152,7 +2161,7 @@ static int file_filenum_exec(bContext *C, wmOperator *op)
file_draw_check(C);
// WM_event_add_notifier(C, NC_WINDOW, NULL);
}
-
+
return OPERATOR_FINISHED;
}
@@ -2163,7 +2172,7 @@ void FILE_OT_filenum(struct wmOperatorType *ot)
ot->name = "Increment Number in Filename";
ot->description = "Increment number in filename";
ot->idname = "FILE_OT_filenum";
-
+
/* api callbacks */
ot->exec = file_filenum_exec;
ot->poll = ED_operator_file_active; /* <- important, handler is on window level */
@@ -2176,7 +2185,7 @@ static int file_rename_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C);
-
+
if (sfile->params) {
int idx = sfile->params->highlight_file;
int numfiles = filelist_files_ensure(sfile->files);
@@ -2188,7 +2197,7 @@ static int file_rename_exec(bContext *C, wmOperator *UNUSED(op))
}
ED_area_tag_redraw(sa);
}
-
+
return OPERATOR_FINISHED;
}
@@ -2232,10 +2241,10 @@ void FILE_OT_rename(struct wmOperatorType *ot)
ot->name = "Rename File or Directory";
ot->description = "Rename file or file directory";
ot->idname = "FILE_OT_rename";
-
+
/* api callbacks */
ot->exec = file_rename_exec;
- ot->poll = file_rename_poll;
+ ot->poll = file_rename_poll;
}
@@ -2262,13 +2271,14 @@ static int file_delete_poll(bContext *C)
}
else
poll = 0;
-
+
return poll;
}
int file_delete_exec(bContext *C, wmOperator *op)
{
char str[FILE_MAX];
+ Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
SpaceFile *sfile = CTX_wm_space_file(C);
ScrArea *sa = CTX_wm_area(C);
@@ -2281,7 +2291,7 @@ int file_delete_exec(bContext *C, wmOperator *op)
for (i = 0; i < numfiles; i++) {
if (filelist_entry_select_index_get(sfile->files, i, CHECK_FILES)) {
file = filelist_file(sfile->files, i);
- BLI_make_file_string(G.main->name, str, sfile->params->dir, file->relpath);
+ BLI_make_file_string(BKE_main_blendfile_path(bmain), str, sfile->params->dir, file->relpath);
if (BLI_delete(str, false, false) != 0 ||
BLI_exists(str))
{
@@ -2289,7 +2299,7 @@ int file_delete_exec(bContext *C, wmOperator *op)
}
}
}
-
+
if (report_error) {
BKE_reportf(op->reports, RPT_ERROR,
"Could not delete file: %s",
@@ -2298,7 +2308,7 @@ int file_delete_exec(bContext *C, wmOperator *op)
ED_fileselect_clear(wm, sa, sfile);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -2309,7 +2319,7 @@ void FILE_OT_delete(struct wmOperatorType *ot)
ot->name = "Delete Selected Files";
ot->description = "Delete selected files";
ot->idname = "FILE_OT_delete";
-
+
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = file_delete_exec;
@@ -2321,6 +2331,6 @@ void ED_operatormacros_file(void)
{
// wmOperatorType *ot;
// wmOperatorTypeMacro *otmacro;
-
+
/* future macros */
}
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index 363e9666399..78bbe3aea58 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation, Andrea Weikert
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index d670af59bc9..8123bed541c 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -43,7 +43,7 @@
#else
# include <io.h>
# include <direct.h>
-#endif
+#endif
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
@@ -188,13 +188,13 @@ void folderlist_free(ListBase *folderlist)
ListBase *folderlist_duplicate(ListBase *folderlist)
{
-
+
if (folderlist) {
ListBase *folderlistn = MEM_callocN(sizeof(*folderlistn), __func__);
FolderList *folder;
-
+
BLI_duplicatelist(folderlistn, folderlist);
-
+
for (folder = folderlistn->first; folder; folder = folder->next) {
folder->foldername = MEM_dupallocN(folder->foldername);
}
@@ -404,7 +404,7 @@ static int compare_direntry_generic(const FileListInternEntry *entry1, const Fil
if (FILENAME_IS_CURRENT(entry2->relpath)) return 1;
if (FILENAME_IS_PARENT(entry1->relpath)) return -1;
if (FILENAME_IS_PARENT(entry2->relpath)) return 1;
-
+
return 0;
}
@@ -436,7 +436,7 @@ static int compare_date(void *UNUSED(user_data), const void *a1, const void *a2)
if ((ret = compare_direntry_generic(entry1, entry2))) {
return ret;
}
-
+
time1 = (int64_t)entry1->st.st_mtime;
time2 = (int64_t)entry2->st.st_mtime;
if (time1 < time2) return 1;
@@ -459,7 +459,7 @@ static int compare_size(void *UNUSED(user_data), const void *a1, const void *a2)
if ((ret = compare_direntry_generic(entry1, entry2))) {
return ret;
}
-
+
size1 = entry1->st.st_size;
size2 = entry2->st.st_size;
if (size1 < size2) return 1;
@@ -1347,7 +1347,7 @@ void filelist_free(struct FileList *filelist)
printf("Attempting to delete empty filelist.\n");
return;
}
-
+
filelist_clear_ex(filelist, false, false); /* No need to clear cache & selection_state, we free them anyway. */
filelist_cache_free(&filelist->filelist_cache);
@@ -1419,7 +1419,7 @@ void filelist_setdir(struct FileList *filelist, char *r_dir)
{
BLI_assert(strlen(r_dir) < FILE_MAX_LIBEXTRA);
- BLI_cleanup_dir(G.main->name, r_dir);
+ BLI_cleanup_dir(BKE_main_blendfile_path_from_global(), r_dir);
const bool is_valid_path = filelist->checkdirf(filelist, r_dir, true);
BLI_assert(is_valid_path);
UNUSED_VARS_NDEBUG(is_valid_path);
@@ -1555,7 +1555,7 @@ FileDirEntry *filelist_file(struct FileList *filelist, int index)
int filelist_file_findpath(struct FileList *filelist, const char *filename)
{
int fidx = -1;
-
+
if (filelist->filelist.nbr_entries_filtered < 0) {
return fidx;
}
@@ -1950,17 +1950,17 @@ static bool file_is_blend_backup(const char *str)
}
else {
const char *loc;
-
+
if (a > b + 1)
b++;
-
+
/* allow .blend1 .blend2 .blend32 */
loc = BLI_strcasestr(str + a - b, ".blend");
-
+
if (loc)
retval = 1;
}
-
+
return (retval);
}
@@ -2024,7 +2024,7 @@ static int file_extension_type(const char *dir, const char *relpath)
int ED_file_extension_icon(const char *path)
{
const int type = ED_path_extension_type(path);
-
+
switch (type) {
case FILE_TYPE_BLENDER:
return ICON_FILE_BLEND;
@@ -2313,13 +2313,13 @@ static int filelist_readjob_list_lib(const char *root, ListBase *entries, const
#if 0
/* Kept for reference here, in case we want to add back that feature later. We do not need it currently. */
/* Code ***NOT*** updated for job stuff! */
-static void filelist_readjob_main_rec(struct FileList *filelist)
+static void filelist_readjob_main_rec(Main *bmain, FileList *filelist)
{
ID *id;
FileDirEntry *files, *firstlib = NULL;
ListBase *lb;
int a, fake, idcode, ok, totlib, totbl;
-
+
// filelist->type = FILE_MAIN; // XXX TODO: add modes to filebrowser
BLI_assert(filelist->filelist.entries == NULL);
@@ -2375,7 +2375,7 @@ static void filelist_readjob_main_rec(struct FileList *filelist)
/* make files */
idcode = groupname_to_code(filelist->filelist.root);
- lb = which_libbase(G.main, idcode);
+ lb = which_libbase(bmain, idcode);
if (lb == NULL) return;
filelist->filelist.nbr_entries = 0;
@@ -2394,7 +2394,7 @@ static void filelist_readjob_main_rec(struct FileList *filelist)
}
files = filelist->filelist.entries;
-
+
if (!(filelist->filter_data.flags & FLF_HIDE_PARENT)) {
files->entry->relpath = BLI_strdup(FILENAME_PARENT);
files->typeflag |= FILE_TYPE_DIR;
@@ -2700,13 +2700,14 @@ static void filelist_readjob_free(void *flrjv)
void filelist_readjob_start(FileList *filelist, const bContext *C)
{
+ Main *bmain = CTX_data_main(C);
wmJob *wm_job;
FileListReadJob *flrj;
/* prepare job data */
flrj = MEM_callocN(sizeof(*flrj), __func__);
flrj->filelist = filelist;
- BLI_strncpy(flrj->main_name, G.main->name, sizeof(flrj->main_name));
+ BLI_strncpy(flrj->main_name, BKE_main_blendfile_path(bmain), sizeof(flrj->main_name));
filelist->flags &= ~(FL_FORCE_RESET | FL_IS_READY);
filelist->flags |= FL_IS_PENDING;
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 3dfeb5eb5b3..418a9f8c16f 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -96,11 +96,13 @@ short ED_fileselect_set_params(SpaceFile *sfile)
FileSelectParams *params;
wmOperator *op = sfile->op;
+ const char *blendfile_path = BKE_main_blendfile_path_from_global();
+
/* create new parameters if necessary */
if (!sfile->params) {
sfile->params = MEM_callocN(sizeof(FileSelectParams), "fileselparams");
/* set path to most recently opened .blend */
- BLI_split_dirfile(G.main->name, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file));
+ BLI_split_dirfile(blendfile_path, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file));
sfile->params->filter_glob[0] = '\0';
/* set the default thumbnails size */
sfile->params->thumbnail_size = 128;
@@ -149,8 +151,8 @@ short ED_fileselect_set_params(SpaceFile *sfile)
}
if (params->dir[0]) {
- BLI_cleanup_dir(G.main->name, params->dir);
- BLI_path_abs(params->dir, G.main->name);
+ BLI_cleanup_dir(blendfile_path, params->dir);
+ BLI_path_abs(params->dir, blendfile_path);
}
if (is_directory == true && is_filename == false && is_filepath == false && is_files == false) {
@@ -224,7 +226,7 @@ short ED_fileselect_set_params(SpaceFile *sfile)
else {
params->flag &= ~FILE_HIDE_DOT;
}
-
+
if (params->type == FILE_LOADLIB) {
params->flag |= RNA_boolean_get(op->ptr, "link") ? FILE_LINK : 0;
@@ -283,8 +285,8 @@ short ED_fileselect_set_params(SpaceFile *sfile)
sfile->folders_prev = folderlist_new();
if (!sfile->params->dir[0]) {
- if (G.main->name[0]) {
- BLI_split_dir_part(G.main->name, sfile->params->dir, sizeof(sfile->params->dir));
+ if (blendfile_path[0] != '\0') {
+ BLI_split_dir_part(blendfile_path, sfile->params->dir, sizeof(sfile->params->dir));
}
else {
const char *doc_path = BKE_appdir_folder_default();
@@ -366,12 +368,12 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r
if (layout == NULL)
return sel;
-
+
colmin = (rect->xmin) / (layout->tile_w + 2 * layout->tile_border_x);
rowmin = (rect->ymin) / (layout->tile_h + 2 * layout->tile_border_y);
colmax = (rect->xmax) / (layout->tile_w + 2 * layout->tile_border_x);
rowmax = (rect->ymax) / (layout->tile_h + 2 * layout->tile_border_y);
-
+
if (is_inside(colmin, rowmin, layout->columns, layout->rows) ||
is_inside(colmax, rowmax, layout->columns, layout->rows) )
{
@@ -380,12 +382,12 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r
CLAMP(colmax, 0, layout->columns - 1);
CLAMP(rowmax, 0, layout->rows - 1);
}
-
+
if ((colmin > layout->columns - 1) || (rowmin > layout->rows - 1)) {
sel.first = -1;
}
else {
- if (layout->flag & FILE_LAYOUT_HOR)
+ if (layout->flag & FILE_LAYOUT_HOR)
sel.first = layout->rows * colmin + rowmin;
else
sel.first = colmin + layout->columns * rowmin;
@@ -394,7 +396,7 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r
sel.last = -1;
}
else {
- if (layout->flag & FILE_LAYOUT_HOR)
+ if (layout->flag & FILE_LAYOUT_HOR)
sel.last = layout->rows * colmax + rowmax;
else
sel.last = colmax + layout->columns * rowmax;
@@ -410,14 +412,14 @@ int ED_fileselect_layout_offset(FileLayout *layout, int x, int y)
if (layout == NULL)
return -1;
-
+
offsetx = (x) / (layout->tile_w + 2 * layout->tile_border_x);
offsety = (y) / (layout->tile_h + 2 * layout->tile_border_y);
-
+
if (offsetx > layout->columns - 1) return -1;
if (offsety > layout->rows - 1) return -1;
-
- if (layout->flag & FILE_LAYOUT_HOR)
+
+ if (layout->flag & FILE_LAYOUT_HOR)
active_file = layout->rows * offsetx + offsety;
else
active_file = offsetx + layout->columns * offsety;
@@ -611,12 +613,12 @@ void ED_file_change_dir(bContext *C)
int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matched_file)
{
int match = 0;
-
+
int i;
FileDirEntry *file;
int n = filelist_files_ensure(sfile->files);
- /* select any file that matches the pattern, this includes exact match
+ /* select any file that matches the pattern, this includes exact match
* if the user selects a single file by entering the filename
*/
for (i = 0; i < n; i++) {
@@ -645,7 +647,7 @@ int autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v))
DIR *dir;
struct dirent *de;
-
+
BLI_split_dir_part(str, dirname, sizeof(dirname));
dir = opendir(dirname);
@@ -660,7 +662,7 @@ int autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v))
else {
char path[FILE_MAX];
BLI_stat_t status;
-
+
BLI_join_dirfile(path, sizeof(path), dirname, de->d_name);
if (BLI_stat(path, &status) == 0) {
@@ -726,7 +728,7 @@ void ED_fileselect_exit(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile)
folderlist_free(sfile->folders_prev);
folderlist_free(sfile->folders_next);
-
+
if (sfile->files) {
ED_fileselect_clear(wm, sa, sfile);
filelist_free(sfile->files);
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index ea251f2018c..5ecb95bf61b 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -350,7 +350,7 @@ void fsmenu_remove_entry(struct FSMenu *fsmenu, FSMenuCategory category, int idx
idx--;
if (fsm_iter) {
- /* you should only be able to remove entries that were
+ /* you should only be able to remove entries that were
* not added by default, like windows drives.
* also separators (where path == NULL) shouldn't be removed */
if (fsm_iter->save && fsm_iter->path) {
@@ -510,18 +510,18 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
/* Get mounted volumes better method OSX 10.6 and higher, see: */
/*https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html*/
/* we get all volumes sorted including network and do not relay on user-defined finder visibility, less confusing */
-
+
CFURLRef cfURL = NULL;
CFURLEnumeratorResult result = kCFURLEnumeratorSuccess;
CFURLEnumeratorRef volEnum = CFURLEnumeratorCreateForMountedVolumes(NULL, kCFURLEnumeratorSkipInvisibles, NULL);
-
+
while (result != kCFURLEnumeratorEnd) {
char defPath[FILE_MAX];
result = CFURLEnumeratorGetNextURL(volEnum, &cfURL, NULL);
if (result != kCFURLEnumeratorSuccess)
continue;
-
+
CFURLGetFileSystemRepresentation(cfURL, false, (UInt8 *)defPath, FILE_MAX);
/* Add end slash for consistency with other platforms */
@@ -529,29 +529,29 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, defPath, NULL, FS_INSERT_SORTED);
}
-
+
CFRelease(volEnum);
-
+
/* Finally get user favorite places */
if (read_bookmarks) {
UInt32 seed;
LSSharedFileListRef list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteItems, NULL);
CFArrayRef pathesArray = LSSharedFileListCopySnapshot(list, &seed);
CFIndex pathesCount = CFArrayGetCount(pathesArray);
-
+
for (CFIndex i = 0; i < pathesCount; i++) {
LSSharedFileListItemRef itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i);
-
+
CFURLRef cfURL = NULL;
- OSErr err = LSSharedFileListItemResolve(itemRef,
+ OSErr err = LSSharedFileListItemResolve(itemRef,
kLSSharedFileListNoUserInteraction |
kLSSharedFileListDoNotMountVolumes,
&cfURL, NULL);
if (err != noErr || !cfURL)
continue;
-
+
CFStringRef pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle);
-
+
if (pathString == NULL || !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingUTF8))
continue;
@@ -563,11 +563,11 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
if (!strstr(line, "myDocuments.cannedSearch") && (*line != '\0')) {
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, FS_INSERT_LAST);
}
-
+
CFRelease(pathString);
CFRelease(cfURL);
}
-
+
CFRelease(pathesArray);
CFRelease(list);
}
diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h
index 81014874fb5..85804538e19 100644
--- a/source/blender/editors/space_file/fsmenu.h
+++ b/source/blender/editors/space_file/fsmenu.h
@@ -23,7 +23,7 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- *
+ *
*/
/** \file blender/editors/space_file/fsmenu.h
@@ -60,7 +60,7 @@ void fsmenu_remove_entry(struct FSMenu *fsmenu, enum FSMenuCategory category,
/** saves the 'bookmarks' to the specified file */
void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename);
-
+
/** reads the 'bookmarks' from the specified file */
void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename);
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 40707d5add7..62e7c7923e8 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -115,9 +115,9 @@ static SpaceLink *file_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen
/* not spacelink itself */
static void file_free(SpaceLink *sl)
-{
+{
SpaceFile *sfile = (SpaceFile *) sl;
-
+
BLI_assert(sfile->previews_timer == NULL);
if (sfile->files) {
@@ -185,7 +185,7 @@ static SpaceLink *file_duplicate(SpaceLink *sl)
{
SpaceFile *sfileo = (SpaceFile *)sl;
SpaceFile *sfilen = MEM_dupallocN(sl);
-
+
/* clear or remove stuff from old */
sfilen->op = NULL; /* file window doesn't own operators */
@@ -203,7 +203,7 @@ static SpaceLink *file_duplicate(SpaceLink *sl)
if (sfileo->folders_next)
sfilen->folders_next = folderlist_duplicate(sfileo->folders_next);
-
+
if (sfileo->layout) {
sfilen->layout = MEM_dupallocN(sfileo->layout);
}
@@ -326,9 +326,9 @@ static void file_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Sce
static void file_main_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
-
+
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
-
+
/* own keymaps */
keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
@@ -410,9 +410,9 @@ static void file_main_region_draw(const bContext *C, ARegion *ar)
UI_GetThemeColor3fv(TH_BACK, col);
glClearColor(col[0], col[1], col[2], 0.0);
glClear(GL_COLOR_BUFFER_BIT);
-
+
/* Allow dynamically sliders to be set, saves notifiers etc. */
-
+
if (params->display == FILE_IMGDISPLAY) {
v2d->scroll = V2D_SCROLL_RIGHT;
v2d->keepofs &= ~V2D_LOCKOFS_Y;
@@ -422,7 +422,7 @@ static void file_main_region_draw(const bContext *C, ARegion *ar)
v2d->scroll = V2D_SCROLL_BOTTOM;
v2d->keepofs &= ~V2D_LOCKOFS_X;
v2d->keepofs |= V2D_LOCKOFS_Y;
-
+
/* XXX this happens on scaling down Screen (like from startup.blend) */
/* view2d has no type specific for filewindow case, which doesnt scroll vertically */
if (v2d->cur.ymax < 0) {
@@ -438,18 +438,18 @@ static void file_main_region_draw(const bContext *C, ARegion *ar)
/* set view */
UI_view2d_view_ortho(v2d);
-
+
/* on first read, find active file */
if (params->highlight_file == -1) {
wmEvent *event = CTX_wm_window(C)->eventstate;
file_highlight_set(sfile, ar, event->x, event->y);
}
-
+
file_draw_list(C, ar);
-
+
/* reset view matrix */
UI_view2d_view_restore(C);
-
+
/* scrollers */
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
UI_view2d_scrollers_draw(C, v2d, scrollers);
@@ -603,8 +603,8 @@ static void file_keymap(struct wmKeyConfig *keyconf)
RNA_int_set(kmi->ptr, "increment", -10);
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_CTRL, 0);
RNA_int_set(kmi->ptr, "increment", -100);
-
-
+
+
/* keys for button region (top) */
keymap = WM_keymap_find(keyconf, "File Browser Buttons", SPACE_FILE, 0);
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0);
@@ -655,9 +655,9 @@ static void file_tools_region_listener(
static void file_header_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
-
+
ED_region_header_init(ar);
-
+
keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
}
@@ -748,10 +748,10 @@ void ED_spacetype_file(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype file");
ARegionType *art;
-
+
st->spaceid = SPACE_FILE;
strncpy(st->name, "File", BKE_ST_MAXNAME);
-
+
st->new = file_new;
st->free = file_free;
st->init = file_init;
@@ -772,7 +772,7 @@ void ED_spacetype_file(void)
art->message_subscribe = file_main_region_message_subscribe;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
art->regionid = RGN_TYPE_HEADER;
@@ -782,7 +782,7 @@ void ED_spacetype_file(void)
art->draw = file_header_region_draw;
// art->listener = file_header_region_listener;
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: ui */
art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
art->regionid = RGN_TYPE_UI;
@@ -843,7 +843,7 @@ void ED_file_exit(void)
void ED_file_read_bookmarks(void)
{
const char * const cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, NULL);
-
+
fsmenu_free();
fsmenu_read_system(ED_fsmenu_get(), true);
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index 3c75bc5763d..4f3de0398a2 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation, Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
@@ -81,25 +81,25 @@ static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **
{
bAnimContext ac;
bAnimListElem *elem = NULL;
-
- /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools)
+
+ /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools)
* to work correctly is able to be correctly retrieved. There's no point showing empty panels?
*/
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0)
return 0;
-
+
/* try to find 'active' F-Curve */
elem = get_active_fcurve_channel(&ac);
- if (elem == NULL)
+ if (elem == NULL)
return 0;
-
+
if (fcu)
*fcu = (FCurve *)elem->data;
if (ale)
*ale = elem;
else
MEM_freeN(elem);
-
+
return 1;
}
@@ -118,7 +118,7 @@ static void graph_panel_view(const bContext *C, Panel *pa)
Scene *scene = CTX_data_scene(C);
PointerRNA spaceptr, sceneptr;
uiLayout *col, *sub, *row;
-
+
/* get RNA pointers for use when creating the UI elements */
RNA_id_pointer_create(&scene->id, &sceneptr);
RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr);
@@ -126,7 +126,7 @@ static void graph_panel_view(const bContext *C, Panel *pa)
/* 2D-Cursor */
col = uiLayoutColumn(pa->layout, false);
uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE);
-
+
sub = uiLayoutColumn(col, true);
uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump");
@@ -139,7 +139,7 @@ static void graph_panel_view(const bContext *C, Panel *pa)
else
uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE);
uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA);
-
+
row = uiLayoutSplit(sub, 0.7f, true);
uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE);
uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE);
@@ -159,10 +159,10 @@ static void graph_panel_properties(const bContext *C, Panel *pa)
if (!graph_panel_context(C, &ale, &fcu))
return;
-
+
/* F-Curve pointer */
RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr);
-
+
/* user-friendly 'name' for F-Curve */
col = uiLayoutColumn(layout, false);
if (ale->type == ANIMTYPE_FCURVE) {
@@ -172,7 +172,7 @@ static void graph_panel_properties(const bContext *C, Panel *pa)
else {
/* NLA Control Curve, etc. */
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
-
+
/* get name */
if (acf && acf->name) {
acf->name(ale, name);
@@ -181,35 +181,35 @@ static void graph_panel_properties(const bContext *C, Panel *pa)
strcpy(name, IFACE_("<invalid>"));
icon = ICON_ERROR;
}
-
+
/* icon */
if (ale->type == ANIMTYPE_NLACURVE)
icon = ICON_NLA;
}
uiItemL(col, name, icon);
-
+
/* RNA-Path Editing - only really should be enabled when things aren't working */
col = uiLayoutColumn(layout, true);
uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED) != 0);
uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA);
uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE);
-
+
/* color settings */
col = uiLayoutColumn(layout, true);
uiItemL(col, IFACE_("Display Color:"), ICON_NONE);
-
+
row = uiLayoutRow(col, true);
uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE);
-
+
sub = uiLayoutRow(row, true);
uiLayoutSetEnabled(sub, (fcu->color_mode == FCURVE_COLOR_CUSTOM));
uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE);
-
+
/* smoothing setting */
col = uiLayoutColumn(layout, true);
uiItemL(col, IFACE_("Auto Handle Smoothing:"), ICON_NONE);
uiItemR(col, &fcu_ptr, "auto_smoothing", 0, "", ICON_NONE);
-
+
MEM_freeN(ale);
}
@@ -220,31 +220,31 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT
{
BezTriple *b;
int i;
-
+
/* zero the pointers */
*bezt = *prevbezt = NULL;
-
+
/* sanity checks */
if ((fcu->bezt == NULL) || (fcu->totvert == 0))
return 0;
-
- /* find first selected keyframe for now, and call it the active one
- * - this is a reasonable assumption, given that whenever anyone
+
+ /* find first selected keyframe for now, and call it the active one
+ * - this is a reasonable assumption, given that whenever anyone
* wants to edit numerically, there is likely to only be 1 vert selected
*/
for (i = 0, b = fcu->bezt; i < fcu->totvert; i++, b++) {
if (BEZT_ISSEL_ANY(b)) {
- /* found
+ /* found
* - 'previous' is either the one before, of the keyframe itself (which is still fine)
* XXX: we can just make this null instead if needed
*/
*prevbezt = (i > 0) ? b - 1 : b;
*bezt = b;
-
+
return 1;
}
}
-
+
/* not found */
return 0;
}
@@ -253,7 +253,7 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT
static void graphedit_activekey_update_cb(bContext *UNUSED(C), void *fcu_ptr, void *UNUSED(bezt_ptr))
{
FCurve *fcu = (FCurve *)fcu_ptr;
-
+
/* make sure F-Curve and its handles are still valid after this editing */
sort_time_fcurve(fcu);
calchandles_fcurve(fcu);
@@ -263,8 +263,8 @@ static void graphedit_activekey_update_cb(bContext *UNUSED(C), void *fcu_ptr, vo
static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
{
BezTriple *bezt = (BezTriple *)bezt_ptr;
-
- /* since editing the handles, make sure they're set to types which are receptive to editing
+
+ /* since editing the handles, make sure they're set to types which are receptive to editing
* see transform_conversions.c :: createTransGraphEditData(), last step in second loop
*/
if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) {
@@ -275,7 +275,7 @@ static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bez
else {
BKE_nurb_bezt_handle_test(bezt, true);
}
-
+
/* now call standard updates */
graphedit_activekey_update_cb(C, fcu_ptr, bezt_ptr);
}
@@ -305,20 +305,20 @@ static void graphedit_activekey_left_handle_coord_cb(bContext *C, void *fcu_ptr,
static void graphedit_activekey_right_handle_coord_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
{
BezTriple *bezt = (BezTriple *)bezt_ptr;
-
+
/* original state of handle selection - to be restored after performing the recalculation */
const char f1 = bezt->f1;
const char f3 = bezt->f3;
-
- /* temporarily make it so that only the right handle is selected, so that updates go correctly
+
+ /* temporarily make it so that only the right handle is selected, so that updates go correctly
* (i.e. it now acts as if we've just transforming the vert when it is selected by itself)
*/
bezt->f1 &= ~SELECT;
bezt->f3 |= SELECT;
-
+
/* perform normal updates NOW */
graphedit_activekey_handles_cb(C, fcu_ptr, bezt_ptr);
-
+
/* restore selection state so that no-one notices this hack */
bezt->f1 = f1;
bezt->f3 = f3;
@@ -329,34 +329,34 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
bAnimListElem *ale;
FCurve *fcu;
BezTriple *bezt, *prevbezt;
-
+
uiLayout *layout = pa->layout;
uiLayout *col;
uiBlock *block;
if (!graph_panel_context(C, &ale, &fcu))
return;
-
+
block = uiLayoutGetBlock(layout);
/* UI_block_func_handle_set(block, do_graph_region_buttons, NULL); */
-
+
/* only show this info if there are keyframes to edit */
if (get_active_fcurve_keyframe_edit(fcu, &bezt, &prevbezt)) {
PointerRNA bezt_ptr, id_ptr, fcu_prop_ptr;
PropertyRNA *fcu_prop = NULL;
uiBut *but;
int unit = B_UNIT_NONE;
-
+
/* RNA pointer to keyframe, to allow editing */
RNA_pointer_create(ale->id, &RNA_Keyframe, bezt, &bezt_ptr);
-
+
/* get property that F-Curve affects, for some unit-conversion magic */
RNA_id_pointer_create(ale->id, &id_ptr);
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &fcu_prop_ptr, &fcu_prop)) {
/* determine the unit for this property */
unit = RNA_SUBTYPE_UNIT(RNA_property_subtype(fcu_prop));
}
-
+
/* interpolation */
col = uiLayoutColumn(layout, false);
if (fcu->flag & FCURVE_DISCRETE_VALUES) {
@@ -367,7 +367,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
else {
uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE);
}
-
+
/* easing type */
if (bezt->ipo > BEZT_IPO_BEZ)
uiItemR(col, &bezt_ptr, "easing", 0, NULL, 0);
@@ -386,8 +386,8 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
default:
break;
}
-
- /* numerical coordinate editing
+
+ /* numerical coordinate editing
* - we use the button-versions of the calls so that we can attach special update handlers
* and unit conversion magic that cannot be achieved using a purely RNA-approach
*/
@@ -395,50 +395,50 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
/* keyframe itself */
{
uiItemL(col, IFACE_("Key:"), ICON_NONE);
-
+
but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, IFACE_("Frame:"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "co", 0, 0, 0, -1, -1, NULL);
UI_but_func_set(but, graphedit_activekey_update_cb, fcu, bezt);
-
+
but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, IFACE_("Value:"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "co", 1, 0, 0, -1, -1, NULL);
UI_but_func_set(but, graphedit_activekey_update_cb, fcu, bezt);
UI_but_unit_type_set(but, unit);
}
-
+
/* previous handle - only if previous was Bezier interpolation */
if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) {
uiItemL(col, IFACE_("Left Handle:"), ICON_NONE);
-
+
but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, "X:", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL);
UI_but_func_set(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt);
-
+
but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, "Y:", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL);
UI_but_func_set(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt);
UI_but_unit_type_set(but, unit);
-
+
/* XXX: with label? */
but = uiDefButR(block, UI_BTYPE_MENU, B_REDR, NULL, 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_left_type", 0, 0, 0, -1, -1, "Type of left handle");
UI_but_func_set(but, graphedit_activekey_handles_cb, fcu, bezt);
}
-
+
/* next handle - only if current is Bezier interpolation */
if (bezt->ipo == BEZT_IPO_BEZ) {
/* NOTE: special update callbacks are needed on the coords here due to T39911 */
uiItemL(col, IFACE_("Right Handle:"), ICON_NONE);
-
+
but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, "X:", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL);
UI_but_func_set(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt);
-
+
but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, "Y:", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL);
UI_but_func_set(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt);
UI_but_unit_type_set(but, unit);
-
+
/* XXX: with label? */
but = uiDefButR(block, UI_BTYPE_MENU, B_REDR, NULL, 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_right_type", 0, 0, 0, -1, -1, "Type of right handle");
@@ -459,7 +459,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
else
uiItemL(layout, IFACE_("No active keyframe on F-Curve"), ICON_NONE);
}
-
+
MEM_freeN(ale);
}
@@ -471,26 +471,26 @@ static void do_graph_region_driver_buttons(bContext *C, void *fcu_v, int event)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
-
+
switch (event) {
case B_IPO_DEPCHANGE:
{
/* force F-Curve & Driver to get re-evaluated (same as the old Update Dependencies) */
FCurve *fcu = (FCurve *)fcu_v;
ChannelDriver *driver = (fcu) ? fcu->driver : NULL;
-
+
/* clear invalid flags */
if (fcu) {
fcu->flag &= ~FCURVE_DISABLED;
driver->flag &= ~DRIVER_FLAG_INVALID;
}
-
+
/* rebuild depsgraph for the new deps */
DEG_relations_tag_update(bmain);
break;
}
}
-
+
/* default for now */
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); // XXX could use better notifier
}
@@ -499,7 +499,7 @@ static void do_graph_region_driver_buttons(bContext *C, void *fcu_v, int event)
static void driver_add_var_cb(bContext *C, void *driver_v, void *UNUSED(arg))
{
ChannelDriver *driver = (ChannelDriver *)driver_v;
-
+
/* add a new variable */
driver_add_new_variable(driver);
ED_undo_push(C, "Add Driver Variable");
@@ -510,7 +510,7 @@ static void driver_delete_var_cb(bContext *C, void *driver_v, void *dvar_v)
{
ChannelDriver *driver = (ChannelDriver *)driver_v;
DriverVar *dvar = (DriverVar *)dvar_v;
-
+
/* remove the active variable */
driver_free_variable_ex(driver, dvar);
ED_undo_push(C, "Delete Driver Variable");
@@ -521,9 +521,9 @@ static void driver_dvar_invalid_name_query_cb(bContext *C, void *dvar_v, void *U
{
uiPopupMenu *pup = UI_popup_menu_begin(C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Invalid Variable Name"), ICON_NONE);
uiLayout *layout = UI_popup_menu_layout(pup);
-
+
DriverVar *dvar = (DriverVar *)dvar_v;
-
+
if (dvar->flag & DVAR_FLAG_INVALID_EMPTY) {
uiItemL(layout, "It cannot be left blank", ICON_ERROR);
}
@@ -531,7 +531,7 @@ static void driver_dvar_invalid_name_query_cb(bContext *C, void *dvar_v, void *U
uiItemL(layout, "It cannot start with a number", ICON_ERROR);
}
if (dvar->flag & DVAR_FLAG_INVALID_START_CHAR) {
- uiItemL(layout,
+ uiItemL(layout,
"It cannot start with a special character,"
" including '$', '@', '!', '~', '+', '-', '_', '.', or ' '",
ICON_NONE);
@@ -548,7 +548,7 @@ static void driver_dvar_invalid_name_query_cb(bContext *C, void *dvar_v, void *U
if (dvar->flag & DVAR_FLAG_INVALID_PY_KEYWORD) {
uiItemL(layout, "It cannot be a reserved keyword in Python", ICON_INFO);
}
-
+
UI_popup_menu_end(C, pup);
}
@@ -557,7 +557,7 @@ static void driver_update_flags_cb(bContext *UNUSED(C), void *fcu_v, void *UNUSE
{
FCurve *fcu = (FCurve *)fcu_v;
ChannelDriver *driver = fcu->driver;
-
+
/* clear invalid flags */
fcu->flag &= ~FCURVE_DISABLED;
driver->flag &= ~DRIVER_FLAG_INVALID;
@@ -580,22 +580,22 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa
DriverTarget *dtar = &dvar->targets[0];
PointerRNA dtar_ptr;
uiLayout *row, *col;
-
+
/* initialize RNA pointer to the target */
- RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr);
-
+ RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr);
+
/* Target ID */
row = uiLayoutRow(layout, false);
uiLayoutSetRedAlert(row, ((dtar->flag & DTAR_FLAG_INVALID) && !dtar->id));
uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:"));
-
+
/* Target Property */
if (dtar->id) {
PointerRNA root_ptr;
-
+
/* get pointer for resolving the property selected */
RNA_id_pointer_create(dtar->id, &root_ptr);
-
+
/* rna path */
col = uiLayoutColumn(layout, true);
uiLayoutSetRedAlert(col, (dtar->flag & DTAR_FLAG_INVALID));
@@ -652,23 +652,23 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar *
Object *ob2 = (Object *)dtar2->id;
PointerRNA dtar_ptr, dtar2_ptr;
uiLayout *col;
-
+
/* initialize RNA pointer to the target */
- RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr);
- RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr);
+ RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr);
+ RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr);
/* Object 1 */
col = uiLayoutColumn(layout, true);
uiLayoutSetRedAlert(col, (dtar->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */
uiItemR(col, &dtar_ptr, "id", 0, IFACE_("Object 1"), ICON_NONE);
-
+
if (dtar->id && GS(dtar->id->name) == ID_OB && ob1->pose) {
PointerRNA tar_ptr;
-
+
RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr);
uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", IFACE_("Bone"), ICON_BONE_DATA);
}
-
+
uiLayoutSetRedAlert(col, false); /* we can clear it again now - it's only needed when creating the ID/Bone fields */
uiItemR(col, &dtar_ptr, "transform_space", 0, NULL, ICON_NONE);
@@ -676,14 +676,14 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar *
col = uiLayoutColumn(layout, true);
uiLayoutSetRedAlert(col, (dtar2->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */
uiItemR(col, &dtar2_ptr, "id", 0, IFACE_("Object 2"), ICON_NONE);
-
+
if (dtar2->id && GS(dtar2->id->name) == ID_OB && ob2->pose) {
PointerRNA tar_ptr;
-
+
RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr);
uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", IFACE_("Bone"), ICON_BONE_DATA);
}
-
+
uiLayoutSetRedAlert(col, false); /* we can clear it again now - it's only needed when creating the ID/Bone fields */
uiItemR(col, &dtar2_ptr, "transform_space", 0, NULL, ICON_NONE);
}
@@ -695,22 +695,22 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar
Object *ob = (Object *)dtar->id;
PointerRNA dtar_ptr;
uiLayout *col, *sub;
-
+
/* initialize RNA pointer to the target */
- RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr);
-
+ RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr);
+
/* properties */
col = uiLayoutColumn(layout, true);
uiLayoutSetRedAlert(col, (dtar->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */
uiItemR(col, &dtar_ptr, "id", 0, IFACE_("Object"), ICON_NONE);
-
+
if (dtar->id && GS(dtar->id->name) == ID_OB && ob->pose) {
PointerRNA tar_ptr;
-
+
RNA_pointer_create(dtar->id, &RNA_Pose, ob->pose, &tar_ptr);
uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", IFACE_("Bone"), ICON_BONE_DATA);
}
-
+
sub = uiLayoutColumn(layout, true);
uiItemR(sub, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE);
uiItemR(sub, &dtar_ptr, "transform_space", 0, IFACE_("Space"), ICON_NONE);
@@ -726,76 +726,79 @@ static void graph_draw_driven_property_panel(uiLayout *layout, ID *id, FCurve *f
uiLayout *row;
char name[256];
int icon = 0;
-
+
/* F-Curve pointer */
RNA_pointer_create(id, &RNA_FCurve, fcu, &fcu_ptr);
-
+
/* get user-friendly 'name' for F-Curve */
icon = getname_anim_fcurve(name, id, fcu);
-
+
/* panel layout... */
row = uiLayoutRow(layout, true);
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT);
-
+
/* -> user friendly 'name' for datablock that owns F-Curve */
/* XXX: Actually, we may need the datablock icons only... (e.g. right now will show bone for bone props) */
uiItemL(row, id->name + 2, icon);
-
+
/* -> user friendly 'name' for F-Curve/driver target */
uiItemL(row, "", VICO_SMALL_TRI_RIGHT_VEC);
uiItemL(row, name, ICON_RNA);
}
/* UI properties panel layout for driver settings - shared for Drivers Editor and for */
-static void graph_draw_driver_settings_panel(uiLayout *layout, ID *id, FCurve *fcu)
+static void graph_draw_driver_settings_panel(uiLayout *layout, ID *id, FCurve *fcu, const bool is_popover)
{
ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
-
+
PointerRNA driver_ptr;
uiLayout *col, *row;
uiBlock *block;
uiBut *but;
-
+
/* set event handler for panel */
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_graph_region_driver_buttons, NULL);
-
+
/* driver-level settings - type, expressions, and errors */
RNA_pointer_create(id, &RNA_Driver, driver, &driver_ptr);
-
+
col = uiLayoutColumn(layout, true);
block = uiLayoutGetBlock(col);
uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE);
-
+
{
char valBuf[32];
-
+
/* value of driver */
row = uiLayoutRow(col, true);
uiItemL(row, IFACE_("Driver Value:"), ICON_NONE);
BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval);
uiItemL(row, valBuf, ICON_NONE);
}
-
+
+ uiItemS(layout);
+ uiItemS(layout);
+
/* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */
if (driver->type == DRIVER_TYPE_PYTHON) {
bool bpy_data_expr_error = (strstr(driver->expression, "bpy.data.") != NULL);
bool bpy_ctx_expr_error = (strstr(driver->expression, "bpy.context.") != NULL);
-
+
/* expression */
/* TODO: "Show syntax hints" button */
col = uiLayoutColumn(layout, true);
block = uiLayoutGetBlock(col);
-
+
uiItemL(col, IFACE_("Expression:"), ICON_NONE);
uiItemR(col, &driver_ptr, "expression", 0, "", ICON_NONE);
uiItemR(col, &driver_ptr, "use_self", 0, NULL, ICON_NONE);
-
+
/* errors? */
col = uiLayoutColumn(layout, true);
block = uiLayoutGetBlock(col);
-
+
if ((G.f & G_SCRIPT_AUTOEXEC) == 0) {
/* TODO: Add button to enable? */
uiItemL(col, IFACE_("ERROR: Python auto-execution disabled"), ICON_CANCEL);
@@ -803,12 +806,12 @@ static void graph_draw_driver_settings_panel(uiLayout *layout, ID *id, FCurve *f
else if (driver->flag & DRIVER_FLAG_INVALID) {
uiItemL(col, IFACE_("ERROR: Invalid Python expression"), ICON_CANCEL);
}
-
+
/* Explicit bpy-references are evil. Warn about these to prevent errors */
/* TODO: put these in a box? */
if (bpy_data_expr_error || bpy_ctx_expr_error) {
uiItemL(col, IFACE_("WARNING: Driver expression may not work correctly"), ICON_HELP);
-
+
if (bpy_data_expr_error) {
uiItemL(col, IFACE_("TIP: Use variables instead of bpy.data paths (see below)"), ICON_ERROR);
}
@@ -821,10 +824,10 @@ static void graph_draw_driver_settings_panel(uiLayout *layout, ID *id, FCurve *f
/* errors? */
col = uiLayoutColumn(layout, true);
block = uiLayoutGetBlock(col);
-
+
if (driver->flag & DRIVER_FLAG_INVALID)
uiItemL(col, IFACE_("ERROR: Invalid target channel(s)"), ICON_ERROR);
-
+
/* Warnings about a lack of variables
* NOTE: The lack of variables is generally a bad thing, since it indicates
* that the driver doesn't work at all. This particular scenario arises
@@ -833,80 +836,96 @@ static void graph_draw_driver_settings_panel(uiLayout *layout, ID *id, FCurve *f
*/
if (BLI_listbase_is_empty(&driver->variables)) {
uiItemL(col, IFACE_("ERROR: Driver is useless without any inputs"), ICON_ERROR);
-
+
if (!BLI_listbase_is_empty(&fcu->modifiers)) {
uiItemL(col, IFACE_("TIP: Use F-Curves for procedural animation instead"), ICON_INFO);
uiItemL(col, IFACE_("F-Modifiers can generate curves for those too"), ICON_INFO);
}
}
}
-
+
+ uiItemS(layout);
+
/* add/copy/paste driver variables */
- {
+ if (is_popover) {
+ /* add driver variable - add blank */
+ row = uiLayoutRow(layout, true);
+ block = uiLayoutGetBlock(row);
+ but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_ZOOMIN, IFACE_("Add Input Variable"),
+ 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
+ NULL, 0.0, 0.0, 0, 0,
+ TIP_("Add a Driver Variable to keep track an input used by the driver"));
+ UI_but_func_set(but, driver_add_var_cb, driver, NULL);
+
+ /* add driver variable - add using eyedropper */
+ /* XXX: will this operator work like this? */
+ uiItemO(row, "", ICON_EYEDROPPER, "UI_OT_eyedropper_driver");
+ }
+ else {
/* add driver variable */
row = uiLayoutRow(layout, false);
block = uiLayoutGetBlock(row);
but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_ZOOMIN, IFACE_("Add Input Variable"),
- 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
- NULL, 0.0, 0.0, 0, 0,
- TIP_("Driver variables ensure that all dependencies will be accounted for, eusuring that drivers will update correctly"));
+ 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
+ NULL, 0.0, 0.0, 0, 0,
+ TIP_("Driver variables ensure that all dependencies will be accounted for, eusuring that drivers will update correctly"));
UI_but_func_set(but, driver_add_var_cb, driver, NULL);
-
+
/* copy/paste (as sub-row) */
row = uiLayoutRow(row, true);
block = uiLayoutGetBlock(row);
-
+
uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_driver_variables_copy");
uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_driver_variables_paste");
}
-
+
/* loop over targets, drawing them */
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
PointerRNA dvar_ptr;
uiLayout *box;
uiLayout *subrow, *sub;
-
+
/* sub-layout column for this variable's settings */
col = uiLayoutColumn(layout, true);
-
+
/* 1) header panel */
box = uiLayoutBox(col);
RNA_pointer_create(id, &RNA_DriverVariable, dvar, &dvar_ptr);
-
+
row = uiLayoutRow(box, false);
block = uiLayoutGetBlock(row);
-
+
/* 1.1) variable type and name */
subrow = uiLayoutRow(row, true);
-
+
/* 1.1.1) variable type */
sub = uiLayoutRow(subrow, true); /* HACK: special group just for the enum, otherwise we */
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); /* we get ugly layout with text included too... */
-
+
uiItemR(sub, &dvar_ptr, "type", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
-
+
/* 1.1.2) variable name */
sub = uiLayoutRow(subrow, true); /* HACK: special group to counteract the effects of the previous */
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_EXPAND); /* enum, which now pushes everything too far right */
-
+
uiItemR(sub, &dvar_ptr, "name", 0, "", ICON_NONE);
-
+
/* 1.2) invalid name? */
UI_block_emboss_set(block, UI_EMBOSS_NONE);
-
+
if (dvar->flag & DVAR_FLAG_INVALID_NAME) {
but = uiDefIconBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_ERROR, 290, 0, UI_UNIT_X, UI_UNIT_Y,
NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Invalid variable name, click here for details"));
UI_but_func_set(but, driver_dvar_invalid_name_query_cb, dvar, NULL); // XXX: reports?
}
-
+
/* 1.3) remove button */
but = uiDefIconBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y,
NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable"));
UI_but_func_set(but, driver_delete_var_cb, driver, dvar);
UI_block_emboss_set(block, UI_EMBOSS);
-
-
+
+
/* 2) variable type settings */
box = uiLayoutBox(col);
/* controls to draw depends on the type of variable */
@@ -924,15 +943,15 @@ static void graph_draw_driver_settings_panel(uiLayout *layout, ID *id, FCurve *f
graph_panel_driverVar__transChan(box, id, dvar);
break;
}
-
+
/* 3) value of variable */
{
char valBuf[32];
-
+
box = uiLayoutBox(col);
row = uiLayoutRow(box, true);
uiItemL(row, IFACE_("Value:"), ICON_NONE);
-
+
if ((dvar->type == DVAR_TYPE_ROT_DIFF) ||
(dvar->type == DVAR_TYPE_TRANSFORM_CHAN &&
dvar->targets[0].transChan >= DTAR_TRANSCHAN_ROTX &&
@@ -943,11 +962,14 @@ static void graph_draw_driver_settings_panel(uiLayout *layout, ID *id, FCurve *f
else {
BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval);
}
-
+
uiItemL(row, valBuf, ICON_NONE);
}
}
-
+
+ uiItemS(layout);
+ uiItemS(layout);
+
/* XXX: This should become redundant. But sometimes the flushing fails, so keep this around for a while longer as a "last resort" */
row = uiLayoutRow(layout, true);
block = uiLayoutGetBlock(row);
@@ -969,9 +991,9 @@ static void graph_panel_driven_property(const bContext *C, Panel *pa)
if (!graph_panel_context(C, &ale, &fcu))
return;
-
+
graph_draw_driven_property_panel(pa->layout, ale->id, fcu);
-
+
MEM_freeN(ale);
}
@@ -980,13 +1002,13 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
{
bAnimListElem *ale;
FCurve *fcu;
-
+
/* Get settings from context */
if (!graph_panel_context(C, &ale, &fcu))
return;
-
- graph_draw_driver_settings_panel(pa->layout, ale->id, fcu);
-
+
+ graph_draw_driver_settings_panel(pa->layout, ale->id, fcu, false);
+
/* cleanup */
MEM_freeN(ale);
}
@@ -1003,40 +1025,46 @@ static int graph_panel_drivers_popover_poll(const bContext *C, PanelType *UNUSED
static void graph_panel_drivers_popover(const bContext *C, Panel *pa)
{
uiLayout *layout = pa->layout;
-
+
PointerRNA ptr = {{NULL}};
PropertyRNA *prop = NULL;
int index = -1;
uiBut *but = NULL;
-
+
/* Get active property to show driver properties for */
but = UI_context_active_but_prop_get((bContext *)C, &ptr, &prop, &index);
if (but) {
FCurve *fcu;
bool driven, special;
-
+
fcu = rna_get_fcurve_context_ui((bContext *)C,
&ptr, prop, index,
NULL, NULL, &driven, &special);
-
+
+ /* Hack: Force all buttons in this panel to be able to know the driver button
+ * this panel is getting spawned from, so that things like the "Open Drivers Editor"
+ * button will work.
+ */
+ uiLayoutSetContextFromBut(layout, but);
+
/* Populate Panel - With a combination of the contents of the Driven and Driver panels */
if (fcu) {
ID *id = ptr.id.data;
-
+
/* Driven Property Settings */
uiItemL(layout, IFACE_("Driven Property:"), ICON_NONE);
graph_draw_driven_property_panel(pa->layout, id, fcu);
/* TODO: All vs Single */
-
+
uiItemS(layout);
uiItemS(layout);
-
+
/* Drivers Settings */
uiItemL(layout, IFACE_("Driver Settings:"), ICON_NONE);
- graph_draw_driver_settings_panel(pa->layout, id, fcu);
+ graph_draw_driver_settings_panel(pa->layout, id, fcu, true);
}
}
-
+
/* Show drivers editor is always visible */
uiItemO(layout, IFACE_("Show in Drivers Editor"), ICON_DRIVER, "SCREEN_OT_drivers_editor_show");
}
@@ -1055,7 +1083,7 @@ static void do_graph_region_modifier_buttons(bContext *C, void *UNUSED(arg), int
}
}
-static void graph_panel_modifiers(const bContext *C, Panel *pa)
+static void graph_panel_modifiers(const bContext *C, Panel *pa)
{
bAnimListElem *ale;
FCurve *fcu;
@@ -1063,37 +1091,37 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa)
uiLayout *col, *row;
uiBlock *block;
bool active;
-
+
if (!graph_panel_context(C, &ale, &fcu))
return;
-
+
block = uiLayoutGetBlock(pa->layout);
UI_block_func_handle_set(block, do_graph_region_modifier_buttons, NULL);
-
+
/* 'add modifier' button at top of panel */
{
row = uiLayoutRow(pa->layout, false);
-
- /* this is an operator button which calls a 'add modifier' operator...
+
+ /* this is an operator button which calls a 'add modifier' operator...
* a menu might be nicer but would be tricky as we need some custom filtering
*/
uiItemMenuEnumO(row, (bContext *)C, "GRAPH_OT_fmodifier_add", "type", IFACE_("Add Modifier"), ICON_NONE);
-
+
/* copy/paste (as sub-row) */
row = uiLayoutRow(row, true);
uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_fmodifier_copy");
uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste");
}
-
+
active = !(fcu->flag & FCURVE_MOD_OFF);
/* draw each modifier */
for (fcm = fcu->modifiers.first; fcm; fcm = fcm->next) {
col = uiLayoutColumn(pa->layout, true);
uiLayoutSetActive(col, active);
-
+
ANIM_uiTemplate_fmodifier_draw(col, ale->id, &fcu->modifiers, fcm);
}
-
+
MEM_freeN(ale);
}
@@ -1111,7 +1139,7 @@ void graph_buttons_register(ARegionType *art)
pt->draw = graph_panel_properties;
pt->poll = graph_panel_poll;
BLI_addtail(&art->paneltypes, pt);
-
+
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
strcpy(pt->idname, "GRAPH_PT_key_properties");
strcpy(pt->label, N_("Active Keyframe"));
@@ -1138,7 +1166,7 @@ void graph_buttons_register(ARegionType *art)
pt->draw = graph_panel_drivers;
pt->poll = graph_panel_drivers_poll;
BLI_addtail(&art->paneltypes, pt);
-
+
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers pover");
strcpy(pt->idname, "GRAPH_PT_drivers_popover");
strcpy(pt->label, N_("Add/Edit Driver"));
@@ -1156,7 +1184,7 @@ void graph_buttons_register(ARegionType *art)
pt->draw = graph_panel_modifiers;
pt->poll = graph_panel_poll;
BLI_addtail(&art->paneltypes, pt);
-
+
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel view");
strcpy(pt->idname, "GRAPH_PT_view");
strcpy(pt->label, N_("View Properties"));
@@ -1170,7 +1198,7 @@ static int graph_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = graph_has_buttons_region(sa);
-
+
if (ar)
ED_region_toggle_hidden(C, ar);
@@ -1182,7 +1210,7 @@ void GRAPH_OT_properties(wmOperatorType *ot)
ot->name = "Properties";
ot->idname = "GRAPH_OT_properties";
ot->description = "Toggle the properties region visibility";
-
+
ot->exec = graph_properties_toggle_exec;
ot->poll = ED_operator_graphedit_active;
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 26a3f110d36..7c6af0b4c62 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -63,7 +63,7 @@
/* *************************** */
/* Utility Drawing Defines */
-/* determine the alpha value that should be used when
+/* determine the alpha value that should be used when
* drawing components for some F-Curve (fcu)
* - selected F-Curves should be more visible than partially visible ones
*/
@@ -175,14 +175,14 @@ static void draw_fcurve_selected_keyframe_vertices(FCurve *fcu, View2D *v2d, boo
BezTriple *bezt = fcu->bezt;
for (int i = 0; i < fcu->totvert; i++, bezt++) {
- /* as an optimization step, only draw those in view
+ /* as an optimization step, only draw those in view
* - we apply a correction factor to ensure that points don't pop in/out due to slight twitches of view size
*/
if (IN_RANGE(bezt->vec[1][0], (v2d->cur.xmin - fac), (v2d->cur.xmax + fac))) {
if (edit) {
/* 'Keyframe' vertex only, as handle lines and handles have already been drawn
* - only draw those with correct selection state for the current drawing color
- * -
+ * -
*/
if ((bezt->f2 & SELECT) == sel)
immVertex2fv(pos, bezt->vec[1]);
@@ -273,7 +273,7 @@ static void draw_fcurve_vertices(ARegion *ar, FCurve *fcu, bool do_handles, bool
{
View2D *v2d = &ar->v2d;
- /* only draw points if curve is visible
+ /* only draw points if curve is visible
* - draw unselected points before selected points as separate passes
* to make sure in the case of overlapping points that the selected is always visible
* - draw handles before keyframes, so that keyframes will overlap handles (keyframes are more important for users)
@@ -330,7 +330,7 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
immBeginAtMost(GWN_PRIM_LINES, 4 * 2 * fcu->totvert);
- /* slightly hacky, but we want to draw unselected points before selected ones
+ /* slightly hacky, but we want to draw unselected points before selected ones
* so that selected points are clearly visible
*/
for (sel = 0; sel < 2; sel++) {
@@ -340,18 +340,18 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
unsigned char col[4];
for (b = 0; b < fcu->totvert; b++, prevbezt = bezt, bezt++) {
- /* if only selected keyframes can get their handles shown,
+ /* if only selected keyframes can get their handles shown,
* check that keyframe is selected
*/
if (sipo->flag & SIPO_SELVHANDLESONLY) {
if (BEZT_ISSEL_ANY(bezt) == 0)
continue;
}
-
+
/* draw handle with appropriate set of colors if selection is ok */
if ((bezt->f2 & SELECT) == sel) {
fp = bezt->vec[0];
-
+
/* only draw first handle if previous segment had handles */
if ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) {
UI_GetThemeColor3ubv(basecol + bezt->h1, col);
@@ -361,7 +361,7 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
immAttrib4ubv(color, col);
immVertex2fv(pos, fp + 3);
}
-
+
/* only draw second handle if this segment is bezier */
if (bezt->ipo == BEZT_IPO_BEZ) {
UI_GetThemeColor3ubv(basecol + bezt->h2, col);
@@ -385,7 +385,7 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
immAttrib4ubv(color, col);
immVertex2fv(pos, fp + 3);
}
-
+
/* only draw second handle if this segment is bezier, and selection is ok */
if (((bezt->f3 & SELECT) == sel) &&
(bezt->ipo == BEZT_IPO_BEZ))
@@ -408,8 +408,8 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
/* Samples ---------------- */
-/* helper func - draw sample-range marker for an F-Curve as a cross
- * NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't
+/* helper func - draw sample-range marker for an F-Curve as a cross
+ * NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't
* have a consistent appearance (due to off-pixel alignments)...
*/
static void draw_fcurve_sample_control(float x, float y, float xscale, float yscale, float hsize, unsigned int pos)
@@ -437,15 +437,15 @@ static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
{
FPoint *first, *last;
float hsize, xscale, yscale;
-
+
/* get view settings */
hsize = UI_GetThemeValuef(TH_VERTEX_SIZE);
UI_view2d_scale_get(&ar->v2d, &xscale, &yscale);
-
+
/* get verts */
first = fcu->fpt;
last = (first) ? (first + (fcu->totvert - 1)) : (NULL);
-
+
/* draw */
if (first && last) {
/* anti-aliased lines for more consistent appearance */
@@ -491,10 +491,10 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d
/* disable any drivers temporarily */
driver = fcu->driver;
fcu->driver = NULL;
-
+
/* compute unit correction factor */
unitFac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
-
+
/* Note about sampling frequency:
* Ideally, this is chosen such that we have 1-2 pixels = 1 segment
* which means that our curves can be as smooth as possible. However,
@@ -510,10 +510,10 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d
/* grid->dx represents the number of 'frames' between gridlines, but we divide by U.v2d_min_gridsize to get pixels-steps */
/* TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted? */
samplefreq = dx / (U.v2d_min_gridsize * U.pixelsize);
-
+
if (sipo->flag & SIPO_BEAUTYDRAW_OFF) {
/* Low Precision = coarse lower-bound clamping
- *
+ *
* Although the "Beauty Draw" flag was originally for AA'd
* line drawing, the sampling rate here has a much greater
* impact on performance (e.g. for T40372)!
@@ -529,15 +529,15 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d
if (samplefreq < 0.00001f)
samplefreq = 0.00001f;
}
-
-
+
+
/* the start/end times are simply the horizontal extents of the 'cur' rect */
stime = v2d->cur.xmin;
etime = v2d->cur.xmax + samplefreq; /* + samplefreq here so that last item gets included... */
-
-
- /* at each sampling interval, add a new vertex
- * - apply the unit correction factor to the calculated values so that
+
+
+ /* at each sampling interval, add a new vertex
+ * - apply the unit correction factor to the calculated values so that
* the displayed values appear correctly in the viewport
*/
@@ -584,11 +584,11 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
gpuTranslate2f(0.0f, offset);
immBegin(GWN_PRIM_LINE_STRIP, count);
-
+
/* extrapolate to left? - left-side of view comes before first keyframe? */
if (prevfpt->vec[0] > v2d->cur.xmin) {
v[0] = v2d->cur.xmin;
-
+
/* y-value depends on the interpolation */
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) {
/* just extend across the first keyframe's value */
@@ -600,26 +600,26 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
if (fac) fac = 1.0f / fac;
v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]);
}
-
+
immVertex2fv(shdr_pos, v);
}
-
+
/* loop over samples, drawing segments */
/* draw curve between first and last keyframe (if there are enough to do so) */
while (b--) {
/* Linear interpolation: just add one point (which should add a new line segment) */
immVertex2fv(shdr_pos, prevfpt->vec);
-
+
/* get next pointers */
if (b > 0) {
prevfpt++;
}
}
-
+
/* extrapolate to right? (see code for left-extrapolation above too) */
if (prevfpt->vec[0] < v2d->cur.xmax) {
v[0] = v2d->cur.xmax;
-
+
/* y-value depends on the interpolation */
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) {
/* based on last keyframe's value */
@@ -632,29 +632,29 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
if (fac) fac = 1.0f / fac;
v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]);
}
-
+
immVertex2fv(shdr_pos, v);
}
-
+
immEnd();
gpuPopMatrix();
}
-/* helper func - check if the F-Curve only contains easily drawable segments
- * (i.e. no easing equation interpolations)
+/* helper func - check if the F-Curve only contains easily drawable segments
+ * (i.e. no easing equation interpolations)
*/
static bool fcurve_can_use_simple_bezt_drawing(FCurve *fcu)
{
BezTriple *bezt;
int i;
-
+
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
if (ELEM(bezt->ipo, BEZT_IPO_CONST, BEZT_IPO_LIN, BEZT_IPO_BEZ) == false) {
return false;
}
}
-
+
return true;
}
@@ -670,7 +670,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
int resol;
float unit_scale, offset;
short mapping_flag = ANIM_get_normalization_flags(ac);
-
+
/* apply unit mapping */
gpuPushMatrix();
unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
@@ -681,12 +681,12 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
* bezier interpolation, and are drawn at full res.
* This is tricky to optimize, but maybe can be improved at some point... */
immBeginAtMost(GWN_PRIM_LINE_STRIP, (b * 32 + 3));
-
+
/* extrapolate to left? */
if (prevbezt->vec[1][0] > v2d->cur.xmin) {
/* left-side of view comes before first keyframe, so need to extend as not cyclic */
v1[0] = v2d->cur.xmin;
-
+
/* y-value depends on the interpolation */
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) {
/* just extend across the first keyframe's value */
@@ -704,17 +704,17 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
if (fac) fac = 1.0f / fac;
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[0][1] - prevbezt->vec[1][1]);
}
-
+
immVertex2fv(pos, v1);
}
-
+
/* if only one keyframe, add it now */
if (fcu->totvert == 1) {
v1[0] = prevbezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
immVertex2fv(pos, v1);
}
-
+
/* draw curve between first and last keyframe (if there are enough to do so) */
/* TODO: optimize this to not have to calc stuff out of view too? */
while (b--) {
@@ -723,7 +723,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
v1[0] = prevbezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
immVertex2fv(pos, v1);
-
+
v1[0] = bezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
immVertex2fv(pos, v1);
@@ -735,10 +735,10 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
immVertex2fv(pos, v1);
}
else if (prevbezt->ipo == BEZT_IPO_BEZ) {
- /* Bezier-Interpolation: draw curve as series of segments between keyframes
+ /* Bezier-Interpolation: draw curve as series of segments between keyframes
* - resol determines number of points to sample in between keyframes
*/
-
+
/* resol depends on distance between points (not just horizontal) OR is a fixed high res */
/* TODO: view scale should factor into this someday too... */
if (fcu->driver) {
@@ -747,7 +747,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
else {
resol = (int)(5.0f * len_v2v2(bezt->vec[1], prevbezt->vec[1]));
}
-
+
if (resol < 2) {
/* only draw one */
v1[0] = prevbezt->vec[1][0];
@@ -758,32 +758,32 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
/* clamp resolution to max of 32 */
/* NOTE: higher values will crash */
if (resol > 32) resol = 32;
-
+
v1[0] = prevbezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
v2[0] = prevbezt->vec[2][0];
v2[1] = prevbezt->vec[2][1];
-
+
v3[0] = bezt->vec[0][0];
v3[1] = bezt->vec[0][1];
v4[0] = bezt->vec[1][0];
v4[1] = bezt->vec[1][1];
-
+
correct_bezpart(v1, v2, v3, v4);
-
+
BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float) * 3);
BKE_curve_forward_diff_bezier(v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float) * 3);
-
+
for (fp = data; resol; resol--, fp += 3) {
immVertex2fv(pos, fp);
}
}
}
-
+
/* get next pointers */
prevbezt = bezt;
bezt++;
-
+
/* last point? */
if (b == 0) {
v1[0] = prevbezt->vec[1][0];
@@ -791,11 +791,11 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
immVertex2fv(pos, v1);
}
}
-
+
/* extrapolate to right? (see code for left-extrapolation above too) */
if (prevbezt->vec[1][0] < v2d->cur.xmax) {
v1[0] = v2d->cur.xmax;
-
+
/* y-value depends on the interpolation */
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) {
/* based on last keyframe's value */
@@ -814,10 +814,10 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
if (fac) fac = 1.0f / fac;
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[2][1] - prevbezt->vec[1][1]);
}
-
+
immVertex2fv(pos, v1);
}
-
+
immEnd();
gpuPopMatrix();
@@ -825,10 +825,10 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
/* Debugging -------------------------------- */
-/* Draw indicators which show the value calculated from the driver,
+/* Draw indicators which show the value calculated from the driver,
* and how this is mapped to the value that comes out of it. This
* is handy for helping users better understand how to interpret
- * the graphs, and also facilitates debugging.
+ * the graphs, and also facilitates debugging.
*/
static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
{
@@ -837,7 +837,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
short mapping_flag = ANIM_get_normalization_flags(ac);
float offset;
float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
-
+
/* for now, only show when debugging driver... */
//if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0)
// return;
@@ -852,19 +852,19 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
immUniform1i("num_colors", 0); /* Simple dashes. */
/* No curve to modify/visualize the result?
- * => We still want to show the 1-1 default...
+ * => We still want to show the 1-1 default...
*/
if ((fcu->totvert == 0) && BLI_listbase_is_empty(&fcu->modifiers)) {
float t;
-
+
/* draw with thin dotted lines in style of what curve would have been */
immUniformColor3fv(fcu->color);
-
+
immUniform1f("dash_width", 40.0f);
immUniform1f("dash_factor", 0.5f);
glLineWidth(2.0f);
-
- /* draw 1-1 line, stretching just past the screen limits
+
+ /* draw 1-1 line, stretching just past the screen limits
* NOTE: we need to scale the y-values to be valid for the units
*/
immBegin(GWN_PRIM_LINES, 2);
@@ -877,17 +877,17 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
immEnd();
}
-
+
/* draw driver only if actually functional */
if ((driver->flag & DRIVER_FLAG_INVALID) == 0) {
/* grab "coordinates" for driver outputs */
float x = driver->curval;
float y = fcu->curval * unitfac;
-
+
/* only draw indicators if the point is in range*/
if (x >= v2d->cur.xmin) {
float co[2];
-
+
/* draw dotted lines leading towards this point from both axes ....... */
immUniformColor3f(0.9f, 0.9f, 0.9f);
immUniform1f("dash_width", 10.0f);
@@ -916,7 +916,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
immVertex2fv(shdr_pos, co);
immEnd();
-
+
immUnbindProgram();
/* GWN_PRIM_POINTS do not survive dashed line geometry shader... */
@@ -926,15 +926,15 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
/* -> outer frame */
immUniformColor3f(0.9f, 0.9f, 0.9f);
glPointSize(7.0);
-
+
immBegin(GWN_PRIM_POINTS, 1);
immVertex2f(shdr_pos, x, y);
immEnd();
-
+
/* inner frame */
immUniformColor3f(0.9f, 0.0f, 0.0f);
glPointSize(3.0);
-
+
immBegin(GWN_PRIM_POINTS, 1);
immVertex2f(shdr_pos, x, y);
immEnd();
@@ -946,16 +946,16 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
/* Public Curve-Drawing API ---------------- */
-/* Draw the 'ghost' F-Curves (i.e. snapshots of the curve)
+/* Draw the 'ghost' F-Curves (i.e. snapshots of the curve)
* NOTE: unit mapping has already been applied to the values, so do not try and apply again
*/
void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
{
FCurve *fcu;
-
+
/* draw with thick dotted lines */
glLineWidth(3.0f);
-
+
/* anti-aliased lines for less jagged appearance */
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
glEnable(GL_LINE_SMOOTH);
@@ -976,12 +976,12 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
/* the ghost curves are simply sampled F-Curves stored in sipo->ghostCurves */
for (fcu = sipo->ghostCurves.first; fcu; fcu = fcu->next) {
- /* set whatever color the curve has set
+ /* set whatever color the curve has set
* - this is set by the function which creates these
* - draw with a fixed opacity of 2
*/
immUniformColor3fvAlpha(fcu->color, 0.5f);
-
+
/* simply draw the stored samples */
draw_fcurve_curve_samples(ac, NULL, fcu, &ar->v2d, shdr_pos);
}
@@ -1002,21 +1002,21 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* build list of curves to draw */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE);
filter |= ((sel) ? (ANIMFILTER_SEL) : (ANIMFILTER_UNSEL));
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* for each curve:
- * draw curve, then handle-lines, and finally vertices in this order so that
+ * draw curve, then handle-lines, and finally vertices in this order so that
* the data will be layered correctly
*/
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
FModifier *fcm = find_active_fmodifier(&fcu->modifiers);
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
/* map keyframes for drawing if scaled F-Curve */
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
@@ -1028,7 +1028,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
* - controls from active modifier take precedence over keyframes
* (XXX! editing tools need to take this into account!)
*/
-
+
/* 1) draw curve line */
if (((fcu->modifiers.first) || (fcu->flag & FCURVE_INT_VALUES)) ||
(((fcu->bezt) || (fcu->fpt)) && (fcu->totvert)))
@@ -1041,7 +1041,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
else {
glLineWidth(1.0);
}
-
+
/* anti-aliased lines for less jagged appearance */
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
glEnable(GL_LINE_SMOOTH);
@@ -1081,8 +1081,8 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
/* draw F-Curve */
if ((fcu->modifiers.first) || (fcu->flag & FCURVE_INT_VALUES)) {
- /* draw a curve affected by modifiers or only allowed to have integer values
- * by sampling it at various small-intervals over the visible region
+ /* draw a curve affected by modifiers or only allowed to have integer values
+ * by sampling it at various small-intervals over the visible region
*/
draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, grid, shdr_pos);
}
@@ -1108,8 +1108,8 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
}
glDisable(GL_BLEND);
}
-
- /* 2) draw handles and vertices as appropriate based on active
+
+ /* 2) draw handles and vertices as appropriate based on active
* - if the option to only show controls if the F-Curve is selected is enabled, we must obey this
*/
if (!(sipo->flag & SIPO_SELCUVERTSONLY) || (fcu->flag & FCURVE_SELECTED)) {
@@ -1127,46 +1127,46 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
short mapping_flag = ANIM_get_normalization_flags(ac);
float offset;
float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset);
-
+
/* apply unit-scaling to all values via OpenGL */
gpuPushMatrix();
gpuScale2f(1.0f, unit_scale);
gpuTranslate2f(0.0f, offset);
-
+
/* set this once and for all - all handles and handle-verts should use the same thickness */
glLineWidth(1.0);
-
+
if (fcu->bezt) {
bool do_handles = draw_fcurve_handles_check(sipo, fcu);
-
+
if (do_handles) {
/* only draw handles/vertices on keyframes */
glEnable(GL_BLEND);
draw_fcurve_handles(sipo, fcu);
glDisable(GL_BLEND);
}
-
+
draw_fcurve_vertices(ar, fcu, do_handles, (sipo->flag & SIPO_SELVHANDLESONLY));
}
else {
/* samples: only draw two indicators at either end as indicators */
draw_fcurve_samples(sipo, ar, fcu);
}
-
+
gpuPopMatrix();
}
}
-
+
/* 3) draw driver debugging stuff */
if ((ac->datatype == ANIMCONT_DRIVERS) && (fcu->flag & FCURVE_ACTIVE)) {
graph_draw_driver_debug(ac, ale->id, fcu);
}
-
+
/* undo mapping of keyframes for drawing if scaled F-Curve */
if (adt)
- ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
-
+
/* free list of curves */
ANIM_animdata_freelist(&anim_data);
}
@@ -1175,40 +1175,40 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
/* Channel List */
/* left hand part */
-void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
+void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
View2D *v2d = &ar->v2d;
float y = 0.0f, height;
size_t items;
int i = 0;
-
+
/* build list of channels to draw */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* Update max-extent of channels here (taking into account scrollers):
* - this is done to allow the channel list to be scrollable, but must be done here
* to avoid regenerating the list again and/or also because channels list is drawn first
- * - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for
+ * - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for
* start of list offset, and the second is as a correction for the scrollers.
*/
height = (float)((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac) * 2));
UI_view2d_totRect_set(v2d, BLI_rcti_size_x(&ar->v2d.mask), height);
-
+
/* loop through channels, and set up drawing depending on their type */
{ /* first pass: just the standard GL-drawing for backdrop + text */
size_t channel_index = 0;
-
+
y = (float)ACHANNEL_FIRST(ac);
-
+
for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) {
const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
-
+
/* check if visible */
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
@@ -1216,7 +1216,7 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
/* draw all channels using standard channel-drawing API */
ANIM_channel_draw(ac, ale, yminc, ymaxc, channel_index);
}
-
+
/* adjust y-position for next one */
y -= ACHANNEL_STEP(ac);
channel_index++;
@@ -1225,17 +1225,17 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
{ /* second pass: widgets */
uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
size_t channel_index = 0;
-
+
y = (float)ACHANNEL_FIRST(ac);
-
+
/* set blending again, as may not be set in previous step */
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
-
+
for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) {
const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
-
+
/* check if visible */
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
@@ -1243,18 +1243,18 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
/* draw all channels using standard channel-drawing API */
ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index);
}
-
+
/* adjust y-position for next one */
y -= ACHANNEL_STEP(ac);
channel_index++;
}
-
+
UI_block_end(C, block);
UI_block_draw(C, block);
-
+
glDisable(GL_BLEND);
}
-
+
/* free tempolary channels */
ANIM_animdata_freelist(&anim_data);
}
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 562efcbb0ea..26a6e93ba57 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -54,10 +54,11 @@
#include "BLT_translation.h"
+#include "BKE_context.h"
#include "BKE_fcurve.h"
#include "BKE_global.h"
+#include "BKE_main.h"
#include "BKE_nla.h"
-#include "BKE_context.h"
#include "BKE_report.h"
#include "DEG_depsgraph_build.h"
@@ -83,36 +84,36 @@
/* Get the min/max keyframes*/
/* note: it should return total boundbox, filter for selection only can be argument... */
-void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax,
+void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax,
const bool do_sel_only, const bool include_handles)
{
Scene *scene = ac->scene;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get data to filter, from Dopesheet */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* set large values initial values that will be easy to override */
if (xmin) *xmin = 999999999.0f;
if (xmax) *xmax = -999999999.0f;
if (ymin) *ymin = 999999999.0f;
if (ymax) *ymax = -999999999.0f;
-
+
/* check if any channels to set range with */
if (anim_data.first) {
bool foundBounds = false;
-
+
/* go through channels, finding max extents */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
FCurve *fcu = (FCurve *)ale->key_data;
float txmin, txmax, tymin, tymax;
float unitFac, offset;
-
+
/* get range */
if (calc_fcurve_bounds(fcu, &txmin, &txmax, &tymin, &tymax, do_sel_only, include_handles)) {
short mapping_flag = ANIM_get_normalization_flags(ac);
@@ -122,24 +123,24 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa
txmin = BKE_nla_tweakedit_remap(adt, txmin, NLATIME_CONVERT_MAP);
txmax = BKE_nla_tweakedit_remap(adt, txmax, NLATIME_CONVERT_MAP);
}
-
+
/* apply unit corrections */
unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset);
tymin += offset;
tymax += offset;
tymin *= unitFac;
tymax *= unitFac;
-
+
/* try to set cur using these values, if they're more extreme than previously set values */
if ((xmin) && (txmin < *xmin)) *xmin = txmin;
if ((xmax) && (txmax > *xmax)) *xmax = txmax;
if ((ymin) && (tymin < *ymin)) *ymin = tymin;
if ((ymax) && (tymax > *ymax)) *ymax = tymax;
-
+
foundBounds = true;
}
}
-
+
/* ensure that the extents are not too extreme that view implodes...*/
if (foundBounds) {
if ((xmin && xmax) && (fabsf(*xmax - *xmin) < 0.001f)) {
@@ -157,7 +158,7 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa
if (ymin) *ymin = -5;
if (ymax) *ymax = 5;
}
-
+
/* free memory */
ANIM_animdata_freelist(&anim_data);
}
@@ -171,7 +172,7 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa
if (xmin) *xmin = -5;
if (xmax) *xmax = 100;
}
-
+
if (ymin) *ymin = -5;
if (ymax) *ymax = 5;
}
@@ -184,7 +185,7 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
Scene *scene;
float min, max;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
@@ -192,31 +193,31 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
else
scene = ac.scene;
-
+
/* set the range directly */
get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL, false, false);
scene->r.flag |= SCER_PRV_RANGE;
scene->r.psfra = round_fl_to_int(min);
scene->r.pefra = round_fl_to_int(max);
-
+
/* set notifier that things have changed */
// XXX err... there's nothing for frame ranges yet, but this should do fine too
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_previewrange_set(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Auto-Set Preview Range";
ot->idname = "GRAPH_OT_previewrange_set";
ot->description = "Automatically set Preview Range based on range of keyframes";
-
+
/* api callbacks */
ot->exec = graphkeys_previewrange_exec;
ot->poll = ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier...
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -228,11 +229,11 @@ static int graphkeys_viewall(bContext *C, const bool do_sel_only, const bool inc
{
bAnimContext ac;
rctf cur_new;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
get_graph_keyframe_extents(&ac,
&cur_new.xmin, &cur_new.xmax,
@@ -240,9 +241,9 @@ static int graphkeys_viewall(bContext *C, const bool do_sel_only, const bool inc
do_sel_only, include_handles);
BLI_rctf_scale(&cur_new, 1.1f);
-
+
UI_view2d_smooth_view(C, ac.ar, &cur_new, smooth_viewtx);
-
+
return OPERATOR_FINISHED;
}
@@ -252,16 +253,16 @@ static int graphkeys_viewall_exec(bContext *C, wmOperator *op)
{
const bool include_handles = RNA_boolean_get(op->ptr, "include_handles");
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
-
+
/* whole range */
return graphkeys_viewall(C, false, include_handles, smooth_viewtx);
}
-
+
static int graphkeys_view_selected_exec(bContext *C, wmOperator *op)
{
const bool include_handles = RNA_boolean_get(op->ptr, "include_handles");
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
-
+
/* only selected */
return graphkeys_viewall(C, true, include_handles, smooth_viewtx);
}
@@ -274,16 +275,16 @@ void GRAPH_OT_view_all(wmOperatorType *ot)
ot->name = "View All";
ot->idname = "GRAPH_OT_view_all";
ot->description = "Reset viewable area to show full keyframe range";
-
+
/* api callbacks */
ot->exec = graphkeys_viewall_exec;
ot->poll = ED_operator_graphedit_active; /* XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... */
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
- ot->prop = RNA_def_boolean(ot->srna, "include_handles", true, "Include Handles",
+ ot->prop = RNA_def_boolean(ot->srna, "include_handles", true, "Include Handles",
"Include handles of keyframes when calculating extents");
}
@@ -300,9 +301,9 @@ void GRAPH_OT_view_selected(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
- ot->prop = RNA_def_boolean(ot->srna, "include_handles", true, "Include Handles",
+ ot->prop = RNA_def_boolean(ot->srna, "include_handles", true, "Include Handles",
"Include handles of keyframes when calculating extents");
}
@@ -321,11 +322,11 @@ void GRAPH_OT_view_frame(wmOperatorType *ot)
ot->name = "View Frame";
ot->idname = "GRAPH_OT_view_frame";
ot->description = "Reset viewable area to show range around current frame";
-
+
/* api callbacks */
ot->exec = graphkeys_view_frame_exec;
ot->poll = ED_operator_graphedit_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -337,25 +338,25 @@ void GRAPH_OT_view_frame(wmOperatorType *ot)
/* Bake each F-Curve into a set of samples, and store as a ghost curve */
static void create_ghost_curves(bAnimContext *ac, int start, int end)
-{
+{
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* free existing ghost curves */
free_fcurves(&sipo->ghostCurves);
-
+
/* sanity check */
if (start >= end) {
printf("Error: Frame range for Ghost F-Curve creation is inappropriate\n");
return;
}
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through filtered data and add keys between selected keyframes on every frame */
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
@@ -366,41 +367,41 @@ static void create_ghost_curves(bAnimContext *ac, int start, int end)
float unitFac, offset;
int cfra;
short mapping_flag = ANIM_get_normalization_flags(ac);
-
+
/* disable driver so that it don't muck up the sampling process */
fcu->driver = NULL;
-
+
/* calculate unit-mapping factor */
unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset);
-
- /* create samples, but store them in a new curve
- * - we cannot use fcurve_store_samples() as that will only overwrite the original curve
+
+ /* create samples, but store them in a new curve
+ * - we cannot use fcurve_store_samples() as that will only overwrite the original curve
*/
gcu->fpt = fpt = MEM_callocN(sizeof(FPoint) * (end - start + 1), "Ghost FPoint Samples");
gcu->totvert = end - start + 1;
-
+
/* use the sampling callback at 1-frame intervals from start to end frames */
for (cfra = start; cfra <= end; cfra++, fpt++) {
float cfrae = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
-
+
fpt->vec[0] = cfrae;
fpt->vec[1] = (fcurve_samplingcb_evalcurve(fcu, NULL, cfrae) + offset) * unitFac;
}
-
- /* set color of ghost curve
+
+ /* set color of ghost curve
* - make the color slightly darker
*/
gcu->color[0] = fcu->color[0] - 0.07f;
gcu->color[1] = fcu->color[1] - 0.07f;
gcu->color[2] = fcu->color[2] - 0.07f;
-
+
/* store new ghost curve */
BLI_addtail(&sipo->ghostCurves, gcu);
-
+
/* restore driver */
fcu->driver = driver;
}
-
+
/* admin and redraws */
ANIM_animdata_freelist(&anim_data);
}
@@ -412,39 +413,39 @@ static int graphkeys_create_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op)
bAnimContext ac;
View2D *v2d;
int start, end;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* ghost curves are snapshots of the visible portions of the curves, so set range to be the visible range */
v2d = &ac.ar->v2d;
start = (int)v2d->cur.xmin;
end = (int)v2d->cur.xmax;
-
+
/* bake selected curves into a ghost curve */
create_ghost_curves(&ac, start, end);
-
+
/* update this editor only */
ED_area_tag_redraw(CTX_wm_area(C));
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_ghost_curves_create(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Create Ghost Curves";
ot->idname = "GRAPH_OT_ghost_curves_create";
ot->description = "Create snapshot (Ghosts) of selected F-Curves as background aid for active Graph Editor";
-
+
/* api callbacks */
ot->exec = graphkeys_create_ghostcurves_exec;
ot->poll = graphop_visible_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
// todo: add props for start/end frames
}
@@ -455,36 +456,36 @@ static int graphkeys_clear_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
SpaceIpo *sipo;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
sipo = (SpaceIpo *)ac.sl;
-
+
/* if no ghost curves, don't do anything */
if (BLI_listbase_is_empty(&sipo->ghostCurves))
return OPERATOR_CANCELLED;
-
+
/* free ghost curves */
free_fcurves(&sipo->ghostCurves);
-
+
/* update this editor only */
ED_area_tag_redraw(CTX_wm_area(C));
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_ghost_curves_clear(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Clear Ghost Curves";
ot->idname = "GRAPH_OT_ghost_curves_clear";
ot->description = "Clear F-Curve snapshots (Ghosts) for active Graph Editor";
-
+
/* api callbacks */
ot->exec = graphkeys_clear_ghostcurves_exec;
ot->poll = ED_operator_graphedit_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -517,27 +518,27 @@ static const EnumPropertyItem prop_graphkeys_insertkey_types[] = {
};
/* this function is responsible for snapping keyframes to frame-times */
-static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
+static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
size_t num_items;
-
+
ReportList *reports = ac->reports;
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
struct Depsgraph *depsgraph = ac->depsgraph;
Scene *scene = ac->scene;
ToolSettings *ts = scene->toolsettings;
short flag = 0;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
if (mode & GRAPHKEYS_INSERTKEY_SEL)
filter |= ANIMFILTER_SEL;
else if (mode & GRAPHKEYS_INSERTKEY_ACTIVE)
filter |= ANIMFILTER_ACTIVE;
-
+
num_items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
if (num_items == 0) {
if (mode & GRAPHKEYS_INSERTKEY_ACTIVE)
@@ -546,26 +547,26 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
BKE_report(reports, RPT_ERROR, "No selected F-Curves to add keyframes to");
else
BKE_report(reports, RPT_ERROR, "No channels to add keyframes to");
-
+
return;
}
-
+
/* init keyframing flag */
flag = ANIM_get_keyframing_flags(scene, 1);
-
+
/* insert keyframes */
if (mode & GRAPHKEYS_INSERTKEY_CURSOR) {
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
FCurve *fcu = (FCurve *)ale->key_data;
-
+
short mapping_flag = ANIM_get_normalization_flags(ac);
float offset;
float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, mapping_flag, &offset);
-
+
float x, y;
-
-
+
+
/* perform time remapping for x-coordinate (if necessary) */
if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS))
x = sipo->cursorTime;
@@ -573,16 +574,16 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
x = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
else
x = (float)CFRA;
-
+
/* normalise units of cursor's value */
if (sipo)
y = (sipo->cursorVal / unit_scale) - offset;
else
y = 0.0f;
-
+
/* insert keyframe directly into the F-Curve */
insert_vert_fcurve(fcu, x, y, ts->keyframe_type, 0);
-
+
ale->update |= ANIM_UPDATE_DEFAULT;
}
}
@@ -591,15 +592,15 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
FCurve *fcu = (FCurve *)ale->key_data;
float cfra;
-
+
/* adjust current frame for NLA-mapping */
if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS))
cfra = sipo->cursorTime;
else if (adt)
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
- else
+ else
cfra = (float)CFRA;
-
+
/* read value from property the F-Curve represents, or from the curve only?
* - ale->id != NULL: Typically, this means that we have enough info to try resolving the path
* - ale->owner != NULL: If this is set, then the path may not be resolvable from the ID alone,
@@ -609,17 +610,18 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
* up adding the keyframes on a new F-Curve in the action data instead.
*/
if (ale->id && !ale->owner && !fcu->driver) {
- insert_keyframe(depsgraph, reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag);
+ insert_keyframe(ac->bmain, depsgraph, reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)),
+ fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag);
}
else {
const float curval = evaluate_fcurve(fcu, cfra);
insert_vert_fcurve(fcu, cfra, curval, ts->keyframe_type, 0);
}
-
+
ale->update |= ANIM_UPDATE_DEFAULT;
}
}
-
+
ANIM_animdata_update(ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
}
@@ -630,20 +632,20 @@ static int graphkeys_insertkey_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
eGraphKeys_InsertKey_Types mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* which channels to affect? */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* insert keyframes */
insert_graph_keys(&ac, mode);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -653,15 +655,15 @@ void GRAPH_OT_keyframe_insert(wmOperatorType *ot)
ot->name = "Insert Keyframes";
ot->idname = "GRAPH_OT_keyframe_insert";
ot->description = "Insert keyframes for the specified channels";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = graphkeys_insertkey_exec;
ot->poll = graphop_editable_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_insertkey_types, 0, "Type", "");
}
@@ -675,11 +677,11 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
AnimData *adt;
FCurve *fcu;
float frame, val;
-
+
/* get animation context */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get active F-Curve 'anim-list-element' */
ale = get_active_fcurve_channel(&ac);
if (ELEM(NULL, ale, ale->data)) {
@@ -687,17 +689,17 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
fcu = ale->data;
-
+
/* when there are F-Modifiers on the curve, only allow adding
* keyframes if these will be visible after doing so...
*/
if (fcurve_is_keyframable(fcu)) {
ListBase anim_data;
ToolSettings *ts = ac.scene->toolsettings;
-
+
short mapping_flag = ANIM_get_normalization_flags(&ac);
float scale, offset;
-
+
/* preserve selection? */
if (RNA_boolean_get(op->ptr, "extend") == false) {
/* deselect all keyframes first, so that we can immediately start manipulating the newly added one(s)
@@ -705,28 +707,28 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
*/
deselect_graph_keys(&ac, false, SELECT_SUBTRACT, false);
}
-
+
/* get frame and value from props */
frame = RNA_float_get(op->ptr, "frame");
val = RNA_float_get(op->ptr, "value");
-
+
/* apply inverse NLA-mapping to frame to get correct time in un-scaled action */
adt = ANIM_nla_mapping_get(&ac, ale);
frame = BKE_nla_tweakedit_remap(adt, frame, NLATIME_CONVERT_UNMAP);
-
+
/* apply inverse unit-mapping to value to get correct value for F-Curves */
scale = ANIM_unit_mapping_get_factor(ac.scene, ale->id, fcu, mapping_flag | ANIM_UNITCONV_RESTORE, &offset);
-
+
val = val * scale - offset;
-
+
/* insert keyframe on the specified frame + value */
insert_vert_fcurve(fcu, frame, val, ts->keyframe_type, 0);
-
+
ale->update |= ANIM_UPDATE_DEPS;
-
+
BLI_listbase_clear(&anim_data);
BLI_addtail(&anim_data, ale);
-
+
ANIM_animdata_update(&ac, &anim_data);
}
else {
@@ -738,13 +740,13 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
else
BKE_report(op->reports, RPT_ERROR, "Remove F-Modifiers from F-Curve to add keyframes");
}
-
+
/* free temp data */
MEM_freeN(ale);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -756,23 +758,23 @@ static int graphkeys_click_insert_invoke(bContext *C, wmOperator *op, const wmEv
View2D *v2d;
int mval[2];
float x, y;
-
+
/* get animation context */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* store mouse coordinates in View2D space, into the operator's properties */
ar = ac.ar;
v2d = &ar->v2d;
-
+
mval[0] = (event->x - ar->winrct.xmin);
mval[1] = (event->y - ar->winrct.ymin);
-
+
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
-
+
RNA_float_set(op->ptr, "frame", x);
RNA_float_set(op->ptr, "value", y);
-
+
/* run exec now */
return graphkeys_click_insert_exec(C, op);
}
@@ -783,19 +785,19 @@ void GRAPH_OT_click_insert(wmOperatorType *ot)
ot->name = "Click-Insert Keyframes";
ot->idname = "GRAPH_OT_click_insert";
ot->description = "Insert new keyframe at the cursor position for the active F-Curve";
-
+
/* api callbacks */
ot->invoke = graphkeys_click_insert_invoke;
ot->exec = graphkeys_click_insert_exec;
ot->poll = graphop_active_fcurve_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_float(ot->srna, "frame", 1.0f, -FLT_MAX, FLT_MAX, "Frame Number", "Frame to insert keyframe on", 0, 100);
RNA_def_float(ot->srna, "value", 1.0f, -FLT_MAX, FLT_MAX, "Value", "Value for keyframe on", 0, 100);
-
+
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first");
}
@@ -803,20 +805,20 @@ void GRAPH_OT_click_insert(wmOperatorType *ot)
/* NOTE: the backend code for this is shared with the dopesheet editor */
static short copy_graph_keys(bAnimContext *ac)
-{
+{
ListBase anim_data = {NULL, NULL};
int filter, ok = 0;
-
+
/* clear buffer first */
ANIM_fcurves_copybuf_free();
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* copy keyframes */
ok = copy_animedit_keys(ac, &anim_data);
-
+
/* clean up */
ANIM_animdata_freelist(&anim_data);
@@ -825,21 +827,21 @@ static short copy_graph_keys(bAnimContext *ac)
static short paste_graph_keys(bAnimContext *ac,
const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode, bool flip)
-{
+{
ListBase anim_data = {NULL, NULL};
int filter, ok = 0;
-
- /* filter data
- * - First time we try to filter more strictly, allowing only selected channels
+
+ /* filter data
+ * - First time we try to filter more strictly, allowing only selected channels
* to allow copying animation between channels
* - Second time, we loosen things up if nothing was found the first time, allowing
* users to just paste keyframes back into the original curve again [#31670]
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
-
+
if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0)
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* paste keyframes */
ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode, flip);
@@ -854,32 +856,32 @@ static short paste_graph_keys(bAnimContext *ac,
static int graphkeys_copy_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* copy keyframes */
if (copy_graph_keys(&ac)) {
BKE_report(op->reports, RPT_ERROR, "No keyframes copied to keyframes copy/paste buffer");
return OPERATOR_CANCELLED;
}
-
+
/* just return - no operator needed here (no changes) */
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_copy(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Copy Keyframes";
ot->idname = "GRAPH_OT_copy";
ot->description = "Copy selected keyframes to the copy/paste buffer";
-
+
/* api callbacks */
ot->exec = graphkeys_copy_exec;
ot->poll = graphop_editable_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -893,11 +895,11 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op)
const eKeyPasteOffset offset_mode = RNA_enum_get(op->ptr, "offset");
const eKeyMergeMode merge_mode = RNA_enum_get(op->ptr, "merge");
const bool flipped = RNA_boolean_get(op->ptr, "flipped");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* ac.reports by default will be the global reports list, which won't show warnings */
ac.reports = op->reports;
@@ -905,30 +907,30 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op)
if (paste_graph_keys(&ac, offset_mode, merge_mode, flipped)) {
return OPERATOR_CANCELLED;
}
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_paste(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Paste Keyframes";
ot->idname = "GRAPH_OT_paste";
ot->description = "Paste keyframes from copy/paste buffer for the selected channels, starting on the current frame";
-
+
/* api callbacks */
// ot->invoke = WM_operator_props_popup; // better wait for graph redo panel
ot->exec = graphkeys_paste_exec;
ot->poll = graphop_editable_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
RNA_def_enum(ot->srna, "offset", rna_enum_keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys");
RNA_def_enum(ot->srna, "merge", rna_enum_keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merging pasted keys and existing");
@@ -943,11 +945,11 @@ static void duplicate_graph_keys(bAnimContext *ac)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through filtered data and delete selected keys */
for (ale = anim_data.first; ale; ale = ale->next) {
duplicate_fcurve_keys((FCurve *)ale->key_data);
@@ -964,17 +966,17 @@ static void duplicate_graph_keys(bAnimContext *ac)
static int graphkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* duplicate keyframes */
duplicate_graph_keys(&ac);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -984,14 +986,14 @@ void GRAPH_OT_duplicate(wmOperatorType *ot)
ot->name = "Duplicate Keyframes";
ot->idname = "GRAPH_OT_duplicate";
ot->description = "Make a copy of all selected keyframes";
-
+
/* api callbacks */
ot->exec = graphkeys_duplicate_exec;
ot->poll = graphop_editable_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* to give to transform */
RNA_def_enum(ot->srna, "mode", rna_enum_transform_mode_types, TFM_TRANSLATION, "Mode", "");
}
@@ -1004,17 +1006,17 @@ static bool delete_graph_keys(bAnimContext *ac)
bAnimListElem *ale;
int filter;
bool changed_final = false;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through filtered data and delete selected keys */
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
AnimData *adt = ale->adt;
bool changed;
-
+
/* delete selected keyframes only */
changed = delete_fcurve_keys(fcu);
@@ -1022,7 +1024,7 @@ static bool delete_graph_keys(bAnimContext *ac)
ale->update |= ANIM_UPDATE_DEFAULT;
changed_final = true;
}
-
+
/* Only delete curve too if it won't be doing anything anymore */
if ((fcu->totvert == 0) &&
(list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0) &&
@@ -1044,33 +1046,33 @@ static bool delete_graph_keys(bAnimContext *ac)
static int graphkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* delete keyframes */
if (!delete_graph_keys(&ac))
return OPERATOR_CANCELLED;
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_delete(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Delete Keyframes";
ot->idname = "GRAPH_OT_delete";
ot->description = "Remove all selected keyframes";
-
+
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = graphkeys_delete_exec;
ot->poll = graphop_editable_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1078,15 +1080,15 @@ void GRAPH_OT_delete(wmOperatorType *ot)
/* ******************** Clean Keyframes Operator ************************* */
static void clean_graph_keys(bAnimContext *ac, float thresh, bool clean_chan)
-{
+{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through filtered data and clean curves */
for (ale = anim_data.first; ale; ale = ale->next) {
clean_fcurve(ac, ale, thresh, clean_chan);
@@ -1105,38 +1107,38 @@ static int graphkeys_clean_exec(bContext *C, wmOperator *op)
bAnimContext ac;
float thresh;
bool clean_chan;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get cleaning threshold */
thresh = RNA_float_get(op->ptr, "threshold");
clean_chan = RNA_boolean_get(op->ptr, "channels");
/* clean keyframes */
clean_graph_keys(&ac, thresh, clean_chan);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_clean(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Clean Keyframes";
ot->idname = "GRAPH_OT_clean";
ot->description = "Simplify F-Curves by removing closely spaced keyframes";
-
+
/* api callbacks */
- //ot->invoke = // XXX we need that number popup for this!
+ //ot->invoke = // XXX we need that number popup for this!
ot->exec = graphkeys_clean_exec;
ot->poll = graphop_editable_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f);
RNA_def_boolean(ot->srna, "channels", false, "Channels", "");
@@ -1147,26 +1149,26 @@ void GRAPH_OT_clean(wmOperatorType *ot)
/* Bake each F-Curve into a set of samples */
static void bake_graph_curves(bAnimContext *ac, int start, int end)
-{
+{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through filtered data and add keys between selected keyframes on every frame */
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
ChannelDriver *driver = fcu->driver;
-
+
/* disable driver so that it don't muck up the sampling process */
fcu->driver = NULL;
-
+
/* create samples */
fcurve_store_samples(fcu, NULL, start, end, fcurve_samplingcb_evalcurve);
-
+
/* restore driver */
fcu->driver = driver;
@@ -1184,42 +1186,42 @@ static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
Scene *scene = NULL;
int start, end;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* for now, init start/end from preview-range extents */
- // TODO: add properties for this
+ // TODO: add properties for this
scene = ac.scene;
start = PSFRA;
end = PEFRA;
-
+
/* bake keyframes */
bake_graph_curves(&ac, start, end);
-
+
/* set notifier that keyframes have changed */
// NOTE: some distinction between order/number of keyframes and type should be made?
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_bake(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Bake Curve";
ot->idname = "GRAPH_OT_bake";
ot->description = "Bake selected F-Curves to a set of sampled points defining a similar curve";
-
+
/* api callbacks */
ot->invoke = WM_operator_confirm; // FIXME...
ot->exec = graphkeys_bake_exec;
- ot->poll = graphop_selected_fcurve_poll;
-
+ ot->poll = graphop_selected_fcurve_poll;
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
// todo: add props for start/end frames
}
@@ -1312,7 +1314,7 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
/* loop through all selected F-Curves, replacing its data with the sound samples */
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
-
+
/* sample the sound */
fcurve_store_samples(fcu, &sbi, start, end, fcurve_samplingcb_sound);
@@ -1403,15 +1405,15 @@ void GRAPH_OT_sound_bake(wmOperatorType *ot)
/* Evaluates the curves between each selected keyframe on each frame, and keys the value */
static void sample_graph_keys(bAnimContext *ac)
-{
+{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through filtered data and add keys between selected keyframes on every frame */
for (ale = anim_data.first; ale; ale = ale->next) {
sample_fcurve((FCurve *)ale->key_data);
@@ -1428,31 +1430,31 @@ static void sample_graph_keys(bAnimContext *ac)
static int graphkeys_sample_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* sample keyframes */
sample_graph_keys(&ac);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_sample(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Sample Keyframes";
ot->idname = "GRAPH_OT_sample";
ot->description = "Add keyframes on every frame between the selected keyframes";
-
+
/* api callbacks */
ot->exec = graphkeys_sample_exec;
ot->poll = graphop_editable_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1471,27 +1473,27 @@ void GRAPH_OT_sample(wmOperatorType *ot)
static const EnumPropertyItem prop_graphkeys_expo_types[] = {
{FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant Extrapolation", "Values on endpoint keyframes are held"},
{FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear Extrapolation", "Straight-line slope of end segments are extended past the endpoint keyframes"},
-
+
{MAKE_CYCLIC_EXPO, "MAKE_CYCLIC", 0, "Make Cyclic (F-Modifier)", "Add Cycles F-Modifier if one doesn't exist already"},
{CLEAR_CYCLIC_EXPO, "CLEAR_CYCLIC", 0, "Clear Cyclic (F-Modifier)", "Remove Cycles F-Modifier if not needed anymore"},
{0, NULL, 0, NULL, NULL}
};
/* this function is responsible for setting extrapolation mode for keyframes */
-static void setexpo_graph_keys(bAnimContext *ac, short mode)
+static void setexpo_graph_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through setting mode per F-Curve */
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
-
+
if (mode >= 0) {
/* just set mode setting */
fcu->extend = mode;
@@ -1499,7 +1501,7 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode)
ale->update |= ANIM_UPDATE_HANDLES;
}
else {
- /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation
+ /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation
* without having to go through FModifier UI in Graph Editor to do so
*/
if (mode == MAKE_CYCLIC_EXPO) {
@@ -1512,10 +1514,10 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode)
else if (mode == CLEAR_CYCLIC_EXPO) {
/* remove all the modifiers fitting this description */
FModifier *fcm, *fcn = NULL;
-
+
for (fcm = fcu->modifiers.first; fcm; fcm = fcn) {
fcn = fcm->next;
-
+
if (fcm->type == FMODIFIER_TYPE_CYCLES)
remove_fmodifier(&fcu->modifiers, fcm);
}
@@ -1535,38 +1537,38 @@ static int graphkeys_expo_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* set handle type */
setexpo_graph_keys(&ac, mode);
-
+
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_extrapolation_type(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Keyframe Extrapolation";
ot->idname = "GRAPH_OT_extrapolation_type";
ot->description = "Set extrapolation mode for selected F-Curves";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = graphkeys_expo_exec;
ot->poll = graphop_editable_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_expo_types, 0, "Type", "");
}
@@ -1574,17 +1576,17 @@ void GRAPH_OT_extrapolation_type(wmOperatorType *ot)
/* ******************** Set Interpolation-Type Operator *********************** */
/* this function is responsible for setting interpolation mode for keyframes */
-static void setipo_graph_keys(bAnimContext *ac, short mode)
+static void setipo_graph_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
KeyframeEditFunc set_cb = ANIM_editkeyframes_ipo(mode);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through setting BezTriple interpolation
* Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
*/
@@ -1604,38 +1606,38 @@ static int graphkeys_ipo_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* set handle type */
setipo_graph_keys(&ac, mode);
-
+
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_interpolation_type(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Keyframe Interpolation";
ot->idname = "GRAPH_OT_interpolation_type";
ot->description = "Set interpolation mode for the F-Curve segments starting from the selected keyframes";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = graphkeys_ipo_exec;
ot->poll = graphop_editable_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_beztriple_interpolation_mode_items, 0, "Type", "");
}
@@ -1648,11 +1650,11 @@ static void seteasing_graph_keys(bAnimContext *ac, short mode)
bAnimListElem *ale;
int filter;
KeyframeEditFunc set_cb = ANIM_editkeyframes_easing(mode);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through setting BezTriple easing
* Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
*/
@@ -1670,20 +1672,20 @@ static int graphkeys_easing_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* set handle type */
seteasing_graph_keys(&ac, mode);
-
+
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1693,15 +1695,15 @@ void GRAPH_OT_easing_type(wmOperatorType *ot)
ot->name = "Set Keyframe Easing Type";
ot->idname = "GRAPH_OT_easing_type";
ot->description = "Set easing type for the F-Curve segments starting from the selected keyframes";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = graphkeys_easing_exec;
ot->poll = graphop_editable_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_beztriple_interpolation_easing_items, 0, "Type", "");
}
@@ -1709,25 +1711,25 @@ void GRAPH_OT_easing_type(wmOperatorType *ot)
/* ******************** Set Handle-Type Operator *********************** */
/* this function is responsible for setting handle-type of selected keyframes */
-static void sethandles_graph_keys(bAnimContext *ac, short mode)
+static void sethandles_graph_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditFunc edit_cb = ANIM_editkeyframes_handles(mode);
KeyframeEditFunc sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
- /* loop through setting flags for handles
+
+ /* loop through setting flags for handles
* Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
*/
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
-
+
/* any selected keyframes for editing? */
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) {
/* change type of selected handles */
@@ -1746,38 +1748,38 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* set handle type */
sethandles_graph_keys(&ac, mode);
-
+
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_handle_type(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Keyframe Handle Type";
ot->idname = "GRAPH_OT_handle_type";
ot->description = "Set type of handle for selected keyframes";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = graphkeys_handletype_exec;
ot->poll = graphop_editable_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_keyframe_handle_type_items, 0, "Type", "");
}
@@ -1795,43 +1797,43 @@ void GRAPH_OT_handle_type(wmOperatorType *ot)
/* set of three euler-rotation F-Curves */
typedef struct tEulerFilter {
struct tEulerFilter *next, *prev;
-
+
ID *id; /* ID-block which owns the channels */
FCurve *(fcurves[3]); /* 3 Pointers to F-Curves */
const char *rna_path; /* Pointer to one of the RNA Path's used by one of the F-Curves */
} tEulerFilter;
-
+
static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
ListBase eulers = {NULL, NULL};
tEulerFilter *euf = NULL;
int groups = 0, failed = 0;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* The process is done in two passes:
* 1) Sets of three related rotation curves are identified from the selected channels,
* and are stored as a single 'operation unit' for the next step
* 2) Each set of three F-Curves is processed for each keyframe, with the values being
* processed as necessary
*/
-
+
/* step 1: extract only the rotation f-curves */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
-
- /* check if this is an appropriate F-Curve
+
+ /* check if this is an appropriate F-Curve
* - only rotation curves
* - for pchan curves, make sure we're only using the euler curves
*/
@@ -1843,9 +1845,9 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
(ale->id) ? ale->id->name : TIP_("<No ID>"), fcu->rna_path, fcu->array_index);
continue;
}
-
+
/* optimization: assume that xyz curves will always be stored consecutively,
- * so if the paths or the ID's don't match up, then a curve needs to be added
+ * so if the paths or the ID's don't match up, then a curve needs to be added
* to a new group
*/
if ((euf) && (euf->id == ale->id) && (STREQ(euf->rna_path, fcu->rna_path))) {
@@ -1857,7 +1859,7 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
euf = MEM_callocN(sizeof(tEulerFilter), "tEulerFilter");
BLI_addtail(&eulers, euf);
groups++;
-
+
euf->id = ale->id;
euf->rna_path = fcu->rna_path; /* this should be safe, since we're only using it for a short time */
euf->fcurves[fcu->array_index] = fcu;
@@ -1871,13 +1873,13 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_WARNING, "No Euler Rotation F-Curves to fix up");
return OPERATOR_CANCELLED;
}
-
- /* step 2: go through each set of curves, processing the values at each keyframe
+
+ /* step 2: go through each set of curves, processing the values at each keyframe
* - it is assumed that there must be a full set of keyframes at each keyframe position
*/
for (euf = eulers.first; euf; euf = euf->next) {
int f;
-
+
/* sanity check: ensure that there are enough F-Curves to work on in this group */
/* TODO: also enforce assumption that there be a full set of keyframes at each position by ensuring that totvert counts are same? */
if (ELEM(NULL, euf->fcurves[0], euf->fcurves[1], euf->fcurves[2])) {
@@ -1888,7 +1890,7 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
(euf->fcurves[1] == NULL) ? "Y" : "",
(euf->fcurves[2] == NULL) ? "Z" : "",
euf->id->name, euf->rna_path);
-
+
/* keep track of number of failed sets, and carry on to next group */
failed++;
continue;
@@ -1900,21 +1902,21 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
FCurve *fcu = euf->fcurves[f];
BezTriple *bezt, *prev;
unsigned int i;
-
+
/* skip if not enough vets to do a decent analysis of... */
if (fcu->totvert <= 2)
continue;
-
+
/* prev follows bezt, bezt = "current" point to be fixed */
/* our method depends on determining a "difference" from the previous vert */
for (i = 1, prev = fcu->bezt, bezt = fcu->bezt + 1; i < fcu->totvert; i++, prev = bezt++) {
const float sign = (prev->vec[1][1] > bezt->vec[1][1]) ? 1.0f : -1.0f;
-
+
/* > 180 degree flip? */
if ((sign * (prev->vec[1][1] - bezt->vec[1][1])) >= (float)M_PI) {
/* 360 degrees to add/subtract frame value until difference is acceptably small that there's no more flip */
const float fac = sign * 2.0f * (float)M_PI;
-
+
while ((sign * (prev->vec[1][1] - bezt->vec[1][1])) >= (float)M_PI) {
bezt->vec[0][1] += fac;
bezt->vec[1][1] += fac;
@@ -1925,13 +1927,13 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
}
}
BLI_freelistN(&eulers);
-
+
ANIM_animdata_update(&ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
/* updates + finishing warnings */
if (failed == groups) {
- BKE_report(op->reports, RPT_ERROR,
+ BKE_report(op->reports, RPT_ERROR,
"No Euler Rotations could be corrected, ensure each rotation has keys for all components, "
"and that F-Curves for these are in consecutive XYZ order and selected");
return OPERATOR_CANCELLED;
@@ -1943,15 +1945,15 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
"ensure each rotation has keys for all components, and that F-Curves for these are in "
"consecutive XYZ order and selected");
}
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
/* done at last */
return OPERATOR_FINISHED;
}
}
-
+
void GRAPH_OT_euler_filter(wmOperatorType *ot)
{
/* identifiers */
@@ -1960,11 +1962,11 @@ void GRAPH_OT_euler_filter(wmOperatorType *ot)
ot->description = "Fix large jumps and flips in the selected "
"Euler Rotation F-Curves arising from rotation "
"values being clipped when baking physics";
-
+
/* api callbacks */
ot->exec = graphkeys_euler_filter_exec;
ot->poll = graphop_editable_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1988,18 +1990,18 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
bAnimListElem *ale;
int filter;
KeyframeEditData ked;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* init edit data */
memset(&ked, 0, sizeof(KeyframeEditData));
-
+
/* loop over action data, averaging values */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
short mapping_flag = ANIM_get_normalization_flags(&ac);
@@ -2010,9 +2012,9 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
memset(&current_ked, 0, sizeof(current_ked));
if (adt) {
- ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&current_ked, ale->key_data, NULL, bezt_calc_average, NULL);
- ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
else
ANIM_fcurve_keyframes_loop(&current_ked, ale->key_data, NULL, bezt_calc_average, NULL);
@@ -2022,14 +2024,14 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
ked.f2 += (current_ked.f2 + offset) * unit_scale;
ked.i2 += current_ked.i2;
}
-
+
ANIM_animdata_freelist(&anim_data);
-
+
/* set the new current frame and cursor values, based on the average time and value */
if (ked.i1) {
SpaceIpo *sipo = (SpaceIpo *)ac.sl;
Scene *scene = ac.scene;
-
+
/* take the average values, rounding to the nearest int as necessary for int results */
if (sipo->mode == SIPO_MODE_DRIVERS) {
/* Drivers Mode - Affects cursor (float) */
@@ -2043,10 +2045,10 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
sipo->cursorVal = ked.f2 / (float)ked.i1;
}
}
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
-
+
return OPERATOR_FINISHED;
}
@@ -2056,11 +2058,11 @@ void GRAPH_OT_frame_jump(wmOperatorType *ot)
ot->name = "Jump to Keyframes";
ot->idname = "GRAPH_OT_frame_jump";
ot->description = "Place the cursor on the midpoint of selected keyframes";
-
+
/* api callbacks */
ot->exec = graphkeys_framejump_exec;
ot->poll = graphkeys_framejump_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2085,23 +2087,23 @@ static const EnumPropertyItem prop_graphkeys_snap_types[] = {
};
/* this function is responsible for snapping keyframes to frame-times */
-static void snap_graph_keys(bAnimContext *ac, short mode)
+static void snap_graph_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
KeyframeEditData ked;
KeyframeEditFunc edit_cb;
float cursor_value = 0.0f;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* init custom data for iterating over keyframes */
- memset(&ked, 0, sizeof(KeyframeEditData));
+ memset(&ked, 0, sizeof(KeyframeEditData));
ked.scene = ac->scene;
if (mode == GRAPHKEYS_SNAP_NEAREST_MARKER) {
ked.list.first = (ac->markers) ? ac->markers->first : NULL;
@@ -2119,32 +2121,32 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
mode = SNAP_KEYS_TIME;
}
}
-
+
/* get beztriple editing callbacks */
edit_cb = ANIM_editkeyframes_snap(mode);
-
+
/* snap keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
/* normalise cursor value (for normalised F-Curves display) */
if (mode == GRAPHKEYS_SNAP_VALUE) {
short mapping_flag = ANIM_get_normalization_flags(ac);
float offset;
float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, mapping_flag, &offset);
-
+
ked.f1 = (cursor_value / unit_scale) - offset;
}
-
+
/* perform snapping */
if (adt) {
- ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
- else
+ else
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
-
+
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -2158,38 +2160,38 @@ static int graphkeys_snap_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get snapping mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* snap keyframes */
snap_graph_keys(&ac, mode);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_snap(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Snap Keys";
ot->idname = "GRAPH_OT_snap";
ot->description = "Snap selected keyframes to the chosen times/values";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = graphkeys_snap_exec;
ot->poll = graphop_editable_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_snap_types, 0, "Type", "");
}
@@ -2212,28 +2214,28 @@ static const EnumPropertyItem prop_graphkeys_mirror_types[] = {
};
/* this function is responsible for mirroring keyframes */
-static void mirror_graph_keys(bAnimContext *ac, short mode)
+static void mirror_graph_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
KeyframeEditData ked;
KeyframeEditFunc edit_cb;
float cursor_value = 0.0f;
/* init custom data for looping over keyframes */
- memset(&ked, 0, sizeof(KeyframeEditData));
+ memset(&ked, 0, sizeof(KeyframeEditData));
ked.scene = ac->scene;
-
+
/* store mode-specific custom data... */
if (mode == GRAPHKEYS_MIRROR_MARKER) {
TimeMarker *marker = NULL;
-
+
/* find first selected marker */
marker = ED_markers_get_first_selected(ac->markers);
-
+
/* store marker's time (if available) */
if (marker)
ked.f1 = (float)marker->frame;
@@ -2252,36 +2254,36 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
mode = MIRROR_KEYS_TIME;
}
}
-
+
/* get beztriple editing callbacks */
edit_cb = ANIM_editkeyframes_mirror(mode);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* mirror keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
/* apply unit corrections */
if (mode == GRAPHKEYS_MIRROR_VALUE) {
short mapping_flag = ANIM_get_normalization_flags(ac);
float offset;
float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, mapping_flag | ANIM_UNITCONV_ONLYKEYS, &offset);
-
+
ked.f1 = (cursor_value + offset) * unit_scale;
}
-
+
/* perform actual mirroring */
if (adt) {
- ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
- else
+ else
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
-
+
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -2295,38 +2297,38 @@ static int graphkeys_mirror_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get mirroring mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* mirror keyframes */
mirror_graph_keys(&ac, mode);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_mirror(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Mirror Keys";
ot->idname = "GRAPH_OT_mirror";
ot->description = "Flip selected keyframes over the selected mirror line";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = graphkeys_mirror_exec;
ot->poll = graphop_editable_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_mirror_types, 0, "Type", "");
}
@@ -2339,15 +2341,15 @@ static int graphkeys_smooth_exec(bContext *C, wmOperator *UNUSED(op))
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* smooth keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
/* For now, we can only smooth by flattening handles AND smoothing curve values.
@@ -2361,24 +2363,24 @@ static int graphkeys_smooth_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_animdata_update(&ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_smooth(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Smooth Keys";
ot->idname = "GRAPH_OT_smooth";
ot->description = "Apply weighted moving means to make selected F-Curves less bumpy";
-
+
/* api callbacks */
ot->exec = graphkeys_smooth_exec;
ot->poll = graphop_editable_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2393,29 +2395,29 @@ static const EnumPropertyItem *graph_fmodifier_itemf(bContext *C, PointerRNA *UN
EnumPropertyItem *item = NULL;
int totitem = 0;
int i = 0;
-
+
if (C == NULL) {
return rna_enum_fmodifier_type_items;
}
-
+
/* start from 1 to skip the 'Invalid' modifier type */
for (i = 1; i < FMODIFIER_NUM_TYPES; i++) {
const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(i);
int index;
-
+
/* check if modifier is valid for this context */
if (fmi == NULL)
continue;
-
+
index = RNA_enum_from_value(rna_enum_fmodifier_type_items, fmi->type);
if (index != -1) { /* Not all types are implemented yet... */
RNA_enum_item_add(&item, &totitem, &rna_enum_fmodifier_type_items[index]);
}
}
-
+
RNA_enum_item_end(&item, &totitem);
*r_free = true;
-
+
return item;
}
@@ -2426,14 +2428,14 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
bAnimListElem *ale;
int filter;
short type;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get type of modifier to add */
type = RNA_enum_get(op->ptr, "type");
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
if (RNA_boolean_get(op->ptr, "only_active"))
@@ -2441,12 +2443,12 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
else
filter |= (ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* add f-modifier to each curve */
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
FModifier *fcm;
-
+
/* add F-Modifier of specified type to active F-Curve, and make it the active one */
fcm = add_fmodifier(&fcu->modifiers, type, fcu);
if (fcm) {
@@ -2456,41 +2458,41 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Modifier could not be added (see console for details)");
break;
}
-
+
ale->update |= ANIM_UPDATE_DEPS;
}
-
+
ANIM_animdata_update(&ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_fmodifier_add(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Add F-Curve Modifier";
ot->idname = "GRAPH_OT_fmodifier_add";
ot->description = "Add F-Modifier to the active/selected F-Curves";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = graph_fmodifier_add_exec;
- ot->poll = graphop_selected_fcurve_poll;
-
+ ot->poll = graphop_selected_fcurve_poll;
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
prop = RNA_def_enum(ot->srna, "type", rna_enum_fmodifier_type_items, 0, "Type", "");
RNA_def_enum_funcs(prop, graph_fmodifier_itemf);
ot->prop = prop;
-
+
RNA_def_boolean(ot->srna, "only_active", 1, "Only Active", "Only add F-Modifier to active F-Curve");
}
@@ -2501,28 +2503,28 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op)
bAnimContext ac;
bAnimListElem *ale;
bool ok = false;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* clear buffer first */
ANIM_fmodifiers_copybuf_free();
-
+
/* get the active F-Curve */
ale = get_active_fcurve_channel(&ac);
-
+
/* if this exists, call the copy F-Modifiers API function */
if (ale && ale->data) {
FCurve *fcu = (FCurve *)ale->data;
-
+
/* TODO: when 'active' vs 'all' boolean is added, change last param! */
ok = ANIM_fmodifiers_copy_to_buf(&fcu->modifiers, 0);
-
+
/* free temp data now */
MEM_freeN(ale);
}
-
+
/* successful or not? */
if (ok == 0) {
BKE_report(op->reports, RPT_ERROR, "No F-Modifiers available to be copied");
@@ -2531,21 +2533,21 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op)
else
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_fmodifier_copy(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Copy F-Modifiers";
ot->idname = "GRAPH_OT_fmodifier_copy";
ot->description = "Copy the F-Modifier(s) of the active F-Curve";
-
+
/* api callbacks */
ot->exec = graph_fmodifier_copy_exec;
- ot->poll = graphop_active_fcurve_poll;
-
+ ot->poll = graphop_active_fcurve_poll;
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
//ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All F-Modifiers", "Copy all the F-Modifiers, instead of just the active one");
}
@@ -2555,18 +2557,18 @@ void GRAPH_OT_fmodifier_copy(wmOperatorType *ot)
static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
const bool replace = RNA_boolean_get(op->ptr, "replace");
bool ok = false;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* filter data */
if (RNA_boolean_get(op->ptr, "only_active")) {
/* This should be the default (for buttons) - Just paste to the active FCurve */
@@ -2576,32 +2578,32 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op)
/* This is only if the operator gets called from a hotkey or search - Paste to all visible curves */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
}
-
+
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* paste modifiers */
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
int tot;
-
+
tot = ANIM_fmodifiers_paste_from_buf(&fcu->modifiers, replace, fcu);
-
+
if (tot) {
ale->update |= ANIM_UPDATE_DEPS;
ok = true;
}
}
-
+
if (ok) {
ANIM_animdata_update(&ac, &anim_data);
}
ANIM_animdata_freelist(&anim_data);
-
+
/* successful or not? */
if (ok) {
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
else {
@@ -2609,24 +2611,24 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
}
-
+
void GRAPH_OT_fmodifier_paste(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Paste F-Modifiers";
ot->idname = "GRAPH_OT_fmodifier_paste";
ot->description = "Add copied F-Modifiers to the selected F-Curves";
-
+
/* api callbacks */
ot->exec = graph_fmodifier_paste_exec;
ot->poll = graphop_active_fcurve_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "only_active", true, "Only Active", "Only paste F-Modifiers on active F-Curve");
- RNA_def_boolean(ot->srna, "replace", false, "Replace Existing",
+ RNA_def_boolean(ot->srna, "replace", false, "Replace Existing",
"Replace existing F-Modifiers, instead of just appending to the end of the existing list");
}
@@ -2640,45 +2642,45 @@ static int graph_driver_vars_copy_exec(bContext *C, wmOperator *op)
bAnimContext ac;
bAnimListElem *ale;
bool ok = false;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* clear buffer first */
ANIM_driver_vars_copybuf_free();
-
+
/* get the active F-Curve */
ale = get_active_fcurve_channel(&ac);
-
+
/* if this exists, call the copy driver vars API function */
if (ale && ale->data) {
FCurve *fcu = (FCurve *)ale->data;
-
+
ok = ANIM_driver_vars_copy(op->reports, fcu);
-
+
/* free temp data now */
MEM_freeN(ale);
}
-
+
/* successful or not? */
if (ok)
return OPERATOR_FINISHED;
else
return OPERATOR_CANCELLED;
}
-
+
void GRAPH_OT_driver_variables_copy(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Copy Driver Variables";
ot->idname = "GRAPH_OT_driver_variables_copy";
ot->description = "Copy the driver variables of the active F-Curve";
-
+
/* api callbacks */
ot->exec = graph_driver_vars_copy_exec;
- ot->poll = graphop_active_fcurve_poll;
-
+ ot->poll = graphop_active_fcurve_poll;
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2688,62 +2690,62 @@ void GRAPH_OT_driver_variables_copy(wmOperatorType *ot)
static int graph_driver_vars_paste_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
const bool replace = RNA_boolean_get(op->ptr, "replace");
bool ok = false;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* paste variables */
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
ok |= ANIM_driver_vars_paste(op->reports, fcu, replace);
}
-
+
/* cleanup */
ANIM_animdata_freelist(&anim_data);
-
+
/* successful or not? */
if (ok) {
/* rebuild depsgraph, now that there are extra deps here */
DEG_relations_tag_update(CTX_data_main(C));
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, CTX_data_scene(C));
-
+
return OPERATOR_FINISHED;
}
else {
return OPERATOR_CANCELLED;
}
}
-
+
void GRAPH_OT_driver_variables_paste(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Paste Driver Variables";
ot->idname = "GRAPH_OT_driver_variables_paste";
ot->description = "Add copied driver variables to the active driver";
-
+
/* api callbacks */
ot->exec = graph_driver_vars_paste_exec;
ot->poll = graphop_active_fcurve_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
- RNA_def_boolean(ot->srna, "replace", false, "Replace Existing",
+ RNA_def_boolean(ot->srna, "replace", false, "Replace Existing",
"Replace existing driver variables, instead of just appending to the end of the existing list");
}
diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h
index 6c375b23352..da352d4ea06 100644
--- a/source/blender/editors/space_graph/graph_intern.h
+++ b/source/blender/editors/space_graph/graph_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -87,7 +87,7 @@ enum eGraphKeys_ColumnSelect_Mode {
/* ***************************************** */
/* graph_edit.c */
-void get_graph_keyframe_extents(struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax,
+void get_graph_keyframe_extents(struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax,
const bool do_selected, const bool include_handles);
void GRAPH_OT_previewrange_set(struct wmOperatorType *ot);
@@ -119,7 +119,7 @@ void GRAPH_OT_frame_jump(struct wmOperatorType *ot);
void GRAPH_OT_snap(struct wmOperatorType *ot);
void GRAPH_OT_mirror(struct wmOperatorType *ot);
-/* defines for snap keyframes
+/* defines for snap keyframes
* NOTE: keep in sync with eEditKeyframes_Snap (in ED_keyframes_edit.h)
*/
enum eGraphKeys_Snap_Mode {
@@ -131,7 +131,7 @@ enum eGraphKeys_Snap_Mode {
GRAPHKEYS_SNAP_VALUE,
};
-/* defines for mirror keyframes
+/* defines for mirror keyframes
* NOTE: keep in sync with eEditKeyframes_Mirror (in ED_keyframes_edit.h)
*/
enum eGraphKeys_Mirror_Mode {
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index 57d8f45905d..bae5798ca21 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -83,19 +83,19 @@ static void graphview_cursor_apply(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
SpaceIpo *sipo = CTX_wm_space_graph(C);
float frame = RNA_float_get(op->ptr, "frame"); /* this isn't technically "frame", but it'll do... */
-
+
/* adjust the frame or the cursor x-value */
if (sipo->mode == SIPO_MODE_DRIVERS) {
/* adjust cursor x-value */
sipo->cursorTime = frame;
}
else {
- /* adjust the frame
+ /* adjust the frame
* NOTE: sync this part of the code with ANIM_OT_change_frame
*/
/* 1) frame is rounded to the nearest int, since frames are ints */
CFRA = round_fl_to_int(frame);
-
+
if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) {
/* Clip to preview range
* NOTE: Preview range won't go into negative values,
@@ -107,14 +107,14 @@ static void graphview_cursor_apply(bContext *C, wmOperator *op)
/* Prevent negative frames */
FRAMENUMBER_MIN_CLAMP(CFRA);
}
-
+
SUBFRA = 0.0f;
BKE_sound_seek_scene(bmain, scene);
}
-
+
/* set the cursor value */
sipo->cursorVal = RNA_float_get(op->ptr, "value");
-
+
/* send notifiers - notifiers for frame should force an update for both vars ok... */
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
@@ -135,14 +135,14 @@ static void graphview_cursor_setprops(bContext *C, wmOperator *op, const wmEvent
{
ARegion *ar = CTX_wm_region(C);
float viewx, viewy;
-
+
/* abort if not active region (should not really be possible) */
if (ar == NULL)
return;
-
+
/* convert from region coordinates to View2D 'tot' space */
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy);
-
+
/* store the values in the operator properties */
/* NOTE: we don't clamp frame here, as it might be used for the drivers cursor */
RNA_float_set(op->ptr, "frame", viewx);
@@ -153,18 +153,18 @@ static void graphview_cursor_setprops(bContext *C, wmOperator *op, const wmEvent
static int graphview_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
bScreen *screen = CTX_wm_screen(C);
-
+
/* Change to frame that mouse is over before adding modal handler,
* as user could click on a single frame (jump to frame) as well as
* click-dragging over a range (modal scrubbing). Apply this change.
*/
graphview_cursor_setprops(C, op, event);
graphview_cursor_apply(C, op);
-
+
/* Signal that a scrubbing operating is starting */
if (screen)
screen->scrubbing = true;
-
+
/* add temp handler */
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
@@ -175,32 +175,32 @@ static int graphview_cursor_modal(bContext *C, wmOperator *op, const wmEvent *ev
{
bScreen *screen = CTX_wm_screen(C);
Scene *scene = CTX_data_scene(C);
-
+
/* execute the events */
switch (event->type) {
case ESCKEY:
if (screen)
screen->scrubbing = false;
-
+
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
return OPERATOR_FINISHED;
-
+
case MOUSEMOVE:
/* set the new values */
graphview_cursor_setprops(C, op, event);
graphview_cursor_apply(C, op);
break;
-
- case LEFTMOUSE:
+
+ case LEFTMOUSE:
case RIGHTMOUSE:
case MIDDLEMOUSE:
- /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init
+ /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init
* the modal op) doesn't work for some reason
*/
if (event->val == KM_RELEASE) {
if (screen)
screen->scrubbing = false;
-
+
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
return OPERATOR_FINISHED;
}
@@ -216,13 +216,13 @@ static void GRAPH_OT_cursor_set(wmOperatorType *ot)
ot->name = "Set Cursor";
ot->idname = "GRAPH_OT_cursor_set";
ot->description = "Interactively set the current frame and value cursor";
-
+
/* api callbacks */
ot->exec = graphview_cursor_exec;
ot->invoke = graphview_cursor_invoke;
ot->modal = graphview_cursor_modal;
ot->poll = graphview_cursor_poll;
-
+
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_UNDO;
@@ -241,39 +241,39 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
bAnimListElem *ale;
int filter;
const bool unselected = RNA_boolean_get(op->ptr, "unselected");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
- /* get list of all channels that selection may need to be flushed to
+
+ /* get list of all channels that selection may need to be flushed to
* - hierarchy must not affect what we have access to here...
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype);
-
+
/* filter data
- * - of the remaining visible curves, we want to hide the ones that are
- * selected/unselected (depending on "unselected" prop)
+ * - of the remaining visible curves, we want to hide the ones that are
+ * selected/unselected (depending on "unselected" prop)
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
if (unselected)
filter |= ANIMFILTER_UNSEL;
else
filter |= ANIMFILTER_SEL;
-
+
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
/* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */
/* TODO: find out why this is the case, and fix that */
if (ale->type == ANIMTYPE_OBJECT)
continue;
-
+
/* change the hide setting, and unselect it... */
ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_CLEAR);
ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_SELECT, ACHANNEL_SETFLAG_CLEAR);
-
+
/* now, also flush selection status up/down as appropriate */
ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_CLEAR);
}
@@ -281,7 +281,7 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
/* cleanup */
ANIM_animdata_freelist(&anim_data);
BLI_freelistN(&all_data);
-
+
/* unhide selected */
if (unselected) {
/* turn off requirement for visible */
@@ -295,21 +295,21 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
/* TODO: find out why this is the case, and fix that */
if (ale->type == ANIMTYPE_OBJECT)
continue;
-
+
/* change the hide setting, and unselect it... */
ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_ADD);
ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_SELECT, ACHANNEL_SETFLAG_ADD);
-
+
/* now, also flush selection status up/down as appropriate */
ANIM_flush_setting_anim_channels(&ac, &anim_data, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_ADD);
}
- ANIM_animdata_freelist(&anim_data);
+ ANIM_animdata_freelist(&anim_data);
}
-
-
+
+
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -319,14 +319,14 @@ static void GRAPH_OT_hide(wmOperatorType *ot)
ot->name = "Hide Curves";
ot->idname = "GRAPH_OT_hide";
ot->description = "Hide selected curves from Graph Editor view";
-
+
/* api callbacks */
ot->exec = graphview_curves_hide_exec;
ot->poll = ED_operator_graphedit_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected curves");
}
@@ -341,50 +341,50 @@ static int graphview_curves_reveal_exec(bContext *C, wmOperator *op)
bAnimListElem *ale;
int filter;
const bool select = RNA_boolean_get(op->ptr, "select");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
- /* get list of all channels that selection may need to be flushed to
+
+ /* get list of all channels that selection may need to be flushed to
* - hierarchy must not affect what we have access to here...
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype);
-
+
/* filter data
* - just go through all visible channels, ensuring that everything is set to be curve-visible
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
/* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */
/* TODO: find out why this is the case, and fix that */
if (ale->type == ANIMTYPE_OBJECT)
continue;
-
+
/* select if it is not visible */
if (ANIM_channel_setting_get(&ac, ale, ACHANNEL_SETTING_VISIBLE) == 0) {
ANIM_channel_setting_set(
&ac, ale, ACHANNEL_SETTING_SELECT,
select ? ACHANNEL_SETFLAG_ADD : ACHANNEL_SETFLAG_CLEAR);
}
-
+
/* change the visibility setting */
ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_ADD);
-
+
/* now, also flush selection status up/down as appropriate */
ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, true);
}
-
+
/* cleanup */
ANIM_animdata_freelist(&anim_data);
BLI_freelistN(&all_data);
-
+
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -394,11 +394,11 @@ static void GRAPH_OT_reveal(wmOperatorType *ot)
ot->name = "Reveal Curves";
ot->idname = "GRAPH_OT_reveal";
ot->description = "Make previously hidden curves visible again in Graph Editor view";
-
+
/* api callbacks */
ot->exec = graphview_curves_reveal_exec;
ot->poll = ED_operator_graphedit_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -411,19 +411,19 @@ void graphedit_operatortypes(void)
{
/* view */
WM_operatortype_append(GRAPH_OT_cursor_set);
-
+
WM_operatortype_append(GRAPH_OT_previewrange_set);
WM_operatortype_append(GRAPH_OT_view_all);
WM_operatortype_append(GRAPH_OT_view_selected);
WM_operatortype_append(GRAPH_OT_properties);
WM_operatortype_append(GRAPH_OT_view_frame);
-
+
WM_operatortype_append(GRAPH_OT_ghost_curves_create);
WM_operatortype_append(GRAPH_OT_ghost_curves_clear);
-
+
WM_operatortype_append(GRAPH_OT_hide);
WM_operatortype_append(GRAPH_OT_reveal);
-
+
/* keyframes */
/* selection */
WM_operatortype_append(GRAPH_OT_clickselect);
@@ -436,7 +436,7 @@ void graphedit_operatortypes(void)
WM_operatortype_append(GRAPH_OT_select_more);
WM_operatortype_append(GRAPH_OT_select_less);
WM_operatortype_append(GRAPH_OT_select_leftright);
-
+
/* editing */
WM_operatortype_append(GRAPH_OT_snap);
WM_operatortype_append(GRAPH_OT_mirror);
@@ -453,18 +453,18 @@ void graphedit_operatortypes(void)
WM_operatortype_append(GRAPH_OT_euler_filter);
WM_operatortype_append(GRAPH_OT_delete);
WM_operatortype_append(GRAPH_OT_duplicate);
-
+
WM_operatortype_append(GRAPH_OT_copy);
WM_operatortype_append(GRAPH_OT_paste);
-
+
WM_operatortype_append(GRAPH_OT_keyframe_insert);
WM_operatortype_append(GRAPH_OT_click_insert);
-
+
/* F-Curve Modifiers */
WM_operatortype_append(GRAPH_OT_fmodifier_add);
WM_operatortype_append(GRAPH_OT_fmodifier_copy);
WM_operatortype_append(GRAPH_OT_fmodifier_paste);
-
+
/* Drivers */
WM_operatortype_append(GRAPH_OT_driver_variables_copy);
WM_operatortype_append(GRAPH_OT_driver_variables_paste);
@@ -475,7 +475,7 @@ void ED_operatormacros_graph(void)
{
wmOperatorType *ot;
wmOperatorTypeMacro *otmacro;
-
+
ot = WM_operatortype_append_macro("GRAPH_OT_duplicate_move", "Duplicate",
"Make a copy of all selected keyframes and move them",
OPTYPE_UNDO | OPTYPE_REGISTER);
@@ -491,7 +491,7 @@ void ED_operatormacros_graph(void)
static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
{
wmKeyMapItem *kmi;
-
+
/* view */
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", HKEY, KM_PRESS, KM_CTRL, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.show_handles");
@@ -500,8 +500,8 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
* This keymap is supposed to override ANIM_OT_change_frame, which does the same except it doesn't do y-values
*/
WM_keymap_add_item(keymap, "GRAPH_OT_cursor_set", ACTIONMOUSE, KM_PRESS, 0, 0);
-
-
+
+
/* graph_select.c - selection tools */
/* click-select: keyframe (replace) */
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0);
@@ -533,7 +533,7 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
RNA_boolean_set(kmi->ptr, "extend", true);
RNA_boolean_set(kmi->ptr, "curves", true);
RNA_boolean_set(kmi->ptr, "column", false);
-
+
/* click-select left/right */
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "extend", false);
@@ -541,20 +541,20 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", true);
RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST);
-
+
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "extend", false);
RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_LEFT);
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "extend", false);
RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT);
-
+
/* deselect all */
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "invert", false);
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "invert", true);
-
+
/* borderselect */
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "axis_range", false);
@@ -562,68 +562,70 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "axis_range", true);
RNA_boolean_set(kmi->ptr, "include_handles", false);
-
+
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "axis_range", false);
RNA_boolean_set(kmi->ptr, "include_handles", true);
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "axis_range", true);
RNA_boolean_set(kmi->ptr, "include_handles", true);
-
+
/* region select */
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "deselect", false);
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "deselect", true);
-
+
WM_keymap_add_item(keymap, "GRAPH_OT_select_circle", CKEY, KM_PRESS, 0, 0);
-
+
/* column select */
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_KEYS);
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_CFRA);
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN);
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN);
-
+
/* select more/less */
WM_keymap_add_item(keymap, "GRAPH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "GRAPH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
-
+
/* select linked */
WM_keymap_add_item(keymap, "GRAPH_OT_select_linked", LKEY, KM_PRESS, 0, 0);
-
-
+
+
/* graph_edit.c */
/* jump to selected keyframes */
WM_keymap_add_item(keymap, "GRAPH_OT_frame_jump", GKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* menu + single-step transform */
WM_keymap_add_item(keymap, "GRAPH_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "GRAPH_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0);
-
+
WM_keymap_add_item(keymap, "GRAPH_OT_handle_type", VKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "GRAPH_OT_interpolation_type", TKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "GRAPH_OT_easing_type", EKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* destructive */
WM_keymap_add_item(keymap, "GRAPH_OT_smooth", OKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "GRAPH_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0);
-
+
WM_keymap_add_item(keymap, "GRAPH_OT_bake", CKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_menu(keymap, "GRAPH_MT_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_menu(keymap, "GRAPH_MT_delete", DELKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_menu(keymap, "GRAPH_MT_specials", WKEY, KM_PRESS, 0, 0);
+
WM_keymap_add_item(keymap, "GRAPH_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
-
+
/* insertkey */
WM_keymap_add_item(keymap, "GRAPH_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0);
-
+
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_click_insert", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "extend", false);
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_click_insert", ACTIONMOUSE, KM_CLICK, KM_CTRL | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", true);
-
+
/* copy/paste */
WM_keymap_add_item(keymap, "GRAPH_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "GRAPH_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
@@ -648,16 +650,16 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
/* F-Modifiers */
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "only_active", false);
-
+
/* animation module */
/* channels list
* NOTE: these operators were originally for the channels list, but are added here too for convenience...
*/
WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0);
-
+
/* transform system */
transform_keymap_for_space(keyconf, keymap, SPACE_IPO);
-
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_fcurve");
@@ -665,15 +667,15 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
RNA_string_set(kmi->ptr, "value", "BOUNDING_BOX_CENTER");
-
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
RNA_string_set(kmi->ptr, "value", "CURSOR");
-
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, KM_CTRL, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
RNA_string_set(kmi->ptr, "value", "INDIVIDUAL_ORIGINS");
-
+
/* special markers hotkeys for anim editors: see note in definition of this function */
ED_marker_keymap_animedit_conflictfree(keymap);
}
@@ -684,35 +686,34 @@ void graphedit_keymap(wmKeyConfig *keyconf)
{
wmKeyMap *keymap;
wmKeyMapItem *kmi;
-
+
/* keymap for all regions */
keymap = WM_keymap_find(keyconf, "Graph Editor Generic", SPACE_IPO, 0);
WM_keymap_add_item(keymap, "GRAPH_OT_properties", NKEY, KM_PRESS, 0, 0);
-
+
/* extrapolation works on channels, not keys */
WM_keymap_add_item(keymap, "GRAPH_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0);
-
+
/* find (i.e. a shortcut for setting the name filter) */
WM_keymap_add_item(keymap, "ANIM_OT_channels_find", FKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* hide/reveal selected curves */
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_hide", HKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "unselected", false);
-
+
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "unselected", true);
-
+
WM_keymap_add_item(keymap, "GRAPH_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
-
-
+
+
/* channels */
- /* Channels are not directly handled by the Graph Editor module, but are inherited from the Animation module.
+ /* Channels are not directly handled by the Graph Editor module, but are inherited from the Animation module.
* All the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as these
* are all used for the Graph Editor too.
*/
-
+
/* keyframes */
keymap = WM_keymap_find(keyconf, "Graph Editor", SPACE_IPO, 0);
graphedit_keymap_keyframes(keyconf, keymap);
}
-
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 0b7ce7d7310..ed9bed19d20 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -77,7 +77,7 @@
* - This is called by the deselect all operator, as well as other ones!
*
* - test: check if select or deselect all
- * - sel: how to select keyframes
+ * - sel: how to select keyframes
* 0 = deselect
* 1 = select
* 2 = invert
@@ -88,20 +88,20 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
KeyframeEditData ked = {{NULL}};
KeyframeEditFunc test_cb, sel_cb;
-
+
/* determine type-based settings */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
-
+
/* filter data */
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* init BezTriple looping data */
test_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
-
+
/* See if we should be selecting or deselecting */
if (test) {
for (ale = anim_data.first; ale; ale = ale->next) {
@@ -111,17 +111,17 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel
}
}
}
-
+
/* convert sel to selectmode, and use that to get editor */
sel_cb = ANIM_editkeyframes_select(sel);
-
+
/* Now set the flags */
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
-
+
/* Keyframes First */
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL);
-
+
/* affect channel selection status? */
if (do_channels) {
/* only change selection of channel when the visibility of keyframes doesn't depend on this */
@@ -129,17 +129,17 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel
/* deactivate the F-Curve, and deselect if deselecting keyframes.
* otherwise select the F-Curve too since we've selected all the keyframes
*/
- if (sel == SELECT_SUBTRACT)
+ if (sel == SELECT_SUBTRACT)
fcu->flag &= ~FCURVE_SELECTED;
else
fcu->flag |= FCURVE_SELECTED;
}
-
+
/* always deactivate all F-Curves if we perform batch ops for selection */
fcu->flag &= ~FCURVE_ACTIVE;
}
}
-
+
/* Cleanup */
ANIM_animdata_freelist(&anim_data);
}
@@ -150,56 +150,56 @@ static int graphkeys_deselectall_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
bAnimListElem *ale_active = NULL;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
- /* find active F-Curve, and preserve this for later
+
+ /* find active F-Curve, and preserve this for later
* or else it becomes annoying with the current active
* curve keeps fading out even while you're editing it
*/
ale_active = get_active_fcurve_channel(&ac);
-
+
/* 'standard' behavior - check if selected, then apply relevant selection */
if (RNA_boolean_get(op->ptr, "invert"))
deselect_graph_keys(&ac, 0, SELECT_INVERT, true);
else
deselect_graph_keys(&ac, 1, SELECT_ADD, true);
-
+
/* restore active F-Curve... */
if (ale_active) {
FCurve *fcu = (FCurve *)ale_active->data;
-
- /* all others should not be disabled, so we should be able to just set this directly...
+
+ /* all others should not be disabled, so we should be able to just set this directly...
* - selection needs to be set too, or else this won't work...
*/
fcu->flag |= (FCURVE_SELECTED | FCURVE_ACTIVE);
-
+
MEM_freeN(ale_active);
ale_active = NULL;
}
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_select_all_toggle(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Select All";
ot->idname = "GRAPH_OT_select_all_toggle";
ot->description = "Toggle selection of all keyframes";
-
+
/* api callbacks */
ot->exec = graphkeys_deselectall_exec;
ot->poll = graphop_visible_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
}
@@ -226,24 +226,24 @@ static void borderselect_graphkeys(
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter, mapping_flag;
-
+
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
KeyframeEditData ked;
KeyframeEditFunc ok_cb, select_cb;
View2D *v2d = &ac->ar->v2d;
rctf rectf, scaled_rectf;
-
+
/* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */
UI_view2d_region_to_view_rctf(v2d, rectf_view, &rectf);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* get beztriple editing/validation funcs */
select_cb = ANIM_editkeyframes_select(selectmode);
ok_cb = ANIM_editkeyframes_ok(mode);
-
+
/* init editing data */
memset(&ked, 0, sizeof(KeyframeEditData));
if (mode == BEZT_OK_REGION_LASSO) {
@@ -259,7 +259,7 @@ static void borderselect_graphkeys(
else {
ked.data = &scaled_rectf;
}
-
+
/* treat handles separately? */
if (incl_handles) {
ked.iterflags |= KEYFRAME_ITER_INCL_HANDLES;
@@ -267,29 +267,29 @@ static void borderselect_graphkeys(
}
else
mapping_flag = ANIM_UNITCONV_ONLYKEYS;
-
+
mapping_flag |= ANIM_get_normalization_flags(ac);
-
+
/* loop over data, doing border select */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
FCurve *fcu = (FCurve *)ale->key_data;
float offset;
float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset);
-
+
/* apply NLA mapping to all the keyframes, since it's easier than trying to
* guess when a callback might use something different
*/
if (adt)
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles == 0);
-
+
scaled_rectf.xmin = rectf.xmin;
scaled_rectf.xmax = rectf.xmax;
scaled_rectf.ymin = rectf.ymin / unit_scale - offset;
scaled_rectf.ymax = rectf.ymax / unit_scale - offset;
-
- /* set horizontal range (if applicable)
- * NOTE: these values are only used for x-range and y-range but not region
+
+ /* set horizontal range (if applicable)
+ * NOTE: these values are only used for x-range and y-range but not region
* (which uses ked.data, i.e. rectf)
*/
if (mode != BEZT_OK_VALUERANGE) {
@@ -300,12 +300,12 @@ static void borderselect_graphkeys(
ked.f1 = rectf.ymin;
ked.f2 = rectf.ymax;
}
-
+
/* firstly, check if any keyframes will be hit by this */
if (ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, ok_cb, NULL)) {
/* select keyframes that are in the appropriate places */
ANIM_fcurve_keyframes_loop(&ked, fcu, ok_cb, select_cb, NULL);
-
+
/* only change selection of channel when the visibility of keyframes doesn't depend on this */
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
/* select the curve too now that curve will be touched */
@@ -313,12 +313,12 @@ static void borderselect_graphkeys(
fcu->flag |= FCURVE_SELECTED;
}
}
-
+
/* un-apply NLA mapping from all the keyframes */
if (adt)
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, incl_handles == 0);
}
-
+
/* cleanup */
ANIM_animdata_freelist(&anim_data);
}
@@ -334,7 +334,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op)
bool incl_handles;
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
@@ -344,7 +344,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op)
if (!extend)
deselect_graph_keys(&ac, 1, SELECT_SUBTRACT, true);
- /* get select mode
+ /* get select mode
* - 'include_handles' from the operator specifies whether to include handles in the selection
*/
if (select) {
@@ -353,15 +353,15 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op)
else {
selectmode = SELECT_SUBTRACT;
}
-
+
incl_handles = RNA_boolean_get(op->ptr, "include_handles");
-
+
/* get settings from operator */
WM_operator_properties_border_to_rcti(op, &rect);
-
+
/* selection 'mode' depends on whether borderselect region only matters on one axis */
if (RNA_boolean_get(op->ptr, "axis_range")) {
- /* mode depends on which axis of the range is larger to determine which axis to use
+ /* mode depends on which axis of the range is larger to determine which axis to use
* - checking this in region-space is fine, as it's fundamentally still going to be a different rect size
* - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
* used for tweaking timing when "blocking", while channels is not that useful...
@@ -371,19 +371,19 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op)
else
mode = BEZT_OK_VALUERANGE;
}
- else
+ else
mode = BEZT_OK_REGION;
BLI_rctf_rcti_copy(&rect_fl, &rect);
/* apply borderselect action */
borderselect_graphkeys(&ac, &rect_fl, mode, selectmode, incl_handles, NULL);
-
+
/* send notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
-}
+}
void GRAPH_OT_select_border(wmOperatorType *ot)
{
@@ -391,21 +391,21 @@ void GRAPH_OT_select_border(wmOperatorType *ot)
ot->name = "Border Select";
ot->idname = "GRAPH_OT_select_border";
ot->description = "Select all keyframes within the specified region";
-
+
/* api callbacks */
ot->invoke = WM_gesture_border_invoke;
ot->exec = graphkeys_borderselect_exec;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
-
+
ot->poll = graphop_visible_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* rna */
WM_operator_properties_gesture_border_select(ot);
-
+
ot->prop = RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", "");
RNA_def_boolean(ot->srna, "include_handles", 0, "Include Handles", "Are handles tested individually against the selection criteria");
}
@@ -416,34 +416,34 @@ void GRAPH_OT_select_border(wmOperatorType *ot)
static int graphkeys_lassoselect_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
KeyframeEdit_LassoData data_lasso = {0};
rcti rect;
rctf rect_fl;
-
+
short selectmode;
bool incl_handles;
bool extend;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
data_lasso.rectf_view = &rect_fl;
data_lasso.mcords = WM_gesture_lasso_path_to_array(C, op, &data_lasso.mcords_tot);
if (data_lasso.mcords == NULL)
return OPERATOR_CANCELLED;
-
+
/* clear all selection if not extending selection */
extend = RNA_boolean_get(op->ptr, "extend");
if (!extend)
deselect_graph_keys(&ac, 1, SELECT_SUBTRACT, true);
-
+
if (!RNA_boolean_get(op->ptr, "deselect"))
selectmode = SELECT_ADD;
else
selectmode = SELECT_SUBTRACT;
-
+
{
SpaceIpo *sipo = (SpaceIpo *)ac.sl;
if (selectmode == SELECT_ADD) {
@@ -454,19 +454,19 @@ static int graphkeys_lassoselect_exec(bContext *C, wmOperator *op)
incl_handles = (sipo->flag & SIPO_NOHANDLES) == 0;
}
}
-
+
/* get settings from operator */
BLI_lasso_boundbox(&rect, data_lasso.mcords, data_lasso.mcords_tot);
BLI_rctf_rcti_copy(&rect_fl, &rect);
-
+
/* apply borderselect action */
borderselect_graphkeys(&ac, &rect_fl, BEZT_OK_REGION_LASSO, selectmode, incl_handles, &data_lasso);
-
+
MEM_freeN((void *)data_lasso.mcords);
-
+
/* send notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -476,17 +476,17 @@ void GRAPH_OT_select_lasso(wmOperatorType *ot)
ot->name = "Lasso Select";
ot->description = "Select keyframe points using lasso selection";
ot->idname = "GRAPH_OT_select_lasso";
-
+
/* api callbacks */
ot->invoke = WM_gesture_lasso_invoke;
ot->modal = WM_gesture_lasso_modal;
ot->exec = graphkeys_lassoselect_exec;
ot->poll = graphop_visible_keyframes_poll;
ot->cancel = WM_gesture_lasso_cancel;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
-
+
/* properties */
WM_operator_properties_gesture_lasso_select(ot);
}
@@ -499,10 +499,10 @@ static int graph_circle_select_exec(bContext *C, wmOperator *op)
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const short selectmode = select ? SELECT_ADD : SELECT_SUBTRACT;
bool incl_handles = false;
-
+
KeyframeEdit_CircleData data = {0};
rctf rect_fl;
-
+
float x = RNA_int_get(op->ptr, "x");
float y = RNA_int_get(op->ptr, "y");
float radius = RNA_int_get(op->ptr, "radius");
@@ -510,17 +510,17 @@ static int graph_circle_select_exec(bContext *C, wmOperator *op)
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
data.mval[0] = x;
data.mval[1] = y;
data.radius_squared = radius * radius;
data.rectf_view = &rect_fl;
-
+
rect_fl.xmin = x - radius;
rect_fl.xmax = x + radius;
rect_fl.ymin = y - radius;
rect_fl.ymax = y + radius;
-
+
{
SpaceIpo *sipo = (SpaceIpo *)ac.sl;
if (selectmode == SELECT_ADD) {
@@ -531,13 +531,13 @@ static int graph_circle_select_exec(bContext *C, wmOperator *op)
incl_handles = (sipo->flag & SIPO_NOHANDLES) == 0;
}
}
-
+
/* apply borderselect action */
borderselect_graphkeys(&ac, &rect_fl, BEZT_OK_REGION_CIRCLE, selectmode, incl_handles, &data);
-
+
/* send notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -546,13 +546,13 @@ void GRAPH_OT_select_circle(wmOperatorType *ot)
ot->name = "Circle Select";
ot->description = "Select keyframe points using circle selection";
ot->idname = "GRAPH_OT_select_circle";
-
+
ot->invoke = WM_gesture_circle_invoke;
ot->modal = WM_gesture_circle_modal;
ot->exec = graph_circle_select_exec;
ot->poll = graphop_visible_keyframes_poll;
ot->cancel = WM_gesture_circle_cancel;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
@@ -577,7 +577,7 @@ static const EnumPropertyItem prop_column_select_types[] = {
{0, NULL, 0, NULL, NULL}
};
-/* ------------------- */
+/* ------------------- */
/* Selects all visible keyframes between the specified markers */
/* TODO, this is almost an _exact_ duplicate of a function of the same name in action_select.c
@@ -587,27 +587,27 @@ static void markers_selectkeys_between(bAnimContext *ac)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditFunc ok_cb, select_cb;
KeyframeEditData ked = {{NULL}};
float min, max;
-
+
/* get extreme markers */
ED_markers_get_minmax(ac->markers, 1, &min, &max);
min -= 0.5f;
max += 0.5f;
-
+
/* get editing funcs + data */
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
select_cb = ANIM_editkeyframes_select(SELECT_ADD);
ked.f1 = min;
ked.f2 = max;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* select keys in-between */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
@@ -621,7 +621,7 @@ static void markers_selectkeys_between(bAnimContext *ac)
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
}
}
-
+
/* Cleanup */
ANIM_animdata_freelist(&anim_data);
}
@@ -633,56 +633,56 @@ static void columnselect_graph_keys(bAnimContext *ac, short mode)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
Scene *scene = ac->scene;
CfraElem *ce;
KeyframeEditFunc select_cb, ok_cb;
KeyframeEditData ked;
-
+
/* initialize keyframe editing data */
memset(&ked, 0, sizeof(KeyframeEditData));
-
+
/* build list of columns */
switch (mode) {
case GRAPHKEYS_COLUMNSEL_KEYS: /* list of selected keys */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next)
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL);
-
+
ANIM_animdata_freelist(&anim_data);
break;
-
+
case GRAPHKEYS_COLUMNSEL_CFRA: /* current frame */
/* make a single CfraElem for storing this */
ce = MEM_callocN(sizeof(CfraElem), "cfraElem");
BLI_addtail(&ked.list, ce);
-
+
ce->cfra = (float)CFRA;
break;
-
+
case GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */
ED_markers_make_cfra_list(ac->markers, &ked.list, SELECT);
break;
-
+
default: /* invalid option */
return;
}
-
+
/* set up BezTriple edit callbacks */
select_cb = ANIM_editkeyframes_select(SELECT_ADD);
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME);
-
+
/* loop through all of the keys and select additional keyframes
* based on the keys found to be selected above
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
/* loop over cfraelems (stored in the KeyframeEditData->list)
* - we need to do this here, as we can apply fewer NLA-mapping conversions
*/
@@ -694,7 +694,7 @@ static void columnselect_graph_keys(bAnimContext *ac, short mode)
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
}
}
-
+
/* free elements */
BLI_freelistN(&ked.list);
ANIM_animdata_freelist(&anim_data);
@@ -706,39 +706,39 @@ static int graphkeys_columnselect_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* action to take depends on the mode */
mode = RNA_enum_get(op->ptr, "mode");
-
+
if (mode == GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN)
markers_selectkeys_between(&ac);
else
columnselect_graph_keys(&ac, mode);
-
+
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void GRAPH_OT_select_column(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Select All";
ot->idname = "GRAPH_OT_select_column";
ot->description = "Select all keyframes on the specified frame(s)";
-
+
/* api callbacks */
ot->exec = graphkeys_columnselect_exec;
ot->poll = graphop_visible_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
ot->prop = RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", "");
}
@@ -748,38 +748,38 @@ void GRAPH_OT_select_column(wmOperatorType *ot)
static int graphkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditFunc ok_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
KeyframeEditFunc sel_cb = ANIM_editkeyframes_select(SELECT_ADD);
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* loop through all of the keys and select additional keyframes based on these */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
-
+
/* check if anything selected? */
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) {
/* select every keyframe in this curve then */
ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL);
}
}
-
+
/* Cleanup */
ANIM_animdata_freelist(&anim_data);
-
+
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -789,11 +789,11 @@ void GRAPH_OT_select_linked(wmOperatorType *ot)
ot->name = "Select Linked";
ot->idname = "GRAPH_OT_select_linked";
ot->description = "Select keyframes occurring in the same F-Curves as selected ones";
-
+
/* api callbacks */
ot->exec = graphkeys_select_linked_exec;
ot->poll = graphop_visible_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -806,38 +806,38 @@ static void select_moreless_graph_keys(bAnimContext *ac, short mode)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditData ked;
KeyframeEditFunc build_cb;
-
-
+
+
/* init selmap building data */
build_cb = ANIM_editkeyframes_buildselmap(mode);
- memset(&ked, 0, sizeof(KeyframeEditData));
-
+ memset(&ked, 0, sizeof(KeyframeEditData));
+
/* loop through all of the keys and select additional keyframes based on these */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
-
+
/* only continue if F-Curve has keyframes */
if (fcu->bezt == NULL)
continue;
-
+
/* build up map of whether F-Curve's keyframes should be selected or not */
ked.data = MEM_callocN(fcu->totvert, "selmap graphEdit");
ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, build_cb, NULL);
-
+
/* based on this map, adjust the selection status of the keyframes */
ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, bezt_selmap_flush, NULL);
-
+
/* free the selmap used here */
MEM_freeN(ked.data);
ked.data = NULL;
}
-
+
/* Cleanup */
ANIM_animdata_freelist(&anim_data);
}
@@ -847,17 +847,17 @@ static void select_moreless_graph_keys(bAnimContext *ac, short mode)
static int graphkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* perform select changes */
select_moreless_graph_keys(&ac, SELMAP_MORE);
-
+
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -867,11 +867,11 @@ void GRAPH_OT_select_more(wmOperatorType *ot)
ot->name = "Select More";
ot->idname = "GRAPH_OT_select_more";
ot->description = "Select keyframes beside already selected ones";
-
+
/* api callbacks */
ot->exec = graphkeys_select_more_exec;
ot->poll = graphop_visible_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -881,17 +881,17 @@ void GRAPH_OT_select_more(wmOperatorType *ot)
static int graphkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* perform select changes */
select_moreless_graph_keys(&ac, SELMAP_LESS);
-
+
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -901,11 +901,11 @@ void GRAPH_OT_select_less(wmOperatorType *ot)
ot->name = "Select Less";
ot->idname = "GRAPH_OT_select_less";
ot->description = "Deselect keyframes on ends of selection islands";
-
+
/* api callbacks */
ot->exec = graphkeys_select_less_exec;
ot->poll = graphop_visible_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -928,25 +928,25 @@ static void graphkeys_select_leftright(bAnimContext *ac, short leftright, short
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditFunc ok_cb, select_cb;
KeyframeEditData ked = {{NULL}};
Scene *scene = ac->scene;
-
+
/* if select mode is replace, deselect all keyframes (and channels) first */
if (select_mode == SELECT_REPLACE) {
select_mode = SELECT_ADD;
-
+
/* - deselect all other keyframes, so that just the newly selected remain
* - channels aren't deselected, since we don't re-select any as a consequence
*/
deselect_graph_keys(ac, 0, SELECT_SUBTRACT, false);
}
-
+
/* set callbacks and editing data */
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
select_cb = ANIM_editkeyframes_select(select_mode);
-
+
if (leftright == GRAPHKEYS_LRSEL_LEFT) {
ked.f1 = MINAFRAMEF;
ked.f2 = (float)(CFRA + 0.1f);
@@ -955,15 +955,15 @@ static void graphkeys_select_leftright(bAnimContext *ac, short leftright, short
ked.f1 = (float)(CFRA - 0.1f);
ked.f2 = MAXFRAMEF;
}
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* select keys */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
@@ -984,28 +984,28 @@ static int graphkeys_select_leftright_exec(bContext *C, wmOperator *op)
bAnimContext ac;
short leftright = RNA_enum_get(op->ptr, "mode");
short selectmode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* select mode is either replace (deselect all, then add) or add/extend */
if (RNA_boolean_get(op->ptr, "extend"))
selectmode = SELECT_INVERT;
else
selectmode = SELECT_REPLACE;
-
+
/* if "test" mode is set, we don't have any info to set this with */
if (leftright == GRAPHKEYS_LRSEL_TEST)
return OPERATOR_CANCELLED;
-
+
/* do the selecting now */
graphkeys_select_leftright(&ac, leftright, selectmode);
-
+
/* set notifier that keyframe selection (and channels too) have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1013,11 +1013,11 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, const
{
bAnimContext ac;
short leftright = RNA_enum_get(op->ptr, "mode");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* handle mode-based testing */
if (leftright == GRAPHKEYS_LRSEL_TEST) {
Scene *scene = ac.scene;
@@ -1032,7 +1032,7 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, const
else
RNA_enum_set(op->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT);
}
-
+
/* perform selection */
return graphkeys_select_leftright_exec(C, op);
}
@@ -1040,24 +1040,24 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, const
void GRAPH_OT_select_leftright(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Select Left/Right";
ot->idname = "GRAPH_OT_select_leftright";
ot->description = "Select keyframes to the left or the right of the current frame";
-
+
/* api callbacks */
ot->invoke = graphkeys_select_leftright_invoke;
ot->exec = graphkeys_select_leftright_exec;
ot->poll = graphop_visible_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "mode", prop_graphkeys_leftright_select_types, GRAPHKEYS_LRSEL_TEST, "Mode", "");
RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
-
+
prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", "");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
@@ -1068,25 +1068,25 @@ void GRAPH_OT_select_leftright(wmOperatorType *ot)
* - 2) all keyframes on the same side of current frame indicator as mouse - ALT modifier
* - 3) column select all keyframes in frame under mouse - CTRL modifier
*
- * In addition to these basic options, the SHIFT modifier can be used to toggle the
+ * In addition to these basic options, the SHIFT modifier can be used to toggle the
* selection mode between replacing the selection (without) and inverting the selection (with).
*/
/* temp info for caching handle vertices close */
typedef struct tNearestVertInfo {
struct tNearestVertInfo *next, *prev;
-
+
FCurve *fcu; /* F-Curve that keyframe comes from */
-
+
BezTriple *bezt; /* keyframe to consider */
FPoint *fpt; /* sample point to consider */
-
+
short hpoint; /* the handle index that we hit (eHandleIndex) */
short sel; /* whether the handle is selected or not */
int dist; /* distance from mouse to vert */
-
+
eAnim_ChannelType ctype; /* type of animation channel this FCurve comes from */
-
+
float frame; /* frame that point was on when it matched (global time) */
} tNearestVertInfo;
@@ -1095,7 +1095,7 @@ typedef enum eGraphVertIndex {
NEAREST_HANDLE_LEFT = -1,
NEAREST_HANDLE_KEY,
NEAREST_HANDLE_RIGHT
-} eGraphVertIndex;
+} eGraphVertIndex;
/* Tolerance for absolute radius (in pixels) of the vert from the cursor to use */
// TODO: perhaps this should depend a bit on the size that the user set the vertices to be?
@@ -1121,9 +1121,9 @@ static void nearest_fcurve_vert_store(
/* Keyframes or Samples? */
if (bezt) {
int screen_co[2], dist;
-
- /* convert from data-space to screen coordinates
- * NOTE: hpoint+1 gives us 0,1,2 respectively for each handle,
+
+ /* convert from data-space to screen coordinates
+ * NOTE: hpoint+1 gives us 0,1,2 respectively for each handle,
* needed to access the relevant vertex coordinates in the 3x3
* 'vec' matrix
*/
@@ -1135,7 +1135,7 @@ static void nearest_fcurve_vert_store(
{
tNearestVertInfo *nvi = (tNearestVertInfo *)matches->last;
bool replace = false;
-
+
/* if there is already a point for the F-Curve, check if this point is closer than that was */
if ((nvi) && (nvi->fcu == fcu)) {
/* replace if we are closer, or if equal and that one wasn't selected but we are... */
@@ -1145,19 +1145,19 @@ static void nearest_fcurve_vert_store(
/* add new if not replacing... */
if (replace == 0)
nvi = MEM_callocN(sizeof(tNearestVertInfo), "Nearest Graph Vert Info - Bezt");
-
+
/* store values */
nvi->fcu = fcu;
nvi->ctype = ctype;
-
+
nvi->bezt = bezt;
nvi->hpoint = hpoint;
nvi->dist = dist;
-
+
nvi->frame = bezt->vec[1][0]; /* currently in global time... */
-
+
nvi->sel = BEZT_ISSEL_ANY(bezt); // XXX... should this use the individual verts instead?
-
+
/* add to list of matches if appropriate... */
if (replace == 0)
BLI_addtail(matches, nvi);
@@ -1174,12 +1174,12 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
View2D *v2d = &ac->ar->v2d;
short mapping_flag = 0;
-
- /* get curves to search through
+
+ /* get curves to search through
* - if the option to only show keyframes that belong to selected F-Curves is enabled,
* include the 'only selected' flag...
*/
@@ -1188,32 +1188,32 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
filter |= ANIMFILTER_SEL;
mapping_flag |= ANIM_get_normalization_flags(ac);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
float offset;
float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset);
-
+
/* apply NLA mapping to all the keyframes */
if (adt)
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
-
+
if (fcu->bezt) {
BezTriple *bezt1 = fcu->bezt, *prevbezt = NULL;
int i;
-
+
for (i = 0; i < fcu->totvert; i++, prevbezt = bezt1, bezt1++) {
/* keyframe */
nearest_fcurve_vert_store(matches, v2d, fcu, ale->type, bezt1, NULL, NEAREST_HANDLE_KEY, mval, unit_scale, offset);
-
+
/* handles - only do them if they're visible */
if (fcurve_handle_sel_check(sipo, bezt1) && (fcu->totvert > 1)) {
/* first handle only visible if previous segment had handles */
if ((!prevbezt && (bezt1->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) {
nearest_fcurve_vert_store(matches, v2d, fcu, ale->type, bezt1, NULL, NEAREST_HANDLE_LEFT, mval, unit_scale, offset);
}
-
+
/* second handle only visible if this segment is bezier */
if (bezt1->ipo == BEZT_IPO_BEZ) {
nearest_fcurve_vert_store(matches, v2d, fcu, ale->type, bezt1, NULL, NEAREST_HANDLE_RIGHT, mval, unit_scale, offset);
@@ -1223,14 +1223,14 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
}
else if (fcu->fpt) {
// TODO; do this for samples too
-
+
}
-
+
/* un-apply NLA mapping from all the keyframes */
if (adt)
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
-
+
/* free channels */
ANIM_animdata_freelist(&anim_data);
}
@@ -1240,22 +1240,22 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
{
tNearestVertInfo *nvi = NULL;
short found = 0;
-
+
/* abort if list is empty */
if (BLI_listbase_is_empty(matches))
return NULL;
-
+
/* if list only has 1 item, remove it from the list and return */
if (BLI_listbase_is_single(matches)) {
/* need to remove from the list, otherwise it gets freed and then we can't return it */
return BLI_pophead(matches);
}
-
+
/* try to find the first selected F-Curve vert, then take the one after it */
for (nvi = matches->first; nvi; nvi = nvi->next) {
/* which mode of search are we in: find first selected, or find vert? */
if (found) {
- /* just take this vert now that we've found the selected one
+ /* just take this vert now that we've found the selected one
* - we'll need to remove this from the list so that it can be returned to the original caller
*/
BLI_remlink(matches, nvi);
@@ -1267,29 +1267,29 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
found = 1;
}
}
-
+
/* if we're still here, this means that we failed to find anything appropriate in the first pass,
* so just take the first item now...
*/
return BLI_pophead(matches);
}
-/* Find the nearest vertices (either a handle or the keyframe) that are nearest to the mouse cursor (in area coordinates)
- * NOTE: the match info found must still be freed
+/* Find the nearest vertices (either a handle or the keyframe) that are nearest to the mouse cursor (in area coordinates)
+ * NOTE: the match info found must still be freed
*/
static tNearestVertInfo *find_nearest_fcurve_vert(bAnimContext *ac, const int mval[2])
{
ListBase matches = {NULL, NULL};
tNearestVertInfo *nvi;
-
+
/* step 1: get the nearest verts */
get_nearest_fcurve_verts_list(ac, mval, &matches);
-
+
/* step 2: find the best vert */
nvi = get_best_nearest_fcurve_vert(&matches);
-
+
BLI_freelistN(&matches);
-
+
/* return the best vert found */
return nvi;
}
@@ -1302,30 +1302,30 @@ static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_m
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
tNearestVertInfo *nvi;
BezTriple *bezt = NULL;
-
+
/* find the beztriple that we're selecting, and the handle that was clicked on */
nvi = find_nearest_fcurve_vert(ac, mval);
-
+
/* check if anything to select */
if (nvi == NULL)
return;
-
+
/* deselect all other curves? */
if (select_mode == SELECT_REPLACE) {
/* reset selection mode */
select_mode = SELECT_ADD;
-
+
/* deselect all other keyframes (+ F-Curves too) */
deselect_graph_keys(ac, 0, SELECT_SUBTRACT, true);
-
- /* deselect other channels too, but only only do this if
- * selection of channel when the visibility of keyframes
- * doesn't depend on this
+
+ /* deselect other channels too, but only only do this if
+ * selection of channel when the visibility of keyframes
+ * doesn't depend on this
*/
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0)
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
}
-
+
/* if points can be selected on this F-Curve */
// TODO: what about those with no keyframes?
if ((curves_only == 0) && ((nvi->fcu->flag & FCURVE_PROTECTED) == 0)) {
@@ -1343,7 +1343,7 @@ static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_m
BEZT_SEL_ALL(bezt);
}
}
-
+
/* handles - toggle selection of relevant handle */
else if (nvi->hpoint == NEAREST_HANDLE_LEFT) {
/* toggle selection */
@@ -1360,9 +1360,9 @@ static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_m
BEZT_SEL_ALL(bezt);
}
/* otherwise, select the handle that applied */
- else if (nvi->hpoint == NEAREST_HANDLE_LEFT)
+ else if (nvi->hpoint == NEAREST_HANDLE_LEFT)
bezt->f1 |= SELECT;
- else
+ else
bezt->f3 |= SELECT;
}
}
@@ -1373,22 +1373,22 @@ static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_m
else {
KeyframeEditFunc select_cb;
KeyframeEditData ked;
-
+
/* initialize keyframe editing data */
memset(&ked, 0, sizeof(KeyframeEditData));
-
+
/* set up BezTriple edit callbacks */
select_cb = ANIM_editkeyframes_select(select_mode);
-
+
/* select all keyframes */
ANIM_fcurve_keyframes_loop(&ked, nvi->fcu, NULL, select_cb, NULL);
}
-
+
/* only change selection of channel when the visibility of keyframes doesn't depend on this */
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
/* select or deselect curve? */
if (bezt) {
- /* take selection status from item that got hit, to prevent flip/flop on channel
+ /* take selection status from item that got hit, to prevent flip/flop on channel
* selection status when shift-selecting (i.e. "SELECT_INVERT") points
*/
if (BEZT_ISSEL_ANY(bezt))
@@ -1425,66 +1425,66 @@ static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditFunc select_cb, ok_cb;
KeyframeEditData ked;
tNearestVertInfo *nvi;
float selx = (float)ac->scene->r.cfra;
-
+
/* find the beztriple that we're selecting, and the handle that was clicked on */
nvi = find_nearest_fcurve_vert(ac, mval);
-
+
/* check if anything to select */
if (nvi == NULL)
return;
-
+
/* get frame number on which elements should be selected */
// TODO: should we restrict to integer frames only?
selx = nvi->frame;
-
+
/* if select mode is replace, deselect all keyframes first */
if (select_mode == SELECT_REPLACE) {
/* reset selection mode to add to selection */
select_mode = SELECT_ADD;
-
+
/* - deselect all other keyframes, so that just the newly selected remain
* - channels aren't deselected, since we don't re-select any as a consequence
*/
deselect_graph_keys(ac, 0, SELECT_SUBTRACT, false);
}
-
+
/* initialize keyframe editing data */
memset(&ked, 0, sizeof(KeyframeEditData));
-
+
/* set up BezTriple edit callbacks */
select_cb = ANIM_editkeyframes_select(select_mode);
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME);
-
+
/* loop through all of the keys and select additional keyframes
* based on the keys found to be selected above
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
/* set frame for validation callback to refer to */
if (adt)
ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP);
else
ked.f1 = selx;
-
+
/* select elements with frame number matching cfra */
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
}
-
+
/* free elements */
MEM_freeN(nvi);
BLI_freelistN(&ked.list);
ANIM_animdata_freelist(&anim_data);
}
-
+
/* ------------------- */
/* handle clicking */
@@ -1502,7 +1502,7 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEve
selectmode = SELECT_INVERT;
else
selectmode = SELECT_REPLACE;
-
+
/* figure out action to take */
if (RNA_boolean_get(op->ptr, "column")) {
/* select all keyframes in the same frame as the one that was under the mouse */
@@ -1516,41 +1516,41 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEve
/* select keyframe under mouse */
mouse_graph_keys(&ac, event->mval, selectmode, 0);
}
-
+
/* set notifier that keyframe selection (and also channel selection in some cases) has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
-
+
/* for tweak grab to work */
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
}
-
+
void GRAPH_OT_clickselect(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Mouse Select Keys";
ot->idname = "GRAPH_OT_clickselect";
ot->description = "Select keyframes by clicking on them";
-
+
/* callbacks */
ot->invoke = graphkeys_clickselect_invoke;
ot->poll = graphop_visible_keyframes_poll;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
-
+
/* properties */
prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select",
"Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-
- prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select",
+
+ prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select",
"Select all keyframes that occur on the same frame as the one under the mouse"); // ALTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-
- prop = RNA_def_boolean(ot->srna, "curves", 0, "Only Curves",
+
+ prop = RNA_def_boolean(ot->srna, "curves", 0, "Only Curves",
"Select all the keyframes in the curve"); // CTRLKEY + ALTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c
index 907f346c931..f55a5511e2d 100644
--- a/source/blender/editors/space_graph/graph_utils.c
+++ b/source/blender/editors/space_graph/graph_utils.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation, Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
@@ -57,8 +57,8 @@
/* ************************************************************** */
/* Active F-Curve */
-/* Find 'active' F-Curve. It must be editable, since that's the purpose of these buttons (subject to change).
- * We return the 'wrapper' since it contains valuable context info (about hierarchy), which will need to be freed
+/* Find 'active' F-Curve. It must be editable, since that's the purpose of these buttons (subject to change).
+ * We return the 'wrapper' since it contains valuable context info (about hierarchy), which will need to be freed
* when the caller is done with it.
*
* NOTE: curve-visible flag isn't included, otherwise selecting a curve via list to edit is too cumbersome
@@ -68,20 +68,20 @@ bAnimListElem *get_active_fcurve_channel(bAnimContext *ac)
ListBase anim_data = {NULL, NULL};
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ACTIVE);
size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* We take the first F-Curve only, since some other ones may have had 'active' flag set
* if they were from linked data.
*/
if (items) {
bAnimListElem *ale = (bAnimListElem *)anim_data.first;
-
+
/* remove first item from list, then free the rest of the list and return the stored one */
BLI_remlink(&anim_data, ale);
ANIM_animdata_freelist(&anim_data);
-
+
return ale;
}
-
+
/* no active F-Curve */
return NULL;
}
@@ -99,30 +99,30 @@ int graphop_visible_keyframes_poll(bContext *C)
size_t items;
int filter;
short found = 0;
-
+
/* firstly, check if in Graph Editor */
// TODO: also check for region?
if ((sa == NULL) || (sa->spacetype != SPACE_IPO))
return 0;
-
+
/* try to init Anim-Context stuff ourselves and check */
if (ANIM_animdata_get_context(C, &ac) == 0)
return 0;
-
+
/* loop over the visible (selection doesn't matter) F-Curves, and see if they're suitable
* stopping on the first successful match
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE);
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- if (items == 0)
+ if (items == 0)
return 0;
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
-
+
/* visible curves for selection must fulfill the following criteria:
* - it has bezier keyframes
- * - F-Curve modifiers do not interfere with the result too much
+ * - F-Curve modifiers do not interfere with the result too much
* (i.e. the modifier-control drawing check returns false)
*/
if (fcu->bezt == NULL)
@@ -132,7 +132,7 @@ int graphop_visible_keyframes_poll(bContext *C)
break;
}
}
-
+
/* cleanup and return findings */
ANIM_animdata_freelist(&anim_data);
return found;
@@ -148,27 +148,27 @@ int graphop_editable_keyframes_poll(bContext *C)
size_t items;
int filter;
short found = 0;
-
+
/* firstly, check if in Graph Editor */
// TODO: also check for region?
if ((sa == NULL) || (sa->spacetype != SPACE_IPO))
return 0;
-
+
/* try to init Anim-Context stuff ourselves and check */
if (ANIM_animdata_get_context(C, &ac) == 0)
return 0;
-
+
/* loop over the editable F-Curves, and see if they're suitable
* stopping on the first successful match
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- if (items == 0)
+ if (items == 0)
return 0;
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
-
+
/* editable curves must fulfill the following criteria:
* - it has bezier keyframes
* - it must not be protected from editing (this is already checked for with the edit flag
@@ -182,7 +182,7 @@ int graphop_editable_keyframes_poll(bContext *C)
break;
}
}
-
+
/* cleanup and return findings */
ANIM_animdata_freelist(&anim_data);
return found;
@@ -195,21 +195,21 @@ int graphop_active_fcurve_poll(bContext *C)
bAnimListElem *ale;
ScrArea *sa = CTX_wm_area(C);
bool has_fcurve = 0;
-
+
/* firstly, check if in Graph Editor */
// TODO: also check for region?
if ((sa == NULL) || (sa->spacetype != SPACE_IPO))
return 0;
-
+
/* try to init Anim-Context stuff ourselves and check */
if (ANIM_animdata_get_context(C, &ac) == 0)
return 0;
-
+
/* try to get the Active F-Curve */
ale = get_active_fcurve_channel(&ac);
if (ale == NULL)
return 0;
-
+
/* do we have a suitable F-Curves?
* - For most cases, NLA Control Curves are sufficiently similar to NLA curves to serve this role too.
* Under the hood, they are F-Curves too. The only problems which will arise here are if these need to be
@@ -220,10 +220,10 @@ int graphop_active_fcurve_poll(bContext *C)
FCurve *fcu = (FCurve *)ale->data;
has_fcurve = (fcu->flag & FCURVE_VISIBLE) != 0;
}
-
+
/* free temp data... */
MEM_freeN(ale);
-
+
/* return success */
return has_fcurve;
}
@@ -236,24 +236,24 @@ int graphop_selected_fcurve_poll(bContext *C)
ScrArea *sa = CTX_wm_area(C);
size_t items;
int filter;
-
+
/* firstly, check if in Graph Editor */
// TODO: also check for region?
if ((sa == NULL) || (sa->spacetype != SPACE_IPO))
return 0;
-
+
/* try to init Anim-Context stuff ourselves and check */
if (ANIM_animdata_get_context(C, &ac) == 0)
return 0;
-
- /* get the editable + selected F-Curves, and as long as we got some, we can return
+
+ /* get the editable + selected F-Curves, and as long as we got some, we can return
* NOTE: curve-visible flag isn't included, otherwise selecting a curve via list to edit is too cumbersome
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT);
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- if (items == 0)
+ if (items == 0)
return 0;
-
+
/* cleanup and return findings */
ANIM_animdata_freelist(&anim_data);
return 1;
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 6ecb454096d..56236ea8f47 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -71,7 +71,7 @@
ARegion *graph_has_buttons_region(ScrArea *sa)
{
ARegion *ar, *arnew;
-
+
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
if (ar) return ar;
@@ -80,15 +80,15 @@ ARegion *graph_has_buttons_region(ScrArea *sa)
/* is error! */
if (ar == NULL) return NULL;
-
+
arnew = MEM_callocN(sizeof(ARegion), "buttons for graph");
-
+
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
arnew->regiontype = RGN_TYPE_UI;
arnew->alignment = RGN_ALIGN_RIGHT;
-
+
arnew->flag = RGN_FLAG_HIDDEN;
-
+
return arnew;
}
@@ -99,82 +99,82 @@ static SpaceLink *graph_new(const ScrArea *UNUSED(sa), const Scene *scene)
{
ARegion *ar;
SpaceIpo *sipo;
-
+
/* Graph Editor - general stuff */
sipo = MEM_callocN(sizeof(SpaceIpo), "init graphedit");
sipo->spacetype = SPACE_IPO;
-
+
sipo->autosnap = SACTSNAP_FRAME;
-
+
/* allocate DopeSheet data for Graph Editor */
sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
sipo->ads->source = (ID *)scene;
-
+
/* settings for making it easier by default to just see what you're interested in tweaking */
sipo->ads->filterflag |= ADS_FILTER_ONLYSEL;
sipo->flag |= SIPO_SELVHANDLESONLY;
-
+
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for graphedit");
-
+
BLI_addtail(&sipo->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_TOP;
-
+
/* channels */
ar = MEM_callocN(sizeof(ARegion), "channels region for graphedit");
-
+
BLI_addtail(&sipo->regionbase, ar);
ar->regiontype = RGN_TYPE_CHANNELS;
ar->alignment = RGN_ALIGN_LEFT;
-
+
ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
-
+
/* ui buttons */
ar = MEM_callocN(sizeof(ARegion), "buttons region for graphedit");
-
+
BLI_addtail(&sipo->regionbase, ar);
ar->regiontype = RGN_TYPE_UI;
ar->alignment = RGN_ALIGN_RIGHT;
ar->flag = RGN_FLAG_HIDDEN;
-
+
/* main region */
ar = MEM_callocN(sizeof(ARegion), "main region for graphedit");
-
+
BLI_addtail(&sipo->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
-
+
ar->v2d.tot.xmin = 0.0f;
ar->v2d.tot.ymin = (float)scene->r.sfra - 10.0f;
ar->v2d.tot.xmax = (float)scene->r.efra;
ar->v2d.tot.ymax = 10.0f;
-
+
ar->v2d.cur = ar->v2d.tot;
-
+
ar->v2d.min[0] = FLT_MIN;
ar->v2d.min[1] = FLT_MIN;
ar->v2d.max[0] = MAXFRAMEF;
ar->v2d.max[1] = FLT_MAX;
-
+
ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL);
-
+
ar->v2d.keeptot = 0;
-
+
return (SpaceLink *)sipo;
}
/* not spacelink itself */
static void graph_free(SpaceLink *sl)
-{
+{
SpaceIpo *si = (SpaceIpo *)sl;
-
+
if (si->ads) {
BLI_freelistN(&si->ads->chanbase);
MEM_freeN(si->ads);
}
-
+
if (si->ghostCurves.first)
free_fcurves(&si->ghostCurves);
}
@@ -184,13 +184,13 @@ static void graph_free(SpaceLink *sl)
static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
{
SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first;
-
+
/* init dopesheet data if non-existent (i.e. for old files) */
if (sipo->ads == NULL) {
sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
sipo->ads->source = (ID *)(G.main->scene.first); // FIXME: this is a really nasty hack here for now...
}
-
+
/* force immediate init of any invalid F-Curve colors */
/* XXX: but, don't do SIPO_TEMP_NEEDCHANSYNC (i.e. channel select state sync)
* as this is run on each region resize; setting this here will cause selection
@@ -202,11 +202,11 @@ static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
static SpaceLink *graph_duplicate(SpaceLink *sl)
{
SpaceIpo *sipon = MEM_dupallocN(sl);
-
+
/* clear or remove stuff from old */
BLI_duplicatelist(&sipon->ghostCurves, &((SpaceIpo *)sl)->ghostCurves);
sipon->ads = MEM_dupallocN(sipon->ads);
-
+
return (SpaceLink *)sipon;
}
@@ -214,9 +214,9 @@ static SpaceLink *graph_duplicate(SpaceLink *sl)
static void graph_main_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
-
+
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
-
+
/* own keymap */
keymap = WM_keymap_find(wm->defaultconf, "Graph Editor", SPACE_IPO, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
@@ -235,42 +235,42 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
View2DScrollers *scrollers;
float col[3];
short unitx = 0, unity = V2D_UNIT_VALUES, cfra_flag = 0;
-
+
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
glClearColor(col[0], col[1], col[2], 0.0);
glClear(GL_COLOR_BUFFER_BIT);
-
+
UI_view2d_view_ortho(v2d);
-
+
/* grid */
unitx = ((sipo->mode == SIPO_MODE_ANIMATION) && (sipo->flag & SIPO_DRAWTIME)) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMESCALE;
grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy);
UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
-
+
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
-
+
/* start and end frame (in F-Curve mode only) */
if (sipo->mode != SIPO_MODE_DRIVERS) {
ANIM_draw_framerange(scene, v2d);
}
-
+
/* draw data */
if (ANIM_animdata_get_context(C, &ac)) {
/* draw ghost curves */
graph_draw_ghost_curves(&ac, sipo, ar);
-
+
/* draw curves twice - unselected, then selected, so that the are fewer occlusion problems */
graph_draw_curves(&ac, sipo, ar, grid, 0);
graph_draw_curves(&ac, sipo, ar, grid, 1);
-
+
/* XXX the slow way to set tot rect... but for nice sliders needed (ton) */
get_graph_keyframe_extents(&ac, &v2d->tot.xmin, &v2d->tot.xmax, &v2d->tot.ymin, &v2d->tot.ymax, false, true);
/* extra offset so that these items are visible */
v2d->tot.xmin -= 10.0f;
v2d->tot.xmax += 10.0f;
}
-
+
/* only free grid after drawing data, as we need to use it to determine sampling rate */
UI_view2d_grid_free(grid);
@@ -322,28 +322,28 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
if (sipo->flag & SIPO_DRAWTIME) cfra_flag |= DRAWCFRA_UNIT_SECONDS;
ANIM_draw_cfra(C, v2d, cfra_flag);
}
-
+
/* markers */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
ED_markers_draw(C, DRAW_MARKERS_MARGIN);
-
+
/* preview range */
UI_view2d_view_ortho(v2d);
ANIM_draw_previewrange(C, v2d, 0);
-
+
/* callback */
UI_view2d_view_ortho(v2d);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
/* reset view matrix */
UI_view2d_view_restore(C);
-
+
/* scrollers */
// FIXME: args for scrollers depend on the type of data being shown...
scrollers = UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP);
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
-
+
/* draw current frame number-indicator on top of scrollers */
if ((sipo->mode != SIPO_MODE_DRIVERS) && ((sipo->flag & SIPO_NODRAWCFRANUM) == 0)) {
UI_view2d_view_orthoSpecial(ar, v2d, 1);
@@ -354,15 +354,15 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
static void graph_channel_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
-
+
/* make sure we keep the hide flags */
ar->v2d.scroll |= V2D_SCROLL_RIGHT;
ar->v2d.scroll &= ~(V2D_SCROLL_LEFT | V2D_SCROLL_TOP | V2D_SCROLL_BOTTOM); /* prevent any noise of past */
ar->v2d.scroll |= V2D_SCROLL_HORIZONTAL_HIDE;
ar->v2d.scroll |= V2D_SCROLL_VERTICAL_HIDE;
-
+
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
-
+
/* own keymap */
keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
@@ -376,22 +376,22 @@ static void graph_channel_region_draw(const bContext *C, ARegion *ar)
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
float col[3];
-
+
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
glClearColor(col[0], col[1], col[2], 0.0);
glClear(GL_COLOR_BUFFER_BIT);
-
+
UI_view2d_view_ortho(v2d);
-
+
/* draw channels */
if (ANIM_animdata_get_context(C, &ac)) {
graph_draw_channel_names((bContext *)C, &ac, ar);
}
-
+
/* reset view matrix */
UI_view2d_view_restore(C);
-
+
/* scrollers */
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
UI_view2d_scrollers_draw(C, v2d, scrollers);
@@ -413,7 +413,7 @@ static void graph_header_region_draw(const bContext *C, ARegion *ar)
static void graph_buttons_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
-
+
ED_region_panels_init(wm, ar);
keymap = WM_keymap_find(wm->defaultconf, "Graph Editor Generic", SPACE_IPO, 0);
@@ -483,7 +483,7 @@ static void graph_region_listener(
if (wmn->data == ND_KEYS)
ED_region_tag_redraw(ar);
break;
-
+
}
}
@@ -525,7 +525,7 @@ static void graph_region_message_subscribe(
WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
}
}
-
+
/* All dopesheet filter settings, etc. affect the drawing of this editor,
* also same applies for all animation-related datatypes that may appear here,
* so just whitelist the entire structs for updates
@@ -534,12 +534,12 @@ static void graph_region_message_subscribe(
wmMsgParams_RNA msg_key_params = {{{0}}};
StructRNA *type_array[] = {
&RNA_DopeSheet, /* dopesheet filters */
-
+
&RNA_ActionGroup, /* channel groups */
&RNA_FCurve, /* F-Curve */
&RNA_Keyframe,
&RNA_FCurveSample,
-
+
&RNA_FModifier, /* F-Modifiers (XXX: Why can't we just do all subclasses too?) */
&RNA_FModifierCycles,
&RNA_FModifierEnvelope,
@@ -568,7 +568,7 @@ static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Sc
WorkSpace *UNUSED(workspace))
{
SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first;
-
+
/* context changes */
switch (wmn->category) {
case NC_ANIMATION:
@@ -585,7 +585,7 @@ static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Sc
sipo->flag |= SIPO_TEMP_NEEDCHANSYNC;
ED_area_tag_refresh(sa);
break;
-
+
default: /* just redrawing the view will do */
ED_area_tag_redraw(sa);
break;
@@ -600,7 +600,7 @@ static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Sc
break;
case ND_TRANSFORM:
break; /*do nothing*/
-
+
default: /* just redrawing the view will do */
ED_area_tag_redraw(sa);
break;
@@ -623,7 +623,7 @@ static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Sc
ED_area_tag_refresh(sa);
}
break;
-
+
// XXX: restore the case below if not enough updates occur...
//default:
// if (wmn->data == ND_KEYS)
@@ -635,29 +635,29 @@ static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Sc
static void graph_refresh_fcurve_colors(const bContext *C)
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
size_t items;
int filter;
int i;
-
+
if (ANIM_animdata_get_context(C, &ac) == false)
return;
-
+
UI_SetTheme(SPACE_IPO, RGN_TYPE_WINDOW);
-
+
/* build list of F-Curves which will be visible as channels in channel-region
* - we don't include ANIMFILTER_CURVEVISIBLE filter, as that will result in a
* mismatch between channel-colors and the drawn curves
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS);
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* loop over F-Curves, assigning colors */
for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) {
FCurve *fcu = (FCurve *)ale->data;
-
+
/* set color of curve here */
switch (fcu->color_mode) {
case FCURVE_COLOR_CUSTOM:
@@ -669,11 +669,11 @@ static void graph_refresh_fcurve_colors(const bContext *C)
}
case FCURVE_COLOR_AUTO_RGB:
{
- /* F-Curve's array index is automatically mapped to RGB values. This works best of 3-value vectors.
+ /* F-Curve's array index is automatically mapped to RGB values. This works best of 3-value vectors.
* TODO: find a way to module the hue so that not all curves have same color...
*/
float *col = fcu->color;
-
+
switch (fcu->array_index) {
case 0:
UI_GetThemeColor3fv(TH_AXIS_X, col);
@@ -695,7 +695,7 @@ static void graph_refresh_fcurve_colors(const bContext *C)
{
/* Like FCURVE_COLOR_AUTO_RGB, except this is for quaternions... */
float *col = fcu->color;
-
+
switch (fcu->array_index) {
case 1:
UI_GetThemeColor3fv(TH_AXIS_X, col);
@@ -706,29 +706,29 @@ static void graph_refresh_fcurve_colors(const bContext *C)
case 3:
UI_GetThemeColor3fv(TH_AXIS_Z, col);
break;
-
+
case 0:
{
/* Special Case: "W" channel should be yellowish, so blend X and Y channel colors... */
float c1[3], c2[3];
float h1[3], h2[3];
float hresult[3];
-
+
/* - get colors (rgb) */
UI_GetThemeColor3fv(TH_AXIS_X, c1);
UI_GetThemeColor3fv(TH_AXIS_Y, c2);
-
+
/* - perform blending in HSV space (to keep brightness similar) */
rgb_to_hsv_v(c1, h1);
rgb_to_hsv_v(c2, h2);
-
+
interp_v3_v3v3(hresult, h1, h2, 0.5f);
-
+
/* - convert back to RGB for display */
hsv_to_rgb_v(hresult, col);
break;
}
-
+
default:
/* 'unknown' color - bluish so as to not conflict with handles */
col[0] = 0.3f; col[1] = 0.8f; col[2] = 1.0f;
@@ -747,7 +747,7 @@ static void graph_refresh_fcurve_colors(const bContext *C)
}
}
}
-
+
/* free temp list */
ANIM_animdata_freelist(&anim_data);
}
@@ -755,24 +755,24 @@ static void graph_refresh_fcurve_colors(const bContext *C)
static void graph_refresh(const bContext *C, ScrArea *sa)
{
SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first;
-
+
/* updates to data needed depends on Graph Editor mode... */
switch (sipo->mode) {
case SIPO_MODE_ANIMATION: /* all animation */
{
break;
}
-
+
case SIPO_MODE_DRIVERS: /* drivers only */
{
break;
}
}
-
+
/* region updates? */
// XXX re-sizing y-extents of tot should go here?
-
- /* update the state of the animchannels in response to changes from the data they represent
+
+ /* update the state of the animchannels in response to changes from the data they represent
* NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled
*/
if (sipo->flag & SIPO_TEMP_NEEDCHANSYNC) {
@@ -780,7 +780,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
sipo->flag &= ~SIPO_TEMP_NEEDCHANSYNC;
ED_area_tag_redraw(sa);
}
-
+
/* init/adjust F-Curve colors */
graph_refresh_fcurve_colors(C);
}
@@ -788,7 +788,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
static void graph_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
{
SpaceIpo *sgraph = (SpaceIpo *)slink;
-
+
if (sgraph->ads) {
if ((ID *)sgraph->ads->filter_grp == old_id) {
sgraph->ads->filter_grp = (Collection *)new_id;
@@ -804,10 +804,10 @@ void ED_spacetype_ipo(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype ipo");
ARegionType *art;
-
+
st->spaceid = SPACE_IPO;
strncpy(st->name, "Graph", BKE_ST_MAXNAME);
-
+
st->new = graph_new;
st->free = graph_free;
st->init = graph_init;
@@ -828,7 +828,7 @@ void ED_spacetype_ipo(void)
art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
art->regionid = RGN_TYPE_HEADER;
@@ -837,9 +837,9 @@ void ED_spacetype_ipo(void)
art->listener = graph_region_listener;
art->init = graph_header_region_init;
art->draw = graph_header_region_draw;
-
+
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: channels */
art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
art->regionid = RGN_TYPE_CHANNELS;
@@ -849,9 +849,9 @@ void ED_spacetype_ipo(void)
art->message_subscribe = graph_region_message_subscribe;
art->init = graph_channel_region_init;
art->draw = graph_channel_region_draw;
-
+
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: UI buttons */
art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
art->regionid = RGN_TYPE_UI;
@@ -860,11 +860,11 @@ void ED_spacetype_ipo(void)
art->listener = graph_region_listener;
art->init = graph_buttons_region_init;
art->draw = graph_buttons_region_draw;
-
+
BLI_addhead(&st->regiontypes, art);
graph_buttons_register(art);
-
+
BKE_spacetype_register(st);
}
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index c105f40f1d6..8b8aabb2ce0 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -134,7 +134,7 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf,
struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree)
{
bNode *node;
-
+
if (ntree)
for (node = ntree->nodes.first; node; node = node->next)
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
@@ -147,7 +147,7 @@ struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree)
/* ************ panel stuff ************* */
#if 0
-/* 0: disable preview
+/* 0: disable preview
* otherwise refresh preview
*
* XXX if you put this back, also check XXX in image_main_region_draw() */
@@ -155,7 +155,7 @@ struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree)
void image_preview_event(int event)
{
int exec = 0;
-
+
if (event == 0) {
G.scene->r.scemode &= ~R_COMP_CROP;
exec = 1;
@@ -168,27 +168,27 @@ void image_preview_event(int event)
else
G.scene->r.scemode &= ~R_COMP_CROP;
}
-
+
if (exec && G.scene->nodetree) {
Scene *scene = G.scene;
/* should work when no node editor in screen..., so we execute right away */
-
+
ntreeCompositTagGenerators(G.scene->nodetree);
G.is_break = false;
G.scene->nodetree->timecursor = set_timecursor;
G.scene->nodetree->test_break = BKE_blender_test_break;
-
+
BIF_store_spare();
-
+
ntreeCompositExecTree(scene->nodetree, &scene->r, 1, &scene->view_settings, &scene->display_settings); /* 1 is do_previews */
-
+
G.scene->nodetree->timecursor = NULL;
G.scene->nodetree->test_break = NULL;
-
+
scrarea_do_windraw(curarea);
waitcursor(0);
-
+
WM_event_add_notifier(C, NC_IMAGE, ima_v);
}
}
@@ -203,20 +203,20 @@ static void preview_cb(ScrArea *sa, struct uiBlock *block)
int winx = (G.scene->r.size * G.scene->r.xsch) / 100;
int winy = (G.scene->r.size * G.scene->r.ysch) / 100;
int mval[2];
-
+
if (G.scene->r.mode & R_BORDER) {
winx *= BLI_rcti_size_x(&G.scene->r.border);
winy *= BLI_rctf_size_y(&G.scene->r.border);
}
-
+
/* while dragging we need to update the rects, otherwise it doesn't end with correct one */
BLI_rctf_init(&dispf, 15.0f, BLI_rcti_size_x(&block->rect) - 15.0f, 15.0f, (BLI_rctf_size_y(&block->rect)) - 15.0f);
ui_graphics_to_window_rct(sa->win, &dispf, disprect);
-
+
/* correction for gla draw */
BLI_rcti_translate(disprect, -curarea->winrct.xmin, -curarea->winrct.ymin);
-
+
calc_image_view(sima, 'p');
// printf("winrct %d %d %d %d\n", disprect->xmin, disprect->ymin, disprect->xmax, disprect->ymax);
/* map to image space coordinates */
@@ -224,13 +224,13 @@ static void preview_cb(ScrArea *sa, struct uiBlock *block)
areamouseco_to_ipoco(v2d, mval, &dispf.xmin, &dispf.ymin);
mval[0] = disprect->xmax; mval[1] = disprect->ymax;
areamouseco_to_ipoco(v2d, mval, &dispf.xmax, &dispf.ymax);
-
+
/* map to render coordinates */
disprect->xmin = dispf.xmin;
disprect->xmax = dispf.xmax;
disprect->ymin = dispf.ymin;
disprect->ymax = dispf.ymax;
-
+
CLAMP(disprect->xmin, 0, winx);
CLAMP(disprect->xmax, 0, winx);
CLAMP(disprect->ymin, 0, winy);
@@ -254,7 +254,7 @@ static bool is_preview_allowed(ScrArea *cur)
/* check image type */
if (sima->image == NULL || sima->image->type != IMA_TYPE_COMPOSITE)
return 0;
-
+
return 1;
}
@@ -264,23 +264,23 @@ static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PRE
uiBlock *block;
SpaceImage *sima = sa->spacedata.first;
int ofsx, ofsy;
-
+
if (is_preview_allowed(sa) == 0) {
rem_blockhandler(sa, IMAGE_HANDLER_PREVIEW);
G.scene->r.scemode &= ~R_COMP_CROP; /* quite weak */
return;
}
-
+
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | UI_PNL_SCALE | cntrl);
uiSetPanelHandler(IMAGE_HANDLER_PREVIEW); // for close and esc
-
+
ofsx = -150 + (sa->winx / 2) / sima->blockscale;
ofsy = -100 + (sa->winy / 2) / sima->blockscale;
if (uiNewPanel(C, ar, block, "Preview", "Image", ofsx, ofsy, 300, 200) == 0) return;
-
+
UI_but_func_drawextra_set(block, preview_cb);
-
+
}
#endif
@@ -660,7 +660,7 @@ static void image_multiview_cb(bContext *C, void *rnd_pt, void *UNUSED(arg_v))
}
#if 0
-static void image_freecache_cb(bContext *C, void *ima_v, void *unused)
+static void image_freecache_cb(bContext *C, void *ima_v, void *unused)
{
Scene *scene = CTX_data_scene(C);
BKE_image_free_anim_ibufs(ima_v, scene->r.cfra);
@@ -898,7 +898,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
uiDefIconTextBut(block, UI_BTYPE_BUT, B_SIMA_PLAY, ICON_PLAY, "Play", 110, 120, 100, 20, 0, 0, 0, 0, 0, "");
but = uiDefBut(block, UI_BTYPE_BUT, B_NOP, "Free Cache", 210, 120, 100, 20, 0, 0, 0, 0, 0, "");
UI_but_func_set(but, image_freecache_cb, ima, NULL);
-
+
if (iuser->frames)
BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr);
else strcpy(str, "Frames:");
@@ -929,7 +929,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
uiItemO(row, "", ICON_PACKAGE, "image.unpack");
else
uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack");
-
+
row = uiLayoutRow(row, true);
uiLayoutSetEnabled(row, BKE_image_has_packedfile(ima) == false);
uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE);
@@ -1043,7 +1043,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
col = uiLayoutColumn(split, true);
uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE);
uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE);
-
+
uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE);
uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
@@ -1077,7 +1077,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_man
col = uiLayoutColumn(layout, false);
split = uiLayoutSplit(col, 0.5f, false);
-
+
uiItemR(split, imfptr, "file_format", 0, "", ICON_NONE);
sub = uiLayoutRow(split, false);
uiItemR(sub, imfptr, "color_mode", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE);
@@ -1109,7 +1109,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_man
if (ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
uiItemR(col, imfptr, "exr_codec", 0, NULL, ICON_NONE);
}
-
+
row = uiLayoutRow(col, false);
if (BKE_imtype_supports_zbuf(imf->imtype)) {
uiItemR(row, imfptr, "use_zbuffer", 0, NULL, ICON_NONE);
@@ -1126,7 +1126,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_man
row = uiLayoutRow(col, false);
uiItemR(row, imfptr, "use_jpeg2k_cinema_preset", 0, NULL, ICON_NONE);
uiItemR(row, imfptr, "use_jpeg2k_cinema_48", 0, NULL, ICON_NONE);
-
+
uiItemR(col, imfptr, "use_jpeg2k_ycc", 0, NULL, ICON_NONE);
}
@@ -1297,14 +1297,14 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
void image_buttons_register(ARegionType *UNUSED(art))
{
-
+
}
static int image_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = image_has_buttons_region(sa);
-
+
if (ar)
ED_region_toggle_hidden(C, ar);
@@ -1316,10 +1316,10 @@ void IMAGE_OT_properties(wmOperatorType *ot)
ot->name = "Properties";
ot->idname = "IMAGE_OT_properties";
ot->description = "Toggle the properties region visibility";
-
+
ot->exec = image_properties_toggle_exec;
ot->poll = ED_operator_image_active;
-
+
/* flags */
ot->flag = 0;
}
@@ -1328,10 +1328,10 @@ static int image_scopes_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = image_has_tools_region(sa);
-
+
if (ar)
ED_region_toggle_hidden(C, ar);
-
+
return OPERATOR_FINISHED;
}
@@ -1343,7 +1343,7 @@ void IMAGE_OT_toolshelf(wmOperatorType *ot)
ot->exec = image_scopes_toggle_exec;
ot->poll = ED_operator_image_active;
-
+
/* flags */
ot->flag = 0;
}
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index fc4d8c39e26..1e2d668018f 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -231,7 +231,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
-
+
BLF_color3ubv(blf_mono_font, green);
if (fp)
BLI_snprintf(str, sizeof(str), " G:%-.5f", fp[1]);
@@ -242,7 +242,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
-
+
BLF_color3ubv(blf_mono_font, blue);
if (fp)
BLI_snprintf(str, sizeof(str), " B:%-.5f", fp[2]);
@@ -253,7 +253,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
-
+
if (channels == 4) {
BLF_color3ub(blf_mono_font, 255, 255, 255);
if (fp)
@@ -287,7 +287,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
dx += BLF_width(blf_mono_font, str, sizeof(str));
}
}
-
+
/* color rectangle */
if (channels == 1) {
if (fp) {
@@ -384,7 +384,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
rgb_to_hsv((float)cp[0] / 255.0f, (float)cp[0] / 255.0f, (float)cp[0] / 255.0f, &hue, &sat, &val);
rgb_to_yuv((float)cp[0] / 255.0f, (float)cp[0] / 255.0f, (float)cp[0] / 255.0f, &lum, &u, &v, BLI_YUV_ITU_BT709);
}
-
+
BLI_snprintf(str, sizeof(str), "V:%-.4f", val);
BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
@@ -561,7 +561,7 @@ void draw_image_grease_pencil(bContext *C, bool onlyv2d)
else {
/* assume that UI_view2d_restore(C) has been called... */
//SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C);
-
+
/* draw grease-pencil ('screen' strokes) */
ED_gpencil_draw_view2d(C, 0);
}
@@ -647,10 +647,10 @@ void draw_image_main(const bContext *C, ARegion *ar)
/* XXX can we do this in refresh? */
#if 0
what_image(sima);
-
+
if (sima->image) {
ED_image_get_aspect(sima->image, &xuser_asp, &yuser_asp);
-
+
/* UGLY hack? until now iusers worked fine... but for flipbook viewer we need this */
if (sima->image->type == IMA_TYPE_COMPOSITE) {
ImageUser *iuser = ntree_get_active_iuser(scene->nodetree);
diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c
index c598e486a7e..0eb6a2400d2 100644
--- a/source/blender/editors/space_image/image_edit.c
+++ b/source/blender/editors/space_image/image_edit.c
@@ -41,6 +41,7 @@
#include "BKE_image.h"
#include "BKE_editmesh.h"
#include "BKE_library.h"
+#include "BKE_main.h"
#include "IMB_imbuf_types.h"
@@ -63,7 +64,7 @@ Image *ED_space_image(SpaceImage *sima)
}
/* called to assign images to UV faces */
-void ED_space_image_set(SpaceImage *sima, Scene *UNUSED(scene), Object *obedit, Image *ima)
+void ED_space_image_set(Main *bmain, SpaceImage *sima, Scene *UNUSED(scene), Object *obedit, Image *ima)
{
/* change the space ima after because uvedit_face_visible_test uses the space ima
* to check if the face is displayed in UV-localview */
@@ -76,7 +77,7 @@ void ED_space_image_set(SpaceImage *sima, Scene *UNUSED(scene), Object *obedit,
}
if (sima->image)
- BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
+ BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
id_us_ensure_real((ID *)sima->image);
@@ -322,7 +323,7 @@ void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *s
{
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
-
+
/* scope update can be expensive, don't update during paint modes */
if (sima->mode == SI_MODE_PAINT)
return;
@@ -338,7 +339,7 @@ void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *s
return;
}
}
-
+
scopes_update(&sima->scopes, ibuf, use_view_settings ? &scene->view_settings : NULL, &scene->display_settings);
}
diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h
index 47d6257366c..9167a193f2d 100644
--- a/source/blender/editors/space_image/image_intern.h
+++ b/source/blender/editors/space_image/image_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index a2afb5cb5c5..39544eb55dd 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -227,7 +227,7 @@ static int space_image_file_exists_poll(bContext *C)
ibuf = ED_space_image_acquire_buffer(sima, &lock);
if (ibuf) {
BLI_strncpy(name, ibuf->name, FILE_MAX);
- BLI_path_abs(name, bmain->name);
+ BLI_path_abs(name, BKE_main_blendfile_path(bmain));
if (BLI_exists(name) == false) {
CTX_wm_operator_poll_msg_set(C, "image file not found");
@@ -366,7 +366,7 @@ static int image_view_pan_exec(bContext *C, wmOperator *op)
image_preview_event(2);
}
#endif
-
+
return OPERATOR_FINISHED;
}
@@ -375,7 +375,7 @@ static int image_view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *eve
if (event->type == MOUSEPAN) {
SpaceImage *sima = CTX_wm_space_image(C);
float offset[2];
-
+
offset[0] = (event->prevx - event->x) / sima->zoom;
offset[1] = (event->prevy - event->y) / sima->zoom;
RNA_float_set_array(op->ptr, "offset", offset);
@@ -426,7 +426,7 @@ void IMAGE_OT_view_pan(wmOperatorType *ot)
ot->name = "View Pan";
ot->idname = "IMAGE_OT_view_pan";
ot->description = "Pan the view";
-
+
/* api callbacks */
ot->exec = image_view_pan_exec;
ot->invoke = image_view_pan_invoke;
@@ -436,7 +436,7 @@ void IMAGE_OT_view_pan(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR | OPTYPE_LOCK_BYPASS;
-
+
/* properties */
RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX,
"Offset", "Offset in floating point units, 1.0 is the width and height of the image", -FLT_MAX, FLT_MAX);
@@ -521,7 +521,7 @@ static int image_view_zoom_exec(bContext *C, wmOperator *op)
image_preview_event(2);
}
#endif
-
+
return OPERATOR_FINISHED;
}
@@ -549,7 +549,7 @@ static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
RNA_float_set(op->ptr, "factor", factor);
sima_zoom_set(sima, ar, sima->zoom * factor, location);
ED_region_tag_redraw(ar);
-
+
return OPERATOR_FINISHED;
}
else {
@@ -642,7 +642,7 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot)
ot->name = "View Zoom";
ot->idname = "IMAGE_OT_view_zoom";
ot->description = "Zoom in/out the image";
-
+
/* api callbacks */
ot->exec = image_view_zoom_exec;
ot->invoke = image_view_zoom_invoke;
@@ -652,7 +652,7 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR | OPTYPE_LOCK_BYPASS;
-
+
/* properties */
prop = RNA_def_float(ot->srna, "factor", 0.0f, -FLT_MAX, FLT_MAX, "Factor",
"Zoom factor, values higher than 1.0 zoom in, lower values zoom out", -FLT_MAX, FLT_MAX);
@@ -701,7 +701,7 @@ void IMAGE_OT_view_ndof(wmOperatorType *ot)
ot->name = "NDOF Pan/Zoom";
ot->idname = "IMAGE_OT_view_ndof";
ot->description = "Use a 3D mouse device to pan/zoom the view";
-
+
/* api callbacks */
ot->invoke = image_view_ndof_invoke;
ot->poll = space_image_main_region_poll;
@@ -734,7 +734,7 @@ static int image_view_all_exec(bContext *C, wmOperator *op)
w = width * aspx;
h = height * aspy;
-
+
/* check if the image will fit in the image with (zoom == 1) */
width = BLI_rcti_size_x(&ar->winrct) + 1;
height = BLI_rcti_size_y(&ar->winrct) + 1;
@@ -762,7 +762,7 @@ static int image_view_all_exec(bContext *C, wmOperator *op)
sima->xof = sima->yof = 0.0f;
ED_region_tag_redraw(ar);
-
+
return OPERATOR_FINISHED;
}
@@ -774,7 +774,7 @@ void IMAGE_OT_view_all(wmOperatorType *ot)
ot->name = "View All";
ot->idname = "IMAGE_OT_view_all";
ot->description = "View the entire image";
-
+
/* api callbacks */
ot->exec = image_view_all_exec;
ot->poll = space_image_main_region_poll;
@@ -830,7 +830,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
sima_zoom_set_from_bounds(sima, ar, &bounds);
ED_region_tag_redraw(ar);
-
+
return OPERATOR_FINISHED;
}
@@ -845,7 +845,7 @@ void IMAGE_OT_view_selected(wmOperatorType *ot)
ot->name = "View Center";
ot->idname = "IMAGE_OT_view_selected";
ot->description = "View all selected UVs";
-
+
/* api callbacks */
ot->exec = image_view_selected_exec;
ot->poll = image_view_selected_poll;
@@ -858,13 +858,13 @@ static int image_view_zoom_in_exec(bContext *C, wmOperator *op)
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
float location[2];
-
+
RNA_float_get_array(op->ptr, "location", location);
sima_zoom_set_factor(sima, ar, powf(2.0f, 1.0f / 3.0f), location);
ED_region_tag_redraw(ar);
-
+
return OPERATOR_FINISHED;
}
@@ -887,7 +887,7 @@ void IMAGE_OT_view_zoom_in(wmOperatorType *ot)
ot->name = "View Zoom In";
ot->idname = "IMAGE_OT_view_zoom_in";
ot->description = "Zoom in the image (centered around 2D cursor)";
-
+
/* api callbacks */
ot->invoke = image_view_zoom_in_invoke;
ot->exec = image_view_zoom_in_exec;
@@ -907,13 +907,13 @@ static int image_view_zoom_out_exec(bContext *C, wmOperator *op)
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
float location[2];
-
+
RNA_float_get_array(op->ptr, "location", location);
sima_zoom_set_factor(sima, ar, powf(0.5f, 1.0f / 3.0f), location);
-
+
ED_region_tag_redraw(ar);
-
+
return OPERATOR_FINISHED;
}
@@ -936,7 +936,7 @@ void IMAGE_OT_view_zoom_out(wmOperatorType *ot)
ot->name = "View Zoom Out";
ot->idname = "IMAGE_OT_view_zoom_out";
ot->description = "Zoom out the image (centered around 2D cursor)";
-
+
/* api callbacks */
ot->invoke = image_view_zoom_out_invoke;
ot->exec = image_view_zoom_out_exec;
@@ -959,7 +959,7 @@ static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
sima_zoom_set(sima, ar, RNA_float_get(op->ptr, "ratio"), NULL);
-
+
/* ensure pixel exact locations for draw */
sima->xof = (int)sima->xof;
sima->yof = (int)sima->yof;
@@ -974,7 +974,7 @@ static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op)
#endif
ED_region_tag_redraw(ar);
-
+
return OPERATOR_FINISHED;
}
@@ -984,7 +984,7 @@ void IMAGE_OT_view_zoom_ratio(wmOperatorType *ot)
ot->name = "View Zoom Ratio";
ot->idname = "IMAGE_OT_view_zoom_ratio";
ot->description = "Set zoom ratio of the view";
-
+
/* api callbacks */
ot->exec = image_view_zoom_ratio_exec;
ot->poll = space_image_main_region_poll;
@@ -1057,7 +1057,7 @@ void IMAGE_OT_view_zoom_border(wmOperatorType *ot)
static void image_filesel(bContext *C, wmOperator *op, const char *path)
{
RNA_string_set(op->ptr, "filepath", path);
- WM_event_add_fileselect(C, op);
+ WM_event_add_fileselect(C, op);
}
/******************** open image operator ********************/
@@ -1179,14 +1179,14 @@ static int image_sequence_get_len(ListBase *frames, int *ofs)
}
static Image *image_open_single(
- wmOperator *op, const char *filepath, const char *relbase,
+ Main *bmain, wmOperator *op, const char *filepath, const char *relbase,
bool is_relative_path, bool use_multiview, int frame_seq_len)
{
bool exists = false;
Image *ima = NULL;
errno = 0;
- ima = BKE_image_load_exists_ex(filepath, &exists);
+ ima = BKE_image_load_exists_ex(bmain, filepath, &exists);
if (!ima) {
if (op->customdata) MEM_freeN(op->customdata);
@@ -1263,11 +1263,11 @@ static int image_open_exec(bContext *C, wmOperator *op)
BLI_strncpy(filepath_range, frame_range->filepath, sizeof(filepath_range));
if (was_relative) {
- BLI_path_rel(filepath_range, bmain->name);
+ BLI_path_rel(filepath_range, BKE_main_blendfile_path(bmain));
}
Image *ima_range = image_open_single(
- op, filepath_range, bmain->name,
+ bmain, op, filepath_range, BKE_main_blendfile_path(bmain),
is_relative_path, use_multiview, frame_range_seq_len);
/* take the first image */
@@ -1282,7 +1282,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
else {
/* for drag & drop etc. */
ima = image_open_single(
- op, filepath, bmain->name,
+ bmain, op, filepath, BKE_main_blendfile_path(bmain),
is_relative_path, use_multiview, 1);
}
@@ -1308,7 +1308,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
}
else if (sa && sa->spacetype == SPACE_IMAGE) {
SpaceImage *sima = sa->spacedata.first;
- ED_space_image_set(sima, scene, obedit, ima);
+ ED_space_image_set(bmain, sima, scene, obedit, ima);
iuser = &sima->iuser;
}
else {
@@ -1348,10 +1348,10 @@ static int image_open_exec(bContext *C, wmOperator *op)
/* XXX unpackImage frees image buffers */
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
-
- BKE_image_signal(ima, iuser, IMA_SIGNAL_RELOAD);
+
+ BKE_image_signal(bmain, ima, iuser, IMA_SIGNAL_RELOAD);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
-
+
MEM_freeN(op->customdata);
return OPERATOR_FINISHED;
@@ -1399,7 +1399,7 @@ static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
if (RNA_struct_property_is_set(op->ptr, "filepath"))
return image_open_exec(C, op);
-
+
image_open_init(C, op);
/* show multiview save options only if scene has multiviews */
@@ -1448,7 +1448,7 @@ void IMAGE_OT_open(wmOperatorType *ot)
ot->name = "Open Image";
ot->description = "Open image";
ot->idname = "IMAGE_OT_open";
-
+
/* api callbacks */
ot->exec = image_open_exec;
ot->invoke = image_open_invoke;
@@ -1487,7 +1487,7 @@ static int image_match_len_exec(bContext *C, wmOperator *UNUSED(op))
ima = sima->image;
iuser = &sima->iuser;
}
-
+
}
if (!ima || !iuser || !BKE_image_has_anim(ima))
@@ -1509,7 +1509,7 @@ void IMAGE_OT_match_movie_length(wmOperatorType *ot)
ot->name = "Match Movie Length";
ot->description = "Set image's user's length to the one of this video";
ot->idname = "IMAGE_OT_match_movie_length";
-
+
/* api callbacks */
ot->exec = image_match_len_exec;
@@ -1521,12 +1521,13 @@ void IMAGE_OT_match_movie_length(wmOperatorType *ot)
static int image_replace_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
SpaceImage *sima = CTX_wm_space_image(C);
char str[FILE_MAX];
if (!sima->image)
return OPERATOR_CANCELLED;
-
+
RNA_string_get(op->ptr, "filepath", str);
/* we cant do much if the str is longer then FILE_MAX :/ */
@@ -1534,9 +1535,9 @@ static int image_replace_exec(bContext *C, wmOperator *op)
if (sima->image->source == IMA_SRC_GENERATED) {
sima->image->source = IMA_SRC_FILE;
- BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_SRC_CHANGE);
+ BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_SRC_CHANGE);
}
-
+
if (BLI_testextensie_array(str, imb_ext_movie))
sima->image->source = IMA_SRC_MOVIE;
else
@@ -1544,9 +1545,9 @@ static int image_replace_exec(bContext *C, wmOperator *op)
/* XXX unpackImage frees image buffers */
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
-
+
BKE_icon_changed(BKE_icon_id_ensure(&sima->image->id));
- BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_RELOAD);
+ BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_RELOAD);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, sima->image);
return OPERATOR_FINISHED;
@@ -1576,7 +1577,7 @@ void IMAGE_OT_replace(wmOperatorType *ot)
ot->name = "Replace Image";
ot->idname = "IMAGE_OT_replace";
ot->description = "Replace current image by another one from disk";
-
+
/* api callbacks */
ot->exec = image_replace_exec;
ot->invoke = image_replace_invoke;
@@ -1627,7 +1628,7 @@ static char imtype_best_depth(ImBuf *ibuf, const char imtype)
}
}
-static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, Scene *scene,
+static int save_image_options_init(Main *bmain, SaveImageOptions *simopts, SpaceImage *sima, Scene *scene,
const bool guess_path, const bool save_as_render)
{
void *lock;
@@ -1692,12 +1693,12 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
}
else {
BLI_strncpy(simopts->filepath, "//untitled", sizeof(simopts->filepath));
- BLI_path_abs(simopts->filepath, G.main->name);
+ BLI_path_abs(simopts->filepath, BKE_main_blendfile_path(bmain));
}
}
else {
BLI_snprintf(simopts->filepath, sizeof(simopts->filepath), "//%s", ima->id.name + 2);
- BLI_path_abs(simopts->filepath, is_prev_save ? G.ima : G.main->name);
+ BLI_path_abs(simopts->filepath, is_prev_save ? G.ima : BKE_main_blendfile_path(bmain));
}
}
@@ -1711,7 +1712,7 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
return (ibuf != NULL);
}
-static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op)
+static void save_image_options_from_op(Main *bmain, SaveImageOptions *simopts, wmOperator *op)
{
if (op->customdata) {
BKE_color_managed_view_settings_free(&simopts->im_format.view_settings);
@@ -1721,7 +1722,7 @@ static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
RNA_string_get(op->ptr, "filepath", simopts->filepath);
- BLI_path_abs(simopts->filepath, G.main->name);
+ BLI_path_abs(simopts->filepath, BKE_main_blendfile_path(bmain));
}
}
@@ -1737,7 +1738,7 @@ static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op)
}
static void save_image_post(
- wmOperator *op, ImBuf *ibuf, Image *ima, int ok, int save_copy,
+ Main *bmain, wmOperator *op, ImBuf *ibuf, Image *ima, int ok, int save_copy,
const char *relbase, int relative, int do_newpath, const char *filepath)
{
if (ok) {
@@ -1783,7 +1784,7 @@ static void save_image_post(
if (!BKE_color_managed_colorspace_settings_equals(&old_colorspace_settings,
&ima->colorspace_settings))
{
- BKE_image_signal(ima, NULL, IMA_SIGNAL_COLORMANAGE);
+ BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE);
}
}
}
@@ -1814,6 +1815,7 @@ static void save_imbuf_post(ImBuf *ibuf, ImBuf *colormanaged_ibuf)
*/
static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, bool do_newpath)
{
+ Main *bmain = CTX_data_main(C);
Image *ima = ED_space_image(sima);
void *lock;
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
@@ -1891,7 +1893,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
if (imf->views_format == R_IMF_VIEWS_MULTIVIEW && is_exr_rr) {
/* save render result */
ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, sima->iuser.layer);
- save_image_post(op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath);
+ save_image_post(bmain, op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath);
ED_space_image_release_buffer(sima, ibuf, lock);
}
/* regular mono pipeline */
@@ -1904,7 +1906,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
ok = BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, imf, save_copy);
save_imbuf_post(ibuf, colormanaged_ibuf);
}
- save_image_post(op, ibuf, ima, ok, (is_exr_rr ? true : save_copy), relbase, relative, do_newpath, simopts->filepath);
+ save_image_post(bmain, op, ibuf, ima, ok, (is_exr_rr ? true : save_copy), relbase, relative, do_newpath, simopts->filepath);
ED_space_image_release_buffer(sima, ibuf, lock);
}
/* individual multiview images */
@@ -1926,7 +1928,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
if (is_exr_rr) {
BKE_scene_multiview_view_filepath_get(&scene->r, simopts->filepath, view, filepath);
ok_view = RE_WriteRenderResult(op->reports, rr, filepath, imf, view, -1);
- save_image_post(op, ibuf, ima, ok_view, true, relbase, relative, do_newpath, filepath);
+ save_image_post(bmain, op, ibuf, ima, ok_view, true, relbase, relative, do_newpath, filepath);
}
else {
/* copy iuser to get the correct ibuf for this view */
@@ -1947,7 +1949,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(ibuf, save_as_render, true, &imf->view_settings, &imf->display_settings, imf);
ok_view = BKE_imbuf_write_as(colormanaged_ibuf, filepath, &simopts->im_format, save_copy);
save_imbuf_post(ibuf, colormanaged_ibuf);
- save_image_post(op, ibuf, ima, ok_view, true, relbase, relative, do_newpath, filepath);
+ save_image_post(bmain, op, ibuf, ima, ok_view, true, relbase, relative, do_newpath, filepath);
BKE_image_release_ibuf(sima->image, ibuf, lock);
}
ok &= ok_view;
@@ -1961,7 +1963,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
else if (simopts->im_format.views_format == R_IMF_VIEWS_STEREO_3D) {
if (imf->imtype == R_IMF_IMTYPE_MULTILAYER) {
ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, -1);
- save_image_post(op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath);
+ save_image_post(bmain, op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath);
ED_space_image_release_buffer(sima, ibuf, lock);
}
else {
@@ -2054,6 +2056,7 @@ static void image_save_as_free(wmOperator *op)
static int image_save_as_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
SpaceImage *sima = CTX_wm_space_image(C);
SaveImageOptions simopts;
@@ -2061,9 +2064,9 @@ static int image_save_as_exec(bContext *C, wmOperator *op)
/* just in case to initialize values,
* these should be set on invoke or by the caller. */
- save_image_options_init(&simopts, sima, CTX_data_scene(C), false, false);
+ save_image_options_init(bmain, &simopts, sima, CTX_data_scene(C), false, false);
- save_image_options_from_op(&simopts, op);
+ save_image_options_from_op(bmain, &simopts, op);
save_image_doit(C, sima, op, &simopts, true);
@@ -2080,6 +2083,7 @@ static bool image_save_as_check(bContext *UNUSED(C), wmOperator *op)
static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
+ Main *bmain = CTX_data_main(C);
SpaceImage *sima = CTX_wm_space_image(C);
Image *ima = ED_space_image(sima);
Scene *scene = CTX_data_scene(C);
@@ -2092,7 +2096,7 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
save_image_options_defaults(&simopts);
- if (save_image_options_init(&simopts, sima, scene, true, save_as_render) == 0)
+ if (save_image_options_init(bmain, &simopts, sima, scene, true, save_as_render) == 0)
return OPERATOR_CANCELLED;
save_image_options_to_op(&simopts, op);
@@ -2178,7 +2182,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
ot->name = "Save As Image";
ot->idname = "IMAGE_OT_save_as";
ot->description = "Save the image with another name and/or settings";
-
+
/* api callbacks */
ot->exec = image_save_as_exec;
ot->check = image_save_as_check;
@@ -2203,14 +2207,15 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
static int image_save_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
SaveImageOptions simopts;
save_image_options_defaults(&simopts);
- if (save_image_options_init(&simopts, sima, scene, false, false) == 0)
+ if (save_image_options_init(bmain, &simopts, sima, scene, false, false) == 0)
return OPERATOR_CANCELLED;
- save_image_options_from_op(&simopts, op);
+ save_image_options_from_op(bmain, &simopts, op);
if (BLI_exists(simopts.filepath) && BLI_file_is_writable(simopts.filepath)) {
if (save_image_doit(C, sima, op, &simopts, false)) {
@@ -2232,7 +2237,7 @@ void IMAGE_OT_save(wmOperatorType *ot)
ot->name = "Save Image";
ot->idname = "IMAGE_OT_save";
ot->description = "Save the image with current name and settings";
-
+
/* api callbacks */
ot->exec = image_save_exec;
ot->poll = space_image_file_exists_poll;
@@ -2251,7 +2256,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
int tot = 0;
char di[FILE_MAX];
struct MovieCacheIter *iter;
-
+
if (sima->image == NULL)
return OPERATOR_CANCELLED;
@@ -2264,7 +2269,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Cannot save multilayer sequences");
return OPERATOR_CANCELLED;
}
-
+
/* get total dirty buffers and first dirty buffer which is used for menu */
ibuf = NULL;
if (sima->image->cache != NULL) {
@@ -2281,7 +2286,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
}
IMB_moviecacheIter_free(iter);
}
-
+
if (tot == 0) {
BKE_report(op->reports, RPT_WARNING, "No images have been changed");
return OPERATOR_CANCELLED;
@@ -2299,7 +2304,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
char name[FILE_MAX];
BLI_strncpy(name, ibuf->name, sizeof(name));
- BLI_path_abs(name, bmain->name);
+ BLI_path_abs(name, BKE_main_blendfile_path(bmain));
if (0 == IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)) {
BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno));
@@ -2323,7 +2328,7 @@ void IMAGE_OT_save_sequence(wmOperatorType *ot)
ot->name = "Save Sequence";
ot->idname = "IMAGE_OT_save_sequence";
ot->description = "Save a sequence of images";
-
+
/* api callbacks */
ot->exec = image_save_sequence_exec;
ot->poll = space_image_buffer_exists_poll;
@@ -2336,6 +2341,7 @@ void IMAGE_OT_save_sequence(wmOperatorType *ot)
static int image_reload_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Main *bmain = CTX_data_main(C);
Image *ima = CTX_data_edit_image(C);
SpaceImage *sima = CTX_wm_space_image(C);
@@ -2344,13 +2350,13 @@ static int image_reload_exec(bContext *C, wmOperator *UNUSED(op))
/* XXX unpackImage frees image buffers */
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
-
+
// XXX other users?
- BKE_image_signal(ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_RELOAD);
+ BKE_image_signal(bmain, ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_RELOAD);
DEG_id_tag_update(&ima->id, 0);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
-
+
return OPERATOR_FINISHED;
}
@@ -2360,7 +2366,7 @@ void IMAGE_OT_reload(wmOperatorType *ot)
ot->name = "Reload Image";
ot->idname = "IMAGE_OT_reload";
ot->description = "Reload current image from disk";
-
+
/* api callbacks */
ot->exec = image_reload_exec;
@@ -2438,16 +2444,16 @@ static int image_new_exec(bContext *C, wmOperator *op)
RNA_property_update(C, &ptr, prop);
}
else if (sima) {
- ED_space_image_set(sima, scene, obedit, ima);
+ ED_space_image_set(bmain, sima, scene, obedit, ima);
}
else if (gen_context == GEN_CONTEXT_PAINT_CANVAS) {
bScreen *sc;
Object *ob = CTX_data_active_object(C);
-
+
if (scene->toolsettings->imapaint.canvas)
id_us_min(&scene->toolsettings->imapaint.canvas->id);
scene->toolsettings->imapaint.canvas = ima;
-
+
for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
@@ -2455,9 +2461,9 @@ static int image_new_exec(bContext *C, wmOperator *op)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima_other = (SpaceImage *)sl;
-
+
if (!sima_other->pin) {
- ED_space_image_set(sima_other, scene, obedit, ima);
+ ED_space_image_set(bmain, sima_other, scene, obedit, ima);
}
}
}
@@ -2471,8 +2477,8 @@ static int image_new_exec(bContext *C, wmOperator *op)
if (scene->toolsettings->imapaint.stencil)
id_us_min(&scene->toolsettings->imapaint.stencil->id);
scene->toolsettings->imapaint.stencil = ima;
- BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
- WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
+ BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
+ WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
}
else {
Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
@@ -2484,10 +2490,10 @@ static int image_new_exec(bContext *C, wmOperator *op)
}
}
- BKE_image_signal(ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE);
-
+ BKE_image_signal(bmain, ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE);
+
WM_event_add_notifier(C, NC_IMAGE | NA_ADDED, ima);
-
+
return OPERATOR_FINISHED;
}
@@ -2558,17 +2564,17 @@ void IMAGE_OT_new(wmOperatorType *ot)
{GEN_CONTEXT_PAINT_STENCIL, "PAINT_STENCIL", 0, "Paint Stencil", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "New Image";
ot->description = "Create a new image";
ot->idname = "IMAGE_OT_new";
-
+
/* api callbacks */
ot->exec = image_new_exec;
ot->invoke = image_new_invoke;
ot->ui = image_new_draw;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
@@ -2630,7 +2636,7 @@ static int image_invert_exec(bContext *C, wmOperator *op)
}
/* TODO: make this into an IMB_invert_channels(ibuf,r,g,b,a) method!? */
if (ibuf->rect_float) {
-
+
float *fp = (float *) ibuf->rect_float;
for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, fp += 4) {
if (r) fp[0] = 1.0f - fp[0];
@@ -2644,7 +2650,7 @@ static int image_invert_exec(bContext *C, wmOperator *op)
}
}
else if (ibuf->rect) {
-
+
char *cp = (char *) ibuf->rect;
for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, cp += 4) {
if (r) cp[0] = 255 - cp[0];
@@ -2685,11 +2691,11 @@ void IMAGE_OT_invert(wmOperatorType *ot)
ot->name = "Invert Channels";
ot->idname = "IMAGE_OT_invert";
ot->description = "Invert image's channels";
-
+
/* api callbacks */
ot->exec = image_invert_exec;
ot->poll = image_invert_poll;
-
+
/* properties */
prop = RNA_def_boolean(ot->srna, "invert_r", 0, "Red", "Invert Red Channel");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
@@ -2699,7 +2705,7 @@ void IMAGE_OT_invert(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "invert_a", 0, "Alpha", "Invert Alpha Channel");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2733,7 +2739,7 @@ static int image_pack_exec(bContext *C, wmOperator *op)
if (!image_pack_test(C, op))
return OPERATOR_CANCELLED;
-
+
if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) {
BKE_report(op->reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG");
return OPERATOR_CANCELLED;
@@ -2785,9 +2791,9 @@ void IMAGE_OT_pack(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Pack Image";
- ot->description = "Pack an image as embedded data into the .blend file";
+ ot->description = "Pack an image as embedded data into the .blend file";
ot->idname = "IMAGE_OT_pack";
-
+
/* api callbacks */
ot->exec = image_pack_exec;
ot->invoke = image_pack_invoke;
@@ -2813,7 +2819,7 @@ static int image_unpack_exec(bContext *C, wmOperator *op)
ima = BLI_findstring(&CTX_data_main(C)->image, imaname, offsetof(ID, name) + 2);
if (!ima) ima = CTX_data_edit_image(C);
}
-
+
if (!ima || !BKE_image_has_packedfile(ima))
return OPERATOR_CANCELLED;
@@ -2824,12 +2830,12 @@ static int image_unpack_exec(bContext *C, wmOperator *op)
if (G.fileflags & G_AUTOPACK)
BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save");
-
+
/* XXX unpackImage frees image buffers */
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
-
- unpackImage(op->reports, ima, method);
-
+
+ unpackImage(CTX_data_main(C), op->reports, ima, method);
+
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
return OPERATOR_FINISHED;
@@ -2841,7 +2847,7 @@ static int image_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
if (RNA_struct_property_is_set(op->ptr, "id"))
return image_unpack_exec(C, op);
-
+
if (!ima || !BKE_image_has_packedfile(ima))
return OPERATOR_CANCELLED;
@@ -2862,16 +2868,16 @@ void IMAGE_OT_unpack(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Unpack Image";
- ot->description = "Save an image packed in the .blend file to disk";
+ ot->description = "Save an image packed in the .blend file to disk";
ot->idname = "IMAGE_OT_unpack";
-
+
/* api callbacks */
ot->exec = image_unpack_exec;
ot->invoke = image_unpack_invoke;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_enum(ot->srna, "method", rna_enum_unpack_method_items, PF_USE_LOCAL, "Method", "How to unpack");
RNA_def_string(ot->srna, "id", NULL, MAX_ID_NAME - 2, "Image Name", "Image data-block name to unpack"); /* XXX, weark!, will fail with library, name collisions */
@@ -3074,7 +3080,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event
#if 0
{
ScrArea *sa, *cur = curarea;
-
+
node_curvemap_sample(fp); /* sends global to node editor */
for (sa = G.curscreen->areabase.first; sa; sa = sa->next) {
if (sa->spacetype == SPACE_NODE) {
@@ -3118,7 +3124,7 @@ static int image_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event
if (!ED_space_image_has_buffer(sima))
return OPERATOR_CANCELLED;
-
+
info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
info->art = ar->type;
info->draw_handle = ED_region_draw_cb_activate(ar->type, image_sample_draw, info, REGION_DRAW_POST_PIXEL);
@@ -3160,7 +3166,7 @@ void IMAGE_OT_sample(wmOperatorType *ot)
ot->name = "Sample Color";
ot->idname = "IMAGE_OT_sample";
ot->description = "Use mouse to sample a color in current image";
-
+
/* api callbacks */
ot->invoke = image_sample_invoke;
ot->modal = image_sample_modal;
@@ -3182,13 +3188,13 @@ static int image_sample_line_exec(bContext *C, wmOperator *op)
int y_start = RNA_int_get(op->ptr, "ystart");
int x_end = RNA_int_get(op->ptr, "xend");
int y_end = RNA_int_get(op->ptr, "yend");
-
+
void *lock;
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
Histogram *hist = &sima->sample_line_hist;
-
+
float x1f, y1f, x2f, y2f;
-
+
if (ibuf == NULL) {
ED_space_image_release_buffer(sima, ibuf, lock);
return OPERATOR_CANCELLED;
@@ -3198,7 +3204,7 @@ static int image_sample_line_exec(bContext *C, wmOperator *op)
ED_space_image_release_buffer(sima, ibuf, lock);
return OPERATOR_CANCELLED;
}
-
+
UI_view2d_region_to_view(&ar->v2d, x_start, y_start, &x1f, &y1f);
UI_view2d_region_to_view(&ar->v2d, x_end, y_end, &x2f, &y2f);
@@ -3211,14 +3217,14 @@ static int image_sample_line_exec(bContext *C, wmOperator *op)
hist->flag |= HISTO_FLAG_SAMPLELINE;
BKE_histogram_update_sample_line(hist, ibuf, &scene->view_settings, &scene->display_settings);
-
+
/* reset y zoom */
hist->ymax = 1.0f;
ED_space_image_release_buffer(sima, ibuf, lock);
-
+
ED_area_tag_redraw(CTX_wm_area(C));
-
+
return OPERATOR_FINISHED;
}
@@ -3231,7 +3237,7 @@ static int image_sample_line_invoke(bContext *C, wmOperator *op, const wmEvent *
if (!ED_space_image_has_buffer(sima))
return OPERATOR_CANCELLED;
-
+
return WM_gesture_straightline_invoke(C, op, event);
}
@@ -3241,17 +3247,17 @@ void IMAGE_OT_sample_line(wmOperatorType *ot)
ot->name = "Sample Line";
ot->idname = "IMAGE_OT_sample_line";
ot->description = "Sample a line and show it in Scope panels";
-
+
/* api callbacks */
ot->invoke = image_sample_line_invoke;
ot->modal = WM_gesture_straightline_modal;
ot->exec = image_sample_line_exec;
ot->poll = space_image_main_region_poll;
ot->cancel = WM_gesture_straightline_cancel;
-
+
/* flags */
ot->flag = 0; /* no undo/register since this operates on the space */
-
+
WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT);
}
@@ -3272,7 +3278,7 @@ void IMAGE_OT_curves_point_set(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->invoke = image_sample_invoke;
ot->modal = image_sample_modal;
@@ -3298,19 +3304,19 @@ static int image_record_composite_apply(bContext *C, wmOperator *op)
RecordCompositeData *rcd = op->customdata;
Scene *scene = CTX_data_scene(C);
ImBuf *ibuf;
-
+
WM_cursor_time(CTX_wm_window(C), scene->r.cfra);
// XXX scene->nodetree->test_break = BKE_blender_test_break;
// XXX scene->nodetree->test_break = NULL;
-
+
BKE_image_all_free_anim_ibufs(scene->r.cfra);
ntreeCompositTagAnimated(scene->nodetree);
ntreeCompositExecTree(scene->nodetree, &scene->r, 0, scene->r.cfra != rcd->old_cfra,
&scene->view_settings, &scene->display_settings); /* 1 is no previews */
ED_area_tag_redraw(CTX_wm_area(C));
-
+
ibuf = BKE_image_acquire_ibuf(sima->image, &sima->iuser, NULL);
/* save memory in flipbooks */
if (ibuf)
@@ -3333,7 +3339,7 @@ static int image_record_composite_init(bContext *C, wmOperator *op)
return 0;
if (scene->nodetree == NULL)
return 0;
-
+
op->customdata = rcd = MEM_callocN(sizeof(RecordCompositeData), "ImageRecordCompositeData");
rcd->old_cfra = scene->r.cfra;
@@ -3369,18 +3375,18 @@ static int image_record_composite_exec(bContext *C, wmOperator *op)
{
if (!image_record_composite_init(C, op))
return OPERATOR_CANCELLED;
-
+
while (image_record_composite_apply(C, op)) {}
-
+
image_record_composite_exit(C, op);
-
+
return OPERATOR_FINISHED;
}
static int image_record_composite_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
RecordCompositeData *rcd;
-
+
if (!image_record_composite_init(C, op))
return OPERATOR_CANCELLED;
@@ -3426,7 +3432,7 @@ void IMAGE_OT_record_composite(wmOperatorType *ot)
/* identifiers */
ot->name = "Record Composite";
ot->idname = "IMAGE_OT_record_composite";
-
+
/* api callbacks */
ot->exec = image_record_composite_exec;
ot->invoke = image_record_composite_invoke;
@@ -3460,7 +3466,7 @@ static int image_cycle_render_slot_exec(bContext *C, wmOperator *op)
/* no undo push for browsing existing */
if (ima->renders[ima->render_slot] || ima->render_slot == ima->last_render_slot)
return OPERATOR_CANCELLED;
-
+
return OPERATOR_FINISHED;
}
@@ -3470,7 +3476,7 @@ void IMAGE_OT_cycle_render_slot(wmOperatorType *ot)
ot->name = "Cycle Render Slot";
ot->idname = "IMAGE_OT_cycle_render_slot";
ot->description = "Cycle through all non-void render slots";
-
+
/* api callbacks */
ot->exec = image_cycle_render_slot_exec;
ot->poll = image_cycle_render_slot_poll;
@@ -3601,13 +3607,14 @@ void IMAGE_OT_change_frame(wmOperatorType *ot)
/* goes over all scenes, reads render layers */
static int image_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
SpaceImage *sima = CTX_wm_space_image(C);
Image *ima;
- ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
+ ima = BKE_image_verify_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result");
if (sima->image == NULL) {
- ED_space_image_set(sima, scene, NULL, ima);
+ ED_space_image_set(bmain, sima, scene, NULL, ima);
}
RE_ReadRenderResult(scene, scene);
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index c303a78594d..c143ebbcd67 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -72,6 +72,7 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "WM_message.h"
#include "UI_resources.h"
#include "UI_interface.h"
@@ -116,21 +117,21 @@ ARegion *image_has_buttons_region(ScrArea *sa)
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
if (ar) return ar;
-
+
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
/* is error! */
if (ar == NULL) return NULL;
-
+
arnew = MEM_callocN(sizeof(ARegion), "buttons for image");
-
+
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
arnew->regiontype = RGN_TYPE_UI;
arnew->alignment = RGN_ALIGN_RIGHT;
-
+
arnew->flag = RGN_FLAG_HIDDEN;
-
+
return arnew;
}
@@ -146,17 +147,17 @@ ARegion *image_has_tools_region(ScrArea *sa)
/* is error! */
if (ar == NULL) return NULL;
-
+
arnew = MEM_callocN(sizeof(ARegion), "scopes for image");
-
+
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
arnew->regiontype = RGN_TYPE_TOOLS;
arnew->alignment = RGN_ALIGN_LEFT;
-
+
arnew->flag = RGN_FLAG_HIDDEN;
image_scopes_tag_refresh(sa);
-
+
return arnew;
}
@@ -166,7 +167,7 @@ static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(sce
{
ARegion *ar;
SpaceImage *simage;
-
+
simage = MEM_callocN(sizeof(SpaceImage), "initimage");
simage->spacetype = SPACE_IMAGE;
simage->zoom = 1.0f;
@@ -183,22 +184,22 @@ static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(sce
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for image");
-
+
BLI_addtail(&simage->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_TOP;
-
+
/* buttons/list view */
ar = MEM_callocN(sizeof(ARegion), "buttons for image");
-
+
BLI_addtail(&simage->regionbase, ar);
ar->regiontype = RGN_TYPE_UI;
ar->alignment = RGN_ALIGN_RIGHT;
ar->flag = RGN_FLAG_HIDDEN;
-
+
/* scopes/uv sculpt/paint */
ar = MEM_callocN(sizeof(ARegion), "buttons for image");
-
+
BLI_addtail(&simage->regionbase, ar);
ar->regiontype = RGN_TYPE_TOOLS;
ar->alignment = RGN_ALIGN_LEFT;
@@ -206,16 +207,16 @@ static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(sce
/* main area */
ar = MEM_callocN(sizeof(ARegion), "main area for image");
-
+
BLI_addtail(&simage->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
-
+
return (SpaceLink *)simage;
}
/* not spacelink itself */
static void image_free(SpaceLink *sl)
-{
+{
SpaceImage *simage = (SpaceImage *) sl;
scopes_free(&simage->scopes);
@@ -229,13 +230,13 @@ static void image_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
/* add drop boxes */
WM_event_add_dropbox_handler(&sa->handlers, lb);
-
+
}
static SpaceLink *image_duplicate(SpaceLink *sl)
{
SpaceImage *simagen = MEM_dupallocN(sl);
-
+
/* clear or remove stuff from old */
scopes_new(&simagen->scopes);
@@ -267,7 +268,7 @@ static void image_operatortypes(void)
WM_operatortype_append(IMAGE_OT_save_sequence);
WM_operatortype_append(IMAGE_OT_pack);
WM_operatortype_append(IMAGE_OT_unpack);
-
+
WM_operatortype_append(IMAGE_OT_invert);
WM_operatortype_append(IMAGE_OT_cycle_render_slot);
@@ -291,7 +292,7 @@ static void image_keymap(struct wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_keymap_find(keyconf, "Image Generic", SPACE_IMAGE, 0);
wmKeyMapItem *kmi;
int i;
-
+
WM_keymap_add_item(keymap, "IMAGE_OT_new", NKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "IMAGE_OT_open", OKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "IMAGE_OT_reload", RKEY, KM_PRESS, KM_ALT, 0);
@@ -301,11 +302,13 @@ static void image_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "IMAGE_OT_properties", NKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "IMAGE_OT_toolshelf", TKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_menu(keymap, "IMAGE_MT_specials", WKEY, KM_PRESS, 0, 0);
+
WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, 0, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, KM_ALT, 0)->ptr, "reverse", true);
-
+
keymap = WM_keymap_find(keyconf, "Image", SPACE_IMAGE, 0);
-
+
WM_keymap_add_item(keymap, "IMAGE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
kmi = WM_keymap_add_item(keymap, "IMAGE_OT_view_all", HOMEKEY, KM_PRESS, KM_SHIFT, 0);
@@ -398,7 +401,7 @@ static void image_drop_copy(wmDrag *drag, wmDropBox *drop)
static void image_dropboxes(void)
{
ListBase *lb = WM_dropboxmap_find("Image", SPACE_IMAGE, 0);
-
+
WM_dropbox_add(lb, "IMAGE_OT_open", image_drop_poll, image_drop_copy);
}
@@ -415,7 +418,7 @@ static void image_refresh(const bContext *C, ScrArea *sa)
ima = ED_space_image(sima);
BKE_image_user_check_frame_calc(&sima->iuser, scene->r.cfra, 0);
-
+
/* check if we have to set the image from the editmesh */
if (ima && (ima->source == IMA_SRC_VIEWER && sima->mode == SI_MODE_MASK)) {
if (scene->nodetree) {
@@ -431,7 +434,7 @@ static void image_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Sc
WorkSpace *workspace)
{
SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
-
+
/* context changes */
switch (wmn->category) {
case NC_WINDOW:
@@ -604,7 +607,7 @@ static void image_main_region_set_view2d(SpaceImage *sima, ARegion *ar)
Image *ima = ED_space_image(sima);
float x1, y1, w, h;
int width, height, winx, winy;
-
+
#if 0
if (image_preview_active(curarea, &width, &height)) {}
else
@@ -613,18 +616,18 @@ static void image_main_region_set_view2d(SpaceImage *sima, ARegion *ar)
w = width;
h = height;
-
+
if (ima)
h *= ima->aspy / ima->aspx;
winx = BLI_rcti_size_x(&ar->winrct) + 1;
winy = BLI_rcti_size_y(&ar->winrct) + 1;
-
+
ar->v2d.tot.xmin = 0;
ar->v2d.tot.ymin = 0;
ar->v2d.tot.xmax = w;
ar->v2d.tot.ymax = h;
-
+
ar->v2d.mask.xmin = ar->v2d.mask.ymin = 0;
ar->v2d.mask.xmax = winx;
ar->v2d.mask.ymax = winy;
@@ -635,15 +638,15 @@ static void image_main_region_set_view2d(SpaceImage *sima, ARegion *ar)
x1 -= sima->zoom * sima->xof;
y1 -= sima->zoom * sima->yof;
-
+
/* relative display right */
ar->v2d.cur.xmin = ((ar->winrct.xmin - (float)x1) / sima->zoom);
ar->v2d.cur.xmax = ar->v2d.cur.xmin + ((float)winx / sima->zoom);
-
+
/* relative display left */
ar->v2d.cur.ymin = ((ar->winrct.ymin - (float)y1) / sima->zoom);
ar->v2d.cur.ymax = ar->v2d.cur.ymin + ((float)winy / sima->zoom);
-
+
/* normalize 0.0..1.0 */
ar->v2d.cur.xmin /= w;
ar->v2d.cur.xmax /= w;
@@ -655,7 +658,7 @@ static void image_main_region_set_view2d(SpaceImage *sima, ARegion *ar)
static void image_main_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
-
+
// image space manages own v2d
// UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
@@ -685,7 +688,7 @@ static void image_main_region_init(wmWindowManager *wm, ARegion *ar)
keymap = WM_keymap_find(wm->defaultconf, "UV Editor", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
-
+
keymap = WM_keymap_find(wm->defaultconf, "UV Sculpt", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
@@ -713,7 +716,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
/* XXX not supported yet, disabling for now */
scene->r.scemode &= ~R_COMP_CROP;
-
+
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
glClearColor(col[0], col[1], col[2], 0.0);
@@ -859,7 +862,7 @@ static void image_buttons_region_init(wmWindowManager *wm, ARegion *ar)
ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
ED_region_panels_init(wm, ar);
-
+
keymap = WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
@@ -910,10 +913,10 @@ static void image_buttons_region_listener(
static void image_tools_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
-
+
ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
ED_region_panels_init(wm, ar);
-
+
keymap = WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
@@ -940,7 +943,7 @@ static void image_tools_region_draw(const bContext *C, ARegion *ar)
}
}
ED_space_image_release_buffer(sima, ibuf, lock);
-
+
ED_region_panels(C, ar, NULL, -1, true);
}
@@ -975,10 +978,25 @@ static void image_tools_region_listener(
case NC_NODE:
ED_region_tag_redraw(ar);
break;
-
+
}
}
+static void image_tools_region_message_subscribe(
+ const struct bContext *UNUSED(C),
+ struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene),
+ struct bScreen *UNUSED(screen), struct ScrArea *UNUSED(sa), struct ARegion *ar,
+ struct wmMsgBus *mbus)
+{
+ wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
+ .owner = ar,
+ .user_data = ar,
+ .notify = ED_region_do_msg_notify_tag_redraw,
+ };
+ WM_msg_subscribe_rna_anon_prop(mbus, WorkSpace, tools, &msg_sub_value_region_tag_redraw);
+}
+
+
/************************* header region **************************/
/* add handlers, stuff you only do once or on area/region changes */
@@ -1054,10 +1072,10 @@ void ED_spacetype_image(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype image");
ARegionType *art;
-
+
st->spaceid = SPACE_IMAGE;
strncpy(st->name, "Image", BKE_ST_MAXNAME);
-
+
st->new = image_new;
st->free = image_free;
st->init = image_init;
@@ -1080,7 +1098,7 @@ void ED_spacetype_image(void)
art->listener = image_main_region_listener;
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: listview/buttons */
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
art->regionid = RGN_TYPE_UI;
@@ -1100,6 +1118,7 @@ void ED_spacetype_image(void)
art->prefsizex = 220; // XXX
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
art->listener = image_tools_region_listener;
+ art->message_subscribe = image_tools_region_message_subscribe;
art->init = image_tools_region_init;
art->draw = image_tools_region_draw;
BLI_addhead(&st->regiontypes, art);
@@ -1112,9 +1131,8 @@ void ED_spacetype_image(void)
art->listener = image_header_region_listener;
art->init = image_header_region_init;
art->draw = image_header_region_draw;
-
+
BLI_addhead(&st->regiontypes, art);
-
+
BKE_spacetype_register(st);
}
-
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c
index cd424f45842..9421567b6ba 100644
--- a/source/blender/editors/space_info/info_draw.c
+++ b/source/blender/editors/space_info/info_draw.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -236,7 +236,7 @@ static int info_textview_main__internal(struct SpaceInfo *sinfo, ARegion *ar, Re
int draw, int mval[2], void **mouse_pick, int *pos_pick)
{
int ret = 0;
-
+
View2D *v2d = &ar->v2d;
TextViewContext tvc = {0};
@@ -260,7 +260,7 @@ static int info_textview_main__internal(struct SpaceInfo *sinfo, ARegion *ar, Re
tvc.winx = ar->winx - V2D_SCROLL_WIDTH;
ret = textview_draw(&tvc, draw, mval, mouse_pick, pos_pick);
-
+
return ret;
}
diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.h
index 967bcec57c5..a16acd665b4 100644
--- a/source/blender/editors/space_info/info_intern.h
+++ b/source/blender/editors/space_info/info_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c
index b87a0de23b9..acd0a856f1a 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -87,7 +87,7 @@ void FILE_OT_pack_libraries(wmOperatorType *ot)
ot->name = "Pack Blender Libraries";
ot->idname = "FILE_OT_pack_libraries";
ot->description = "Pack all used Blender library files into the current .blend";
-
+
/* api callbacks */
ot->exec = pack_libraries_exec;
@@ -98,9 +98,9 @@ void FILE_OT_pack_libraries(wmOperatorType *ot)
static int unpack_libraries_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
-
+
unpackLibraries(bmain, op->reports);
-
+
return OPERATOR_FINISHED;
}
@@ -115,11 +115,11 @@ void FILE_OT_unpack_libraries(wmOperatorType *ot)
ot->name = "Unpack Blender Libraries";
ot->idname = "FILE_OT_unpack_libraries";
ot->description = "Unpack all used Blender library files from this .blend file";
-
+
/* api callbacks */
ot->invoke = unpack_libraries_invoke;
ot->exec = unpack_libraries_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -131,13 +131,13 @@ static int autopack_toggle_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
if (G.fileflags & G_AUTOPACK) {
- G.fileflags &= ~G_AUTOPACK;
+ G.fileflags &= ~G_AUTOPACK;
}
else {
packAll(bmain, op->reports, true);
G.fileflags |= G_AUTOPACK;
}
-
+
return OPERATOR_FINISHED;
}
@@ -147,10 +147,10 @@ void FILE_OT_autopack_toggle(wmOperatorType *ot)
ot->name = "Automatically Pack Into .blend";
ot->idname = "FILE_OT_autopack_toggle";
ot->description = "Automatically pack all external files into the .blend file";
-
+
/* api callbacks */
ot->exec = autopack_toggle_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -160,9 +160,9 @@ void FILE_OT_autopack_toggle(wmOperatorType *ot)
static int pack_all_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
-
+
packAll(bmain, op->reports, true);
-
+
return OPERATOR_FINISHED;
}
@@ -171,25 +171,25 @@ static int pack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev
Main *bmain = CTX_data_main(C);
Image *ima;
ImBuf *ibuf;
-
+
// first check for dirty images
for (ima = bmain->image.first; ima; ima = ima->id.next) {
if (BKE_image_has_loaded_ibuf(ima)) { /* XXX FIX */
ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
-
+
if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) {
BKE_image_release_ibuf(ima, ibuf, NULL);
break;
}
-
+
BKE_image_release_ibuf(ima, ibuf, NULL);
}
}
-
+
if (ima) {
return WM_operator_confirm_message(C, op, "Some images are painted on. These changes will be lost. Continue?");
}
-
+
return pack_all_exec(C, op);
}
@@ -199,11 +199,11 @@ void FILE_OT_pack_all(wmOperatorType *ot)
ot->name = "Pack All Into .blend";
ot->idname = "FILE_OT_pack_all";
ot->description = "Pack all used external files into the .blend";
-
+
/* api callbacks */
ot->exec = pack_all_exec;
ot->invoke = pack_all_invoke;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -238,9 +238,9 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
uiLayout *layout;
char title[64];
int count = 0;
-
+
count = countPackedFiles(bmain);
-
+
if (!count) {
BKE_report(op->reports, RPT_WARNING, "No packed files to unpack");
G.fileflags &= ~G_AUTOPACK;
@@ -251,7 +251,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
BLI_strncpy(title, IFACE_("Unpack 1 File"), sizeof(title));
else
BLI_snprintf(title, sizeof(title), IFACE_("Unpack %d Files"), count);
-
+
pup = UI_popup_menu_begin(C, title, ICON_NONE);
layout = UI_popup_menu_layout(pup);
@@ -269,7 +269,7 @@ void FILE_OT_unpack_all(wmOperatorType *ot)
ot->name = "Unpack All Into Files";
ot->idname = "FILE_OT_unpack_all";
ot->description = "Unpack all files packed into this .blend to external ones";
-
+
/* api callbacks */
ot->exec = unpack_all_exec;
ot->invoke = unpack_all_invoke;
@@ -301,18 +301,18 @@ static int unpack_item_exec(bContext *C, wmOperator *op)
int method = RNA_enum_get(op->ptr, "method");
RNA_string_get(op->ptr, "id_name", idname);
- id = BKE_libblock_find_name(type, idname);
+ id = BKE_libblock_find_name(bmain, type, idname);
if (id == NULL) {
BKE_report(op->reports, RPT_WARNING, "No packed file");
return OPERATOR_CANCELLED;
}
-
+
if (method != PF_KEEP)
BKE_unpack_id(bmain, id, op->reports, method); /* XXX PF_ASK can't work here */
-
+
G.fileflags &= ~G_AUTOPACK;
-
+
return OPERATOR_FINISHED;
}
@@ -320,15 +320,15 @@ static int unpack_item_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED
{
uiPopupMenu *pup;
uiLayout *layout;
-
+
pup = UI_popup_menu_begin(C, IFACE_("Unpack"), ICON_NONE);
layout = UI_popup_menu_layout(pup);
-
+
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
uiItemsFullEnumO(layout, op->type->idname, "method", op->ptr->data, WM_OP_EXEC_REGION_WIN, 0);
-
+
UI_popup_menu_end(C, pup);
-
+
return OPERATOR_INTERFACE;
}
@@ -338,14 +338,14 @@ void FILE_OT_unpack_item(wmOperatorType *ot)
ot->name = "Unpack Item";
ot->idname = "FILE_OT_unpack_item";
ot->description = "Unpack this file to an external file";
-
+
/* api callbacks */
ot->exec = unpack_item_exec;
ot->invoke = unpack_item_invoke;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
-
+
/* properties */
RNA_def_enum(ot->srna, "method", unpack_item_method_items, PF_USE_LOCAL, "Method", "How to unpack");
RNA_def_string(ot->srna, "id_name", NULL, BKE_ST_MAXNAME, "ID name", "Name of ID block to unpack");
@@ -364,7 +364,7 @@ static int make_paths_relative_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- BKE_bpath_relative_convert(bmain, bmain->name, op->reports);
+ BKE_bpath_relative_convert(bmain, BKE_main_blendfile_path(bmain), op->reports);
/* redraw everything so any changed paths register */
WM_main_add_notifier(NC_WINDOW, NULL);
@@ -378,7 +378,7 @@ void FILE_OT_make_paths_relative(wmOperatorType *ot)
ot->name = "Make All Paths Relative";
ot->idname = "FILE_OT_make_paths_relative";
ot->description = "Make all paths to external files relative to current .blend";
-
+
/* api callbacks */
ot->exec = make_paths_relative_exec;
@@ -397,7 +397,7 @@ static int make_paths_absolute_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- BKE_bpath_absolute_convert(bmain, bmain->name, op->reports);
+ BKE_bpath_absolute_convert(bmain, BKE_main_blendfile_path(bmain), op->reports);
/* redraw everything so any changed paths register */
WM_main_add_notifier(NC_WINDOW, NULL);
@@ -411,7 +411,7 @@ void FILE_OT_make_paths_absolute(wmOperatorType *ot)
ot->name = "Make All Paths Absolute";
ot->idname = "FILE_OT_make_paths_absolute";
ot->description = "Make all paths to external files absolute";
-
+
/* api callbacks */
ot->exec = make_paths_absolute_exec;
@@ -427,7 +427,7 @@ static int report_missing_files_exec(bContext *C, wmOperator *op)
/* run the missing file check */
BKE_bpath_missing_files_check(bmain, op->reports);
-
+
return OPERATOR_FINISHED;
}
@@ -437,7 +437,7 @@ void FILE_OT_report_missing_files(wmOperatorType *ot)
ot->name = "Report Missing Files";
ot->idname = "FILE_OT_report_missing_files";
ot->description = "Report all missing external files";
-
+
/* api callbacks */
ot->exec = report_missing_files_exec;
@@ -462,7 +462,7 @@ static int find_missing_files_exec(bContext *C, wmOperator *op)
static int find_missing_files_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
/* XXX file open button text "Find Missing Files" */
- WM_event_add_fileselect(C, op);
+ WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
}
@@ -472,7 +472,7 @@ void FILE_OT_find_missing_files(wmOperatorType *ot)
ot->name = "Find Missing Files";
ot->idname = "FILE_OT_find_missing_files";
ot->description = "Try to find missing external files";
-
+
/* api callbacks */
ot->exec = find_missing_files_exec;
ot->invoke = find_missing_files_invoke;
@@ -490,10 +490,10 @@ void FILE_OT_find_missing_files(wmOperatorType *ot)
/********************* report box operator *********************/
-/* Hard to decide whether to keep this as an operator,
- * or turn it into a hardcoded ui control feature,
+/* Hard to decide whether to keep this as an operator,
+ * or turn it into a hardcoded ui control feature,
* handling TIMER events for all regions in interface_handlers.c
- * Not sure how good that is to be accessing UI data from
+ * Not sure how good that is to be accessing UI data from
* inactive regions, so use this for now. --matt
*/
@@ -513,7 +513,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co
float neutral_gray = 0.6;
float timeout = 0.0, color_timeout = 0.0;
int send_note = 0;
-
+
/* escape if not our timer */
if ((reports->reporttimer == NULL) ||
(reports->reporttimer != event->customdata) ||
@@ -524,17 +524,17 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co
}
rti = (ReportTimerInfo *)reports->reporttimer->customdata;
-
+
timeout = (report->type & RPT_ERROR_ALL) ? ERROR_TIMEOUT : INFO_TIMEOUT;
color_timeout = (report->type & RPT_ERROR_ALL) ? ERROR_COLOR_TIMEOUT : INFO_COLOR_TIMEOUT;
-
+
/* clear the report display after timeout */
if ((float)reports->reporttimer->duration > timeout) {
WM_event_remove_timer(wm, NULL, reports->reporttimer);
reports->reporttimer = NULL;
-
+
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL);
-
+
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
}
@@ -558,14 +558,14 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co
rti->grayscale = 0.75;
rti->widthfac = 1.0;
}
-
+
progress = (float)reports->reporttimer->duration / timeout;
color_progress = (float)reports->reporttimer->duration / color_timeout;
-
+
/* save us from too many draws */
if (color_progress <= 1.0f) {
send_note = 1;
-
+
/* fade colors out sharply according to progress through fade-out duration */
interp_v3_v3v3(rti->col, rti->col, neutral_col, color_progress);
rti->grayscale = interpf(neutral_gray, rti->grayscale, color_progress);
@@ -577,11 +577,11 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co
rti->widthfac = 1.0f - rti->widthfac;
send_note = 1;
}
-
+
if (send_note) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL);
}
-
+
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
}
@@ -591,13 +591,13 @@ void INFO_OT_reports_display_update(wmOperatorType *ot)
ot->name = "Update Reports Display";
ot->idname = "INFO_OT_reports_display_update";
ot->description = "Update the display of reports in Blender UI (internal use)";
-
+
/* api callbacks */
ot->invoke = update_reports_display_invoke;
-
+
/* flags */
ot->flag = 0;
-
+
/* properties */
}
diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c
index d2bfcfa76df..481c9031a73 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -70,7 +70,7 @@ typedef struct SceneStats {
int totface, totfacesel;
int totbone, totbonesel;
int totobj, totobjsel;
- int totlamp, totlampsel;
+ int totlamp, totlampsel;
int tottri;
char infostr[MAX_INFO_LEN];
@@ -154,10 +154,10 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
stats->totvert = em->bm->totvert;
stats->totvertsel = em->bm->totvertsel;
-
+
stats->totedge = em->bm->totedge;
stats->totedgesel = em->bm->totedgesel;
-
+
stats->totface = em->bm->totface;
stats->totfacesel = em->bm->totfacesel;
@@ -170,15 +170,15 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
stats->totbone++;
-
+
if ((ebo->flag & BONE_CONNECTED) && ebo->parent)
stats->totvert--;
-
+
if (ebo->flag & BONE_TIPSEL)
stats->totvertsel++;
if (ebo->flag & BONE_ROOTSEL)
stats->totvertsel++;
-
+
if (ebo->flag & BONE_SELECTED) stats->totbonesel++;
/* if this is a connected child and it's parent is being moved, remove our root */
@@ -227,7 +227,7 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
/* MetaBall Edit */
MetaBall *mball = obedit->data;
MetaElem *ml;
-
+
for (ml = mball->editelems->first; ml; ml = ml->next) {
stats->totvert++;
if (ml->flag & SELECT) stats->totvertsel++;
@@ -241,7 +241,7 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
int a;
bp = editlatt->def;
-
+
a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw;
while (a--) {
stats->totvert++;
@@ -319,7 +319,7 @@ static void stats_dupli_object(Base *base, Object *ob, SceneStats *stats)
stats_dupli_object_group_doit(collection, stats, psys, totgroup, &cur);
}
}
-
+
stats_object(ob, base->flag & BASE_SELECTED, 1, stats);
stats->totobj++;
}
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index f9336b45196..65b3c7bb9fd 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -67,7 +67,7 @@ static SpaceLink *info_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen
{
ARegion *ar;
SpaceInfo *sinfo;
-
+
sinfo = MEM_callocN(sizeof(SpaceInfo), "initinfo");
sinfo->spacetype = SPACE_INFO;
@@ -75,17 +75,17 @@ static SpaceLink *info_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for info");
-
+
BLI_addtail(&sinfo->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_TOP;
-
+
/* main region */
ar = MEM_callocN(sizeof(ARegion), "main region for info");
-
+
BLI_addtail(&sinfo->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
-
+
/* keep in sync with console */
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
ar->v2d.align |= V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y; /* align bottom left */
@@ -96,15 +96,15 @@ static SpaceLink *info_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
//ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM);
-
+
return (SpaceLink *)sinfo;
}
/* not spacelink itself */
static void info_free(SpaceLink *UNUSED(sl))
-{
+{
// SpaceInfo *sinfo = (SpaceInfo *) sl;
-
+
}
@@ -117,9 +117,9 @@ static void info_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
static SpaceLink *info_duplicate(SpaceLink *sl)
{
SpaceInfo *sinfon = MEM_dupallocN(sl);
-
+
/* clear or remove stuff from old */
-
+
return (SpaceLink *)sinfon;
}
@@ -132,7 +132,7 @@ static void info_main_region_init(wmWindowManager *wm, ARegion *ar)
/* force it on init, for old files, until it becomes config */
ar->v2d.scroll = (V2D_SCROLL_RIGHT);
-
+
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
/* own keymap */
@@ -162,7 +162,7 @@ static void info_main_region_draw(const bContext *C, ARegion *ar)
/* quick way to avoid drawing if not bug enough */
if (ar->winy < 16)
return;
-
+
info_textview_update_rect(C, ar);
/* worlks best with no view2d matrix set */
@@ -172,7 +172,7 @@ static void info_main_region_draw(const bContext *C, ARegion *ar)
/* reset view matrix */
UI_view2d_view_restore(C);
-
+
/* scrollers */
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP);
UI_view2d_scrollers_draw(C, v2d, scrollers);
@@ -187,7 +187,7 @@ static void info_operatortypes(void)
WM_operatortype_append(FILE_OT_unpack_all);
WM_operatortype_append(FILE_OT_unpack_item);
WM_operatortype_append(FILE_OT_unpack_libraries);
-
+
WM_operatortype_append(FILE_OT_make_paths_relative);
WM_operatortype_append(FILE_OT_make_paths_absolute);
WM_operatortype_append(FILE_OT_report_missing_files);
@@ -207,13 +207,13 @@ static void info_operatortypes(void)
static void info_keymap(struct wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_find(keyconf, "Window", 0, 0);
-
+
WM_keymap_verify_item(keymap, "INFO_OT_reports_display_update", TIMERREPORT, KM_ANY, KM_ANY, 0);
/* info space */
keymap = WM_keymap_find(keyconf, "Info", SPACE_INFO, 0);
-
-
+
+
/* report selection */
WM_keymap_add_item(keymap, "INFO_OT_select_pick", SELECTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "INFO_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
@@ -284,7 +284,7 @@ static void info_header_listener(
ED_region_tag_redraw(ar);
break;
}
-
+
}
static void info_header_region_message_subscribe(
@@ -337,17 +337,17 @@ void ED_spacetype_info(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype info");
ARegionType *art;
-
+
st->spaceid = SPACE_INFO;
strncpy(st->name, "Info", BKE_ST_MAXNAME);
-
+
st->new = info_new;
st->free = info_free;
st->init = info_init;
st->duplicate = info_duplicate;
st->operatortypes = info_operatortypes;
st->keymap = info_keymap;
-
+
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype info region");
art->regionid = RGN_TYPE_WINDOW;
@@ -358,20 +358,20 @@ void ED_spacetype_info(void)
art->listener = info_main_region_listener;
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype info region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
-
+
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
art->listener = info_header_listener;
art->message_subscribe = info_header_region_message_subscribe;
art->init = info_header_region_init;
art->draw = info_header_region_draw;
-
+
BLI_addhead(&st->regiontypes, art);
-
+
recent_files_menu_register();
BKE_spacetype_register(st);
diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c
index 3f35cadd820..85de70c020f 100644
--- a/source/blender/editors/space_info/textview.c
+++ b/source/blender/editors/space_info/textview.c
@@ -63,7 +63,7 @@ typedef struct ConsoleDrawContext {
int ymin, ymax;
int *xy; // [2]
int *sel; // [2]
- int *pos_pick; // bottom of view == 0, top of file == combine chars, end of line is lower then start.
+ int *pos_pick; // bottom of view == 0, top of file == combine chars, end of line is lower then start.
const int *mval; // [2]
int draw;
} ConsoleDrawContext;
@@ -181,14 +181,14 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
size_t len = str_len - initial_offset;
const char *s = str + initial_offset;
int i;
-
+
int sel_orig[2];
copy_v2_v2_int(sel_orig, cdc->sel);
/* invert and swap for wrapping */
cdc->sel[0] = str_len - sel_orig[1];
cdc->sel[1] = str_len - sel_orig[0];
-
+
if (bg) {
Gwn_VertFormat *format = immVertexFormat();
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
@@ -219,7 +219,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
BLF_position(cdc->font_id, cdc->xy[0], cdc->lofs + cdc->xy[1], 0);
BLF_draw_mono(cdc->font_id, s, len, cdc->cwidth);
-
+
if (cdc->sel[0] != cdc->sel[1]) {
console_step_sel(cdc, len);
/* BLF_color3ub(cdc->font_id, 0, 255, 0); // debug */
@@ -227,7 +227,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
}
cdc->xy[1] += cdc->lheight;
-
+
/* check if were out of view bounds */
if (cdc->xy[1] > cdc->ymax) {
MEM_freeN(offsets);
@@ -254,7 +254,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
BLF_color3ubv(cdc->font_id, fg);
BLF_position(cdc->font_id, cdc->xy[0], cdc->lofs + cdc->xy[1], 0);
BLF_draw_mono(cdc->font_id, str, str_len, cdc->cwidth);
-
+
if (cdc->sel[0] != cdc->sel[1]) {
int isel[2];
diff --git a/source/blender/editors/space_info/textview.h b/source/blender/editors/space_info/textview.h
index 2f9e518ed47..55f69fbf444 100644
--- a/source/blender/editors/space_info/textview.h
+++ b/source/blender/editors/space_info/textview.h
@@ -37,7 +37,7 @@ typedef struct TextViewContext {
int winx;
int ymin, ymax;
-
+
/* callbacks */
int (*begin)(struct TextViewContext *tvc);
void (*end)(struct TextViewContext *tvc);
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index 9551a1cf362..a26e6b0280e 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation, Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
@@ -87,27 +87,27 @@ bool nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_p
ListBase anim_data = {NULL, NULL};
short found = 0; /* not bool, since we need to indicate "found but not ideal" status */
int filter;
-
- /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools)
+
+ /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools)
* to work correctly is able to be correctly retrieved. There's no point showing empty panels?
*/
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0)
return false;
-
- /* extract list of active channel(s), of which we should only take the first one
+
+ /* extract list of active channel(s), of which we should only take the first one
* - we need the channels flag to get the active AnimData block when there are no NLA Tracks
*/
// XXX: double-check active!
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
switch (ale->type) {
case ANIMTYPE_NLATRACK: /* NLA Track - The primary data type which should get caught */
{
NlaTrack *nlt = (NlaTrack *)ale->data;
AnimData *adt = ale->adt;
-
+
/* found it, now set the pointers */
if (adt_ptr) {
/* AnimData pointer */
@@ -122,7 +122,7 @@ bool nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_p
NlaStrip *strip = BKE_nlastrip_find_active(nlt);
RNA_pointer_create(ale->id, &RNA_NlaStrip, strip, strip_ptr);
}
-
+
found = 1;
break;
}
@@ -149,7 +149,7 @@ bool nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_p
/* for these channels, we only do AnimData */
if (ale->adt && adt_ptr) {
ID *id;
-
+
if ((ale->data == NULL) || (ale->type == ANIMTYPE_OBJECT)) {
/* ale->data is not an ID block! */
id = ale->id;
@@ -158,13 +158,13 @@ bool nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_p
/* ale->data is always the proper ID block we need, but ale->id may not be (i.e. for textures) */
id = (ID *)ale->data;
}
-
+
/* AnimData pointer */
if (adt_ptr) {
RNA_pointer_create(id, &RNA_AnimData, ale->adt, adt_ptr);
}
-
- /* set found status to -1, since setting to 1 would break the loop
+
+ /* set found status to -1, since setting to 1 would break the loop
* and potentially skip an active NLA-Track in some cases...
*/
found = -1;
@@ -172,14 +172,14 @@ bool nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_p
break;
}
}
-
+
if (found > 0)
break;
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
return (found != 0);
}
@@ -212,12 +212,12 @@ static int nla_strip_actclip_panel_poll(const bContext *C, PanelType *UNUSED(pt)
{
PointerRNA ptr;
NlaStrip *strip;
-
+
if (!nla_panel_context(C, NULL, NULL, &ptr))
return 0;
if (ptr.data == NULL)
return 0;
-
+
strip = ptr.data;
return (strip->type == NLASTRIP_TYPE_CLIP);
}
@@ -226,17 +226,17 @@ static int nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt))
{
PointerRNA ptr;
NlaStrip *strip;
-
+
if (!nla_panel_context(C, NULL, NULL, &ptr))
return 0;
if (ptr.data == NULL)
return 0;
-
+
strip = ptr.data;
-
+
if (strip->type == NLASTRIP_TYPE_SOUND)
return 0;
-
+
return 1;
}
@@ -250,53 +250,53 @@ static void nla_panel_animdata(const bContext *C, Panel *pa)
uiLayout *layout = pa->layout;
uiLayout *row;
uiBlock *block;
-
+
/* check context and also validity of pointer */
if (!nla_panel_context(C, &adt_ptr, NULL, NULL))
return;
/* adt = adt_ptr.data; */
-
+
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
-
+
/* AnimData Source Properties ----------------------------------- */
-
- /* icon + id-block name of block where AnimData came from to prevent
+
+ /* icon + id-block name of block where AnimData came from to prevent
* accidentally changing the properties of the wrong action
*/
if (adt_ptr.id.data) {
ID *id = adt_ptr.id.data;
PointerRNA id_ptr;
-
+
RNA_id_pointer_create(id, &id_ptr);
-
+
/* ID-block name > AnimData */
row = uiLayoutRow(layout, true);
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT);
-
+
uiItemL(row, id->name + 2, RNA_struct_ui_icon(id_ptr.type)); /* id-block (src) */
uiItemL(row, "", VICO_SMALL_TRI_RIGHT_VEC); /* expander */
uiItemL(row, IFACE_("Animation Data"), ICON_ANIM_DATA); /* animdata */
-
+
uiItemS(layout);
}
-
+
/* Active Action Properties ------------------------------------- */
/* action */
row = uiLayoutRow(layout, true);
uiTemplateID(
row, (bContext *)C, &adt_ptr, "action",
"ACTION_OT_new", NULL, "NLA_OT_action_unlink", UI_TEMPLATE_ID_FILTER_ALL);
-
+
/* extrapolation */
row = uiLayoutRow(layout, true);
uiItemR(row, &adt_ptr, "action_extrapolation", 0, NULL, ICON_NONE);
-
+
/* blending */
row = uiLayoutRow(layout, true);
uiItemR(row, &adt_ptr, "action_blend_type", 0, NULL, ICON_NONE);
-
+
/* influence */
row = uiLayoutRow(layout, true);
uiItemR(row, &adt_ptr, "action_influence", 0, NULL, ICON_NONE);
@@ -309,14 +309,14 @@ static void nla_panel_track(const bContext *C, Panel *pa)
uiLayout *layout = pa->layout;
uiLayout *row;
uiBlock *block;
-
+
/* check context and also validity of pointer */
if (!nla_panel_context(C, NULL, &nlt_ptr, NULL))
return;
-
+
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
-
+
/* Info - Active NLA-Context:Track ---------------------- */
row = uiLayoutRow(layout, true);
uiItemR(row, &nlt_ptr, "name", 0, NULL, ICON_NLA);
@@ -330,41 +330,41 @@ static void nla_panel_properties(const bContext *C, Panel *pa)
uiLayout *column, *row, *sub;
uiBlock *block;
short showEvalProps = 1;
-
+
if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
return;
-
+
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
-
+
/* Strip Properties ------------------------------------- */
/* strip type */
row = uiLayoutColumn(layout, true);
uiItemR(row, &strip_ptr, "name", 0, NULL, ICON_NLA); // XXX icon?
uiItemR(row, &strip_ptr, "type", 0, NULL, ICON_NONE);
-
+
/* strip extents */
column = uiLayoutColumn(layout, true);
uiItemL(column, IFACE_("Strip Extents:"), ICON_NONE);
uiItemR(column, &strip_ptr, "frame_start", 0, NULL, ICON_NONE);
uiItemR(column, &strip_ptr, "frame_end", 0, NULL, ICON_NONE);
-
+
/* Evaluation-Related Strip Properties ------------------ */
-
+
/* sound properties strips don't have these settings */
if (RNA_enum_get(&strip_ptr, "type") == NLASTRIP_TYPE_SOUND)
showEvalProps = 0;
-
+
/* only show if allowed to... */
if (showEvalProps) {
/* extrapolation */
row = uiLayoutRow(layout, true);
uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE);
-
+
/* blending */
row = uiLayoutRow(layout, true);
uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE);
-
+
/* blend in/out + autoblending
* - blend in/out can only be set when autoblending is off
*/
@@ -376,7 +376,7 @@ static void nla_panel_properties(const bContext *C, Panel *pa)
uiLayoutSetActive(sub, RNA_boolean_get(&strip_ptr, "use_auto_blend") == false);
uiItemR(sub, &strip_ptr, "blend_in", 0, NULL, ICON_NONE);
uiItemR(sub, &strip_ptr, "blend_out", 0, NULL, ICON_NONE);
-
+
/* settings */
column = uiLayoutColumn(layout, true);
uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time")));
@@ -398,27 +398,27 @@ static void nla_panel_actclip(const bContext *C, Panel *pa)
/* check context and also validity of pointer */
if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
return;
-
+
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
-
+
/* Strip Properties ------------------------------------- */
/* action pointer */
row = uiLayoutRow(layout, true);
uiItemR(row, &strip_ptr, "action", 0, NULL, ICON_ACTION);
-
+
/* action extents */
// XXX custom names were used here (to avoid the prefixes)... probably not necessary in future?
column = uiLayoutColumn(layout, true);
uiItemL(column, IFACE_("Action Extents:"), ICON_NONE);
uiItemR(column, &strip_ptr, "action_frame_start", 0, IFACE_("Start Frame"), ICON_NONE);
uiItemR(column, &strip_ptr, "action_frame_end", 0, IFACE_("End Frame"), ICON_NONE);
-
+
// XXX: this layout may actually be too abstract and confusing, and may be better using standard column layout
row = uiLayoutRow(layout, false);
uiItemR(row, &strip_ptr, "use_sync_length", 0, IFACE_("Sync Length"), ICON_NONE);
uiItemO(row, IFACE_("Now"), ICON_FILE_REFRESH, "NLA_OT_action_sync_length");
-
+
/* action usage */
column = uiLayoutColumn(layout, true);
uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_time") == false);
@@ -438,13 +438,13 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa)
/* check context and also validity of pointer */
if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
return;
-
+
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, &strip_ptr, "use_animated_influence", 0, NULL, ICON_NONE);
-
+
sub = uiLayoutColumn(col, true);
uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_influence"));
uiItemR(sub, &strip_ptr, "influence", 0, NULL, ICON_NONE);
@@ -472,28 +472,28 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa)
if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
return;
strip = strip_ptr.data;
-
+
block = uiLayoutGetBlock(pa->layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
-
+
/* 'add modifier' button at top of panel */
{
row = uiLayoutRow(pa->layout, false);
block = uiLayoutGetBlock(row);
-
+
// FIXME: we need to set the only-active property so that this will only add modifiers for the active strip (not all selected)
uiItemMenuEnumO(row, (bContext *)C, "NLA_OT_fmodifier_add", "type", IFACE_("Add Modifier"), ICON_NONE);
-
+
/* copy/paste (as sub-row) */
row = uiLayoutRow(row, true);
uiItemO(row, "", ICON_COPYDOWN, "NLA_OT_fmodifier_copy");
uiItemO(row, "", ICON_PASTEDOWN, "NLA_OT_fmodifier_paste");
}
-
+
/* draw each modifier */
for (fcm = strip->modifiers.first; fcm; fcm = fcm->next) {
col = uiLayoutColumn(pa->layout, true);
-
+
ANIM_uiTemplate_fmodifier_draw(col, strip_ptr.id.data, &strip->modifiers, fcm);
}
}
@@ -565,7 +565,7 @@ static int nla_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = nla_has_buttons_region(sa);
-
+
if (ar)
ED_region_toggle_hidden(C, ar);
@@ -577,7 +577,7 @@ void NLA_OT_properties(wmOperatorType *ot)
ot->name = "Properties";
ot->idname = "NLA_OT_properties";
ot->description = "Toggle the properties region visibility";
-
+
ot->exec = nla_properties_toggle_exec;
ot->poll = ED_operator_nla_active;
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index 1cc3d5142f5..d782fe4d7ef 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
* All rights reserved.
*
- *
+ *
* Contributor(s): Joshua Leung (major recode)
*
* ***** END GPL LICENSE BLOCK *****
@@ -80,26 +80,26 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
View2D *v2d = &ac->ar->v2d;
int notifierFlags = 0;
-
+
/* get the channel that was clicked on */
/* filter channels */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* get channel from index */
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
/* channel not found */
if (G.debug & G_DEBUG)
printf("Error: animation channel (index = %d) not found in mouse_anim_channels()\n", channel_index);
-
+
ANIM_animdata_freelist(&anim_data);
return 0;
}
-
+
/* action to take depends on what channel we've got */
// WARNING: must keep this in sync with the equivalent function in anim_channels_edit.c
switch (ale->type) {
@@ -107,7 +107,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
{
Scene *sce = (Scene *)ale->data;
AnimData *adt = sce->adt;
-
+
/* set selection status */
if (selectmode == SELECT_INVERT) {
/* swap select */
@@ -118,7 +118,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
sce->flag |= SCE_DS_SELECTED;
if (adt) adt->flag |= ADT_UI_SELECTED;
}
-
+
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
break;
}
@@ -128,14 +128,14 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
Base *base = (Base *)ale->data;
Object *ob = base->object;
AnimData *adt = ob->adt;
-
+
if (nlaedit_is_tweakmode_on(ac) == 0 && (base->flag & BASE_SELECTABLED)) {
/* set selection status */
if (selectmode == SELECT_INVERT) {
/* swap select */
ED_object_base_select(base, BA_INVERT);
BKE_scene_object_base_flag_sync_from_base(base);
-
+
if (adt) adt->flag ^= ADT_UI_SELECTED;
}
else {
@@ -146,19 +146,19 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
BKE_scene_object_base_flag_sync_from_base(b);
if (b->object->adt) b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
}
-
+
/* select object now */
ED_object_base_select(base, BA_SELECT);
BKE_scene_object_base_flag_sync_from_base(base);
if (adt) adt->flag |= ADT_UI_SELECTED;
}
-
+
/* change active object - regardless of whether it is now selected [T37883] */
ED_object_base_activate(C, base); /* adds notifier */
-
+
if ((adt) && (adt->flag & ADT_UI_SELECTED))
adt->flag |= ADT_UI_ACTIVE;
-
+
/* notifiers - channel was selected */
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
}
@@ -195,12 +195,12 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
ale->adt->flag |= ADT_UI_SELECTED;
}
-
+
/* set active? */
if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
ale->adt->flag |= ADT_UI_ACTIVE;
}
-
+
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
break;
}
@@ -209,7 +209,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
NlaTrack *nlt = (NlaTrack *)ale->data;
AnimData *adt = ale->adt;
short offset;
-
+
/* offset for start of channel (on LHS of channel-list) */
if (ale->id) {
/* special exception for materials and particles */
@@ -220,25 +220,25 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
}
else
offset = 0;
-
+
if (x >= (v2d->cur.xmax - NLACHANNEL_BUTTON_WIDTH)) {
/* toggle protection (only if there's a toggle there) */
nlt->flag ^= NLATRACK_PROTECTED;
-
+
/* notifier flags - channel was edited */
notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
}
else if (x >= (v2d->cur.xmax - 2 * NLACHANNEL_BUTTON_WIDTH)) {
/* toggle mute */
nlt->flag ^= NLATRACK_MUTED;
-
+
/* notifier flags - channel was edited */
notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
}
else if (x <= ((NLACHANNEL_BUTTON_WIDTH * 2) + offset)) {
/* toggle 'solo' */
BKE_nlatrack_solo_toggle(adt, nlt);
-
+
/* notifier flags - channel was edited */
notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
}
@@ -253,11 +253,11 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
nlt->flag |= NLATRACK_SELECTED;
}
-
+
/* if NLA-Track is selected now, make NLA-Track the 'active' one in the visible list */
if (nlt->flag & NLATRACK_SELECTED)
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nlt, ANIMTYPE_NLATRACK);
-
+
/* notifier flags - channel was selected */
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
}
@@ -266,7 +266,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
case ANIMTYPE_NLAACTION:
{
AnimData *adt = BKE_animdata_from_id(ale->id);
-
+
/* button region... */
if (x >= (v2d->cur.xmax - NLACHANNEL_BUTTON_WIDTH)) {
if (nlaedit_is_tweakmode_on(ac) == 0) {
@@ -279,13 +279,13 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
/* when in tweakmode, this button becomes the toggle for mapped editing */
adt->flag ^= ADT_NLA_EDIT_NOMAP;
}
-
+
/* changes to NLA-Action occurred */
notifierFlags |= ND_NLA_ACTCHANGE;
}
/* OR rest of name... */
else {
- /* NOTE: rest of NLA-Action name doubles for operating on the AnimData block
+ /* NOTE: rest of NLA-Action name doubles for operating on the AnimData block
* - this is useful when there's no clear divider, and makes more sense in
* the case of users trying to use this to change actions
* - in tweakmode, clicking here gets us out of tweakmode, as changing selection
@@ -296,7 +296,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
if (nlaedit_is_tweakmode_on(ac)) {
/* exit tweakmode immediately */
nlaedit_disable_tweakmode(ac, true);
-
+
/* changes to NLA-Action occurred */
notifierFlags |= ND_NLA_ACTCHANGE;
}
@@ -311,11 +311,11 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
adt->flag |= ADT_UI_SELECTED;
}
-
+
/* set active? */
if (adt->flag & ADT_UI_SELECTED)
adt->flag |= ADT_UI_ACTIVE;
-
+
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
}
}
@@ -326,10 +326,10 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
printf("Error: Invalid channel type in mouse_nla_channels()\n");
break;
}
-
+
/* free channels */
ANIM_animdata_freelist(&anim_data);
-
+
/* return the notifier-flags set */
return notifierFlags;
}
@@ -347,55 +347,55 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEv
int notifierFlags = 0;
short selectmode;
float x, y;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get useful pointers from animation context data */
snla = (SpaceNla *)ac.sl;
ar = ac.ar;
v2d = &ar->v2d;
-
+
/* select mode is either replace (deselect all, then add) or add/extend */
if (RNA_boolean_get(op->ptr, "extend"))
selectmode = SELECT_INVERT;
else
selectmode = SELECT_REPLACE;
-
- /* figure out which channel user clicked in
+
+ /* figure out which channel user clicked in
* Note: although channels technically start at y= NLACHANNEL_FIRST, we need to adjust by half a channel's height
* so that the tops of channels get caught ok. Since NLACHANNEL_FIRST is really NLACHANNEL_HEIGHT, we simply use
* NLACHANNEL_HEIGHT_HALF.
*/
UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y);
UI_view2d_listview_view_to_cell(v2d, NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP(snla), 0, (float)NLACHANNEL_HEIGHT_HALF(snla), x, y, NULL, &channel_index);
-
+
/* handle mouse-click in the relevant channel then */
notifierFlags = mouse_nla_channels(C, &ac, x, channel_index, selectmode);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void NLA_OT_channels_click(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Mouse Click on NLA Channels";
ot->idname = "NLA_OT_channels_click";
ot->description = "Handle clicks to select NLA channels";
-
+
/* api callbacks */
ot->invoke = nlachannels_mouseclick_invoke;
ot->poll = ED_operator_nla_active;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
-
+
/* props */
prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
@@ -411,15 +411,15 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
bAnimContext ac;
AnimData *adt = NULL;
int channel_index = RNA_int_get(op->ptr, "channel_index");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get anim-channel to use (or more specifically, the animdata block behind it) */
if (channel_index == -1) {
PointerRNA adt_ptr = {{NULL}};
-
+
/* active animdata block */
if (nla_panel_context(C, &adt_ptr, NULL, NULL) == 0 || (adt_ptr.data == NULL)) {
BKE_report(op->reports, RPT_ERROR, "No active AnimData block to use "
@@ -435,11 +435,11 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter channels */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* get channel from index */
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
@@ -452,14 +452,14 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
ANIM_animdata_freelist(&anim_data);
return OPERATOR_CANCELLED;
}
-
+
/* grab AnimData from the channel */
adt = ale->adt;
-
+
/* we don't need anything here anymore, so free it all */
ANIM_animdata_freelist(&anim_data);
}
-
+
/* double-check that we are free to push down here... */
if (adt == NULL) {
BKE_report(op->reports, RPT_WARNING, "Internal Error - AnimData block is not valid");
@@ -478,7 +478,7 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
/* 'push-down' action - only usable when not in TweakMode */
BKE_nla_action_pushdown(adt);
}
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
return OPERATOR_FINISHED;
@@ -490,14 +490,14 @@ void NLA_OT_action_pushdown(wmOperatorType *ot)
ot->name = "Push Down Action";
ot->idname = "NLA_OT_action_pushdown";
ot->description = "Push action down onto the top of the NLA stack as a new strip";
-
+
/* callbacks */
ot->exec = nlachannels_pushdown_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_int(ot->srna, "channel_index", -1, -1, INT_MAX, "Channel Index",
"Index of NLA action channel to perform pushdown operation on",
@@ -512,7 +512,7 @@ static int nla_action_unlink_poll(bContext *C)
if (ED_operator_nla_active(C)) {
return nla_panel_context(C, NULL, NULL, NULL);
}
-
+
/* something failed... */
return false;
}
@@ -521,22 +521,22 @@ static int nla_action_unlink_exec(bContext *C, wmOperator *op)
{
PointerRNA adt_ptr;
AnimData *adt;
-
+
/* check context and also validity of pointer */
if (!nla_panel_context(C, &adt_ptr, NULL, NULL))
return OPERATOR_CANCELLED;
-
+
/* get animdata */
adt = adt_ptr.data;
if (adt == NULL)
return OPERATOR_CANCELLED;
-
+
/* do unlinking */
if (adt && adt->action) {
bool force_delete = RNA_boolean_get(op->ptr, "force_delete");
ED_animedit_unlink_action(C, adt_ptr.id.data, adt, adt->action, op->reports, force_delete);
}
-
+
return OPERATOR_FINISHED;
}
@@ -550,19 +550,19 @@ static int nla_action_unlink_invoke(bContext *C, wmOperator *op, const wmEvent *
void NLA_OT_action_unlink(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Unlink Action";
ot->idname = "NLA_OT_action_unlink";
ot->description = "Unlink this action from the active action slot (and/or exit Tweak Mode)";
-
+
/* callbacks */
ot->invoke = nla_action_unlink_invoke;
ot->exec = nla_action_unlink_exec;
ot->poll = nla_action_unlink_poll;
-
+
/* properties */
- prop = RNA_def_boolean(ot->srna, "force_delete", false, "Force Delete",
+ prop = RNA_def_boolean(ot->srna, "force_delete", false, "Force Delete",
"Clear Fake User and remove copy stashed in this datablock's NLA stack");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
@@ -578,17 +578,17 @@ bool nlaedit_add_tracks_existing(bAnimContext *ac, bool above_sel)
int filter;
AnimData *lastAdt = NULL;
bool added = false;
-
+
/* get a list of the (selected) NLA Tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* add tracks... */
for (ale = anim_data.first; ale; ale = ale->next) {
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
AnimData *adt = ale->adt;
-
+
/* check if just adding a new track above this one,
* or whether we're adding a new one to the top of the stack that this one belongs to
*/
@@ -605,10 +605,10 @@ bool nlaedit_add_tracks_existing(bAnimContext *ac, bool above_sel)
}
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
return added;
}
@@ -619,18 +619,18 @@ bool nlaedit_add_tracks_empty(bAnimContext *ac)
bAnimListElem *ale;
int filter;
bool added = false;
-
+
/* get a list of the selected AnimData blocks in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* check if selected AnimData blocks are empty, and add tracks if so... */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ale->adt;
-
+
/* sanity check */
BLI_assert(adt->flag & ADT_UI_SELECTED);
-
+
/* ensure it is empty */
if (BLI_listbase_is_empty(&adt->nla_tracks)) {
/* add new track to this AnimData block then */
@@ -638,10 +638,10 @@ bool nlaedit_add_tracks_empty(bAnimContext *ac)
added = true;
}
}
-
+
/* cleanup */
ANIM_animdata_freelist(&anim_data);
-
+
return added;
}
@@ -652,20 +652,20 @@ static int nlaedit_add_tracks_exec(bContext *C, wmOperator *op)
bAnimContext ac;
bool above_sel = RNA_boolean_get(op->ptr, "above_selected");
bool op_done = false;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* perform adding in two passes - existing first so that we don't double up for empty */
op_done |= nlaedit_add_tracks_existing(&ac, above_sel);
op_done |= nlaedit_add_tracks_empty(&ac);
-
+
/* done? */
if (op_done) {
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -673,7 +673,7 @@ static int nlaedit_add_tracks_exec(bContext *C, wmOperator *op)
/* failed to add any tracks */
BKE_report(op->reports, RPT_WARNING,
"Select an existing NLA Track or an empty action line first");
-
+
/* not done */
return OPERATOR_CANCELLED;
}
@@ -685,14 +685,14 @@ void NLA_OT_tracks_add(wmOperatorType *ot)
ot->name = "Add Tracks";
ot->idname = "NLA_OT_tracks_add";
ot->description = "Add NLA-Tracks above/after the selected tracks";
-
+
/* api callbacks */
ot->exec = nlaedit_add_tracks_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "above_selected", 0, "Above Selected", "Add a new NLA Track above every existing selected one");
}
@@ -703,42 +703,42 @@ void NLA_OT_tracks_add(wmOperatorType *ot)
static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the AnimData blocks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* delete tracks */
for (ale = anim_data.first; ale; ale = ale->next) {
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
AnimData *adt = ale->adt;
-
+
/* if track is currently 'solo', then AnimData should have its
* 'has solo' flag disabled
*/
if (nlt->flag & NLATRACK_SOLO)
adt->flag &= ~ADT_NLA_SOLO_TRACK;
-
+
/* call delete on this track - deletes all strips too */
BKE_nlatrack_free(&adt->nla_tracks, nlt);
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -749,11 +749,11 @@ void NLA_OT_tracks_delete(wmOperatorType *ot)
ot->name = "Delete Tracks";
ot->idname = "NLA_OT_tracks_delete";
ot->description = "Delete selected NLA-Tracks and the strips they contain";
-
+
/* api callbacks */
ot->exec = nlaedit_delete_tracks_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -762,10 +762,10 @@ void NLA_OT_tracks_delete(wmOperatorType *ot)
/* AnimData Related Operators */
/* ******************** Include Objects Operator ***************************** */
-/* Include selected objects in NLA Editor, by giving them AnimData blocks
+/* Include selected objects in NLA Editor, by giving them AnimData blocks
* NOTE: This doesn't help for non-object AnimData, where we do not have any effective
* selection mechanism in place. Unfortunately, this means that non-object AnimData
- * once again becomes a second-class citizen here. However, at least for the most
+ * once again becomes a second-class citizen here. However, at least for the most
* common use case, we now have a nice shortcut again.
*/
@@ -773,28 +773,28 @@ static int nlaedit_objects_add_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
SpaceNla *snla;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* ensure that filters are set so that the effect will be immediately visible */
snla = (SpaceNla *)ac.sl;
if (snla && snla->ads) {
snla->ads->filterflag &= ~ADS_FILTER_NLA_NOACT;
}
-
- /* operate on selected objects... */
+
+ /* operate on selected objects... */
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
{
/* ensure that object has AnimData... that's all */
BKE_animdata_add_id(&ob->id);
}
CTX_DATA_END;
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -805,11 +805,11 @@ void NLA_OT_selected_objects_add(wmOperatorType *ot)
ot->name = "Include Selected Objects";
ot->idname = "NLA_OT_selected_objects_add";
ot->description = "Make selected objects appear in NLA Editor by adding Animation Data";
-
+
/* api callbacks */
ot->exec = nlaedit_objects_add_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index a7773aaaed5..3f1ab059a91 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
* All rights reserved.
*
- *
+ *
* Contributor(s): Joshua Leung (major recode)
*
* ***** END GPL LICENSE BLOCK *****
@@ -74,7 +74,7 @@
/* Action-Line ---------------------- */
-/* get colors for drawing Action-Line
+/* get colors for drawing Action-Line
* NOTE: color returned includes fine-tuned alpha!
*/
void nla_action_get_color(AnimData *adt, bAction *act, float color[4])
@@ -93,7 +93,7 @@ void nla_action_get_color(AnimData *adt, bAction *act, float color[4])
UI_GetThemeColor4fv(TH_ANIM_INACTIVE, color);
}
}
-
+
/* when an NLA track is tagged "solo", action doesn't contribute, so shouldn't be as prominent */
if (adt && (adt->flag & ADT_NLA_SOLO_TRACK))
color[3] *= 0.15f;
@@ -111,8 +111,8 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa
if (ELEM(NULL, act, keys.first))
return;
- /* draw a darkened region behind the strips
- * - get and reset the background color, this time without the alpha to stand out better
+ /* draw a darkened region behind the strips
+ * - get and reset the background color, this time without the alpha to stand out better
* (amplified alpha is used instead)
*/
float color[4];
@@ -213,7 +213,7 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax
static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc)
{
glLineWidth(2.0f);
-
+
if (strip->type == NLASTRIP_TYPE_CLIP) {
/* try not to be too conspicuous, while being visible enough when transforming */
int shade = (strip->flag & NLASTRIP_FLAG_SELECT) ? -60 : -40;
@@ -231,7 +231,7 @@ static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc)
}
}
}
-
+
glLineWidth(1.0f);
}
@@ -303,18 +303,18 @@ static void nla_strip_get_color_inside(AnimData *adt, NlaStrip *strip, float col
static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, unsigned int pos)
{
const float yheight = ymaxc - yminc;
-
+
immUniformColor3f(0.7f, 0.7f, 0.7f);
-
+
/* draw with AA'd line */
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
-
+
/* influence -------------------------- */
if (strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) {
FCurve *fcu = list_find_fcurve(&strip->fcurves, "influence", 0);
float cfra;
-
+
/* plot the curve (over the strip's main region) */
if (fcu) {
immBegin(GWN_PRIM_LINE_STRIP, abs((int)(strip->end - strip->start) + 1));
@@ -343,7 +343,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns
}
else
immVertex2f(pos, strip->start, ymaxc);
-
+
/* end of strip */
if (IS_EQF(strip->blendout, 0.0f) == 0) {
immVertex2f(pos, strip->end - strip->blendout, ymaxc);
@@ -367,14 +367,14 @@ static uint nla_draw_use_dashed_outlines(float color[4], bool muted)
/* Note that we use dashed shader here, and make it draw solid lines if not muted... */
uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
-
+
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
-
+
immUniform1i("num_colors", 0); /* Simple dashes. */
immUniformColor3fv(color);
-
+
/* line style: dotted for muted */
if (muted) {
/* dotted - and slightly thicker for readability of the dashes */
@@ -387,7 +387,7 @@ static uint nla_draw_use_dashed_outlines(float color[4], bool muted)
immUniform1f("dash_factor", 2.0f);
glLineWidth(1.0f);
}
-
+
return shdr_pos;
}
@@ -398,13 +398,13 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
const bool muted = ((nlt->flag & NLATRACK_MUTED) || (strip->flag & NLASTRIP_FLAG_MUTED));
float color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
uint shdr_pos;
-
+
/* get color of strip */
nla_strip_get_color_inside(adt, strip, color);
-
+
shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
+
/* draw extrapolation info first (as backdrop)
* - but this should only be drawn if track has some contribution
*/
@@ -415,9 +415,9 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
switch (strip->extendmode) {
/* since this does both sides, only do the 'before' side, and leave the rest to the next case */
- case NLASTRIP_EXTEND_HOLD:
- /* only need to draw here if there's no strip before since
- * it only applies in such a situation
+ case NLASTRIP_EXTEND_HOLD:
+ /* only need to draw here if there's no strip before since
+ * it only applies in such a situation
*/
if (strip->prev == NULL) {
/* set the drawing color to the color of the strip, but with very faint alpha */
@@ -429,12 +429,12 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
ATTR_FALLTHROUGH;
/* this only draws after the strip */
- case NLASTRIP_EXTEND_HOLD_FORWARD:
+ case NLASTRIP_EXTEND_HOLD_FORWARD:
/* only need to try and draw if the next strip doesn't occur immediately after */
if ((strip->next == NULL) || (IS_EQF(strip->next->start, strip->end) == 0)) {
/* set the drawing color to the color of the strip, but this time less faint */
immUniformColor3fvAlpha(color, 0.3f);
-
+
/* draw the rect to the next strip or the edge of the screen */
float x2 = strip->next ? strip->next->start : v2d->cur.xmax;
immRectf(shdr_pos, strip->end, yminc, x2, ymaxc);
@@ -461,7 +461,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
else {
/* strip is in disabled track - make less visible */
immUniformColor3fvAlpha(color, 0.1f);
-
+
glEnable(GL_BLEND);
immRectf(shdr_pos, strip->start, yminc, strip->end, ymaxc);
glDisable(GL_BLEND);
@@ -494,7 +494,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
color[0] = color[1] = color[2] = 0.0f; /* FIXME: or 1.0f ?? */
}
- /* draw outline
+ /* draw outline
* - dashed-line shader is loaded after this block
*/
if (muted) {
@@ -505,7 +505,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
else {
/* non-muted - draw solid, rounded outline */
UI_draw_roundbox_shade_x(false, strip->start, yminc, strip->end, ymaxc, 0.0, 0.0, 0.1, color);
-
+
/* restore current vertex format & program (roundbox trashes it) */
shdr_pos = nla_draw_use_dashed_outlines(color, muted);
}
@@ -537,7 +537,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
/* only draw first-level of child-strips, but don't draw any lines on the endpoints */
for (NlaStrip *cs = strip->strips.first; cs; cs = cs->next) {
- /* draw start-line if not same as end of previous (and only if not the first strip)
+ /* draw start-line if not same as end of previous (and only if not the first strip)
* - on upper half of strip
*/
if ((cs->prev) && IS_EQF(cs->prev->end, cs->start) == 0) {
@@ -569,7 +569,7 @@ static void nla_draw_strip_text(
char str[256];
size_t str_len;
char col[4];
-
+
/* just print the name and the range */
if (strip->flag & NLASTRIP_FLAG_TEMP_META) {
str_len = BLI_snprintf_rlen(str, sizeof(str), "%d) Temp-Meta", index);
@@ -577,7 +577,7 @@ static void nla_draw_strip_text(
else {
str_len = BLI_strncpy_rlen(str, strip->name, sizeof(str));
}
-
+
/* set text color - if colors (see above) are light, draw black text, otherwise draw white */
if (strip->flag & (NLASTRIP_FLAG_ACTIVE | NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_TWEAKUSER)) {
col[0] = col[1] = col[2] = 0;
@@ -585,14 +585,14 @@ static void nla_draw_strip_text(
else {
col[0] = col[1] = col[2] = 255;
}
-
+
/* text opacity depends on whether if there's a solo'd track, this isn't it */
if (non_solo == 0)
col[3] = 255;
else
col[3] = 128;
- /* set bounding-box for text
+ /* set bounding-box for text
* - padding of 2 'units' on either side
*/
/* TODO: make this centered? */
@@ -618,8 +618,8 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V
size_t numstr_len;
/* Always draw times above the strip, whereas sequencer drew below + above.
- * However, we should be fine having everything on top, since these tend to be
- * quite spaced out.
+ * However, we should be fine having everything on top, since these tend to be
+ * quite spaced out.
* - 1 dp is compromise between lack of precision (ints only, as per sequencer)
* while also preserving some accuracy, since we do use floats
*/
@@ -639,32 +639,32 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
View2D *v2d = &ar->v2d;
const float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
const float text_margin_x = (8 * UI_DPI_FAC) * pixelx;
-
+
/* build list of channels to draw */
ListBase anim_data = {NULL, NULL};
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* Update max-extent of channels here (taking into account scrollers):
* - this is done to allow the channel list to be scrollable, but must be done here
* to avoid regenerating the list again and/or also because channels list is drawn first
- * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for
+ * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for
* start of list offset, and the second is as a correction for the scrollers.
*/
int height = ((items * NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla) * 2));
-
- /* don't use totrect set, as the width stays the same
- * (NOTE: this is ok here, the configuration is pretty straightforward)
+
+ /* don't use totrect set, as the width stays the same
+ * (NOTE: this is ok here, the configuration is pretty straightforward)
*/
v2d->tot.ymin = (float)(-height);
-
+
/* loop through channels, and set up drawing depending on their type */
float y = (float)(-NLACHANNEL_HEIGHT(snla));
-
+
for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla));
const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla));
-
+
/* check if visible */
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
@@ -677,7 +677,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
int index;
-
+
/* draw each strip in the track (if visible) */
for (strip = nlt->strips.first, index = 1; strip; strip = strip->next, index++) {
if (BKE_nlastrip_within_bounds(strip, v2d->cur.xmin, v2d->cur.xmax)) {
@@ -686,13 +686,13 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
/* draw the visualization of the strip */
nla_draw_strip(snla, adt, nlt, strip, v2d, yminc, ymaxc);
-
+
/* add the text for this strip to the cache */
if (xminc < xmaxc) {
nla_draw_strip_text(adt, nlt, strip, index, v2d, xminc, xmaxc, yminc, ymaxc);
}
-
- /* if transforming strips (only real reason for temp-metas currently),
+
+ /* if transforming strips (only real reason for temp-metas currently),
* add to the cache the frame numbers of the strip's extents
*/
if (strip->flag & NLASTRIP_FLAG_TEMP_META)
@@ -723,7 +723,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
* but also slightly shorter for some more contrast when viewing the strips
*/
immRectf(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP);
-
+
/* draw 'embossed' lines above and below the strip for effect */
/* white base-lines */
glLineWidth(2.0f);
@@ -761,7 +761,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
/* adjust y-position for next one */
y -= NLACHANNEL_STEP(snla);
}
-
+
/* free tempolary channels */
ANIM_animdata_freelist(&anim_data);
}
@@ -774,40 +774,40 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
SpaceNla *snla = (SpaceNla *)ac->sl;
View2D *v2d = &ar->v2d;
float y = 0.0f;
size_t items;
-
+
/* build list of channels to draw */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* Update max-extent of channels here (taking into account scrollers):
* - this is done to allow the channel list to be scrollable, but must be done here
* to avoid regenerating the list again and/or also because channels list is drawn first
- * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for
+ * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for
* start of list offset, and the second is as a correction for the scrollers.
*/
int height = ((items * NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla) * 2));
- /* don't use totrect set, as the width stays the same
- * (NOTE: this is ok here, the configuration is pretty straightforward)
+ /* don't use totrect set, as the width stays the same
+ * (NOTE: this is ok here, the configuration is pretty straightforward)
*/
v2d->tot.ymin = (float)(-height);
/* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */
UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY);
-
+
/* draw channels */
{ /* first pass: just the standard GL-drawing for backdrop + text */
size_t channel_index = 0;
-
+
y = (float)(-NLACHANNEL_HEIGHT(snla));
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla));
float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla));
-
+
/* check if visible */
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
@@ -815,7 +815,7 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar)
/* draw all channels using standard channel-drawing API */
ANIM_channel_draw(ac, ale, yminc, ymaxc, channel_index);
}
-
+
/* adjust y-position for next one */
y -= NLACHANNEL_STEP(snla);
channel_index++;
@@ -824,18 +824,18 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar)
{ /* second pass: UI widgets */
uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
size_t channel_index = 0;
-
+
y = (float)(-NLACHANNEL_HEIGHT(snla));
-
+
/* set blending again, as may not be set in previous step */
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
-
+
/* loop through channels, and set up drawing depending on their type */
for (ale = anim_data.first; ale; ale = ale->next) {
const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla));
const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla));
-
+
/* check if visible */
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
@@ -843,18 +843,18 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar)
/* draw all channels using standard channel-drawing API */
ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index);
}
-
+
/* adjust y-position for next one */
y -= NLACHANNEL_STEP(snla);
channel_index++;
}
-
+
UI_block_end(C, block);
UI_block_draw(C, block);
-
+
glDisable(GL_BLEND);
}
-
+
/* free temporary channels */
ANIM_animdata_freelist(&anim_data);
}
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index c86e9872c0a..26ac06446c4 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
* All rights reserved.
*
- *
+ *
* Contributor(s): Joshua Leung (major recode)
*
* ***** END GPL LICENSE BLOCK *****
@@ -83,15 +83,15 @@ void ED_nla_postop_refresh(bAnimContext *ac)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
short filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT);
-
+
/* get blocks to work on */
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
/* performing auto-blending, extend-mode validation, etc. */
BKE_nla_validate_state(ale->data);
}
-
+
/* free temp memory */
ANIM_animdata_freelist(&anim_data);
}
@@ -100,62 +100,62 @@ void ED_nla_postop_refresh(bAnimContext *ac)
/* 'Special' Editing */
/* ******************** Tweak-Mode Operators ***************************** */
-/* 'Tweak mode' allows the action referenced by the active NLA-strip to be edited
- * as if it were the normal Active-Action of its AnimData block.
+/* 'Tweak mode' allows the action referenced by the active NLA-strip to be edited
+ * as if it were the normal Active-Action of its AnimData block.
*/
static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
const bool do_solo = RNA_boolean_get(op->ptr, "isolate_action");
bool ok = false;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the AnimData blocks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* if no blocks, popup error? */
if (BLI_listbase_is_empty(&anim_data)) {
BKE_report(op->reports, RPT_ERROR, "No AnimData blocks to enter tweak mode for");
return OPERATOR_CANCELLED;
}
-
+
/* for each AnimData block with NLA-data, try setting it in tweak-mode */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ale->data;
-
+
/* try entering tweakmode if valid */
ok |= BKE_nla_tweakmode_enter(adt);
-
+
/* mark the active track as being "solo"? */
if (do_solo && adt->actstrip) {
NlaTrack *nlt = BKE_nlatrack_find_tweaked(adt);
-
+
if (nlt && !(nlt->flag & NLATRACK_SOLO)) {
BKE_nlatrack_solo_toggle(adt, nlt);
}
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
- /* if we managed to enter tweakmode on at least one AnimData block,
+
+ /* if we managed to enter tweakmode on at least one AnimData block,
* set the flag for this in the active scene and send notifiers
*/
if (ac.scene && ok) {
/* set editing flag */
ac.scene->flag |= SCE_NLA_EDIT_ON;
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
}
@@ -163,27 +163,27 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active strip(s) to enter tweak mode on");
return OPERATOR_CANCELLED;
}
-
+
/* done */
return OPERATOR_FINISHED;
}
-
+
void NLA_OT_tweakmode_enter(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Enter Tweak Mode";
ot->idname = "NLA_OT_tweakmode_enter";
ot->description = "Enter tweaking mode for the action referenced by the active strip to edit its keyframes";
-
+
/* api callbacks */
ot->exec = nlaedit_enable_tweakmode_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
prop = RNA_def_boolean(ot->srna, "isolate_action", 0, "Isolate Action",
"Enable 'solo' on the NLA Track containing the active strip, "
@@ -198,47 +198,47 @@ bool nlaedit_disable_tweakmode(bAnimContext *ac, bool do_solo)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
- int filter;
-
+ int filter;
+
/* get a list of the AnimData blocks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* if no blocks, popup error? */
if (BLI_listbase_is_empty(&anim_data)) {
BKE_report(ac->reports, RPT_ERROR, "No AnimData blocks in tweak mode to exit from");
return false;
}
-
+
/* for each AnimData block with NLA-data, try exitting tweak-mode */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ale->data;
-
+
/* clear solo flags */
if ((do_solo) & (adt->flag & ADT_NLA_SOLO_TRACK) &&
- (adt->flag & ADT_NLA_EDIT_ON))
+ (adt->flag & ADT_NLA_EDIT_ON))
{
BKE_nlatrack_solo_toggle(adt, NULL);
}
-
+
/* to be sure that we're doing everything right, just exit tweakmode... */
BKE_nla_tweakmode_exit(adt);
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
- /* if we managed to enter tweakmode on at least one AnimData block,
+
+ /* if we managed to enter tweakmode on at least one AnimData block,
* set the flag for this in the active scene and send notifiers
*/
if (ac->scene) {
/* clear editing flag */
ac->scene->flag &= ~SCE_NLA_EDIT_ON;
-
+
/* set notifier that things have changed */
WM_main_add_notifier(NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
}
-
+
/* done */
return true;
}
@@ -247,40 +247,40 @@ bool nlaedit_disable_tweakmode(bAnimContext *ac, bool do_solo)
static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
const bool do_solo = RNA_boolean_get(op->ptr, "isolate_action");
bool ok = false;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* perform operation */
ok = nlaedit_disable_tweakmode(&ac, do_solo);
-
+
/* success? */
if (ok)
return OPERATOR_FINISHED;
else
return OPERATOR_CANCELLED;
}
-
+
void NLA_OT_tweakmode_exit(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Exit Tweak Mode";
ot->idname = "NLA_OT_tweakmode_exit";
ot->description = "Exit tweaking mode for the action referenced by the active strip";
-
+
/* api callbacks */
ot->exec = nlaedit_disable_tweakmode_exec;
ot->poll = nlaop_poll_tweakmode_on;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
prop = RNA_def_boolean(ot->srna, "isolate_action", 0, "Isolate Action",
"Disable 'solo' on any of the NLA Tracks after exiting tweak mode "
@@ -300,38 +300,38 @@ static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const
bAnimListElem *ale;
int filter;
bool found_bounds = false;
-
+
/* get data to filter */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* set large values to try to override */
*min = 999999999.0f;
*max = -999999999.0f;
-
+
/* check if any channels to set range with */
if (anim_data.first) {
/* go through channels, finding max extents */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* only consider selected strips? */
if ((only_sel == false) || (strip->flag & NLASTRIP_FLAG_SELECT)) {
/* extend range if appropriate */
*min = min_ff(*min, strip->start);
*max = max_ff(*max, strip->end);
-
+
found_bounds = true;
}
}
}
-
+
/* free memory */
ANIM_animdata_freelist(&anim_data);
}
-
+
/* set default range if nothing happened */
if (found_bounds == false) {
if (ac->scene) {
@@ -352,40 +352,40 @@ static int nlaedit_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
Scene *scene;
float min, max;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
if (ac.scene == NULL)
return OPERATOR_CANCELLED;
else
scene = ac.scene;
-
+
/* set the range directly */
get_nlastrip_extents(&ac, &min, &max, true);
scene->r.flag |= SCER_PRV_RANGE;
scene->r.psfra = round_fl_to_int(min);
scene->r.pefra = round_fl_to_int(max);
-
+
/* set notifier that things have changed */
// XXX err... there's nothing for frame ranges yet, but this should do fine too
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
-
+
return OPERATOR_FINISHED;
}
-
+
void NLA_OT_previewrange_set(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Auto-Set Preview Range";
ot->idname = "NLA_OT_previewrange_set";
ot->description = "Automatically set Preview Range based on range of keyframes";
-
+
/* api callbacks */
ot->exec = nlaedit_previewrange_exec;
ot->poll = ED_operator_nla_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -404,33 +404,33 @@ static bool nla_channels_get_selected_extents(bAnimContext *ac, float *min, floa
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
SpaceNla *snla = (SpaceNla *)ac->sl;
const float half_height = NLACHANNEL_HEIGHT_HALF(snla);
short found = 0; /* NOTE: not bool, since we want prioritise individual channels over expanders */
float y;
-
+
/* get all items - we need to do it this way */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through all channels, finding the first one that's selected */
y = (float)NLACHANNEL_FIRST;
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
-
+
/* must be selected... */
- if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) &&
+ if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) &&
ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT))
{
/* update best estimate */
*min = (float)(y - half_height);
*max = (float)(y + half_height);
-
+
/* is this high enough priority yet? */
found = acf->channel_role;
-
+
/* only stop our search when we've found an actual channel
* - datablock expanders get less priority so that we don't abort prematurely
*/
@@ -438,14 +438,14 @@ static bool nla_channels_get_selected_extents(bAnimContext *ac, float *min, floa
break;
}
}
-
+
/* adjust y-position for next one */
y -= NLACHANNEL_STEP(snla);
}
-
+
/* free all temp data */
ANIM_animdata_freelist(&anim_data);
-
+
return (found != 0);
}
@@ -454,19 +454,19 @@ static int nlaedit_viewall(bContext *C, const bool only_sel)
bAnimContext ac;
View2D *v2d;
float extra;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
v2d = &ac.ar->v2d;
-
+
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
get_nlastrip_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, only_sel);
-
+
extra = 0.1f * BLI_rctf_size_x(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
-
+
/* set vertical range */
if (only_sel == false) {
/* view all -> the summary channel is usually the shows everything, and resides right at the top... */
@@ -477,30 +477,30 @@ static int nlaedit_viewall(bContext *C, const bool only_sel)
/* locate first selected channel (or the active one), and frame those */
float ymin = v2d->cur.ymin;
float ymax = v2d->cur.ymax;
-
+
if (nla_channels_get_selected_extents(&ac, &ymin, &ymax)) {
/* recenter the view so that this range is in the middle */
float ymid = (ymax - ymin) / 2.0f + ymin;
float x_center;
-
+
UI_view2d_center_get(v2d, &x_center, NULL);
UI_view2d_center_set(v2d, x_center, ymid);
}
}
-
+
/* do View2D syncing */
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
-
+
/* just redraw this view */
ED_area_tag_redraw(CTX_wm_area(C));
-
+
return OPERATOR_FINISHED;
}
/* ......... */
static int nlaedit_viewall_exec(bContext *C, wmOperator *UNUSED(op))
-{
+{
/* whole range */
return nlaedit_viewall(C, false);
}
@@ -510,18 +510,18 @@ static int nlaedit_viewsel_exec(bContext *C, wmOperator *UNUSED(op))
/* only selected */
return nlaedit_viewall(C, true);
}
-
+
void NLA_OT_view_all(wmOperatorType *ot)
{
/* identifiers */
ot->name = "View All";
ot->idname = "NLA_OT_view_all";
ot->description = "Reset viewable area to show full strips range";
-
+
/* api callbacks */
ot->exec = nlaedit_viewall_exec;
ot->poll = ED_operator_nla_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -532,11 +532,11 @@ void NLA_OT_view_selected(wmOperatorType *ot)
ot->name = "View Selected";
ot->idname = "NLA_OT_view_selected";
ot->description = "Reset viewable area to show selected strips range";
-
+
/* api callbacks */
ot->exec = nlaedit_viewsel_exec;
ot->poll = ED_operator_nla_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -556,11 +556,11 @@ void NLA_OT_view_frame(wmOperatorType *ot)
ot->name = "View Frame";
ot->idname = "NLA_OT_view_frame";
ot->description = "Reset viewable area to show range around current frame";
-
+
/* api callbacks */
ot->exec = nlaedit_viewframe_exec;
ot->poll = ED_operator_nla_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -577,7 +577,7 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
Scene *scene;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
size_t items;
@@ -586,17 +586,17 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
bAction *act;
float cfra;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
scene = ac.scene;
cfra = (float)CFRA;
-
+
/* get action to use */
act = BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action"));
-
+
if (act == NULL) {
BKE_report(op->reports, RPT_ERROR, "No valid action to add");
//printf("Add strip - actname = '%s'\n", actname);
@@ -610,68 +610,68 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
"for this action to avoid future problems)",
act->id.name + 2);
}
-
+
/* add tracks to empty but selected animdata blocks so that strips can be added to those directly
* without having to manually add tracks first
*/
nlaedit_add_tracks_empty(&ac);
-
+
/* get a list of the editable tracks being shown in the NLA
- * - this is limited to active ones for now, but could be expanded to
+ * - this is limited to active ones for now, but could be expanded to
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT);
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
if (items == 0) {
- BKE_report(op->reports, RPT_ERROR,
+ BKE_report(op->reports, RPT_ERROR,
"No active track(s) to add strip to, select an existing track or add one before trying again");
return OPERATOR_CANCELLED;
}
-
+
/* for every active track, try to add strip to free space in track or to the top of the stack if no space */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
AnimData *adt = ale->adt;
NlaStrip *strip = NULL;
-
- /* sanity check: only apply actions of the right type for this ID
+
+ /* sanity check: only apply actions of the right type for this ID
* NOTE: in the case that this hasn't been set, we've already warned the user about this already
*/
if ((act->idroot) && (act->idroot != GS(ale->id->name))) {
- BKE_reportf(op->reports, RPT_ERROR,
+ BKE_reportf(op->reports, RPT_ERROR,
"Could not add action '%s' as it cannot be used relative to ID-blocks of type '%s'",
act->id.name + 2, ale->id->name);
continue;
}
-
+
/* create a new strip, and offset it to start on the current frame */
strip = BKE_nlastrip_new(act);
-
+
strip->end += (cfra - strip->start);
strip->start = cfra;
-
+
/* firstly try adding strip to our current track, but if that fails, add to a new track */
if (BKE_nlatrack_add_strip(nlt, strip) == 0) {
- /* trying to add to the current failed (no space),
+ /* trying to add to the current failed (no space),
* so add a new track to the stack, and add to that...
*/
nlt = BKE_nlatrack_add(adt, NULL);
BKE_nlatrack_add_strip(nlt, strip);
}
-
+
/* auto-name it */
BKE_nlastrip_validate_name(adt, strip);
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* refresh auto strip properties */
ED_nla_postop_refresh(&ac);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -684,15 +684,15 @@ void NLA_OT_actionclip_add(wmOperatorType *ot)
ot->name = "Add Action Strip";
ot->idname = "NLA_OT_actionclip_add";
ot->description = "Add an Action-Clip strip (i.e. an NLA Strip referencing an Action) to the active track";
-
+
/* api callbacks */
ot->invoke = WM_enum_search_invoke;
ot->exec = nlaedit_add_actionclip_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
// TODO: this would be nicer as an ID-pointer...
prop = RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", "");
@@ -707,45 +707,45 @@ void NLA_OT_actionclip_add(wmOperatorType *ot)
static int nlaedit_add_transition_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
bool done = false;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* for each track, find pairs of strips to add transitions to */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
AnimData *adt = ale->adt;
NlaStrip *s1, *s2;
-
+
/* get initial pair of strips */
if (ELEM(nlt->strips.first, NULL, nlt->strips.last))
continue;
s1 = nlt->strips.first;
s2 = s1->next;
-
+
/* loop over strips */
for (; s1 && s2; s1 = s2, s2 = s2->next) {
NlaStrip *strip;
-
+
/* check if both are selected */
if (ELEM(0, (s1->flag & NLASTRIP_FLAG_SELECT), (s2->flag & NLASTRIP_FLAG_SELECT)))
continue;
/* check if there's space between the two */
if (IS_EQF(s1->end, s2->start))
continue;
- /* make sure neither one is a transition
- * - although this is impossible to create with the standard tools,
+ /* make sure neither one is a transition
+ * - although this is impossible to create with the standard tools,
* the user may have altered the settings
*/
if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type))
@@ -753,48 +753,48 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op)
/* also make sure neither one is a soundclip */
if (ELEM(NLASTRIP_TYPE_SOUND, s1->type, s2->type))
continue;
-
+
/* allocate new strip */
strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip");
BLI_insertlinkafter(&nlt->strips, s1, strip);
-
+
/* set the type */
strip->type = NLASTRIP_TYPE_TRANSITION;
-
- /* generic settings
+
+ /* generic settings
* - selected flag to highlight this to the user
- * - auto-blends to ensure that blend in/out values are automatically
+ * - auto-blends to ensure that blend in/out values are automatically
* determined by overlaps of strips
*/
strip->flag = NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_AUTO_BLENDS;
-
+
/* range is simply defined as the endpoints of the adjacent strips */
strip->start = s1->end;
strip->end = s2->start;
-
+
/* scale and repeat aren't of any use, but shouldn't ever be 0 */
strip->scale = 1.0f;
strip->repeat = 1.0f;
-
+
/* auto-name it */
BKE_nlastrip_validate_name(adt, strip);
-
+
/* make note of this */
done = true;
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* was anything added? */
if (done) {
/* refresh auto strip properties */
ED_nla_postop_refresh(&ac);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -810,11 +810,11 @@ void NLA_OT_transition_add(wmOperatorType *ot)
ot->name = "Add Transition";
ot->idname = "NLA_OT_transition_add";
ot->description = "Add a transition strip between two adjacent selected strips";
-
+
/* api callbacks */
ot->exec = nlaedit_add_transition_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -825,66 +825,66 @@ void NLA_OT_transition_add(wmOperatorType *ot)
static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
Scene *scene;
int cfra;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
scene = ac.scene;
cfra = CFRA;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* for each track, add sound clips if it belongs to a speaker */
// TODO: what happens if there aren't any tracks... well that's a more general problem for later
for (ale = anim_data.first; ale; ale = ale->next) {
Object *ob = (Object *)ale->id; /* may not be object until we actually check! */
-
+
AnimData *adt = ale->adt;
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
/* does this belong to speaker - assumed to live on Object level only */
if ((GS(ale->id->name) != ID_OB) || (ob->type != OB_SPEAKER))
continue;
-
+
/* create a new strip, and offset it to start on the current frame */
strip = BKE_nla_add_soundstrip(ac.scene, ob->data);
-
+
strip->start += cfra;
strip->end += cfra;
-
+
/* firstly try adding strip to our current track, but if that fails, add to a new track */
if (BKE_nlatrack_add_strip(nlt, strip) == 0) {
- /* trying to add to the current failed (no space),
+ /* trying to add to the current failed (no space),
* so add a new track to the stack, and add to that...
*/
nlt = BKE_nlatrack_add(adt, NULL);
BKE_nlatrack_add_strip(nlt, strip);
}
-
+
/* auto-name it */
BKE_nlastrip_validate_name(adt, strip);
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* refresh auto strip properties */
ED_nla_postop_refresh(&ac);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -895,11 +895,11 @@ void NLA_OT_soundclip_add(wmOperatorType *ot)
ot->name = "Add Sound Clip";
ot->idname = "NLA_OT_soundclip_add";
ot->description = "Add a strip for controlling when speaker plays its sound clip";
-
+
/* api callbacks */
ot->exec = nlaedit_add_sound_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -911,28 +911,28 @@ void NLA_OT_soundclip_add(wmOperatorType *ot)
static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* for each track, find pairs of strips to add transitions to */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
AnimData *adt = ale->adt;
NlaStrip *strip;
-
+
/* create meta-strips from the continuous chains of selected strips */
BKE_nlastrips_make_metas(&nlt->strips, 0);
-
+
/* name the metas */
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* auto-name this strip if selected (that means it is a meta) */
@@ -940,13 +940,13 @@ static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op))
BKE_nlastrip_validate_name(adt, strip);
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -957,11 +957,11 @@ void NLA_OT_meta_add(wmOperatorType *ot)
ot->name = "Add Meta-Strips";
ot->idname = "NLA_OT_meta_add";
ot->description = "Add new meta-strips incorporating the selected strips";
-
+
/* api callbacks */
ot->exec = nlaedit_add_meta_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -972,33 +972,33 @@ void NLA_OT_meta_add(wmOperatorType *ot)
static int nlaedit_remove_meta_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* for each track, find pairs of strips to add transitions to */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
-
+
/* clear all selected meta-strips, regardless of whether they are temporary or not */
BKE_nlastrips_clear_metas(&nlt->strips, 1, 0);
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -1009,11 +1009,11 @@ void NLA_OT_meta_remove(wmOperatorType *ot)
ot->name = "Remove Meta-Strips";
ot->idname = "NLA_OT_meta_remove";
ot->description = "Separate out the strips held by the selected meta-strips";
-
+
/* api callbacks */
ot->exec = nlaedit_remove_meta_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1022,27 +1022,27 @@ void NLA_OT_meta_remove(wmOperatorType *ot)
/* Duplicates the selected NLA-Strips, putting them on new tracks above the one
* the originals were housed in.
*/
-
+
static int nlaedit_duplicate_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
bool linked = RNA_boolean_get(op->ptr, "linked");
bool done = false;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
- /* duplicate strips in tracks starting from the last one so that we're
+
+ /* duplicate strips in tracks starting from the last one so that we're
* less likely to duplicate strips we just duplicated...
*/
for (ale = anim_data.last; ale; ale = ale->prev) {
@@ -1050,46 +1050,46 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op)
AnimData *adt = ale->adt;
NlaStrip *strip, *nstrip, *next;
NlaTrack *track;
-
+
for (strip = nlt->strips.first; strip; strip = next) {
next = strip->next;
-
+
/* if selected, split the strip at its midpoint */
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* make a copy (assume that this is possible) */
nstrip = BKE_nlastrip_copy(strip, linked);
-
+
/* in case there's no space in the track above, or we haven't got a reference to it yet, try adding */
if (BKE_nlatrack_add_strip(nlt->next, nstrip) == 0) {
/* need to add a new track above the one above the current one
- * - if the current one is the last one, nlt->next will be NULL, which defaults to adding
+ * - if the current one is the last one, nlt->next will be NULL, which defaults to adding
* at the top of the stack anyway...
*/
track = BKE_nlatrack_add(adt, nlt->next);
BKE_nlatrack_add_strip(track, nstrip);
}
-
+
/* deselect the original and the active flag */
strip->flag &= ~(NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE);
-
+
/* auto-name newly created strip */
BKE_nlastrip_validate_name(adt, nstrip);
-
+
done = true;
}
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
if (done) {
/* refresh auto strip properties */
ED_nla_postop_refresh(&ac);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -1100,7 +1100,7 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op)
static int nlaedit_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
nlaedit_duplicate_exec(C, op);
-
+
RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION);
WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
@@ -1113,18 +1113,18 @@ void NLA_OT_duplicate(wmOperatorType *ot)
ot->name = "Duplicate Strips";
ot->idname = "NLA_OT_duplicate";
ot->description = "Duplicate selected NLA-Strips, adding the new strips in new tracks above the originals";
-
+
/* api callbacks */
ot->invoke = nlaedit_duplicate_invoke;
ot->exec = nlaedit_duplicate_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* own properties */
ot->prop = RNA_def_boolean(ot->srna, "linked", false, "Linked", "When duplicating strips, assign new copies of the actions they use");
-
+
/* to give to transform */
RNA_def_enum(ot->srna, "mode", rna_enum_transform_mode_types, TFM_TRANSLATION, "Mode", "");
}
@@ -1135,52 +1135,52 @@ void NLA_OT_duplicate(wmOperatorType *ot)
static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* for each NLA-Track, delete all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip, *nstrip;
-
+
for (strip = nlt->strips.first; strip; strip = nstrip) {
nstrip = strip->next;
-
+
/* if selected, delete */
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* if a strip either side of this was a transition, delete those too */
- if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION))
+ if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION))
BKE_nlastrip_free(&nlt->strips, strip->prev);
if ((nstrip) && (nstrip->type == NLASTRIP_TYPE_TRANSITION)) {
nstrip = nstrip->next;
BKE_nlastrip_free(&nlt->strips, strip->next);
}
-
+
/* finally, delete this strip */
BKE_nlastrip_free(&nlt->strips, strip);
}
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* refresh auto strip properties */
ED_nla_postop_refresh(&ac);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -1191,18 +1191,18 @@ void NLA_OT_delete(wmOperatorType *ot)
ot->name = "Delete Strips";
ot->idname = "NLA_OT_delete";
ot->description = "Delete selected strips";
-
+
/* api callbacks */
ot->exec = nlaedit_delete_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* ******************** Split Strips Operator ***************************** */
/* Splits the selected NLA-Strips into two strips at the midpoint of the strip */
-// TODO's?
+// TODO's?
// - multiple splits
// - variable-length splits?
@@ -1211,9 +1211,9 @@ static void nlaedit_split_strip_actclip(AnimData *adt, NlaTrack *nlt, NlaStrip *
{
NlaStrip *nstrip;
float splitframe, splitaframe;
-
- /* calculate the frames to do the splitting at
- * - use current frame if within extents of strip
+
+ /* calculate the frames to do the splitting at
+ * - use current frame if within extents of strip
*/
if ((cfra > strip->start) && (cfra < strip->end)) {
/* use the current frame */
@@ -1223,14 +1223,14 @@ static void nlaedit_split_strip_actclip(AnimData *adt, NlaTrack *nlt, NlaStrip *
else {
/* split in the middle */
float len;
-
+
/* strip extents */
len = strip->end - strip->start;
if (IS_EQF(len, 0.0f))
return;
else
splitframe = strip->start + (len / 2.0f);
-
+
/* action range */
len = strip->actend - strip->actstart;
if (IS_EQF(len, 0.0f))
@@ -1238,28 +1238,28 @@ static void nlaedit_split_strip_actclip(AnimData *adt, NlaTrack *nlt, NlaStrip *
else
splitaframe = strip->actstart + (len / 2.0f);
}
-
+
/* make a copy (assume that this is possible) and append
* it immediately after the current strip
*/
nstrip = BKE_nlastrip_copy(strip, true);
BLI_insertlinkafter(&nlt->strips, strip, nstrip);
-
- /* set the endpoint of the first strip and the start of the new strip
+
+ /* set the endpoint of the first strip and the start of the new strip
* to the splitframe values calculated above
*/
strip->end = splitframe;
nstrip->start = splitframe;
-
+
if ((splitaframe > strip->actstart) && (splitaframe < strip->actend)) {
/* only do this if we're splitting down the middle... */
strip->actend = splitaframe;
nstrip->actstart = splitaframe;
}
-
+
/* clear the active flag from the copy */
nstrip->flag &= ~NLASTRIP_FLAG_ACTIVE;
-
+
/* auto-name the new strip */
BKE_nlastrip_validate_name(adt, nstrip);
}
@@ -1276,28 +1276,28 @@ static void nlaedit_split_strip_meta(NlaTrack *nlt, NlaStrip *strip)
static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* for each NLA-Track, split all selected strips into two strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
AnimData *adt = ale->adt;
NlaStrip *strip, *next;
-
+
for (strip = nlt->strips.first; strip; strip = next) {
next = strip->next;
-
+
/* if selected, split the strip at its midpoint */
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* splitting method depends on the type of strip */
@@ -1305,27 +1305,27 @@ static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op))
case NLASTRIP_TYPE_CLIP: /* action-clip */
nlaedit_split_strip_actclip(adt, nlt, strip, (float)ac.scene->r.cfra);
break;
-
+
case NLASTRIP_TYPE_META: /* meta-strips need special handling */
nlaedit_split_strip_meta(nlt, strip);
break;
-
+
default: /* for things like Transitions, do not split! */
break;
}
}
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* refresh auto strip properties */
ED_nla_postop_refresh(&ac);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -1336,11 +1336,11 @@ void NLA_OT_split(wmOperatorType *ot)
ot->name = "Split Strips";
ot->idname = "NLA_OT_split";
ot->description = "Split selected strips at their midpoints";
-
+
/* api callbacks */
ot->exec = nlaedit_split_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1351,34 +1351,34 @@ void NLA_OT_split(wmOperatorType *ot)
static int nlaedit_bake_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
// int flag = 0;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* for each AnimData block, bake strips to animdata... */
for (ale = anim_data.first; ale; ale = ale->next) {
//BKE_nla_bake(ac.scene, ale->id, ale->data, flag);
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* refresh auto strip properties */
ED_nla_postop_refresh(&ac);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -1390,11 +1390,11 @@ static void UNUSED_FUNCTION(NLA_OT_bake)(wmOperatorType *ot)
ot->name = "Bake Strips";
ot->idname = "NLA_OT_bake";
ot->description = "Bake all strips of selected AnimData blocks";
-
+
/* api callbacks */
ot->exec = nlaedit_bake_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1408,44 +1408,44 @@ static void UNUSED_FUNCTION(NLA_OT_bake)(wmOperatorType *ot)
static int nlaedit_toggle_mute_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* go over all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
/* for every selected strip, toggle muting */
for (strip = nlt->strips.first; strip; strip = strip->next) {
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* just flip the mute flag for now */
// TODO: have a pre-pass to check if mute all or unmute all?
strip->flag ^= NLASTRIP_FLAG_MUTED;
-
+
/* tag AnimData to get recalculated */
ale->update |= ANIM_UPDATE_DEPS;
}
}
}
-
+
/* cleanup */
ANIM_animdata_update(&ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -1456,11 +1456,11 @@ void NLA_OT_mute_toggle(wmOperatorType *ot)
ot->name = "Toggle Muting";
ot->idname = "NLA_OT_mute_toggle";
ot->description = "Mute or un-mute selected strips";
-
+
/* api callbacks */
ot->exec = nlaedit_toggle_mute_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1471,35 +1471,35 @@ void NLA_OT_mute_toggle(wmOperatorType *ot)
static int nlaedit_swap_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* consider each track in turn */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
-
+
NlaStrip *strip, *stripN = NULL;
NlaStrip *sa = NULL, *sb = NULL;
-
+
/* make temporary metastrips so that entire islands of selections can be moved around */
BKE_nlastrips_make_metas(&nlt->strips, 1);
-
- /* special case: if there is only 1 island (i.e. temp meta BUT NOT unselected/normal/normal-meta strips) left after this,
+
+ /* special case: if there is only 1 island (i.e. temp meta BUT NOT unselected/normal/normal-meta strips) left after this,
* and this island has two strips inside it, then we should be able to just swap these still...
*/
if (BLI_listbase_is_empty(&nlt->strips) == false) {
NlaStrip *mstrip = (NlaStrip *)nlt->strips.first;
-
+
if ((mstrip->flag & NLASTRIP_FLAG_TEMP_META) &&
(BLI_listbase_count_at_most(&mstrip->strips, 3) == 2))
{
@@ -1507,13 +1507,13 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
BKE_nlastrips_clear_metas(&nlt->strips, 0, 1);
}
}
-
+
/* get two selected strips only (these will be metas due to prev step) to operate on
* - only allow swapping 2, as with more the context becomes unclear
*/
for (strip = nlt->strips.first; strip; strip = stripN) {
stripN = strip->next;
-
+
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* first or second strip? */
if (sa == NULL) {
@@ -1530,10 +1530,10 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
}
}
}
-
+
if (strip) {
/* too many selected warning */
- BKE_reportf(op->reports, RPT_WARNING,
+ BKE_reportf(op->reports, RPT_WARNING,
"Too many clusters of strips selected in NLA Track (%s): needs exactly 2 to be selected",
nlt->name);
}
@@ -1548,11 +1548,11 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
}
else {
float nsa[2], nsb[2];
-
+
/* remove these strips from the track, so that we can test if they can fit in the proposed places */
BLI_remlink(&nlt->strips, sa);
BLI_remlink(&nlt->strips, sb);
-
+
/* calculate new extents for strips */
/* a --> b */
nsa[0] = sb->start;
@@ -1560,16 +1560,16 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
/* b --> a */
nsb[0] = sa->start;
nsb[1] = sa->start + (sb->end - sb->start);
-
+
/* check if the track has room for the strips to be swapped */
- if (BKE_nlastrips_has_space(&nlt->strips, nsa[0], nsa[1]) &&
+ if (BKE_nlastrips_has_space(&nlt->strips, nsa[0], nsa[1]) &&
BKE_nlastrips_has_space(&nlt->strips, nsb[0], nsb[1]))
{
/* set new extents for strips then */
sa->start = nsa[0];
sa->end = nsa[1];
BKE_nlameta_flush_transforms(sa);
-
+
sb->start = nsb[0];
sb->end = nsb[1];
BKE_nlameta_flush_transforms(sb);
@@ -1586,25 +1586,25 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
sa->name, sb->name);
}
}
-
+
/* add strips back to track now */
BKE_nlatrack_add_strip(nlt, sa);
BKE_nlatrack_add_strip(nlt, sb);
}
-
+
/* clear (temp) metastrips */
BKE_nlastrips_clear_metas(&nlt->strips, 0, 1);
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* refresh auto strip properties */
ED_nla_postop_refresh(&ac);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -1615,11 +1615,11 @@ void NLA_OT_swap(wmOperatorType *ot)
ot->name = "Swap Strips";
ot->idname = "NLA_OT_swap";
ot->description = "Swap order of selected strips within tracks";
-
+
/* api callbacks */
ot->exec = nlaedit_swap_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1630,19 +1630,19 @@ void NLA_OT_swap(wmOperatorType *ot)
static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* since we're potentially moving strips from lower tracks to higher tracks, we should
* loop over the tracks in reverse order to avoid moving earlier strips up multiple tracks
*/
@@ -1650,15 +1650,15 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op))
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaTrack *nltn = nlt->next;
NlaStrip *strip, *stripn;
-
+
/* if this track has no tracks after it, skip for now... */
if (nltn == NULL)
continue;
-
+
/* for every selected strip, try to move */
for (strip = nlt->strips.first; strip; strip = stripn) {
stripn = strip->next;
-
+
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* check if the track above has room for this strip */
if (BKE_nlatrack_has_space(nltn, strip->start, strip->end)) {
@@ -1669,16 +1669,16 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op))
}
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* refresh auto strip properties */
ED_nla_postop_refresh(&ac);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -1689,11 +1689,11 @@ void NLA_OT_move_up(wmOperatorType *ot)
ot->name = "Move Strips Up";
ot->idname = "NLA_OT_move_up";
ot->description = "Move selected strips up a track if there's room";
-
+
/* api callbacks */
ot->exec = nlaedit_move_up_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1704,19 +1704,19 @@ void NLA_OT_move_up(wmOperatorType *ot)
static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* loop through the tracks in normal order, since we're pushing strips down,
* strips won't get operated on twice
*/
@@ -1724,15 +1724,15 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op))
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaTrack *nltp = nlt->prev;
NlaStrip *strip, *stripn;
-
+
/* if this track has no tracks before it, skip for now... */
if (nltp == NULL)
continue;
-
+
/* for every selected strip, try to move */
for (strip = nlt->strips.first; strip; strip = stripn) {
stripn = strip->next;
-
+
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* check if the track below has room for this strip */
if (BKE_nlatrack_has_space(nltp, strip->start, strip->end)) {
@@ -1743,16 +1743,16 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op))
}
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* refresh auto strip properties */
ED_nla_postop_refresh(&ac);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -1763,11 +1763,11 @@ void NLA_OT_move_down(wmOperatorType *ot)
ot->name = "Move Strips Down";
ot->idname = "NLA_OT_move_down";
ot->description = "Move selected strips down a track if there's room";
-
+
/* api callbacks */
ot->exec = nlaedit_move_down_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1778,26 +1778,26 @@ void NLA_OT_move_down(wmOperatorType *ot)
static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
const bool active_only = RNA_boolean_get(op->ptr, "active");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
if (active_only) filter |= ANIMFILTER_ACTIVE;
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* for each NLA-Track, apply scale of all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* strip selection/active status check */
if (active_only) {
@@ -1808,27 +1808,27 @@ static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op)
if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0)
continue;
}
-
+
/* must be action-clip only (transitions don't have scale) */
if (strip->type == NLASTRIP_TYPE_CLIP) {
- if (strip->act == NULL)
+ if (strip->act == NULL)
continue;
-
+
/* recalculate the length of the action */
calc_action_range(strip->act, &strip->actstart, &strip->actend, 0);
-
+
/* adjust the strip extents in response to this */
BKE_nlastrip_recalculate_bounds(strip);
}
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -1839,14 +1839,14 @@ void NLA_OT_action_sync_length(wmOperatorType *ot)
ot->name = "Sync Action Length";
ot->idname = "NLA_OT_action_sync_length";
ot->description = "Synchronize the length of the referenced Action with the length used in the strip";
-
+
/* api callbacks */
ot->exec = nlaedit_sync_actlen_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_boolean(ot->srna, "active", 1, "Active Strip Only", "Only sync the active length for the active strip");
}
@@ -1858,19 +1858,19 @@ static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* Ensure that each action used only has a single user
* - This is done in reverse order so that the original strips are
* likely to still get to keep their action
@@ -1878,34 +1878,34 @@ static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op))
for (ale = anim_data.last; ale; ale = ale->prev) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
for (strip = nlt->strips.last; strip; strip = strip->prev) {
/* must be action-clip only (as only these have actions) */
if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) {
- if (strip->act == NULL)
+ if (strip->act == NULL)
continue;
-
+
/* multi-user? */
if (ID_REAL_USERS(strip->act) > 1) {
/* make a new copy of the action for us to use (it will have 1 user already) */
bAction *new_action = BKE_action_copy(bmain, strip->act);
-
+
/* decrement user count of our existing action */
id_us_min(&strip->act->id);
-
+
/* switch to the new copy */
strip->act = new_action;
}
}
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -1916,12 +1916,12 @@ void NLA_OT_make_single_user(wmOperatorType *ot)
ot->name = "Make Single User";
ot->idname = "NLA_OT_make_single_user";
ot->description = "Ensure that each action is only used once in the set of strips selected";
-
+
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = nlaedit_make_single_user_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1934,12 +1934,12 @@ static short bezt_apply_nlamapping(KeyframeEditData *ked, BezTriple *bezt)
{
/* NLA-strip which has this scaling is stored in ked->data */
NlaStrip *strip = (NlaStrip *)ked->data;
-
+
/* adjust all the times */
bezt->vec[0][0] = nlastrip_get_frame(strip, bezt->vec[0][0], NLATIME_CONVERT_MAP);
bezt->vec[1][0] = nlastrip_get_frame(strip, bezt->vec[1][0], NLATIME_CONVERT_MAP);
bezt->vec[2][0] = nlastrip_get_frame(strip, bezt->vec[2][0], NLATIME_CONVERT_MAP);
-
+
/* nothing to return or else we exit */
return 0;
}
@@ -1948,61 +1948,61 @@ static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditData ked = {{NULL}};
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* for each NLA-Track, apply scale of all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* strip must be selected, and must be action-clip only (transitions don't have scale) */
if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) {
/* if the referenced action is used by other strips, make this strip use its own copy */
- if (strip->act == NULL)
+ if (strip->act == NULL)
continue;
if (strip->act->id.us > 1) {
/* make a copy of the Action to work on */
bAction *act = BKE_action_copy(bmain, strip->act);
-
+
/* set this as the new referenced action, decrementing the users of the old one */
id_us_min(&strip->act->id);
strip->act = act;
}
-
+
/* setup iterator, and iterate over all the keyframes in the action, applying this scaling */
ked.data = strip;
ANIM_animchanneldata_keyframes_loop(&ked, ac.ads, strip->act, ALE_ACT, NULL, bezt_apply_nlamapping, calchandles_fcurve);
-
+
/* clear scale of strip now that it has been applied,
* and recalculate the extents of the action now that it has been scaled
- * but leave everything else alone
+ * but leave everything else alone
*/
strip->scale = 1.0f;
calc_action_range(strip->act, &strip->actstart, &strip->actend, 0);
}
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -2013,11 +2013,11 @@ void NLA_OT_apply_scale(wmOperatorType *ot)
ot->name = "Apply Scale";
ot->idname = "NLA_OT_apply_scale";
ot->description = "Apply scaling of selected strips to their referenced Actions";
-
+
/* api callbacks */
ot->exec = nlaedit_apply_scale_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2028,44 +2028,44 @@ void NLA_OT_apply_scale(wmOperatorType *ot)
static int nlaedit_clear_scale_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* for each NLA-Track, reset scale of all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* strip must be selected, and must be action-clip only (transitions don't have scale) */
if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) {
PointerRNA strip_ptr;
-
+
RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr);
RNA_float_set(&strip_ptr, "scale", 1.0f);
}
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* refresh auto strip properties */
ED_nla_postop_refresh(&ac);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -2076,11 +2076,11 @@ void NLA_OT_clear_scale(wmOperatorType *ot)
ot->name = "Clear Scale";
ot->idname = "NLA_OT_clear_scale";
ot->description = "Reset scaling of selected strips";
-
+
/* api callbacks */
ot->exec = nlaedit_clear_scale_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2100,27 +2100,27 @@ static const EnumPropertyItem prop_nlaedit_snap_types[] = {
static int nlaedit_snap_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
Scene *scene;
int mode = RNA_enum_get(op->ptr, "type");
float secf;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* get some necessary vars */
scene = ac.scene;
secf = (float)FPS;
-
+
/* since we may add tracks, perform this in reverse order */
for (ale = anim_data.last; ale; ale = ale->prev) {
ListBase tmp_strips = {NULL, NULL};
@@ -2128,23 +2128,23 @@ static int nlaedit_snap_exec(bContext *C, wmOperator *op)
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip, *stripn;
NlaTrack *track;
-
+
/* create meta-strips from the continuous chains of selected strips */
BKE_nlastrips_make_metas(&nlt->strips, 1);
-
+
/* apply the snapping to all the temp meta-strips, then put them in a separate list to be added
* back to the original only if they still fit
*/
for (strip = nlt->strips.first; strip; strip = stripn) {
stripn = strip->next;
-
+
if (strip->flag & NLASTRIP_FLAG_TEMP_META) {
float start, end;
-
+
/* get the existing end-points */
start = strip->start;
end = strip->end;
-
+
/* calculate new start position based on snapping mode */
switch (mode) {
case NLAEDIT_SNAP_CFRA: /* to current frame */
@@ -2163,54 +2163,54 @@ static int nlaedit_snap_exec(bContext *C, wmOperator *op)
strip->start = start;
break;
}
-
+
/* get new endpoint based on start-point (and old length) */
strip->end = strip->start + (end - start);
-
+
/* apply transforms to meta-strip to its children */
BKE_nlameta_flush_transforms(strip);
-
+
/* remove strip from track, and add to the temp buffer */
BLI_remlink(&nlt->strips, strip);
BLI_addtail(&tmp_strips, strip);
}
}
-
+
/* try adding each meta-strip back to the track one at a time, to make sure they'll fit */
for (strip = tmp_strips.first; strip; strip = stripn) {
stripn = strip->next;
-
+
/* remove from temp-strips list */
BLI_remlink(&tmp_strips, strip);
-
+
/* in case there's no space in the current track, try adding */
if (BKE_nlatrack_add_strip(nlt, strip) == 0) {
/* need to add a new track above the current one */
track = BKE_nlatrack_add(adt, nlt);
BKE_nlatrack_add_strip(track, strip);
-
+
/* clear temp meta-strips on this new track, as we may not be able to get back to it */
BKE_nlastrips_clear_metas(&track->strips, 0, 1);
}
}
-
+
/* remove the meta-strips now that we're done */
BKE_nlastrips_clear_metas(&nlt->strips, 0, 1);
-
+
/* tag for recalculating the animation */
ale->update |= ANIM_UPDATE_DEPS;
}
-
+
/* cleanup */
ANIM_animdata_update(&ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
-
+
/* refresh auto strip properties */
ED_nla_postop_refresh(&ac);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -2221,15 +2221,15 @@ void NLA_OT_snap(wmOperatorType *ot)
ot->name = "Snap Strips";
ot->idname = "NLA_OT_snap";
ot->description = "Move start of strips to specified time";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = nlaedit_snap_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", prop_nlaedit_snap_types, 0, "Type", "");
}
@@ -2244,31 +2244,31 @@ static const EnumPropertyItem *nla_fmodifier_itemf(bContext *C, PointerRNA *UNUS
EnumPropertyItem *item = NULL;
int totitem = 0;
int i = 0;
-
+
if (C == NULL) {
return rna_enum_fmodifier_type_items;
}
-
+
/* start from 1 to skip the 'Invalid' modifier type */
for (i = 1; i < FMODIFIER_NUM_TYPES; i++) {
const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(i);
int index;
-
+
/* check if modifier is valid for this context */
if (fmi == NULL)
continue;
if (i == FMODIFIER_TYPE_CYCLES) /* we already have repeat... */
continue;
-
+
index = RNA_enum_from_value(rna_enum_fmodifier_type_items, fmi->type);
if (index != -1) { /* Not all types are implemented yet... */
RNA_enum_item_add(&item, &totitem, &rna_enum_fmodifier_type_items[index]);
}
}
-
+
RNA_enum_item_end(&item, &totitem);
*r_free = true;
-
+
return item;
}
@@ -2276,28 +2276,28 @@ static const EnumPropertyItem *nla_fmodifier_itemf(bContext *C, PointerRNA *UNUS
static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
FModifier *fcm;
int type = RNA_enum_get(op->ptr, "type");
const bool active_only = RNA_boolean_get(op->ptr, "only_active");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* for each NLA-Track, add the specified modifier to all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* can F-Modifier be added to the current strip? */
if (active_only) {
@@ -2310,14 +2310,14 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0)
continue;
}
-
+
/* sound clips are not affected by FModifiers */
if (strip->type == NLASTRIP_TYPE_SOUND)
continue;
-
+
/* add F-Modifier of specified type to selected, and make it the active one */
fcm = add_fmodifier(&strip->modifiers, type, NULL);
-
+
if (fcm) {
set_active_fmodifier(&strip->modifiers, fcm);
ale->update |= ANIM_UPDATE_DEPS;
@@ -2329,37 +2329,37 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
}
}
}
-
+
/* free temp data */
ANIM_animdata_update(&ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
-
+
void NLA_OT_fmodifier_add(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Add F-Modifier";
ot->idname = "NLA_OT_fmodifier_add";
ot->description = "Add F-Modifier to the active/selected NLA-Strips";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = nla_fmodifier_add_exec;
- ot->poll = nlaop_poll_tweakmode_off;
-
+ ot->poll = nlaop_poll_tweakmode_off;
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_fmodifier_type_items, 0, "Type", "");
RNA_def_enum_funcs(ot->prop, nla_fmodifier_itemf);
-
+
RNA_def_boolean(ot->srna, "only_active", true, "Only Active", "Only add a F-Modifier of the specified type to the active strip");
}
@@ -2372,36 +2372,36 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op)
bAnimListElem *ale;
int filter;
bool ok = false;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* clear buffer first */
ANIM_fmodifiers_copybuf_free();
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* for each NLA-Track, add the specified modifier to all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* only add F-Modifier if on active strip? */
if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0)
continue;
-
+
// TODO: when 'active' vs 'all' boolean is added, change last param!
ok |= ANIM_fmodifiers_copy_to_buf(&strip->modifiers, 0);
}
}
-
+
/* free temp data */
ANIM_animdata_freelist(&anim_data);
-
+
/* successful or not? */
if (ok == 0) {
BKE_report(op->reports, RPT_ERROR, "No F-Modifiers available to be copied");
@@ -2412,21 +2412,21 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
}
-
+
void NLA_OT_fmodifier_copy(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Copy F-Modifiers";
ot->idname = "NLA_OT_fmodifier_copy";
ot->description = "Copy the F-Modifier(s) of the active NLA-Strip";
-
+
/* api callbacks */
ot->exec = nla_fmodifier_copy_exec;
- ot->poll = nlaop_poll_tweakmode_off;
-
+ ot->poll = nlaop_poll_tweakmode_off;
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
//ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All F-Modifiers", "Copy all the F-Modifiers, instead of just the active one");
}
@@ -2439,23 +2439,23 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter, ok = 0;
-
+
const bool active_only = RNA_boolean_get(op->ptr, "only_active");
const bool replace = RNA_boolean_get(op->ptr, "replace");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* for each NLA-Track, add the specified modifier to all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* can F-Modifier be added to the current strip? */
if (active_only) {
@@ -2468,17 +2468,17 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op)
if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0)
continue;
}
-
+
/* paste FModifiers from buffer */
ok += ANIM_fmodifiers_paste_from_buf(&strip->modifiers, replace, NULL);
ale->update |= ANIM_UPDATE_DEPS;
}
}
-
+
/* clean up */
ANIM_animdata_update(&ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
-
+
/* successful or not? */
if (ok) {
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
@@ -2489,24 +2489,24 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
}
-
+
void NLA_OT_fmodifier_paste(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Paste F-Modifiers";
ot->idname = "NLA_OT_fmodifier_paste";
ot->description = "Add copied F-Modifiers to the selected NLA-Strips";
-
+
/* api callbacks */
ot->exec = nla_fmodifier_paste_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "only_active", true, "Only Active", "Only paste F-Modifiers on active strip");
- RNA_def_boolean(ot->srna, "replace", false, "Replace Existing",
+ RNA_def_boolean(ot->srna, "replace", false, "Replace Existing",
"Replace existing F-Modifiers, instead of just appending to the end of the existing list");
}
diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h
index 806fbe90ff2..2e73c82ebb6 100644
--- a/source/blender/editors/space_nla/nla_intern.h
+++ b/source/blender/editors/space_nla/nla_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation, Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c
index 48037a10b2d..0c087fa67b9 100644
--- a/source/blender/editors/space_nla/nla_ops.c
+++ b/source/blender/editors/space_nla/nla_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
* All rights reserved.
*
- *
+ *
* Contributor(s): Joshua Leung (major recode)
*
* ***** END GPL LICENSE BLOCK *****
@@ -55,21 +55,21 @@
int nlaop_poll_tweakmode_off(bContext *C)
{
Scene *scene;
-
- /* for now, we check 2 things:
+
+ /* for now, we check 2 things:
* 1) active editor must be NLA
- * 2) tweakmode is currently set as a 'per-scene' flag
+ * 2) tweakmode is currently set as a 'per-scene' flag
* so that it will affect entire NLA data-sets,
- * but not all AnimData blocks will be in tweakmode for
+ * but not all AnimData blocks will be in tweakmode for
* various reasons
*/
if (ED_operator_nla_active(C) == 0)
return 0;
-
+
scene = CTX_data_scene(C);
if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON))
return 0;
-
+
return 1;
}
@@ -77,21 +77,21 @@ int nlaop_poll_tweakmode_off(bContext *C)
int nlaop_poll_tweakmode_on(bContext *C)
{
Scene *scene;
-
- /* for now, we check 2 things:
+
+ /* for now, we check 2 things:
* 1) active editor must be NLA
- * 2) tweakmode is currently set as a 'per-scene' flag
+ * 2) tweakmode is currently set as a 'per-scene' flag
* so that it will affect entire NLA data-sets,
- * but not all AnimData blocks will be in tweakmode for
+ * but not all AnimData blocks will be in tweakmode for
* various reasons
*/
if (ED_operator_nla_active(C) == 0)
return 0;
-
+
scene = CTX_data_scene(C);
if ((scene == NULL) || !(scene->flag & SCE_NLA_EDIT_ON))
return 0;
-
+
return 1;
}
@@ -109,61 +109,61 @@ void nla_operatortypes(void)
{
/* view */
WM_operatortype_append(NLA_OT_properties);
-
+
/* channels */
WM_operatortype_append(NLA_OT_channels_click);
-
+
WM_operatortype_append(NLA_OT_action_pushdown);
WM_operatortype_append(NLA_OT_action_unlink);
-
+
WM_operatortype_append(NLA_OT_tracks_add);
WM_operatortype_append(NLA_OT_tracks_delete);
-
+
WM_operatortype_append(NLA_OT_selected_objects_add);
-
+
/* select */
WM_operatortype_append(NLA_OT_click_select);
WM_operatortype_append(NLA_OT_select_border);
WM_operatortype_append(NLA_OT_select_all_toggle);
WM_operatortype_append(NLA_OT_select_leftright);
-
+
/* view */
WM_operatortype_append(NLA_OT_view_all);
WM_operatortype_append(NLA_OT_view_selected);
WM_operatortype_append(NLA_OT_view_frame);
-
+
WM_operatortype_append(NLA_OT_previewrange_set);
-
+
/* edit */
WM_operatortype_append(NLA_OT_tweakmode_enter);
WM_operatortype_append(NLA_OT_tweakmode_exit);
-
+
WM_operatortype_append(NLA_OT_actionclip_add);
WM_operatortype_append(NLA_OT_transition_add);
WM_operatortype_append(NLA_OT_soundclip_add);
-
+
WM_operatortype_append(NLA_OT_meta_add);
WM_operatortype_append(NLA_OT_meta_remove);
-
+
WM_operatortype_append(NLA_OT_duplicate);
WM_operatortype_append(NLA_OT_delete);
WM_operatortype_append(NLA_OT_split);
-
+
WM_operatortype_append(NLA_OT_mute_toggle);
-
+
WM_operatortype_append(NLA_OT_swap);
WM_operatortype_append(NLA_OT_move_up);
WM_operatortype_append(NLA_OT_move_down);
-
+
WM_operatortype_append(NLA_OT_action_sync_length);
-
+
WM_operatortype_append(NLA_OT_make_single_user);
-
+
WM_operatortype_append(NLA_OT_apply_scale);
WM_operatortype_append(NLA_OT_clear_scale);
-
+
WM_operatortype_append(NLA_OT_snap);
-
+
WM_operatortype_append(NLA_OT_fmodifier_add);
WM_operatortype_append(NLA_OT_fmodifier_copy);
WM_operatortype_append(NLA_OT_fmodifier_paste);
@@ -176,7 +176,7 @@ static void nla_keymap_channels(wmKeyMap *keymap)
wmKeyMapItem *kmi;
/* keymappings here are NLA-specific (different to standard channels keymap) */
-
+
/* selection --------------------------------------------------------------------- */
/* click-select */
// XXX for now, only leftmouse....
@@ -184,14 +184,14 @@ static void nla_keymap_channels(wmKeyMap *keymap)
RNA_boolean_set(kmi->ptr, "extend", false);
kmi = WM_keymap_add_item(keymap, "NLA_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", true);
-
+
/* channel operations ------------------------------------------------------------ */
/* add tracks */
kmi = WM_keymap_add_item(keymap, "NLA_OT_tracks_add", AKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "above_selected", false);
kmi = WM_keymap_add_item(keymap, "NLA_OT_tracks_add", AKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "above_selected", true);
-
+
/* delete tracks */
WM_keymap_add_item(keymap, "NLA_OT_tracks_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NLA_OT_tracks_delete", DELKEY, KM_PRESS, 0, 0);
@@ -200,14 +200,14 @@ static void nla_keymap_channels(wmKeyMap *keymap)
static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap)
{
wmKeyMapItem *kmi;
-
+
/* selection ------------------------------------------------ */
/* click select */
kmi = WM_keymap_add_item(keymap, "NLA_OT_click_select", SELECTMOUSE, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "extend", false);
kmi = WM_keymap_add_item(keymap, "NLA_OT_click_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", true);
-
+
/* select left/right */
kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "extend", false);
@@ -215,92 +215,92 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap)
kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", true);
RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_TEST);
-
+
kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "extend", false);
RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_LEFT);
kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "extend", false);
RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_RIGHT);
-
-
+
+
/* deselect all */
/* TODO: uniformize with other select_all ops? */
kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "invert", false);
kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "invert", true);
-
+
/* borderselect */
kmi = WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "axis_range", false);
kmi = WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "axis_range", true);
-
+
/* view ---------------------------------------------------- */
/* auto-set range */
WM_keymap_add_item(keymap, "NLA_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
-
+
WM_keymap_add_item(keymap, "NLA_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
#ifdef WITH_INPUT_NDOF
WM_keymap_add_item(keymap, "NLA_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
#endif
WM_keymap_add_item(keymap, "NLA_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NLA_OT_view_frame", PAD0, KM_PRESS, 0, 0);
-
+
/* editing ------------------------------------------------ */
-
+
/* add strips */
WM_keymap_add_item(keymap, "NLA_OT_actionclip_add", AKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "NLA_OT_transition_add", TKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "NLA_OT_soundclip_add", KKEY, KM_PRESS, KM_SHIFT, 0);
-
+
/* meta-strips */
WM_keymap_add_item(keymap, "NLA_OT_meta_add", GKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "NLA_OT_meta_remove", GKEY, KM_PRESS, KM_ALT, 0);
-
+
/* duplicate */
kmi = WM_keymap_add_item(keymap, "NLA_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "linked", false);
-
+
kmi = WM_keymap_add_item(keymap, "NLA_OT_duplicate", DKEY, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "linked", true);
-
+
/* single user */
WM_keymap_add_item(keymap, "NLA_OT_make_single_user", UKEY, KM_PRESS, 0, 0);
-
+
/* delete */
WM_keymap_add_item(keymap, "NLA_OT_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NLA_OT_delete", DELKEY, KM_PRESS, 0, 0);
/* split */
WM_keymap_add_item(keymap, "NLA_OT_split", YKEY, KM_PRESS, 0, 0);
-
+
/* toggles */
WM_keymap_add_item(keymap, "NLA_OT_mute_toggle", HKEY, KM_PRESS, 0, 0);
-
+
/* swap */
WM_keymap_add_item(keymap, "NLA_OT_swap", FKEY, KM_PRESS, KM_ALT, 0);
-
+
/* move up */
WM_keymap_add_item(keymap, "NLA_OT_move_up", PAGEUPKEY, KM_PRESS, 0, 0);
/* move down */
WM_keymap_add_item(keymap, "NLA_OT_move_down", PAGEDOWNKEY, KM_PRESS, 0, 0);
-
+
/* apply scale */
WM_keymap_add_item(keymap, "NLA_OT_apply_scale", AKEY, KM_PRESS, KM_CTRL, 0);
/* clear scale */
WM_keymap_add_item(keymap, "NLA_OT_clear_scale", SKEY, KM_PRESS, KM_ALT, 0);
-
+
/* snap */
WM_keymap_add_item(keymap, "NLA_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
-
+
/* add f-modifier */
WM_keymap_add_item(keymap, "NLA_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
-
+
/* transform system */
transform_keymap_for_space(keyconf, keymap, SPACE_NLA);
-
+
/* special markers hotkeys for anim editors: see note in definition of this function */
ED_marker_keymap_animedit_conflictfree(keymap);
}
@@ -311,35 +311,35 @@ void nla_keymap(wmKeyConfig *keyconf)
{
wmKeyMap *keymap;
wmKeyMapItem *kmi;
-
+
/* keymap for all regions ------------------------------------------- */
keymap = WM_keymap_find(keyconf, "NLA Generic", SPACE_NLA, 0);
-
+
/* region management */
WM_keymap_add_item(keymap, "NLA_OT_properties", NKEY, KM_PRESS, 0, 0);
-
+
/* tweakmode
* - enter and exit are separate operators with the same hotkey...
* This works as they use different poll()'s
*/
WM_keymap_add_item(keymap, "NLA_OT_tweakmode_enter", TABKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NLA_OT_tweakmode_exit", TABKEY, KM_PRESS, 0, 0);
-
+
/* tweakmode for stashed actions
* - similar to normal tweakmode, except we mark the tracks as being "solo"
* too so that the action can be edited in isolation
*/
kmi = WM_keymap_add_item(keymap, "NLA_OT_tweakmode_enter", TABKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "isolate_action", true);
-
+
kmi = WM_keymap_add_item(keymap, "NLA_OT_tweakmode_exit", TABKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "isolate_action", true);
-
+
/* find (i.e. a shortcut for setting the name filter) */
WM_keymap_add_item(keymap, "ANIM_OT_channels_find", FKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* channels ---------------------------------------------------------- */
- /* Channels are not directly handled by the NLA Editor module, but are inherited from the Animation module.
+ /* Channels are not directly handled by the NLA Editor module, but are inherited from the Animation module.
* Most of the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as there
* are many similarities with the other Animation Editors.
*
@@ -347,7 +347,7 @@ void nla_keymap(wmKeyConfig *keyconf)
*/
keymap = WM_keymap_find(keyconf, "NLA Channels", SPACE_NLA, 0);
nla_keymap_channels(keymap);
-
+
/* data ------------------------------------------------------------- */
keymap = WM_keymap_find(keyconf, "NLA Editor", SPACE_NLA, 0);
nla_keymap_main(keyconf, keymap);
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index e09e4417d5d..8c9372f0612 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
* All rights reserved.
*
- *
+ *
* Contributor(s): Joshua Leung (major recode)
*
* ***** END GPL LICENSE BLOCK *****
@@ -89,12 +89,12 @@ enum {
DESELECT_STRIPS_TEST,
DESELECT_STRIPS_CLEARACTIVE,
} /*eDeselectNlaStrips*/;
-
+
/* Deselects strips in the NLA Editor
* - This is called by the deselect all operator, as well as other ones!
*
* - test: check if select or deselect all (1) or clear all active (2)
- * - sel: how to select keyframes
+ * - sel: how to select keyframes
* 0 = deselect
* 1 = select
* 2 = invert
@@ -105,20 +105,20 @@ static void deselect_nla_strips(bAnimContext *ac, short test, short sel)
bAnimListElem *ale;
int filter;
short smode;
-
+
/* determine type-based settings */
// FIXME: double check whether ANIMFILTER_LIST_VISIBLE is needed!
filter = (ANIMFILTER_DATA_VISIBLE);
-
+
/* filter data */
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* See if we should be selecting or deselecting */
if (test == DESELECT_STRIPS_TEST) {
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
/* if any strip is selected, break out, since we should now be deselecting */
for (strip = nlt->strips.first; strip; strip = strip->next) {
if (strip->flag & NLASTRIP_FLAG_SELECT) {
@@ -126,32 +126,32 @@ static void deselect_nla_strips(bAnimContext *ac, short test, short sel)
break;
}
}
-
+
if (sel == SELECT_SUBTRACT)
break;
}
}
-
+
/* convert selection modes to selection modes */
smode = selmodes_to_flagmodes(sel);
-
+
/* Now set the flags */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
/* apply same selection to all strips */
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* set selection */
if (test != DESELECT_STRIPS_CLEARACTIVE)
ACHANNEL_SET_FLAG(strip, smode, NLASTRIP_FLAG_SELECT);
-
+
/* clear active flag */
// TODO: for clear active, do we want to limit this to only doing this on a certain set of tracks though?
strip->flag &= ~NLASTRIP_FLAG_ACTIVE;
}
}
-
+
/* Cleanup */
ANIM_animdata_freelist(&anim_data);
}
@@ -161,37 +161,37 @@ static void deselect_nla_strips(bAnimContext *ac, short test, short sel)
static int nlaedit_deselectall_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* 'standard' behavior - check if selected, then apply relevant selection */
if (RNA_boolean_get(op->ptr, "invert"))
deselect_nla_strips(&ac, DESELECT_STRIPS_NOTEST, SELECT_INVERT);
else
deselect_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_ADD);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void NLA_OT_select_all_toggle(wmOperatorType *ot)
{
/* identifiers */
ot->name = "(De)select All";
ot->idname = "NLA_OT_select_all_toggle";
ot->description = "Select or deselect all NLA-Strips";
-
+
/* api callbacks */
ot->exec = nlaedit_deselectall_exec;
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/;
-
+
/* props */
ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
@@ -218,27 +218,27 @@ static void borderselect_nla_strips(bAnimContext *ac, rcti rect, short mode, sho
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
SpaceNla *snla = (SpaceNla *)ac->sl;
View2D *v2d = &ac->ar->v2d;
rctf rectf;
float ymin /* =(float)(-NLACHANNEL_HEIGHT(snla)) */ /* UNUSED */, ymax = 0;
-
+
/* convert border-region to view coordinates */
UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin + 2, &rectf.xmin, &rectf.ymin);
UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax - 2, &rectf.xmax, &rectf.ymax);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* convert selection modes to selection modes */
selectmode = selmodes_to_flagmodes(selectmode);
-
+
/* loop over data, doing border select */
for (ale = anim_data.first; ale; ale = ale->next) {
ymin = ymax - NLACHANNEL_STEP(snla);
-
+
/* perform vertical suitability check (if applicable) */
if ((mode == NLA_BORDERSEL_FRAMERANGE) ||
!((ymax < rectf.ymin) || (ymin > rectf.ymax)))
@@ -247,7 +247,7 @@ static void borderselect_nla_strips(bAnimContext *ac, rcti rect, short mode, sho
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
/* only select strips if they fall within the required ranges (if applicable) */
for (strip = nlt->strips.first; strip; strip = strip->next) {
if ((mode == NLA_BORDERSEL_CHANNELS) ||
@@ -255,18 +255,18 @@ static void borderselect_nla_strips(bAnimContext *ac, rcti rect, short mode, sho
{
/* set selection */
ACHANNEL_SET_FLAG(strip, selectmode, NLASTRIP_FLAG_SELECT);
-
+
/* clear active flag */
strip->flag &= ~NLASTRIP_FLAG_ACTIVE;
}
}
}
}
-
+
/* set minimum extent to be the maximum of the next channel */
ymax = ymin;
}
-
+
/* cleanup */
ANIM_animdata_freelist(&anim_data);
}
@@ -280,7 +280,7 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op)
short mode = 0, selectmode = 0;
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
@@ -302,7 +302,7 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op)
/* selection 'mode' depends on whether borderselect region only matters on one axis */
if (RNA_boolean_get(op->ptr, "axis_range")) {
- /* mode depends on which axis of the range is larger to determine which axis to use
+ /* mode depends on which axis of the range is larger to determine which axis to use
* - checking this in region-space is fine, as it's fundamentally still going to be a different rect size
* - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
* used for tweaking timing when "blocking", while channels is not that useful...
@@ -312,17 +312,17 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op)
else
mode = NLA_BORDERSEL_CHANNELS;
}
- else
+ else
mode = NLA_BORDERSEL_ALLSTRIPS;
-
+
/* apply borderselect action */
borderselect_nla_strips(&ac, rect, mode, selectmode);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
-}
+}
void NLA_OT_select_border(wmOperatorType *ot)
{
@@ -330,21 +330,21 @@ void NLA_OT_select_border(wmOperatorType *ot)
ot->name = "Border Select";
ot->idname = "NLA_OT_select_border";
ot->description = "Use box selection to grab NLA-Strips";
-
+
/* api callbacks */
ot->invoke = WM_gesture_border_invoke;
ot->exec = nlaedit_borderselect_exec;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
-
+
ot->poll = nlaop_poll_tweakmode_off;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* rna */
WM_operator_properties_gesture_border_select(ot);
-
+
RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", "");
}
@@ -366,24 +366,24 @@ static void nlaedit_select_leftright(bContext *C, bAnimContext *ac, short leftri
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
Scene *scene = ac->scene;
float xmin, xmax;
-
+
/* if currently in tweakmode, exit tweakmode first */
if (scene->flag & SCE_NLA_EDIT_ON)
WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL);
-
+
/* if select mode is replace, deselect all keyframes (and channels) first */
if (select_mode == SELECT_REPLACE) {
select_mode = SELECT_ADD;
-
+
/* - deselect all other keyframes, so that just the newly selected remain
* - channels aren't deselected, since we don't re-select any as a consequence
*/
deselect_nla_strips(ac, 0, SELECT_SUBTRACT);
}
-
+
/* get range, and get the right flag-setting mode */
if (leftright == NLAEDIT_LRSEL_LEFT) {
xmin = MINAFRAMEF;
@@ -393,19 +393,19 @@ static void nlaedit_select_leftright(bContext *C, bAnimContext *ac, short leftri
xmin = (float)(CFRA - 0.1f);
xmax = MAXFRAMEF;
}
-
+
select_mode = selmodes_to_flagmodes(select_mode);
-
-
+
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* select strips on the side where most data occurs */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
/* check each strip to see if it is appropriate */
for (strip = nlt->strips.first; strip; strip = strip->next) {
if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) {
@@ -413,7 +413,7 @@ static void nlaedit_select_leftright(bContext *C, bAnimContext *ac, short leftri
}
}
}
-
+
/* Cleanup */
ANIM_animdata_freelist(&anim_data);
}
@@ -425,28 +425,28 @@ static int nlaedit_select_leftright_exec(bContext *C, wmOperator *op)
bAnimContext ac;
short leftright = RNA_enum_get(op->ptr, "mode");
short selectmode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* select mode is either replace (deselect all, then add) or add/extend */
if (RNA_boolean_get(op->ptr, "extend"))
selectmode = SELECT_INVERT;
else
selectmode = SELECT_REPLACE;
-
+
/* if "test" mode is set, we don't have any info to set this with */
if (leftright == NLAEDIT_LRSEL_TEST)
return OPERATOR_CANCELLED;
-
+
/* do the selecting now */
nlaedit_select_leftright(C, &ac, leftright, selectmode);
-
+
/* set notifier that keyframe selection (and channels too) have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -454,18 +454,18 @@ static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, const wm
{
bAnimContext ac;
short leftright = RNA_enum_get(op->ptr, "mode");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* handle mode-based testing */
if (leftright == NLAEDIT_LRSEL_TEST) {
Scene *scene = ac.scene;
ARegion *ar = ac.ar;
View2D *v2d = &ar->v2d;
float x;
-
+
/* determine which side of the current frame mouse is on */
x = UI_view2d_region_to_view_x(v2d, event->mval[0]);
if (x < CFRA)
@@ -473,7 +473,7 @@ static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, const wm
else
RNA_enum_set(op->ptr, "mode", NLAEDIT_LRSEL_RIGHT);
}
-
+
/* perform selection */
return nlaedit_select_leftright_exec(C, op);
}
@@ -481,24 +481,24 @@ static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, const wm
void NLA_OT_select_leftright(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Select Left/Right";
ot->idname = "NLA_OT_select_leftright";
ot->description = "Select strips to the left or the right of the current frame";
-
+
/* api callbacks */
ot->invoke = nlaedit_select_leftright_invoke;
ot->exec = nlaedit_select_leftright_exec;
ot->poll = ED_operator_nla_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "mode", prop_nlaedit_leftright_select_types, NLAEDIT_LRSEL_TEST, "Mode", "");
RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
-
+
prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", "");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
@@ -512,7 +512,7 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale = NULL;
int filter;
-
+
SpaceNla *snla = (SpaceNla *)ac->sl;
View2D *v2d = &ac->ar->v2d;
Scene *scene = ac->scene;
@@ -520,22 +520,22 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
int channel_index;
float xmin, xmax;
float x, y;
-
-
+
+
/* use View2D to determine the index of the channel (i.e a row in the list) where keyframe was */
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
UI_view2d_listview_view_to_cell(v2d, 0, NLACHANNEL_STEP(snla), 0, (float)NLACHANNEL_HEIGHT_HALF(snla), x, y, NULL, &channel_index);
-
- /* x-range to check is +/- 7 (in screen/region-space) on either side of mouse click
- * (that is the size of keyframe icons, so user should be expecting similar tolerances)
+
+ /* x-range to check is +/- 7 (in screen/region-space) on either side of mouse click
+ * (that is the size of keyframe icons, so user should be expecting similar tolerances)
*/
xmin = UI_view2d_region_to_view_x(v2d, mval[0] - 7);
xmax = UI_view2d_region_to_view_x(v2d, mval[0] + 7);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* try to get channel */
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
@@ -548,65 +548,65 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
/* found some channel - we only really should do somethign when its an Nla-Track */
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
-
+
/* loop over NLA-strips in this track, trying to find one which occurs in the necessary bounds */
for (strip = nlt->strips.first; strip; strip = strip->next) {
if (BKE_nlastrip_within_bounds(strip, xmin, xmax))
break;
}
}
-
+
/* remove active channel from list of channels for separate treatment (since it's needed later on) */
BLI_remlink(&anim_data, ale);
-
+
/* free list of channels, since it's not used anymore */
ANIM_animdata_freelist(&anim_data);
}
-
+
/* if currently in tweakmode, exit tweakmode before changing selection states
* now that we've found our target...
*/
if (scene->flag & SCE_NLA_EDIT_ON)
WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL);
-
+
/* for replacing selection, firstly need to clear existing selection */
if (select_mode == SELECT_REPLACE) {
/* reset selection mode for next steps */
select_mode = SELECT_ADD;
-
+
/* deselect all strips */
deselect_nla_strips(ac, 0, SELECT_SUBTRACT);
-
+
/* deselect all other channels first */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
}
-
+
/* only select strip if we clicked on a valid channel and hit something */
if (ale) {
/* select the strip accordingly (if a matching one was found) */
if (strip) {
select_mode = selmodes_to_flagmodes(select_mode);
ACHANNEL_SET_FLAG(strip, select_mode, NLASTRIP_FLAG_SELECT);
-
+
/* if we selected it, we can make it active too
- * - we always need to clear the active strip flag though...
+ * - we always need to clear the active strip flag though...
* - as well as selecting its track...
*/
deselect_nla_strips(ac, DESELECT_STRIPS_CLEARACTIVE, 0);
-
+
if (strip->flag & NLASTRIP_FLAG_SELECT) {
strip->flag |= NLASTRIP_FLAG_ACTIVE;
-
+
/* Highlight NLA-Track */
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
-
+
nlt->flag |= NLATRACK_SELECTED;
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nlt, ANIMTYPE_NLATRACK);
}
}
}
-
+
/* free this channel */
MEM_freeN(ale);
}
@@ -626,7 +626,7 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get useful pointers from animation context data */
/* scene= ac.scene; */ /* UNUSED */
/* ar= ac.ar; */ /* UNUSED */
@@ -637,33 +637,33 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent
selectmode = SELECT_INVERT;
else
selectmode = SELECT_REPLACE;
-
+
/* select strips based upon mouse position */
mouse_nla_strips(C, &ac, event->mval, selectmode);
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL);
-
+
/* for tweak grab to work */
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
}
-
+
void NLA_OT_click_select(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Mouse Select";
ot->idname = "NLA_OT_click_select";
ot->description = "Handle clicks to select NLA Strips";
-
+
/* api callbacks - absolutely no exec() this yet... */
ot->invoke = nlaedit_clickselect_invoke;
ot->poll = ED_operator_nla_active;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
-
+
/* properties */
prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index e56fc12c75b..318d8bf777b 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -78,15 +78,15 @@ ARegion *nla_has_buttons_region(ScrArea *sa)
/* is error! */
if (ar == NULL) return NULL;
-
+
arnew = MEM_callocN(sizeof(ARegion), "buttons for nla");
-
+
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
arnew->regiontype = RGN_TYPE_UI;
arnew->alignment = RGN_ALIGN_RIGHT;
-
+
arnew->flag = RGN_FLAG_HIDDEN;
-
+
return arnew;
}
@@ -98,58 +98,58 @@ static SpaceLink *nla_new(const ScrArea *sa, const Scene *scene)
{
ARegion *ar;
SpaceNla *snla;
-
+
snla = MEM_callocN(sizeof(SpaceNla), "initnla");
snla->spacetype = SPACE_NLA;
-
+
/* allocate DopeSheet data for NLA Editor */
snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet");
snla->ads->source = (ID *)scene;
-
+
/* set auto-snapping settings */
snla->autosnap = SACTSNAP_FRAME;
-
+
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for nla");
-
+
BLI_addtail(&snla->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_TOP;
-
+
/* channel list region */
ar = MEM_callocN(sizeof(ARegion), "channel list for nla");
BLI_addtail(&snla->regionbase, ar);
ar->regiontype = RGN_TYPE_CHANNELS;
ar->alignment = RGN_ALIGN_LEFT;
-
+
/* only need to set these settings since this will use the 'stack' configuration */
ar->v2d.scroll = V2D_SCROLL_BOTTOM;
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
-
+
/* ui buttons */
ar = MEM_callocN(sizeof(ARegion), "buttons region for nla");
-
+
BLI_addtail(&snla->regionbase, ar);
ar->regiontype = RGN_TYPE_UI;
ar->alignment = RGN_ALIGN_RIGHT;
ar->flag = RGN_FLAG_HIDDEN;
-
+
/* main region */
ar = MEM_callocN(sizeof(ARegion), "main region for nla");
-
+
BLI_addtail(&snla->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
-
+
ar->v2d.tot.xmin = (float)(SFRA - 10);
ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
ar->v2d.tot.xmax = (float)(EFRA + 10);
ar->v2d.tot.ymax = 0.0f;
-
+
ar->v2d.cur = ar->v2d.tot;
-
+
ar->v2d.min[0] = 0.0f;
ar->v2d.min[1] = 0.0f;
-
+
ar->v2d.max[0] = MAXFRAMEF;
ar->v2d.max[1] = 10000.0f;
@@ -161,15 +161,15 @@ static SpaceLink *nla_new(const ScrArea *sa, const Scene *scene)
ar->v2d.keepofs = V2D_KEEPOFS_Y;
ar->v2d.align = V2D_ALIGN_NO_POS_Y;
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
-
+
return (SpaceLink *)snla;
}
/* not spacelink itself */
static void nla_free(SpaceLink *sl)
-{
+{
SpaceNla *snla = (SpaceNla *) sl;
-
+
if (snla->ads) {
BLI_freelistN(&snla->ads->chanbase);
MEM_freeN(snla->ads);
@@ -181,7 +181,7 @@ static void nla_free(SpaceLink *sl)
static void nla_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
{
SpaceNla *snla = (SpaceNla *)sa->spacedata.first;
-
+
/* init dopesheet data if non-existent (i.e. for old files) */
if (snla->ads == NULL) {
snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet");
@@ -194,10 +194,10 @@ static void nla_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
static SpaceLink *nla_duplicate(SpaceLink *sl)
{
SpaceNla *snlan = MEM_dupallocN(sl);
-
+
/* clear or remove stuff from old */
snlan->ads = MEM_dupallocN(snlan->ads);
-
+
return (SpaceLink *)snlan;
}
@@ -205,12 +205,12 @@ static SpaceLink *nla_duplicate(SpaceLink *sl)
static void nla_channel_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
-
+
/* ensure the 2d view sync works - main region has bottom scroller */
ar->v2d.scroll = V2D_SCROLL_BOTTOM;
-
+
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
-
+
/* own keymap */
/* own channels map first to override some channel keymaps */
keymap = WM_keymap_find(wm->defaultconf, "NLA Channels", SPACE_NLA, 0);
@@ -218,7 +218,7 @@ static void nla_channel_region_init(wmWindowManager *wm, ARegion *ar)
/* now generic channels map for everything else that can apply */
keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
-
+
keymap = WM_keymap_find(wm->defaultconf, "NLA Generic", SPACE_NLA, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
}
@@ -229,21 +229,21 @@ static void nla_channel_region_draw(const bContext *C, ARegion *ar)
bAnimContext ac;
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
-
+
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
glClear(GL_COLOR_BUFFER_BIT);
-
+
UI_view2d_view_ortho(v2d);
-
+
/* data */
if (ANIM_animdata_get_context(C, &ac)) {
draw_nla_channel_list(C, &ac, ar);
}
-
+
/* reset view matrix */
UI_view2d_view_restore(C);
-
+
/* scrollers */
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
UI_view2d_scrollers_draw(C, v2d, scrollers);
@@ -255,9 +255,9 @@ static void nla_channel_region_draw(const bContext *C, ARegion *ar)
static void nla_main_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
-
+
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
-
+
/* own keymap */
keymap = WM_keymap_find(wm->defaultconf, "NLA Editor", SPACE_NLA, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
@@ -275,59 +275,59 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
View2DGrid *grid;
View2DScrollers *scrollers;
short unit = 0, cfra_flag = 0;
-
+
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
glClear(GL_COLOR_BUFFER_BIT);
-
+
UI_view2d_view_ortho(v2d);
-
+
/* time grid */
unit = (snla->flag & SNLA_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
UI_view2d_grid_free(grid);
-
+
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
-
+
/* start and end frame */
ANIM_draw_framerange(scene, v2d);
-
+
/* data */
if (ANIM_animdata_get_context(C, &ac)) {
/* strips and backdrops */
draw_nla_main_data(&ac, snla, ar);
-
+
/* text draw cached, in pixelspace now */
UI_view2d_text_cache_draw(ar);
}
-
+
UI_view2d_view_ortho(v2d);
-
+
/* current frame */
if (snla->flag & SNLA_DRAWTIME) cfra_flag |= DRAWCFRA_UNIT_SECONDS;
ANIM_draw_cfra(C, v2d, cfra_flag);
-
+
/* markers */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
ED_markers_draw(C, DRAW_MARKERS_MARGIN);
-
+
/* preview range */
UI_view2d_view_ortho(v2d);
ANIM_draw_previewrange(C, v2d, 0);
-
+
/* callback */
UI_view2d_view_ortho(v2d);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
/* reset view matrix */
UI_view2d_view_restore(C);
-
+
/* scrollers */
scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
-
+
/* draw current frame number-indicator on top of scrollers */
if ((snla->flag & SNLA_NODRAWCFRANUM) == 0) {
UI_view2d_view_orthoSpecial(ar, v2d, 1);
@@ -351,9 +351,9 @@ static void nla_header_region_draw(const bContext *C, ARegion *ar)
static void nla_buttons_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
-
+
ED_region_panels_init(wm, ar);
-
+
keymap = WM_keymap_find(wm->defaultconf, "NLA Generic", SPACE_NLA, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
}
@@ -541,7 +541,7 @@ static void nla_channel_region_message_subscribe(
.user_data = ar,
.notify = ED_region_do_msg_notify_tag_redraw,
};
-
+
/* All dopesheet filter settings, etc. affect the drawing of this editor,
* so just whitelist the entire struct for updates
*/
@@ -603,7 +603,7 @@ static void nla_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scen
static void nla_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
{
SpaceNla *snla = (SpaceNla *)slink;
-
+
if (snla->ads) {
if ((ID *)snla->ads->filter_grp == old_id) {
snla->ads->filter_grp = (Collection *)new_id;
@@ -619,10 +619,10 @@ void ED_spacetype_nla(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype nla");
ARegionType *art;
-
+
st->spaceid = SPACE_NLA;
strncpy(st->name, "NLA", BKE_ST_MAXNAME);
-
+
st->new = nla_new;
st->free = nla_free;
st->init = nla_init;
@@ -642,31 +642,31 @@ void ED_spacetype_nla(void)
art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype nla region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
-
+
art->init = nla_header_region_init;
art->draw = nla_header_region_draw;
-
+
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: channels */
art = MEM_callocN(sizeof(ARegionType), "spacetype nla region");
art->regionid = RGN_TYPE_CHANNELS;
art->prefsizex = 200;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
-
+
art->init = nla_channel_region_init;
art->draw = nla_channel_region_draw;
art->listener = nla_channel_region_listener;
art->message_subscribe = nla_channel_region_message_subscribe;
-
+
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: UI buttons */
art = MEM_callocN(sizeof(ARegionType), "spacetype nla region");
art->regionid = RGN_TYPE_UI;
@@ -675,11 +675,11 @@ void ED_spacetype_nla(void)
art->listener = nla_region_listener;
art->init = nla_buttons_region_init;
art->draw = nla_buttons_region_draw;
-
+
BLI_addhead(&st->regiontypes, art);
nla_buttons_register(art);
-
-
+
+
BKE_spacetype_register(st);
}
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 19e2ae9808a..db718da12ef 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -94,7 +94,7 @@ static void node_buts_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *p
bNodeSocket *output = node->outputs.first;
PointerRNA sockptr;
RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr);
-
+
uiItemR(layout, &sockptr, "default_value", 0, "", ICON_NONE);
}
@@ -106,14 +106,14 @@ static void node_buts_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr
PointerRNA sockptr;
uiLayout *col;
RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr);
-
+
col = uiLayoutColumn(layout, false);
uiTemplateColorPicker(col, &sockptr, "default_value", 1, 0, 0, 0);
uiItemR(col, &sockptr, "default_value", UI_ITEM_R_SLIDER, "", ICON_NONE);
}
static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
+{
uiLayout *row, *col;
bNodeTree *ntree = (bNodeTree *)ptr->id.data;
@@ -134,7 +134,7 @@ static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *pt
/* XXX no context access here .. */
bNode *node = ptr->data;
CurveMapping *cumap = node->storage;
-
+
if (cumap) {
cumap->flag |= CUMA_DRAW_CFRA;
if (node->custom1 < node->custom2)
@@ -194,7 +194,7 @@ static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA *
bNodeSocket *output = node->outputs.first;
PointerRNA sockptr;
RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr);
-
+
uiItemR(layout, &sockptr, "default_value", 0, "", ICON_NONE);
}
@@ -205,9 +205,9 @@ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v)
bNodeTree *ntree = ntree_v;
bNode *node = node_v;
Tex *tex;
-
+
if (node->menunr < 1) return;
-
+
if (node->id) {
id_us_min(node->id);
node->id = NULL;
@@ -217,16 +217,16 @@ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v)
node->id = &tex->id;
id_us_plus(node->id);
BLI_strncpy(node->name, node->id->name + 2, sizeof(node->name));
-
+
nodeSetActive(ntree, node);
-
+
if (ntree->type == NTREE_TEXTURE)
ntreeTexCheckCyclics(ntree);
-
+
// allqueue(REDRAWBUTSSHADING, 0);
// allqueue(REDRAWNODE, 0);
- NodeTagChanged(ntree, node);
-
+ NodeTagChanged(ntree, node);
+
node->menunr = 0;
}
#endif
@@ -241,9 +241,9 @@ static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA
(node->type != CMP_NODE_TEXTURE) &&
(node->type != TEX_NODE_TEXTURE)
);
-
+
uiItemR(layout, ptr, "texture", 0, "", ICON_NONE);
-
+
if (multi) {
/* Number Drawing not optimal here, better have a list*/
uiItemR(layout, ptr, "node_output", 0, "", ICON_NONE);
@@ -251,7 +251,7 @@ static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA
}
static void node_buts_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
+{
uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
uiItemR(layout, ptr, "use_clamp", 0, NULL, ICON_NONE);
}
@@ -271,7 +271,7 @@ static int node_resize_area_default(bNode *node, int x, int y)
const float size = 10.0f;
rctf totr = node->totr;
int dir = 0;
-
+
if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax)
dir |= NODE_RESIZE_RIGHT;
if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax)
@@ -300,11 +300,11 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree,
bNode *tnode;
rctf rect, noderect;
float xmax, ymax;
-
+
/* init rect from current frame size */
node_to_view(node, node->offsetx, node->offsety, &rect.xmin, &rect.ymax);
node_to_view(node, node->offsetx + node->width, node->offsety - node->height, &rect.xmax, &rect.ymin);
-
+
/* frame can be resized manually only if shrinking is disabled or no children are attached */
data->flag |= NODE_FRAME_RESIZEABLE;
/* for shrinking bbox, initialize the rect from first child node */
@@ -313,14 +313,14 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree,
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
if (tnode->parent != node)
continue;
-
+
/* add margin to node rect */
noderect = tnode->totr;
noderect.xmin -= margin;
noderect.xmax += margin;
noderect.ymin -= margin;
noderect.ymax += margin;
-
+
/* first child initializes frame */
if (bbinit) {
bbinit = 0;
@@ -330,13 +330,13 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree,
else
BLI_rctf_union(&rect, &noderect);
}
-
+
/* now adjust the frame size from view-space bounding box */
node_from_view(node, rect.xmin, rect.ymax, &node->offsetx, &node->offsety);
node_from_view(node, rect.xmax, rect.ymin, &xmax, &ymax);
node->width = xmax - node->offsetx;
node->height = -ymax + node->offsety;
-
+
node->totr = rect;
}
@@ -361,7 +361,7 @@ static void node_draw_frame_label(bNodeTree *ntree, bNode *node, const float asp
BLF_enable(fontid, BLF_ASPECT);
BLF_aspect(fontid, aspect, aspect, 1.0f);
BLF_size(fontid, MIN2(24, font_size), U.dpi); /* clamp otherwise it can suck up a LOT of memory */
-
+
/* title color */
UI_GetThemeColorBlendShade3ubv(TH_TEXT, color_id, 0.4f, 10, color);
BLF_color3ubv(fontid, color);
@@ -369,7 +369,7 @@ static void node_draw_frame_label(bNodeTree *ntree, bNode *node, const float asp
width = BLF_width(fontid, label, sizeof(label));
ascender = BLF_ascender(fontid);
label_height = ((margin / aspect) + (ascender * aspect));
-
+
/* 'x' doesn't need aspect correction */
x = BLI_rctf_cent_x(rct) - (0.5f * width);
y = rct->ymax - label_height;
@@ -431,7 +431,7 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode,
int color_id = node_get_colorid(node);
float color[4];
float alpha;
-
+
/* skip if out of view */
if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == false) {
UI_block_end(C, node->block);
@@ -441,10 +441,10 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode,
UI_GetThemeColor4fv(TH_NODE_FRAME, color);
alpha = color[3];
-
+
/* shadow */
node_draw_shadow(snode, node, BASIS_RAD, alpha);
-
+
/* body */
if (node->flag & NODE_CUSTOM_COLOR) {
rgba_float_args_set(color, node->color[0], node->color[1], node->color[2], alpha);
@@ -467,9 +467,9 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode,
/* label */
node_draw_frame_label(ntree, node, snode->aspect);
-
+
UI_ThemeClearColor(color_id);
-
+
UI_block_end(C, node->block);
UI_block_draw(C, node->block);
node->block = NULL;
@@ -481,11 +481,11 @@ static int node_resize_area_frame(bNode *node, int x, int y)
NodeFrame *data = (NodeFrame *)node->storage;
rctf totr = node->totr;
int dir = 0;
-
+
/* shrinking frame size is determined by child nodes */
if (!(data->flag & NODE_FRAME_RESIZEABLE))
return 0;
-
+
if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax)
dir |= NODE_RESIZE_RIGHT;
if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax)
@@ -494,7 +494,7 @@ static int node_resize_area_frame(bNode *node, int x, int y)
dir |= NODE_RESIZE_TOP;
if (x >= totr.xmin && x < totr.xmax && y >= totr.ymin && y < totr.ymin + size)
dir |= NODE_RESIZE_BOTTOM;
-
+
return dir;
}
@@ -513,10 +513,10 @@ static void node_draw_reroute_prepare(const bContext *UNUSED(C), bNodeTree *UNUS
bNodeSocket *nsock;
float locx, locy;
float size = NODE_REROUTE_SIZE;
-
+
/* get "global" coords */
node_to_view(node, 0.0f, 0.0f, &locx, &locy);
-
+
/* reroute node has exactly one input and one output, both in the same place */
nsock = node->outputs.first;
nsock->locx = locx;
@@ -604,7 +604,7 @@ static int node_tweak_area_reroute(bNode *node, int x, int y)
{
/* square of tweak radius */
const float tweak_radius_sq = SQUARE(24);
-
+
bNodeSocket *sock = node->inputs.first;
float dx = sock->locx - x;
float dy = sock->locy - y;
@@ -644,9 +644,9 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr,
return;
col = uiLayoutColumn(layout, false);
-
+
uiItemR(col, imaptr, "source", 0, "", ICON_NONE);
-
+
source = RNA_enum_get(imaptr, "source");
if (source == IMA_SRC_SEQUENCE) {
@@ -715,12 +715,12 @@ static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), Poin
}
static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
+{
uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
}
static void node_shader_buts_vect_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
+{
uiItemR(layout, ptr, "vector_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
uiItemR(layout, ptr, "convert_from", 0, "", ICON_NONE);
uiItemR(layout, ptr, "convert_to", 0, "", ICON_NONE);
@@ -827,7 +827,7 @@ static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, P
}
static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
+{
uiItemR(layout, ptr, "sky_type", 0, "", ICON_NONE);
uiItemR(layout, ptr, "sun_direction", 0, "", ICON_NONE);
uiItemR(layout, ptr, "turbidity", 0, NULL, ICON_NONE);
@@ -849,11 +849,11 @@ static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), Po
static void node_shader_buts_tex_brick(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *col;
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "offset", UI_ITEM_R_SLIDER, IFACE_("Offset"), ICON_NONE);
uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE);
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE);
uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE);
@@ -1108,15 +1108,15 @@ static void node_shader_set_butfunc(bNodeType *ntype)
case SH_NODE_VALTORGB:
ntype->draw_buttons = node_buts_colorramp;
break;
- case SH_NODE_MATH:
+ case SH_NODE_MATH:
ntype->draw_buttons = node_buts_math;
- break;
- case SH_NODE_VECT_MATH:
+ break;
+ case SH_NODE_VECT_MATH:
ntype->draw_buttons = node_shader_buts_vect_math;
- break;
- case SH_NODE_VECT_TRANSFORM:
+ break;
+ case SH_NODE_VECT_TRANSFORM:
ntype->draw_buttons = node_shader_buts_vect_transform;
- break;
+ break;
case SH_NODE_ATTRIBUTE:
ntype->draw_buttons = node_shader_buts_attribute;
break;
@@ -1237,14 +1237,14 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *
{
bNode *node = ptr->data;
PointerRNA imaptr, iuserptr;
-
+
RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr);
uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
uiTemplateID(
layout, C, ptr, "image",
NULL, "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL);
if (!node->id) return;
-
+
imaptr = RNA_pointer_get(ptr, "image");
node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr, true);
@@ -1273,17 +1273,17 @@ static void node_composit_buts_viewlayers(uiLayout *layout, bContext *C, Pointer
char scene_name[MAX_ID_NAME - 2];
uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL, UI_TEMPLATE_ID_FILTER_ALL);
-
+
if (!node->id) return;
col = uiLayoutColumn(layout, false);
row = uiLayoutRow(col, true);
uiItemR(row, ptr, "layer", 0, "", ICON_NONE);
-
+
prop = RNA_struct_find_property(ptr, "layer");
if (!(RNA_property_enum_identifier(C, ptr, prop, RNA_property_enum_get(ptr, prop), &layer_name)))
return;
-
+
scn_ptr = RNA_pointer_get(ptr, "scene");
RNA_string_get(&scn_ptr, "name", scene_name);
@@ -1298,7 +1298,7 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point
uiLayout *col, *row;
int reference;
int filter;
-
+
col = uiLayoutColumn(layout, false);
filter = RNA_enum_get(ptr, "filter_type");
reference = RNA_boolean_get(ptr, "use_variable_size");
@@ -1311,14 +1311,14 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point
}
uiItemR(col, ptr, "use_gamma_correction", 0, NULL, ICON_NONE);
}
-
+
uiItemR(col, ptr, "use_relative", 0, NULL, ICON_NONE);
-
+
if (RNA_boolean_get(ptr, "use_relative")) {
uiItemL(col, IFACE_("Aspect Correction"), ICON_NONE);
row = uiLayoutRow(layout, true);
uiItemR(row, ptr, "aspect_correction", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "factor_x", 0, IFACE_("X"), ICON_NONE);
uiItemR(col, ptr, "factor_y", 0, IFACE_("Y"), ICON_NONE);
@@ -1334,31 +1334,31 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point
static void node_composit_buts_dblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *col;
-
+
uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "use_wrap", 0, NULL, ICON_NONE);
-
+
col = uiLayoutColumn(layout, true);
uiItemL(col, IFACE_("Center:"), ICON_NONE);
uiItemR(col, ptr, "center_x", 0, IFACE_("X"), ICON_NONE);
uiItemR(col, ptr, "center_y", 0, IFACE_("Y"), ICON_NONE);
-
+
uiItemS(layout);
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "distance", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE);
-
+
uiItemS(layout);
-
+
uiItemR(layout, ptr, "spin", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "zoom", 0, NULL, ICON_NONE);
}
static void node_composit_buts_bilateralblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
+{
uiLayout *col;
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "iterations", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "sigma_color", 0, NULL, ICON_NONE);
@@ -1368,7 +1368,7 @@ static void node_composit_buts_bilateralblur(uiLayout *layout, bContext *UNUSED(
static void node_composit_buts_defocus(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
uiLayout *sub, *col;
-
+
col = uiLayoutColumn(layout, false);
uiItemL(col, IFACE_("Bokeh Type:"), ICON_NONE);
uiItemR(col, ptr, "bokeh", 0, "", ICON_NONE);
@@ -1397,17 +1397,17 @@ static void node_composit_buts_defocus(uiLayout *layout, bContext *C, PointerRNA
/* qdn: glare node */
static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
+{
uiItemR(layout, ptr, "glare_type", 0, "", ICON_NONE);
uiItemR(layout, ptr, "quality", 0, "", ICON_NONE);
if (RNA_enum_get(ptr, "glare_type") != 1) {
uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
-
+
if (RNA_enum_get(ptr, "glare_type") != 0)
uiItemR(layout, ptr, "color_modulation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
}
-
+
uiItemR(layout, ptr, "mix", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE);
@@ -1417,7 +1417,7 @@ static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), Poin
}
if (RNA_enum_get(ptr, "glare_type") == 0 || RNA_enum_get(ptr, "glare_type") == 2) {
uiItemR(layout, ptr, "fade", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
-
+
if (RNA_enum_get(ptr, "glare_type") == 0)
uiItemR(layout, ptr, "use_rotate_45", 0, NULL, ICON_NONE);
}
@@ -1427,7 +1427,7 @@ static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), Poin
}
static void node_composit_buts_tonemap(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
+{
uiLayout *col;
col = uiLayoutColumn(layout, false);
@@ -1461,11 +1461,11 @@ static void node_composit_buts_lensdist(uiLayout *layout, bContext *UNUSED(C), P
static void node_composit_buts_vecblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *col;
-
+
col = uiLayoutColumn(layout, false);
uiItemR(col, ptr, "samples", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "factor", 0, IFACE_("Blur"), ICON_NONE);
-
+
col = uiLayoutColumn(layout, true);
uiItemL(col, IFACE_("Speed:"), ICON_NONE);
uiItemR(col, ptr, "speed_min", 0, IFACE_("Min"), ICON_NONE);
@@ -1509,7 +1509,7 @@ static void node_composit_buts_crop(uiLayout *layout, bContext *UNUSED(C), Point
static void node_composit_buts_splitviewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *row, *col;
-
+
col = uiLayoutColumn(layout, false);
row = uiLayoutRow(col, false);
uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
@@ -1539,17 +1539,17 @@ static void node_composit_buts_map_range(uiLayout *layout, bContext *UNUSED(C),
static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *sub, *col;
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "size", 0, NULL, ICON_NONE);
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "use_min", 0, NULL, ICON_NONE);
sub = uiLayoutColumn(col, false);
uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_min"));
uiItemR(sub, ptr, "min", 0, "", ICON_NONE);
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "use_max", 0, NULL, ICON_NONE);
sub = uiLayoutColumn(col, false);
@@ -1558,18 +1558,18 @@ static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C),
}
static void node_composit_buts_alphaover(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
+{
uiLayout *col;
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "use_premultiply", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "premul", 0, NULL, ICON_NONE);
}
static void node_composit_buts_zcombine(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
+{
uiLayout *col;
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "use_alpha", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "use_antialias_z", 0, NULL, ICON_NONE);
@@ -1606,7 +1606,7 @@ static void node_composit_buts_despeckle(uiLayout *layout, bContext *UNUSED(C),
static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *col;
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
@@ -1615,7 +1615,7 @@ static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C),
static void node_composit_buts_distance_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *col, *row;
-
+
col = uiLayoutColumn(layout, true);
uiItemL(layout, IFACE_("Color Space:"), ICON_NONE);
@@ -1629,7 +1629,7 @@ static void node_composit_buts_distance_matte(uiLayout *layout, bContext *UNUSED
static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *row, *col;
-
+
uiItemL(layout, IFACE_("Despill Channel:"), ICON_NONE);
row = uiLayoutRow(layout, false);
uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
@@ -1655,11 +1655,11 @@ static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C)
static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *col;
-
+
col = uiLayoutColumn(layout, false);
uiItemR(col, ptr, "tolerance", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE);
-
+
col = uiLayoutColumn(layout, true);
/*uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now */
uiItemR(col, ptr, "gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
@@ -1669,7 +1669,7 @@ static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C
static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *col;
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
@@ -1677,7 +1677,7 @@ static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C)
}
static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
+{
uiLayout *col, *row;
uiItemL(layout, IFACE_("Color Space:"), ICON_NONE);
@@ -1705,7 +1705,7 @@ static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED(
static void node_composit_buts_luma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *col;
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
@@ -1743,22 +1743,22 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi
int active_index;
const bool multilayer = RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER;
const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
-
+
node_composit_buts_file_output(layout, C, ptr);
uiTemplateImageSettings(layout, &imfptr, false);
-
+
/* disable stereo output for multilayer, too much work for something that no one will use */
/* if someone asks for that we can implement it */
if (is_multiview)
uiTemplateImageFormatViews(layout, &imfptr, NULL);
uiItemS(layout);
-
+
uiItemO(layout, IFACE_("Add Input"), ICON_ZOOMIN, "NODE_OT_output_file_add_socket");
-
+
row = uiLayoutRow(layout, false);
col = uiLayoutColumn(row, true);
-
+
active_index = RNA_int_get(ptr, "active_input_index");
/* using different collection properties if multilayer format is enabled */
if (multilayer) {
@@ -1775,18 +1775,18 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi
}
/* XXX collection lookup does not return the ID part of the pointer, setting this manually here */
active_input_ptr.id.data = ptr->id.data;
-
+
col = uiLayoutColumn(row, true);
ot = WM_operatortype_find("NODE_OT_output_file_move_active_socket", false);
uiItemFullO_ptr(col, ot, "", ICON_TRIA_UP, NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr);
RNA_enum_set(&op_ptr, "direction", 1);
uiItemFullO_ptr(col, ot, "", ICON_TRIA_DOWN, NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr);
RNA_enum_set(&op_ptr, "direction", 2);
-
+
if (active_input_ptr.data) {
if (multilayer) {
col = uiLayoutColumn(layout, true);
-
+
uiItemL(col, IFACE_("Layer:"), ICON_NONE);
row = uiLayoutRow(col, false);
uiItemR(row, &active_input_ptr, "name", 0, "", ICON_NONE);
@@ -1795,20 +1795,20 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi
}
else {
col = uiLayoutColumn(layout, true);
-
+
uiItemL(col, IFACE_("File Subpath:"), ICON_NONE);
row = uiLayoutRow(col, false);
uiItemR(row, &active_input_ptr, "path", 0, "", ICON_NONE);
uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "",
ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY, NULL);
-
+
/* format details for individual files */
imfptr = RNA_pointer_get(&active_input_ptr, "format");
-
+
col = uiLayoutColumn(layout, true);
uiItemL(col, IFACE_("Format:"), ICON_NONE);
uiItemR(col, &active_input_ptr, "use_node_format", 0, NULL, ICON_NONE);
-
+
col = uiLayoutColumn(layout, false);
uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == false);
uiTemplateImageSettings(col, &imfptr, false);
@@ -1840,7 +1840,7 @@ static void node_composit_buts_rotate(uiLayout *layout, bContext *UNUSED(C), Poi
static void node_composit_buts_invert(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *col;
-
+
col = uiLayoutColumn(layout, false);
uiItemR(col, ptr, "invert_rgb", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "invert_alpha", 0, NULL, ICON_NONE);
@@ -1859,22 +1859,22 @@ static void node_composit_buts_view_levels(uiLayout *layout, bContext *UNUSED(C)
static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *split, *col, *row;
-
+
uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE);
-
+
if (RNA_enum_get(ptr, "correction_method") == 0) {
-
+
split = uiLayoutSplit(layout, 0.0f, false);
col = uiLayoutColumn(split, false);
uiTemplateColorPicker(col, ptr, "lift", 1, 1, 0, 1);
row = uiLayoutRow(col, false);
uiItemR(row, ptr, "lift", 0, NULL, ICON_NONE);
-
+
col = uiLayoutColumn(split, false);
uiTemplateColorPicker(col, ptr, "gamma", 1, 1, 1, 1);
row = uiLayoutRow(col, false);
uiItemR(row, ptr, "gamma", 0, NULL, ICON_NONE);
-
+
col = uiLayoutColumn(split, false);
uiTemplateColorPicker(col, ptr, "gain", 1, 1, 1, 1);
row = uiLayoutRow(col, false);
@@ -1882,19 +1882,19 @@ static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C
}
else {
-
+
split = uiLayoutSplit(layout, 0.0f, false);
col = uiLayoutColumn(split, false);
uiTemplateColorPicker(col, ptr, "offset", 1, 1, 0, 1);
row = uiLayoutRow(col, false);
uiItemR(row, ptr, "offset", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "offset_basis", 0, NULL, ICON_NONE);
-
+
col = uiLayoutColumn(split, false);
uiTemplateColorPicker(col, ptr, "power", 1, 1, 0, 1);
row = uiLayoutRow(col, false);
uiItemR(row, ptr, "power", 0, NULL, ICON_NONE);
-
+
col = uiLayoutColumn(split, false);
uiTemplateColorPicker(col, ptr, "slope", 1, 1, 0, 1);
row = uiLayoutRow(col, false);
@@ -1947,7 +1947,7 @@ static void node_composit_buts_huecorrect(uiLayout *layout, bContext *UNUSED(C),
}
static void node_composit_buts_ycc(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
+{
uiItemR(layout, ptr, "mode", 0, "", ICON_NONE);
}
@@ -2010,7 +2010,7 @@ static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, Po
static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *row;
-
+
row = uiLayoutRow(layout, false);
uiItemR(row, ptr, "red", 0, NULL, ICON_NONE);
uiItemR(row, ptr, "green", 0, NULL, ICON_NONE);
@@ -2064,7 +2064,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE
static void node_composit_buts_colorcorrection_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *row;
-
+
row = uiLayoutRow(layout, false);
uiItemR(row, ptr, "red", 0, NULL, ICON_NONE);
uiItemR(row, ptr, "green", 0, NULL, ICON_NONE);
@@ -2093,7 +2093,7 @@ static void node_composit_buts_colorcorrection_ex(uiLayout *layout, bContext *UN
uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
-
+
uiItemL(row, IFACE_("Lift"), ICON_NONE);
uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
@@ -2120,11 +2120,11 @@ static void node_composit_buts_switch_view_ex(uiLayout *layout, bContext *UNUSED
static void node_composit_buts_boxmask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *row;
-
+
row = uiLayoutRow(layout, true);
uiItemR(row, ptr, "x", 0, NULL, ICON_NONE);
uiItemR(row, ptr, "y", 0, NULL, ICON_NONE);
-
+
row = uiLayoutRow(layout, true);
uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
@@ -2293,7 +2293,7 @@ static void node_composit_buts_viewer(uiLayout *layout, bContext *UNUSED(C), Poi
static void node_composit_buts_viewer_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *col;
-
+
uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "tile_order", 0, NULL, ICON_NONE);
if (RNA_enum_get(ptr, "tile_order") == 0) {
@@ -2691,11 +2691,11 @@ static void node_composit_set_butfunc(bNodeType *ntype)
static void node_texture_buts_bricks(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *col;
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "offset", UI_ITEM_R_SLIDER, IFACE_("Offset"), ICON_NONE);
uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE);
-
+
col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE);
uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE);
@@ -2708,7 +2708,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe
ID *id = ptr->id.data;
Tex *tex = (Tex *)node->storage;
uiLayout *col, *row;
-
+
RNA_pointer_create(id, &RNA_Texture, tex, &tex_ptr);
col = uiLayoutColumn(layout, false);
@@ -2752,7 +2752,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe
uiLayoutSetActive(row, !(ELEM(tex->stype, TEX_BAND, TEX_RING)));
uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
break;
-
+
case TEX_CLOUDS:
uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
row = uiLayoutRow(col, false);
@@ -2761,7 +2761,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe
uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
uiItemR(col, &tex_ptr, "noise_depth", UI_ITEM_R_EXPAND, IFACE_("Depth"), ICON_NONE);
break;
-
+
case TEX_DISTNOISE:
uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
uiItemR(col, &tex_ptr, "noise_distortion", 0, "", ICON_NONE);
@@ -2862,7 +2862,7 @@ static void node_socket_template_properties_update(bNodeType *ntype, bNodeSocket
{
StructRNA *srna = ntype->ext.srna;
PropertyRNA *prop = RNA_struct_type_find_property(srna, stemp->identifier);
-
+
if (prop)
RNA_def_property_update_runtime(prop, node_property_update_default);
}
@@ -2870,7 +2870,7 @@ static void node_socket_template_properties_update(bNodeType *ntype, bNodeSocket
static void node_template_properties_update(bNodeType *ntype)
{
bNodeSocketTemplate *stemp;
-
+
if (ntype->inputs) {
for (stemp = ntype->inputs; stemp->type >= 0; ++stemp)
node_socket_template_properties_update(ntype, stemp);
@@ -2916,7 +2916,7 @@ void ED_node_init_butfuncs(void)
/*extern bNodeTreeType NodeTreeTypeUndefined;*/
extern bNodeType NodeTypeUndefined;
extern bNodeSocketType NodeSocketTypeUndefined;
-
+
/* default ui functions */
NodeTypeUndefined.draw_nodetype = node_draw_default;
NodeTypeUndefined.draw_nodetype_prepare = node_update_default;
@@ -2925,12 +2925,12 @@ void ED_node_init_butfuncs(void)
NodeTypeUndefined.draw_buttons = NULL;
NodeTypeUndefined.draw_buttons_ex = NULL;
NodeTypeUndefined.resize_area_func = node_resize_area_default;
-
+
NodeSocketTypeUndefined.draw = node_socket_undefined_draw;
NodeSocketTypeUndefined.draw_color = node_socket_undefined_draw_color;
NodeSocketTypeUndefined.interface_draw = node_socket_undefined_interface_draw;
NodeSocketTypeUndefined.interface_draw_color = node_socket_undefined_interface_draw_color;
-
+
/* node type ui functions */
NODE_TYPES_BEGIN(ntype)
/* default ui functions */
@@ -2941,17 +2941,17 @@ void ED_node_init_butfuncs(void)
ntype->draw_buttons = NULL;
ntype->draw_buttons_ex = NULL;
ntype->resize_area_func = node_resize_area_default;
-
+
node_common_set_butfunc(ntype);
-
+
node_composit_set_butfunc(ntype);
node_shader_set_butfunc(ntype);
node_texture_set_butfunc(ntype);
-
+
/* define update callbacks for socket properties */
node_template_properties_update(ntype);
NODE_TYPES_END
-
+
/* tree type icons */
ntreeType_Composite->ui_icon = ICON_RENDERLAYERS;
ntreeType_Shader->ui_icon = ICON_MATERIAL;
@@ -3008,16 +3008,16 @@ static void node_file_output_socket_draw(bContext *C, uiLayout *layout, PointerR
uiLayout *row;
PointerRNA inputptr, imfptr;
int imtype;
-
+
row = uiLayoutRow(layout, false);
-
+
imfptr = RNA_pointer_get(node_ptr, "format");
imtype = RNA_enum_get(&imfptr, "file_format");
if (imtype == R_IMF_IMTYPE_MULTILAYER) {
NodeImageMultiFileSocket *input = sock->storage;
RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr);
-
+
uiItemL(row, input->layer, ICON_NONE);
}
else {
@@ -3026,12 +3026,12 @@ static void node_file_output_socket_draw(bContext *C, uiLayout *layout, PointerR
const char *imtype_name;
uiBlock *block;
RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr);
-
+
uiItemL(row, input->path, ICON_NONE);
-
+
if (!RNA_boolean_get(&inputptr, "use_node_format"))
imfptr = RNA_pointer_get(&inputptr, "format");
-
+
imtype_prop = RNA_struct_find_property(&imfptr, "file_format");
RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop,
RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name);
@@ -3048,7 +3048,7 @@ static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr,
bNodeSocket *sock = ptr->data;
int type = sock->typeinfo->type;
/*int subtype = sock->typeinfo->subtype;*/
-
+
/* XXX not nice, eventually give this node its own socket type ... */
if (node->type == CMP_NODE_OUTPUT_FILE) {
node_file_output_socket_draw(C, layout, ptr, node_ptr);
@@ -3059,7 +3059,7 @@ static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr,
node_socket_button_label(C, layout, ptr, node_ptr, text);
return;
}
-
+
switch (type) {
case SOCK_FLOAT:
case SOCK_INT:
@@ -3088,7 +3088,7 @@ static void std_node_socket_interface_draw(bContext *UNUSED(C), uiLayout *layout
bNodeSocket *sock = ptr->data;
int type = sock->typeinfo->type;
/*int subtype = sock->typeinfo->subtype;*/
-
+
switch (type) {
case SOCK_FLOAT:
{
@@ -3151,38 +3151,39 @@ void ED_init_node_socket_type_virtual(bNodeSocketType *stype)
void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeInstanceKey parent_key)
{
+ Main *bmain = CTX_data_main(C);
bNodeInstanceKey active_viewer_key = (snode->nodetree ? snode->nodetree->active_viewer_key : NODE_INSTANCE_KEY_NONE);
float shuffle[4] = {0.0f, 0.0f, 0.0f, 0.0f};
Image *ima;
void *lock;
ImBuf *ibuf;
-
+
if (!(snode->flag & SNODE_BACKDRAW) || !ED_node_is_compositor(snode))
return;
-
+
if (parent_key.value != active_viewer_key.value)
return;
-
- ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+
+ ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf) {
- float x, y;
+ float x, y;
gpuPushProjectionMatrix();
gpuPushMatrix();
/* somehow the offset has to be calculated inverse */
wmOrtho2_region_pixelspace(ar);
-
+
x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof;
y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof;
-
+
if (ibuf->rect || ibuf->rect_float) {
unsigned char *display_buffer = NULL;
void *cache_handle = NULL;
-
+
if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B | SNODE_SHOW_ALPHA)) {
-
+
display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
if (snode->flag & SNODE_SHOW_R)
@@ -3213,11 +3214,11 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
else {
glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom);
}
-
+
if (cache_handle)
IMB_display_buffer_release(cache_handle);
}
-
+
/** \note draw selected info on backdrop */
if (snode->edittree) {
bNode *node = snode->edittree->nodes.first;
@@ -3230,7 +3231,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
}
node = node->next;
}
-
+
if ((snode->nodetree->flag & NTREE_VIEWER_BORDER) &&
viewer_border->xmin < viewer_border->xmax &&
viewer_border->ymin < viewer_border->ymax)
@@ -3255,7 +3256,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
gpuPopProjectionMatrix();
gpuPopMatrix();
}
-
+
BKE_image_release_ibuf(ima, ibuf, lock);
}
@@ -3266,14 +3267,14 @@ static bool node_link_bezier_handles(View2D *v2d, SpaceNode *snode, bNodeLink *l
float deltax, deltay;
float cursor[2] = {0.0f, 0.0f};
int toreroute, fromreroute;
-
+
/* this function can be called with snode null (via cut_links_intersect) */
/* XXX map snode->cursor back to view space */
if (snode) {
cursor[0] = snode->cursor[0] * UI_DPI_FAC;
cursor[1] = snode->cursor[1] * UI_DPI_FAC;
}
-
+
/* in v0 and v3 we put begin/end points */
if (link->fromsock) {
vec[0][0] = link->fromsock->locx;
@@ -3352,7 +3353,7 @@ bool node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, flo
coord_array[0] + 0, resol, sizeof(float) * 2);
BKE_curve_forward_diff_bezier(vec[0][1], vec[1][1], vec[2][1], vec[3][1],
coord_array[0] + 1, resol, sizeof(float) * 2);
-
+
return 1;
}
return 0;
@@ -3595,10 +3596,10 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link,
void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
{
int th_col1 = TH_WIRE_INNER, th_col2 = TH_WIRE_INNER, th_col3 = TH_WIRE;
-
+
if (link->fromsock == NULL && link->tosock == NULL)
return;
-
+
/* new connection */
if (!link->fromsock || !link->tosock) {
th_col1 = th_col2 = TH_ACTIVE;
@@ -3636,7 +3637,7 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border, unsigned pos)
{
immBegin(GWN_PRIM_LINES, 4);
-
+
if (border & (NODE_LEFT | NODE_RIGHT)) {
immVertex2f(pos, cent[0], v2d->cur.ymin);
immVertex2f(pos, cent[0], v2d->cur.ymax);
@@ -3645,7 +3646,7 @@ void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder
immVertex2f(pos, cent[0], cent[1] - size);
immVertex2f(pos, cent[0], cent[1] + size);
}
-
+
if (border & (NODE_TOP | NODE_BOTTOM)) {
immVertex2f(pos, v2d->cur.xmin, cent[1]);
immVertex2f(pos, v2d->cur.xmax, cent[1]);
@@ -3654,6 +3655,6 @@ void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder
immVertex2f(pos, cent[0] - size, cent[1]);
immVertex2f(pos, cent[0] + size, cent[1]);
}
-
+
immEnd();
}
diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c
index c200c5a7612..72b1a35973a 100644
--- a/source/blender/editors/space_node/node_add.c
+++ b/source/blender/editors/space_node/node_add.c
@@ -70,32 +70,32 @@ bNode *node_add_node(const bContext *C, const char *idname, int type, float locx
SpaceNode *snode = CTX_wm_space_node(C);
Main *bmain = CTX_data_main(C);
bNode *node = NULL;
-
+
node_deselect_all(snode);
-
+
if (idname)
node = nodeAddNode(C, snode->edittree, idname);
else
node = nodeAddStaticNode(C, snode->edittree, type);
BLI_assert(node && node->typeinfo);
-
+
/* generics */
node->locx = locx;
node->locy = locy + 60.0f; /* arbitrary... so its visible, (0,0) is top of node */
nodeSetSelected(node, true);
-
+
node->locx = locx;
node->locy = locy + 60.0f;
-
+
ntreeUpdateTree(bmain, snode->edittree);
ED_node_set_active(bmain, snode->edittree, node);
-
+
snode_update(snode, node);
-
+
if (snode->nodetree->type == NTREE_TEXTURE) {
ntreeTexCheckCyclics(snode->edittree);
}
-
+
return node;
}
@@ -122,7 +122,7 @@ static bool add_reroute_intersect_check(bNodeLink *link, float mcoords[][2], int
typedef struct bNodeSocketLink {
struct bNodeSocketLink *next, *prev;
-
+
struct bNodeSocket *sock;
struct bNodeLink *link;
float point[2];
@@ -131,12 +131,12 @@ typedef struct bNodeSocketLink {
static bNodeSocketLink *add_reroute_insert_socket_link(ListBase *lb, bNodeSocket *sock, bNodeLink *link, const float point[2])
{
bNodeSocketLink *socklink, *prev;
-
+
socklink = MEM_callocN(sizeof(bNodeSocketLink), "socket link");
socklink->sock = sock;
socklink->link = link;
copy_v2_v2(socklink->point, point);
-
+
for (prev = lb->last; prev; prev = prev->prev) {
if (prev->sock == sock)
break;
@@ -153,18 +153,18 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C, bNodeSocketLi
bNodeSocket *cursock = socklink->sock;
float insert_point[2];
int num_links;
-
+
zero_v2(insert_point);
num_links = 0;
-
+
while (socklink && socklink->sock == cursock) {
if (!(socklink->link->flag & NODE_LINK_TEST)) {
socklink->link->flag |= NODE_LINK_TEST;
-
+
/* create the reroute node for this cursock */
if (!reroute_node) {
reroute_node = nodeAddStaticNode(C, ntree, NODE_REROUTE);
-
+
/* add a single link to/from the reroute node to replace multiple links */
if (in_out == SOCK_OUT) {
nodeAddLink(ntree, socklink->link->fromnode, socklink->link->fromsock, reroute_node, reroute_node->inputs.first);
@@ -173,7 +173,7 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C, bNodeSocketLi
nodeAddLink(ntree, reroute_node, reroute_node->outputs.first, socklink->link->tonode, socklink->link->tosock);
}
}
-
+
/* insert the reroute node into the link */
if (in_out == SOCK_OUT) {
socklink->link->fromnode = reroute_node;
@@ -183,21 +183,21 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C, bNodeSocketLi
socklink->link->tonode = reroute_node;
socklink->link->tosock = reroute_node->inputs.first;
}
-
+
add_v2_v2(insert_point, socklink->point);
num_links++;
}
socklink = socklink->next;
}
-
+
if (num_links > 0) {
/* average cut point from shared links */
mul_v2_fl(insert_point, 1.0f / num_links);
-
+
reroute_node->locx = insert_point[0] / UI_DPI_FAC;
reroute_node->locy = insert_point[1] / UI_DPI_FAC;
}
-
+
return socklink;
}
@@ -208,7 +208,7 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
bNodeTree *ntree = snode->edittree;
float mcoords[256][2];
int i = 0;
-
+
/* Get the cut path */
RNA_BEGIN (op->ptr, itemptr, "path")
{
@@ -227,12 +227,12 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
bNodeLink *link;
bNodeSocketLink *socklink;
float insert_point[2];
-
+
/* always first */
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
-
+
node_deselect_all(snode);
-
+
/* Find cut links and sort them by sockets */
BLI_listbase_clear(&output_links);
BLI_listbase_clear(&input_links);
@@ -243,12 +243,12 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
if (add_reroute_intersect_check(link, mcoords, i, insert_point)) {
add_reroute_insert_socket_link(&output_links, link->fromsock, link, insert_point);
add_reroute_insert_socket_link(&input_links, link->tosock, link, insert_point);
-
+
/* Clear flag */
link->flag &= ~NODE_LINK_TEST;
}
}
-
+
/* Create reroute nodes for intersected links.
* Only one reroute if links share the same input/output socket.
*/
@@ -260,18 +260,18 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
while (socklink) {
socklink = add_reroute_do_socket_section(C, socklink, SOCK_IN);
}
-
+
BLI_freelistN(&output_links);
BLI_freelistN(&input_links);
-
+
/* always last */
ntreeUpdateTree(CTX_data_main(C), ntree);
snode_notify(C, snode);
snode_dag_update(C, snode);
-
+
return OPERATOR_FINISHED;
}
-
+
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
}
@@ -304,6 +304,7 @@ void NODE_OT_add_reroute(wmOperatorType *ot)
static int node_add_file_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
bNode *node;
Image *ima;
@@ -327,29 +328,29 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
default:
return OPERATOR_CANCELLED;
}
-
+
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
-
+
node = node_add_node(C, NULL, type, snode->cursor[0], snode->cursor[1]);
-
+
if (!node) {
BKE_report(op->reports, RPT_WARNING, "Could not add an image node");
return OPERATOR_CANCELLED;
}
-
+
node->id = (ID *)ima;
/* When adding new image file via drag-drop we need to load imbuf in order
* to get proper image source.
*/
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
- BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
+ BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_RELOAD);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
}
snode_notify(C, snode);
snode_dag_update(C, snode);
-
+
return OPERATOR_FINISHED;
}
@@ -357,11 +358,11 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *even
{
ARegion *ar = CTX_wm_region(C);
SpaceNode *snode = CTX_wm_space_node(C);
-
+
/* convert mouse coordinates to v2d space */
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
&snode->cursor[0], &snode->cursor[1]);
-
+
if (RNA_struct_property_is_set(op->ptr, "filepath") || RNA_struct_property_is_set(op->ptr, "name"))
return node_add_file_exec(C, op);
else
@@ -400,6 +401,7 @@ static int node_add_mask_poll(bContext *C)
static int node_add_mask_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
bNode *node;
ID *mask = NULL;
@@ -407,7 +409,7 @@ static int node_add_mask_exec(bContext *C, wmOperator *op)
/* check input variables */
char name[MAX_ID_NAME - 2];
RNA_string_get(op->ptr, "name", name);
- mask = BKE_libblock_find_name(ID_MSK, name);
+ mask = BKE_libblock_find_name(bmain, ID_MSK, name);
if (!mask) {
BKE_reportf(op->reports, RPT_ERROR, "Mask '%s' not found", name);
return OPERATOR_CANCELLED;
@@ -460,7 +462,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op)
const char *idname;
char treename_buf[MAX_ID_NAME - 2];
const char *treename;
-
+
if (RNA_struct_property_is_set(op->ptr, "type")) {
prop = RNA_struct_find_property(op->ptr, "type");
RNA_property_enum_identifier(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &idname);
@@ -469,7 +471,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op)
idname = snode->tree_idname;
else
return OPERATOR_CANCELLED;
-
+
if (RNA_struct_property_is_set(op->ptr, "name")) {
RNA_string_get(op->ptr, "name", treename_buf);
treename = treename_buf;
@@ -477,14 +479,14 @@ static int new_node_tree_exec(bContext *C, wmOperator *op)
else {
treename = DATA_("NodeTree");
}
-
+
if (!ntreeTypeFind(idname)) {
BKE_reportf(op->reports, RPT_ERROR, "Node tree type %s undefined", idname);
return OPERATOR_CANCELLED;
}
-
+
ntree = ntreeAddTree(bmain, treename, idname);
-
+
/* hook into UI */
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
@@ -500,10 +502,10 @@ static int new_node_tree_exec(bContext *C, wmOperator *op)
}
else if (snode) {
snode->nodetree = ntree;
-
+
ED_node_tree_update(C);
}
-
+
return OPERATOR_FINISHED;
}
@@ -515,18 +517,18 @@ static const EnumPropertyItem *new_node_tree_type_itemf(bContext *UNUSED(C), Poi
void NODE_OT_new_node_tree(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "New Node Tree";
ot->idname = "NODE_OT_new_node_tree";
ot->description = "Create a new node tree";
-
+
/* api callbacks */
ot->exec = new_node_tree_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
prop = RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Tree Type", "");
RNA_def_enum_funcs(prop, new_node_tree_type_itemf);
RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME - 2, "Name", "");
diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c
index e8b4e6ec990..0a656ee1deb 100644
--- a/source/blender/editors/space_node/node_buttons.c
+++ b/source/blender/editors/space_node/node_buttons.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -62,7 +62,7 @@
static int active_nodetree_poll(const bContext *C, PanelType *UNUSED(pt))
{
SpaceNode *snode = CTX_wm_space_node(C);
-
+
return (snode && snode->nodetree);
}
#endif
@@ -70,7 +70,7 @@ static int active_nodetree_poll(const bContext *C, PanelType *UNUSED(pt))
static int node_sockets_poll(const bContext *C, PanelType *UNUSED(pt))
{
SpaceNode *snode = CTX_wm_space_node(C);
-
+
return (snode && snode->nodetree && G.debug_value == 777);
}
@@ -82,10 +82,10 @@ static void node_sockets_panel(const bContext *C, Panel *pa)
bNodeSocket *sock;
uiLayout *layout = pa->layout, *split;
char name[UI_MAX_NAME_STR];
-
+
if (ELEM(NULL, ntree, node))
return;
-
+
for (sock = node->inputs.first; sock; sock = sock->next) {
BLI_snprintf(name, sizeof(name), "%s:", sock->name);
@@ -98,7 +98,7 @@ static void node_sockets_panel(const bContext *C, Panel *pa)
static int node_tree_interface_poll(const bContext *C, PanelType *UNUSED(pt))
{
SpaceNode *snode = CTX_wm_space_node(C);
-
+
return (snode && snode->edittree && (snode->edittree->inputs.first || snode->edittree->outputs.first));
}
@@ -119,7 +119,7 @@ static bool node_tree_find_active_socket(bNodeTree *ntree, bNodeSocket **r_sock,
return true;
}
}
-
+
*r_sock = NULL;
*r_in_out = 0;
return false;
@@ -137,14 +137,14 @@ static void node_tree_interface_panel(const bContext *C, Panel *pa)
if (!ntree)
return;
-
+
RNA_id_pointer_create((ID *)ntree, &ptr);
-
+
node_tree_find_active_socket(ntree, &sock, &in_out);
RNA_pointer_create((ID *)ntree, &RNA_NodeSocketInterface, sock, &sockptr);
-
+
row = uiLayoutRow(layout, false);
-
+
split = uiLayoutRow(row, true);
col = uiLayoutColumn(split, true);
ot = WM_operatortype_find("NODE_OT_tree_socket_add", false);
@@ -153,26 +153,26 @@ static void node_tree_interface_panel(const bContext *C, Panel *pa)
NULL, 0, 0, 0, 0);
uiItemFullO_ptr(col, ot, "", ICON_PLUS, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr);
RNA_enum_set(&opptr, "in_out", SOCK_IN);
-
+
col = uiLayoutColumn(split, true);
uiItemL(col, IFACE_("Outputs:"), ICON_NONE);
uiTemplateList(col, (bContext *)C, "NODE_UL_interface_sockets", "outputs", &ptr, "outputs", &ptr, "active_output",
NULL, 0, 0, 0, 0);
uiItemFullO_ptr(col, ot, "", ICON_PLUS, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr);
RNA_enum_set(&opptr, "in_out", SOCK_OUT);
-
+
ot = WM_operatortype_find("NODE_OT_tree_socket_move", false);
col = uiLayoutColumn(row, true);
uiItemFullO_ptr(col, ot, "", ICON_TRIA_UP, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr);
RNA_enum_set(&opptr, "direction", 1);
uiItemFullO_ptr(col, ot, "", ICON_TRIA_DOWN, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr);
RNA_enum_set(&opptr, "direction", 2);
-
+
if (sock) {
row = uiLayoutRow(layout, true);
uiItemR(row, &sockptr, "name", 0, NULL, ICON_NONE);
uiItemO(row, "", ICON_X, "NODE_OT_tree_socket_remove");
-
+
if (sock->typeinfo->interface_draw) {
uiItemS(layout);
sock->typeinfo->interface_draw((bContext *)C, layout, &sockptr);
@@ -185,7 +185,7 @@ static void node_tree_interface_panel(const bContext *C, Panel *pa)
void node_buttons_register(ARegionType *art)
{
PanelType *pt;
-
+
pt = MEM_callocN(sizeof(PanelType), "spacetype node panel node sockets");
strcpy(pt->idname, "NODE_PT_sockets");
strcpy(pt->label, N_("Sockets"));
@@ -208,7 +208,7 @@ static int node_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = node_has_buttons_region(sa);
-
+
if (ar)
ED_region_toggle_hidden(C, ar);
@@ -227,10 +227,10 @@ void NODE_OT_properties(wmOperatorType *ot)
ot->name = "Properties";
ot->description = "Toggle the properties region visibility";
ot->idname = "NODE_OT_properties";
-
+
ot->exec = node_properties_toggle_exec;
ot->poll = node_properties_poll;
-
+
/* flags */
ot->flag = 0;
}
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index ae810b0fde0..8089f47bce4 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -100,7 +100,7 @@ static bNodeTree *node_tree_from_ID(ID *id)
{
if (id) {
short idtype = GS(id->name);
-
+
switch (idtype) {
case ID_NT:
return (bNodeTree *)id;
@@ -118,7 +118,7 @@ static bNodeTree *node_tree_from_ID(ID *id)
return ((FreestyleLineStyle *)id)->nodetree;
}
}
-
+
return NULL;
}
@@ -137,7 +137,7 @@ void ED_node_tag_update_id(ID *id)
if (ntree->type == NTREE_SHADER) {
DEG_id_tag_update(id, 0);
-
+
if (GS(id->name) == ID_MA)
WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id);
else if (GS(id->name) == ID_LA)
@@ -165,7 +165,7 @@ void ED_node_tag_update_nodetree(Main *bmain, bNodeTree *ntree, bNode *node)
bool do_tag_update = true;
if (node != NULL) {
- if (!node_connected_to_output(ntree, node)) {
+ if (!node_connected_to_output(bmain, ntree, node)) {
do_tag_update = false;
}
}
@@ -191,7 +191,7 @@ static bool compare_nodes(const bNode *a, const bNode *b)
*/
bool a_select = (a->flag & NODE_SELECT) != 0, b_select = (b->flag & NODE_SELECT) != 0;
bool a_active = (a->flag & NODE_ACTIVE) != 0, b_active = (b->flag & NODE_ACTIVE) != 0;
-
+
/* if one is an ancestor of the other */
/* XXX there might be a better sorting algorithm for stable topological sort, this is O(n^2) worst case */
for (parent = a->parent; parent; parent = parent->parent) {
@@ -220,13 +220,13 @@ static bool compare_nodes(const bNode *a, const bNode *b)
return 0;
else if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND))
return 1;
-
+
/* if one has a higher selection state (active > selected > nothing) */
if (!b_active && a_active)
return 1;
else if (!b_select && (a_active || a_select))
return 1;
-
+
return 0;
}
@@ -239,11 +239,11 @@ void ED_node_sort(bNodeTree *ntree)
bNode *first_a, *first_b, *node_a, *node_b, *tmp;
int totnodes = BLI_listbase_count(&ntree->nodes);
int k, a, b;
-
+
k = 1;
while (k < totnodes) {
first_a = first_b = ntree->nodes.first;
-
+
do {
/* setup first_b pointer */
for (b = 0; b < k && first_b; ++b) {
@@ -252,7 +252,7 @@ void ED_node_sort(bNodeTree *ntree)
/* all batches merged? */
if (first_b == NULL)
break;
-
+
/* merge batches */
node_a = first_a;
node_b = first_b;
@@ -281,7 +281,7 @@ void ED_node_sort(bNodeTree *ntree)
}
first_a = first_b;
} while (first_b);
-
+
k = k << 1;
}
}
@@ -300,9 +300,9 @@ static void node_uiblocks_init(const bContext *C, bNodeTree *ntree)
{
bNode *node;
char uiblockstr[32];
-
+
/* add node uiBlocks in drawing order - prevents events going to overlapping nodes */
-
+
for (node = ntree->nodes.first; node; node = node->next) {
/* ui block */
BLI_snprintf(uiblockstr, sizeof(uiblockstr), "node buttons %p", (void *)node);
@@ -344,52 +344,52 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
float locx, locy;
float dy;
int buty;
-
+
RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr);
-
+
/* get "global" coords */
node_to_view(node, 0.0f, 0.0f, &locx, &locy);
dy = locy;
-
+
/* header */
dy -= NODE_DY;
-
+
/* little bit space in top */
if (node->outputs.first)
dy -= NODE_DYS / 2;
-
+
/* output sockets */
bool add_output_space = false;
for (nsock = node->outputs.first; nsock; nsock = nsock->next) {
if (nodeSocketIsHidden(nsock))
continue;
-
+
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr);
-
+
layout = UI_block_layout(
node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
locx + NODE_DYS, dy, NODE_WIDTH(node) - NODE_DY, NODE_DY, 0, UI_style_get());
/* context pointers for current node and socket */
uiLayoutSetContextPointer(layout, "node", &nodeptr);
uiLayoutSetContextPointer(layout, "socket", &sockptr);
-
+
/* align output buttons to the right */
row = uiLayoutRow(layout, 1);
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT);
-
+
nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name));
-
+
UI_block_align_end(node->block);
UI_block_layout_resolve(node->block, NULL, &buty);
-
+
/* ensure minimum socket height in case layout is empty */
buty = min_ii(buty, dy - NODE_DY);
-
+
nsock->locx = locx + NODE_WIDTH(node);
/* place the socket circle in the middle of the layout */
nsock->locy = 0.5f * (dy + buty);
-
+
dy = buty;
if (nsock->next)
dy -= NODE_SOCKDY;
@@ -407,28 +407,28 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
/* preview rect? */
if (node->flag & NODE_PREVIEW) {
float aspect = 1.0f;
-
- if (node->preview_xsize && node->preview_ysize)
+
+ if (node->preview_xsize && node->preview_ysize)
aspect = (float)node->preview_ysize / (float)node->preview_xsize;
-
+
dy -= NODE_DYS / 2;
node->prvr.ymax = dy;
-
+
if (aspect <= 1.0f)
node->prvr.ymin = dy - aspect * (NODE_WIDTH(node) - NODE_DY);
else {
/* width correction of image */
/* XXX huh? (ton) */
float dx = (NODE_WIDTH(node) - NODE_DYS) - (NODE_WIDTH(node) - NODE_DYS) / aspect;
-
+
node->prvr.ymin = dy - (NODE_WIDTH(node) - NODE_DY);
-
+
node->prvr.xmin += 0.5f * dx;
node->prvr.xmax -= 0.5f * dx;
}
-
+
dy = node->prvr.ymin - NODE_DYS / 2;
-
+
/* make sure that maximums are bigger or equal to minimums */
if (node->prvr.xmax < node->prvr.xmin) SWAP(float, node->prvr.xmax, node->prvr.xmin);
if (node->prvr.ymax < node->prvr.ymin) SWAP(float, node->prvr.ymax, node->prvr.ymin);
@@ -443,18 +443,18 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
node->butr.xmax = NODE_WIDTH(node) - 2 * NODE_DYS;
node->butr.ymin = 0;
node->butr.ymax = 0;
-
-
+
+
layout = UI_block_layout(
node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
locx + NODE_DYS, dy, node->butr.xmax, 0, 0, UI_style_get());
uiLayoutSetContextPointer(layout, "node", &nodeptr);
-
+
node->typeinfo->draw_buttons(layout, (bContext *)C, &nodeptr);
-
+
UI_block_align_end(node->block);
UI_block_layout_resolve(node->block, NULL, &buty);
-
+
dy = buty - NODE_DYS / 2;
}
@@ -462,35 +462,35 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
for (nsock = node->inputs.first; nsock; nsock = nsock->next) {
if (nodeSocketIsHidden(nsock))
continue;
-
+
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr);
-
+
layout = UI_block_layout(
node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
locx + NODE_DYS, dy, NODE_WIDTH(node) - NODE_DY, NODE_DY, 0, UI_style_get());
/* context pointers for current node and socket */
uiLayoutSetContextPointer(layout, "node", &nodeptr);
uiLayoutSetContextPointer(layout, "socket", &sockptr);
-
+
row = uiLayoutRow(layout, 1);
-
+
nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name));
-
+
UI_block_align_end(node->block);
UI_block_layout_resolve(node->block, NULL, &buty);
-
+
/* ensure minimum socket height in case layout is empty */
buty = min_ii(buty, dy - NODE_DY);
-
+
nsock->locx = locx;
/* place the socket circle in the middle of the layout */
nsock->locy = 0.5f * (dy + buty);
-
+
dy = buty;
if (nsock->next)
dy -= NODE_SOCKDY;
}
-
+
/* little bit space in end */
if (node->inputs.first || (node->flag & (NODE_OPTIONS | NODE_PREVIEW)) == 0)
dy -= NODE_DYS / 2;
@@ -499,7 +499,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
node->totr.xmax = locx + NODE_WIDTH(node);
node->totr.ymax = locy;
node->totr.ymin = min_ff(dy, locy - 2 * NODE_DY);
-
+
/* Set the block bounds to clip mouse events from underlying nodes.
* Add a margin for sockets on each side.
*/
@@ -518,7 +518,7 @@ static void node_update_hidden(bNode *node)
float locx, locy;
float rad, drad, hiddenrad = HIDDEN_RAD;
int totin = 0, totout = 0, tot;
-
+
/* get "global" coords */
node_to_view(node, 0.0f, 0.0f, &locx, &locy);
@@ -529,20 +529,20 @@ static void node_update_hidden(bNode *node)
for (nsock = node->outputs.first; nsock; nsock = nsock->next)
if (!nodeSocketIsHidden(nsock))
totout++;
-
+
tot = MAX2(totin, totout);
if (tot > 4) {
hiddenrad += 5.0f * (float)(tot - 4);
}
-
+
node->totr.xmin = locx;
node->totr.xmax = locx + 3 * hiddenrad + node->miniwidth;
node->totr.ymax = locy + (hiddenrad - 0.5f * NODE_DY);
node->totr.ymin = node->totr.ymax - 2 * hiddenrad;
-
+
/* output sockets */
rad = drad = (float)M_PI / (1.0f + (float)totout);
-
+
for (nsock = node->outputs.first; nsock; nsock = nsock->next) {
if (!nodeSocketIsHidden(nsock)) {
nsock->locx = node->totr.xmax - hiddenrad + sinf(rad) * hiddenrad;
@@ -550,10 +550,10 @@ static void node_update_hidden(bNode *node)
rad += drad;
}
}
-
+
/* input sockets */
rad = drad = -(float)M_PI / (1.0f + (float)totin);
-
+
for (nsock = node->inputs.first; nsock; nsock = nsock->next) {
if (!nodeSocketIsHidden(nsock)) {
nsock->locx = node->totr.xmin + hiddenrad + sinf(rad) * hiddenrad;
@@ -632,10 +632,10 @@ static void node_socket_circle_draw(const bContext *C, bNodeTree *ntree, Pointer
{
PointerRNA ptr;
float color[4];
-
+
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
sock->typeinfo->draw_color((bContext *)C, &ptr, &node_ptr, color);
-
+
immAttrib4fv(col, color);
immVertex2f(pos, sock->locx, sock->locy);
}
@@ -645,7 +645,7 @@ static void node_socket_circle_draw(const bContext *C, bNodeTree *ntree, Pointer
static void node_draw_preview_background(float tile, rctf *rect)
{
float x, y;
-
+
Gwn_VertFormat *format = immVertexFormat();
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -655,7 +655,7 @@ static void node_draw_preview_background(float tile, rctf *rect)
immUniformColor3ub(120, 120, 120);
immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
immUniformColor3ub(160, 160, 160);
-
+
for (y = rect->ymin; y < rect->ymax; y += tile * 2) {
for (x = rect->xmin; x < rect->xmax; x += tile * 2) {
float tilex = tile, tiley = tile;
@@ -692,7 +692,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
float yscale = yrect / ((float)preview->ysize);
float scale;
rctf draw_rect;
-
+
/* uniform scale and offset */
draw_rect = *prv;
if (xscale < yscale) {
@@ -707,16 +707,16 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
draw_rect.xmax -= offset;
scale = yscale;
}
-
+
node_draw_preview_background(BLI_rctf_size_x(prv) / 10.0f, &draw_rect);
-
+
glEnable(GL_BLEND);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); /* premul graphics */
-
+
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
immDrawPixelsTex(&state, draw_rect.xmin, draw_rect.ymin, preview->xsize, preview->ysize, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, preview->rect,
scale, scale, NULL);
-
+
glDisable(GL_BLEND);
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -731,23 +731,23 @@ static void node_toggle_button_cb(struct bContext *C, void *node_argv, void *op_
{
bNode *node = (bNode *)node_argv;
const char *opname = (const char *)op_argv;
-
+
/* select & activate only the button's node */
node_select_single(C, node);
-
+
WM_operator_name_call(C, opname, WM_OP_INVOKE_DEFAULT, NULL);
}
void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha)
{
rctf *rct = &node->totr;
-
+
UI_draw_roundbox_corner_set(UI_CNR_ALL);
if (node->parent == NULL)
ui_draw_dropshadow(rct, radius, snode->aspect, alpha, node->flag & SELECT);
else {
const float margin = 3.0f;
-
+
float color[4] = {0.0f, 0.0f, 0.0f, 0.33f};
UI_draw_roundbox_aa(true, rct->xmin - margin, rct->ymin - margin,
rct->xmax + margin, rct->ymax + margin, radius + margin, color);
@@ -802,7 +802,7 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
node_socket_circle_draw(C, ntree, node_ptr, sock, pos, col);
}
-
+
/* socket outputs */
short selected_output_ct = 0;
if (draw_outputs) {
@@ -878,17 +878,17 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
float color[4];
char showname[128]; /* 128 used below */
View2D *v2d = &ar->v2d;
-
+
/* skip if out of view */
if (BLI_rctf_isect(&node->totr, &v2d->cur, NULL) == false) {
UI_block_end(C, node->block);
node->block = NULL;
return;
}
-
+
/* shadow */
node_draw_shadow(snode, node, BASIS_RAD, 1.0f);
-
+
if (node->flag & NODE_MUTED) {
UI_GetThemeColorBlendShade4fv(color_id, TH_REDALERT, 0.5f, 0, color);
}
@@ -907,10 +907,10 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
UI_draw_roundbox_aa(true, rct->xmin, rct->ymax - NODE_DY, rct->xmax, rct->ymax, BASIS_RAD, color);
-
+
/* show/hide icons */
iconofs = rct->xmax - 0.35f * U.widget_unit;
-
+
/* preview */
if (node->typeinfo->flag & NODE_PREVIEW) {
uiBut *but;
@@ -937,7 +937,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_group_edit");
UI_block_emboss_set(node->block, UI_EMBOSS);
}
-
+
/* title */
if (node->flag & SELECT) {
UI_GetThemeColor4fv(TH_SELECT, color);
@@ -945,7 +945,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
else {
UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, color);
}
-
+
/* open/close entirely? */
{
uiBut *but;
@@ -957,16 +957,16 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
but_size, but_size, NULL, 0, 0, 0, 0, "");
UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle");
UI_block_emboss_set(node->block, UI_EMBOSS);
-
+
/* custom draw function for this button */
UI_draw_icon_tri(rct->xmin + 0.5f * U.widget_unit, rct->ymax - NODE_DY / 2.0f, 'v', color);
}
-
+
nodeLabel(ntree, node, showname, sizeof(showname));
-
+
//if (node->flag & NODE_MUTED)
// BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */
-
+
uiDefBut(node->block, UI_BTYPE_LABEL, 0, showname,
(int)(rct->xmin + (NODE_MARGIN_X)), (int)(rct->ymax - NODE_DY),
(short)(iconofs - rct->xmin - 18.0f), (short)NODE_DY,
@@ -991,7 +991,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
UI_draw_roundbox_corner_set(UI_CNR_ALL);
UI_draw_roundbox_aa(false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD, color);
}
-
+
/* disable lines */
if (node->flag & NODE_MUTED)
node_draw_mute_line(v2d, snode, node);
@@ -1007,9 +1007,9 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
}
}
}
-
+
UI_ThemeClearColor(color_id);
-
+
UI_block_end(C, node->block);
UI_block_draw(C, node->block);
node->block = NULL;
@@ -1027,7 +1027,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
float scale;
UI_view2d_scale_get(v2d, &scale, NULL);
-
+
/* shadow */
node_draw_shadow(snode, node, hiddenrad, 1.0f);
@@ -1036,9 +1036,9 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
UI_GetThemeColorBlendShade4fv(color_id, TH_REDALERT, 0.5f, 0, color);
else
UI_GetThemeColor4fv(color_id, color);
-
+
UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad, color);
-
+
/* outline active and selected emphasis */
if (node->flag & SELECT) {
UI_GetThemeColorShadeAlpha4fv((node->flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, 0, -40, color);
@@ -1064,7 +1064,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
else {
UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, color);
}
-
+
/* open entirely icon */
{
uiBut *but;
@@ -1076,11 +1076,11 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
but_size, but_size, NULL, 0, 0, 0, 0, "");
UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle");
UI_block_emboss_set(node->block, UI_EMBOSS);
-
+
/* custom draw function for this button */
UI_draw_icon_tri(rct->xmin + 10.0f, centy, 'h', color);
}
-
+
/* disable lines */
if (node->flag & NODE_MUTED)
node_draw_mute_line(&ar->v2d, snode, node);
@@ -1150,7 +1150,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2])
bNode *node;
bNodeSocket *sock;
int wmcursor = CURSOR_STD;
-
+
if (ntree) {
if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_IN | SOCK_OUT)) {
/* pass */
@@ -1167,7 +1167,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2])
}
}
}
-
+
WM_cursor_set(win, wmcursor);
}
@@ -1188,10 +1188,10 @@ static void node_update(const bContext *C, bNodeTree *ntree, bNode *node)
void node_update_nodetree(const bContext *C, bNodeTree *ntree)
{
bNode *node;
-
+
/* make sure socket "used" tags are correct, for displaying value buttons */
ntreeTagUsedSockets(ntree);
-
+
/* update nodes front to back, so children sizes get updated before parents */
for (node = ntree->nodes.last; node; node = node->prev) {
node_update(C, ntree, node);
@@ -1211,7 +1211,7 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT
bNode *node;
bNodeLink *link;
int a;
-
+
if (ntree == NULL) return; /* groups... */
#ifdef USE_DRAW_TOT_UPDATE
@@ -1237,7 +1237,7 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT
node->nr = a; /* index of node in list, used for exec event code */
node_draw(C, ar, snode, ntree, node, key);
}
-
+
/* node lines */
glEnable(GL_BLEND);
nodelink_batch_start(snode);
@@ -1247,7 +1247,7 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT
}
nodelink_batch_end(snode);
glDisable(GL_BLEND);
-
+
/* draw foreground nodes, last nodes in front */
for (a = 0, node = ntree->nodes.first; node; node = node->next, a++) {
bNodeInstanceKey key;
@@ -1264,9 +1264,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT
static void draw_tree_path(SpaceNode *snode)
{
char info[256];
-
+
ED_node_tree_path_get_fixedbuf(snode, info, sizeof(info));
-
+
UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
BLF_draw_default(1.5f * UI_UNIT_X, 1.5f * UI_UNIT_Y, 0.0f, info, sizeof(info));
}
@@ -1274,11 +1274,11 @@ static void draw_tree_path(SpaceNode *snode)
static void snode_setup_v2d(SpaceNode *snode, ARegion *ar, const float center[2])
{
View2D *v2d = &ar->v2d;
-
+
/* shift view to node tree center */
UI_view2d_center_set(v2d, center[0], center[1]);
UI_view2d_view_ortho(v2d);
-
+
/* aspect+font, set each time */
snode->aspect = BLI_rctf_size_x(&v2d->cur) / (float)ar->winx;
// XXX snode->curfont = uiSetCurFont_ext(snode->aspect);
@@ -1309,7 +1309,7 @@ static void draw_group_overlay(const bContext *C, ARegion *ar)
UI_draw_roundbox_corner_set(UI_CNR_NONE);
UI_draw_roundbox_4fv(true, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 0, color);
glDisable(GL_BLEND);
-
+
/* set the block bounds to clip mouse events from underlying nodes */
block = UI_block_begin(C, ar, "node tree bounds block", UI_EMBOSS);
UI_block_bounds_set_explicit(block, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
@@ -1328,21 +1328,21 @@ void drawnodespace(const bContext *C, ARegion *ar)
glClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(v2d);
-
+
/* XXX snode->cursor set in coordspace for placing new nodes, used for drawing noodles too */
UI_view2d_region_to_view(&ar->v2d, win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin,
&snode->cursor[0], &snode->cursor[1]);
snode->cursor[0] /= UI_DPI_FAC;
snode->cursor[1] /= UI_DPI_FAC;
-
+
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
/* only set once */
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
+
/* nodes */
snode_set_context(C);
-
+
/* draw parent node trees */
if (snode->treepath.last) {
static const int max_depth = 2;
@@ -1352,50 +1352,50 @@ void drawnodespace(const bContext *C, ARegion *ar)
bNodeTree *ntree;
bNodeLinkDrag *nldrag;
LinkData *linkdata;
-
+
path = snode->treepath.last;
-
+
/* update tree path name (drawn in the bottom left) */
ID *name_id = (path->nodetree && path->nodetree != snode->nodetree) ? &path->nodetree->id : snode->id;
if (name_id && UNLIKELY(!STREQ(path->node_name, name_id->name + 2))) {
BLI_strncpy(path->node_name, name_id->name + 2, sizeof(path->node_name));
}
-
+
/* current View2D center, will be set temporarily for parent node trees */
UI_view2d_center_get(v2d, &center[0], &center[1]);
-
+
/* store new view center in path and current edittree */
copy_v2_v2(path->view_center, center);
if (snode->edittree)
copy_v2_v2(snode->edittree->view_center, center);
-
+
depth = 0;
while (path->prev && depth < max_depth) {
path = path->prev;
++depth;
}
-
+
/* parent node trees in the background */
for (curdepth = depth; curdepth > 0; path = path->next, --curdepth) {
ntree = path->nodetree;
if (ntree) {
snode_setup_v2d(snode, ar, path->view_center);
-
+
draw_nodetree(C, ar, ntree, path->parent_key);
-
+
draw_group_overlay(C, ar);
}
}
-
+
/* top-level edit tree */
ntree = path->nodetree;
if (ntree) {
snode_setup_v2d(snode, ar, center);
-
+
/* grid, uses theme color based on node path depth */
UI_view2d_multi_grid_draw(v2d, (depth > 0 ? TH_NODE_GROUP : TH_BACK), ED_node_grid_size(), NODE_GRID_STEPS, 2);
-
+
/* backdrop */
draw_nodespace_back_pix(C, ar, snode, path->parent_key);
@@ -1416,7 +1416,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
draw_nodetree(C, ar, ntree, path->parent_key);
}
-
+
/* temporary links */
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
@@ -1426,7 +1426,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
}
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
-
+
if (snode->flag & SNODE_SHOW_GPENCIL) {
/* draw grease-pencil ('canvas' strokes) */
ED_gpencil_draw_view2d(C, true);
@@ -1435,16 +1435,16 @@ void drawnodespace(const bContext *C, ARegion *ar)
else {
/* default grid */
UI_view2d_multi_grid_draw(v2d, TH_BACK, ED_node_grid_size(), NODE_GRID_STEPS, 2);
-
+
/* backdrop */
draw_nodespace_back_pix(C, ar, snode, NODE_INSTANCE_KEY_NONE);
}
-
+
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
-
+
/* reset view matrix */
UI_view2d_view_restore(C);
-
+
if (snode->treepath.last) {
if (snode->flag & SNODE_SHOW_GPENCIL) {
/* draw grease-pencil (screen strokes, and also paintbuffer) */
@@ -1454,7 +1454,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
/* tree path info */
draw_tree_path(snode);
-
+
/* scrollers */
scrollers = UI_view2d_scrollers_calc(C, v2d, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
UI_view2d_scrollers_draw(C, v2d, scrollers);
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index d91c330c853..91101d1101e 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -88,6 +88,7 @@ enum {
};
typedef struct CompoJob {
+ Main *bmain;
Scene *scene;
bNodeTree *ntree;
bNodeTree *localtree;
@@ -152,7 +153,7 @@ static int compo_get_recalc_flags(const bContext *C)
static int compo_breakjob(void *cjv)
{
CompoJob *cj = cjv;
-
+
/* without G.is_break 'ESC' wont quit - which annoys users */
return (*(cj->stop)
#ifdef USE_ESC_COMPO
@@ -166,7 +167,7 @@ static int compo_breakjob(void *cjv)
static void compo_statsdrawjob(void *cjv, const char *UNUSED(str))
{
CompoJob *cj = cjv;
-
+
*(cj->do_update) = true;
}
@@ -174,7 +175,7 @@ static void compo_statsdrawjob(void *cjv, const char *UNUSED(str))
static void compo_redrawjob(void *cjv)
{
CompoJob *cj = cjv;
-
+
*(cj->do_update) = true;
}
@@ -183,7 +184,7 @@ static void compo_freejob(void *cjv)
CompoJob *cj = cjv;
if (cj->localtree) {
- ntreeLocalMerge(cj->localtree, cj->ntree);
+ ntreeLocalMerge(cj->bmain, cj->localtree, cj->ntree);
}
MEM_freeN(cj);
}
@@ -209,7 +210,7 @@ static void compo_updatejob(void *UNUSED(cjv))
static void compo_progressjob(void *cjv, float progress)
{
CompoJob *cj = cjv;
-
+
*(cj->progress) = progress;
}
@@ -223,7 +224,7 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog
if (scene->use_nodes == false)
return;
-
+
cj->stop = stop;
cj->do_update = do_update;
cj->progress = progress;
@@ -267,6 +268,7 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene
{
wmJob *wm_job;
CompoJob *cj;
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
/* to fix bug: [#32272] */
@@ -278,13 +280,14 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene
G.is_break = false;
#endif
- BKE_image_backup_render(scene, BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"), false);
+ BKE_image_backup_render(scene, BKE_image_verify_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result"), false);
wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene_owner, "Compositing",
WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS, WM_JOB_TYPE_COMPOSITE);
cj = MEM_callocN(sizeof(CompoJob), "compo job");
/* customdata for preview thread */
+ cj->bmain = bmain;
cj->scene = scene;
cj->ntree = nodetree;
cj->recalc_flags = compo_get_recalc_flags(C);
@@ -388,7 +391,7 @@ void ED_node_shader_default(const bContext *C, ID *id)
bNodeTree *ntree;
int output_type, shader_type;
float color[4] = { 0.0f, 0.0f, 0.0f, 1.0f }, strength = 1.0f;
-
+
ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname);
switch (GS(id->name)) {
@@ -435,14 +438,14 @@ void ED_node_shader_default(const bContext *C, ID *id)
printf("ED_node_shader_default called on wrong ID type.\n");
return;
}
-
+
out = nodeAddStaticNode(C, ntree, output_type);
out->locx = 300.0f; out->locy = 300.0f;
-
+
in = nodeAddStaticNode(C, ntree, shader_type);
in->locx = 10.0f; in->locy = 300.0f;
nodeSetActive(ntree, in);
-
+
/* only a link from color to color */
fromsock = in->outputs.first;
tosock = out->inputs.first;
@@ -452,7 +455,7 @@ void ED_node_shader_default(const bContext *C, ID *id)
PointerRNA sockptr;
sock = in->inputs.first;
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sockptr);
-
+
RNA_float_set_array(&sockptr, "default_value", color);
if (strength != 0.0f) {
@@ -460,7 +463,7 @@ void ED_node_shader_default(const bContext *C, ID *id)
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sockptr);
RNA_float_set(&sockptr, "default_value", strength);
}
-
+
ntreeUpdateTree(CTX_data_main(C), ntree);
}
@@ -470,32 +473,32 @@ void ED_node_composit_default(const bContext *C, struct Scene *sce)
{
bNode *in, *out;
bNodeSocket *fromsock, *tosock;
-
+
/* but lets check it anyway */
if (sce->nodetree) {
if (G.debug & G_DEBUG)
printf("error in composite initialize\n");
return;
}
-
+
sce->nodetree = ntreeAddTree(NULL, "Compositing Nodetree", ntreeType_Composite->idname);
-
+
sce->nodetree->chunksize = 256;
sce->nodetree->edit_quality = NTREE_QUALITY_HIGH;
sce->nodetree->render_quality = NTREE_QUALITY_HIGH;
-
+
out = nodeAddStaticNode(C, sce->nodetree, CMP_NODE_COMPOSITE);
out->locx = 300.0f; out->locy = 400.0f;
-
+
in = nodeAddStaticNode(C, sce->nodetree, CMP_NODE_R_LAYERS);
in->locx = 10.0f; in->locy = 400.0f;
nodeSetActive(sce->nodetree, in);
-
+
/* links from color to color */
fromsock = in->outputs.first;
tosock = out->inputs.first;
nodeAddLink(sce->nodetree, in, fromsock, out, tosock);
-
+
ntreeUpdateTree(CTX_data_main(C), sce->nodetree);
}
@@ -505,27 +508,27 @@ void ED_node_texture_default(const bContext *C, Tex *tx)
{
bNode *in, *out;
bNodeSocket *fromsock, *tosock;
-
+
/* but lets check it anyway */
if (tx->nodetree) {
if (G.debug & G_DEBUG)
printf("error in texture initialize\n");
return;
}
-
+
tx->nodetree = ntreeAddTree(NULL, "Texture Nodetree", ntreeType_Texture->idname);
-
+
out = nodeAddStaticNode(C, tx->nodetree, TEX_NODE_OUTPUT);
out->locx = 300.0f; out->locy = 300.0f;
-
+
in = nodeAddStaticNode(C, tx->nodetree, TEX_NODE_CHECKER);
in->locx = 10.0f; in->locy = 300.0f;
nodeSetActive(tx->nodetree, in);
-
+
fromsock = in->outputs.first;
tosock = out->inputs.first;
nodeAddLink(tx->nodetree, in, fromsock, out, tosock);
-
+
ntreeUpdateTree(CTX_data_main(C), tx->nodetree);
}
@@ -536,7 +539,7 @@ void snode_set_context(const bContext *C)
bNodeTreeType *treetype = ntreeTypeFind(snode->tree_idname);
bNodeTree *ntree = snode->nodetree;
ID *id = snode->id, *from = snode->from;
-
+
/* check the tree type */
if (!treetype ||
(treetype->poll && !treetype->poll(C, treetype)))
@@ -547,25 +550,25 @@ void snode_set_context(const bContext *C)
*/
return;
}
-
+
if (snode->nodetree && !STREQ(snode->nodetree->idname, snode->tree_idname)) {
/* current tree does not match selected type, clear tree path */
ntree = NULL;
id = NULL;
from = NULL;
}
-
+
if (!(snode->flag & SNODE_PIN) || ntree == NULL) {
if (treetype->get_from_context) {
/* reset and update from context */
ntree = NULL;
id = NULL;
from = NULL;
-
+
treetype->get_from_context(C, treetype, &ntree, &id, &from);
}
}
-
+
if (snode->nodetree != ntree || snode->id != id || snode->from != from ||
(snode->treepath.last == NULL && ntree))
{
@@ -576,12 +579,12 @@ void snode_set_context(const bContext *C)
void snode_update(SpaceNode *snode, bNode *node)
{
bNodeTreePath *path;
-
+
/* XXX this only updates nodes in the current node space tree path.
* The function supposedly should update any potential group node linking to changed tree,
* this really requires a working depsgraph ...
*/
-
+
/* update all edited group nodes */
path = snode->treepath.last;
if (path) {
@@ -601,38 +604,38 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
const bool was_active_texture = (node->flag & NODE_ACTIVE_TEXTURE) != 0;
nodeSetActive(ntree, node);
-
+
if (node->type != NODE_GROUP) {
const bool was_output = (node->flag & NODE_DO_OUTPUT) != 0;
bool do_update = false;
-
+
/* generic node group output: set node as active output */
if (node->type == NODE_GROUP_OUTPUT) {
bNode *tnode;
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next)
if (tnode->type == NODE_GROUP_OUTPUT)
tnode->flag &= ~NODE_DO_OUTPUT;
-
+
node->flag |= NODE_DO_OUTPUT;
if (!was_output)
do_update = 1;
}
-
+
/* tree specific activate calls */
if (ntree->type == NTREE_SHADER) {
/* when we select a material, active texture is cleared, for buttons */
if (node->id && ELEM(GS(node->id->name), ID_MA, ID_LA, ID_WO))
nodeClearActiveID(ntree, ID_TE);
-
+
if (ELEM(node->type, SH_NODE_OUTPUT_MATERIAL,
SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LAMP, SH_NODE_OUTPUT_LINESTYLE))
{
bNode *tnode;
-
+
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next)
if (tnode->type == node->type)
tnode->flag &= ~NODE_DO_OUTPUT;
-
+
node->flag |= NODE_DO_OUTPUT;
if (was_output == 0)
ED_node_tag_update_nodetree(bmain, ntree, node);
@@ -652,7 +655,7 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
for (wo = bmain->world.first; wo; wo = wo->id.next)
if (wo->nodetree && wo->use_nodes && ntreeHasTree(wo->nodetree, ntree))
GPU_material_free(&wo->gpumaterial);
-
+
WM_main_add_notifier(NC_IMAGE, NULL);
}
@@ -662,27 +665,27 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
/* make active viewer, currently only 1 supported... */
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
bNode *tnode;
-
+
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next)
if (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
tnode->flag &= ~NODE_DO_OUTPUT;
-
+
node->flag |= NODE_DO_OUTPUT;
if (was_output == 0)
ED_node_tag_update_nodetree(bmain, ntree, node);
-
+
/* addnode() doesnt link this yet... */
- node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ node->id = (ID *)BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
}
else if (node->type == CMP_NODE_COMPOSITE) {
if (was_output == 0) {
bNode *tnode;
-
+
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next)
if (tnode->type == CMP_NODE_COMPOSITE)
tnode->flag &= ~NODE_DO_OUTPUT;
-
+
node->flag |= NODE_DO_OUTPUT;
ED_node_tag_update_nodetree(bmain, ntree, node);
}
@@ -737,13 +740,13 @@ static int edit_node_invoke_properties(bContext *C, wmOperator *op)
else
RNA_string_set(op->ptr, "node", node->name);
}
-
+
if (!RNA_struct_property_is_set(op->ptr, "in_out"))
RNA_enum_set(op->ptr, "in_out", SOCK_IN);
-
+
if (!RNA_struct_property_is_set(op->ptr, "socket"))
RNA_int_set(op->ptr, "socket", 0);
-
+
return 1;
}
@@ -754,18 +757,18 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r
char nodename[MAX_NAME];
int sockindex;
int in_out;
-
+
RNA_string_get(op->ptr, "node", nodename);
node = nodeFindNodebyName(ntree, nodename);
-
+
in_out = RNA_enum_get(op->ptr, "in_out");
-
+
sockindex = RNA_int_get(op->ptr, "socket");
switch (in_out) {
case SOCK_IN: sock = BLI_findlink(&node->inputs, sockindex); break;
case SOCK_OUT: sock = BLI_findlink(&node->outputs, sockindex); break;
}
-
+
if (rnode)
*rnode = node;
if (rsock)
@@ -781,7 +784,7 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r
static bNode *visible_node(SpaceNode *snode, const rctf *rct)
{
bNode *node;
-
+
for (node = snode->edittree->nodes.last; node; node = node->prev) {
if (BLI_rctf_isect(&node->totr, rct, NULL))
break;
@@ -803,13 +806,13 @@ typedef struct NodeSizeWidget {
static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED(event), bNode *node, int dir)
{
SpaceNode *snode = CTX_wm_space_node(C);
-
+
NodeSizeWidget *nsw = MEM_callocN(sizeof(NodeSizeWidget), "size widget op data");
-
+
op->customdata = nsw;
nsw->mxstart = snode->cursor[0];
nsw->mystart = snode->cursor[1];
-
+
/* store old */
nsw->oldlocx = node->locx;
nsw->oldlocy = node->locy;
@@ -819,7 +822,7 @@ static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED(
nsw->oldheight = node->height;
nsw->oldminiwidth = node->miniwidth;
nsw->directions = dir;
-
+
WM_cursor_modal_set(CTX_wm_window(C), node_get_resize_cursor(dir));
/* add modal handler */
WM_event_add_modal_handler(C, op);
@@ -828,7 +831,7 @@ static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED(
static void node_resize_exit(bContext *C, wmOperator *op, bool UNUSED(cancel))
{
WM_cursor_modal_restore(CTX_wm_window(C));
-
+
MEM_freeN(op->customdata);
op->customdata = NULL;
}
@@ -840,14 +843,14 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event)
bNode *node = nodeGetActive(snode->edittree);
NodeSizeWidget *nsw = op->customdata;
float mx, my, dx, dy;
-
+
switch (event->type) {
case MOUSEMOVE:
-
+
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &mx, &my);
dx = (mx - nsw->mxstart) / UI_DPI_FAC;
dy = (my - nsw->mystart) / UI_DPI_FAC;
-
+
if (node) {
/* width can use node->width or node->miniwidth (hidden nodes) */
float *pwidth;
@@ -865,7 +868,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event)
widthmin = node->typeinfo->minwidth;
}
widthmax = node->typeinfo->maxwidth;
-
+
{
if (nsw->directions & NODE_RESIZE_RIGHT) {
*pwidth = oldwidth + dx;
@@ -873,20 +876,20 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
if (nsw->directions & NODE_RESIZE_LEFT) {
float locmax = nsw->oldlocx + oldwidth;
-
+
node->locx = nsw->oldlocx + dx;
CLAMP(node->locx, locmax - widthmax, locmax - widthmin);
*pwidth = locmax - node->locx;
}
}
-
+
/* height works the other way round ... */
{
float heightmin = UI_DPI_FAC * node->typeinfo->minheight;
float heightmax = UI_DPI_FAC * node->typeinfo->maxheight;
if (nsw->directions & NODE_RESIZE_TOP) {
float locmin = nsw->oldlocy - nsw->oldheight;
-
+
node->locy = nsw->oldlocy + dy;
CLAMP(node->locy, locmin + heightmin, locmin + heightmax);
node->height = node->locy - locmin;
@@ -896,7 +899,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event)
CLAMP(node->height, heightmin, heightmax);
}
}
-
+
/* XXX make callback? */
if (node->type == NODE_FRAME) {
/* keep the offset symmetric around center point */
@@ -918,21 +921,21 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
}
-
+
ED_region_tag_redraw(ar);
break;
-
+
case LEFTMOUSE:
case MIDDLEMOUSE:
case RIGHTMOUSE:
-
+
node_resize_exit(C, op, false);
ED_node_post_apply_transform(C, snode->edittree);
-
+
return OPERATOR_FINISHED;
}
-
+
return OPERATOR_RUNNING_MODAL;
}
@@ -942,7 +945,7 @@ static int node_resize_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ARegion *ar = CTX_wm_region(C);
bNode *node = nodeGetActive(snode->edittree);
int dir;
-
+
if (node) {
/* convert mouse coordinates to v2d space */
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
@@ -967,13 +970,13 @@ void NODE_OT_resize(wmOperatorType *ot)
ot->name = "Resize Node";
ot->idname = "NODE_OT_resize";
ot->description = "Resize a node";
-
+
/* api callbacks */
ot->invoke = node_resize_invoke;
ot->modal = node_resize_modal;
ot->poll = ED_operator_node_active;
ot->cancel = node_resize_cancel;
-
+
/* flags */
ot->flag = OPTYPE_BLOCKING;
}
@@ -984,7 +987,7 @@ void NODE_OT_resize(wmOperatorType *ot)
int node_has_hidden_sockets(bNode *node)
{
bNodeSocket *sock;
-
+
for (sock = node->inputs.first; sock; sock = sock->next)
if (sock->flag & SOCK_HIDDEN)
return 1;
@@ -1025,10 +1028,10 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so
bNode *node;
bNodeSocket *sock;
rctf rect;
-
+
*nodep = NULL;
*sockp = NULL;
-
+
/* check if we click in a socket */
for (node = snode->edittree->nodes.first; node; node = node->next) {
@@ -1045,7 +1048,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so
rect.xmin -= NODE_SOCKSIZE;
}
}
-
+
if (in_out & SOCK_IN) {
for (sock = node->inputs.first; sock; sock = sock->next) {
if (!nodeSocketIsHidden(sock)) {
@@ -1073,7 +1076,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so
}
}
}
-
+
return 0;
}
@@ -1082,9 +1085,9 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so
static void node_duplicate_reparent_recursive(bNode *node)
{
bNode *parent;
-
+
node->flag |= NODE_TEST;
-
+
/* find first selected parent */
for (parent = node->parent; parent; parent = parent->parent) {
if (parent->flag & SELECT) {
@@ -1102,6 +1105,7 @@ static void node_duplicate_reparent_recursive(bNode *node)
static int node_duplicate_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
bNode *node, *newnode, *lastnode;
@@ -1109,13 +1113,13 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
const bool keep_inputs = RNA_boolean_get(op->ptr, "keep_inputs");
bool do_tag_update = false;
- ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
-
+ ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
+
lastnode = ntree->nodes.last;
for (node = ntree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
newnode = nodeCopyNode(ntree, node);
-
+
if (newnode->id) {
/* simple id user adjustment, node internal functions don't touch this
* but operators and readfile.c do. */
@@ -1124,12 +1128,12 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
ED_node_tag_update_id(snode->id);
}
}
-
+
/* make sure we don't copy new nodes again! */
if (node == lastnode)
break;
}
-
+
/* copy links between selected nodes
* NB: this depends on correct node->new_node and sock->new_sock pointers from above copy!
*/
@@ -1154,15 +1158,15 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
newlink->fromnode = link->fromnode;
newlink->fromsock = link->fromsock;
}
-
+
BLI_addtail(&ntree->links, newlink);
}
-
+
/* make sure we don't copy new links again! */
if (link == lastlink)
break;
}
-
+
/* clear flags for recursive depth-first iteration */
for (node = ntree->nodes.first; node; node = node->next)
node->flag &= ~NODE_TEST;
@@ -1170,32 +1174,32 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
for (node = ntree->nodes.first; node; node = node->next) {
if ((node->flag & SELECT) && !(node->flag & NODE_TEST))
node_duplicate_reparent_recursive(node);
-
+
/* only has to check old nodes */
if (node == lastnode)
break;
}
-
+
/* deselect old nodes, select the copies instead */
for (node = ntree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
/* has been set during copy above */
newnode = node->new_node;
-
+
nodeSetSelected(node, false);
node->flag &= ~NODE_ACTIVE;
nodeSetSelected(newnode, true);
- do_tag_update |= (do_tag_update || node_connected_to_output(ntree, newnode));
+ do_tag_update |= (do_tag_update || node_connected_to_output(bmain, ntree, newnode));
}
-
+
/* make sure we don't copy new nodes again! */
if (node == lastnode)
break;
}
-
+
ntreeUpdateTree(CTX_data_main(C), snode->edittree);
-
+
snode_notify(C, snode);
if (do_tag_update) {
snode_dag_update(C, snode);
@@ -1210,14 +1214,14 @@ void NODE_OT_duplicate(wmOperatorType *ot)
ot->name = "Duplicate Nodes";
ot->description = "Duplicate selected nodes";
ot->idname = "NODE_OT_duplicate";
-
+
/* api callbacks */
ot->exec = node_duplicate_exec;
ot->poll = ED_operator_node_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_boolean(ot->srna, "keep_inputs", 0, "Keep Inputs", "Keep the input links to duplicated nodes");
}
@@ -1264,7 +1268,7 @@ static int node_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
}
}
}
-
+
snode_notify(C, snode);
snode_dag_update(C, snode);
@@ -1273,15 +1277,15 @@ static int node_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
void NODE_OT_read_viewlayers(wmOperatorType *ot)
{
-
+
ot->name = "Read View Layers";
ot->idname = "NODE_OT_read_viewlayers";
ot->description = "Read all render layers of all used scenes";
-
+
ot->exec = node_read_viewlayers_exec;
-
+
ot->poll = composite_node_active;
-
+
/* flags */
ot->flag = 0;
}
@@ -1290,7 +1294,7 @@ int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *sce = CTX_data_scene(C);
bNode *node;
-
+
for (node = sce->nodetree->nodes.first; node; node = node->next) {
if (node->id == (ID *)sce && node->need_exec) {
break;
@@ -1298,21 +1302,21 @@ int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op))
}
if (node) {
ViewLayer *view_layer = BLI_findlink(&sce->view_layers, node->custom1);
-
+
if (view_layer) {
PointerRNA op_ptr;
-
+
WM_operator_properties_create(&op_ptr, "RENDER_OT_render");
RNA_string_set(&op_ptr, "layer", view_layer->name);
RNA_string_set(&op_ptr, "scene", sce->id.name + 2);
-
+
/* to keep keypositions */
sce->r.scemode |= R_NO_FRAME_UPDATE;
-
+
WM_operator_name_call(C, "RENDER_OT_render", WM_OP_INVOKE_DEFAULT, &op_ptr);
WM_operator_properties_free(&op_ptr);
-
+
return OPERATOR_FINISHED;
}
}
@@ -1324,11 +1328,11 @@ void NODE_OT_render_changed(wmOperatorType *ot)
ot->name = "Render Changed Layer";
ot->idname = "NODE_OT_render_changed";
ot->description = "Render current scene, when input node's layer has been changed";
-
+
ot->exec = node_render_changed_exec;
-
+
ot->poll = composite_node_active;
-
+
/* flags */
ot->flag = 0;
}
@@ -1347,12 +1351,12 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag)
*/
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
-
+
if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0)
continue;
if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex))
continue;
-
+
if (node->flag & toggle_flag)
tot_eq++;
else
@@ -1361,12 +1365,12 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag)
}
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
-
+
if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0)
continue;
if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex))
continue;
-
+
if ((tot_eq && tot_neq) || tot_eq == 0)
node->flag |= toggle_flag;
else
@@ -1378,11 +1382,11 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag)
static int node_hide_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceNode *snode = CTX_wm_space_node(C);
-
+
/* sanity checking (poll callback checks this already) */
if ((snode == NULL) || (snode->edittree == NULL))
return OPERATOR_CANCELLED;
-
+
node_flag_toggle_exec(snode, NODE_HIDDEN);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
@@ -1396,7 +1400,7 @@ void NODE_OT_hide_toggle(wmOperatorType *ot)
ot->name = "Hide";
ot->description = "Toggle hiding of selected nodes";
ot->idname = "NODE_OT_hide_toggle";
-
+
/* callbacks */
ot->exec = node_hide_toggle_exec;
ot->poll = ED_operator_node_active;
@@ -1489,7 +1493,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op))
}
}
}
-
+
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
node_set_hidden_sockets(snode, node, !hidden);
@@ -1522,26 +1526,27 @@ void NODE_OT_hide_socket_toggle(wmOperatorType *ot)
static int node_mute_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
bNode *node;
bool do_tag_update = false;
- ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
+ ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
for (node = snode->edittree->nodes.first; node; node = node->next) {
/* Only allow muting of nodes having a mute func! */
if ((node->flag & SELECT) && node->typeinfo->update_internal_links) {
node->flag ^= NODE_MUTED;
snode_update(snode, node);
- do_tag_update |= (do_tag_update || node_connected_to_output(snode->edittree, node));
+ do_tag_update |= (do_tag_update || node_connected_to_output(bmain, snode->edittree, node));
}
}
-
+
snode_notify(C, snode);
if (do_tag_update) {
snode_dag_update(C, snode);
}
-
+
return OPERATOR_FINISHED;
}
@@ -1551,11 +1556,11 @@ void NODE_OT_mute_toggle(wmOperatorType *ot)
ot->name = "Toggle Node Mute";
ot->description = "Toggle muting of the nodes";
ot->idname = "NODE_OT_mute_toggle";
-
+
/* callbacks */
ot->exec = node_mute_exec;
ot->poll = ED_operator_node_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1564,30 +1569,31 @@ void NODE_OT_mute_toggle(wmOperatorType *ot)
static int node_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
bNode *node, *next;
bool do_tag_update = false;
- ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
+ ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
for (node = snode->edittree->nodes.first; node; node = next) {
next = node->next;
if (node->flag & SELECT) {
/* check id user here, nodeFreeNode is called for free dbase too */
- do_tag_update |= (do_tag_update || node_connected_to_output(snode->edittree, node));
+ do_tag_update |= (do_tag_update || node_connected_to_output(bmain, snode->edittree, node));
if (node->id)
id_us_min(node->id);
nodeFreeNode(snode->edittree, node);
}
}
-
+
ntreeUpdateTree(CTX_data_main(C), snode->edittree);
snode_notify(C, snode);
if (do_tag_update) {
snode_dag_update(C, snode);
}
-
+
return OPERATOR_FINISHED;
}
@@ -1597,11 +1603,11 @@ void NODE_OT_delete(wmOperatorType *ot)
ot->name = "Delete";
ot->description = "Delete selected nodes";
ot->idname = "NODE_OT_delete";
-
+
/* api callbacks */
ot->exec = node_delete_exec;
ot->poll = ED_operator_node_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1666,7 +1672,7 @@ static int node_delete_reconnect_exec(bContext *C, wmOperator *UNUSED(op))
next = node->next;
if (node->flag & SELECT) {
nodeInternalRelink(snode->edittree, node);
-
+
/* check id user here, nodeFreeNode is called for free dbase too */
if (node->id)
id_us_min(node->id);
@@ -1754,7 +1760,7 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *U
PointerRNA ptr = CTX_data_pointer_get(C, "node");
bNodeTree *ntree = NULL;
bNode *node = NULL;
-
+
if (ptr.data) {
node = ptr.data;
ntree = ptr.id.data;
@@ -1766,12 +1772,12 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *U
if (!node || node->type != CMP_NODE_OUTPUT_FILE)
return OPERATOR_CANCELLED;
-
+
if (!ntreeCompositOutputFileRemoveActiveSocket(ntree, node))
return OPERATOR_CANCELLED;
-
+
snode_notify(C, snode);
-
+
return OPERATOR_FINISHED;
}
@@ -1781,11 +1787,11 @@ void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot)
ot->name = "Remove File Node Socket";
ot->description = "Remove active input from a file output node";
ot->idname = "NODE_OT_output_file_remove_active_socket";
-
+
/* callbacks */
ot->exec = node_output_file_remove_active_socket_exec;
ot->poll = composite_node_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1800,7 +1806,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op)
NodeImageMultiFile *nimf;
bNodeSocket *sock;
int direction;
-
+
if (ptr.data)
node = ptr.data;
else if (snode && snode->edittree)
@@ -1810,13 +1816,13 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
nimf = node->storage;
-
+
sock = BLI_findlink(&node->inputs, nimf->active_input);
if (!sock)
return OPERATOR_CANCELLED;
-
+
direction = RNA_enum_get(op->ptr, "direction");
-
+
if (direction == 1) {
bNodeSocket *before = sock->prev;
if (!before)
@@ -1833,9 +1839,9 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op)
BLI_insertlinkafter(&node->inputs, after, sock);
nimf->active_input++;
}
-
+
snode_notify(C, snode);
-
+
return OPERATOR_FINISHED;
}
@@ -1846,19 +1852,19 @@ void NODE_OT_output_file_move_active_socket(wmOperatorType *ot)
{2, "DOWN", 0, "Down", ""},
{ 0, NULL, 0, NULL, NULL }
};
-
+
/* identifiers */
ot->name = "Move File Node Socket";
ot->description = "Move the active input of a file output node up or down the list";
ot->idname = "NODE_OT_output_file_move_active_socket";
-
+
/* callbacks */
ot->exec = node_output_file_move_active_socket_exec;
ot->poll = composite_node_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_enum(ot->srna, "direction", direction_items, 2, "Direction", "");
}
@@ -1869,13 +1875,13 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op))
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
bNode *node, *tnode;
-
+
if (!ntree)
return OPERATOR_CANCELLED;
node = nodeGetActive(ntree);
if (!node)
return OPERATOR_CANCELLED;
-
+
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
if (tnode->flag & NODE_SELECT && tnode != node) {
if (node->flag & NODE_CUSTOM_COLOR) {
@@ -1934,7 +1940,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
for (node = ntree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
bNode *new_node = node->new_node;
-
+
/* ensure valid pointers */
if (new_node->parent) {
/* parent pointer must be redirected to new node or detached if parent is not copied */
@@ -2053,7 +2059,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
/* pasted nodes are selected */
nodeSetSelected(new_node, true);
}
-
+
/* reparent copied nodes */
for (node = clipboard_nodes_lb->first; node; node = node->next) {
bNode *new_node = node->new_node;
@@ -2108,9 +2114,9 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op)
PointerRNA ntree_ptr;
bNodeSocket *sock, *tsock, *active_sock;
const char *default_name;
-
+
RNA_id_pointer_create((ID *)ntree, &ntree_ptr);
-
+
if (in_out == SOCK_IN) {
active_sock = ntree_get_active_interface_socket(&ntree->inputs);
default_name = "Input";
@@ -2119,7 +2125,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op)
active_sock = ntree_get_active_interface_socket(&ntree->outputs);
default_name = "Output";
}
-
+
if (active_sock) {
/* insert a copy of the active socket right after it */
sock = ntreeInsertSocketInterface(ntree, in_out, active_sock->idname, active_sock->next, active_sock->name);
@@ -2130,7 +2136,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op)
/* XXX TODO define default socket type for a tree! */
sock = ntreeAddSocketInterface(ntree, in_out, "NodeSocketFloat", default_name);
}
-
+
/* deactivate sockets (has to check both lists) */
for (tsock = ntree->inputs.first; tsock; tsock = tsock->next)
tsock->flag &= ~SELECT;
@@ -2138,11 +2144,11 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op)
tsock->flag &= ~SELECT;
/* make the new socket active */
sock->flag |= SELECT;
-
+
ntreeUpdateTree(CTX_data_main(C), ntree);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -2152,14 +2158,14 @@ void NODE_OT_tree_socket_add(wmOperatorType *ot)
ot->name = "Add Node Tree Interface Socket";
ot->description = "Add an input or output socket to the current node tree";
ot->idname = "NODE_OT_tree_socket_add";
-
+
/* api callbacks */
ot->exec = ntree_socket_add_exec;
ot->poll = ED_operator_node_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_enum(ot->srna, "in_out", rna_enum_node_socket_in_out_items, SOCK_IN, "Socket Type", "");
}
@@ -2170,25 +2176,25 @@ static int ntree_socket_remove_exec(bContext *C, wmOperator *UNUSED(op))
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
bNodeSocket *iosock, *active_sock;
-
+
iosock = ntree_get_active_interface_socket(&ntree->inputs);
if (!iosock)
iosock = ntree_get_active_interface_socket(&ntree->outputs);
if (!iosock)
return OPERATOR_CANCELLED;
-
+
/* preferably next socket becomes active, otherwise try previous socket */
active_sock = (iosock->next ? iosock->next : iosock->prev);
ntreeRemoveSocketInterface(ntree, iosock);
-
+
/* set active socket */
if (active_sock)
active_sock->flag |= SELECT;
-
+
ntreeUpdateTree(CTX_data_main(C), ntree);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -2198,11 +2204,11 @@ void NODE_OT_tree_socket_remove(wmOperatorType *ot)
ot->name = "Remove Node Tree Interface Socket";
ot->description = "Remove an input or output socket to the current node tree";
ot->idname = "NODE_OT_tree_socket_remove";
-
+
/* api callbacks */
ot->exec = ntree_socket_remove_exec;
ot->poll = ED_operator_node_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2222,7 +2228,7 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op)
int direction = RNA_enum_get(op->ptr, "direction");
bNodeSocket *iosock;
ListBase *lb;
-
+
lb = &ntree->inputs;
iosock = ntree_get_active_interface_socket(lb);
if (!iosock) {
@@ -2231,7 +2237,7 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op)
}
if (!iosock)
return OPERATOR_CANCELLED;
-
+
switch (direction) {
case 1:
{ /* up */
@@ -2254,11 +2260,11 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op)
break;
}
}
-
+
ntreeUpdateTree(CTX_data_main(C), ntree);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -2268,14 +2274,14 @@ void NODE_OT_tree_socket_move(wmOperatorType *ot)
ot->name = "Move Node Tree Socket";
ot->description = "Move a socket up or down in the current node tree's sockets stack";
ot->idname = "NODE_OT_tree_socket_move";
-
+
/* api callbacks */
ot->exec = ntree_socket_move_exec;
ot->poll = ED_operator_node_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_enum(ot->srna, "direction", move_direction_items, 1, "Direction", "");
}
@@ -2322,9 +2328,9 @@ static bool node_shader_script_update_text_recursive(RenderEngine *engine, Rende
{
bool found = false;
bNode *node;
-
+
ntree->done = true;
-
+
/* update each script that is using this text datablock */
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP) {
@@ -2337,7 +2343,7 @@ static bool node_shader_script_update_text_recursive(RenderEngine *engine, Rende
found = true;
}
}
-
+
return found;
}
@@ -2384,7 +2390,7 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op)
if (ntree->type == NTREE_SHADER)
ntree->done = false;
} FOREACH_NODETREE_END
-
+
FOREACH_NODETREE(bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
if (!ntree->done)
@@ -2434,13 +2440,14 @@ static void viewer_border_corner_to_backdrop(SpaceNode *snode, ARegion *ar, int
static int viewer_border_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Image *ima;
void *lock;
ImBuf *ibuf;
- ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
+ ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
- ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf) {
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index 7eaf35c6c4f..5d326a0be38 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -69,7 +69,7 @@ static int node_group_operator_active(bContext *C)
{
if (ED_operator_node_active(C)) {
SpaceNode *snode = CTX_wm_space_node(C);
-
+
/* Group operators only defined for standard node tree types.
* Disabled otherwise to allow pynodes define their own operators
* with same keymap.
@@ -88,7 +88,7 @@ static int node_group_operator_editable(bContext *C)
{
if (ED_operator_node_editable(C)) {
SpaceNode *snode = CTX_wm_space_node(C);
-
+
/* Group operators only defined for standard node tree types.
* Disabled otherwise to allow pynodes define their own operators
* with same keymap.
@@ -112,14 +112,14 @@ static const char *group_ntree_idname(bContext *C)
static const char *group_node_idname(bContext *C)
{
SpaceNode *snode = CTX_wm_space_node(C);
-
+
if (ED_node_is_shader(snode))
return "ShaderNodeGroup";
else if (ED_node_is_compositor(snode))
return "CompositorNodeGroup";
else if (ED_node_is_texture(snode))
return "TextureNodeGroup";
-
+
return "";
}
@@ -127,7 +127,7 @@ static bNode *node_group_get_active(bContext *C, const char *node_idname)
{
SpaceNode *snode = CTX_wm_space_node(C);
bNode *node = nodeGetActive(snode->edittree);
-
+
if (node && STREQ(node->idname, node_idname))
return node;
else
@@ -142,22 +142,22 @@ static int node_group_edit_exec(bContext *C, wmOperator *op)
const char *node_idname = group_node_idname(C);
bNode *gnode;
const bool exit = RNA_boolean_get(op->ptr, "exit");
-
+
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
-
+
gnode = node_group_get_active(C, node_idname);
-
+
if (gnode && !exit) {
bNodeTree *ngroup = (bNodeTree *)gnode->id;
-
+
if (ngroup)
ED_node_tree_push(snode, ngroup, gnode);
}
else
ED_node_tree_pop(snode);
-
+
WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -167,45 +167,45 @@ void NODE_OT_group_edit(wmOperatorType *ot)
ot->name = "Edit Group";
ot->description = "Edit node group";
ot->idname = "NODE_OT_group_edit";
-
+
/* api callbacks */
ot->exec = node_group_edit_exec;
ot->poll = node_group_operator_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_boolean(ot->srna, "exit", false, "Exit", "");
}
/* ******************** Ungroup operator ********************** */
/* returns 1 if its OK */
-static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
+static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
{
bNodeLink *link, *linkn, *tlink;
bNode *node, *nextnode;
bNodeTree *ngroup, *wgroup;
ListBase anim_basepaths = {NULL, NULL};
LinkNode *nodes_delayed_free = NULL;
-
+
ngroup = (bNodeTree *)gnode->id;
-
+
/* clear new pointers, set in copytree */
for (node = ntree->nodes.first; node; node = node->next)
node->new_node = NULL;
-
+
/* wgroup is a temporary copy of the NodeTree we're merging in
* - all of wgroup's nodes are transferred across to their new home
* - ngroup (i.e. the source NodeTree) is left unscathed
* - temp copy. don't change ID usercount
*/
- wgroup = ntreeCopyTree_ex(ngroup, G.main, false);
-
+ wgroup = ntreeCopyTree_ex(ngroup, bmain, false);
+
/* Add the nodes into the ntree */
for (node = wgroup->nodes.first; node; node = nextnode) {
nextnode = node->next;
-
+
/* Remove interface nodes.
* This also removes remaining links to and from interface nodes.
*/
@@ -213,43 +213,43 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
/* We must delay removal since sockets will reference this node. see: T52092 */
BLI_linklist_prepend(&nodes_delayed_free, node);
}
-
- /* keep track of this node's RNA "base" path (the part of the path identifying the node)
+
+ /* keep track of this node's RNA "base" path (the part of the path identifying the node)
* if the old nodetree has animation data which potentially covers this node
*/
if (wgroup->adt) {
PointerRNA ptr;
char *path;
-
+
RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr);
path = RNA_path_from_ID_to_struct(&ptr);
-
+
if (path)
BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
}
-
+
/* migrate node */
BLI_remlink(&wgroup->nodes, node);
BLI_addtail(&ntree->nodes, node);
-
+
/* ensure unique node name in the node tree */
nodeUniqueName(ntree, node);
-
+
if (!node->parent) {
node->locx += gnode->locx;
node->locy += gnode->locy;
}
-
+
node->flag |= NODE_SELECT;
}
-
+
/* Add internal links to the ntree */
for (link = wgroup->links.first; link; link = linkn) {
linkn = link->next;
BLI_remlink(&wgroup->links, link);
BLI_addtail(&ntree->links, link);
}
-
+
/* and copy across the animation,
* note that the animation data's action can be NULL here */
if (wgroup->adt) {
@@ -257,40 +257,40 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
bAction *waction;
/* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */
- waction = wgroup->adt->action = BKE_action_copy(G.main, wgroup->adt->action);
-
+ waction = wgroup->adt->action = BKE_action_copy(bmain, wgroup->adt->action);
+
/* now perform the moving */
BKE_animdata_separate_by_basepath(&wgroup->id, &ntree->id, &anim_basepaths);
-
+
/* paths + their wrappers need to be freed */
for (ld = anim_basepaths.first; ld; ld = ldn) {
ldn = ld->next;
-
+
MEM_freeN(ld->data);
BLI_freelinkN(&anim_basepaths, ld);
}
-
+
/* free temp action too */
if (waction) {
- BKE_libblock_free(G.main, waction);
+ BKE_libblock_free(bmain, waction);
wgroup->adt->action = NULL;
}
}
-
+
/* free the group tree (takes care of user count) */
- BKE_libblock_free(G.main, wgroup);
-
+ BKE_libblock_free(bmain, wgroup);
+
/* restore external links to and from the gnode */
/* note: the nodes have been copied to intermediate wgroup first (so need to use new_node),
* then transferred to ntree (new_node pointers remain valid).
*/
-
+
/* input links */
for (link = ngroup->links.first; link; link = link->next) {
if (link->fromnode->type == NODE_GROUP_INPUT) {
const char *identifier = link->fromsock->identifier;
int num_external_links = 0;
-
+
/* find external links to this input */
for (tlink = ntree->links.first; tlink; tlink = tlink->next) {
if (tlink->tonode == gnode && STREQ(tlink->tosock->identifier, identifier)) {
@@ -298,24 +298,24 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
++num_external_links;
}
}
-
+
/* if group output is not externally linked,
* convert the constant input value to ensure somewhat consistent behavior */
if (num_external_links == 0) {
/* XXX TODO bNodeSocket *sock = node_group_find_input_socket(gnode, identifier);
BLI_assert(sock);*/
-
+
/* XXX TODO nodeSocketCopy(ntree, link->tosock->new_sock, link->tonode->new_node, ntree, sock, gnode);*/
}
}
}
-
+
/* output links */
for (link = ntree->links.first; link; link = link->next) {
if (link->fromnode == gnode) {
const char *identifier = link->fromsock->identifier;
int num_internal_links = 0;
-
+
/* find internal links to this output */
for (tlink = ngroup->links.first; tlink; tlink = tlink->next) {
/* only use active output node */
@@ -326,18 +326,18 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
}
}
}
-
+
/* if group output is not internally linked,
* convert the constant output value to ensure somewhat consistent behavior */
if (num_internal_links == 0) {
/* XXX TODO bNodeSocket *sock = node_group_find_output_socket(gnode, identifier);
BLI_assert(sock);*/
-
+
/* XXX TODO nodeSocketCopy(ntree, link->tosock, link->tonode, ntree, sock, gnode); */
}
}
}
-
+
while (nodes_delayed_free) {
node = BLI_linklist_pop(&nodes_delayed_free);
nodeFreeNode(ntree, node);
@@ -345,27 +345,28 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
/* delete the group instance */
nodeFreeNode(ntree, gnode);
-
+
ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
-
+
return 1;
}
static int node_group_ungroup_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
const char *node_idname = group_node_idname(C);
bNode *gnode;
- ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
+ ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
gnode = node_group_get_active(C, node_idname);
if (!gnode)
return OPERATOR_CANCELLED;
-
- if (gnode->id && node_group_ungroup(snode->edittree, gnode)) {
- ntreeUpdateTree(CTX_data_main(C), snode->nodetree);
+
+ if (gnode->id && node_group_ungroup(bmain, snode->edittree, gnode)) {
+ ntreeUpdateTree(bmain, snode->nodetree);
}
else {
BKE_report(op->reports, RPT_WARNING, "Cannot ungroup");
@@ -384,11 +385,11 @@ void NODE_OT_group_ungroup(wmOperatorType *ot)
ot->name = "Ungroup";
ot->description = "Ungroup selected nodes";
ot->idname = "NODE_OT_group_ungroup";
-
+
/* api callbacks */
ot->exec = node_group_ungroup_exec;
ot->poll = node_group_operator_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -401,27 +402,27 @@ static int node_group_separate_selected(bNodeTree *ntree, bNodeTree *ngroup, flo
bNodeLink *link, *link_next;
bNode *node, *node_next, *newnode;
ListBase anim_basepaths = {NULL, NULL};
-
+
/* deselect all nodes in the target tree */
for (node = ntree->nodes.first; node; node = node->next)
nodeSetSelected(node, false);
-
+
/* clear new pointers, set in nodeCopyNode */
for (node = ngroup->nodes.first; node; node = node->next)
node->new_node = NULL;
-
+
/* add selected nodes into the ntree */
for (node = ngroup->nodes.first; node; node = node_next) {
node_next = node->next;
if (!(node->flag & NODE_SELECT))
continue;
-
+
/* ignore interface nodes */
if (ELEM(node->type, NODE_GROUP_INPUT, NODE_GROUP_OUTPUT)) {
nodeSetSelected(node, false);
continue;
}
-
+
if (make_copy) {
/* make a copy */
newnode = nodeCopyNode(ngroup, node);
@@ -430,44 +431,44 @@ static int node_group_separate_selected(bNodeTree *ntree, bNodeTree *ngroup, flo
/* use the existing node */
newnode = node;
}
-
- /* keep track of this node's RNA "base" path (the part of the path identifying the node)
+
+ /* keep track of this node's RNA "base" path (the part of the path identifying the node)
* if the old nodetree has animation data which potentially covers this node
*/
if (ngroup->adt) {
PointerRNA ptr;
char *path;
-
+
RNA_pointer_create(&ngroup->id, &RNA_Node, newnode, &ptr);
path = RNA_path_from_ID_to_struct(&ptr);
-
+
if (path)
BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
}
-
+
/* ensure valid parent pointers, detach if parent stays inside the group */
if (newnode->parent && !(newnode->parent->flag & NODE_SELECT))
nodeDetachNode(newnode);
-
+
/* migrate node */
BLI_remlink(&ngroup->nodes, newnode);
BLI_addtail(&ntree->nodes, newnode);
-
+
/* ensure unique node name in the node tree */
nodeUniqueName(ntree, newnode);
if (!newnode->parent) {
newnode->locx += offx;
- newnode->locy += offy;
+ newnode->locy += offy;
}
}
-
+
/* add internal links to the ntree */
for (link = ngroup->links.first; link; link = link_next) {
const bool fromselect = (link->fromnode && (link->fromnode->flag & NODE_SELECT));
const bool toselect = (link->tonode && (link->tonode->flag & NODE_SELECT));
link_next = link->next;
-
+
if (make_copy) {
/* make a copy of internal links */
if (fromselect && toselect)
@@ -484,28 +485,28 @@ static int node_group_separate_selected(bNodeTree *ntree, bNodeTree *ngroup, flo
}
}
}
-
+
/* and copy across the animation,
* note that the animation data's action can be NULL here */
if (ngroup->adt) {
LinkData *ld, *ldn = NULL;
-
+
/* now perform the moving */
BKE_animdata_separate_by_basepath(&ngroup->id, &ntree->id, &anim_basepaths);
-
+
/* paths + their wrappers need to be freed */
for (ld = anim_basepaths.first; ld; ld = ldn) {
ldn = ld->next;
-
+
MEM_freeN(ld->data);
BLI_freelinkN(&anim_basepaths, ld);
}
}
-
+
ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
if (!make_copy)
ngroup->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
-
+
return 1;
}
@@ -539,7 +540,7 @@ static int node_group_separate_exec(bContext *C, wmOperator *op)
}
/* get node tree offset */
snode_group_offset(snode, &offx, &offy);
-
+
switch (type) {
case NODE_GS_COPY:
if (!node_group_separate_selected(nparent, ngroup, offx, offy, 1)) {
@@ -554,12 +555,12 @@ static int node_group_separate_exec(bContext *C, wmOperator *op)
}
break;
}
-
+
/* switch to parent tree */
ED_node_tree_pop(snode);
-
+
ntreeUpdateTree(CTX_data_main(C), snode->nodetree);
-
+
snode_notify(C, snode);
snode_dag_update(C, snode);
@@ -570,13 +571,13 @@ static int node_group_separate_invoke(bContext *C, wmOperator *UNUSED(op), const
{
uiPopupMenu *pup = UI_popup_menu_begin(C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Separate"), ICON_NONE);
uiLayout *layout = UI_popup_menu_layout(pup);
-
+
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
uiItemEnumO(layout, "NODE_OT_group_separate", NULL, 0, "type", NODE_GS_COPY);
uiItemEnumO(layout, "NODE_OT_group_separate", NULL, 0, "type", NODE_GS_MOVE);
-
+
UI_popup_menu_end(C, pup);
-
+
return OPERATOR_INTERFACE;
}
@@ -586,15 +587,15 @@ void NODE_OT_group_separate(wmOperatorType *ot)
ot->name = "Separate";
ot->description = "Separate selected nodes from the node group";
ot->idname = "NODE_OT_group_separate";
-
+
/* api callbacks */
ot->invoke = node_group_separate_invoke;
ot->exec = node_group_separate_exec;
ot->poll = node_group_operator_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_enum(ot->srna, "type", node_group_separate_types, NODE_GS_COPY, "Type", "");
}
@@ -613,10 +614,10 @@ static bool node_group_make_test_selected(bNodeTree *ntree, bNode *gnode, const
bNode *node;
bNodeLink *link;
int ok = true;
-
+
/* make a local pseudo node tree to pass to the node poll functions */
ngroup = ntreeAddTree(NULL, "Pseudo Node Group", ntree_idname);
-
+
/* check poll functions for selected nodes */
for (node = ntree->nodes.first; node; node = node->next) {
if (node_group_make_use_node(node, gnode)) {
@@ -629,13 +630,13 @@ static bool node_group_make_test_selected(bNodeTree *ntree, bNode *gnode, const
node->done = 0;
}
-
+
/* free local pseudo node tree again */
ntreeFreeTree(ngroup);
MEM_freeN(ngroup);
if (!ok)
return false;
-
+
/* check if all connections are OK, no unselected node has both
* inputs and outputs to a selection */
for (link = ntree->links.first; link; link = link->next) {
@@ -660,7 +661,7 @@ static int node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min,
bNode *node;
float loc[2];
int totselect = 0;
-
+
INIT_MINMAX2(min, max);
for (node = ntree->nodes.first; node; node = node->next) {
if (node_group_make_use_node(node, gnode)) {
@@ -669,12 +670,12 @@ static int node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min,
++totselect;
}
}
-
+
/* sane min/max if no selected nodes */
if (totselect == 0) {
min[0] = min[1] = max[0] = max[1] = 0.0f;
}
-
+
return totselect;
}
@@ -689,89 +690,89 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
int totselect;
bool expose_all = false;
bNode *input_node, *output_node;
-
+
/* XXX rough guess, not nice but we don't have access to UI constants here ... */
static const float offsetx = 200;
static const float offsety = 0.0f;
-
+
/* deselect all nodes in the target tree */
for (node = ngroup->nodes.first; node; node = node->next)
nodeSetSelected(node, false);
-
+
totselect = node_get_selected_minmax(ntree, gnode, min, max);
add_v2_v2v2(center, min, max);
mul_v2_fl(center, 0.5f);
-
+
/* auto-add interface for "solo" nodes */
if (totselect == 1)
expose_all = true;
-
+
/* move nodes over */
for (node = ntree->nodes.first; node; node = nextn) {
nextn = node->next;
if (node_group_make_use_node(node, gnode)) {
- /* keep track of this node's RNA "base" path (the part of the pat identifying the node)
+ /* keep track of this node's RNA "base" path (the part of the pat identifying the node)
* if the old nodetree has animation data which potentially covers this node
*/
if (ntree->adt) {
PointerRNA ptr;
char *path;
-
+
RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr);
path = RNA_path_from_ID_to_struct(&ptr);
-
+
if (path)
BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
}
-
+
/* ensure valid parent pointers, detach if parent stays outside the group */
if (node->parent && !(node->parent->flag & NODE_SELECT))
nodeDetachNode(node);
-
+
/* change node-collection membership */
BLI_remlink(&ntree->nodes, node);
BLI_addtail(&ngroup->nodes, node);
-
+
/* ensure unique node name in the ngroup */
nodeUniqueName(ngroup, node);
}
}
-
+
/* move animation data over */
if (ntree->adt) {
LinkData *ld, *ldn = NULL;
-
+
BKE_animdata_separate_by_basepath(&ntree->id, &ngroup->id, &anim_basepaths);
-
+
/* paths + their wrappers need to be freed */
for (ld = anim_basepaths.first; ld; ld = ldn) {
ldn = ld->next;
-
+
MEM_freeN(ld->data);
BLI_freelinkN(&anim_basepaths, ld);
}
}
-
+
/* node groups don't use internal cached data */
ntreeFreeCache(ngroup);
-
+
/* create input node */
input_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_INPUT);
input_node->locx = min[0] - center[0] - offsetx;
input_node->locy = -offsety;
-
+
/* create output node */
output_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_OUTPUT);
output_node->locx = max[0] - center[0] + offsetx;
output_node->locy = -offsety;
-
+
/* relink external sockets */
for (link = ntree->links.first; link; link = linkn) {
int fromselect = node_group_make_use_node(link->fromnode, gnode);
int toselect = node_group_make_use_node(link->tonode, gnode);
-
+
linkn = link->next;
-
+
if ((fromselect && link->tonode == gnode) || (toselect && link->fromnode == gnode)) {
/* remove all links to/from the gnode.
* this can remove link information, but there's no general way to preserve it.
@@ -785,17 +786,17 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
else if (toselect) {
bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link->tonode, link->tosock);
bNodeSocket *input_sock;
-
+
/* update the group node and interface node sockets,
* so the new interface socket can be linked.
*/
node_group_verify(ntree, gnode, (ID *)ngroup);
node_group_input_verify(ngroup, input_node, (ID *)ngroup);
-
+
/* create new internal link */
input_sock = node_group_input_find_socket(input_node, iosock->identifier);
nodeAddLink(ngroup, input_node, input_sock, link->tonode, link->tosock);
-
+
/* redirect external link */
link->tonode = gnode;
link->tosock = node_group_find_input_socket(gnode, iosock->identifier);
@@ -842,7 +843,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
node->locy -= center[1];
}
}
-
+
/* expose all unlinked sockets too */
if (expose_all) {
for (node = ngroup->nodes.first; node; node = node->next) {
@@ -858,16 +859,16 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
}
if (skip)
continue;
-
+
iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
-
+
node_group_input_verify(ngroup, input_node, (ID *)ngroup);
-
+
/* create new internal link */
input_sock = node_group_input_find_socket(input_node, iosock->identifier);
nodeAddLink(ngroup, input_node, input_sock, node, sock);
}
-
+
for (sock = node->outputs.first; sock; sock = sock->next) {
bNodeSocket *iosock, *output_sock;
bool skip = false;
@@ -876,11 +877,11 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
skip = true;
if (skip)
continue;
-
+
iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
-
+
node_group_output_verify(ngroup, output_node, (ID *)ngroup);
-
+
/* create new internal link */
output_sock = node_group_output_find_socket(output_node, iosock->identifier);
nodeAddLink(ngroup, node, sock, output_node, output_sock);
@@ -902,22 +903,22 @@ static bNode *node_group_make_from_selected(const bContext *C, bNodeTree *ntree,
bNodeTree *ngroup;
float min[2], max[2];
int totselect;
-
+
totselect = node_get_selected_minmax(ntree, NULL, min, max);
/* don't make empty group */
if (totselect == 0)
return NULL;
-
+
/* new nodetree */
ngroup = ntreeAddTree(bmain, "NodeGroup", ntreetype);
-
+
/* make group node */
gnode = nodeAddNode(C, ntree, ntype);
gnode->id = (ID *)ngroup;
-
+
gnode->locx = 0.5f * (min[0] + max[0]);
gnode->locy = 0.5f * (min[1] + max[1]);
-
+
node_group_make_insert_selected(C, ntree, gnode);
/* update of the tree containing the group instance node */
@@ -935,29 +936,29 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
bNodeTree *ngroup;
bNode *gnode;
Main *bmain = CTX_data_main(C);
-
+
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
-
+
if (!node_group_make_test_selected(ntree, NULL, ntree_idname, op->reports))
return OPERATOR_CANCELLED;
-
+
gnode = node_group_make_from_selected(C, ntree, node_idname, ntree_idname);
-
+
if (gnode) {
ngroup = (bNodeTree *)gnode->id;
-
+
nodeSetActive(ntree, gnode);
if (ngroup) {
ED_node_tree_push(snode, ngroup, gnode);
ntreeUpdateTree(bmain, ngroup);
}
}
-
+
ntreeUpdateTree(bmain, ntree);
snode_notify(C, snode);
snode_dag_update(C, snode);
-
+
return OPERATOR_FINISHED;
}
@@ -967,11 +968,11 @@ void NODE_OT_group_make(wmOperatorType *ot)
ot->name = "Make Group";
ot->description = "Make group from selected nodes";
ot->idname = "NODE_OT_group_make";
-
+
/* api callbacks */
ot->exec = node_group_make_exec;
ot->poll = node_group_operator_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -986,29 +987,29 @@ static int node_group_insert_exec(bContext *C, wmOperator *op)
const char *node_idname = group_node_idname(C);
bNode *gnode;
Main *bmain = CTX_data_main(C);
-
+
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
-
+
gnode = node_group_get_active(C, node_idname);
-
+
if (!gnode || !gnode->id)
return OPERATOR_CANCELLED;
-
+
ngroup = (bNodeTree *)gnode->id;
if (!node_group_make_test_selected(ntree, gnode, ngroup->idname, op->reports))
return OPERATOR_CANCELLED;
-
+
node_group_make_insert_selected(C, ntree, gnode);
-
+
nodeSetActive(ntree, gnode);
ED_node_tree_push(snode, ngroup, gnode);
ntreeUpdateTree(bmain, ngroup);
-
+
ntreeUpdateTree(bmain, ntree);
-
+
snode_notify(C, snode);
snode_dag_update(C, snode);
-
+
return OPERATOR_FINISHED;
}
@@ -1018,11 +1019,11 @@ void NODE_OT_group_insert(wmOperatorType *ot)
ot->name = "Group Insert";
ot->description = "Insert selected nodes into a node group";
ot->idname = "NODE_OT_group_insert";
-
+
/* api callbacks */
ot->exec = node_group_insert_exec;
ot->poll = node_group_operator_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 1235133f8ac..2cc37a4e0fe 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -41,6 +41,7 @@ struct ARegion;
struct ARegionType;
struct View2D;
struct bContext;
+struct Main;
struct wmWindow;
struct bNode;
struct bNodeSocket;
@@ -50,7 +51,7 @@ struct wmKeyConfig;
/* temp data to pass on to modal */
typedef struct bNodeLinkDrag {
struct bNodeLinkDrag *next, *prev;
-
+
/* List of links dragged by the operator.
* Note: This is a list of LinkData structs on top of the actual bNodeLinks.
* This way the links can be added to the node tree while being stored in this list.
@@ -157,7 +158,7 @@ void NODE_OT_group_edit(struct wmOperatorType *ot);
/* node_relationships.c */
-bool node_connected_to_output(struct bNodeTree *ntree, struct bNode *node);
+bool node_connected_to_output(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node);
void NODE_OT_link(struct wmOperatorType *ot);
void NODE_OT_link_make(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_node/node_manipulators.c b/source/blender/editors/space_node/node_manipulators.c
index 73b0f44b043..851e3973288 100644
--- a/source/blender/editors/space_node/node_manipulators.c
+++ b/source/blender/editors/space_node/node_manipulators.c
@@ -31,6 +31,7 @@
#include "BKE_context.h"
#include "BKE_image.h"
+#include "BKE_main.h"
#include "ED_screen.h"
#include "ED_manipulator_library.h"
@@ -140,13 +141,14 @@ static void WIDGETGROUP_node_transform_setup(const bContext *UNUSED(C), wmManipu
static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmManipulatorGroup *mgroup)
{
+ Main *bmain = CTX_data_main(C);
wmManipulator *cage = ((wmManipulatorWrapper *)mgroup->customdata)->manipulator;
const ARegion *ar = CTX_wm_region(C);
/* center is always at the origin */
const float origin[3] = {ar->winx / 2, ar->winy / 2};
void *lock;
- Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf) {
@@ -340,11 +342,12 @@ static void WIDGETGROUP_node_crop_draw_prepare(const bContext *C, wmManipulatorG
static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmManipulatorGroup *mgroup)
{
+ Main *bmain = CTX_data_main(C);
struct NodeCropWidgetGroup *crop_group = mgroup->customdata;
wmManipulator *mpr = crop_group->border;
void *lock;
- Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf) {
@@ -451,11 +454,12 @@ static void WIDGETGROUP_node_sbeam_draw_prepare(const bContext *C, wmManipulator
static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmManipulatorGroup *mgroup)
{
+ Main *bmain = CTX_data_main(C);
struct NodeSunBeamsWidgetGroup *sbeam_group = mgroup->customdata;
wmManipulator *mpr = sbeam_group->manipulator;
void *lock;
- Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf) {
@@ -563,10 +567,11 @@ static void WIDGETGROUP_node_corner_pin_draw_prepare(const bContext *C, wmManipu
static void WIDGETGROUP_node_corner_pin_refresh(const bContext *C, wmManipulatorGroup *mgroup)
{
+ Main *bmain = CTX_data_main(C);
struct NodeCornerPinWidgetGroup *cpin_group = mgroup->customdata;
void *lock;
- Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf) {
diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c
index c9c29212f02..3b6cc8a89cf 100644
--- a/source/blender/editors/space_node/node_ops.c
+++ b/source/blender/editors/space_node/node_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation, Nathan Letwory
*
* ***** END GPL LICENSE BLOCK *****
@@ -50,7 +50,7 @@ void node_operatortypes(void)
{
WM_operatortype_append(NODE_OT_properties);
WM_operatortype_append(NODE_OT_toolbar);
-
+
WM_operatortype_append(NODE_OT_select);
WM_operatortype_append(NODE_OT_select_all);
WM_operatortype_append(NODE_OT_select_linked_to);
@@ -60,9 +60,9 @@ void node_operatortypes(void)
WM_operatortype_append(NODE_OT_select_lasso);
WM_operatortype_append(NODE_OT_select_grouped);
WM_operatortype_append(NODE_OT_select_same_type_step);
-
+
WM_operatortype_append(NODE_OT_find_node);
-
+
WM_operatortype_append(NODE_OT_view_all);
WM_operatortype_append(NODE_OT_view_selected);
@@ -72,12 +72,12 @@ void node_operatortypes(void)
WM_operatortype_append(NODE_OT_options_toggle);
WM_operatortype_append(NODE_OT_hide_socket_toggle);
WM_operatortype_append(NODE_OT_node_copy_color);
-
+
WM_operatortype_append(NODE_OT_duplicate);
WM_operatortype_append(NODE_OT_delete);
WM_operatortype_append(NODE_OT_delete_reconnect);
WM_operatortype_append(NODE_OT_resize);
-
+
WM_operatortype_append(NODE_OT_link);
WM_operatortype_append(NODE_OT_link_make);
WM_operatortype_append(NODE_OT_links_cut);
@@ -89,36 +89,36 @@ void node_operatortypes(void)
WM_operatortype_append(NODE_OT_group_ungroup);
WM_operatortype_append(NODE_OT_group_separate);
WM_operatortype_append(NODE_OT_group_edit);
-
+
WM_operatortype_append(NODE_OT_link_viewer);
-
+
WM_operatortype_append(NODE_OT_insert_offset);
-
+
WM_operatortype_append(NODE_OT_read_viewlayers);
WM_operatortype_append(NODE_OT_render_changed);
-
+
WM_operatortype_append(NODE_OT_backimage_move);
WM_operatortype_append(NODE_OT_backimage_zoom);
WM_operatortype_append(NODE_OT_backimage_fit);
WM_operatortype_append(NODE_OT_backimage_sample);
-
+
WM_operatortype_append(NODE_OT_add_file);
WM_operatortype_append(NODE_OT_add_mask);
-
+
WM_operatortype_append(NODE_OT_new_node_tree);
-
+
WM_operatortype_append(NODE_OT_output_file_add_socket);
WM_operatortype_append(NODE_OT_output_file_remove_active_socket);
WM_operatortype_append(NODE_OT_output_file_move_active_socket);
-
+
WM_operatortype_append(NODE_OT_parent_set);
WM_operatortype_append(NODE_OT_join);
WM_operatortype_append(NODE_OT_attach);
WM_operatortype_append(NODE_OT_detach);
-
+
WM_operatortype_append(NODE_OT_clipboard_copy);
WM_operatortype_append(NODE_OT_clipboard_paste);
-
+
WM_operatortype_append(NODE_OT_shader_script_update);
WM_operatortype_append(NODE_OT_viewer_border);
@@ -135,7 +135,7 @@ void ED_operatormacros_node(void)
{
wmOperatorType *ot;
wmOperatorTypeMacro *mot;
-
+
ot = WM_operatortype_append_macro("NODE_OT_select_link_viewer", "Link Viewer",
"Select node and link it to a viewer node",
OPTYPE_UNDO);
@@ -149,7 +149,7 @@ void ED_operatormacros_node(void)
RNA_boolean_set(mot->ptr, "release_confirm", true);
WM_operatortype_macro_define(ot, "NODE_OT_attach");
WM_operatortype_macro_define(ot, "NODE_OT_insert_offset");
-
+
/* NODE_OT_translate_attach with remove_on_canel set to true */
ot = WM_operatortype_append_macro("NODE_OT_translate_attach_remove_on_cancel", "Move and Attach",
"Move nodes and attach to frame",
@@ -212,7 +212,7 @@ static void node_select_keymap(wmKeyMap *keymap, int extend)
const int *mod = (extend ? mod_extend : mod_single);
wmKeyMapItem *kmi;
int i;
-
+
for (i = 0; mod[i] >= 0; ++i) {
kmi = WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, mod[i], 0);
RNA_boolean_set(kmi->ptr, "extend", extend);
@@ -225,17 +225,17 @@ void node_keymap(struct wmKeyConfig *keyconf)
{
wmKeyMap *keymap;
wmKeyMapItem *kmi;
-
+
/* Entire Editor only ----------------- */
keymap = WM_keymap_find(keyconf, "Node Generic", SPACE_NODE, 0);
-
+
WM_keymap_add_item(keymap, "NODE_OT_properties", NKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NODE_OT_toolbar", TKEY, KM_PRESS, 0, 0);
-
+
/* Main Region only ----------------- */
keymap = WM_keymap_find(keyconf, "Node Editor", SPACE_NODE, 0);
-
- /* mouse select in nodes used to be both keys, but perhaps this should be reduced?
+
+ /* mouse select in nodes used to be both keys, but perhaps this should be reduced?
* NOTE: mouse-clicks on left-mouse will fall through to allow transform-tweak, but also link/resize
* NOTE 2: socket select is part of the node select operator, to handle overlapping cases
* NOTE 3: select op is registered for various combinations of modifier key, so the specialized
@@ -243,10 +243,10 @@ void node_keymap(struct wmKeyConfig *keyconf)
*/
node_select_keymap(keymap, false);
node_select_keymap(keymap, true);
-
+
kmi = WM_keymap_add_item(keymap, "NODE_OT_select_border", EVT_TWEAK_S, KM_ANY, 0, 0);
RNA_boolean_set(kmi->ptr, "tweak", true);
-
+
kmi = WM_keymap_add_item(keymap, "NODE_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "deselect", false);
kmi = WM_keymap_add_item(keymap, "NODE_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT | KM_ALT, 0);
@@ -259,13 +259,13 @@ void node_keymap(struct wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "detach", false);
kmi = WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "detach", true);
-
+
WM_keymap_add_item(keymap, "NODE_OT_resize", LEFTMOUSE, KM_PRESS, 0, 0);
-
+
WM_keymap_add_item(keymap, "NODE_OT_add_reroute", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "NODE_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "NODE_OT_select_link_viewer", LEFTMOUSE, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "NODE_OT_backimage_move", MIDDLEMOUSE, KM_PRESS, KM_ALT, 0);
kmi = WM_keymap_add_item(keymap, "NODE_OT_backimage_zoom", VKEY, KM_PRESS, 0, 0);
RNA_float_set(kmi->ptr, "factor", 0.83333f);
@@ -274,6 +274,8 @@ void node_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "NODE_OT_backimage_fit", HOMEKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "NODE_OT_backimage_sample", ACTIONMOUSE, KM_PRESS, KM_ALT, 0);
+ WM_keymap_add_menu(keymap, "NODE_MT_specials", WKEY, KM_PRESS, 0, 0);
+
kmi = WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "replace", false);
kmi = WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, KM_SHIFT, 0);
@@ -283,16 +285,16 @@ void node_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "NODE_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
/* modified operator call for duplicating with input links */
WM_keymap_add_item(keymap, "NODE_OT_duplicate_move_keep_inputs", DKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "NODE_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "NODE_OT_detach", PKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "NODE_OT_join", JKEY, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "NODE_OT_hide_toggle", HKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NODE_OT_mute_toggle", MKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NODE_OT_preview_toggle", HKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "NODE_OT_hide_socket_toggle", HKEY, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "NODE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
#ifdef WITH_INPUT_NDOF
WM_keymap_add_item(keymap, "NODE_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
@@ -322,9 +324,9 @@ void node_keymap(struct wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "prev", false);
kmi = WM_keymap_add_item(keymap, "NODE_OT_select_same_type_step", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "prev", true);
-
+
WM_keymap_add_item(keymap, "NODE_OT_find_node", FKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* node group operators */
WM_keymap_add_item(keymap, "NODE_OT_group_make", GKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "NODE_OT_group_ungroup", GKEY, KM_PRESS, KM_ALT, 0);
@@ -336,7 +338,7 @@ void node_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "NODE_OT_read_viewlayers", RKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "NODE_OT_render_changed", ZKEY, KM_PRESS, 0, 0);
-
+
WM_keymap_add_item(keymap, "NODE_OT_clipboard_copy", CKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "NODE_OT_clipboard_paste", VKEY, KM_PRESS, KM_CTRL, 0);
#ifdef __APPLE__
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index 70f7553cf41..e4c59bc9508 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -131,9 +131,8 @@ static bool node_group_has_output_dfs(bNode *node)
return false;
}
-static bool node_group_has_output(bNode *node)
+static bool node_group_has_output(Main *bmain, bNode *node)
{
- Main *bmain = G.main;
BLI_assert(node->type == NODE_GROUP);
bNodeTree *ntree = (bNodeTree *)node->id;
if (ntree == NULL) {
@@ -143,7 +142,7 @@ static bool node_group_has_output(bNode *node)
return node_group_has_output_dfs(node);
}
-bool node_connected_to_output(bNodeTree *ntree, bNode *node)
+bool node_connected_to_output(Main *bmain, bNodeTree *ntree, bNode *node)
{
/* Special case for drivers: if node tree has any drivers we assume it is
* always to be tagged for update when node changes. Otherwise we will be
@@ -170,7 +169,7 @@ bool node_connected_to_output(bNodeTree *ntree, bNode *node)
return true;
}
if (ntree_check_nodes_connected(ntree, node, current_node) &&
- node_group_has_output(current_node))
+ node_group_has_output(bmain, current_node))
{
return true;
}
@@ -313,7 +312,7 @@ static bool snode_autoconnect_input(SpaceNode *snode, bNode *node_fr, bNodeSocke
return true;
}
-static void snode_autoconnect(SpaceNode *snode, const bool allow_multiple, const bool replace)
+static void snode_autoconnect(Main *bmain, SpaceNode *snode, const bool allow_multiple, const bool replace)
{
bNodeTree *ntree = snode->edittree;
ListBase *nodelist = MEM_callocN(sizeof(ListBase), "items_list");
@@ -390,7 +389,7 @@ static void snode_autoconnect(SpaceNode *snode, const bool allow_multiple, const
}
if (numlinks > 0) {
- ntreeUpdateTree(G.main, ntree);
+ ntreeUpdateTree(bmain, ntree);
}
BLI_freelistN(nodelist);
@@ -556,12 +555,12 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
bNodeLink *tlink, *tlink_next;
int to_count = node_count_links(ntree, to);
int from_count = node_count_links(ntree, from);
-
+
for (tlink = ntree->links.first; tlink; tlink = tlink_next) {
tlink_next = tlink->next;
if (tlink == link)
continue;
-
+
if (tlink && tlink->fromsock == from) {
if (from_count > from->limit) {
nodeRemLink(ntree, tlink);
@@ -569,7 +568,7 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
--from_count;
}
}
-
+
if (tlink && tlink->tosock == to) {
if (to_count > to->limit) {
nodeRemLink(ntree, tlink);
@@ -582,6 +581,7 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
{
+ Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
bNodeLinkDrag *nldrag = op->customdata;
@@ -607,20 +607,20 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
link->fromnode->typeinfo->insert_link(ntree, link->fromnode, link);
if (link->tonode->typeinfo->insert_link)
link->tonode->typeinfo->insert_link(ntree, link->tonode, link);
-
+
/* add link to the node tree */
BLI_addtail(&ntree->links, link);
-
+
ntree->update |= NTREE_UPDATE_LINKS;
-
+
/* tag tonode for update */
link->tonode->update |= NODE_UPDATE;
-
+
/* we might need to remove a link */
node_remove_extra_links(snode, link);
if (link->tonode) {
- do_tag_update |= (do_tag_update || node_connected_to_output(ntree, link->tonode));
+ do_tag_update |= (do_tag_update || node_connected_to_output(bmain, ntree, link->tonode));
}
}
else {
@@ -628,13 +628,13 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
}
}
ntree->is_updating = false;
-
- ntreeUpdateTree(CTX_data_main(C), ntree);
+
+ ntreeUpdateTree(bmain, ntree);
snode_notify(C, snode);
if (do_tag_update) {
snode_dag_update(C, snode);
}
-
+
BLI_remlink(&snode->linkdrag, nldrag);
/* links->data pointers are either held by the tree or freed already */
BLI_freelistN(&nldrag->links);
@@ -653,14 +653,14 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
if (node_find_indicated_socket(snode, &tnode, &tsock, cursor, SOCK_IN)) {
for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
bNodeLink *link = linkdata->data;
-
+
/* skip if this is already the target socket */
if (link->tosock == tsock)
continue;
/* skip if socket is on the same node as the fromsock */
if (tnode && link->fromnode == tnode)
continue;
-
+
/* attach links to the socket */
link->tonode = tnode;
link->tosock = tsock;
@@ -669,7 +669,7 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
else {
for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
bNodeLink *link = linkdata->data;
-
+
link->tonode = NULL;
link->tosock = NULL;
}
@@ -679,14 +679,14 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
if (node_find_indicated_socket(snode, &tnode, &tsock, cursor, SOCK_OUT)) {
for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
bNodeLink *link = linkdata->data;
-
+
/* skip if this is already the target socket */
if (link->fromsock == tsock)
continue;
/* skip if socket is on the same node as the fromsock */
if (tnode && link->tonode == tnode)
continue;
-
+
/* attach links to the socket */
link->fromnode = tnode;
link->fromsock = tsock;
@@ -695,7 +695,7 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
else {
for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
bNodeLink *link = linkdata->data;
-
+
link->fromnode = NULL;
link->fromsock = NULL;
}
@@ -710,35 +710,38 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
bNodeLinkDrag *nldrag = op->customdata;
ARegion *ar = CTX_wm_region(C);
float cursor[2];
-
+
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
&cursor[0], &cursor[1]);
-
+
switch (event->type) {
case MOUSEMOVE:
node_link_find_socket(C, op, cursor);
-
+
node_link_update_header(C, nldrag);
ED_region_tag_redraw(ar);
break;
-
+
case LEFTMOUSE:
case RIGHTMOUSE:
case MIDDLEMOUSE:
{
- node_link_exit(C, op, true);
-
- ED_area_headerprint(CTX_wm_area(C), NULL);
- ED_region_tag_redraw(ar);
- return OPERATOR_FINISHED;
+ if (event->val == KM_RELEASE) {
+ node_link_exit(C, op, true);
+
+ ED_area_headerprint(CTX_wm_area(C), NULL);
+ ED_region_tag_redraw(ar);
+ return OPERATOR_FINISHED;
+ }
+ break;
}
}
-
+
return OPERATOR_RUNNING_MODAL;
}
/* return 1 when socket clicked */
-static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool detach)
+static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor[2], bool detach)
{
bNode *node;
bNodeSocket *sock;
@@ -772,7 +775,7 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool det
* using TEST flag.
*/
oplink->flag &= ~NODE_LINK_TEST;
- if (node_connected_to_output(snode->edittree, link->tonode)) {
+ if (node_connected_to_output(bmain, snode->edittree, link->tonode)) {
oplink->flag |= NODE_LINK_TEST;
}
@@ -791,7 +794,7 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool det
oplink->fromsock = sock;
oplink->flag |= NODE_LINK_VALID;
oplink->flag &= ~NODE_LINK_TEST;
- if (node_connected_to_output(snode->edittree, node)) {
+ if (node_connected_to_output(bmain, snode->edittree, node)) {
oplink->flag |= NODE_LINK_TEST;
}
@@ -816,13 +819,13 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool det
oplink->next = oplink->prev = NULL;
oplink->flag |= NODE_LINK_VALID;
oplink->flag &= ~NODE_LINK_TEST;
- if (node_connected_to_output(snode->edittree, link->tonode)) {
+ if (node_connected_to_output(bmain, snode->edittree, link->tonode)) {
oplink->flag |= NODE_LINK_TEST;
}
BLI_addtail(&nldrag->links, linkdata);
nodeRemLink(snode->edittree, link);
-
+
/* send changed event to original link->tonode */
if (node)
snode_update(snode, node);
@@ -839,32 +842,33 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool det
oplink->tosock = sock;
oplink->flag |= NODE_LINK_VALID;
oplink->flag &= ~NODE_LINK_TEST;
- if (node_connected_to_output(snode->edittree, node)) {
+ if (node_connected_to_output(bmain, snode->edittree, node)) {
oplink->flag |= NODE_LINK_TEST;
}
BLI_addtail(&nldrag->links, linkdata);
}
}
-
+
return nldrag;
}
static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
+ Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *ar = CTX_wm_region(C);
bNodeLinkDrag *nldrag;
float cursor[2];
-
+
bool detach = RNA_boolean_get(op->ptr, "detach");
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
&cursor[0], &cursor[1]);
- ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
+ ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
- nldrag = node_link_init(snode, cursor, detach);
+ nldrag = node_link_init(bmain, snode, cursor, detach);
if (nldrag) {
op->customdata = nldrag;
@@ -915,12 +919,13 @@ void NODE_OT_link(wmOperatorType *ot)
/* makes a link between selected output and input sockets */
static int node_make_link_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
const bool replace = RNA_boolean_get(op->ptr, "replace");
- ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
+ ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
- snode_autoconnect(snode, 1, replace);
+ snode_autoconnect(bmain, snode, 1, replace);
/* deselect sockets after linking */
node_deselect_all_input_sockets(snode, 0);
@@ -968,6 +973,7 @@ static bool cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot)
static int cut_links_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *ar = CTX_wm_region(C);
float mcoords[256][2];
@@ -989,9 +995,9 @@ static int cut_links_exec(bContext *C, wmOperator *op)
if (i > 1) {
bool found = false;
bNodeLink *link, *next;
-
- ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
-
+
+ ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
+
for (link = snode->edittree->links.first; link; link = next) {
next = link->next;
if (nodeLinkIsHidden(link))
@@ -1001,11 +1007,11 @@ static int cut_links_exec(bContext *C, wmOperator *op)
if (found == false) {
/* TODO(sergey): Why did we kill jobs twice? */
- ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
+ ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
found = true;
}
- do_tag_update |= (do_tag_update || node_connected_to_output(snode->edittree, link->tonode));
+ do_tag_update |= (do_tag_update || node_connected_to_output(bmain, snode->edittree, link->tonode));
snode_update(snode, link->tonode);
nodeRemLink(snode->edittree, link);
@@ -1294,7 +1300,7 @@ void NODE_OT_attach(wmOperatorType *ot)
ot->idname = "NODE_OT_attach";
/* api callbacks */
-
+
ot->invoke = node_attach_invoke;
ot->poll = ED_operator_node_editable;
@@ -1413,7 +1419,7 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode,
for (link = snode->edittree->links.first; link; link = link->next) {
if (nodeLinkIsHidden(link))
continue;
-
+
if (link->tonode == select || link->fromnode == select)
return false;
}
@@ -1830,7 +1836,7 @@ void NODE_OT_insert_offset(wmOperatorType *ot)
}
/* assumes link with NODE_LINKFLAG_HILITE set */
-void ED_node_link_insert(ScrArea *sa)
+void ED_node_link_insert(Main *bmain, ScrArea *sa)
{
bNode *node, *select;
SpaceNode *snode;
@@ -1847,18 +1853,18 @@ void ED_node_link_insert(ScrArea *sa)
if (link) {
bNodeSocket *best_input = socket_best_match(&select->inputs);
bNodeSocket *best_output = socket_best_match(&select->outputs);
-
+
if (best_input && best_output) {
node = link->tonode;
sockto = link->tosock;
-
+
link->tonode = select;
link->tosock = best_input;
node_remove_extra_links(snode, link);
link->flag &= ~NODE_LINKFLAG_HILITE;
-
+
nodeAddLink(snode->edittree, select, best_output, node, sockto);
-
+
/* set up insert offset data, it needs stuff from here */
if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) {
NodeInsertOfsData *iofsd = MEM_callocN(sizeof(NodeInsertOfsData), __func__);
@@ -1870,7 +1876,7 @@ void ED_node_link_insert(ScrArea *sa)
snode->iofsd = iofsd;
}
- ntreeUpdateTree(G.main, snode->edittree); /* needed for pointers */
+ ntreeUpdateTree(bmain, snode->edittree); /* needed for pointers */
snode_update(snode, select);
ED_node_tag_update_id(snode->id);
}
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index fcbd8156723..3ae542c48db 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation, Nathan Letwory
*
* ***** END GPL LICENSE BLOCK *****
@@ -65,7 +65,7 @@
static bNode *node_under_mouse_select(bNodeTree *ntree, int mx, int my)
{
bNode *node;
-
+
for (node = ntree->nodes.last; node; node = node->prev) {
if (node->typeinfo->select_area_func) {
if (node->typeinfo->select_area_func(node, mx, my))
@@ -78,7 +78,7 @@ static bNode *node_under_mouse_select(bNodeTree *ntree, int mx, int my)
static bNode *node_under_mouse_tweak(bNodeTree *ntree, int mx, int my)
{
bNode *node;
-
+
for (node = ntree->nodes.last; node; node = node->prev) {
if (node->typeinfo->tweak_area_func) {
if (node->typeinfo->tweak_area_func(node, mx, my))
@@ -96,7 +96,7 @@ static void node_toggle(bNode *node)
void node_socket_select(bNode *node, bNodeSocket *sock)
{
sock->flag |= SELECT;
-
+
/* select node too */
if (node)
node->flag |= SELECT;
@@ -105,10 +105,10 @@ void node_socket_select(bNode *node, bNodeSocket *sock)
void node_socket_deselect(bNode *node, bNodeSocket *sock, const bool deselect_node)
{
sock->flag &= ~SELECT;
-
+
if (node && deselect_node) {
bool sel = 0;
-
+
/* if no selected sockets remain, also deselect the node */
for (sock = node->inputs.first; sock; sock = sock->next) {
if (sock->flag & SELECT) {
@@ -122,7 +122,7 @@ void node_socket_deselect(bNode *node, bNodeSocket *sock, const bool deselect_no
break;
}
}
-
+
if (!sel)
node->flag &= ~SELECT;
}
@@ -140,7 +140,7 @@ static void node_socket_toggle(bNode *node, bNodeSocket *sock, int deselect_node
void node_deselect_all(SpaceNode *snode)
{
bNode *node;
-
+
for (node = snode->edittree->nodes.first; node; node = node->next)
nodeSetSelected(node, false);
}
@@ -149,18 +149,18 @@ void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes
{
bNode *node;
bNodeSocket *sock;
-
+
/* XXX not calling node_socket_deselect here each time, because this does iteration
* over all node sockets internally to check if the node stays selected.
* We can do that more efficiently here.
*/
-
+
for (node = snode->edittree->nodes.first; node; node = node->next) {
int sel = 0;
-
+
for (sock = node->inputs.first; sock; sock = sock->next)
sock->flag &= ~SELECT;
-
+
/* if no selected sockets remain, also deselect the node */
if (deselect_nodes) {
for (sock = node->outputs.first; sock; sock = sock->next) {
@@ -169,7 +169,7 @@ void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes
break;
}
}
-
+
if (!sel)
node->flag &= ~SELECT;
}
@@ -180,18 +180,18 @@ void node_deselect_all_output_sockets(SpaceNode *snode, const bool deselect_node
{
bNode *node;
bNodeSocket *sock;
-
+
/* XXX not calling node_socket_deselect here each time, because this does iteration
* over all node sockets internally to check if the node stays selected.
* We can do that more efficiently here.
*/
-
+
for (node = snode->edittree->nodes.first; node; node = node->next) {
bool sel = false;
-
+
for (sock = node->outputs.first; sock; sock = sock->next)
sock->flag &= ~SELECT;
-
+
/* if no selected sockets remain, also deselect the node */
if (deselect_nodes) {
for (sock = node->inputs.first; sock; sock = sock->next) {
@@ -200,7 +200,7 @@ void node_deselect_all_output_sockets(SpaceNode *snode, const bool deselect_node
break;
}
}
-
+
if (!sel)
node->flag &= ~SELECT;
}
@@ -364,32 +364,32 @@ void node_select_single(bContext *C, bNode *node)
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
bNode *tnode;
-
+
for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next)
if (tnode != node)
nodeSetSelected(tnode, false);
nodeSetSelected(node, true);
-
+
ED_node_set_active(bmain, snode->edittree, node);
ED_node_set_active_viewer_key(snode);
-
+
ED_node_sort(snode->edittree);
-
+
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
}
/* ****** Click Select ****** */
-
+
static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const int mval[2], short extend)
{
bNode *node, *tnode;
bNodeSocket *sock, *tsock;
float cursor[2];
int selected = 0;
-
+
/* get mouse coordinates in view2d space */
UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &cursor[0], &cursor[1]);
-
+
if (extend) {
/* first do socket selection, these generally overlap with nodes.
* socket selection only in extend mode.
@@ -417,7 +417,7 @@ static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const i
else {
/* find the closest visible node */
node = node_under_mouse_select(snode->edittree, cursor[0], cursor[1]);
-
+
if (node) {
if ((node->flag & SELECT) && (node->flag & NODE_ACTIVE) == 0) {
/* if node is selected but not active make it active
@@ -435,10 +435,10 @@ static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const i
}
}
else { /* extend == 0 */
-
+
/* find the closest visible node */
node = node_under_mouse_select(snode->edittree, cursor[0], cursor[1]);
-
+
if (node) {
for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) {
nodeSetSelected(tnode, false);
@@ -448,13 +448,13 @@ static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const i
selected = 1;
}
}
-
+
/* update node order */
if (selected) {
ED_node_set_active_viewer_key(snode);
ED_node_sort(snode->edittree);
}
-
+
return selected;
}
@@ -465,18 +465,18 @@ static int node_select_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
int mval[2];
short extend;
-
+
/* get settings from RNA properties for operator */
mval[0] = RNA_int_get(op->ptr, "mouse_x");
mval[1] = RNA_int_get(op->ptr, "mouse_y");
-
+
extend = RNA_boolean_get(op->ptr, "extend");
-
+
/* perform the select */
if (node_mouse_select(bmain, snode, ar, mval, extend)) {
/* send notifiers */
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
-
+
/* allow tweak event to work too */
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
}
@@ -501,15 +501,15 @@ void NODE_OT_select(wmOperatorType *ot)
ot->name = "Select";
ot->idname = "NODE_OT_select";
ot->description = "Select the node under the cursor";
-
+
/* api callbacks */
ot->invoke = node_select_invoke;
ot->exec = node_select_exec;
ot->poll = ED_operator_node_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_int(ot->srna, "mouse_x", 0, INT_MIN, INT_MAX, "Mouse X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "mouse_y", 0, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX);
@@ -526,10 +526,10 @@ static int node_borderselect_exec(bContext *C, wmOperator *op)
rctf rectf;
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
-
+
WM_operator_properties_border_to_rctf(op, &rectf);
UI_view2d_region_to_view_rctf(&ar->v2d, &rectf, &rectf);
-
+
for (node = snode->edittree->nodes.first; node; node = node->next) {
bool is_inside;
if (node->type == NODE_FRAME) {
@@ -546,9 +546,9 @@ static int node_borderselect_exec(bContext *C, wmOperator *op)
nodeSetSelected(node, false);
}
}
-
+
ED_node_sort(snode->edittree);
-
+
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -557,7 +557,7 @@ static int node_borderselect_exec(bContext *C, wmOperator *op)
static int node_border_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
const bool tweak = RNA_boolean_get(op->ptr, "tweak");
-
+
if (tweak) {
/* prevent initiating the border select if the mouse is over a node */
/* this allows border select on empty space, but drag-translate on nodes */
@@ -566,11 +566,11 @@ static int node_border_select_invoke(bContext *C, wmOperator *op, const wmEvent
float mx, my;
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &mx, &my);
-
+
if (node_under_mouse_tweak(snode->edittree, mx, my))
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
}
-
+
return WM_gesture_border_invoke(C, op, event);
}
@@ -580,18 +580,18 @@ void NODE_OT_select_border(wmOperatorType *ot)
ot->name = "Border Select";
ot->idname = "NODE_OT_select_border";
ot->description = "Use box selection to select nodes";
-
+
/* api callbacks */
ot->invoke = node_border_select_invoke;
ot->exec = node_borderselect_exec;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
-
+
ot->poll = ED_operator_node_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* rna */
WM_operator_properties_gesture_border_select(ot);
RNA_def_boolean(ot->srna, "tweak", 0, "Tweak", "Only activate when mouse is not over a node - useful for tweak gesture");
@@ -767,7 +767,7 @@ static int node_select_all_exec(bContext *C, wmOperator *op)
}
ED_node_sort(snode->edittree);
-
+
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -778,11 +778,11 @@ void NODE_OT_select_all(wmOperatorType *ot)
ot->name = "(De)select All";
ot->description = "(De)select all nodes";
ot->idname = "NODE_OT_select_all";
-
+
/* api callbacks */
ot->exec = node_select_all_exec;
ot->poll = ED_operator_node_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -796,7 +796,7 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op))
SpaceNode *snode = CTX_wm_space_node(C);
bNodeLink *link;
bNode *node;
-
+
for (node = snode->edittree->nodes.first; node; node = node->next)
node->flag &= ~NODE_TEST;
@@ -806,14 +806,14 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op))
if (link->fromnode && link->tonode && (link->fromnode->flag & NODE_SELECT))
link->tonode->flag |= NODE_TEST;
}
-
+
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & NODE_TEST)
nodeSetSelected(node, true);
}
-
+
ED_node_sort(snode->edittree);
-
+
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -824,11 +824,11 @@ void NODE_OT_select_linked_to(wmOperatorType *ot)
ot->name = "Select Linked To";
ot->description = "Select nodes linked to the selected ones";
ot->idname = "NODE_OT_select_linked_to";
-
+
/* api callbacks */
ot->exec = node_select_linked_to_exec;
ot->poll = ED_operator_node_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -840,7 +840,7 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op))
SpaceNode *snode = CTX_wm_space_node(C);
bNodeLink *link;
bNode *node;
-
+
for (node = snode->edittree->nodes.first; node; node = node->next)
node->flag &= ~NODE_TEST;
@@ -850,14 +850,14 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op))
if (link->fromnode && link->tonode && (link->tonode->flag & NODE_SELECT))
link->fromnode->flag |= NODE_TEST;
}
-
+
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & NODE_TEST)
nodeSetSelected(node, true);
}
-
+
ED_node_sort(snode->edittree);
-
+
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -868,11 +868,11 @@ void NODE_OT_select_linked_from(wmOperatorType *ot)
ot->name = "Select Linked From";
ot->description = "Select nodes linked from the selected ones";
ot->idname = "NODE_OT_select_linked_from";
-
+
/* api callbacks */
ot->exec = node_select_linked_from_exec;
ot->poll = ED_operator_node_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -886,29 +886,29 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
int totnodes;
const bool revert = RNA_boolean_get(op->ptr, "prev");
const bool same_type = 1;
-
+
ntreeGetDependencyList(snode->edittree, &node_array, &totnodes);
-
+
if (totnodes > 1) {
int a;
-
+
for (a = 0; a < totnodes; a++) {
if (node_array[a] == active)
break;
}
-
+
if (same_type) {
bNode *node = NULL;
-
+
while (node == NULL) {
if (revert) a--;
else a++;
-
+
if (a < 0 || a >= totnodes)
break;
-
+
node = node_array[a];
-
+
if (node->type == active->type)
break;
else node = NULL;
@@ -930,7 +930,7 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
active = node_array[a + 1];
}
}
-
+
node_select_single(C, active);
/* is note outside view? */
@@ -941,10 +941,10 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
space_node_view_flag(C, snode, ar, NODE_SELECT, smooth_viewtx);
}
}
-
+
if (node_array)
MEM_freeN(node_array);
-
+
return OPERATOR_FINISHED;
}
@@ -954,14 +954,14 @@ void NODE_OT_select_same_type_step(wmOperatorType *ot)
ot->name = "Activate Same Type Next/Prev";
ot->description = "Activate and view same node type, step by step";
ot->idname = "NODE_OT_select_same_type_step";
-
+
/* api callbacks */
ot->exec = node_select_same_type_step_exec;
ot->poll = ED_operator_node_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_boolean(ot->srna, "prev", 0, "Previous", "");
}
@@ -973,12 +973,12 @@ static void node_find_cb(const struct bContext *C, void *UNUSED(arg), const char
{
SpaceNode *snode = CTX_wm_space_node(C);
bNode *node;
-
+
for (node = snode->edittree->nodes.first; node; node = node->next) {
-
+
if (BLI_strcasestr(node->name, str) || BLI_strcasestr(node->label, str)) {
char name[256];
-
+
if (node->label[0])
BLI_snprintf(name, 256, "%s (%s)", node->name, node->label);
else
@@ -993,11 +993,11 @@ static void node_find_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2
{
SpaceNode *snode = CTX_wm_space_node(C);
bNode *active = arg2;
-
+
if (active) {
ARegion *ar = CTX_wm_region(C);
node_select_single(C, active);
-
+
/* is note outside view? */
if (active->totr.xmax < ar->v2d.cur.xmin || active->totr.xmin > ar->v2d.cur.xmax ||
active->totr.ymax < ar->v2d.cur.ymin || active->totr.ymin > ar->v2d.cur.ymax)
@@ -1016,18 +1016,18 @@ static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op)
uiBlock *block;
uiBut *but;
wmOperator *op = (wmOperator *)arg_op;
-
+
block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU);
-
+
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, "");
UI_but_func_search_set(but, NULL, node_find_cb, op->type, node_find_call_cb, NULL);
-
+
/* fake button, it holds space for search items */
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - UI_searchbox_size_y(), UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL);
-
+
UI_block_bounds_set_popup(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */
-
+
// UI_but_active_only(C, ar, block, but); XXX using this here makes Blender hang - investigate
wm_event_init_from_window(win, &event);
event.type = EVT_BUT_OPEN;
@@ -1035,7 +1035,7 @@ static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op)
event.customdata = but;
event.customdatafree = false;
wm_event_add(win, &event);
-
+
return block;
}
@@ -1053,16 +1053,16 @@ void NODE_OT_find_node(wmOperatorType *ot)
ot->name = "Find Node";
ot->description = "Search for named node and allow to select and activate it";
ot->idname = "NODE_OT_find_node";
-
+
/* api callbacks */
ot->invoke = node_find_node_invoke;
ot->poll = ED_operator_node_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_boolean(ot->srna, "prev", 0, "Previous", "");
-
+
}
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index 5f48b7d7a0f..23fd793cdd3 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -64,7 +64,7 @@ typedef struct NodeLinkItem {
int socket_type; /* socket type for compatibility check */
const char *socket_name; /* ui label of the socket */
const char *node_name; /* ui label of the node */
-
+
/* extra settings */
bNodeTree *ngroup; /* group node tree */
} NodeLinkItem;
@@ -82,16 +82,16 @@ static bool node_link_item_compare(bNode *node, NodeLinkItem *item)
return true;
}
-static void node_link_item_apply(bNode *node, NodeLinkItem *item)
+static void node_link_item_apply(Main *bmain, bNode *node, NodeLinkItem *item)
{
if (node->type == NODE_GROUP) {
node->id = (ID *)item->ngroup;
- ntreeUpdateTree(G.main, item->ngroup);
+ ntreeUpdateTree(bmain, item->ngroup);
}
else {
/* nothing to do for now */
}
-
+
if (node->id)
id_us_plus(node->id);
}
@@ -191,6 +191,7 @@ static void node_socket_remove(Main *bmain, bNodeTree *ntree, bNode *node_to, bN
static void node_socket_add_replace(const bContext *C, bNodeTree *ntree, bNode *node_to, bNodeSocket *sock_to,
int type, NodeLinkItem *item)
{
+ Main *bmain = CTX_data_main(C);
bNode *node_from;
bNodeSocket *sock_from_tmp;
bNode *node_prev = NULL;
@@ -232,8 +233,8 @@ static void node_socket_add_replace(const bContext *C, bNodeTree *ntree, bNode *
node_from->locx = node_to->locx - (node_from->typeinfo->width + 50);
node_from->locy = node_to->locy - (node_from->typeinfo->height * index);
}
-
- node_link_item_apply(node_from, item);
+
+ node_link_item_apply(bmain, node_from, item);
}
nodeSetActive(ntree, node_from);
@@ -307,19 +308,19 @@ static void ui_node_link_items(NodeLinkArg *arg, int in_out, NodeLinkItem **r_it
/* XXX this should become a callback for node types! */
NodeLinkItem *items = NULL;
int totitems = 0;
-
+
if (arg->node_type->type == NODE_GROUP) {
bNodeTree *ngroup;
int i;
-
+
for (ngroup = arg->bmain->nodetree.first; ngroup; ngroup = ngroup->id.next) {
ListBase *lb = ((in_out == SOCK_IN) ? &ngroup->inputs : &ngroup->outputs);
totitems += BLI_listbase_count(lb);
}
-
+
if (totitems > 0) {
items = MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items");
-
+
i = 0;
for (ngroup = arg->bmain->nodetree.first; ngroup; ngroup = ngroup->id.next) {
ListBase *lb = (in_out == SOCK_IN ? &ngroup->inputs : &ngroup->outputs);
@@ -327,7 +328,7 @@ static void ui_node_link_items(NodeLinkArg *arg, int in_out, NodeLinkItem **r_it
int index;
for (stemp = lb->first, index = 0; stemp; stemp = stemp->next, ++index, ++i) {
NodeLinkItem *item = &items[i];
-
+
item->socket_index = index;
/* note: int stemp->type is not fully reliable, not used for node group
* interface sockets. use the typeinfo->type instead.
@@ -344,17 +345,17 @@ static void ui_node_link_items(NodeLinkArg *arg, int in_out, NodeLinkItem **r_it
bNodeSocketTemplate *socket_templates = (in_out == SOCK_IN ? arg->node_type->inputs : arg->node_type->outputs);
bNodeSocketTemplate *stemp;
int i;
-
+
for (stemp = socket_templates; stemp && stemp->type != -1; ++stemp)
++totitems;
-
+
if (totitems > 0) {
items = MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items");
-
+
i = 0;
for (stemp = socket_templates; stemp && stemp->type != -1; ++stemp, ++i) {
NodeLinkItem *item = &items[i];
-
+
item->socket_index = i;
item->socket_type = stemp->type;
item->socket_name = stemp->name;
@@ -362,7 +363,7 @@ static void ui_node_link_items(NodeLinkArg *arg, int in_out, NodeLinkItem **r_it
}
}
}
-
+
*r_items = items;
*r_totitems = totitems;
}
@@ -446,7 +447,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
NodeLinkArg *argN;
int first = 1;
int compatibility = 0;
-
+
if (ntree->type == NTREE_SHADER) {
compatibility = NODE_NEW_SHADING;
}
@@ -483,29 +484,29 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
const char *cur_node_name = NULL;
int i, num = 0;
int icon = ICON_NONE;
-
+
arg->node_type = ntype;
-
+
ui_node_link_items(arg, SOCK_OUT, &items, &totitems);
-
+
for (i = 0; i < totitems; ++i)
if (ui_compatible_sockets(items[i].socket_type, sock->type))
num++;
-
+
for (i = 0; i < totitems; ++i) {
if (!ui_compatible_sockets(items[i].socket_type, sock->type))
continue;
-
+
if (first) {
column = uiLayoutColumn(layout, 0);
UI_block_layout_set_current(block, column);
-
+
uiItemL(column, IFACE_(cname), ICON_NODE);
but = block->buttons.last;
-
+
first = 0;
}
-
+
if (num > 1) {
if (!cur_node_name || !STREQ(cur_node_name, items[i].node_name)) {
cur_node_name = items[i].node_name;
@@ -521,15 +522,15 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
BLI_strncpy(name, IFACE_(items[i].node_name), UI_MAX_NAME_STR);
icon = ICON_NONE;
}
-
+
but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y,
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input"));
-
+
argN = MEM_dupallocN(arg);
argN->item = items[i];
UI_but_funcN_set(but, ui_node_link, argN, NULL);
}
-
+
if (items)
MEM_freeN(items);
}
@@ -634,7 +635,7 @@ static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, b
if (node->typeinfo->draw_buttons) {
if (node->type != NODE_GROUP) {
- split = uiLayoutSplit(layout, 0.35f, false);
+ split = uiLayoutSplit(layout, 0.5f, false);
col = uiLayoutColumn(split, false);
col = uiLayoutColumn(split, false);
@@ -677,10 +678,10 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
label[i] = ' ';
}
label[indent] = '\0';
- BLI_snprintf(label + indent, UI_MAX_NAME_STR - indent, "%s:", IFACE_(input->name));
+ BLI_snprintf(label + indent, UI_MAX_NAME_STR - indent, "%s", IFACE_(input->name));
/* split in label and value */
- split = uiLayoutSplit(layout, 0.35f, false);
+ split = uiLayoutSplit(layout, 0.5f, false);
row = uiLayoutRow(split, true);
@@ -702,7 +703,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
uiItemL(row, label, ICON_NONE);
bt = block->buttons.last;
- bt->drawflag = UI_BUT_TEXT_LEFT;
+ bt->drawflag = UI_BUT_TEXT_RIGHT;
if (dependency_loop) {
row = uiLayoutRow(split, false);
@@ -736,7 +737,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
col = uiLayoutColumn(row, false);
uiItemR(col, &inputptr, "default_value", 0, "", ICON_NONE);
break;
-
+
default:
row = uiLayoutRow(split, false);
break;
diff --git a/source/blender/editors/space_node/node_toolbar.c b/source/blender/editors/space_node/node_toolbar.c
index e3e263f2e44..21278dd9fa5 100644
--- a/source/blender/editors/space_node/node_toolbar.c
+++ b/source/blender/editors/space_node/node_toolbar.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2012 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Lukas Toenne
*
* ***** END GPL LICENSE BLOCK *****
@@ -55,7 +55,7 @@ static int node_toolbar_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = node_has_tools_region(sa);
-
+
if (ar)
ED_region_toggle_hidden(C, ar);
@@ -74,10 +74,10 @@ void NODE_OT_toolbar(wmOperatorType *ot)
ot->name = "Tool Shelf";
ot->description = "Toggles tool shelf display";
ot->idname = "NODE_OT_toolbar";
-
+
ot->exec = node_toolbar_toggle_exec;
ot->poll = node_toolbar_poll;
-
+
/* flags */
ot->flag = 0;
}
diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c
index f497a06cb12..00eab0c69c1 100644
--- a/source/blender/editors/space_node/node_view.c
+++ b/source/blender/editors/space_node/node_view.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation, Nathan Letwory
*
* ***** END GPL LICENSE BLOCK *****
@@ -36,8 +36,9 @@
#include "BKE_context.h"
#include "BKE_image.h"
-#include "BKE_screen.h"
+#include "BKE_main.h"
#include "BKE_node.h"
+#include "BKE_screen.h"
#include "ED_node.h" /* own include */
#include "ED_screen.h"
@@ -73,7 +74,7 @@ int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar,
float oldasp, asp;
int tot = 0;
bool has_frame = false;
-
+
oldwidth = BLI_rctf_size_x(&ar->v2d.cur);
oldheight = BLI_rctf_size_y(&ar->v2d.cur);
@@ -154,11 +155,11 @@ void NODE_OT_view_all(wmOperatorType *ot)
ot->name = "View All";
ot->idname = "NODE_OT_view_all";
ot->description = "Resize view so you can see all nodes";
-
+
/* api callbacks */
ot->exec = node_view_all_exec;
ot->poll = ED_operator_node_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -225,11 +226,12 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *e
case LEFTMOUSE:
case MIDDLEMOUSE:
case RIGHTMOUSE:
-
- MEM_freeN(nvm);
- op->customdata = NULL;
-
- return OPERATOR_FINISHED;
+ if (event->val == KM_RELEASE) {
+ MEM_freeN(nvm);
+ op->customdata = NULL;
+ return OPERATOR_FINISHED;
+ }
+ break;
}
return OPERATOR_RUNNING_MODAL;
@@ -237,6 +239,7 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *e
static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
+ Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *ar = CTX_wm_region(C);
NodeViewMove *nvm;
@@ -246,7 +249,7 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *
void *lock;
- ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf == NULL) {
@@ -330,6 +333,7 @@ void NODE_OT_backimage_zoom(wmOperatorType *ot)
static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *ar = CTX_wm_region(C);
@@ -342,7 +346,7 @@ static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
float facx, facy;
- ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if ((ibuf == NULL) || (ibuf->x == 0) || (ibuf->y == 0)) {
@@ -394,7 +398,7 @@ typedef struct ImageSampleInfo {
unsigned char col[4];
float colf[4];
float linearcol[4];
-
+
int z;
float zf;
@@ -420,7 +424,7 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
/* Returns color in linear space, matching ED_space_image_color_sample().
* And here we've got recursion in the comments tips...
*/
-bool ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], float r_col[3])
+bool ED_space_node_color_sample(Main *bmain, SpaceNode *snode, ARegion *ar, int mval[2], float r_col[3])
{
void *lock;
Image *ima;
@@ -435,7 +439,7 @@ bool ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], floa
return false;
}
- ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (!ibuf) {
return false;
@@ -476,6 +480,7 @@ bool ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], floa
static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
{
+ Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *ar = CTX_wm_region(C);
ImageSampleInfo *info = op->customdata;
@@ -484,7 +489,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
ImBuf *ibuf;
float fx, fy, bufx, bufy;
- ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (!ibuf) {
info->draw = 0;
@@ -545,7 +550,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
info->color_manage = true;
}
-
+
if (ibuf->zbuf) {
info->z = ibuf->zbuf[y * ibuf->x + x];
info->zp = &info->z;
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 28598591012..36886d0ab32 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -54,6 +54,8 @@
#include "UI_view2d.h"
#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -71,30 +73,30 @@ void ED_node_tree_start(SpaceNode *snode, bNodeTree *ntree, ID *id, ID *from)
MEM_freeN(path);
}
BLI_listbase_clear(&snode->treepath);
-
+
if (ntree) {
path = MEM_callocN(sizeof(bNodeTreePath), "node tree path");
path->nodetree = ntree;
path->parent_key = NODE_INSTANCE_KEY_BASE;
-
+
/* copy initial offset from bNodeTree */
copy_v2_v2(path->view_center, ntree->view_center);
-
+
if (id)
BLI_strncpy(path->node_name, id->name + 2, sizeof(path->node_name));
-
+
BLI_addtail(&snode->treepath, path);
-
+
id_us_ensure_real(&ntree->id);
}
-
+
/* update current tree */
snode->nodetree = snode->edittree = ntree;
snode->id = id;
snode->from = from;
-
+
ED_node_set_active_viewer_key(snode);
-
+
WM_main_add_notifier(NC_SCENE | ND_NODES, NULL);
}
@@ -108,44 +110,44 @@ void ED_node_tree_push(SpaceNode *snode, bNodeTree *ntree, bNode *gnode)
path->parent_key = BKE_node_instance_key(prev_path->parent_key, prev_path->nodetree, gnode);
else
path->parent_key = NODE_INSTANCE_KEY_BASE;
-
+
BLI_strncpy(path->node_name, gnode->name, sizeof(path->node_name));
}
else
path->parent_key = NODE_INSTANCE_KEY_BASE;
-
+
/* copy initial offset from bNodeTree */
copy_v2_v2(path->view_center, ntree->view_center);
-
+
BLI_addtail(&snode->treepath, path);
-
+
id_us_ensure_real(&ntree->id);
-
+
/* update current tree */
snode->edittree = ntree;
-
+
ED_node_set_active_viewer_key(snode);
-
+
WM_main_add_notifier(NC_SCENE | ND_NODES, NULL);
}
void ED_node_tree_pop(SpaceNode *snode)
{
bNodeTreePath *path = snode->treepath.last;
-
+
/* don't remove root */
if (path == snode->treepath.first)
return;
-
+
BLI_remlink(&snode->treepath, path);
MEM_freeN(path);
-
+
/* update current tree */
path = snode->treepath.last;
snode->edittree = path->nodetree;
-
+
ED_node_set_active_viewer_key(snode);
-
+
/* listener updates the View2D center from edittree */
WM_main_add_notifier(NC_SCENE | ND_NODES, NULL);
}
@@ -183,7 +185,7 @@ void ED_node_tree_path_get(SpaceNode *snode, char *value)
{
bNodeTreePath *path;
int i;
-
+
value[0] = '\0';
for (path = snode->treepath.first, i = 0; path; path = path->next, ++i) {
if (i == 0) {
@@ -201,7 +203,7 @@ void ED_node_tree_path_get_fixedbuf(SpaceNode *snode, char *value, int max_lengt
{
bNodeTreePath *path;
int size, i;
-
+
value[0] = '\0';
for (path = snode->treepath.first, i = 0; path; path = path->next, ++i) {
if (i == 0) {
@@ -228,7 +230,7 @@ void ED_node_set_active_viewer_key(SpaceNode *snode)
void snode_group_offset(SpaceNode *snode, float *x, float *y)
{
bNodeTreePath *path = snode->treepath.last;
-
+
if (path && path->prev) {
float dcenter[2];
sub_v2_v2v2(dcenter, path->view_center, path->prev->view_center);
@@ -268,24 +270,24 @@ ARegion *node_has_buttons_region(ScrArea *sa)
ARegion *node_has_tools_region(ScrArea *sa)
{
ARegion *ar, *arnew;
-
+
ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
if (ar) return ar;
-
+
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
-
+
/* is error! */
if (ar == NULL) return NULL;
-
+
arnew = MEM_callocN(sizeof(ARegion), "node tools");
-
+
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
arnew->regiontype = RGN_TYPE_TOOLS;
arnew->alignment = RGN_ALIGN_LEFT;
-
+
arnew->flag = RGN_FLAG_HIDDEN;
-
+
return arnew;
}
@@ -401,7 +403,7 @@ static void node_area_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn
/* shift view to node tree center */
if (ar && path)
UI_view2d_center_set(&ar->v2d, path->view_center[0], path->view_center[1]);
-
+
ED_area_tag_refresh(sa);
break;
}
@@ -526,7 +528,7 @@ static void node_area_refresh(const struct bContext *C, ScrArea *sa)
{
/* default now: refresh node is starting preview */
SpaceNode *snode = sa->spacedata.first;
-
+
snode_set_context(C);
if (snode->nodetree) {
@@ -627,14 +629,14 @@ static void node_cursor(wmWindow *win, ScrArea *sa, ARegion *ar)
/* convert mouse coordinates to v2d space */
UI_view2d_region_to_view(&ar->v2d, win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin,
&snode->cursor[0], &snode->cursor[1]);
-
+
/* here snode->cursor is used to detect the node edge for sizing */
node_set_cursor(win, snode, snode->cursor);
/* XXX snode->cursor is in placing new nodes space */
snode->cursor[0] /= UI_DPI_FAC;
snode->cursor[1] /= UI_DPI_FAC;
-
+
}
/* Initialize main region, setting handlers. */
@@ -942,6 +944,32 @@ static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID
}
}
+
+static int node_space_subtype_get(ScrArea *sa)
+{
+ SpaceNode *snode = sa->spacedata.first;
+ return rna_node_tree_idname_to_enum(snode->tree_idname);
+}
+
+static void node_space_subtype_set(ScrArea *sa, int value)
+{
+ SpaceNode *snode = sa->spacedata.first;
+ ED_node_set_tree_type(snode, rna_node_tree_type_from_enum(value));
+}
+
+static void node_space_subtype_item_extend(
+ bContext *C, EnumPropertyItem **item, int *totitem)
+{
+ bool free;
+ const EnumPropertyItem *item_src = RNA_enum_node_tree_types_itemf_impl(C, &free);
+ for (const EnumPropertyItem *item_iter = item_src; item_iter->identifier; item_iter++) {
+ RNA_enum_item_add(item, totitem, item_iter);
+ }
+ if (free) {
+ MEM_freeN((void *)item_src);
+ }
+}
+
/* only called once, from space/spacetypes.c */
void ED_spacetype_node(void)
{
@@ -963,6 +991,9 @@ void ED_spacetype_node(void)
st->dropboxes = node_dropboxes;
st->manipulators = node_widgets;
st->id_remap = node_id_remap;
+ st->space_subtype_item_extend = node_space_subtype_item_extend;
+ st->space_subtype_get = node_space_subtype_get;
+ st->space_subtype_set = node_space_subtype_set;
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype node region");
@@ -1009,7 +1040,7 @@ void ED_spacetype_node(void)
art->init = node_toolbar_region_init;
art->draw = node_toolbar_region_draw;
BLI_addhead(&st->regiontypes, art);
-
+
node_toolbar_register(art);
BKE_spacetype_register(st);
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index 50df124bf22..909938ad606 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -42,6 +42,7 @@
#include "DEG_depsgraph_build.h"
#include "ED_object.h"
+#include "ED_outliner.h"
#include "ED_screen.h"
#include "WM_api.h"
@@ -101,7 +102,7 @@ Collection *outliner_collection_from_tree_element(const TreeElement *te)
/* -------------------------------------------------------------------- */
/* Poll functions. */
-static int collections_editor_poll(bContext *C)
+int ED_outliner_collections_editor_poll(bContext *C)
{
SpaceOops *so = CTX_wm_space_outliner(C);
return (so != NULL) && ELEM(so->outlinevis, SO_VIEW_LAYER, SO_SCENES, SO_LIBRARIES);
@@ -178,7 +179,7 @@ void OUTLINER_OT_collection_new(wmOperatorType *ot)
/* api callbacks */
ot->exec = collection_new_exec;
- ot->poll = collections_editor_poll;
+ ot->poll = ED_outliner_collections_editor_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -261,7 +262,7 @@ void OUTLINER_OT_collection_delete(wmOperatorType *ot)
/* api callbacks */
ot->exec = collection_delete_exec;
- ot->poll = collections_editor_poll;
+ ot->poll = ED_outliner_collections_editor_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -333,7 +334,7 @@ void OUTLINER_OT_collection_objects_select(wmOperatorType *ot)
/* api callbacks */
ot->exec = collection_objects_select_exec;
- ot->poll = collections_editor_poll;
+ ot->poll = ED_outliner_collections_editor_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -348,7 +349,7 @@ void OUTLINER_OT_collection_objects_deselect(wmOperatorType *ot)
/* api callbacks */
ot->exec = collection_objects_select_exec;
- ot->poll = collections_editor_poll;
+ ot->poll = ED_outliner_collections_editor_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -427,7 +428,7 @@ void OUTLINER_OT_collection_duplicate(wmOperatorType *ot)
/* api callbacks */
ot->exec = collection_duplicate_exec;
- ot->poll = collections_editor_poll;
+ ot->poll = ED_outliner_collections_editor_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -477,7 +478,7 @@ void OUTLINER_OT_collection_link(wmOperatorType *ot)
/* api callbacks */
ot->exec = collection_link_exec;
- ot->poll = collections_editor_poll;
+ ot->poll = ED_outliner_collections_editor_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -540,7 +541,7 @@ void OUTLINER_OT_collection_instance(wmOperatorType *ot)
/* api callbacks */
ot->exec = collection_instance_exec;
- ot->poll = collections_editor_poll;
+ ot->poll = ED_outliner_collections_editor_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -695,3 +696,21 @@ void OUTLINER_OT_collection_include_set(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+
+/**
+ * Populates the \param objects ListBase with all the outliner selected objects
+ * We store it as (Object *)LinkData->data
+ * \param objects expected to be empty
+ */
+void ED_outliner_selected_objects_get(const bContext *C, ListBase *objects)
+{
+ SpaceOops *soops = CTX_wm_space_outliner(C);
+ struct ObjectsSelectedData data = {{NULL}};
+ outliner_tree_traverse(soops, &soops->tree, 0, TSE_SELECTED, outliner_find_selected_objects, &data);
+ LISTBASE_FOREACH (LinkData *, link, &data.objects_selected_array) {
+ TreeElement *ten_selected = (TreeElement *)link->data;
+ Object *ob = (Object *)TREESTORE(ten_selected)->id;
+ BLI_addtail(objects, BLI_genericNodeN(ob));
+ }
+ BLI_freelistN(&data.objects_selected_array);
+}
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 172669ed122..a514d7f1335 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -105,7 +105,7 @@ static void outliner_width(SpaceOops *soops, ListBase *lb, int *w)
TreeElement *te = lb->first;
while (te) {
// TreeStoreElem *tselem = TREESTORE(te);
-
+
// XXX fixme... te->xend is not set yet
if (!TSELEM_OPEN(tselem, soops)) {
if (te->xend > *w)
@@ -138,6 +138,20 @@ static void outliner_rna_width(SpaceOops *soops, ListBase *lb, int *w, int start
}
}
+/**
+ * The active object is only needed for reference.
+ */
+static bool is_object_data_in_editmode(const ID *id, const Object *obact)
+{
+ const short id_type = GS(id->name);
+ return (
+ (obact && (obact->mode & OB_MODE_EDIT)) &&
+ (id && OB_DATA_SUPPORT_EDITMODE(id_type)) &&
+ (GS(((ID *)obact->data)->name) == id_type) &&
+ BKE_object_data_is_in_editmode(id)
+ );
+}
+
/* ****************************************************** */
static void restrictbutton_recursive_ebone(bContext *C, EditBone *ebone_parent, int flag, bool set_flag)
@@ -145,7 +159,7 @@ static void restrictbutton_recursive_ebone(bContext *C, EditBone *ebone_parent,
Object *obedit = CTX_data_edit_object(C);
bArmature *arm = obedit->data;
EditBone *ebone;
-
+
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (ED_armature_ebone_is_child_recursive(ebone_parent, ebone)) {
if (set_flag) {
@@ -183,7 +197,7 @@ static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *UNUSED(poin2)
static void restrictbutton_modifier_cb(bContext *C, void *UNUSED(poin), void *poin2)
{
Object *ob = (Object *)poin2;
-
+
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
}
@@ -251,9 +265,9 @@ static void restrictbutton_gp_layer_flag_cb(bContext *C, void *UNUSED(poin), voi
static void restrictbutton_id_user_toggle(bContext *UNUSED(C), void *poin, void *UNUSED(poin2))
{
ID *id = (ID *)poin;
-
+
BLI_assert(id != NULL);
-
+
if (id->flag & LIB_FAKEUSER) {
id_us_plus(id);
}
@@ -269,13 +283,13 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
Object *obedit = CTX_data_edit_object(C);
BLI_mempool *ts = soops->treestore;
TreeStoreElem *tselem = tsep;
-
+
if (ts && tselem) {
TreeElement *te = outliner_find_tree_element(&soops->tree, tselem);
-
+
if (tselem->type == 0) {
BLI_libblock_ensure_unique_name(bmain, tselem->id->name);
-
+
switch (GS(tselem->id->name)) {
case ID_MA:
WM_event_add_notifier(C, NC_MATERIAL, NULL); break;
@@ -293,10 +307,10 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
Library *lib = (Library *)tselem->id;
char expanded[FILE_MAX];
- BKE_library_filepath_set(lib, lib->name);
+ BKE_library_filepath_set(bmain, lib, lib->name);
BLI_strncpy(expanded, lib->name, sizeof(expanded));
- BLI_path_abs(expanded, bmain->name);
+ BLI_path_abs(expanded, BKE_main_blendfile_path(bmain));
if (!BLI_exists(expanded)) {
BKE_reportf(CTX_wm_reports(C), RPT_ERROR,
"Library path '%s' does not exist, correct this before saving", expanded);
@@ -326,7 +340,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
/* restore bone name */
BLI_strncpy(newname, ebone->name, sizeof(ebone->name));
BLI_strncpy(ebone->name, oldname, sizeof(ebone->name));
- ED_armature_bone_rename(obedit->data, oldname, newname);
+ ED_armature_bone_rename(bmain, obedit->data, oldname, newname);
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
}
break;
@@ -339,14 +353,14 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
bArmature *arm = (bArmature *)tselem->id;
Bone *bone = te->directdata;
char newname[sizeof(bone->name)];
-
+
/* always make current object active */
tree_element_active(C, scene, view_layer, soops, te, OL_SETSEL_NORMAL, true);
-
+
/* restore bone name */
BLI_strncpy(newname, bone->name, sizeof(bone->name));
BLI_strncpy(bone->name, oldname, sizeof(bone->name));
- ED_armature_bone_rename(arm, oldname, newname);
+ ED_armature_bone_rename(bmain, arm, oldname, newname);
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
break;
}
@@ -357,16 +371,16 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
Object *ob = (Object *)tselem->id;
bPoseChannel *pchan = te->directdata;
char newname[sizeof(pchan->name)];
-
+
/* always make current pose-bone active */
tree_element_active(C, scene, view_layer, soops, te, OL_SETSEL_NORMAL, true);
BLI_assert(ob->type == OB_ARMATURE);
-
+
/* restore bone name */
BLI_strncpy(newname, pchan->name, sizeof(pchan->name));
BLI_strncpy(pchan->name, oldname, sizeof(pchan->name));
- ED_armature_bone_rename(ob->data, oldname, newname);
+ ED_armature_bone_rename(bmain, ob->data, oldname, newname);
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
break;
}
@@ -374,7 +388,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
{
Object *ob = (Object *)tselem->id; // id = object
bActionGroup *grp = te->directdata;
-
+
BLI_uniquename(&ob->pose->agroups, grp, CTX_DATA_(BLT_I18NCONTEXT_ID_ACTION, "Group"), '.',
offsetof(bActionGroup, name), sizeof(grp->name));
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
@@ -384,7 +398,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
{
bGPdata *gpd = (bGPdata *)tselem->id; // id = GP Datablock
bGPDlayer *gpl = te->directdata;
-
+
// XXX: name needs translation stuff
BLI_uniquename(&gpd->layers, gpl, "GP Layer", '.',
offsetof(bGPDlayer, info), sizeof(gpl->info));
@@ -419,7 +433,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
}
static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, ListBase *lb)
-{
+{
uiBut *bt;
TreeElement *te;
TreeStoreElem *tselem;
@@ -444,19 +458,19 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
ViewLayer *view_layer = te->directdata;
UI_block_emboss_set(block, UI_EMBOSS_NONE);
-
+
bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, VIEW_LAYER_RENDER, 0, ICON_RESTRICT_RENDER_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X,
UI_UNIT_Y, &view_layer->flag, 0, 0, 0, 0, TIP_("Use view layer for rendering"));
UI_but_func_set(bt, restrictbutton_r_lay_cb, tselem->id, NULL);
UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
-
+
UI_block_emboss_set(block, UI_EMBOSS);
}
else if (tselem->type == TSE_MODIFIER) {
ModifierData *md = (ModifierData *)te->directdata;
ob = (Object *)tselem->id;
-
+
UI_block_emboss_set(block, UI_EMBOSS_NONE);
bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE_N, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X,
@@ -464,7 +478,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
TIP_("Restrict/Allow visibility in the 3D View"));
UI_but_func_set(bt, restrictbutton_modifier_cb, scene, ob);
UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
-
+
bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE_N, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X,
UI_UNIT_Y, &(md->mode), 0, 0, 0, 0, TIP_("Restrict/Allow renderability"));
@@ -477,7 +491,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
bPoseChannel *pchan = (bPoseChannel *)te->directdata;
Bone *bone = pchan->bone;
ob = (Object *)tselem->id;
-
+
UI_block_emboss_set(block, UI_EMBOSS_NONE);
bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X,
@@ -485,7 +499,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
TIP_("Restrict/Allow visibility in the 3D View"));
UI_but_func_set(bt, restrictbutton_bone_visibility_cb, ob->data, bone);
UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
-
+
bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X,
UI_UNIT_Y, &(bone->flag), 0, 0, 0, 0,
@@ -497,7 +511,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
}
else if (tselem->type == TSE_EBONE) {
EditBone *ebone = (EditBone *)te->directdata;
-
+
UI_block_emboss_set(block, UI_EMBOSS_NONE);
bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X,
@@ -505,7 +519,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
TIP_("Restrict/Allow visibility in the 3D View"));
UI_but_func_set(bt, restrictbutton_ebone_visibility_cb, NULL, ebone);
UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
-
+
bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X,
UI_UNIT_Y, &(ebone->flag), 0, 0, 0, 0,
@@ -517,25 +531,25 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
}
else if (tselem->type == TSE_GP_LAYER) {
bGPDlayer *gpl = (bGPDlayer *)te->directdata;
-
+
UI_block_emboss_set(block, UI_EMBOSS_NONE);
-
+
bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE, GP_LAYER_HIDE, 0, ICON_RESTRICT_VIEW_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X,
UI_UNIT_Y, &gpl->flag, 0, 0, 0, 0,
TIP_("Restrict/Allow visibility in the 3D View"));
UI_but_func_set(bt, restrictbutton_gp_layer_flag_cb, NULL, gpl);
UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
-
+
bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE, GP_LAYER_LOCKED, 0, ICON_UNLOCKED,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X,
UI_UNIT_Y, &gpl->flag, 0, 0, 0, 0,
TIP_("Restrict/Allow editing of strokes and keyframes in this layer"));
UI_but_func_set(bt, restrictbutton_gp_layer_flag_cb, NULL, gpl);
UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
-
+
/* TODO: visibility in renders */
-
+
UI_block_emboss_set(block, UI_EMBOSS);
}
else if (outliner_is_collection_tree_element(te)) {
@@ -569,7 +583,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
UI_block_emboss_set(block, UI_EMBOSS);
}
}
-
+
if (TSELEM_OPEN(tselem, soops)) outliner_draw_restrictbuts(block, scene, ar, soops, &te->subtree);
}
}
@@ -608,16 +622,16 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOops *soops
&id->flag, 0, 0, 0, 0, tip);
UI_but_func_set(bt, restrictbutton_id_user_toggle, id, NULL);
UI_but_flag_enable(bt, but_flag);
-
-
+
+
BLI_str_format_int_grouped(buf, id->us);
- bt = uiDefBut(block, UI_BTYPE_BUT, 1, buf,
- (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys,
+ bt = uiDefBut(block, UI_BTYPE_BUT, 1, buf,
+ (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys,
UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0,
TIP_("Number of users of this data-block"));
UI_but_flag_enable(bt, but_flag);
-
-
+
+
bt = uiDefButBitS(block, UI_BTYPE_TOGGLE, LIB_FAKEUSER, 1, (id->flag & LIB_FAKEUSER) ? "F" : " ",
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y,
&id->flag, 0, 0, 0, 0,
@@ -625,11 +639,11 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOops *soops
"even if nothing else uses it"));
UI_but_func_set(bt, restrictbutton_id_user_toggle, id, NULL);
UI_but_flag_enable(bt, but_flag);
-
+
UI_block_emboss_set(block, UI_EMBOSS);
}
}
-
+
if (TSELEM_OPEN(tselem, soops)) outliner_draw_userbuts(block, ar, soops, &te->subtree);
}
}
@@ -693,12 +707,12 @@ static void outliner_draw_rnabuts(uiBlock *block, ARegion *ar, SpaceOops *soops,
else if (tselem->type == TSE_RNA_ARRAY_ELEM) {
ptr = &te->rnaptr;
prop = te->directdata;
-
+
uiDefAutoButR(block, ptr, prop, te->index, "", ICON_NONE, sizex, te->ys, OL_RNA_COL_SIZEX,
UI_UNIT_Y - 1);
}
}
-
+
if (TSELEM_OPEN(tselem, soops)) outliner_draw_rnabuts(block, ar, soops, sizex, &te->subtree);
}
@@ -762,7 +776,7 @@ static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon)
uiBut *but = uiDefIconBut(arg->block, UI_BTYPE_LABEL, 0, icon, arg->xb, arg->yb, UI_UNIT_X, UI_UNIT_Y, NULL,
0.0, 0.0, 1.0, arg->alpha,
(arg->id && ID_IS_LINKED(arg->id)) ? arg->id->lib->name : "");
-
+
if (arg->id)
UI_but_drag_set_id(but, arg->id);
}
@@ -786,17 +800,17 @@ static void UNUSED_FUNCTION(tselem_draw_gp_icon_uibut)(struct DrawIconArg *arg,
RNA_pointer_create(id, &RNA_GPencilLayer, gpl, &ptr);
UI_block_align_begin(arg->block);
-
+
UI_block_emboss_set(arg->block, is_stroke_visible ? UI_EMBOSS : UI_EMBOSS_NONE);
uiDefButR(arg->block, UI_BTYPE_COLOR, 1, "", arg->xb, arg->yb, w, h,
&ptr, "color", -1,
0, 0, 0, 0, NULL);
-
+
UI_block_emboss_set(arg->block, is_fill_visible ? UI_EMBOSS : UI_EMBOSS_NONE);
uiDefButR(arg->block, UI_BTYPE_COLOR, 1, "", arg->xb + w, arg->yb, w, h,
&ptr, "fill_color", -1,
0, 0, 0, 0, NULL);
-
+
UI_block_emboss_set(arg->block, UI_EMBOSS_NONE);
UI_block_align_end(arg->block);
}
@@ -807,7 +821,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
{
struct DrawIconArg arg;
float aspect;
-
+
/* make function calls a bit compacter */
arg.block = block;
arg.id = tselem->id;
@@ -1231,12 +1245,13 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
}
static void outliner_draw_iconrow(
- bContext *C, uiBlock *block, Scene *scene, ViewLayer *view_layer, Object *obedit, SpaceOops *soops,
+ bContext *C, uiBlock *block, Scene *scene, ViewLayer *view_layer, SpaceOops *soops,
ListBase *lb, int level, int xmax, int *offsx, int ys, float alpha_fac)
{
TreeElement *te;
TreeStoreElem *tselem;
eOLDrawState active;
+ const Object *obact = OBACT(view_layer);
for (te = lb->first; te; te = te->next) {
/* exit drawing early */
@@ -1244,16 +1259,15 @@ static void outliner_draw_iconrow(
break;
tselem = TREESTORE(te);
-
+
/* object hierarchy always, further constrained on level */
if (level < 1 || (tselem->type == 0 && te->idcode == ID_OB)) {
-
/* active blocks get white circle */
if (tselem->type == 0) {
if (te->idcode == ID_OB) {
active = (OBACT(view_layer) == (Object *)tselem->id) ? OL_DRAWSEL_NORMAL : OL_DRAWSEL_NONE;
}
- else if (obedit && obedit->data == tselem->id) {
+ else if (is_object_data_in_editmode(tselem->id, obact)) {
active = OL_DRAWSEL_NORMAL;
}
else {
@@ -1281,24 +1295,24 @@ static void outliner_draw_iconrow(
color);
glEnable(GL_BLEND); /* roundbox disables */
}
-
+
tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f * alpha_fac);
te->xs = *offsx;
te->ys = ys;
te->xend = (short)*offsx + UI_UNIT_X;
te->flag |= TE_ICONROW; // for click
-
+
(*offsx) += UI_UNIT_X;
}
-
+
/* this tree element always has same amount of branches, so don't draw */
if (tselem->type != TSE_R_LAYER) {
outliner_draw_iconrow(
- C, block, scene, view_layer, obedit, soops,
+ C, block, scene, view_layer, soops,
&te->subtree, level + 1, xmax, offsx, ys, alpha_fac);
}
}
-
+
}
/* closed tree element */
@@ -1320,7 +1334,7 @@ static void outliner_set_coord_tree_element(TreeElement *te, int startx, int sta
static void outliner_draw_tree_element(
- bContext *C, uiBlock *block, const uiFontStyle *fstyle, Scene *scene, ViewLayer *view_layer, Object *obedit,
+ bContext *C, uiBlock *block, const uiFontStyle *fstyle, Scene *scene, ViewLayer *view_layer,
ARegion *ar, SpaceOops *soops, TreeElement *te, bool draw_grayed_out,
int startx, int *starty, TreeElement **te_edit, TreeElement **te_floating)
{
@@ -1346,11 +1360,12 @@ static void outliner_draw_tree_element(
/* icons can be ui buts, we don't want it to overlap with restrict */
if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0)
xmax -= OL_TOGW + UI_UNIT_X;
-
+
glEnable(GL_BLEND);
/* colors for active/selected data */
if (tselem->type == 0) {
+ const Object *obact = OBACT(view_layer);
if (te->idcode == ID_SCE) {
if (tselem->id == (ID *)scene) {
rgba_float_args_set(color, 1.0f, 1.0f, 1.0f, alpha);
@@ -1362,18 +1377,18 @@ static void outliner_draw_tree_element(
Base *base = (Base *)te->directdata;
const bool is_selected = (base != NULL) && ((base->flag & BASE_SELECTED) != 0);
- if (ob == OBACT(view_layer) || is_selected) {
+ if (ob == obact || is_selected) {
char col[4] = {0, 0, 0, 0};
-
+
/* outliner active ob: always white text, circle color now similar to view3d */
-
+
active = OL_DRAWSEL_ACTIVE;
- if (ob == OBACT(view_layer)) {
+ if (ob == obact) {
if (is_selected) {
UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col);
col[3] = alpha;
}
-
+
active = OL_DRAWSEL_NORMAL;
}
else if (is_selected) {
@@ -1382,9 +1397,8 @@ static void outliner_draw_tree_element(
}
rgba_float_args_set(color, (float)col[0] / 255, (float)col[1] / 255, (float)col[2] / 255, alpha);
}
-
}
- else if (obedit && obedit->data == tselem->id) {
+ else if (is_object_data_in_editmode(tselem->id, obact)) {
rgba_float_args_set(color, 1.0f, 1.0f, 1.0f, alpha);
active = OL_DRAWSEL_ACTIVE;
}
@@ -1399,7 +1413,7 @@ static void outliner_draw_tree_element(
active = tree_element_type_active(C, scene, view_layer, soops, te, tselem, OL_SETSEL_NONE, false);
rgba_float_args_set(color, 0.85f, 0.85f, 1.0f, alpha);
}
-
+
/* active circle */
if (active != OL_DRAWSEL_NONE) {
UI_draw_roundbox_corner_set(UI_CNR_ALL);
@@ -1411,10 +1425,10 @@ static void outliner_draw_tree_element(
(float)*starty + UI_UNIT_Y - 1.0f * ufac,
UI_UNIT_Y / 2.0f - 1.0f * ufac, color);
glEnable(GL_BLEND); /* roundbox disables it */
-
+
te->flag |= TE_ACTIVE; // for lookup in display hierarchies
}
-
+
if (tselem->type == TSE_VIEW_COLLECTION_BASE) {
/* Scene collection in view layer can't expand/collapse. */
}
@@ -1431,16 +1445,16 @@ static void outliner_draw_tree_element(
alpha_fac);
}
offsx += UI_UNIT_X;
-
+
/* datatype icon */
-
+
if (!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM, TSE_ID_BASE))) {
tselem_draw_icon(block, xmax, (float)startx + offsx, (float)*starty, tselem, te, alpha_fac);
offsx += UI_UNIT_X + 2 * ufac;
}
else
offsx += 2 * ufac;
-
+
if (ELEM(tselem->type, 0, TSE_LAYER_COLLECTION) && ID_IS_LINKED(tselem->id)) {
if (tselem->id->tag & LIB_TAG_MISSING) {
UI_icon_draw_alpha((float)startx + offsx + 2 * ufac, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_BROKEN,
@@ -1462,7 +1476,7 @@ static void outliner_draw_tree_element(
offsx += UI_UNIT_X + 2 * ufac;
}
glDisable(GL_BLEND);
-
+
/* name */
if ((tselem->flag & TSE_TEXTBUT) == 0) {
unsigned char text_col[4];
@@ -1481,9 +1495,9 @@ static void outliner_draw_tree_element(
UI_fontstyle_draw_simple(fstyle, startx + offsx, *starty + 5 * ufac, te->name, text_col);
}
-
+
offsx += (int)(UI_UNIT_X + UI_fontstyle_string_width(fstyle, te->name));
-
+
/* closed item, we draw the icons, not when it's a scene, or master-server list though */
if (!TSELEM_OPEN(tselem, soops)) {
if (te->subtree.first) {
@@ -1515,7 +1529,7 @@ static void outliner_draw_tree_element(
}
outliner_draw_iconrow(
- C, block, scene, view_layer, obedit, soops, &te->subtree, 0, xmax, &tempx,
+ C, block, scene, view_layer, soops, &te->subtree, 0, xmax, &tempx,
*starty, alpha_fac);
glDisable(GL_BLEND);
@@ -1536,7 +1550,7 @@ static void outliner_draw_tree_element(
* childs of a grayed out parent (pass on draw_grayed_out to childs) */
bool draw_childs_grayed_out = draw_grayed_out || (ten->drag_data != NULL);
outliner_draw_tree_element(
- C, block, fstyle, scene, view_layer, obedit,
+ C, block, fstyle, scene, view_layer,
ar, soops, ten, draw_childs_grayed_out,
startx + UI_UNIT_X, starty, te_edit, te_floating);
}
@@ -1545,7 +1559,7 @@ static void outliner_draw_tree_element(
for (TreeElement *ten = te->subtree.first; ten; ten = ten->next) {
outliner_set_coord_tree_element(ten, startx, *starty);
}
-
+
*starty -= UI_UNIT_Y;
}
}
@@ -1637,7 +1651,7 @@ static void outliner_draw_hierarchy_lines_recursive(unsigned pos, SpaceOops *soo
}
*starty -= UI_UNIT_Y;
-
+
if (TSELEM_OPEN(tselem, soops))
outliner_draw_hierarchy_lines_recursive(pos, soops, &te->subtree, startx + UI_UNIT_X,
col, draw_childs_grayed_out, starty);
@@ -1681,7 +1695,7 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase *
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
-
+
/* selection status */
if (TSELEM_OPEN(tselem, soops))
if (tselem->type == TSE_RNA_STRUCT) {
@@ -1777,7 +1791,7 @@ static void outliner_draw_highlights(ARegion *ar, SpaceOops *soops, int startx,
}
static void outliner_draw_tree(
- bContext *C, uiBlock *block, Scene *scene, ViewLayer *view_layer, Object *obedit,
+ bContext *C, uiBlock *block, Scene *scene, ViewLayer *view_layer,
ARegion *ar, SpaceOops *soops, const bool has_restrict_icons,
TreeElement **te_edit)
{
@@ -1809,7 +1823,7 @@ static void outliner_draw_tree(
}
// gray hierarchy lines
-
+
starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y / 2 - OL_Y_OFFSET;
startx = UI_UNIT_X / 2 - 1.0f;
outliner_draw_hierarchy_lines(soops, &soops->tree, startx, &starty);
@@ -1819,7 +1833,7 @@ static void outliner_draw_tree(
startx = 0;
for (TreeElement *te = soops->tree.first; te; te = te->next) {
outliner_draw_tree_element(
- C, block, fstyle, scene, view_layer, obedit,
+ C, block, fstyle, scene, view_layer,
ar, soops, te, te->drag_data != NULL,
startx, &starty, te_edit, &te_floating);
}
@@ -1837,7 +1851,7 @@ static void outliner_draw_tree(
static void outliner_back(ARegion *ar)
{
int ystart;
-
+
ystart = (int)ar->v2d.tot.ymax;
ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET;
@@ -1896,10 +1910,9 @@ static void outliner_draw_restrictcols(ARegion *ar)
void draw_outliner(const bContext *C)
{
- Main *mainvar = CTX_data_main(C);
+ Main *mainvar = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
ARegion *ar = CTX_wm_region(C);
View2D *v2d = &ar->v2d;
SpaceOops *soops = CTX_wm_space_outliner(C);
@@ -1909,7 +1922,7 @@ void draw_outliner(const bContext *C)
bool has_restrict_icons;
outliner_build_tree(mainvar, scene, view_layer, soops, ar); // always
-
+
/* get extents of data */
outliner_height(soops, &soops->tree, &sizey);
@@ -1921,11 +1934,11 @@ void draw_outliner(const bContext *C)
*
* (*) XXX max width for now is a fixed factor of (UI_UNIT_X * (max_indention + 100))
*/
-
+
/* get actual width of column 1 */
outliner_rna_width(soops, &soops->tree, &sizex_rna, 0);
sizex_rna = max_ii(OL_RNA_COLX, sizex_rna + OL_RNA_COL_SPACEX);
-
+
/* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */
sizex = sizex_rna + OL_RNA_COL_SIZEX + 50;
has_restrict_icons = false;
@@ -1935,7 +1948,7 @@ void draw_outliner(const bContext *C)
//outliner_width(soops, &soops->tree, &sizex);
// XXX should use outliner_width instead when te->xend will be set correctly...
outliner_rna_width(soops, &soops->tree, &sizex, 0);
-
+
/* constant offset for restriction columns */
// XXX this isn't that great yet...
if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) {
@@ -1944,7 +1957,7 @@ void draw_outliner(const bContext *C)
has_restrict_icons = !(soops->flag & SO_HIDE_RESTRICTCOLS);
}
-
+
/* adds vertical offset */
sizey += OL_Y_OFFSET;
@@ -1960,7 +1973,7 @@ void draw_outliner(const bContext *C)
outliner_back(ar);
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
outliner_draw_tree(
- (bContext *)C, block, scene, view_layer, obedit,
+ (bContext *)C, block, scene, view_layer,
ar, soops, has_restrict_icons, &te_edit);
if (soops->outlinevis == SO_DATA_API) {
@@ -1986,4 +1999,4 @@ void draw_outliner(const bContext *C)
UI_block_end(C, block);
UI_block_draw(C, block);
-}
+}
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 9bd0c622d66..2a694e2e2e3 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -98,19 +98,19 @@ static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *te
{
TreeElement *te;
TreeStoreElem *tselem;
-
+
for (te = lb->first; te; te = te->next) {
/* check if this tree-element was the one we're seeking */
if (te == teFind) {
*found = 1;
return;
}
-
+
/* try to see if sub-tree contains it then */
outliner_open_reveal(soops, &te->subtree, teFind, found);
if (*found) {
tselem = TREESTORE(te);
- if (tselem->flag & TSE_CLOSED)
+ if (tselem->flag & TSE_CLOSED)
tselem->flag &= ~TSE_CLOSED;
return;
}
@@ -193,10 +193,10 @@ void OUTLINER_OT_highlight_update(wmOperatorType *ot)
static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, const bool all, const float mval[2])
{
-
+
if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) {
TreeStoreElem *tselem = TREESTORE(te);
-
+
/* all below close/open? */
if (all) {
tselem->flag &= ~TSE_CLOSED;
@@ -206,16 +206,16 @@ static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement
if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED;
else tselem->flag |= TSE_CLOSED;
}
-
+
return 1;
}
-
+
for (te = te->subtree.first; te; te = te->next) {
- if (do_outliner_item_openclose(C, soops, te, all, mval))
+ if (do_outliner_item_openclose(C, soops, te, all, mval))
return 1;
}
return 0;
-
+
}
/* event can enterkey, then it opens/closes */
@@ -226,16 +226,16 @@ static int outliner_item_openclose(bContext *C, wmOperator *op, const wmEvent *e
TreeElement *te;
float fmval[2];
const bool all = RNA_boolean_get(op->ptr, "all");
-
+
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
-
+
for (te = soops->tree.first; te; te = te->next) {
- if (do_outliner_item_openclose(C, soops, te, all, fmval))
+ if (do_outliner_item_openclose(C, soops, te, all, fmval))
break;
}
ED_region_tag_redraw(ar);
-
+
return OPERATOR_FINISHED;
}
@@ -244,11 +244,11 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot)
ot->name = "Open/Close Item";
ot->idname = "OUTLINER_OT_item_openclose";
ot->description = "Toggle whether item under cursor is enabled or closed";
-
+
ot->invoke = outliner_item_openclose;
-
+
ot->poll = ED_operator_outliner_active;
-
+
RNA_def_boolean(ot->srna, "all", 1, "All", "Close or open all items");
}
@@ -311,7 +311,7 @@ static int do_outliner_item_rename(ReportList *reports, ARegion *ar, TreeElement
{
if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) {
TreeStoreElem *tselem = TREESTORE(te);
-
+
/* click on name */
if (mval[0] > te->xs + UI_UNIT_X * 2 && mval[0] < te->xend) {
do_item_rename(ar, te, tselem, reports);
@@ -319,7 +319,7 @@ static int do_outliner_item_rename(ReportList *reports, ARegion *ar, TreeElement
}
return 0;
}
-
+
for (te = te->subtree.first; te; te = te->next) {
if (do_outliner_item_rename(reports, ar, te, mval)) return 1;
}
@@ -333,16 +333,16 @@ static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent *even
TreeElement *te;
float fmval[2];
bool changed = false;
-
+
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
-
+
for (te = soops->tree.first; te; te = te->next) {
if (do_outliner_item_rename(op->reports, ar, te, fmval)) {
changed = true;
break;
}
}
-
+
return changed ? OPERATOR_FINISHED : OPERATOR_PASS_THROUGH;
}
@@ -352,9 +352,9 @@ void OUTLINER_OT_item_rename(wmOperatorType *ot)
ot->name = "Rename Item";
ot->idname = "OUTLINER_OT_item_rename";
ot->description = "Rename item under cursor";
-
+
ot->invoke = outliner_item_rename;
-
+
ot->poll = ED_operator_outliner_active;
}
@@ -775,9 +775,9 @@ static int outliner_count_levels(ListBase *lb, const int curlevel)
{
TreeElement *te;
int level = curlevel, lev;
-
+
for (te = lb->first; te; te = te->next) {
-
+
lev = outliner_count_levels(&te->subtree, curlevel + 1);
if (lev > level) level = lev;
}
@@ -789,11 +789,11 @@ int outliner_has_one_flag(ListBase *lb, short flag, const int curlevel)
TreeElement *te;
TreeStoreElem *tselem;
int level;
-
+
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
if (tselem->flag & flag) return curlevel;
-
+
level = outliner_has_one_flag(&te->subtree, flag, curlevel + 1);
if (level) return level;
}
@@ -850,7 +850,7 @@ int common_restrict_check(bContext *C, Object *ob)
ob->restrictflag &= ~OB_RESTRICT_SELECT;
return 0;
}
-
+
return 1;
}
@@ -863,14 +863,14 @@ static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceOops *soops = CTX_wm_space_outliner(C);
ARegion *ar = CTX_wm_region(C);
-
+
if (outliner_has_one_flag(&soops->tree, TSE_CLOSED, 1))
outliner_set_flag(&soops->tree, TSE_CLOSED, 0);
- else
+ else
outliner_set_flag(&soops->tree, TSE_CLOSED, 1);
-
+
ED_region_tag_redraw(ar);
-
+
return OPERATOR_FINISHED;
}
@@ -880,11 +880,11 @@ void OUTLINER_OT_expanded_toggle(wmOperatorType *ot)
ot->name = "Expand/Collapse All";
ot->idname = "OUTLINER_OT_expanded_toggle";
ot->description = "Expand/Collapse all items";
-
+
/* callbacks */
ot->exec = outliner_toggle_expanded_exec;
ot->poll = ED_operator_outliner_active;
-
+
/* no undo or registry, UI option */
}
@@ -895,15 +895,15 @@ static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op))
SpaceOops *soops = CTX_wm_space_outliner(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
-
+
if (outliner_has_one_flag(&soops->tree, TSE_SELECTED, 1))
outliner_set_flag(&soops->tree, TSE_SELECTED, 0);
- else
+ else
outliner_set_flag(&soops->tree, TSE_SELECTED, 1);
-
+
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
ED_region_tag_redraw_no_rebuild(ar);
-
+
return OPERATOR_FINISHED;
}
@@ -913,11 +913,11 @@ void OUTLINER_OT_selected_toggle(wmOperatorType *ot)
ot->name = "Toggle Selected";
ot->idname = "OUTLINER_OT_selected_toggle";
ot->description = "Toggle the Outliner selection of items";
-
+
/* callbacks */
ot->exec = outliner_toggle_selected_exec;
ot->poll = ED_operator_outliner_active;
-
+
/* no undo or registry, UI option */
}
@@ -976,7 +976,7 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
ViewLayer *view_layer = CTX_data_view_layer(C);
ARegion *ar = CTX_wm_region(C);
View2D *v2d = &ar->v2d;
-
+
TreeElement *te;
int xdelta, ytop;
@@ -1015,18 +1015,18 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
/* make te->ys center of view */
ytop = te->ys + BLI_rcti_size_y(&v2d->mask) / 2;
if (ytop > 0) ytop = 0;
-
+
v2d->cur.ymax = (float)ytop;
v2d->cur.ymin = (float)(ytop - BLI_rcti_size_y(&v2d->mask));
-
+
/* make te->xs ==> te->xend center of view */
xdelta = (int)(te->xs - v2d->cur.xmin);
v2d->cur.xmin += xdelta;
v2d->cur.xmax += xdelta;
}
-
+
ED_region_tag_redraw_no_rebuild(ar);
-
+
return OPERATOR_FINISHED;
}
@@ -1036,7 +1036,7 @@ void OUTLINER_OT_show_active(wmOperatorType *ot)
ot->name = "Show Active";
ot->idname = "OUTLINER_OT_show_active";
ot->description = "Open up the tree and adjust the view so that the active Object is shown centered";
-
+
/* callbacks */
ot->exec = outliner_show_active_exec;
ot->poll = ED_operator_outliner_active;
@@ -1049,16 +1049,16 @@ static int outliner_scroll_page_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
int dy = BLI_rcti_size_y(&ar->v2d.mask);
int up = 0;
-
+
if (RNA_boolean_get(op->ptr, "up"))
up = 1;
if (up == 0) dy = -dy;
ar->v2d.cur.ymin += dy;
ar->v2d.cur.ymax += dy;
-
+
ED_region_tag_redraw_no_rebuild(ar);
-
+
return OPERATOR_FINISHED;
}
@@ -1071,11 +1071,11 @@ void OUTLINER_OT_scroll_page(wmOperatorType *ot)
ot->name = "Scroll Page";
ot->idname = "OUTLINER_OT_scroll_page";
ot->description = "Scroll page up or down";
-
+
/* callbacks */
ot->exec = outliner_scroll_page_exec;
ot->poll = ED_operator_outliner_active;
-
+
/* properties */
prop = RNA_def_boolean(ot->srna, "up", 0, "Up", "Scroll up one page");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
@@ -1091,14 +1091,14 @@ static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *nam
TreeElement *prev, int *prevFound)
{
TreeElement *te, *tes;
-
+
for (te = lb->first; te; te = te->next) {
int found = outliner_filter_has_name(te, name, flags);
-
+
if (found) {
/* name is right, but is element the previous one? */
if (prev) {
- if ((te != prev) && (*prevFound))
+ if ((te != prev) && (*prevFound))
return te;
if (te == prev) {
*prevFound = 1;
@@ -1107,7 +1107,7 @@ static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *nam
else
return te;
}
-
+
tes = outliner_find_name(soops, &te->subtree, name, flags, prev, prevFound);
if (tes) return tes;
}
@@ -1116,7 +1116,7 @@ static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *nam
return NULL;
}
-static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int again, int flags)
+static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int again, int flags)
{
ReportList *reports = NULL; // CTX_wm_reports(C);
TreeElement *te = NULL;
@@ -1124,16 +1124,16 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
TreeStoreElem *tselem;
int ytop, xdelta, prevFound = 0;
char name[sizeof(soops->search_string)];
-
+
/* get last found tree-element based on stored search_tse */
last_find = outliner_find_tse(soops, &soops->search_tse);
-
+
/* determine which type of search to do */
if (again && last_find) {
/* no popup panel - previous + user wanted to search for next after previous */
BLI_strncpy(name, soops->search_string, sizeof(name));
flags = soops->search_flags;
-
+
/* try to find matching element */
te = outliner_find_name(soops, &soops->tree, name, flags, last_find, &prevFound);
if (te == NULL) {
@@ -1158,28 +1158,28 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
/* expand branches so that it will be visible, we need to get correct coordinates */
if (outliner_open_back(soops, te))
outliner_set_coordinates(ar, soops);
-
+
/* deselect all visible, and select found element */
outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0);
tselem->flag |= TSE_SELECTED;
-
+
/* make te->ys center of view */
ytop = (int)(te->ys + BLI_rctf_size_y(&ar->v2d.mask) / 2);
if (ytop > 0) ytop = 0;
ar->v2d.cur.ymax = (float)ytop;
ar->v2d.cur.ymin = (float)(ytop - BLI_rctf_size_y(&ar->v2d.mask));
-
+
/* make te->xs ==> te->xend center of view */
xdelta = (int)(te->xs - ar->v2d.cur.xmin);
ar->v2d.cur.xmin += xdelta;
ar->v2d.cur.xmax += xdelta;
-
+
/* store selection */
soops->search_tse = *tselem;
-
+
BLI_strncpy(soops->search_string, name, sizeof(soops->search_string));
soops->search_flags = flags;
-
+
/* redraw */
ED_region_tag_redraw_no_rebuild(ar);
}
@@ -1198,17 +1198,17 @@ static void outliner_openclose_level(ListBase *lb, int curlevel, int level, int
{
TreeElement *te;
TreeStoreElem *tselem;
-
+
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
-
+
if (open) {
if (curlevel <= level) tselem->flag &= ~TSE_CLOSED;
}
else {
if (curlevel >= level) tselem->flag |= TSE_CLOSED;
}
-
+
outliner_openclose_level(&te->subtree, curlevel + 1, level, open);
}
}
@@ -1219,7 +1219,7 @@ static int outliner_one_level_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
const bool add = RNA_boolean_get(op->ptr, "open");
int level;
-
+
level = outliner_has_one_flag(&soops->tree, TSE_CLOSED, 1);
if (add == 1) {
if (level) outliner_openclose_level(&soops->tree, 1, level, 1);
@@ -1228,9 +1228,9 @@ static int outliner_one_level_exec(bContext *C, wmOperator *op)
if (level == 0) level = outliner_count_levels(&soops->tree, 0);
if (level) outliner_openclose_level(&soops->tree, 1, level - 1, 0);
}
-
+
ED_region_tag_redraw(ar);
-
+
return OPERATOR_FINISHED;
}
@@ -1242,13 +1242,13 @@ void OUTLINER_OT_show_one_level(wmOperatorType *ot)
ot->name = "Show/Hide One Level";
ot->idname = "OUTLINER_OT_show_one_level";
ot->description = "Expand/collapse all entries by one level";
-
+
/* callbacks */
ot->exec = outliner_one_level_exec;
ot->poll = ED_operator_outliner_active;
-
+
/* no undo or registry, UI option */
-
+
/* properties */
prop = RNA_def_boolean(ot->srna, "open", 1, "Open", "Expand all entries one level deep");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
@@ -1261,7 +1261,7 @@ static int subtree_has_objects(ListBase *lb)
{
TreeElement *te;
TreeStoreElem *tselem;
-
+
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
if (tselem->type == 0 && te->idcode == ID_OB) return 1;
@@ -1279,7 +1279,7 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase
/* open all object elems, close others */
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
-
+
if (tselem->type == 0) {
if (te->idcode == ID_SCE) {
if (tselem->id != (ID *)scene) tselem->flag |= TSE_CLOSED;
@@ -1306,12 +1306,12 @@ static int outliner_show_hierarchy_exec(bContext *C, wmOperator *UNUSED(op))
SpaceOops *soops = CTX_wm_space_outliner(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
-
+
/* recursively open/close levels */
tree_element_show_hierarchy(scene, soops, &soops->tree);
-
+
ED_region_tag_redraw(ar);
-
+
return OPERATOR_FINISHED;
}
@@ -1321,11 +1321,11 @@ void OUTLINER_OT_show_hierarchy(wmOperatorType *ot)
ot->name = "Show Hierarchy";
ot->idname = "OUTLINER_OT_show_hierarchy";
ot->description = "Open all object entries and close all others";
-
+
/* callbacks */
ot->exec = outliner_show_hierarchy_exec;
ot->poll = ED_operator_outliner_active; // TODO: shouldn't be allowed in RNA views...
-
+
/* no undo or registry, UI option */
}
@@ -1345,9 +1345,9 @@ static int ed_operator_outliner_datablocks_active(bContext *C)
}
-/* Helper func to extract an RNA path from selected tree element
+/* Helper func to extract an RNA path from selected tree element
* NOTE: the caller must zero-out all values of the pointers that it passes here first, as
- * this function does not do that yet
+ * this function does not do that yet
*/
static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem,
ID **id, char **path, int *array_index, short *flag, short *UNUSED(groupmode))
@@ -1359,29 +1359,29 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem,
PointerRNA *ptr, *nextptr;
PropertyRNA *prop;
char *newpath = NULL;
-
+
/* optimize tricks:
* - Don't do anything if the selected item is a 'struct', but arrays are allowed
*/
if (tselem->type == TSE_RNA_STRUCT)
return;
-
+
/* Overview of Algorithm:
* 1. Go up the chain of parents until we find the 'root', taking note of the
* levels encountered in reverse-order (i.e. items are added to the start of the list
* for more convenient looping later)
* 2. Walk down the chain, adding from the first ID encountered
- * (which will become the 'ID' for the KeyingSet Path), and build a
+ * (which will become the 'ID' for the KeyingSet Path), and build a
* path as we step through the chain
*/
-
+
/* step 1: flatten out hierarchy of parents into a flat chain */
for (tem = te->parent; tem; tem = tem->parent) {
ld = MEM_callocN(sizeof(LinkData), "LinkData for tree_element_to_path()");
ld->data = tem;
BLI_addhead(&hierarchy, ld);
}
-
+
/* step 2: step down hierarchy building the path
* (NOTE: addhead in previous loop was needed so that we can loop like this) */
for (ld = hierarchy.first; ld; ld = ld->next) {
@@ -1390,10 +1390,10 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem,
tse = TREESTORE(tem);
ptr = &tem->rnaptr;
prop = tem->directdata;
-
+
/* check if we're looking for first ID, or appending to path */
if (*id) {
- /* just 'append' property to path
+ /* just 'append' property to path
* - to prevent memory leaks, we must write to newpath not path, then free old path + swap them
*/
if (tse->type == TSE_RNA_PROPERTY) {
@@ -1403,35 +1403,35 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem,
}
else if (RNA_property_type(prop) == PROP_COLLECTION) {
char buf[128], *name;
-
+
temnext = (TreeElement *)(ld->next->data);
/* tsenext = TREESTORE(temnext); */ /* UNUSED */
-
+
nextptr = &temnext->rnaptr;
name = RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL);
-
+
if (name) {
/* if possible, use name as a key in the path */
newpath = RNA_path_append(*path, NULL, prop, 0, name);
-
+
if (name != buf)
MEM_freeN(name);
}
else {
/* otherwise use index */
int index = 0;
-
+
for (temsub = tem->subtree.first; temsub; temsub = temsub->next, index++)
if (temsub == temnext)
break;
-
+
newpath = RNA_path_append(*path, NULL, prop, index, NULL);
}
-
+
ld = ld->next;
}
}
-
+
if (newpath) {
if (*path) MEM_freeN(*path);
*path = newpath;
@@ -1445,7 +1445,7 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem,
* since ptr->data is sometimes the owner of this ID? */
if (RNA_struct_is_ID(ptr->type)) {
*id = (ID *)ptr->data;
-
+
/* clear path */
if (*path) {
MEM_freeN(*path);
@@ -1461,7 +1461,7 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem,
/* add the active property to the path */
ptr = &te->rnaptr;
prop = te->directdata;
-
+
/* array checks */
if (tselem->type == TSE_RNA_ARRAY_ELEM) {
/* item is part of an array, so must set the array_index */
@@ -1471,7 +1471,7 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem,
/* entire array was selected, so keyframe all */
*flag |= KSP_FLAG_WHOLE_ARRAY;
}
-
+
/* path */
newpath = RNA_path_append(*path, NULL, prop, 0, NULL);
if (*path) MEM_freeN(*path);
@@ -1493,17 +1493,17 @@ enum {
DRIVERS_EDITMODE_REMOVE,
} /*eDrivers_EditModes*/;
-/* Utilities ---------------------------------- */
+/* Utilities ---------------------------------- */
/* Recursively iterate over tree, finding and working on selected items */
static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportList *reports, short mode)
{
TreeElement *te;
TreeStoreElem *tselem;
-
+
for (te = tree->first; te; te = te->next) {
tselem = TREESTORE(te);
-
+
/* if item is selected, perform operation */
if (tselem->flag & TSE_SELECTED) {
ID *id = NULL;
@@ -1511,7 +1511,7 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL
int array_index = 0;
short flag = 0;
short groupmode = KSP_GROUP_KSNAME;
-
+
/* check if RNA-property described by this selected element is an animatable prop */
if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) &&
RNA_property_animateable(&te->rnaptr, te->directdata))
@@ -1520,12 +1520,12 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL
tree_element_to_path(te, tselem,
&id, &path, &array_index, &flag, &groupmode);
}
-
+
/* only if ID and path were set, should we perform any actions */
if (id && path) {
short dflags = CREATEDRIVER_WITH_DEFAULT_DVAR;
int arraylen = 1;
-
+
/* array checks */
if (flag & KSP_FLAG_WHOLE_ARRAY) {
/* entire array was selected, so add drivers for all */
@@ -1533,11 +1533,11 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL
}
else
arraylen = array_index;
-
+
/* we should do at least one step */
if (arraylen == array_index)
arraylen++;
-
+
/* for each array element we should affect, add driver */
for (; array_index < arraylen; array_index++) {
/* action depends on mode */
@@ -1556,14 +1556,14 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL
}
}
}
-
+
/* free path, since it had to be generated */
MEM_freeN(path);
}
-
-
+
+
}
-
+
/* go over sub-tree */
if (TSELEM_OPEN(tselem, soops))
do_outliner_drivers_editop(soops, &te->subtree, reports, mode);
@@ -1575,17 +1575,17 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL
static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op)
{
SpaceOops *soutliner = CTX_wm_space_outliner(C);
-
+
/* check for invalid states */
if (soutliner == NULL)
return OPERATOR_CANCELLED;
-
+
/* recursively go into tree, adding selected items */
do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_ADD);
-
+
/* send notifiers */
WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX
-
+
return OPERATOR_FINISHED;
}
@@ -1595,11 +1595,11 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot)
ot->idname = "OUTLINER_OT_drivers_add_selected";
ot->name = "Add Drivers for Selected";
ot->description = "Add drivers to selected items";
-
+
/* api callbacks */
ot->exec = outliner_drivers_addsel_exec;
ot->poll = ed_operator_outliner_datablocks_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1610,17 +1610,17 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot)
static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op)
{
SpaceOops *soutliner = CTX_wm_space_outliner(C);
-
+
/* check for invalid states */
if (soutliner == NULL)
return OPERATOR_CANCELLED;
-
+
/* recursively go into tree, adding selected items */
do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_REMOVE);
-
+
/* send notifiers */
WM_event_add_notifier(C, ND_KEYS, NULL); // XXX
-
+
return OPERATOR_FINISHED;
}
@@ -1630,11 +1630,11 @@ void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot)
ot->idname = "OUTLINER_OT_drivers_delete_selected";
ot->name = "Delete Drivers for Selected";
ot->description = "Delete drivers assigned to selected items";
-
+
/* api callbacks */
ot->exec = outliner_drivers_deletesel_exec;
ot->poll = ed_operator_outliner_datablocks_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1650,29 +1650,29 @@ enum {
KEYINGSET_EDITMODE_REMOVE,
} /*eKeyingSet_EditModes*/;
-/* Utilities ---------------------------------- */
-
+/* Utilities ---------------------------------- */
+
/* find the 'active' KeyingSet, and add if not found (if adding is allowed) */
// TODO: should this be an API func?
static KeyingSet *verify_active_keyingset(Scene *scene, short add)
{
KeyingSet *ks = NULL;
-
+
/* sanity check */
if (scene == NULL)
return NULL;
-
+
/* try to find one from scene */
if (scene->active_keyingset > 0)
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
-
+
/* add if none found */
// XXX the default settings have yet to evolve
if ((add) && (ks == NULL)) {
ks = BKE_keyingset_add(&scene->keyingsets, NULL, NULL, KEYINGSET_ABSOLUTE, 0);
scene->active_keyingset = BLI_listbase_count(&scene->keyingsets);
}
-
+
return ks;
}
@@ -1681,10 +1681,10 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa
{
TreeElement *te;
TreeStoreElem *tselem;
-
+
for (te = tree->first; te; te = te->next) {
tselem = TREESTORE(te);
-
+
/* if item is selected, perform operation */
if (tselem->flag & TSE_SELECTED) {
ID *id = NULL;
@@ -1692,7 +1692,7 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa
int array_index = 0;
short flag = 0;
short groupmode = KSP_GROUP_KSNAME;
-
+
/* check if RNA-property described by this selected element is an animatable prop */
if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) &&
RNA_property_animateable(&te->rnaptr, te->directdata))
@@ -1701,7 +1701,7 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa
tree_element_to_path(te, tselem,
&id, &path, &array_index, &flag, &groupmode);
}
-
+
/* only if ID and path were set, should we perform any actions */
if (id && path) {
/* action depends on mode */
@@ -1719,7 +1719,7 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa
{
/* find the relevant path, then remove it from the KeyingSet */
KS_Path *ksp = BKE_keyingset_find_path(ks, id, NULL, path, array_index, groupmode);
-
+
if (ksp) {
/* free path's data */
BKE_keyingset_free_path(ks, ksp);
@@ -1729,12 +1729,12 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa
break;
}
}
-
+
/* free path, since it had to be generated */
MEM_freeN(path);
}
}
-
+
/* go over sub-tree */
if (TSELEM_OPEN(tselem, soops))
do_outliner_keyingset_editop(soops, ks, &te->subtree, mode);
@@ -1748,7 +1748,7 @@ static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op)
SpaceOops *soutliner = CTX_wm_space_outliner(C);
Scene *scene = CTX_data_scene(C);
KeyingSet *ks = verify_active_keyingset(scene, 1);
-
+
/* check for invalid states */
if (ks == NULL) {
BKE_report(op->reports, RPT_ERROR, "Operation requires an active keying set");
@@ -1756,13 +1756,13 @@ static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op)
}
if (soutliner == NULL)
return OPERATOR_CANCELLED;
-
+
/* recursively go into tree, adding selected items */
do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_ADD);
-
+
/* send notifiers */
WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1772,11 +1772,11 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot)
ot->idname = "OUTLINER_OT_keyingset_add_selected";
ot->name = "Keying Set Add Selected";
ot->description = "Add selected items (blue-gray rows) to active Keying Set";
-
+
/* api callbacks */
ot->exec = outliner_keyingset_additems_exec;
ot->poll = ed_operator_outliner_datablocks_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1789,17 +1789,17 @@ static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(o
SpaceOops *soutliner = CTX_wm_space_outliner(C);
Scene *scene = CTX_data_scene(C);
KeyingSet *ks = verify_active_keyingset(scene, 1);
-
+
/* check for invalid states */
if (soutliner == NULL)
return OPERATOR_CANCELLED;
-
+
/* recursively go into tree, adding selected items */
do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_REMOVE);
-
+
/* send notifiers */
WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1809,11 +1809,11 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot)
ot->idname = "OUTLINER_OT_keyingset_remove_selected";
ot->name = "Keying Set Remove Selected";
ot->description = "Remove selected items (blue-gray rows) from active Keying Set";
-
+
/* api callbacks */
ot->exec = outliner_keyingset_removeitems_exec;
ot->poll = ed_operator_outliner_datablocks_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1849,7 +1849,7 @@ static int outliner_orphans_purge_exec(bContext *C, wmOperator *UNUSED(op))
* are retained...
*/
WM_operator_name_call(C, "WM_OT_save_mainfile", WM_OP_EXEC_DEFAULT, NULL);
-
+
/* Now, reload the file to get rid of the orphans... */
WM_operator_name_call(C, "WM_OT_revert_mainfile", WM_OP_EXEC_DEFAULT, NULL);
return OPERATOR_FINISHED;
@@ -1862,12 +1862,12 @@ void OUTLINER_OT_orphans_purge(wmOperatorType *ot)
ot->name = "Purge All";
ot->description = "Clear all orphaned data-blocks without any users from the file "
"(cannot be undone, saves to current .blend file)";
-
+
/* callbacks */
ot->invoke = outliner_orphans_purge_invoke;
ot->exec = outliner_orphans_purge_exec;
ot->poll = ed_operator_outliner_id_orphans_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1887,9 +1887,9 @@ static int parent_drop_exec(bContext *C, wmOperator *op)
partype = RNA_enum_get(op->ptr, "type");
RNA_string_get(op->ptr, "parent", parname);
- par = (Object *)BKE_libblock_find_name(ID_OB, parname);
+ par = (Object *)BKE_libblock_find_name(bmain, ID_OB, parname);
RNA_string_get(op->ptr, "child", childname);
- ob = (Object *)BKE_libblock_find_name(ID_OB, childname);
+ ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, childname);
if (ID_IS_LINKED(ob)) {
BKE_report(op->reports, RPT_INFO, "Can't edit library linked object");
@@ -1928,10 +1928,10 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
RNA_string_set(op->ptr, "parent", te->name);
/* Identify parent and child */
RNA_string_get(op->ptr, "child", childname);
- ob = (Object *)BKE_libblock_find_name(ID_OB, childname);
+ ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, childname);
RNA_string_get(op->ptr, "parent", parname);
- par = (Object *)BKE_libblock_find_name(ID_OB, parname);
-
+ par = (Object *)BKE_libblock_find_name(bmain, ID_OB, parname);
+
if (ELEM(NULL, ob, par)) {
if (par == NULL) printf("par==NULL\n");
return OPERATOR_CANCELLED;
@@ -1943,7 +1943,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
BKE_report(op->reports, RPT_INFO, "Can't edit library linked object");
return OPERATOR_CANCELLED;
}
-
+
scene = (Scene *)outliner_search_back(soops, te, ID_SCE);
if (scene == NULL) {
@@ -1968,7 +1968,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Set Parent To"), ICON_NONE);
uiLayout *layout = UI_popup_menu_layout(pup);
PointerRNA ptr;
-
+
/* Cannot use uiItemEnumO()... have multiple properties to set. */
uiItemFullO_ptr(layout, ot, IFACE_("Object"), 0, NULL, WM_OP_EXEC_DEFAULT, 0, &ptr);
RNA_string_set(&ptr, "parent", parname);
@@ -2024,9 +2024,9 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
RNA_string_set(&ptr, "child", childname);
RNA_enum_set(&ptr, "type", PAR_LATTICE);
}
-
+
UI_popup_menu_end(C, pup);
-
+
return OPERATOR_INTERFACE;
}
}
@@ -2085,7 +2085,7 @@ static int parent_clear_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
char obname[MAX_ID_NAME];
RNA_string_get(op->ptr, "dragged_obj", obname);
- ob = (Object *)BKE_libblock_find_name(ID_OB, obname);
+ ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, obname);
/* search forwards to find the object */
outliner_find_id(soops, &soops->tree, (ID *)ob);
@@ -2136,10 +2136,10 @@ static int scene_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (te) {
RNA_string_set(op->ptr, "scene", te->name);
- scene = (Scene *)BKE_libblock_find_name(ID_SCE, te->name);
+ scene = (Scene *)BKE_libblock_find_name(bmain, ID_SCE, te->name);
RNA_string_get(op->ptr, "object", obname);
- ob = (Object *)BKE_libblock_find_name(ID_OB, obname);
+ ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, obname);
if (ELEM(NULL, ob, scene) || ID_IS_LINKED(scene)) {
return OPERATOR_CANCELLED;
@@ -2201,6 +2201,7 @@ static int material_drop_invoke(bContext *C, wmOperator *op, const wmEvent *even
{
Material *ma = NULL;
Object *ob = NULL;
+ Main *bmain = CTX_data_main(C);
SpaceOops *soops = CTX_wm_space_outliner(C);
ARegion *ar = CTX_wm_region(C);
TreeElement *te = NULL;
@@ -2214,16 +2215,16 @@ static int material_drop_invoke(bContext *C, wmOperator *op, const wmEvent *even
if (te) {
RNA_string_set(op->ptr, "object", te->name);
- ob = (Object *)BKE_libblock_find_name(ID_OB, te->name);
+ ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, te->name);
RNA_string_get(op->ptr, "material", mat_name);
- ma = (Material *)BKE_libblock_find_name(ID_MA, mat_name);
+ ma = (Material *)BKE_libblock_find_name(bmain, ID_MA, mat_name);
if (ELEM(NULL, ob, ma)) {
return OPERATOR_CANCELLED;
}
- assign_material(ob, ma, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF);
+ assign_material(bmain, ob, ma, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, ma);
@@ -2310,7 +2311,7 @@ static int collection_drop_invoke(bContext *C, wmOperator *op, const wmEvent *ev
Scene *scene = BKE_scene_find_from_collection(bmain, collection);
BLI_assert(scene);
RNA_string_get(op->ptr, "child", childname);
- Object *ob = (Object *)BKE_libblock_find_name(ID_OB, childname);
+ Object *ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, childname);
BKE_collection_object_add(bmain, collection, ob);
DEG_relations_tag_update(bmain);
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 7ca1bc9cc9b..8ac09648d60 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -115,7 +115,7 @@ typedef struct TreeElement {
#define TREESTORE_ID_TYPE(_id) \
(ELEM(GS((_id)->name), ID_SCE, ID_LI, ID_OB, ID_ME, ID_CU, ID_MB, ID_NT, ID_MA, ID_TE, ID_IM, ID_LT, ID_LA, ID_CA) || \
ELEM(GS((_id)->name), ID_KE, ID_WO, ID_SPK, ID_GR, ID_AR, ID_AC, ID_BR, ID_PA, ID_GD, ID_LS, ID_LP) || \
- ELEM(GS((_id)->name), ID_SCR, ID_WM, ID_TXT, ID_VF, ID_SO, ID_CF, ID_PAL, ID_WS)) /* Only in 'blendfile' mode ... :/ */
+ ELEM(GS((_id)->name), ID_SCR, ID_WM, ID_TXT, ID_VF, ID_SO, ID_CF, ID_PAL, ID_MC, ID_WS)) /* Only in 'blendfile' mode ... :/ */
/* TreeElement->flag */
enum {
@@ -143,7 +143,7 @@ typedef enum {
OL_SETSEL_EXTEND = 2, /* select the item and extend (also toggles selection) */
} eOLSetState;
-/* get TreeStoreElem associated with a TreeElement
+/* get TreeStoreElem associated with a TreeElement
* < a: (TreeElement) tree element to find stored element for
*/
#define TREESTORE(a) ((a)->store_elem)
@@ -170,13 +170,13 @@ typedef enum {
* Are we looking for something in the outliner?
* If so finding matches in child items makes it more useful
*
- * - We want to flag parents to act as being open to filter child matches
+ * - We want to flag parents to act as being open to filter child matches
* - and also flag matches so we can highlight them
* - Flags are stored in TreeStoreElem->flag
* - Flag options defined in DNA_outliner_types.h
* - SO_SEARCH_RECURSIVE defined in DNA_space_types.h
*
- * - NOT in datablocks view - searching all datablocks takes way too long
+ * - NOT in datablocks view - searching all datablocks takes way too long
* to be useful
* - not searching into RNA items helps but isn't the complete solution
*/
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index 9c1b9bf2630..ecfd12618e5 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -429,16 +429,16 @@ void outliner_operatortypes(void)
WM_operatortype_append(OUTLINER_OT_show_active);
WM_operatortype_append(OUTLINER_OT_show_hierarchy);
WM_operatortype_append(OUTLINER_OT_scroll_page);
-
+
WM_operatortype_append(OUTLINER_OT_selected_toggle);
WM_operatortype_append(OUTLINER_OT_expanded_toggle);
-
+
WM_operatortype_append(OUTLINER_OT_keyingset_add_selected);
WM_operatortype_append(OUTLINER_OT_keyingset_remove_selected);
-
+
WM_operatortype_append(OUTLINER_OT_drivers_add_selected);
WM_operatortype_append(OUTLINER_OT_drivers_delete_selected);
-
+
WM_operatortype_append(OUTLINER_OT_orphans_purge);
WM_operatortype_append(OUTLINER_OT_parent_drop);
@@ -516,47 +516,50 @@ void outliner_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "OUTLINER_OT_select_border", BKEY, KM_PRESS, 0, 0);
-
+
kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_item_openclose", RETKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "all", false);
kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_item_openclose", RETKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "all", true);
-
+
WM_keymap_add_item(keymap, "OUTLINER_OT_item_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "OUTLINER_OT_operation", RIGHTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "OUTLINER_OT_item_drag_drop", EVT_TWEAK_L, KM_ANY, 0, 0);
WM_keymap_add_item(keymap, "OUTLINER_OT_show_hierarchy", HOMEKEY, KM_PRESS, 0, 0);
-
+
WM_keymap_add_item(keymap, "OUTLINER_OT_show_active", PERIODKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "OUTLINER_OT_show_active", PADPERIOD, KM_PRESS, 0, 0);
-
+
kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_scroll_page", PAGEDOWNKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "up", false);
kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_scroll_page", PAGEUPKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "up", true);
-
+
WM_keymap_add_item(keymap, "OUTLINER_OT_show_one_level", PADPLUSKEY, KM_PRESS, 0, 0); /* open */
kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_show_one_level", PADMINUS, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "open", false); /* close */
-
+
WM_keymap_verify_item(keymap, "OUTLINER_OT_selected_toggle", AKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "OUTLINER_OT_expanded_toggle", AKEY, KM_PRESS, KM_SHIFT, 0);
-
+
/* keying sets - only for databrowse */
WM_keymap_verify_item(keymap, "OUTLINER_OT_keyingset_add_selected", KKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "OUTLINER_OT_keyingset_remove_selected", KKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete", IKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_verify_item(keymap, "OUTLINER_OT_drivers_add_selected", DKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "OUTLINER_OT_drivers_delete_selected", DKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_verify_item(keymap, "OUTLINER_OT_collection_new", CKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "OUTLINER_OT_collection_delete", XKEY, KM_PRESS, 0, 0);
+ WM_keymap_verify_item(keymap, "OBJECT_OT_move_to_collection", MKEY, KM_PRESS, 0, 0);
+ WM_keymap_verify_item(keymap, "OBJECT_OT_link_to_collection", MKEY, KM_PRESS, KM_SHIFT, 0);
+
outliner_item_drag_drop_modal_keymap(keyconf);
}
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 42fe70be527..36fd37e1134 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -47,6 +47,7 @@
#include "BKE_collection.h"
#include "BKE_context.h"
#include "BKE_layer.h"
+#include "BKE_main.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_sequencer.h"
@@ -72,6 +73,83 @@
#include "outliner_intern.h"
+static void do_outliner_activate_obdata(bContext *C, Scene *scene, ViewLayer *view_layer, Base *base)
+{
+ Main *bmain = CTX_data_main(C);
+ Object *obact = OBACT(view_layer);
+ bool use_all = false;
+
+ if (obact == NULL) {
+ ED_object_base_activate(C, base);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+ obact = base->object;
+ use_all = true;
+ }
+ else if (obact->data == base->object->data) {
+ use_all = true;
+ }
+
+ if (use_all) {
+ WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL);
+ }
+ else {
+ Object *ob = base->object;
+ if (ob->type == obact->type) {
+ bool ok;
+ if (BKE_object_is_in_editmode(ob)) {
+ ok = ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA | EM_WAITCURSOR);
+ }
+ else {
+ ok = ED_object_editmode_enter_ex(CTX_data_main(C), scene, ob, EM_WAITCURSOR | EM_NO_CONTEXT);
+ }
+ if (ok) {
+ ED_object_base_select(base, (ob->mode & OB_MODE_EDIT) ? BA_SELECT : BA_DESELECT);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+ }
+ }
+ }
+}
+
+static void do_outliner_activate_pose(bContext *C, ViewLayer *view_layer, Base *base)
+{
+ Object *obact = OBACT(view_layer);
+ bool use_all = false;
+
+ if (obact == NULL) {
+ ED_object_base_activate(C, base);
+ Scene *scene = CTX_data_scene(C);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+ obact = base->object;
+ use_all = true;
+ }
+ else if (obact->data == base->object->data) {
+ use_all = true;
+ }
+
+ if (use_all) {
+ WM_operator_name_call(C, "OBJECT_OT_posemode_toggle", WM_OP_INVOKE_REGION_WIN, NULL);
+ }
+ else {
+ Object *ob = base->object;
+ if (ob->type == obact->type) {
+ struct Main *bmain = CTX_data_main(C);
+ bool ok = false;
+ if (ob->mode & OB_MODE_POSE) {
+ ok = ED_object_posemode_exit_ex(bmain, ob);
+ }
+ else {
+ ok = ED_object_posemode_enter_ex(bmain, ob);
+ }
+ if (ok) {
+ ED_object_base_select(base, (ob->mode & OB_MODE_POSE) ? BA_SELECT : BA_DESELECT);
+
+ Scene *scene = CTX_data_scene(C);
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+ }
+ }
+ }
+}
/* ****************************************************** */
/* Outliner Element Selection/Activation on Click */
@@ -80,12 +158,12 @@ static eOLDrawState active_viewlayer(
bContext *C, Scene *UNUSED(scene), ViewLayer *UNUSED(sl), TreeElement *te, TreeStoreElem *tselem, const eOLSetState set)
{
Scene *sce;
-
+
/* paranoia check */
if (te->idcode != ID_SCE)
return OL_DRAWSEL_NONE;
sce = (Scene *)tselem->id;
-
+
WorkSpace *workspace = CTX_wm_workspace(C);
ViewLayer *view_layer = te->directdata;
@@ -149,7 +227,7 @@ static eOLDrawState tree_element_set_active_object(
Scene *sce;
Base *base;
Object *ob = NULL;
-
+
/* if id is not object, we search back */
if (te->idcode == ID_OB) {
ob = (Object *)tselem->id;
@@ -163,27 +241,52 @@ static eOLDrawState tree_element_set_active_object(
if (ob == NULL) {
return OL_DRAWSEL_NONE;
}
-
+
sce = (Scene *)outliner_search_back(soops, te, ID_SCE);
if (sce && scene != sce) {
WM_window_change_active_scene(CTX_data_main(C), C, CTX_wm_window(C), sce);
scene = sce;
}
-
+
/* find associated base in current scene */
base = BKE_view_layer_base_find(view_layer, ob);
+#ifdef USE_OBJECT_MODE_STRICT
+ if (base != NULL) {
+ Object *obact = OBACT(view_layer);
+ const eObjectMode object_mode = obact ? obact->mode : OB_MODE_OBJECT;
+ if (base && !BKE_object_is_mode_compat(base->object, object_mode)) {
+ if (object_mode == OB_MODE_OBJECT) {
+ struct Main *bmain = CTX_data_main(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ ED_object_mode_generic_exit(bmain, depsgraph, scene, base->object);
+ }
+ if (!BKE_object_is_mode_compat(base->object, object_mode)) {
+ base = NULL;
+ }
+ }
+ }
+#endif
+
if (base) {
if (set == OL_SETSEL_EXTEND) {
/* swap select */
if (base->flag & BASE_SELECTED)
ED_object_base_select(base, BA_DESELECT);
- else
+ else
ED_object_base_select(base, BA_SELECT);
}
else {
/* deleselect all */
- BKE_view_layer_base_deselect_all(view_layer);
+#ifdef USE_OBJECT_MODE_STRICT
+ /* Only in object mode so we can switch the active object,
+ * keeping all objects in the current 'mode' selected, useful for multi-pose/edit mode.
+ * This keeps the convention that all objects in the current mode are also selected. see T55246. */
+ if (ob->mode == OB_MODE_OBJECT)
+#endif
+ {
+ BKE_view_layer_base_deselect_all(view_layer);
+ }
ED_object_base_select(base, BA_SELECT);
}
@@ -196,10 +299,10 @@ static eOLDrawState tree_element_set_active_object(
ED_object_base_activate(C, base); /* adds notifier */
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
- }
- if (ob != OBEDIT_FROM_VIEW_LAYER(view_layer)) {
- ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR);
+ if (ob != OBEDIT_FROM_VIEW_LAYER(view_layer)) {
+ ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR);
+ }
}
return OL_DRAWSEL_NORMAL;
}
@@ -210,14 +313,14 @@ static eOLDrawState tree_element_active_material(
{
TreeElement *tes;
Object *ob;
-
+
/* we search for the object parent */
ob = (Object *)outliner_search_back(soops, te, ID_OB);
// note: ob->matbits can be NULL when a local object points to a library mesh.
if (ob == NULL || ob != OBACT(view_layer) || ob->matbits == NULL) {
return OL_DRAWSEL_NONE; /* just paranoia */
}
-
+
/* searching in ob mat array? */
tes = te->parent;
if (tes->idcode == ID_OB) {
@@ -262,21 +365,21 @@ static eOLDrawState tree_element_active_lamp(
TreeElement *te, const eOLSetState set)
{
Object *ob;
-
+
/* we search for the object parent */
ob = (Object *)outliner_search_back(soops, te, ID_OB);
if (ob == NULL || ob != OBACT(view_layer)) {
/* just paranoia */
return OL_DRAWSEL_NONE;
}
-
+
if (set != OL_SETSEL_NONE) {
// XXX extern_set_butspace(F5KEY, 0);
}
else {
return OL_DRAWSEL_NORMAL;
}
-
+
return OL_DRAWSEL_NONE;
}
@@ -300,21 +403,21 @@ static eOLDrawState tree_element_active_world(
TreeElement *tep;
TreeStoreElem *tselem = NULL;
Scene *sce = NULL;
-
+
tep = te->parent;
if (tep) {
tselem = TREESTORE(tep);
if (tselem->type == 0)
sce = (Scene *)tselem->id;
}
-
+
if (set != OL_SETSEL_NONE) {
/* make new scene active */
if (sce && scene != sce) {
WM_window_change_active_scene(CTX_data_main(C), C, CTX_wm_window(C), sce);
}
}
-
+
if (tep == NULL || tselem->id == (ID *)scene) {
if (set != OL_SETSEL_NONE) {
// XXX extern_set_butspace(F8KEY, 0);
@@ -330,7 +433,7 @@ static eOLDrawState tree_element_active_defgroup(
bContext *C, ViewLayer *view_layer, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set)
{
Object *ob;
-
+
/* id in tselem is object */
ob = (Object *)tselem->id;
if (set != OL_SETSEL_NONE) {
@@ -353,7 +456,7 @@ static eOLDrawState tree_element_active_posegroup(
bContext *C, Scene *UNUSED(scene), ViewLayer *view_layer, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set)
{
Object *ob = (Object *)tselem->id;
-
+
if (set != OL_SETSEL_NONE) {
if (ob->pose) {
ob->pose->active_group = te->index + 1;
@@ -376,10 +479,10 @@ static eOLDrawState tree_element_active_posechannel(
Object *ob = (Object *)tselem->id;
bArmature *arm = ob->data;
bPoseChannel *pchan = te->directdata;
-
+
if (set != OL_SETSEL_NONE) {
if (!(pchan->bone->flag & BONE_HIDDEN_P)) {
-
+
if (set != OL_SETSEL_EXTEND) {
bPoseChannel *pchannel;
/* single select forces all other bones to get unselected */
@@ -419,7 +522,7 @@ static eOLDrawState tree_element_active_bone(
{
bArmature *arm = (bArmature *)tselem->id;
Bone *bone = te->directdata;
-
+
if (set != OL_SETSEL_NONE) {
if (!(bone->flag & BONE_HIDDEN_P)) {
Object *ob = OBACT(view_layer);
@@ -432,7 +535,7 @@ static eOLDrawState tree_element_active_bone(
}
}
}
-
+
if (set == OL_SETSEL_EXTEND && (bone->flag & BONE_SELECTED)) {
bone->flag &= ~BONE_SELECTED;
}
@@ -446,13 +549,13 @@ static eOLDrawState tree_element_active_bone(
do_outliner_bone_select_recursive(arm, bone, (bone->flag & BONE_SELECTED) != 0);
}
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, ob);
}
}
else {
Object *ob = OBACT(view_layer);
-
+
if (ob && ob->data == arm) {
if (bone->flag & BONE_SELECTED) {
return OL_DRAWSEL_NORMAL;
@@ -528,12 +631,12 @@ static eOLDrawState tree_element_active_modifier(
{
if (set != OL_SETSEL_NONE) {
Object *ob = (Object *)tselem->id;
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
// XXX extern_set_butspace(F9KEY, 0);
}
-
+
return OL_DRAWSEL_NONE;
}
@@ -542,12 +645,12 @@ static eOLDrawState tree_element_active_psys(
{
if (set != OL_SETSEL_NONE) {
Object *ob = (Object *)tselem->id;
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob);
-
+
// XXX extern_set_butspace(F7KEY, 0);
}
-
+
return OL_DRAWSEL_NONE;
}
@@ -556,11 +659,11 @@ static int tree_element_active_constraint(
{
if (set != OL_SETSEL_NONE) {
Object *ob = (Object *)tselem->id;
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
// XXX extern_set_butspace(F7KEY, 0);
}
-
+
return OL_DRAWSEL_NONE;
}
@@ -584,16 +687,7 @@ static eOLDrawState tree_element_active_pose(
}
if (set != OL_SETSEL_NONE) {
- if (OBEDIT_FROM_VIEW_LAYER(view_layer)) {
- ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR);
- }
-
- if (ob->mode & OB_MODE_POSE) {
- ED_object_posemode_exit(C, ob);
- }
- else {
- ED_object_posemode_enter(C, ob);
- }
+ do_outliner_activate_pose(C, view_layer, base);
}
else {
if (ob->mode & OB_MODE_POSE) {
@@ -668,7 +762,7 @@ static eOLDrawState tree_element_active_keymap_item(
bContext *UNUSED(C), Scene *UNUSED(scene), ViewLayer *UNUSED(sl), TreeElement *te, TreeStoreElem *UNUSED(tselem), const eOLSetState set)
{
wmKeyMapItem *kmi = te->directdata;
-
+
if (set == OL_SETSEL_NONE) {
if (kmi->flag & KMI_INACTIVE) {
return OL_DRAWSEL_NONE;
@@ -817,10 +911,18 @@ static void do_outliner_item_activate_tree_element(
TreeElement *te, TreeStoreElem *tselem,
const bool extend, const bool recursive)
{
- /* always makes active object, except for some specific types.
- * Note about TSE_EBONE: In case of a same ID_AR datablock shared among several objects, we do not want
- * to switch out of edit mode (see T48328 for details). */
- if (!ELEM(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP, TSE_EBONE, TSE_LAYER_COLLECTION)) {
+ /* Always makes active object, except for some specific types. */
+ if (ELEM(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP, TSE_EBONE, TSE_LAYER_COLLECTION)) {
+ /* Note about TSE_EBONE: In case of a same ID_AR datablock shared among several objects, we do not want
+ * to switch out of edit mode (see T48328 for details). */
+ }
+ else if (tselem->id && OB_DATA_SUPPORT_EDITMODE(te->idcode)) {
+ /* Support edit-mode toggle, keeping the active object as is. */
+ }
+ else if (tselem->type == TSE_POSE_BASE) {
+ /* Support pose mode toggle, keeping the active object as is. */
+ }
+ else {
tree_element_set_active_object(
C, scene, view_layer, soops, te,
(extend && tselem->type == 0) ? OL_SETSEL_EXTEND : OL_SETSEL_NORMAL,
@@ -839,18 +941,22 @@ static void do_outliner_item_activate_tree_element(
if (extend) {
int sel = BA_SELECT;
- FOREACH_COLLECTION_BASE_RECURSIVE_BEGIN(gr, base)
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(gr, object)
{
- if (base->flag & BASE_SELECTED) {
+ Base *base = BKE_view_layer_base_find(view_layer, object);
+ if (base && (base->flag & BASE_SELECTED)) {
sel = BA_DESELECT;
break;
}
}
- FOREACH_COLLECTION_BASE_RECURSIVE_END
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(gr, object)
{
- ED_object_base_select(BKE_view_layer_base_find(view_layer, object), sel);
+ Base *base = BKE_view_layer_base_find(view_layer, object);
+ if (base) {
+ ED_object_base_select(base, sel);
+ }
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
@@ -869,11 +975,17 @@ static void do_outliner_item_activate_tree_element(
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
-
+
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
- else if (ELEM(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) {
- WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL);
+ else if (OB_DATA_SUPPORT_EDITMODE(te->idcode)) {
+ Object *ob = (Object *)outliner_search_back(soops, te, ID_OB);
+ if ((ob != NULL) && (ob->data == tselem->id)) {
+ Base *base = BKE_view_layer_base_find(view_layer, ob);
+ if ((base != NULL) && (base->flag & BASE_VISIBLED)) {
+ do_outliner_activate_obdata(C, scene, view_layer, base);
+ }
+ }
}
else { // rest of types
tree_element_active(C, scene, view_layer, soops, te, OL_SETSEL_NORMAL, false);
@@ -1015,11 +1127,11 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot)
ot->name = "Activate Item";
ot->idname = "OUTLINER_OT_item_activate";
ot->description = "Handle mouse clicks to activate/select items";
-
+
ot->invoke = outliner_item_activate_invoke;
-
+
ot->poll = ED_operator_outliner_active;
-
+
RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection for activation");
RNA_def_boolean(ot->srna, "recursive", false, "Recursive", "Select Objects and their children");
}
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 5ae6cec84ba..8a01e5a7f2f 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -101,7 +101,7 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb,
{
TreeElement *te;
TreeStoreElem *tselem;
-
+
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
if (tselem->flag & TSE_SELECTED) {
@@ -121,7 +121,7 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb,
case ID_OB:
*objectlevel = 1;
break;
-
+
case ID_ME: case ID_CU: case ID_MB: case ID_LT:
case ID_LA: case ID_AR: case ID_CA: case ID_SPK:
case ID_MA: case ID_TE: case ID_IP: case ID_IM:
@@ -158,7 +158,7 @@ static void unlink_material_cb(
{
Material **matar = NULL;
int a, totcol = 0;
-
+
if (GS(tsep->id->name) == ID_OB) {
Object *ob = (Object *)tsep->id;
totcol = ob->totcol;
@@ -199,7 +199,7 @@ static void unlink_texture_cb(
{
MTex **mtex = NULL;
int a;
-
+
if (GS(tsep->id->name) == ID_LS) {
FreestyleLineStyle *ls = (FreestyleLineStyle *)tsep->id;
mtex = ls->mtex;
@@ -252,7 +252,7 @@ static void unlink_object_cb(
{
Main *bmain = CTX_data_main(C);
Object *ob = (Object *)tselem->id;
-
+
if (tsep) {
if (GS(tsep->id->name) == ID_GR) {
Collection *parent = (Collection *)tsep->id;
@@ -273,7 +273,7 @@ static void unlink_world_cb(
{
Scene *parscene = (Scene *)tsep->id;
World *wo = (World *)tselem->id;
-
+
/* need to use parent scene not just scene, otherwise may end up getting wrong one */
id_us_min(&wo->id);
parscene->world = NULL;
@@ -286,7 +286,7 @@ static void outliner_do_libdata_operation(
{
TreeElement *te;
TreeStoreElem *tselem;
-
+
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
if (tselem->flag & TSE_SELECTED) {
@@ -496,7 +496,7 @@ static void id_fake_user_set_cb(
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
{
ID *id = tselem->id;
-
+
id_fake_user_set(id);
}
@@ -505,7 +505,7 @@ static void id_fake_user_clear_cb(
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
{
ID *id = tselem->id;
-
+
id_fake_user_clear(id);
}
@@ -523,15 +523,15 @@ static void singleuser_action_cb(
TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data))
{
ID *id = tselem->id;
-
+
if (id) {
IdAdtTemplate *iat = (IdAdtTemplate *)tsep->id;
PointerRNA ptr = {{NULL}};
PropertyRNA *prop;
-
+
RNA_pointer_create(&iat->id, &RNA_AnimData, iat->adt, &ptr);
prop = RNA_struct_find_property(&ptr, "action");
-
+
id_single_user(C, id, &ptr, prop);
}
}
@@ -541,16 +541,16 @@ static void singleuser_world_cb(
TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data))
{
ID *id = tselem->id;
-
+
/* need to use parent scene not just scene, otherwise may end up getting wrong one */
if (id) {
Scene *parscene = (Scene *)tsep->id;
PointerRNA ptr = {{NULL}};
PropertyRNA *prop;
-
+
RNA_id_pointer_create(&parscene->id, &ptr);
prop = RNA_struct_find_property(&ptr, "world");
-
+
id_single_user(C, id, &ptr, prop);
}
}
@@ -563,7 +563,7 @@ void outliner_do_object_operation_ex(
outliner_operation_cb operation_cb, bool select_recurse)
{
TreeElement *te;
-
+
for (te = lb->first; te; te = te->next) {
TreeStoreElem *tselem = TREESTORE(te);
bool select_handled = false;
@@ -617,7 +617,7 @@ static void cleardrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te),
TreeStoreElem *tselem, void *UNUSED(arg))
{
IdAdtTemplate *iat = (IdAdtTemplate *)tselem->id;
-
+
/* just free drivers - stored as a list of F-Curves */
free_fcurves(&iat->adt->drivers);
}
@@ -627,11 +627,11 @@ static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te
{
IdAdtTemplate *iat = (IdAdtTemplate *)tselem->id;
FCurve *fcu;
-
+
/* loop over drivers, performing refresh (i.e. check graph_buttons.c and rna_fcurve.c for details) */
for (fcu = iat->adt->drivers.first; fcu; fcu = fcu->next) {
fcu->flag &= ~FCURVE_DISABLED;
-
+
if (fcu->driver)
fcu->driver->flag &= ~DRIVER_FLAG_INVALID;
}
@@ -662,7 +662,7 @@ typedef enum eOutliner_PropModifierOps {
static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg))
{
bPoseChannel *pchan = (bPoseChannel *)te->directdata;
-
+
if (event == OL_DOP_SELECT)
pchan->bone->flag |= BONE_SELECTED;
else if (event == OL_DOP_DESELECT)
@@ -678,7 +678,7 @@ static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem),
static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg))
{
Bone *bone = (Bone *)te->directdata;
-
+
if (event == OL_DOP_SELECT)
bone->flag |= BONE_SELECTED;
else if (event == OL_DOP_DESELECT)
@@ -694,7 +694,7 @@ static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), v
static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg))
{
EditBone *ebone = (EditBone *)te->directdata;
-
+
if (event == OL_DOP_SELECT)
ebone->flag |= BONE_SELECTED;
else if (event == OL_DOP_DESELECT)
@@ -724,7 +724,7 @@ static void sequence_cb(int event, TreeElement *te, TreeStoreElem *tselem, void
static void gp_layer_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg))
{
bGPDlayer *gpl = (bGPDlayer *)te->directdata;
-
+
if (event == OL_DOP_SELECT)
gpl->flag |= GP_LAYER_SELECT;
else if (event == OL_DOP_DESELECT)
@@ -750,18 +750,19 @@ static void data_select_linked_cb(int event, TreeElement *te, TreeStoreElem *UNU
static void constraint_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *C_v)
{
bContext *C = C_v;
+ Main *bmain = CTX_data_main(C);
SpaceOops *soops = CTX_wm_space_outliner(C);
bConstraint *constraint = (bConstraint *)te->directdata;
Object *ob = (Object *)outliner_search_back(soops, te, ID_OB);
if (event == OL_CONSTRAINTOP_ENABLE) {
constraint->flag &= ~CONSTRAINT_OFF;
- ED_object_constraint_update(ob);
+ ED_object_constraint_update(bmain, ob);
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
}
else if (event == OL_CONSTRAINTOP_DISABLE) {
constraint->flag = CONSTRAINT_OFF;
- ED_object_constraint_update(ob);
+ ED_object_constraint_update(bmain, ob);
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
}
else if (event == OL_CONSTRAINTOP_DELETE) {
@@ -777,7 +778,7 @@ static void constraint_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tsel
if (BKE_constraint_remove_ex(lb, ob, constraint, true)) {
/* there's no active constraint now, so make sure this is the case */
BKE_constraints_active_set(&ob->constraints, NULL);
- ED_object_constraint_update(ob); /* needed to set the flags on posebones correctly */
+ ED_object_constraint_update(bmain, ob); /* needed to set the flags on posebones correctly */
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob);
te->store_elem->flag &= ~TSE_SELECTED;
}
@@ -815,7 +816,7 @@ static void outliner_do_data_operation(SpaceOops *soops, int type, int event, Li
{
TreeElement *te;
TreeStoreElem *tselem;
-
+
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
if (tselem->flag & TSE_SELECTED) {
@@ -931,11 +932,11 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
SpaceOops *soops = CTX_wm_space_outliner(C);
int event;
const char *str = NULL;
-
+
/* check for invalid states */
if (soops == NULL)
return OPERATOR_CANCELLED;
-
+
event = RNA_enum_get(op->ptr, "type");
if (event == OL_OP_SELECT) {
@@ -944,7 +945,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
if (scene != sce) {
WM_window_change_active_scene(bmain, C, win, sce);
}
-
+
str = "Select Objects";
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
@@ -1004,7 +1005,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
}
ED_undo_push(C, str);
-
+
return OPERATOR_FINISHED;
}
@@ -1015,12 +1016,12 @@ void OUTLINER_OT_object_operation(wmOperatorType *ot)
ot->name = "Outliner Object Operation";
ot->idname = "OUTLINER_OT_object_operation";
ot->description = "";
-
+
/* callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = outliner_object_operation_exec;
ot->poll = ED_operator_outliner_active;
-
+
ot->flag = 0;
ot->prop = RNA_def_enum(ot->srna, "type", prop_object_op_types, 0, "Object Operation", "");
@@ -1030,14 +1031,14 @@ void OUTLINER_OT_object_operation(wmOperatorType *ot)
typedef enum eOutlinerIdOpTypes {
OUTLINER_IDOP_INVALID = 0,
-
+
OUTLINER_IDOP_UNLINK,
OUTLINER_IDOP_LOCAL,
OUTLINER_IDOP_STATIC_OVERRIDE,
OUTLINER_IDOP_SINGLE,
OUTLINER_IDOP_DELETE,
OUTLINER_IDOP_REMAP,
-
+
OUTLINER_IDOP_FAKE_ADD,
OUTLINER_IDOP_FAKE_CLEAR,
OUTLINER_IDOP_RENAME,
@@ -1069,15 +1070,15 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
SpaceOops *soops = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
eOutlinerIdOpTypes event;
-
+
/* check for invalid states */
if (soops == NULL)
return OPERATOR_CANCELLED;
-
+
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
-
+
event = RNA_enum_get(op->ptr, "type");
-
+
switch (event) {
case OUTLINER_IDOP_UNLINK:
{
@@ -1093,25 +1094,25 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
switch (idlevel) {
case ID_AC:
outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_action_cb, NULL);
-
+
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
ED_undo_push(C, "Unlink action");
break;
case ID_MA:
outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_material_cb, NULL);
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL);
ED_undo_push(C, "Unlink material");
break;
case ID_TE:
outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_texture_cb, NULL);
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL);
ED_undo_push(C, "Unlink texture");
break;
case ID_WO:
outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_world_cb, NULL);
-
+
WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL);
ED_undo_push(C, "Unlink world");
break;
@@ -1147,18 +1148,18 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
switch (idlevel) {
case ID_AC:
outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, singleuser_action_cb, NULL);
-
+
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
ED_undo_push(C, "Single-User Action");
break;
-
+
case ID_WO:
outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, singleuser_world_cb, NULL);
-
+
WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL);
ED_undo_push(C, "Single-User World");
break;
-
+
default:
BKE_report(op->reports, RPT_WARNING, "Not yet implemented");
break;
@@ -1185,7 +1186,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
{
/* set fake user */
outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_fake_user_set_cb, NULL);
-
+
WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
ED_undo_push(C, "Add Fake User");
break;
@@ -1194,7 +1195,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
{
/* clear fake user */
outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_fake_user_clear_cb, NULL);
-
+
WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
ED_undo_push(C, "Clear Fake User");
break;
@@ -1203,7 +1204,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
{
/* rename */
outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, item_rename_cb, NULL);
-
+
WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
ED_undo_push(C, "Rename");
break;
@@ -1212,18 +1213,18 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_select_linked_cb, NULL);
ED_undo_push(C, "Select");
break;
-
+
default:
// invalid - unhandled
break;
}
-
+
/* wrong notifier still... */
WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
-
- // XXX: this is just so that outliner is always up to date
+
+ // XXX: this is just so that outliner is always up to date
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1234,14 +1235,14 @@ void OUTLINER_OT_id_operation(wmOperatorType *ot)
ot->name = "Outliner ID data Operation";
ot->idname = "OUTLINER_OT_id_operation";
ot->description = "";
-
+
/* callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = outliner_id_operation_exec;
ot->poll = ED_operator_outliner_active;
-
+
ot->flag = 0;
-
+
ot->prop = RNA_def_enum(ot->srna, "type", prop_id_op_types, 0, "ID data Operation", "");
}
@@ -1345,7 +1346,7 @@ static void outliner_do_id_set_operation(SpaceOops *soops, int type, ListBase *l
{
TreeElement *te;
TreeStoreElem *tselem;
-
+
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
if (tselem->flag & TSE_SELECTED) {
@@ -1365,12 +1366,12 @@ static void outliner_do_id_set_operation(SpaceOops *soops, int type, ListBase *l
static void actionset_id_cb(TreeElement *UNUSED(te), TreeStoreElem *tselem, TreeStoreElem *tsep, ID *actId)
{
bAction *act = (bAction *)actId;
-
+
if (tselem->type == TSE_ANIM_DATA) {
/* "animation" entries - action is child of this */
BKE_animdata_set_action(NULL, tselem->id, act);
}
- /* TODO: if any other "expander" channels which own actions need to support this menu,
+ /* TODO: if any other "expander" channels which own actions need to support this menu,
* add: tselem->type = ...
*/
else if (tsep && (tsep->type == TSE_ANIM_DATA)) {
@@ -1384,17 +1385,17 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op)
{
SpaceOops *soops = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
-
+
bAction *act;
-
+
/* check for invalid states */
if (soops == NULL)
return OPERATOR_CANCELLED;
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
-
+
/* get action to use */
act = BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action"));
-
+
if (act == NULL) {
BKE_report(op->reports, RPT_ERROR, "No valid action to add");
return OPERATOR_CANCELLED;
@@ -1407,7 +1408,7 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op)
"for this action to avoid future problems)",
act->id.name + 2);
}
-
+
/* perform action if valid channel */
if (datalevel == TSE_ANIM_DATA)
outliner_do_id_set_operation(soops, datalevel, &soops->tree, (ID *)act, actionset_id_cb);
@@ -1415,11 +1416,11 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op)
outliner_do_id_set_operation(soops, idlevel, &soops->tree, (ID *)act, actionset_id_cb);
else
return OPERATOR_CANCELLED;
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
ED_undo_push(C, "Set action");
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -1432,15 +1433,15 @@ void OUTLINER_OT_action_set(wmOperatorType *ot)
ot->name = "Outliner Set Action";
ot->idname = "OUTLINER_OT_action_set";
ot->description = "Change the active action used";
-
+
/* api callbacks */
ot->invoke = WM_enum_search_invoke;
ot->exec = outliner_action_set_exec;
ot->poll = ED_operator_outliner_active;
-
+
/* flags */
ot->flag = 0;
-
+
/* props */
// TODO: this would be nicer as an ID-pointer...
prop = RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", "");
@@ -1453,15 +1454,15 @@ void OUTLINER_OT_action_set(wmOperatorType *ot)
typedef enum eOutliner_AnimDataOps {
OUTLINER_ANIMOP_INVALID = 0,
-
+
OUTLINER_ANIMOP_CLEAR_ADT,
-
+
OUTLINER_ANIMOP_SET_ACT,
OUTLINER_ANIMOP_CLEAR_ACT,
-
+
OUTLINER_ANIMOP_REFRESH_DRV,
OUTLINER_ANIMOP_CLEAR_DRV
-
+
//OUTLINER_ANIMOP_COPY_DRIVERS,
//OUTLINER_ANIMOP_PASTE_DRIVERS
} eOutliner_AnimDataOps;
@@ -1483,66 +1484,66 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op)
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
eOutliner_AnimDataOps event;
short updateDeps = 0;
-
+
/* check for invalid states */
if (soops == NULL)
return OPERATOR_CANCELLED;
-
+
event = RNA_enum_get(op->ptr, "type");
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
-
+
if (datalevel != TSE_ANIM_DATA)
return OPERATOR_CANCELLED;
-
+
/* perform the core operation */
switch (event) {
case OUTLINER_ANIMOP_CLEAR_ADT:
/* Remove Animation Data - this may remove the active action, in some cases... */
outliner_do_data_operation(soops, datalevel, event, &soops->tree, clear_animdata_cb, NULL);
-
+
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
ED_undo_push(C, "Clear Animation Data");
break;
-
+
case OUTLINER_ANIMOP_SET_ACT:
/* delegate once again... */
WM_operator_name_call(C, "OUTLINER_OT_action_set", WM_OP_INVOKE_REGION_WIN, NULL);
break;
-
+
case OUTLINER_ANIMOP_CLEAR_ACT:
/* clear active action - using standard rules */
outliner_do_data_operation(soops, datalevel, event, &soops->tree, unlinkact_animdata_cb, NULL);
-
+
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
ED_undo_push(C, "Unlink action");
break;
-
+
case OUTLINER_ANIMOP_REFRESH_DRV:
outliner_do_data_operation(soops, datalevel, event, &soops->tree, refreshdrivers_animdata_cb, NULL);
-
+
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL);
//ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */
updateDeps = 1;
break;
-
+
case OUTLINER_ANIMOP_CLEAR_DRV:
outliner_do_data_operation(soops, datalevel, event, &soops->tree, cleardrivers_animdata_cb, NULL);
-
+
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL);
ED_undo_push(C, "Clear Drivers");
updateDeps = 1;
break;
-
+
default: // invalid
break;
}
-
+
/* update dependencies */
if (updateDeps) {
/* rebuild depsgraph for the new deps */
DEG_relations_tag_update(CTX_data_main(C));
}
-
+
return OPERATOR_FINISHED;
}
@@ -1553,14 +1554,14 @@ void OUTLINER_OT_animdata_operation(wmOperatorType *ot)
ot->name = "Outliner Animation Data Operation";
ot->idname = "OUTLINER_OT_animdata_operation";
ot->description = "";
-
+
/* callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = outliner_animdata_operation_exec;
ot->poll = ED_operator_outliner_active;
-
+
ot->flag = 0;
-
+
ot->prop = RNA_def_enum(ot->srna, "type", prop_animdata_op_types, 0, "Animation Operation", "");
}
@@ -1673,14 +1674,14 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op)
SpaceOops *soops = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
eOutliner_PropDataOps event;
-
+
/* check for invalid states */
if (soops == NULL)
return OPERATOR_CANCELLED;
-
+
event = RNA_enum_get(op->ptr, "type");
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
-
+
switch (datalevel) {
case TSE_POSE_CHANNEL:
{
@@ -1732,7 +1733,7 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_WARNING, "Not yet implemented");
break;
}
-
+
return OPERATOR_FINISHED;
}
@@ -1743,14 +1744,14 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot)
ot->name = "Outliner Data Operation";
ot->idname = "OUTLINER_OT_data_operation";
ot->description = "";
-
+
/* callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = outliner_data_operation_exec;
ot->poll = ED_operator_outliner_active;
-
+
ot->flag = 0;
-
+
ot->prop = RNA_def_enum(ot->srna, "type", prop_data_op_types, 0, "Data Operation", "");
}
@@ -1762,24 +1763,24 @@ static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOops *soop
TreeElement *te, const float mval[2])
{
ReportList *reports = CTX_wm_reports(C); // XXX...
-
+
if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) {
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
TreeStoreElem *tselem = TREESTORE(te);
-
+
/* select object that's clicked on and popup context menu */
if (!(tselem->flag & TSE_SELECTED)) {
-
+
if (outliner_has_one_flag(&soops->tree, TSE_SELECTED, 1))
outliner_set_flag(&soops->tree, TSE_SELECTED, 0);
-
+
tselem->flag |= TSE_SELECTED;
/* Only redraw, don't rebuild here because TreeElement pointers will
* become invalid and operations will crash. */
ED_region_tag_redraw_no_rebuild(ar);
}
-
+
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
if (scenelevel) {
@@ -1841,10 +1842,10 @@ static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOops *soop
}
}
}
-
+
return 1;
}
-
+
for (te = te->subtree.first; te; te = te->next) {
if (do_outliner_operation_event(C, ar, soops, te, mval))
return 1;
@@ -1867,7 +1868,7 @@ static int outliner_operation(bContext *C, wmOperator *UNUSED(op), const wmEvent
}
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
-
+
for (te = soops->tree.first; te; te = te->next) {
if (do_outliner_operation_event(C, ar, soops, te, fmval)) {
found = true;
@@ -1881,7 +1882,7 @@ static int outliner_operation(bContext *C, wmOperator *UNUSED(op), const wmEvent
WM_menu_name_call(C, "OUTLINER_MT_collection_new", WM_OP_INVOKE_REGION_WIN);
}
}
-
+
return OPERATOR_FINISHED;
}
@@ -1891,9 +1892,9 @@ void OUTLINER_OT_operation(wmOperatorType *ot)
ot->name = "Execute Operation";
ot->idname = "OUTLINER_OT_operation";
ot->description = "Context menu for item operations";
-
+
ot->invoke = outliner_operation;
-
+
ot->poll = ED_operator_outliner_active;
}
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index d865896e524..d155457a208 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -28,7 +28,7 @@
/** \file blender/editors/space_outliner/outliner_tree.c
* \ingroup spoutliner
*/
-
+
#include <math.h>
#include <string.h>
@@ -101,11 +101,11 @@ static void outliner_make_object_parent_hierarchy(ListBase *lb);
static void outliner_storage_cleanup(SpaceOops *soops)
{
BLI_mempool *ts = soops->treestore;
-
+
if (ts) {
TreeStoreElem *tselem;
int unused = 0;
-
+
/* each element used once, for ID blocks with more users to have each a treestore */
BLI_mempool_iter iter;
@@ -113,7 +113,7 @@ static void outliner_storage_cleanup(SpaceOops *soops)
while ((tselem = BLI_mempool_iterstep(&iter))) {
tselem->used = 0;
}
-
+
/* cleanup only after reading file or undo step, and always for
* RNA datablocks view in order to save memory */
if (soops->storeflag & SO_TREESTORE_CLEANUP) {
@@ -123,7 +123,7 @@ static void outliner_storage_cleanup(SpaceOops *soops)
while ((tselem = BLI_mempool_iterstep(&iter))) {
if (tselem->id == NULL) unused++;
}
-
+
if (unused) {
if (BLI_mempool_len(ts) == unused) {
BLI_mempool_destroy(ts);
@@ -162,11 +162,11 @@ static void outliner_storage_cleanup(SpaceOops *soops)
static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short type, short nr)
{
TreeStoreElem *tselem;
-
+
if (soops->treestore == NULL) {
/* if treestore was not created in readfile.c, create it here */
soops->treestore = BLI_mempool_create(sizeof(TreeStoreElem), 1, 512, BLI_MEMPOOL_ALLOW_ITER);
-
+
}
if (soops->treehash == NULL) {
soops->treehash = BKE_outliner_treehash_create_from_treestore(soops->treestore);
@@ -232,7 +232,7 @@ void outliner_free_tree_element(TreeElement *element, ListBase *parent_subtree)
/* ********************************************************* */
/* Prototype, see functions below */
-static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv,
+static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv,
TreeElement *parent, short type, short index);
/* -------------------------------------------------------- */
@@ -242,11 +242,11 @@ static void outliner_add_bone(SpaceOops *soops, ListBase *lb, ID *id, Bone *curB
TreeElement *parent, int *a)
{
TreeElement *te = outliner_add_element(soops, lb, id, parent, TSE_BONE, *a);
-
+
(*a)++;
te->name = curBone->name;
te->directdata = curBone;
-
+
for (curBone = curBone->childbase.first; curBone; curBone = curBone->next) {
outliner_add_bone(soops, &te->subtree, id, curBone, te, a);
}
@@ -314,11 +314,11 @@ static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *s
}
FOREACH_SCENE_OBJECT_END;
outliner_make_object_parent_hierarchy(&ten->subtree);
-
+
/* Animation Data */
if (outliner_animdata_test(sce->adt))
outliner_add_element(soops, lb, sce, te, TSE_ANIM_DATA, 0);
-
+
/* Grease Pencil */
outliner_add_element(soops, lb, sce->gpd, te, 0, 0);
}
@@ -429,39 +429,39 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree
outliner_add_element(soops, &te->subtree, ob, te, TSE_ANIM_DATA, 0);
outliner_add_element(soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this
-
+
if (ob->proxy && !ID_IS_LINKED(ob))
outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0);
-
+
outliner_add_element(soops, &te->subtree, ob->gpd, te, 0, 0);
-
+
outliner_add_element(soops, &te->subtree, ob->data, te, 0, 0);
-
+
if (ob->pose) {
bArmature *arm = ob->data;
bPoseChannel *pchan;
TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0);
-
+
tenla->name = IFACE_("Pose");
-
+
/* channels undefined in editmode, but we want the 'tenla' pose icon itself */
if ((arm->edbo == NULL) && (ob->mode & OB_MODE_POSE)) {
TreeElement *ten;
int a = 0, const_index = 1000; /* ensure unique id for bone constraints */
-
+
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next, a++) {
ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a);
ten->name = pchan->name;
ten->directdata = pchan;
pchan->temp = (void *)ten;
-
+
if (pchan->constraints.first) {
//Object *target;
bConstraint *con;
TreeElement *ten1;
TreeElement *tenla1 = outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0);
//char *str;
-
+
tenla1->name = IFACE_("Constraints");
for (con = pchan->constraints.first; con; con = con->next, const_index++) {
ten1 = outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index);
@@ -494,7 +494,7 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree
ten = nten;
}
}
-
+
/* Pose Groups */
if (ob->pose->agroups.first) {
bActionGroup *agrp;
@@ -510,11 +510,11 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree
}
}
}
-
+
for (int a = 0; a < ob->totcol; a++) {
outliner_add_element(soops, &te->subtree, ob->mat[a], te, 0, a);
}
-
+
if (ob->constraints.first) {
//Object *target;
bConstraint *con;
@@ -522,7 +522,7 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree
TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0);
//char *str;
int a;
-
+
tenla->name = IFACE_("Constraints");
for (con = ob->constraints.first, a = 0; con; con = con->next, a++) {
ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a);
@@ -537,18 +537,18 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree
/* possible add all other types links? */
}
}
-
+
if (ob->modifiers.first) {
ModifierData *md;
TreeElement *ten_mod = outliner_add_element(soops, &te->subtree, ob, te, TSE_MODIFIER_BASE, 0);
int index;
-
+
ten_mod->name = IFACE_("Modifiers");
for (index = 0, md = ob->modifiers.first; md; index++, md = md->next) {
TreeElement *ten = outliner_add_element(soops, &ten_mod->subtree, ob, ten_mod, TSE_MODIFIER, index);
ten->name = md->name;
ten->directdata = md;
-
+
if (md->type == eModifierType_Lattice) {
outliner_add_element(soops, &ten->subtree, ((LatticeModifierData *) md)->object, ten, TSE_LINKED_OB, 0);
}
@@ -564,21 +564,21 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree
else if (md->type == eModifierType_ParticleSystem) {
ParticleSystem *psys = ((ParticleSystemModifierData *) md)->psys;
TreeElement *ten_psys;
-
+
ten_psys = outliner_add_element(soops, &ten->subtree, ob, te, TSE_LINKED_PSYS, 0);
ten_psys->directdata = psys;
ten_psys->name = psys->part->id.name + 2;
}
}
}
-
+
/* vertex groups */
if (ob->defbase.first) {
bDeformGroup *defgroup;
TreeElement *ten;
TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0);
int a;
-
+
tenla->name = IFACE_("Vertex Groups");
for (defgroup = ob->defbase.first, a = 0; defgroup; defgroup = defgroup->next, a++) {
ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a);
@@ -586,7 +586,7 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree
ten->directdata = defgroup;
}
}
-
+
/* duplicated group */
if (ob->dup_group)
outliner_add_element(soops, &te->subtree, ob->dup_group, te, 0, 0);
@@ -598,7 +598,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
{
/* tuck pointer back in object, to construct hierarchy */
if (GS(id->name) == ID_OB) id->newid = (ID *)te;
-
+
/* expand specific data always */
switch (GS(id->name)) {
case ID_LI:
@@ -620,10 +620,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
{
Mesh *me = (Mesh *)id;
int a;
-
+
if (outliner_animdata_test(me->adt))
outliner_add_element(soops, &te->subtree, me, te, TSE_ANIM_DATA, 0);
-
+
outliner_add_element(soops, &te->subtree, me->key, te, 0, 0);
for (a = 0; a < me->totcol; a++)
outliner_add_element(soops, &te->subtree, me->mat[a], te, 0, a);
@@ -635,10 +635,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
{
Curve *cu = (Curve *)id;
int a;
-
+
if (outliner_animdata_test(cu->adt))
outliner_add_element(soops, &te->subtree, cu, te, TSE_ANIM_DATA, 0);
-
+
for (a = 0; a < cu->totcol; a++)
outliner_add_element(soops, &te->subtree, cu->mat[a], te, 0, a);
break;
@@ -647,10 +647,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
{
MetaBall *mb = (MetaBall *)id;
int a;
-
+
if (outliner_animdata_test(mb->adt))
outliner_add_element(soops, &te->subtree, mb, te, TSE_ANIM_DATA, 0);
-
+
for (a = 0; a < mb->totcol; a++)
outliner_add_element(soops, &te->subtree, mb->mat[a], te, 0, a);
break;
@@ -658,7 +658,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
case ID_MA:
{
Material *ma = (Material *)id;
-
+
if (outliner_animdata_test(ma->adt))
outliner_add_element(soops, &te->subtree, ma, te, TSE_ANIM_DATA, 0);
break;
@@ -666,17 +666,17 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
case ID_TE:
{
Tex *tex = (Tex *)id;
-
+
if (outliner_animdata_test(tex->adt))
outliner_add_element(soops, &te->subtree, tex, te, TSE_ANIM_DATA, 0);
-
+
outliner_add_element(soops, &te->subtree, tex->ima, te, 0, 0);
break;
}
case ID_CA:
{
Camera *ca = (Camera *)id;
-
+
if (outliner_animdata_test(ca->adt))
outliner_add_element(soops, &te->subtree, ca, te, TSE_ANIM_DATA, 0);
break;
@@ -694,7 +694,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
case ID_LA:
{
Lamp *la = (Lamp *)id;
-
+
if (outliner_animdata_test(la->adt))
outliner_add_element(soops, &te->subtree, la, te, TSE_ANIM_DATA, 0);
break;
@@ -718,7 +718,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
case ID_WO:
{
World *wrld = (World *)id;
-
+
if (outliner_animdata_test(wrld->adt))
outliner_add_element(soops, &te->subtree, wrld, te, TSE_ANIM_DATA, 0);
break;
@@ -726,7 +726,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
case ID_KE:
{
Key *key = (Key *)id;
-
+
if (outliner_animdata_test(key->adt))
outliner_add_element(soops, &te->subtree, key, te, TSE_ANIM_DATA, 0);
break;
@@ -741,14 +741,14 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
{
bArmature *arm = (bArmature *)id;
int a = 0;
-
+
if (outliner_animdata_test(arm->adt))
outliner_add_element(soops, &te->subtree, arm, te, TSE_ANIM_DATA, 0);
-
+
if (arm->edbo) {
EditBone *ebone;
TreeElement *ten;
-
+
for (ebone = arm->edbo->first; ebone; ebone = ebone->next, a++) {
ten = outliner_add_element(soops, &te->subtree, id, te, TSE_EBONE, a);
ten->directdata = ebone;
@@ -788,7 +788,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
{
FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
int a;
-
+
if (outliner_animdata_test(linestyle->adt))
outliner_add_element(soops, &te->subtree, linestyle, te, TSE_ANIM_DATA, 0);
@@ -803,10 +803,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
bGPdata *gpd = (bGPdata *)id;
bGPDlayer *gpl;
int a = 0;
-
+
if (outliner_animdata_test(gpd->adt))
outliner_add_element(soops, &te->subtree, gpd, te, TSE_ANIM_DATA, 0);
-
+
// TODO: base element for layers?
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
outliner_add_element(soops, &te->subtree, gpl, te, TSE_GP_LAYER, a);
@@ -835,7 +835,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
TreeElement *te;
TreeStoreElem *tselem;
ID *id = idv;
-
+
if (ELEM(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) {
id = ((PointerRNA *)idv)->id.data;
if (!id) id = ((PointerRNA *)idv)->data;
@@ -864,11 +864,11 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
/* add to the storage */
check_persistent(soops, te, id, type, index);
tselem = TREESTORE(te);
-
+
/* if we are searching for something expand to see child elements */
if (SEARCHING_OUTLINER(soops))
tselem->flag |= TSE_CHILDSEARCH;
-
+
te->parent = parent;
te->index = index; // for data arays
if (ELEM(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) {
@@ -897,10 +897,10 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
te->name = id->name + 2; // default, can be overridden by Library or non-ID data
te->idcode = GS(id->name);
}
-
+
if (type == 0) {
TreeStoreElem *tsepar = parent ? TREESTORE(parent) : NULL;
-
+
/* ID datablock */
if (tsepar == NULL || tsepar->type != TSE_ID_BASE || soops->filter_id_type) {
outliner_add_id_contents(soops, te, tselem, id);
@@ -909,30 +909,30 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
else if (type == TSE_ANIM_DATA) {
IdAdtTemplate *iat = (IdAdtTemplate *)idv;
AnimData *adt = (AnimData *)iat->adt;
-
+
/* this element's info */
te->name = IFACE_("Animation");
te->directdata = adt;
-
+
/* Action */
outliner_add_element(soops, &te->subtree, adt->action, te, 0, 0);
-
+
/* Drivers */
if (adt->drivers.first) {
TreeElement *ted = outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0);
ID *lastadded = NULL;
FCurve *fcu;
-
+
ted->name = IFACE_("Drivers");
-
+
for (fcu = adt->drivers.first; fcu; fcu = fcu->next) {
if (fcu->driver && fcu->driver->variables.first) {
ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
-
+
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
/* loop over all targets used here */
- DRIVER_TARGETS_USED_LOOPER(dvar)
+ DRIVER_TARGETS_USED_LOOPER(dvar)
{
if (lastadded != dtar->id) {
// XXX this lastadded check is rather lame, and also fails quite badly...
@@ -945,23 +945,23 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
}
}
}
-
+
/* NLA Data */
if (adt->nla_tracks.first) {
TreeElement *tenla = outliner_add_element(soops, &te->subtree, adt, te, TSE_NLA, 0);
NlaTrack *nlt;
int a = 0;
-
+
tenla->name = IFACE_("NLA Tracks");
-
+
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
TreeElement *tenlt = outliner_add_element(soops, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a);
NlaStrip *strip;
TreeElement *ten;
int b = 0;
-
+
tenlt->name = nlt->name;
-
+
for (strip = nlt->strips.first; strip; strip = strip->next, b++) {
ten = outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b);
if (ten) ten->directdata = strip;
@@ -971,7 +971,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
}
else if (type == TSE_GP_LAYER) {
bGPDlayer *gpl = (bGPDlayer *)idv;
-
+
te->name = gpl->info;
te->directdata = gpl;
}
@@ -1144,31 +1144,31 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
wmKeyMap *km = (wmKeyMap *)idv;
wmKeyMapItem *kmi;
char opname[OP_MAX_TYPENAME];
-
+
te->directdata = idv;
te->name = km->idname;
-
+
if (TSELEM_OPEN(tselem, soops)) {
int a = 0;
-
+
for (kmi = km->items.first; kmi; kmi = kmi->next, a++) {
const char *key = WM_key_event_string(kmi->type, false);
-
+
if (key[0]) {
wmOperatorType *ot = NULL;
-
+
if (kmi->propvalue) {
/* pass */
}
else {
ot = WM_operatortype_find(kmi->idname, 0);
}
-
+
if (ot || kmi->propvalue) {
TreeElement *ten = outliner_add_element(soops, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a);
-
+
ten->directdata = kmi;
-
+
if (kmi->propvalue) {
ten->name = IFACE_("Modal map, not yet");
}
@@ -1181,7 +1181,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
}
}
}
- else
+ else
te->flag |= TE_LAZY_CLOSED;
}
@@ -1289,7 +1289,7 @@ static TreeElement *outliner_add_library_contents(Main *mainvar, SpaceOops *soop
ListBase *lbarray[MAX_LIBARRAY];
int a, tot;
short filter_id_type = (soops->filter & SO_FILTER_ID_TYPE) ? soops->filter_id_type : 0;
-
+
if (filter_id_type) {
lbarray[0] = which_libbase(mainvar, soops->filter_id_type);
tot = 1;
@@ -1301,12 +1301,12 @@ static TreeElement *outliner_add_library_contents(Main *mainvar, SpaceOops *soop
for (a = 0; a < tot; a++) {
if (lbarray[a] && lbarray[a]->first) {
ID *id = lbarray[a]->first;
-
+
/* check if there's data in current lib */
for (; id; id = id->next)
if (id->lib == lib)
break;
-
+
if (id) {
if (!tenlib) {
/* Create library tree element on demand, depending if there are any datablocks. */
@@ -1328,7 +1328,7 @@ static TreeElement *outliner_add_library_contents(Main *mainvar, SpaceOops *soop
ten->directdata = lbarray[a];
ten->name = outliner_idcode_to_plural(GS(id->name));
}
-
+
for (id = lbarray[a]->first; id; id = id->next) {
if (outliner_library_id_show(lib, id, filter_id_type)) {
outliner_add_element(soops, &ten->subtree, id, ten, 0, 0);
@@ -1347,7 +1347,7 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops)
ListBase *lbarray[MAX_LIBARRAY];
int a, tot;
short filter_id_type = (soops->filter & SO_FILTER_ID_TYPE) ? soops->filter_id_type : 0;
-
+
if (filter_id_type) {
lbarray[0] = which_libbase(mainvar, soops->filter_id_type);
tot = 1;
@@ -1359,13 +1359,13 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops)
for (a = 0; a < tot; a++) {
if (lbarray[a] && lbarray[a]->first) {
ID *id = lbarray[a]->first;
-
+
/* check if there are any datablocks of this type which are orphans */
for (; id; id = id->next) {
if (ID_REAL_USERS(id) <= 0)
break;
}
-
+
if (id) {
/* header for this type of datablock */
if (filter_id_type) {
@@ -1376,7 +1376,7 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops)
ten->directdata = lbarray[a];
ten->name = outliner_idcode_to_plural(GS(id->name));
}
-
+
/* add the orphaned datablocks - these will not be added with any subtrees attached */
for (id = lbarray[a]->first; id; id = id->next) {
if (ID_REAL_USERS(id) <= 0)
@@ -1568,7 +1568,7 @@ static void outliner_make_object_parent_hierarchy(ListBase *lb)
while (te) {
ten = te->next;
tselem = TREESTORE(te);
-
+
if (tselem->type == 0 && te->idcode == ID_OB) {
Object *ob = (Object *)tselem->id;
if (ob->parent && ob->parent->id.newid) {
@@ -1597,16 +1597,16 @@ static int treesort_alpha_ob(const void *v1, const void *v2)
{
const tTreeSort *x1 = v1, *x2 = v2;
int comp;
-
+
/* first put objects last (hierarchy) */
comp = (x1->idcode == ID_OB);
if (x2->idcode == ID_OB) comp += 2;
-
+
if (comp == 1) return 1;
else if (comp == 2) return -1;
else if (comp == 3) {
comp = strcmp(x1->name, x2->name);
-
+
if (comp > 0) return 1;
else if (comp < 0) return -1;
return 0;
@@ -1619,9 +1619,9 @@ static int treesort_alpha(const void *v1, const void *v2)
{
const tTreeSort *x1 = v1, *x2 = v2;
int comp;
-
+
comp = strcmp(x1->name, x2->name);
-
+
if (comp > 0) return 1;
else if (comp < 0) return -1;
return 0;
@@ -1633,7 +1633,7 @@ static int treesort_alpha(const void *v1, const void *v2)
static int treesort_obtype_alpha(const void *v1, const void *v2)
{
const tTreeSort *x1 = v1, *x2 = v2;
-
+
/* first put objects last (hierarchy) */
if (x1->idcode == ID_OB && x2->idcode != ID_OB) {
return 1;
@@ -1650,7 +1650,7 @@ static int treesort_obtype_alpha(const void *v1, const void *v2)
}
else {
int comp = strcmp(x1->name, x2->name);
-
+
if (comp > 0) return 1;
else if (comp < 0) return -1;
return 0;
@@ -1683,15 +1683,15 @@ static void outliner_sort(ListBase *lb)
tp->te = te;
tp->name = te->name;
tp->idcode = te->idcode;
-
+
if (tselem->type && tselem->type != TSE_DEFGROUP)
tp->idcode = 0; // don't sort this
if (tselem->type == TSE_ID_BASE)
tp->idcode = 1; // do sort this
-
+
tp->id = tselem->id;
}
-
+
/* just sort alphabetically */
if (tear->idcode == 1) {
qsort(tear, totelem, sizeof(tTreeSort), treesort_alpha);
@@ -1700,11 +1700,11 @@ static void outliner_sort(ListBase *lb)
/* keep beginning of list */
for (tp = tear, skip = 0; skip < totelem; skip++, tp++)
if (tp->idcode) break;
-
+
if (skip < totelem)
qsort(tear + skip, totelem - skip, sizeof(tTreeSort), treesort_alpha_ob);
}
-
+
BLI_listbase_clear(lb);
tp = tear;
while (totelem--) {
@@ -1714,7 +1714,7 @@ static void outliner_sort(ListBase *lb)
MEM_freeN(tear);
}
}
-
+
for (te = lb->first; te; te = te->next) {
outliner_sort(&te->subtree);
}
@@ -2052,7 +2052,7 @@ static int outliner_filter_subtree(
/* flag as not a found item */
tselem->flag &= ~TSE_SEARCHMATCH;
-
+
if ((!TSELEM_OPEN(tselem, soops)) ||
outliner_filter_subtree(soops, view_layer, &te->subtree, search_string, exclude_filter) == 0)
{
@@ -2130,11 +2130,11 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa
outliner_free_tree(&soops->tree);
outliner_storage_cleanup(soops);
-
+
/* options */
if (soops->outlinevis == SO_LIBRARIES) {
Library *lib;
-
+
/* current file first - mainvar provides tselem with unique pointer - not used */
ten = outliner_add_library_contents(mainvar, soops, &soops->tree, NULL);
if (ten) {
@@ -2142,7 +2142,7 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa
if (!tselem->used)
tselem->flag &= ~TSE_CLOSED;
}
-
+
for (lib = mainvar->library.first; lib; lib = lib->id.next) {
ten = outliner_add_library_contents(mainvar, soops, &soops->tree, lib);
if (ten) {
@@ -2178,7 +2178,7 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa
/* restore newid pointers */
for (lib = mainvar->library.first; lib; lib = lib->id.next)
lib->id.newid = NULL;
-
+
}
else if (soops->outlinevis == SO_SCENES) {
Scene *sce;
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 72ce24aaff5..71ae7eeeb3d 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -68,7 +68,7 @@ static void outliner_main_region_init(wmWindowManager *wm, ARegion *ar)
{
ListBase *lb;
wmKeyMap *keymap;
-
+
/* make sure we keep the hide flags */
ar->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
ar->v2d.scroll &= ~(V2D_SCROLL_LEFT | V2D_SCROLL_TOP); /* prevent any noise of past */
@@ -81,7 +81,7 @@ static void outliner_main_region_init(wmWindowManager *wm, ARegion *ar)
ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
-
+
/* own keymap */
keymap = WM_keymap_find(wm->defaultconf, "Outliner", SPACE_OUTLINER, 0);
/* don't pass on view2d mask, it's always set with scrollbar space, hide fails */
@@ -286,16 +286,16 @@ static void outliner_main_region_draw(const bContext *C, ARegion *ar)
{
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
-
+
/* clear */
UI_ThemeClearColor(TH_BACK);
glClear(GL_COLOR_BUFFER_BIT);
-
+
draw_outliner(C);
-
+
/* reset view matrix */
UI_view2d_view_restore(C);
-
+
/* scrollers */
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
UI_view2d_scrollers_draw(C, v2d, scrollers);
@@ -305,7 +305,7 @@ static void outliner_main_region_draw(const bContext *C, ARegion *ar)
static void outliner_main_region_free(ARegion *UNUSED(ar))
{
-
+
}
static void outliner_main_region_listener(
@@ -418,7 +418,7 @@ static void outliner_main_region_listener(
}
break;
}
-
+
}
static void outliner_main_region_message_subscribe(
@@ -484,20 +484,20 @@ static SpaceLink *outliner_new(const ScrArea *UNUSED(area), const Scene *UNUSED(
soutliner = MEM_callocN(sizeof(SpaceOops), "initoutliner");
soutliner->spacetype = SPACE_OUTLINER;
soutliner->filter_id_type = ID_GR;
-
+
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for outliner");
-
+
BLI_addtail(&soutliner->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_TOP;
-
+
/* main region */
ar = MEM_callocN(sizeof(ARegion), "main region for outliner");
-
+
BLI_addtail(&soutliner->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
-
+
return (SpaceLink *)soutliner;
}
@@ -505,7 +505,7 @@ static SpaceLink *outliner_new(const ScrArea *UNUSED(area), const Scene *UNUSED(
static void outliner_free(SpaceLink *sl)
{
SpaceOops *soutliner = (SpaceOops *)sl;
-
+
outliner_free_tree(&soutliner->tree);
if (soutliner->treestore) {
BLI_mempool_destroy(soutliner->treestore);
@@ -518,7 +518,7 @@ static void outliner_free(SpaceLink *sl)
/* spacetype; init callback */
static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
{
-
+
}
static SpaceLink *outliner_duplicate(SpaceLink *sl)
@@ -529,7 +529,7 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl)
BLI_listbase_clear(&soutlinern->tree);
soutlinern->treestore = NULL;
soutlinern->treehash = NULL;
-
+
return (SpaceLink *)soutlinern;
}
@@ -571,10 +571,10 @@ void ED_spacetype_outliner(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time");
ARegionType *art;
-
+
st->spaceid = SPACE_OUTLINER;
strncpy(st->name, "Outliner", BKE_ST_MAXNAME);
-
+
st->new = outliner_new;
st->free = outliner_free;
st->init = outliner_init;
@@ -588,26 +588,26 @@ void ED_spacetype_outliner(void)
art = MEM_callocN(sizeof(ARegionType), "spacetype outliner region");
art->regionid = RGN_TYPE_WINDOW;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
-
+
art->init = outliner_main_region_init;
art->draw = outliner_main_region_draw;
art->free = outliner_main_region_free;
art->listener = outliner_main_region_listener;
art->message_subscribe = outliner_main_region_message_subscribe;
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype outliner header region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
-
+
art->init = outliner_header_region_init;
art->draw = outliner_header_region_draw;
art->free = outliner_header_region_free;
art->listener = outliner_header_region_listener;
BLI_addhead(&st->regiontypes, art);
-
+
BKE_spacetype_register(st);
}
diff --git a/source/blender/editors/space_script/script_intern.h b/source/blender/editors/space_script/script_intern.h
index cef6082aa1c..a3fcbb34e7e 100644
--- a/source/blender/editors/space_script/script_intern.h
+++ b/source/blender/editors/space_script/script_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c
index 0b87f9ec683..c8e5a4bdf87 100644
--- a/source/blender/editors/space_script/space_script.c
+++ b/source/blender/editors/space_script/space_script.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -66,33 +66,33 @@ static SpaceLink *script_new(const ScrArea *UNUSED(area), const Scene *UNUSED(sc
{
ARegion *ar;
SpaceScript *sscript;
-
+
sscript = MEM_callocN(sizeof(SpaceScript), "initscript");
sscript->spacetype = SPACE_SCRIPT;
-
-
+
+
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for script");
-
+
BLI_addtail(&sscript->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_TOP;
-
+
/* main region */
ar = MEM_callocN(sizeof(ARegion), "main region for script");
-
+
BLI_addtail(&sscript->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
-
+
/* channel list region XXX */
-
+
return (SpaceLink *)sscript;
}
/* not spacelink itself */
static void script_free(SpaceLink *sl)
-{
+{
SpaceScript *sscript = (SpaceScript *) sl;
#ifdef WITH_PYTHON
@@ -116,9 +116,9 @@ static void script_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
static SpaceLink *script_duplicate(SpaceLink *sl)
{
SpaceScript *sscriptn = MEM_dupallocN(sl);
-
+
/* clear or remove stuff from old */
-
+
return (SpaceLink *)sscriptn;
}
@@ -128,9 +128,9 @@ static SpaceLink *script_duplicate(SpaceLink *sl)
static void script_main_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
-
+
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
-
+
/* own keymap */
keymap = WM_keymap_find(wm->defaultconf, "Script", SPACE_SCRIPT, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
@@ -145,12 +145,12 @@ static void script_main_region_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
glClear(GL_COLOR_BUFFER_BIT);
-
+
UI_view2d_view_ortho(v2d);
-
+
/* data... */
// BPY_script_exec(C, "/root/blender-svn/blender25/test.py", NULL);
-
+
#ifdef WITH_PYTHON
if (sscript->script) {
// BPY_run_script_space_draw(C, sscript);
@@ -158,10 +158,10 @@ static void script_main_region_draw(const bContext *C, ARegion *ar)
#else
(void)sscript;
#endif
-
+
/* reset view matrix */
UI_view2d_view_restore(C);
-
+
/* scrollers? */
}
@@ -190,17 +190,17 @@ void ED_spacetype_script(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype script");
ARegionType *art;
-
+
st->spaceid = SPACE_SCRIPT;
strncpy(st->name, "Script", BKE_ST_MAXNAME);
-
+
st->new = script_new;
st->free = script_free;
st->init = script_init;
st->duplicate = script_duplicate;
st->operatortypes = script_operatortypes;
st->keymap = script_keymap;
-
+
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype script region");
art->regionid = RGN_TYPE_WINDOW;
@@ -210,19 +210,19 @@ void ED_spacetype_script(void)
art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_UI | ED_KEYMAP_FRAMES; // XXX need to further test this ED_KEYMAP_UI is needed for button interaction
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype script region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
-
+
art->init = script_header_region_init;
art->draw = script_header_region_draw;
-
+
BLI_addhead(&st->regiontypes, art);
-
-
+
+
BKE_spacetype_register(st);
}
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index caa3ba593fb..a8688b26280 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -95,12 +95,12 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag)
if (flag & SEQPROP_STARTFRAME)
RNA_def_int(ot->srna, "frame_start", 0, INT_MIN, INT_MAX, "Start Frame", "Start frame of the sequence strip", INT_MIN, INT_MAX);
-
+
if (flag & SEQPROP_ENDFRAME)
RNA_def_int(ot->srna, "frame_end", 0, INT_MIN, INT_MAX, "End Frame", "End frame for the color strip", INT_MIN, INT_MAX); /* not usual since most strips have a fixed length */
-
+
RNA_def_int(ot->srna, "channel", 1, 1, MAXSEQ, "Channel", "Channel to place this strip into", 1, MAXSEQ);
-
+
RNA_def_boolean(ot->srna, "replace_sel", 1, "Replace Selection", "Replace the current selection");
/* only for python scripts which import strips and place them after */
@@ -114,9 +114,10 @@ static void sequencer_generic_invoke_path__internal(bContext *C, wmOperator *op,
Scene *scene = CTX_data_scene(C);
Sequence *last_seq = BKE_sequencer_active_get(scene);
if (last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) {
+ Main *bmain = CTX_data_main(C);
char path[FILE_MAX];
BLI_strncpy(path, last_seq->strip->dir, sizeof(path));
- BLI_path_abs(path, G.main->name);
+ BLI_path_abs(path, BKE_main_blendfile_path(bmain));
RNA_string_set(op->ptr, identifier, path);
}
}
@@ -144,7 +145,7 @@ static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type)
proximity = cfra - seq->enddisp;
}
}
-
+
if (tgt) {
return tgt->machine;
}
@@ -154,16 +155,16 @@ static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type)
static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, int flag, int type)
{
Scene *scene = CTX_data_scene(C);
-
+
int cfra = (int) CFRA;
-
+
/* effect strips don't need a channel initialized from the mouse */
if (!(flag & SEQPROP_NOCHAN)) {
RNA_int_set(op->ptr, "channel", sequencer_generic_invoke_xy_guess_channel(C, type));
}
RNA_int_set(op->ptr, "frame_start", cfra);
-
+
if ((flag & SEQPROP_ENDFRAME) && RNA_struct_property_is_set(op->ptr, "frame_end") == 0)
RNA_int_set(op->ptr, "frame_end", cfra + 25); // XXX arbitary but ok for now.
@@ -173,8 +174,10 @@ static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, i
}
}
-static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op)
+static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
+
PropertyRNA *prop;
const bool relative = (prop = RNA_struct_find_property(op->ptr, "relative_path")) && RNA_property_boolean_get(op->ptr, prop);
int is_file = -1;
@@ -196,9 +199,9 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op)
}
if ((is_file != -1) && relative)
- BLI_path_rel(seq_load->path, G.main->name);
+ BLI_path_rel(seq_load->path, BKE_main_blendfile_path(bmain));
+
-
if ((prop = RNA_struct_find_property(op->ptr, "frame_end"))) {
seq_load->end_frame = RNA_property_int_get(op->ptr, prop);
}
@@ -214,7 +217,7 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op)
if ((prop = RNA_struct_find_property(op->ptr, "sound")) && RNA_property_boolean_get(op->ptr, prop))
seq_load->flag |= SEQ_LOAD_MOVIE_SOUND;
-
+
if ((prop = RNA_struct_find_property(op->ptr, "use_framerate")) && RNA_property_boolean_get(op->ptr, prop))
seq_load->flag |= SEQ_LOAD_SYNC_FPS;
@@ -283,35 +286,35 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, true);
-
+
Scene *sce_seq;
Sequence *seq; /* generic strip vars */
Strip *strip;
-
+
int start_frame, channel; /* operator props */
-
+
start_frame = RNA_int_get(op->ptr, "frame_start");
channel = RNA_int_get(op->ptr, "channel");
-
+
sce_seq = BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene"));
-
+
if (sce_seq == NULL) {
BKE_report(op->reports, RPT_ERROR, "Scene not found");
return OPERATOR_CANCELLED;
}
-
+
seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
seq->type = SEQ_TYPE_SCENE;
seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
seq->scene = sce_seq;
-
+
/* basic defaults */
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
seq->len = sce_seq->r.efra - sce_seq->r.sfra + 1;
strip->us = 1;
-
+
BLI_strncpy(seq->name + 2, sce_seq->id.name + 2, sizeof(seq->name) - 2);
BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
@@ -319,12 +322,12 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
BKE_sequence_calc_disp(scene, seq);
BKE_sequencer_sort(scene);
-
+
sequencer_add_apply_replace_sel(C, op, seq);
sequencer_add_apply_overlap(C, op, seq);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -344,7 +347,7 @@ static int sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, const w
void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Add Scene Strip";
ot->idname = "SEQUENCER_OT_scene_strip_add";
@@ -355,10 +358,10 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot)
ot->exec = sequencer_add_scene_strip_exec;
ot->poll = ED_operator_sequencer_active_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
RNA_def_enum_funcs(prop, RNA_scene_without_active_itemf);
@@ -371,24 +374,24 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, true);
-
+
MovieClip *clip;
Sequence *seq; /* generic strip vars */
Strip *strip;
-
+
int start_frame, channel; /* operator props */
-
+
start_frame = RNA_int_get(op->ptr, "frame_start");
channel = RNA_int_get(op->ptr, "channel");
-
+
clip = BLI_findlink(&CTX_data_main(C)->movieclip, RNA_enum_get(op->ptr, "clip"));
-
+
if (clip == NULL) {
BKE_report(op->reports, RPT_ERROR, "Movie clip not found");
return OPERATOR_CANCELLED;
}
-
+
seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
seq->type = SEQ_TYPE_MOVIECLIP;
seq->blend_mode = SEQ_TYPE_CROSS;
@@ -400,18 +403,18 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
seq->len = BKE_movieclip_get_duration(clip);
strip->us = 1;
-
+
BLI_strncpy(seq->name + 2, clip->id.name + 2, sizeof(seq->name) - 2);
BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
BKE_sequence_calc_disp(scene, seq);
BKE_sequencer_sort(scene);
-
+
sequencer_add_apply_replace_sel(C, op, seq);
sequencer_add_apply_overlap(C, op, seq);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -545,7 +548,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
SeqLoadInfo seq_load;
int tot_files;
- seq_load_operator_info(&seq_load, op);
+ seq_load_operator_info(&seq_load, C, op);
if (seq_load.flag & SEQ_LOAD_REPLACE_SEL)
ED_sequencer_deselect_all(scene);
@@ -666,7 +669,7 @@ static int sequencer_add_movie_strip_invoke(bContext *C, wmOperator *op, const w
sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_MOVIE);
return sequencer_add_movie_strip_exec(C, op);
}
-
+
sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIE);
sequencer_add_init(C, op);
@@ -702,7 +705,7 @@ static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op)
void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot)
{
-
+
/* identifiers */
ot->name = "Add Movie Strip";
ot->idname = "SEQUENCER_OT_movie_strip_add";
@@ -718,7 +721,7 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
WM_operator_properties_filesel(
ot, FILE_TYPE_FOLDER | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_OPENFILE,
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_FILES, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
@@ -743,7 +746,7 @@ static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, const w
sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_SOUND_RAM);
return sequencer_add_sound_strip_exec(C, op);
}
-
+
sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_SOUND_RAM);
WM_event_add_fileselect(C, op);
@@ -755,7 +758,7 @@ static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, const w
void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot)
{
-
+
/* identifiers */
ot->name = "Add Sound Strip";
ot->idname = "SEQUENCER_OT_sound_strip_add";
@@ -766,10 +769,10 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot)
ot->exec = sequencer_add_sound_strip_exec;
ot->poll = ED_operator_sequencer_active_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
WM_operator_properties_filesel(
ot, FILE_TYPE_FOLDER | FILE_TYPE_SOUND, FILE_SPECIAL, FILE_OPENFILE,
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_FILES, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
@@ -855,7 +858,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
StripElem *se;
const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders");
- seq_load_operator_info(&seq_load, op);
+ seq_load_operator_info(&seq_load, C, op);
/* images are unique in how they handle this - 1 per strip elem */
if (use_placeholders) {
@@ -925,7 +928,7 @@ static int sequencer_add_image_strip_invoke(bContext *C, wmOperator *op, const w
sequencer_generic_invoke_xy__internal(C, op, SEQPROP_ENDFRAME | SEQPROP_NOPATHS, SEQ_TYPE_IMAGE);
return sequencer_add_image_strip_exec(C, op);
}
-
+
sequencer_generic_invoke_xy__internal(C, op, SEQPROP_ENDFRAME, SEQ_TYPE_IMAGE);
sequencer_add_init(C, op);
@@ -941,7 +944,7 @@ static int sequencer_add_image_strip_invoke(bContext *C, wmOperator *op, const w
void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot)
{
-
+
/* identifiers */
ot->name = "Add Image Strip";
ot->idname = "SEQUENCER_OT_image_strip_add";
@@ -954,10 +957,10 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot)
ot->ui = sequencer_add_draw;
ot->poll = ED_operator_sequencer_active_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
WM_operator_properties_filesel(
ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE, FILE_SPECIAL, FILE_OPENFILE,
WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH | WM_FILESEL_FILES, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
@@ -978,7 +981,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
struct SeqEffectHandle sh;
int start_frame, end_frame, channel, type; /* operator props */
-
+
Sequence *seq1, *seq2, *seq3;
const char *error_msg;
@@ -987,7 +990,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
channel = RNA_int_get(op->ptr, "channel");
type = RNA_enum_get(op->ptr, "type");
-
+
// XXX move to invoke
if (!seq_effect_find_selected(scene, NULL, type, &seq1, &seq2, &seq3, &error_msg)) {
BKE_report(op->reports, RPT_ERROR, error_msg);
@@ -1023,7 +1026,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE;
BKE_sequence_calc(scene, seq);
-
+
/* basic defaults */
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
strip->us = 1;
@@ -1061,7 +1064,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
/* not sure if this is needed with update_changed_seq_and_deps.
* it was NOT called in blender 2.4x, but wont hurt */
- BKE_sequencer_sort(scene);
+ BKE_sequencer_sort(scene);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
@@ -1105,10 +1108,10 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot)
ot->exec = sequencer_add_effect_strip_exec;
ot->poll = ED_operator_sequencer_active_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME | SEQPROP_ENDFRAME);
RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_TYPE_CROSS, "Type", "Sequencer effect type");
RNA_def_float_vector(ot->srna, "color", 3, NULL, 0.0f, 1.0f, "Color",
diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c
index b33a26db728..72f78d4f466 100644
--- a/source/blender/editors/space_sequencer/sequencer_buttons.c
+++ b/source/blender/editors/space_sequencer/sequencer_buttons.c
@@ -65,7 +65,7 @@ void sequencer_buttons_register(ARegionType *UNUSED(art))
{
#if 0
PanelType *pt;
-
+
pt = MEM_callocN(sizeof(PanelType), "spacetype sequencer panel gpencil");
strcpy(pt->idname, "SEQUENCER_PT_gpencil");
strcpy(pt->label, N_("Grease Pencil"));
@@ -83,7 +83,7 @@ static int sequencer_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = sequencer_has_buttons_region(sa);
-
+
if (ar)
ED_region_toggle_hidden(C, ar);
@@ -95,10 +95,10 @@ void SEQUENCER_OT_properties(wmOperatorType *ot)
ot->name = "Properties";
ot->idname = "SEQUENCER_OT_properties";
ot->description = "Toggle the properties region visibility";
-
+
ot->exec = sequencer_properties_toggle_exec;
ot->poll = ED_operator_sequencer_active;
-
+
/* flags */
ot->flag = 0;
}
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 06ea3fceb2f..ffcb4329726 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -125,12 +125,12 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, unsigned char col[3])
case SEQ_TYPE_SCENE:
UI_GetThemeColor3ubv(TH_SEQ_SCENE, col);
-
+
if (seq->scene == curscene) {
UI_GetColorPtrShade3ubv(col, col, 20);
}
break;
-
+
/* transitions */
case SEQ_TYPE_CROSS:
case SEQ_TYPE_GAMCROSS:
@@ -216,7 +216,7 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s
float startsample, endsample;
float value1, value2;
bSound *sound = seq->sound;
-
+
SoundWaveform *waveform;
if (length < 2) {
@@ -227,7 +227,7 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s
sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
BLI_spin_init(sound->spinlock);
}
-
+
BLI_spin_lock(sound->spinlock);
if (!sound->waveform) {
if (!(sound->flags & SOUND_FLAGS_WAVEFORM_LOADING)) {
@@ -242,7 +242,7 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s
return; /* nothing to draw */
}
BLI_spin_unlock(sound->spinlock);
-
+
waveform = sound->waveform;
if (waveform->length == 0) {
@@ -365,7 +365,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
}
immUniformColor4ubv(col);
-
+
/* clamp within parent sequence strip bounds */
if (x1_chan < x1) x1_chan = x1;
if (x2_chan > x2) x2_chan = x2;
@@ -399,10 +399,10 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla
float v1[2], v2[2], v3[2], rx1 = 0, rx2 = 0; //for triangles and rect
float x1, x2, y1, y2;
unsigned int whichsel = 0;
-
+
x1 = seq->startdisp;
x2 = seq->enddisp;
-
+
y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
y2 = seq->machine + SEQ_STRIP_OFSTOP;
@@ -410,32 +410,32 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla
if (direction == SEQ_LEFTHANDLE) {
rx1 = x1;
rx2 = x1 + handsize_clamped * 0.75f;
-
+
v1[0] = x1 + handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2);
v2[0] = x1 + handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2);
v3[0] = v2[0] + handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f;
-
+
whichsel = SEQ_LEFTSEL;
}
else if (direction == SEQ_RIGHTHANDLE) {
rx1 = x2 - handsize_clamped * 0.75f;
rx2 = x2;
-
+
v1[0] = x2 - handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2);
v2[0] = x2 - handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2);
v3[0] = v2[0] - handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f;
-
+
whichsel = SEQ_RIGHTSEL;
}
-
+
/* draw! */
if (!(seq->type & SEQ_TYPE_EFFECT) ||
BKE_sequence_effect_get_num_inputs(seq->type) == 0)
{
glEnable(GL_BLEND);
-
+
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
+
if (seq->flag & whichsel) {
immUniformColor4ub(0, 0, 0, 80);
}
@@ -445,9 +445,9 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla
else {
immUniformColor4ub(0, 0, 0, 22);
}
-
+
immRectf(pos, rx1, y1, rx2, y2);
-
+
if (seq->flag & whichsel) {
immUniformColor4ub(255, 255, 255, 200);
}
@@ -463,7 +463,7 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla
glDisable(GL_BLEND);
}
-
+
if ((G.moving & G_TRANSFORM_SEQ) || (seq->flag & whichsel)) {
const char col[4] = {255, 255, 255, 255};
char numstr[32];
@@ -579,7 +579,7 @@ static void draw_seq_text(View2D *v2d, SpaceSeq *sseq, Sequence *seq, float x1,
str_len = BLI_snprintf(str, sizeof(str), "%s | %d",
name, seq->len);
}
-
+
if (seq->flag & SELECT) {
col[0] = col[1] = col[2] = 255;
}
@@ -604,23 +604,23 @@ static void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq, u
float x1, x2, y1, y2, pixely;
unsigned char col[4], blendcol[3];
View2D *v2d = &ar->v2d;
-
+
x1 = seq->startdisp;
x2 = seq->enddisp;
-
+
y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
y2 = seq->machine + SEQ_STRIP_OFSTOP;
-
+
pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
-
+
if (pixely <= 0) return; /* can happen when the view is split/resized */
-
+
blendcol[0] = blendcol[1] = blendcol[2] = 120;
if (seq->startofs || seq->endofs) {
glEnable(GL_BLEND);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
+
color3ubv_from_seq(scene, seq, col);
if (seq->flag & SELECT) {
@@ -710,7 +710,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg
/* we need to know if this is a single image/color or not for drawing */
is_single_image = (char)BKE_sequence_single_check(seq);
-
+
/* body */
x1 = (seq->startstill) ? seq->start : seq->startdisp;
y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
@@ -765,7 +765,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg
x1 = seq->startdisp;
x2 = seq->enddisp;
-
+
/* draw sound wave */
if (seq->type == SEQ_TYPE_SOUND_RAM) {
if (!(sseq->flag & SEQ_NO_WAVEFORMS)) {
@@ -825,7 +825,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg
}
else
UI_GetColorPtrShade3ubv(col, col, outline_tint);
-
+
if ((seq->type == SEQ_TYPE_META) ||
((seq->type == SEQ_TYPE_SCENE) && (seq->flag & SEQ_SCENE_STRIPS)))
{
@@ -894,7 +894,9 @@ void ED_sequencer_special_preview_clear(void)
sequencer_special_update_set(NULL);
}
-ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int cfra, int frame_ofs, const char *viewname)
+ImBuf *sequencer_ibuf_get(
+ struct Main *bmain, struct Depsgraph *depsgraph, Scene *scene,
+ SpaceSeq *sseq, int cfra, int frame_ofs, const char *viewname)
{
SeqRenderData context = {0};
ImBuf *ibuf;
@@ -919,7 +921,7 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int
recty = (render_size * (float)scene->r.ysch) / 100.0f + 0.5f;
BKE_sequencer_new_render_data(
- bmain, scene,
+ bmain, depsgraph, scene,
rectx, recty, proxy_size, false,
&context);
context.view_id = BKE_scene_multiview_view_id_get(&scene->r, viewname);
@@ -976,7 +978,7 @@ static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scop
{
ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
ImBuf *scope;
-
+
IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings,
&scene->display_settings);
@@ -1091,6 +1093,7 @@ static void sequencer_draw_background(
void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs, bool draw_overlay, bool draw_backdrop)
{
struct Main *bmain = CTX_data_main(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
struct ImBuf *ibuf = NULL;
struct ImBuf *scope = NULL;
struct View2D *v2d = &ar->v2d;
@@ -1134,7 +1137,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
}
/* for now we only support Left/Right */
- ibuf = sequencer_ibuf_get(bmain, scene, sseq, cfra, frame_ofs, names[sseq->multiview_eye]);
+ ibuf = sequencer_ibuf_get(bmain, depsgraph, scene, sseq, cfra, frame_ofs, names[sseq->multiview_eye]);
if ((ibuf == NULL) ||
(ibuf->rect == NULL && ibuf->rect_float == NULL))
@@ -1482,7 +1485,7 @@ void drawprefetchseqspace(Scene *scene, ARegion *UNUSED(ar), SpaceSeq *sseq)
{
int rectx, recty;
int render_size = sseq->render_size;
- int proxy_size = 100.0;
+ int proxy_size = 100.0;
if (render_size == 0) {
render_size = scene->r.size;
}
@@ -1555,12 +1558,12 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
Sequence *last_seq = BKE_sequencer_active_get(scene);
int sel = 0, j;
float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
-
+
/* loop through twice, first unselected, then selected */
for (j = 0; j < 2; j++) {
Sequence *seq;
int outline_tint = (j) ? 40 : -40; /* highlighting around strip edges indicating selection */
-
+
/* loop through strips, checking for those that are visible */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
/* boundbox and selection tests for NOT drawing the strip... */
@@ -1570,15 +1573,15 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
else if (max_ii(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) continue;
else if (seq->machine + 1.0f < v2d->cur.ymin) continue;
else if (seq->machine > v2d->cur.ymax) continue;
-
+
/* strip passed all tests unscathed... so draw it now */
draw_seq_strip(C, sseq, scene, ar, seq, outline_tint, pixelx);
}
-
+
/* draw selected next time round */
sel = SELECT;
}
-
+
/* draw the last selected last (i.e. 'active' in other parts of Blender), removes some overlapping error */
if (last_seq)
draw_seq_strip(C, sseq, scene, ar, last_seq, 120, pixelx);
@@ -1611,7 +1614,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- /* draw darkened area outside of active timeline
+ /* draw darkened area outside of active timeline
* frame range used is preview range or scene range */
immUniformThemeColorShadeAlpha(TH_BACK, -25, -100);
@@ -1670,27 +1673,27 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
View2DScrollers *scrollers;
short unit = 0, cfra_flag = 0;
float col[3];
-
+
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
- if (ed && ed->metastack.first)
+ if (ed && ed->metastack.first)
glClearColor(col[0], col[1], col[2] - 0.1f, 0.0f);
- else
+ else
glClearColor(col[0], col[1], col[2], 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(v2d);
-
-
- /* calculate extents of sequencer strips/data
+
+
+ /* calculate extents of sequencer strips/data
* NOTE: needed for the scrollers later
*/
boundbox_seq(scene, &v2d->tot);
-
-
+
+
/* draw backdrop */
draw_seq_backdrop(v2d);
-
+
/* regular grid-pattern over the rest of the view (i.e. 1-second grid lines) */
UI_view2d_constant_grid_draw(v2d, FPS);
@@ -1699,29 +1702,29 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
draw_image_seq(C, scene, ar, sseq, scene->r.cfra, 0, false, true);
UI_view2d_view_ortho(v2d);
}
-
+
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
-
+
seq_draw_sfra_efra(scene, v2d);
/* sequence strips (if there is data available to be drawn) */
if (ed) {
/* draw the data */
draw_seq_strips(C, ed, ar);
-
+
/* text draw cached (for sequence names), in pixelspace now */
UI_view2d_text_cache_draw(ar);
}
-
+
/* current frame */
UI_view2d_view_ortho(v2d);
if ((sseq->flag & SEQ_DRAWFRAMES) == 0) cfra_flag |= DRAWCFRA_UNIT_SECONDS;
ANIM_draw_cfra(C, v2d, cfra_flag);
-
+
/* markers */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
ED_markers_draw(C, DRAW_MARKERS_LINES | DRAW_MARKERS_MARGIN);
-
+
/* preview range */
UI_view2d_view_ortho(v2d);
ANIM_draw_previewrange(C, v2d, 1);
@@ -1754,7 +1757,7 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_UNIT_VALUES, V2D_GRID_CLAMP);
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
-
+
/* draw current frame number-indicator on top of scrollers */
if ((sseq->flag & SEQ_NO_DRAW_CFRANUM) == 0) {
UI_view2d_view_orthoSpecial(ar, v2d, 1);
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index e200dffa308..b24817f2af8 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -128,8 +128,9 @@ typedef struct TransSeq {
/* ***************** proxy job manager ********************** */
typedef struct ProxyBuildJob {
- Scene *scene;
struct Main *main;
+ struct Depsgraph *depsgraph;
+ Scene *scene;
ListBase queue;
int stop;
} ProxyJob;
@@ -153,7 +154,7 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog
struct SeqIndexBuildContext *context = link->data;
BKE_sequencer_proxy_rebuild(context, stop, do_update, progress);
-
+
if (*stop) {
pj->stop = 1;
fprintf(stderr, "Canceling proxy rebuild on users request...\n");
@@ -181,12 +182,13 @@ static void seq_proxy_build_job(const bContext *C)
{
wmJob *wm_job;
ProxyJob *pj;
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
ScrArea *sa = CTX_wm_area(C);
Sequence *seq;
GSet *file_list;
-
+
if (ed == NULL) {
return;
}
@@ -198,7 +200,8 @@ static void seq_proxy_build_job(const bContext *C)
if (!pj) {
pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job");
-
+
+ pj->depsgraph = depsgraph;
pj->scene = scene;
pj->main = CTX_data_main(C);
@@ -211,13 +214,13 @@ static void seq_proxy_build_job(const bContext *C)
SEQP_BEGIN (ed, seq)
{
if ((seq->flag & SELECT)) {
- BKE_sequencer_proxy_rebuild_context(pj->main, pj->scene, seq, file_list, &pj->queue);
+ BKE_sequencer_proxy_rebuild_context(pj->main, pj->depsgraph, pj->scene, seq, file_list, &pj->queue);
}
}
SEQ_END
BLI_gset_free(file_list, MEM_freeN);
-
+
if (!WM_jobs_is_running(wm_job)) {
G.is_break = false;
WM_jobs_start(CTX_wm_manager(C), wm_job);
@@ -244,7 +247,7 @@ void boundbox_seq(Scene *scene, rctf *rect)
Editing *ed = BKE_sequencer_editing_get(scene, false);
float min[2], max[2];
-
+
if (ed == NULL) return;
min[0] = 0.0;
@@ -273,18 +276,18 @@ static int mouse_frame_side(View2D *v2d, short mouse_x, int frame)
{
int mval[2];
float mouseloc[2];
-
+
mval[0] = mouse_x;
mval[1] = 0;
-
+
/* choose the side based on which side of the playhead the mouse is on */
UI_view2d_region_to_view(v2d, mval[0], mval[1], &mouseloc[0], &mouseloc[1]);
-
+
return mouseloc[0] > frame ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT;
}
-Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int sel)
+Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int sel)
{
/* sel - 0==unselected, 1==selected, -1==done care*/
Sequence *seq;
@@ -293,7 +296,7 @@ Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int se
if (ed == NULL) return NULL;
if (sel > 0) sel = SELECT;
-
+
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if ((seq != test) &&
(test->machine == seq->machine) &&
@@ -316,16 +319,16 @@ Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int se
return NULL;
}
-static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, int sel)
+static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, int sel)
{
/* sel - 0==unselected, 1==selected, -1==done care*/
Sequence *seq, *best_seq = NULL;
Editing *ed = BKE_sequencer_editing_get(scene, false);
-
+
int dist, best_dist;
best_dist = MAXFRAME * 2;
-
+
if (ed == NULL) return NULL;
seq = ed->seqbasep->first;
@@ -336,7 +339,7 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i
((sel == -1) || (sel == (seq->flag & SELECT))))
{
dist = MAXFRAME * 2;
-
+
switch (lr) {
case SEQ_SIDE_LEFT:
if (seq->enddisp <= test->startdisp) {
@@ -349,7 +352,7 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i
}
break;
}
-
+
if (dist == 0) {
best_seq = seq;
break;
@@ -375,15 +378,15 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[
float displen;
*hand = SEQ_SIDE_NONE;
-
+
if (ed == NULL) return NULL;
-
+
pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
-
+
seq = ed->seqbasep->first;
-
+
while (seq) {
if (seq->machine == (int)y) {
/* check for both normal strips, and strips that have been flipped horizontally */
@@ -391,23 +394,23 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[
((seq->startdisp > seq->enddisp) && (seq->startdisp >= x && seq->enddisp <= x)) )
{
if (BKE_sequence_tx_test(seq)) {
-
+
/* clamp handles to defined size in pixel space */
-
+
handsize = seq->handsize;
displen = (float)abs(seq->startdisp - seq->enddisp);
-
+
if (displen / pixelx > 16) { /* don't even try to grab the handles of small strips */
/* Set the max value to handle to 1/3 of the total len when its less than 28.
* This is important because otherwise selecting handles happens even when you click in the middle */
-
+
if ((displen / 3) < 30 * pixelx) {
handsize = displen / 3;
}
else {
CLAMP(handsize, 7 * pixelx, 30 * pixelx);
}
-
+
if (handsize + seq->startdisp >= x)
*hand = SEQ_SIDE_LEFT;
else if (-handsize + seq->enddisp <= x)
@@ -445,7 +448,7 @@ void ED_sequencer_deselect_all(Scene *scene)
Sequence *seq;
Editing *ed = BKE_sequencer_editing_get(scene, false);
-
+
if (ed == NULL) return;
SEQP_BEGIN (ed, seq)
@@ -453,7 +456,7 @@ void ED_sequencer_deselect_all(Scene *scene)
seq->flag &= ~SEQ_ALLSEL;
}
SEQ_END
-
+
}
void recurs_sel_seq(Sequence *seqm)
@@ -518,7 +521,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen
{
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq1 = NULL, *seq2 = NULL, *seq3 = NULL, *seq;
-
+
*error_str = NULL;
if (!activeseq)
@@ -549,7 +552,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen
seq2 = seq3;
seq3 = tmp;
}
-
+
switch (BKE_sequence_effect_get_num_inputs(type)) {
case 0:
@@ -571,12 +574,12 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen
if (seq3 == NULL) seq3 = seq2;
break;
}
-
+
if (seq1 == NULL && seq2 == NULL && seq3 == NULL) {
*error_str = N_("TODO: in what cases does this happen?");
return 0;
}
-
+
*selseq1 = seq1;
*selseq2 = seq2;
*selseq3 = seq3;
@@ -688,7 +691,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, int cutframe)
/* First Strip! */
/* strips with extended stillfames before */
-
+
/* Precaution, needed because the length saved on-disk may not match the length saved in the blend file,
* or our code may have minor differences reading file length between versions.
* This causes hard-cut to fail, see: T47862 */
@@ -730,7 +733,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, int cutframe)
skip_dup = true;
}
}
-
+
BKE_sequence_reload_new_file(scene, seq, false);
BKE_sequence_calc(scene, seq);
@@ -738,7 +741,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, int cutframe)
/* Duplicate AFTER the first change */
seqn = BKE_sequence_dupli_recursive(scene, scene, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
}
-
+
if (seqn) {
seqn->flag |= SELECT;
@@ -840,14 +843,14 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, int cutframe)
skip_dup = true;
}
}
-
+
BKE_sequence_calc(scene, seq);
if (!skip_dup) {
/* Duplicate AFTER the first change */
seqn = BKE_sequence_dupli_recursive(scene, scene, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
}
-
+
if (seqn) {
seqn->flag |= SELECT;
@@ -889,7 +892,7 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, int cutframe)
/* like duplicate, but only duplicate and cut overlapping strips,
- * strips to the left of the cutframe are ignored and strips to the right
+ * strips to the left of the cutframe are ignored and strips to the right
* are moved to the end of slist
* we have to work on the same slist (not using a separate list), since
* otherwise dupli_seq can't check for duplicate names properly and
@@ -901,14 +904,14 @@ static bool cut_seq_list(Scene *scene, ListBase *slist, int cutframe,
{
Sequence *seq, *seq_next_iter;
Sequence *seq_first_new = NULL;
-
+
seq = slist->first;
while (seq && seq != seq_first_new) {
seq_next_iter = seq->next; /* we need this because we may remove seq */
seq->tmp = NULL;
if (seq->flag & SELECT) {
- if (cutframe > seq->startdisp &&
+ if (cutframe > seq->startdisp &&
cutframe < seq->enddisp)
{
Sequence *seqn = cut_seq(scene, seq, cutframe);
@@ -946,7 +949,7 @@ static bool sequence_offset_after_frame(Scene *scene, const int delta, const int
TimeMarker *marker;
/* all strips >= cfra are shifted */
-
+
if (ed == NULL) return 0;
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
@@ -974,7 +977,7 @@ static void set_filter_seq(Scene *scene)
Sequence *seq;
Editing *ed = BKE_sequencer_editing_get(scene, false);
-
+
if (ed == NULL) return;
if (okee("Set Deinterlace") == 0) return;
@@ -999,32 +1002,32 @@ static void UNUSED_FUNCTION(seq_remap_paths) (Scene *scene)
Sequence *seq, *last_seq = BKE_sequencer_active_get(scene);
Editing *ed = BKE_sequencer_editing_get(scene, false);
char from[FILE_MAX], to[FILE_MAX], stripped[FILE_MAX];
-
-
+
+
if (last_seq == NULL)
return;
-
+
BLI_strncpy(from, last_seq->strip->dir, sizeof(from));
// XXX if (0 == sbutton(from, 0, sizeof(from) - 1, "From: "))
// return;
-
+
BLI_strncpy(to, from, sizeof(to));
// XXX if (0 == sbutton(to, 0, sizeof(to) - 1, "To: "))
// return;
-
+
if (STREQ(to, from))
return;
-
+
SEQP_BEGIN (ed, seq)
{
if (seq->flag & SELECT) {
if (STREQLEN(seq->strip->dir, from, strlen(from))) {
printf("found %s\n", seq->strip->dir);
-
+
/* strip off the beginning */
stripped[0] = 0;
BLI_strncpy(stripped, seq->strip->dir + strlen(from), FILE_MAX);
-
+
/* new path */
BLI_snprintf(seq->strip->dir, sizeof(seq->strip->dir), "%s%s", to, stripped);
printf("new %s\n", seq->strip->dir);
@@ -1032,7 +1035,7 @@ static void UNUSED_FUNCTION(seq_remap_paths) (Scene *scene)
}
}
SEQ_END
-
+
}
@@ -1048,7 +1051,7 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op)
boundbox_seq(scene, &rectf);
sfra = (int)rectf.xmin;
efra = (int)rectf.xmax;
-
+
/* first check if the current frame has a gap already */
for (cfra = CFRA; cfra >= sfra; cfra--) {
if (BKE_sequencer_evaluate_frame(scene, cfra)) {
@@ -1073,7 +1076,7 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op)
}
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -1085,15 +1088,15 @@ void SEQUENCER_OT_gap_remove(struct wmOperatorType *ot)
ot->name = "Remove Gaps";
ot->idname = "SEQUENCER_OT_gap_remove";
ot->description = "Remove gap at current frame to first strip at the right, independent of selection or locked state of strips";
-
+
/* api callbacks */
// ot->invoke = sequencer_snap_invoke;
ot->exec = sequencer_gap_remove_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_boolean(ot->srna, "all", 0, "All Gaps", "Do all gaps to right of current frame");
}
@@ -1101,13 +1104,13 @@ static int sequencer_gap_insert_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
int frames = RNA_int_get(op->ptr, "frames");
-
+
sequence_offset_after_frame(scene, frames, CFRA);
-
+
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
+
return OPERATOR_FINISHED;
-
+
}
void SEQUENCER_OT_gap_insert(struct wmOperatorType *ot)
@@ -1116,15 +1119,15 @@ void SEQUENCER_OT_gap_insert(struct wmOperatorType *ot)
ot->name = "Insert Gaps";
ot->idname = "SEQUENCER_OT_gap_insert";
ot->description = "Insert gap at current frame to first strips at the right, independent of selection or locked state of strips";
-
+
/* api callbacks */
// ot->invoke = sequencer_snap_invoke;
ot->exec = sequencer_gap_insert_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_int(ot->srna, "frames", 10, 0, INT_MAX, "Frames", "Frames to insert after current strip", 0, 1000);
}
@@ -1136,7 +1139,7 @@ static int seq_get_snaplimit(View2D *v2d)
* a bit lazy but its only done once pre transform */
float xmouse, ymouse, x;
int mval[2] = {24, 0}; /* 24 screen px snap */
-
+
UI_view2d_region_to_view(v2d, mval[0], mval[1], &xmouse, &ymouse);
x = xmouse;
mval[0] = 0;
@@ -1189,7 +1192,7 @@ int sequencer_view_strips_poll(bContext *C)
static int sequencer_snap_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
-
+
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq;
int snap_frame;
@@ -1231,31 +1234,31 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op)
}
}
else if (seq->type & SEQ_TYPE_EFFECT) {
- if (seq->seq1 && (seq->seq1->flag & SELECT))
+ if (seq->seq1 && (seq->seq1->flag & SELECT))
BKE_sequence_calc(scene, seq);
- else if (seq->seq2 && (seq->seq2->flag & SELECT))
+ else if (seq->seq2 && (seq->seq2->flag & SELECT))
BKE_sequence_calc(scene, seq);
- else if (seq->seq3 && (seq->seq3->flag & SELECT))
+ else if (seq->seq3 && (seq->seq3->flag & SELECT))
BKE_sequence_calc(scene, seq);
}
}
/* as last: */
BKE_sequencer_sort(scene);
-
+
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
+
return OPERATOR_FINISHED;
}
static int sequencer_snap_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
Scene *scene = CTX_data_scene(C);
-
+
int snap_frame;
-
+
snap_frame = CFRA;
-
+
RNA_int_set(op->ptr, "frame", snap_frame);
return sequencer_snap_exec(C, op);
}
@@ -1266,15 +1269,15 @@ void SEQUENCER_OT_snap(struct wmOperatorType *ot)
ot->name = "Snap Strips to Frame";
ot->idname = "SEQUENCER_OT_snap";
ot->description = "Frame where selected strips will be snapped";
-
+
/* api callbacks */
ot->invoke = sequencer_snap_invoke;
ot->exec = sequencer_snap_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_int(ot->srna, "frame", 0, INT_MIN, INT_MAX, "Frame", "Frame where selected strips will be snapped", INT_MIN, INT_MAX);
}
@@ -1705,7 +1708,7 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op)
bool selected;
selected = !RNA_boolean_get(op->ptr, "unselected");
-
+
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if ((seq->flag & SEQ_LOCK) == 0) {
if (selected) { /* mute unselected */
@@ -1722,10 +1725,10 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op)
}
}
}
-
+
BKE_sequencer_update_muting(ed);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -1735,14 +1738,14 @@ void SEQUENCER_OT_mute(struct wmOperatorType *ot)
ot->name = "Mute Strips";
ot->idname = "SEQUENCER_OT_mute";
ot->description = "Mute (un)selected strips";
-
+
/* api callbacks */
ot->exec = sequencer_mute_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Mute unselected rather than selected strips");
}
@@ -1756,7 +1759,7 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op)
bool selected;
selected = !RNA_boolean_get(op->ptr, "unselected");
-
+
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if ((seq->flag & SEQ_LOCK) == 0) {
if (selected) { /* unmute unselected */
@@ -1773,10 +1776,10 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op)
}
}
}
-
+
BKE_sequencer_update_muting(ed);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -1786,14 +1789,14 @@ void SEQUENCER_OT_unmute(struct wmOperatorType *ot)
ot->name = "Un-Mute Strips";
ot->idname = "SEQUENCER_OT_unmute";
ot->description = "Unmute (un)selected strips";
-
+
/* api callbacks */
ot->exec = sequencer_unmute_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Unmute unselected rather than selected strips");
}
@@ -1822,11 +1825,11 @@ void SEQUENCER_OT_lock(struct wmOperatorType *ot)
ot->name = "Lock Strips";
ot->idname = "SEQUENCER_OT_lock";
ot->description = "Lock the active strip so that it can't be transformed";
-
+
/* api callbacks */
ot->exec = sequencer_lock_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1855,11 +1858,11 @@ void SEQUENCER_OT_unlock(struct wmOperatorType *ot)
ot->name = "UnLock Strips";
ot->idname = "SEQUENCER_OT_unlock";
ot->description = "Unlock the active strip so that it can't be transformed";
-
+
/* api callbacks */
ot->exec = sequencer_unlock_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1897,11 +1900,11 @@ void SEQUENCER_OT_reload(struct wmOperatorType *ot)
ot->name = "Reload Strips";
ot->idname = "SEQUENCER_OT_reload";
ot->description = "Reload strips in the sequencer";
-
+
/* api callbacks */
ot->exec = sequencer_reload_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER; /* no undo, the data changed is stored outside 'main' */
@@ -1937,7 +1940,7 @@ void SEQUENCER_OT_refresh_all(struct wmOperatorType *ot)
ot->name = "Refresh Sequencer";
ot->idname = "SEQUENCER_OT_refresh_all";
ot->description = "Refresh the sequencer editor";
-
+
/* api callbacks */
ot->exec = sequencer_refresh_all_exec;
ot->poll = sequencer_refresh_all_poll;
@@ -2058,14 +2061,14 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op)
cut_frame = RNA_int_get(op->ptr, "frame");
cut_hard = RNA_enum_get(op->ptr, "type");
cut_side = RNA_enum_get(op->ptr, "side");
-
+
if (cut_hard == SEQ_CUT_HARD) {
changed = cut_seq_list(scene, ed->seqbasep, cut_frame, cut_seq_hard);
}
else {
changed = cut_seq_list(scene, ed->seqbasep, cut_frame, cut_seq_soft);
}
-
+
if (changed) { /* got new strips ? */
Sequence *seq;
@@ -2118,7 +2121,7 @@ static int sequencer_cut_invoke(bContext *C, wmOperator *op, const wmEvent *even
if (ED_operator_sequencer_active(C) && v2d)
cut_side = mouse_frame_side(v2d, event->mval[0], cut_frame);
-
+
RNA_int_set(op->ptr, "frame", cut_frame);
RNA_enum_set(op->ptr, "side", cut_side);
/*RNA_enum_set(op->ptr, "type", cut_hard); */ /*This type is set from the key shortcut */
@@ -2133,15 +2136,15 @@ void SEQUENCER_OT_cut(struct wmOperatorType *ot)
ot->name = "Cut Strips";
ot->idname = "SEQUENCER_OT_cut";
ot->description = "Cut the selected strips";
-
+
/* api callbacks */
ot->invoke = sequencer_cut_invoke;
ot->exec = sequencer_cut_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_int(ot->srna, "frame", 0, INT_MIN, INT_MAX, "Frame", "Frame where selected strips will be cut", INT_MIN, INT_MAX);
RNA_def_enum(ot->srna, "type", prop_cut_types, SEQ_CUT_SOFT, "Type", "The type of cut operation to perform on strips");
RNA_def_enum(ot->srna, "side", prop_side_types, SEQ_SIDE_BOTH, "Side", "The side that remains selected after cutting");
@@ -2193,14 +2196,14 @@ void SEQUENCER_OT_duplicate(wmOperatorType *ot)
ot->name = "Duplicate Strips";
ot->idname = "SEQUENCER_OT_duplicate";
ot->description = "Duplicate the selected strips";
-
+
/* api callbacks */
ot->exec = sequencer_add_duplicate_exec;
ot->poll = ED_operator_sequencer_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* to give to transform */
RNA_def_enum(ot->srna, "mode", rna_enum_transform_mode_types, TFM_TRANSLATION, "Mode", "");
}
@@ -2261,7 +2264,7 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op))
}
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -2287,12 +2290,12 @@ void SEQUENCER_OT_delete(wmOperatorType *ot)
ot->name = "Erase Strips";
ot->idname = "SEQUENCER_OT_delete";
ot->description = "Erase selected strips from the sequencer";
-
+
/* api callbacks */
ot->invoke = sequencer_delete_invoke;
ot->exec = sequencer_delete_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2355,7 +2358,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
-
+
Sequence *seq, *seq_new;
Strip *strip_new;
StripElem *se, *se_new;
@@ -2425,7 +2428,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
/* as last: */
BKE_sequencer_sort(scene);
-
+
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
@@ -2438,12 +2441,12 @@ void SEQUENCER_OT_images_separate(wmOperatorType *ot)
ot->name = "Separate Images";
ot->idname = "SEQUENCER_OT_images_separate";
ot->description = "On image sequence strips, it returns a strip for each image";
-
+
/* api callbacks */
ot->exec = sequencer_separate_images_exec;
ot->invoke = WM_operator_props_popup_confirm;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -2529,11 +2532,11 @@ void SEQUENCER_OT_meta_toggle(wmOperatorType *ot)
ot->name = "Toggle Meta Strip";
ot->idname = "SEQUENCER_OT_meta_toggle";
ot->description = "Toggle a metastrip (to edit enclosed strips)";
-
+
/* api callbacks */
ot->exec = sequencer_meta_toggle_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2544,7 +2547,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
-
+
Sequence *seq, *seqm, *next, *last_seq = BKE_sequencer_active_get(scene);
int channel_max = 1;
@@ -2576,7 +2579,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
seqm->strip = MEM_callocN(sizeof(Strip), "metastrip");
seqm->strip->us = 1;
-
+
BKE_sequencer_active_set(scene, seqm);
if (BKE_sequence_test_overlap(ed->seqbasep, seqm) ) BKE_sequence_base_shuffle(ed->seqbasep, seqm, scene);
@@ -2596,11 +2599,11 @@ void SEQUENCER_OT_meta_make(wmOperatorType *ot)
ot->name = "Make Meta Strip";
ot->idname = "SEQUENCER_OT_meta_make";
ot->description = "Group selected strips into a metastrip";
-
+
/* api callbacks */
ot->exec = sequencer_meta_make_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2669,11 +2672,11 @@ void SEQUENCER_OT_meta_separate(wmOperatorType *ot)
ot->name = "UnMeta Strip";
ot->idname = "SEQUENCER_OT_meta_separate";
ot->description = "Put the contents of a metastrip back in the sequencer";
-
+
/* api callbacks */
ot->exec = sequencer_meta_separate_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2695,11 +2698,11 @@ void SEQUENCER_OT_view_all(wmOperatorType *ot)
ot->name = "View All";
ot->idname = "SEQUENCER_OT_view_all";
ot->description = "View all the strips in the sequencer";
-
+
/* api callbacks */
ot->exec = sequencer_view_all_exec;
ot->poll = ED_operator_sequencer_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER;
}
@@ -2708,7 +2711,7 @@ static int sequencer_view_frame_exec(bContext *C, wmOperator *op)
{
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
ANIM_center_frame(C, smooth_viewtx);
-
+
return OPERATOR_FINISHED;
}
@@ -2718,11 +2721,11 @@ void SEQUENCER_OT_view_frame(wmOperatorType *ot)
ot->name = "View Frame";
ot->idname = "SEQUENCER_OT_view_frame";
ot->description = "Reset viewable area to show range around current frame";
-
+
/* api callbacks */
ot->exec = sequencer_view_frame_exec;
ot->poll = ED_operator_sequencer_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2742,7 +2745,7 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op))
v2d->cur = v2d->tot;
UI_view2d_curRect_validate(v2d);
UI_view2d_sync(sc, area, v2d, V2D_LOCK_COPY);
-
+
#if 0
/* Like zooming on an image view */
float zoomX, zoomY;
@@ -2784,11 +2787,11 @@ void SEQUENCER_OT_view_all_preview(wmOperatorType *ot)
ot->name = "View All";
ot->idname = "SEQUENCER_OT_view_all_preview";
ot->description = "Zoom preview to fit in the area";
-
+
/* api callbacks */
ot->exec = sequencer_view_all_preview_exec;
ot->poll = ED_operator_sequencer_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER;
}
@@ -2859,11 +2862,11 @@ void SEQUENCER_OT_view_toggle(wmOperatorType *ot)
ot->name = "View Toggle";
ot->idname = "SEQUENCER_OT_view_toggle";
ot->description = "Toggle between sequencer views (sequence, preview, both)";
-
+
/* api callbacks */
ot->exec = sequencer_view_toggle_exec;
ot->poll = ED_operator_sequencer_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER;
}
@@ -2904,7 +2907,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *op)
if (ymax != 0) {
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
-
+
xmax += xmargin;
xmin -= xmargin;
ymax += ymargin;
@@ -2933,7 +2936,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *op)
else {
return OPERATOR_CANCELLED;
}
-
+
}
void SEQUENCER_OT_view_selected(wmOperatorType *ot)
@@ -2942,11 +2945,11 @@ void SEQUENCER_OT_view_selected(wmOperatorType *ot)
ot->name = "View Selected";
ot->idname = "SEQUENCER_OT_view_selected";
ot->description = "Zoom the sequencer on the selected strips";
-
+
/* api callbacks */
ot->exec = sequencer_view_selected_exec;
ot->poll = ED_operator_sequencer_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER;
}
@@ -2958,7 +2961,7 @@ static bool strip_jump_internal(Scene *scene,
bool changed = false;
int cfra = CFRA;
int nfra = BKE_sequencer_find_next_prev_edit(scene, cfra, side, do_skip_mute, do_center, false);
-
+
if (nfra != cfra) {
CFRA = nfra;
changed = true;
@@ -2989,7 +2992,7 @@ static int sequencer_strip_jump_exec(bContext *C, wmOperator *op)
}
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -3006,7 +3009,7 @@ void SEQUENCER_OT_strip_jump(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "next", true, "Next Strip", "");
RNA_def_boolean(ot->srna, "center", true, "Use strip center", "");
@@ -3058,9 +3061,9 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op)
if (active_seq == NULL) return OPERATOR_CANCELLED;
seq = find_next_prev_sequence(scene, active_seq, side, -1);
-
+
if (seq) {
-
+
/* disallow effect strips */
if (BKE_sequence_effect_get_num_inputs(seq->type) >= 1 && (seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3))
return OPERATOR_CANCELLED;
@@ -3068,10 +3071,10 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
switch (side) {
- case SEQ_SIDE_LEFT:
+ case SEQ_SIDE_LEFT:
swap_sequence(scene, seq, active_seq);
break;
- case SEQ_SIDE_RIGHT:
+ case SEQ_SIDE_RIGHT:
swap_sequence(scene, active_seq, seq);
break;
}
@@ -3111,14 +3114,14 @@ void SEQUENCER_OT_swap(wmOperatorType *ot)
ot->name = "Swap Strip";
ot->idname = "SEQUENCER_OT_swap";
ot->description = "Swap active strip with strip to the right or left";
-
+
/* api callbacks */
ot->exec = sequencer_swap_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_enum(ot->srna, "side", prop_side_lr_types, SEQ_SIDE_RIGHT, "Side", "Side of the strip to swap");
}
@@ -3170,14 +3173,14 @@ void SEQUENCER_OT_rendersize(wmOperatorType *ot)
ot->name = "Set Render Size";
ot->idname = "SEQUENCER_OT_rendersize";
ot->description = "Set render size and aspect from active sequence";
-
+
/* api callbacks */
ot->exec = sequencer_rendersize_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
}
@@ -3456,17 +3459,18 @@ static int sequencer_rebuild_proxy_invoke(bContext *C, wmOperator *UNUSED(op),
static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq;
GSet *file_list;
-
+
if (ed == NULL) {
return OPERATOR_CANCELLED;
}
file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list");
-
+
SEQP_BEGIN(ed, seq)
{
if ((seq->flag & SELECT)) {
@@ -3475,7 +3479,7 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
short stop = 0, do_update;
float progress;
- BKE_sequencer_proxy_rebuild_context(bmain, scene, seq, file_list, &queue);
+ BKE_sequencer_proxy_rebuild_context(bmain, depsgraph, scene, seq, file_list, &queue);
for (link = queue.first; link; link = link->next) {
struct SeqIndexBuildContext *context = link->data;
@@ -3488,7 +3492,7 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
SEQ_END
BLI_gset_free(file_list, MEM_freeN);
-
+
return OPERATOR_FINISHED;
}
@@ -3498,11 +3502,11 @@ void SEQUENCER_OT_rebuild_proxy(wmOperatorType *ot)
ot->name = "Rebuild Proxy and Timecode Indices";
ot->idname = "SEQUENCER_OT_rebuild_proxy";
ot->description = "Rebuild all selected proxies and timecode indices using the job system";
-
+
/* api callbacks */
ot->invoke = sequencer_rebuild_proxy_invoke;
ot->exec = sequencer_rebuild_proxy_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER;
}
@@ -3539,27 +3543,27 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op)
if (proxy_25)
seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_25;
- else
+ else
seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_25;
-
+
if (proxy_50)
seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_50;
- else
+ else
seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_50;
-
+
if (proxy_75)
seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_75;
- else
+ else
seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_75;
-
+
if (proxy_100)
seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_100;
- else
+ else
seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_100;
-
+
if (!overwrite)
seq->strip->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING;
- else
+ else
seq->strip->proxy->build_flags &= ~SEQ_PROXY_SKIP_EXISTING;
}
}
@@ -3567,7 +3571,7 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op)
SEQ_END
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -3577,14 +3581,14 @@ void SEQUENCER_OT_enable_proxies(wmOperatorType *ot)
ot->name = "Set Selected Strip Proxies";
ot->idname = "SEQUENCER_OT_enable_proxies";
ot->description = "Enable selected proxies on all selected Movie strips";
-
+
/* api callbacks */
ot->invoke = sequencer_enable_proxies_invoke;
ot->exec = sequencer_enable_proxies_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER;
-
+
RNA_def_boolean(ot->srna, "proxy_25", false, "25%", "");
RNA_def_boolean(ot->srna, "proxy_50", false, "50%", "");
RNA_def_boolean(ot->srna, "proxy_75", false, "75%", "");
@@ -3749,7 +3753,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op)
/* TODO, shouldn't this already be relative from the filesel?
* (as the 'filepath' is) for now just make relative here,
* but look into changing after 2.60 - campbell */
- BLI_path_rel(directory, bmain->name);
+ BLI_path_rel(directory, BKE_main_blendfile_path(bmain));
}
BLI_strncpy(seq->strip->dir, directory, sizeof(seq->strip->dir));
@@ -3861,13 +3865,14 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot)
static int sequencer_export_subtitles_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
+ Main *bmain = CTX_data_main(C);
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
char filepath[FILE_MAX];
- if (G.main->name[0] == 0)
+ if (BKE_main_blendfile_path(bmain)[0] == '\0')
BLI_strncpy(filepath, "untitled", sizeof(filepath));
else
- BLI_strncpy(filepath, G.main->name, sizeof(filepath));
+ BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath));
BLI_replace_extension(filepath, sizeof(filepath), ".srt");
RNA_string_set(op->ptr, "filepath", filepath);
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index de7c46cc02c..41fc98fbe4e 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation, Campbell Barton
*
* ***** END GPL LICENSE BLOCK *****
@@ -63,7 +63,7 @@ void sequencer_special_update_set(Sequence *seq);
/* UNUSED */
// void seq_reset_imageofs(struct SpaceSeq *sseq);
-struct ImBuf *sequencer_ibuf_get(struct Main *bmain, struct Scene *scene, struct SpaceSeq *sseq, int cfra, int frame_ofs, const char *viewname);
+struct ImBuf *sequencer_ibuf_get(struct Main *bmain, struct Depsgraph *depsgraph, struct Scene *scene, struct SpaceSeq *sseq, int cfra, int frame_ofs, const char *viewname);
/* sequencer_edit.c */
struct View2D;
@@ -174,7 +174,7 @@ enum {
SEQ_SELECT_LR_NONE = 0,
SEQ_SELECT_LR_MOUSE,
SEQ_SELECT_LR_LEFT,
- SEQ_SELECT_LR_RIGHT
+ SEQ_SELECT_LR_RIGHT
};
/* defines used internally */
diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c
index a3cfcae77b8..234989ef244 100644
--- a/source/blender/editors/space_sequencer/sequencer_ops.c
+++ b/source/blender/editors/space_sequencer/sequencer_ops.c
@@ -68,7 +68,7 @@ void sequencer_operatortypes(void)
WM_operatortype_append(SEQUENCER_OT_meta_toggle);
WM_operatortype_append(SEQUENCER_OT_meta_make);
WM_operatortype_append(SEQUENCER_OT_meta_separate);
-
+
WM_operatortype_append(SEQUENCER_OT_gap_remove);
WM_operatortype_append(SEQUENCER_OT_gap_insert);
WM_operatortype_append(SEQUENCER_OT_snap);
@@ -135,7 +135,7 @@ void sequencer_keymap(wmKeyConfig *keyconf)
{
wmKeyMap *keymap;
wmKeyMapItem *kmi;
-
+
/* Common items ------------------------------------------------------------------ */
keymap = WM_keymap_find(keyconf, "SequencerCommon", SPACE_SEQ, 0);
@@ -228,7 +228,7 @@ void sequencer_keymap(wmKeyConfig *keyconf)
RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_gap_remove", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "all", false);
RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_gap_remove", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "all", true);
WM_keymap_add_item(keymap, "SEQUENCER_OT_gap_insert", EQUALKEY, KM_PRESS, KM_SHIFT, 0);
-
+
WM_keymap_add_item(keymap, "SEQUENCER_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_swap_inputs", SKEY, KM_PRESS, KM_ALT, 0);
diff --git a/source/blender/editors/space_sequencer/sequencer_preview.c b/source/blender/editors/space_sequencer/sequencer_preview.c
index 3f908dc7096..c58c05b67c0 100644
--- a/source/blender/editors/space_sequencer/sequencer_preview.c
+++ b/source/blender/editors/space_sequencer/sequencer_preview.c
@@ -80,11 +80,11 @@ static void preview_startjob(void *data, short *stop, short *do_update, float *p
BLI_mutex_lock(pj->mutex);
previewjb = pj->previews.first;
BLI_mutex_unlock(pj->mutex);
-
+
while (previewjb) {
PreviewJobAudio *preview_next;
bSound *sound = previewjb->sound;
-
+
BKE_sound_read_waveform(sound, stop);
if (*stop || G.is_break) {
@@ -98,12 +98,12 @@ static void preview_startjob(void *data, short *stop, short *do_update, float *p
BLI_spin_lock(sound->spinlock);
sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING;
BLI_spin_unlock(sound->spinlock);
-
+
BLI_mutex_lock(pj->mutex);
previewjb = previewjb->next;
BLI_mutex_unlock(pj->mutex);
}
-
+
BLI_mutex_lock(pj->mutex);
BLI_freelistN(&pj->previews);
pj->total = 0;
@@ -111,12 +111,12 @@ static void preview_startjob(void *data, short *stop, short *do_update, float *p
BLI_mutex_unlock(pj->mutex);
break;
}
-
+
BLI_mutex_lock(pj->mutex);
preview_next = previewjb->next;
BLI_freelinkN(&pj->previews, previewjb);
previewjb = preview_next;
- pj->processed++;
+ pj->processed++;
*progress = (pj->total > 0) ? (float)pj->processed / (float)pj->total : 1.0f;
*do_update = true;
BLI_mutex_unlock(pj->mutex);
@@ -145,19 +145,19 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq)
if (!pj) {
pj = MEM_callocN(sizeof(PreviewJob), "preview rebuild job");
-
+
pj->mutex = BLI_mutex_alloc();
pj->scene = CTX_data_scene(C);
-
+
WM_jobs_customdata_set(wm_job, pj, free_preview_job);
WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER);
WM_jobs_callbacks(wm_job, preview_startjob, NULL, NULL, preview_endjob);
}
-
+
/* attempt to lock mutex of job here */
-
+
audiojob->sound = seq->sound;
-
+
BLI_mutex_lock(pj->mutex);
BLI_addtail(&pj->previews, audiojob);
pj->total++;
@@ -168,5 +168,5 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq)
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(sa);
}
diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c
index 8c57089f7ab..00811d68251 100644
--- a/source/blender/editors/space_sequencer/sequencer_scopes.c
+++ b/source/blender/editors/space_sequencer/sequencer_scopes.c
@@ -160,7 +160,7 @@ static ImBuf *make_waveform_view_from_ibuf_byte(ImBuf *ibuf)
wform_put_grid(tgt, w, h);
wform_put_border(tgt, w, h);
-
+
for (x = 0; x < 256; x++) {
wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, waveform_gamma) * 255);
}
@@ -229,7 +229,7 @@ static ImBuf *make_waveform_view_from_ibuf_float(ImBuf *ibuf)
}
wform_put_border(tgt, w, h);
-
+
return rval;
}
@@ -285,7 +285,7 @@ static ImBuf *make_sep_waveform_view_from_ibuf_byte(ImBuf *ibuf)
}
wform_put_border(tgt, w, h);
-
+
return rval;
}
@@ -334,7 +334,7 @@ static ImBuf *make_sep_waveform_view_from_ibuf_float(ImBuf *ibuf)
}
wform_put_border(tgt, w, h);
-
+
return rval;
}
@@ -542,7 +542,7 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf)
}
wform_put_border((unsigned char *) rval->rect, rval->x, rval->y);
-
+
return rval;
}
@@ -610,7 +610,7 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
if (bins[2][x] > nb)
nb = bins[2][x];
}
-
+
for (x = 0; x < HIS_STEPS; x++) {
if (nr) {
draw_histogram_bar(rval, x + 1, ((float) bins[0][x]) / nr, 0);
@@ -622,11 +622,11 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
draw_histogram_bar(rval, x + 1, ((float) bins[2][x]) / nb, 2);
}
}
-
+
draw_histogram_marker(rval, get_bin_float(0.0));
draw_histogram_marker(rval, get_bin_float(1.0));
wform_put_border((unsigned char *) rval->rect, rval->x, rval->y);
-
+
return rval;
}
@@ -653,7 +653,7 @@ static void vectorscope_put_cross(unsigned char r, unsigned char g, unsigned ch
rgb[1] = (float)g / 255.0f;
rgb[2] = (float)b / 255.0f;
rgb_to_yuv_normalized(rgb, yuv);
-
+
p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) +
(int) ((yuv[1] * (w - 3) + 1)));
@@ -698,12 +698,12 @@ static ImBuf *make_vectorscope_view_from_ibuf_byte(ImBuf *ibuf)
for (x = 0; x < ibuf->x; x++) {
const char *src1 = src + 4 * (ibuf->x * y + x);
char *p;
-
+
rgb[0] = (float)src1[0] / 255.0f;
rgb[1] = (float)src1[1] / 255.0f;
rgb[2] = (float)src1[2] / 255.0f;
rgb_to_yuv_normalized(rgb, yuv);
-
+
p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) +
(int) ((yuv[1] * (w - 3) + 1)));
scope_put_pixel(wtable, (unsigned char *)p);
@@ -744,7 +744,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf)
for (x = 0; x < ibuf->x; x++) {
const float *src1 = src + 4 * (ibuf->x * y + x);
const char *p;
-
+
memcpy(rgb, src1, 3 * sizeof(float));
CLAMP(rgb[0], 0.0f, 1.0f);
@@ -752,7 +752,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf)
CLAMP(rgb[2], 0.0f, 1.0f);
rgb_to_yuv_normalized(rgb, yuv);
-
+
p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) +
(int) ((yuv[1] * (w - 3) + 1)));
scope_put_pixel(wtable, (unsigned char *)p);
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index 90a369760ac..d7206a6da4e 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -59,11 +59,11 @@ static void *find_nearest_marker(int UNUSED(d1), int UNUSED(d2))
{
return NULL;
}
-
+
static void select_surrounding_handles(Scene *scene, Sequence *test) /* XXX BRING BACK */
{
Sequence *neighbor;
-
+
neighbor = find_neighboring_sequence(scene, test, SEQ_SIDE_LEFT, -1);
if (neighbor) {
/* Only select neighbor handle if matching handle from test seq is also selected, or if neighbor
@@ -152,10 +152,10 @@ static void select_linked_time(ListBase *seqbase, Sequence *seq_link)
void select_surround_from_last(Scene *scene)
{
Sequence *seq = get_last_seq(scene);
-
+
if (seq == NULL)
return;
-
+
select_surrounding_handles(scene, seq);
}
#endif
@@ -163,7 +163,7 @@ void select_surround_from_last(Scene *scene)
void ED_sequencer_select_sequence_single(Scene *scene, Sequence *seq, bool deselect_all)
{
Editing *ed = BKE_sequencer_editing_get(scene, false);
-
+
if (deselect_all)
ED_sequencer_deselect_all(scene);
@@ -264,11 +264,11 @@ void SEQUENCER_OT_select_all(struct wmOperatorType *ot)
ot->name = "(De)select All";
ot->idname = "SEQUENCER_OT_select_all";
ot->description = "Select or deselect all strips";
-
+
/* api callbacks */
ot->exec = sequencer_de_select_all_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -294,7 +294,7 @@ static int sequencer_select_inverse_exec(bContext *C, wmOperator *UNUSED(op))
}
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -304,11 +304,11 @@ void SEQUENCER_OT_select_inverse(struct wmOperatorType *ot)
ot->name = "Select Inverse";
ot->idname = "SEQUENCER_OT_select_inverse";
ot->description = "Select unselected strips";
-
+
/* api callbacks */
ot->exec = sequencer_select_inverse_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -322,16 +322,16 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
const bool linked_handle = RNA_boolean_get(op->ptr, "linked_handle");
const bool linked_time = RNA_boolean_get(op->ptr, "linked_time");
int left_right = RNA_enum_get(op->ptr, "left_right");
-
+
Sequence *seq, *neighbor, *act_orig;
int hand, sel_side;
TimeMarker *marker;
if (ed == NULL)
return OPERATOR_CANCELLED;
-
+
marker = find_nearest_marker(SCE_MARKERS, 1); //XXX - dummy function for now
-
+
seq = find_nearest_seq(scene, v2d, &hand, event->mval);
// XXX - not nice, Ctrl+RMB needs to do left_right only when not over a strip
@@ -353,13 +353,13 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
/* deselect_markers(0, 0); */ /* XXX, in 2.4x, seq selection used to deselect all, need to re-thnik this for 2.5 */
marker->flag |= SELECT;
}
-
+
}
else if (left_right != SEQ_SELECT_LR_NONE) {
/* use different logic for this */
float x;
ED_sequencer_deselect_all(scene);
-
+
switch (left_right) {
case SEQ_SELECT_LR_MOUSE:
x = UI_view2d_region_to_view_x(v2d, event->mval[0]);
@@ -372,7 +372,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
x = CFRA;
break;
}
-
+
SEQP_BEGIN (ed, seq)
{
if (((x < CFRA) && (seq->enddisp <= CFRA)) ||
@@ -408,10 +408,10 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
if (extend == 0 && linked_handle == 0)
ED_sequencer_deselect_all(scene);
-
+
if (seq) {
BKE_sequencer_active_set(scene, seq);
-
+
if ((seq->type == SEQ_TYPE_IMAGE) || (seq->type == SEQ_TYPE_MOVIE)) {
if (seq->strip) {
BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR);
@@ -422,7 +422,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR);
}
}
-
+
/* On Alt selection, select the strip and bordering handles */
if (linked_handle) {
if (!ELEM(hand, SEQ_SIDE_LEFT, SEQ_SIDE_RIGHT)) {
@@ -521,7 +521,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
}
}
}
-
+
/* marker transform */
#if 0 // XXX probably need to redo this differently for 2.5
if (marker) {
@@ -529,7 +529,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
// getmouseco_areawin(mval);
xo = mval[0];
yo = mval[1];
-
+
while (get_mbut()) {
// getmouseco_areawin(mval);
if (abs(mval[0] - xo) + abs(mval[1] - yo) > 4) {
@@ -539,7 +539,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
}
}
#endif
-
+
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
/* allowing tweaks */
@@ -555,19 +555,19 @@ void SEQUENCER_OT_select(wmOperatorType *ot)
{SEQ_SELECT_LR_RIGHT, "RIGHT", 0, "Right", "Select right"},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "Activate/Select";
ot->idname = "SEQUENCER_OT_select";
ot->description = "Select a strip (last selected becomes the \"active strip\")";
-
+
/* api callbacks */
ot->invoke = sequencer_select_invoke;
ot->poll = ED_operator_sequencer_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
RNA_def_boolean(ot->srna, "linked_handle", 0, "Linked Handle", "Select handles next to the active strip");
@@ -584,10 +584,10 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li
Sequence *seq, *neighbor;
bool changed = false;
int isel;
-
+
if (ed == NULL)
return changed;
-
+
if (sel) {
sel = SELECT;
isel = 0;
@@ -596,14 +596,14 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li
sel = 0;
isel = SELECT;
}
-
+
if (!linked) {
/* if not linked we only want to touch each seq once, newseq */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
seq->tmp = NULL;
}
}
-
+
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if ((seq->flag & SELECT) == sel) {
if (linked || (seq->tmp == NULL)) {
@@ -639,7 +639,7 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li
}
}
}
-
+
return changed;
}
@@ -649,12 +649,12 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li
static int sequencer_select_more_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
-
+
if (!select_more_less_seq__internal(scene, true, false))
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -664,14 +664,14 @@ void SEQUENCER_OT_select_more(wmOperatorType *ot)
ot->name = "Select More";
ot->idname = "SEQUENCER_OT_select_more";
ot->description = "Select more strips adjacent to the current selection";
-
+
/* api callbacks */
ot->exec = sequencer_select_more_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
}
@@ -680,12 +680,12 @@ void SEQUENCER_OT_select_more(wmOperatorType *ot)
static int sequencer_select_less_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
-
+
if (!select_more_less_seq__internal(scene, false, false))
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -695,14 +695,14 @@ void SEQUENCER_OT_select_less(wmOperatorType *ot)
ot->name = "Select Less";
ot->idname = "SEQUENCER_OT_select_less";
ot->description = "Shrink the current selection of adjacent selected strips";
-
+
/* api callbacks */
ot->exec = sequencer_select_less_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
}
@@ -712,9 +712,9 @@ static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, cons
{
Scene *scene = CTX_data_scene(C);
View2D *v2d = UI_view2d_fromcontext(C);
-
+
bool extend = RNA_boolean_get(op->ptr, "extend");
-
+
Sequence *mouse_seq;
int selected, hand;
@@ -722,20 +722,20 @@ static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, cons
mouse_seq = find_nearest_seq(scene, v2d, &hand, event->mval);
if (!mouse_seq)
return OPERATOR_FINISHED; /* user error as with mesh?? */
-
+
if (extend == 0)
ED_sequencer_deselect_all(scene);
-
+
mouse_seq->flag |= SELECT;
recurs_sel_seq(mouse_seq);
-
+
selected = 1;
while (selected) {
selected = select_more_less_seq__internal(scene, 1, 1);
}
-
+
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -745,14 +745,14 @@ void SEQUENCER_OT_select_linked_pick(wmOperatorType *ot)
ot->name = "Select Pick Linked";
ot->idname = "SEQUENCER_OT_select_linked_pick";
ot->description = "Select a chain of linked strips nearest to the mouse pointer";
-
+
/* api callbacks */
ot->invoke = sequencer_select_linked_pick_invoke;
ot->poll = ED_operator_sequencer_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
}
@@ -780,14 +780,14 @@ void SEQUENCER_OT_select_linked(wmOperatorType *ot)
ot->name = "Select Linked";
ot->idname = "SEQUENCER_OT_select_linked";
ot->description = "Select all strips adjacent to the current selection";
-
+
/* api callbacks */
ot->exec = sequencer_select_linked_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
}
@@ -830,14 +830,14 @@ void SEQUENCER_OT_select_handles(wmOperatorType *ot)
ot->name = "Select Handles";
ot->idname = "SEQUENCER_OT_select_handles";
ot->description = "Select manipulator handles on the sides of the selected strip";
-
+
/* api callbacks */
ot->exec = sequencer_select_handles_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_enum(ot->srna, "side", prop_side_types, SEQ_SIDE_BOTH, "Side", "The side of the handle that is selected");
}
@@ -867,7 +867,7 @@ void SEQUENCER_OT_select_active_side(wmOperatorType *ot)
ot->name = "Select Active Side";
ot->idname = "SEQUENCER_OT_select_active_side";
ot->description = "Select strips on the nominated side of the active strip";
-
+
/* api callbacks */
ot->exec = sequencer_select_active_side_exec;
ot->poll = sequencer_edit_poll;
@@ -886,7 +886,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
View2D *v2d = UI_view2d_fromcontext(C);
-
+
Sequence *seq;
rctf rectf, rq;
const bool select = !RNA_boolean_get(op->ptr, "deselect");
@@ -900,7 +900,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op)
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
seq_rectf(seq, &rq);
-
+
if (BLI_rctf_isect(&rq, &rectf, NULL)) {
if (select) seq->flag |= SELECT;
else seq->flag &= ~SEQ_ALLSEL;
@@ -915,7 +915,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
return OPERATOR_FINISHED;
-}
+}
/* ****** Border Select ****** */
@@ -925,18 +925,18 @@ void SEQUENCER_OT_select_border(wmOperatorType *ot)
ot->name = "Border Select";
ot->idname = "SEQUENCER_OT_select_border";
ot->description = "Select strips using border selection";
-
+
/* api callbacks */
ot->invoke = WM_gesture_border_invoke;
ot->exec = sequencer_borderselect_exec;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
-
+
ot->poll = ED_operator_sequencer_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* rna */
WM_operator_properties_gesture_border_select(ot);
}
@@ -1267,15 +1267,15 @@ void SEQUENCER_OT_select_grouped(wmOperatorType *ot)
ot->name = "Select Grouped";
ot->description = "Select all strips grouped by various properties";
ot->idname = "SEQUENCER_OT_select_grouped";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = sequencer_select_grouped_exec;
ot->poll = sequencer_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", sequencer_prop_select_grouped_types, 0, "Type", "");
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first");
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c
index 4d6ea865b40..88dcc3a8821 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -91,13 +91,14 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
{
Main *bmain = CTX_data_main(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
SpaceSeq *sseq = (SpaceSeq *) CTX_wm_space_data(C);
ARegion *ar = CTX_wm_region(C);
- ImBuf *ibuf = sequencer_ibuf_get(bmain, scene, sseq, CFRA, 0, NULL);
+ ImBuf *ibuf = sequencer_ibuf_get(bmain, depsgraph, scene, sseq, CFRA, 0, NULL);
ImageSampleInfo *info = op->customdata;
float fx, fy;
-
+
if (ibuf == NULL) {
IMB_freeImBuf(ibuf);
info->draw = 0;
@@ -121,7 +122,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
info->colp = NULL;
info->colfp = NULL;
-
+
if (ibuf->rect) {
cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 6774a253dc3..75734963a0e 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -82,28 +82,28 @@ ARegion *sequencer_has_buttons_region(ScrArea *sa)
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
if (ar) return ar;
-
+
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
/* is error! */
if (ar == NULL) return NULL;
-
+
arnew = MEM_callocN(sizeof(ARegion), "buttons for sequencer");
-
+
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
arnew->regiontype = RGN_TYPE_UI;
arnew->alignment = RGN_ALIGN_RIGHT;
-
+
arnew->flag = RGN_FLAG_HIDDEN;
-
+
return arnew;
}
static ARegion *sequencer_find_region(ScrArea *sa, short type)
{
ARegion *ar = NULL;
-
+
for (ar = sa->regionbase.first; ar; ar = ar->next)
if (ar->regiontype == type)
return ar;
@@ -117,7 +117,7 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene)
{
ARegion *ar;
SpaceSeq *sseq;
-
+
sseq = MEM_callocN(sizeof(SpaceSeq), "initsequencer");
sseq->spacetype = SPACE_SEQ;
sseq->chanshown = 0;
@@ -127,19 +127,19 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene)
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for sequencer");
-
+
BLI_addtail(&sseq->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_TOP;
-
+
/* buttons/list view */
ar = MEM_callocN(sizeof(ARegion), "buttons for sequencer");
-
+
BLI_addtail(&sseq->regionbase, ar);
ar->regiontype = RGN_TYPE_UI;
ar->alignment = RGN_ALIGN_RIGHT;
ar->flag = RGN_FLAG_HIDDEN;
-
+
/* preview region */
/* NOTE: if you change values here, also change them in sequencer_init_preview_region */
ar = MEM_callocN(sizeof(ARegion), "preview region for sequencer");
@@ -166,26 +166,26 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene)
/* main region */
ar = MEM_callocN(sizeof(ARegion), "main region for sequencer");
-
+
BLI_addtail(&sseq->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
-
-
+
+
/* seq space goes from (0,8) to (0, efra) */
-
+
ar->v2d.tot.xmin = 0.0f;
ar->v2d.tot.ymin = 0.0f;
ar->v2d.tot.xmax = scene->r.efra;
ar->v2d.tot.ymax = 8.0f;
-
+
ar->v2d.cur = ar->v2d.tot;
-
+
ar->v2d.min[0] = 10.0f;
ar->v2d.min[1] = 0.5f;
-
+
ar->v2d.max[0] = MAXFRAMEF;
ar->v2d.max[1] = MAXSEQ;
-
+
ar->v2d.minzoom = 0.01f;
ar->v2d.maxzoom = 100.0f;
@@ -200,7 +200,7 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene)
/* not spacelink itself */
static void sequencer_free(SpaceLink *sl)
-{
+{
SpaceSeq *sseq = (SpaceSeq *) sl;
SequencerScopes *scopes = &sseq->scopes;
@@ -226,7 +226,7 @@ static void sequencer_free(SpaceLink *sl)
/* spacetype; init callback */
static void sequencer_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
{
-
+
}
static void sequencer_refresh(const bContext *C, ScrArea *sa)
@@ -330,7 +330,7 @@ static void sequencer_refresh(const bContext *C, ScrArea *sa)
static SpaceLink *sequencer_duplicate(SpaceLink *sl)
{
SpaceSeq *sseqn = MEM_dupallocN(sl);
-
+
/* clear or remove stuff from old */
// XXX sseq->gpd = gpencil_data_duplicate(sseq->gpd, false);
@@ -418,7 +418,7 @@ static void sequencer_drop_copy(wmDrag *drag, wmDropBox *drop)
char dir[FILE_MAX], file[FILE_MAX];
BLI_split_dirfile(drag->path, dir, file, sizeof(dir), sizeof(file));
-
+
RNA_string_set(drop->ptr, "directory", dir);
RNA_collection_clear(drop->ptr, "files");
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index e47a7113883..5885312e255 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -66,17 +66,17 @@ static SpaceLink *text_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen
{
ARegion *ar;
SpaceText *stext;
-
+
stext = MEM_callocN(sizeof(SpaceText), "inittext");
stext->spacetype = SPACE_TEXT;
stext->lheight = 12;
stext->tabnumber = 4;
stext->margin_column = 80;
-
+
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for text");
-
+
BLI_addtail(&stext->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_TOP;
@@ -91,18 +91,18 @@ static SpaceLink *text_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen
/* main region */
ar = MEM_callocN(sizeof(ARegion), "main region for text");
-
+
BLI_addtail(&stext->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
-
+
return (SpaceLink *)stext;
}
/* not spacelink itself */
static void text_free(SpaceLink *sl)
-{
+{
SpaceText *stext = (SpaceText *) sl;
-
+
stext->text = NULL;
text_free_caches(stext);
}
@@ -205,7 +205,7 @@ static void text_operatortypes(void)
WM_operatortype_append(TEXT_OT_select_line);
WM_operatortype_append(TEXT_OT_select_all);
WM_operatortype_append(TEXT_OT_select_word);
-
+
WM_operatortype_append(TEXT_OT_move_lines);
WM_operatortype_append(TEXT_OT_jump);
@@ -231,7 +231,7 @@ static void text_operatortypes(void)
WM_operatortype_append(TEXT_OT_replace_set_selected);
WM_operatortype_append(TEXT_OT_start_find);
-
+
WM_operatortype_append(TEXT_OT_to_3d_object);
WM_operatortype_append(TEXT_OT_resolve_conflict);
@@ -243,7 +243,7 @@ static void text_keymap(struct wmKeyConfig *keyconf)
{
wmKeyMap *keymap;
wmKeyMapItem *kmi;
-
+
keymap = WM_keymap_find(keyconf, "Text Generic", SPACE_TEXT, 0);
WM_keymap_add_item(keymap, "TEXT_OT_start_find", FKEY, KM_PRESS, KM_CTRL, 0);
#ifdef __APPLE__
@@ -255,7 +255,7 @@ static void text_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "TEXT_OT_properties", TKEY, KM_PRESS, KM_CTRL, 0);
keymap = WM_keymap_find(keyconf, "Text", SPACE_TEXT, 0);
-
+
#ifdef __APPLE__
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", LEFTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_BEGIN);
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", RIGHTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_END);
@@ -263,30 +263,30 @@ static void text_keymap(struct wmKeyConfig *keyconf)
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "type", NEXT_WORD);
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", UPARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", FILE_TOP);
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", DOWNARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", FILE_BOTTOM);
-
+
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0)->ptr, "type", LINE_BEGIN);
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0)->ptr, "type", LINE_END);
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0)->ptr, "type", PREV_WORD);
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0)->ptr, "type", NEXT_WORD);
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", UPARROWKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0)->ptr, "type", FILE_TOP);
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", DOWNARROWKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0)->ptr, "type", FILE_BOTTOM);
-
+
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_ALT, 0)->ptr, "type", DEL_PREV_WORD);
-
+
WM_keymap_add_item(keymap, "TEXT_OT_save", SKEY, KM_PRESS, KM_ALT | KM_OSKEY, 0);
WM_keymap_add_item(keymap, "TEXT_OT_save_as", SKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_OSKEY, 0);
WM_keymap_add_item(keymap, "TEXT_OT_cut", XKEY, KM_PRESS, KM_OSKEY, 0);
- WM_keymap_add_item(keymap, "TEXT_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0);
+ WM_keymap_add_item(keymap, "TEXT_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0);
WM_keymap_add_item(keymap, "TEXT_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0);
WM_keymap_add_item(keymap, "TEXT_OT_find_set_selected", EKEY, KM_PRESS, KM_OSKEY, 0);
WM_keymap_add_item(keymap, "TEXT_OT_select_all", AKEY, KM_PRESS, KM_OSKEY, 0);
WM_keymap_add_item(keymap, "TEXT_OT_select_line", AKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0);
#endif
-
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
RNA_boolean_set(kmi->ptr, "reverse", false);
-
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
RNA_boolean_set(kmi->ptr, "reverse", true);
@@ -294,7 +294,7 @@ static void text_keymap(struct wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
RNA_boolean_set(kmi->ptr, "reverse", false);
-
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", PADMINUS, KM_PRESS, KM_CTRL, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
RNA_boolean_set(kmi->ptr, "reverse", true);
@@ -306,7 +306,7 @@ static void text_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "TEXT_OT_save_as", SKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_CTRL, 0);
WM_keymap_add_item(keymap, "TEXT_OT_run_script", PKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_item(keymap, "TEXT_OT_cut", XKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "TEXT_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "TEXT_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
@@ -314,7 +314,7 @@ static void text_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "TEXT_OT_cut", DELKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "TEXT_OT_copy", INSERTKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "TEXT_OT_paste", INSERTKEY, KM_PRESS, KM_SHIFT, 0);
-
+
WM_keymap_add_item(keymap, "TEXT_OT_duplicate_line", DKEY, KM_PRESS, KM_CTRL, 0);
if (U.uiflag & USER_MMB_PASTE) { // XXX not dynamic
@@ -328,14 +328,14 @@ static void text_keymap(struct wmKeyConfig *keyconf)
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_lines", UPARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0)->ptr, "direction", TXT_MOVE_LINE_UP);
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_lines", DOWNARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0)->ptr, "direction", TXT_MOVE_LINE_DOWN);
-
+
WM_keymap_add_item(keymap, "TEXT_OT_indent", TABKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "TEXT_OT_unindent", TABKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "TEXT_OT_uncomment", DKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", HOMEKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_BEGIN);
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", ENDKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_END);
-
+
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", EKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", LINE_END);
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", EKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "type", LINE_END);
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_CHAR);
@@ -367,7 +367,7 @@ static void text_keymap(struct wmKeyConfig *keyconf)
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", DEL_PREV_CHAR); /* same as above [#26623] */
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", DELKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_WORD);
RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_PREV_WORD);
-
+
WM_keymap_add_item(keymap, "TEXT_OT_overwrite_toggle", INSERTKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "TEXT_OT_scroll_bar", LEFTMOUSE, KM_PRESS, 0, 0);
@@ -388,7 +388,7 @@ static void text_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_menu(keymap, "TEXT_MT_toolbox", RIGHTMOUSE, KM_PRESS, KM_ANY, 0);
WM_keymap_add_item(keymap, "TEXT_OT_autocomplete", SPACEKEY, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "TEXT_OT_line_number", KM_TEXTINPUT, KM_ANY, KM_ANY, 0);
WM_keymap_add_item(keymap, "TEXT_OT_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); // last!
}
@@ -418,18 +418,18 @@ static void text_main_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
ListBase *lb;
-
+
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
-
+
/* own keymap */
keymap = WM_keymap_find(wm->defaultconf, "Text Generic", SPACE_TEXT, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
keymap = WM_keymap_find(wm->defaultconf, "Text", SPACE_TEXT, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
-
+
/* add drop boxes */
lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
-
+
WM_event_add_dropbox_handler(&ar->handlers, lb);
}
@@ -438,19 +438,19 @@ static void text_main_region_draw(const bContext *C, ARegion *ar)
/* draw entirely, view changes should be handled here */
SpaceText *st = CTX_wm_space_text(C);
//View2D *v2d = &ar->v2d;
-
+
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
glClear(GL_COLOR_BUFFER_BIT);
-
+
// UI_view2d_view_ortho(v2d);
-
+
/* data... */
draw_text_main(st, ar);
-
+
/* reset view matrix */
// UI_view2d_view_restore(C);
-
+
/* scrollers? */
}
@@ -510,7 +510,7 @@ static void text_drop_paste(wmDrag *drag, wmDropBox *drop)
static void text_dropboxes(void)
{
ListBase *lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
-
+
WM_dropbox_add(lb, "TEXT_OT_open", text_drop_poll, text_drop_copy);
WM_dropbox_add(lb, "TEXT_OT_insert", text_drop_paste_poll, text_drop_paste);
}
@@ -550,9 +550,9 @@ static void text_properties_region_init(wmWindowManager *wm, ARegion *ar)
static void text_properties_region_draw(const bContext *C, ARegion *ar)
{
SpaceText *st = CTX_wm_space_text(C);
-
+
ED_region_panels(C, ar, NULL, -1, true);
-
+
/* this flag trick is make sure buttons have been added already */
if (st->flags & ST_FIND_ACTIVATE) {
if (UI_textbutton_activate_rna(C, ar, st, "find_text")) {
@@ -585,10 +585,10 @@ void ED_spacetype_text(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype text");
ARegionType *art;
-
+
st->spaceid = SPACE_TEXT;
strncpy(st->name, "Text", BKE_ST_MAXNAME);
-
+
st->new = text_new;
st->free = text_free;
st->init = text_init;
@@ -609,13 +609,13 @@ void ED_spacetype_text(void)
art->event_cursor = true;
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: properties */
art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
art->regionid = RGN_TYPE_UI;
art->prefsizex = UI_COMPACT_PANEL_WIDTH;
art->keymapflag = ED_KEYMAP_UI;
-
+
art->init = text_properties_region_init;
art->draw = text_properties_region_draw;
BLI_addhead(&st->regiontypes, art);
@@ -625,7 +625,7 @@ void ED_spacetype_text(void)
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
-
+
art->init = text_header_region_init;
art->draw = text_header_region_draw;
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 3949aa928c9..c1b49fbd32a 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -113,7 +113,7 @@ static int text_font_draw_character_utf8(const TextDrawContext *tdc, int x, int
#if 0
/* Formats every line of the current text */
-static void txt_format_text(SpaceText *st)
+static void txt_format_text(SpaceText *st)
{
TextLine *linep;
@@ -170,7 +170,7 @@ static void format_draw_color(const TextDrawContext *tdc, char formatchar)
* view_width The maximum number of characters displayable in the region
* This equals region_width/font_width for the region
* wrap_chars Characters that allow wrapping. This equals [' ', '\t', '-']
- *
+ *
* def wrap(line, view_width, wrap_chars):
* draw_start = 0
* draw_end = view_width
@@ -184,14 +184,14 @@ static void format_draw_color(const TextDrawContext *tdc, char formatchar)
* draw_end = pos+1
* pos += 1
* print line[draw_start:]
- *
+ *
*/
int wrap_width(const SpaceText *st, ARegion *ar)
{
int winx = ar->winx - TXT_SCROLL_WIDTH;
int x, max;
-
+
x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
max = st->cwidth ? (winx - x) / st->cwidth : 0;
return max > 8 ? max : 8;
@@ -358,7 +358,7 @@ void wrap_offset_in_line(const SpaceText *st, ARegion *ar, TextLine *linein, int
int text_get_char_pos(const SpaceText *st, const char *line, int cur)
{
int a = 0, i;
-
+
for (i = 0; i < cur && line[i]; i += BLI_str_utf8_size_safe(line + i)) {
if (line[i] == '\t')
a += st->tabnumber - a % st->tabnumber;
@@ -407,11 +407,11 @@ static int text_draw_wrapped(
if (max < 8) max = 8;
basex = x;
lines = 1;
-
+
fpos = fstart = 0; mstart = 0;
mend = txt_utf8_forward_columns(str, max, &padding) - str;
end = wrap = max - padding;
-
+
for (i = 0, mi = 0; str[mi]; i += columns, mi += BLI_str_utf8_size_safe(str + mi)) {
columns = BLI_str_utf8_char_width_safe(str + mi);
if (i + columns > end) {
@@ -659,7 +659,7 @@ void text_drawcache_tag_update(SpaceText *st, int full)
/* this happens if text editor ops are caled from python */
if (st == NULL)
return;
-
+
if (st->drawcache) {
DrawCache *drawcache = (DrawCache *)st->drawcache;
Text *txt = st->text;
@@ -808,17 +808,17 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back)
back->xmax = ar->winx;
back->ymin = 0;
back->ymax = ar->winy;
-
+
scroll->xmin = ar->winx - V2D_SCROLL_WIDTH;
scroll->xmax = ar->winx - 5;
scroll->ymin = 4;
scroll->ymax = 4 + pix_available;
-
+
/* when re-sizing a view-port with the bar at the bottom to a greater height more blank lines will be added */
if (ltexth + blank_lines < st->top + st->viewlines) {
blank_lines = st->top + st->viewlines - ltexth;
}
-
+
ltexth += blank_lines;
barheight = (ltexth > 0) ? (st->viewlines * pix_available) / ltexth : 0;
@@ -895,7 +895,7 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back)
if (hlend - hlstart < 2) {
hlend = hlstart + 2;
}
-
+
st->txtscroll = *scroll;
st->txtscroll.ymax = ar->winy - pix_top_margin - hlstart;
st->txtscroll.ymin = ar->winy - pix_top_margin - hlend;
@@ -937,10 +937,10 @@ static void draw_documentation(const SpaceText *st, ARegion *ar)
char *docs, buf[DOC_WIDTH + 1], *p;
int i, br, lines;
int boxw, boxh, l, x, y /* , top */ /* UNUSED */;
-
+
if (!st || !st->text) return;
if (!texttool_text_is_active(st->text)) return;
-
+
docs = texttool_docs_get();
if (!docs) return;
@@ -950,7 +950,7 @@ static void draw_documentation(const SpaceText *st, ARegion *ar)
/* Count the visible lines to the cursor */
for (tmp = st->text->curl, l = -st->top; tmp; tmp = tmp->prev, l++) ;
if (l < 0) return;
-
+
if (st->showlinenrs) {
x = st->cwidth * (st->text->curc - st->left) + TXT_OFFSET + TEXTXLOC - 4;
}
@@ -1031,7 +1031,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
int w, boxw = 0, boxh, i, x, y, *top;
const int lheight = st->lheight_dpi + TXT_LINE_SPACING;
const int margin_x = 2;
-
+
if (!st->text) return;
if (!texttool_text_is_active(st->text)) return;
@@ -1058,7 +1058,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
boxw = SUGG_LIST_WIDTH * st->cwidth + 20;
boxh = SUGG_LIST_SIZE * lheight + 8;
-
+
if (x + boxw > ar->winx)
x = MAX2(0, ar->winx - boxw);
@@ -1086,7 +1086,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
BLI_strncpy(str, item->name, len + 1);
w = st->cwidth * text_get_char_pos(st, str, len);
-
+
if (item == sel) {
unsigned int posi = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -1247,7 +1247,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
Text *text = st->text;
int b, fc, find, stack, viewc, viewl, offl, offc, x, y;
int startc, endc, c;
-
+
char ch;
// showsyntax must be on or else the format string will be null
@@ -1266,7 +1266,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
endc = -1;
find = -b;
stack = 0;
-
+
/* Don't highlight backets if syntax HL is off or bracket in string or comment. */
if (!linep->format || linep->format[fc] == FMT_TYPE_STRING || linep->format[fc] == FMT_TYPE_COMMENT)
return;
@@ -1391,7 +1391,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
const int clip_min_y = -(int)(st->lheight_dpi - 1);
st->viewlines = (st->lheight_dpi) ? (int)(ar->winy - clip_min_y) / (st->lheight_dpi + TXT_LINE_SPACING) : 0;
-
+
text_draw_context_init(st, &tdc);
text_update_drawcache(st, ar);
@@ -1399,7 +1399,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
/* make sure all the positional pointers exist */
if (!text->curl || !text->sell || !text->lines.first || !text->lines.last)
txt_clean_text(text);
-
+
/* update rects for scroll */
calc_text_rcts(st, ar, &scroll, &back); /* scroll will hold the entire bar size */
@@ -1454,7 +1454,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
}
y = ar->winy - st->lheight_dpi;
winx = ar->winx - TXT_SCROLL_WIDTH;
-
+
/* draw cursor, margin, selection and highlight */
draw_text_decoration(st, ar);
@@ -1493,13 +1493,13 @@ void draw_text_main(SpaceText *st, ARegion *ar)
text_draw(st, &tdc, tmp->line, st->left, ar->winx / st->cwidth, x, y, tmp->format);
y -= st->lheight_dpi + TXT_LINE_SPACING;
}
-
+
wrap_skip = 0;
}
-
+
if (st->flags & ST_SHOW_MARGIN) {
margin_column_x = x + st->cwidth * (st->margin_column - st->left);
-
+
if (margin_column_x >= x) {
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
@@ -1527,7 +1527,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
draw_textscroll(st, &scroll, &back);
/* draw_documentation(st, ar); - No longer supported */
draw_suggestion_list(st, &tdc, ar);
-
+
text_font_end(&tdc);
}
@@ -1578,7 +1578,7 @@ void text_scroll_to_cursor(SpaceText *st, ARegion *ar, const bool center)
st->top = i;
}
}
-
+
if (st->wordwrap) {
st->left = 0;
}
diff --git a/source/blender/editors/space_text/text_format.c b/source/blender/editors/space_text/text_format.c
index 0133122c5a3..b64eefe969b 100644
--- a/source/blender/editors/space_text/text_format.c
+++ b/source/blender/editors/space_text/text_format.c
@@ -216,7 +216,7 @@ TextFormatType *ED_text_format_get(Text *text)
}
}
- /* If we make it here we never found an extension that worked - return
+ /* If we make it here we never found an extension that worked - return
* the "default" text format */
return tft_lb.first;
}
diff --git a/source/blender/editors/space_text/text_format.h b/source/blender/editors/space_text/text_format.h
index d7cf31d0b41..5912dc2402c 100644
--- a/source/blender/editors/space_text/text_format.h
+++ b/source/blender/editors/space_text/text_format.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/space_text/text_format_lua.c b/source/blender/editors/space_text/text_format_lua.c
index 1e842729ab3..8b6ec2d804b 100644
--- a/source/blender/editors/space_text/text_format_lua.c
+++ b/source/blender/editors/space_text/text_format_lua.c
@@ -34,8 +34,8 @@
/* *** Lua Keywords (for format_line) *** */
-/* Checks the specified source string for a Lua keyword (minus boolean & 'nil').
- * This name must start at the beginning of the source string and must be
+/* Checks the specified source string for a Lua keyword (minus boolean & 'nil').
+ * This name must start at the beginning of the source string and must be
* followed by a non-identifier (see text_check_identifier(char)) or null char.
*
* If a keyword is found, the length of the matching word is returned.
@@ -75,13 +75,13 @@ static int txtfmt_lua_find_keyword(const char *string)
return i;
}
-/* Checks the specified source string for a Lua special name/function. This
- * name must start at the beginning of the source string and must be followed
+/* Checks the specified source string for a Lua special name/function. This
+ * name must start at the beginning of the source string and must be followed
* by a non-identifier (see text_check_identifier(char)) or null character.
*
* If a special name is found, the length of the matching name is returned.
- * Otherwise, -1 is returned.
- *
+ * Otherwise, -1 is returned.
+ *
* See:
* http://www.lua.org/manual/5.1/manual.html#5.1
*/
diff --git a/source/blender/editors/space_text/text_format_osl.c b/source/blender/editors/space_text/text_format_osl.c
index 97dc1be3b9a..2daaaa348e6 100644
--- a/source/blender/editors/space_text/text_format_osl.c
+++ b/source/blender/editors/space_text/text_format_osl.c
@@ -132,7 +132,7 @@ static int txtfmt_osl_find_reserved(const char *string)
static int txtfmt_osl_find_specialvar(const char *string)
{
int i, len;
-
+
/* OSL shader types */
if (STR_LITERAL_STARTSWITH(string, "shader", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "surface", len)) i = len;
diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c
index e06a5b5474e..50a8739c5b4 100644
--- a/source/blender/editors/space_text/text_header.c
+++ b/source/blender/editors/space_text/text_header.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -54,21 +54,21 @@ static ARegion *text_has_properties_region(ScrArea *sa)
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
if (ar) return ar;
-
+
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
/* is error! */
if (ar == NULL) return NULL;
-
+
arnew = MEM_callocN(sizeof(ARegion), "properties region");
-
+
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
arnew->regiontype = RGN_TYPE_UI;
arnew->alignment = RGN_ALIGN_LEFT;
-
+
arnew->flag = RGN_FLAG_HIDDEN;
-
+
return arnew;
}
@@ -81,7 +81,7 @@ static int text_properties_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = text_has_properties_region(sa);
-
+
if (ar)
ED_region_toggle_hidden(C, ar);
@@ -94,7 +94,7 @@ void TEXT_OT_properties(wmOperatorType *ot)
ot->name = "Properties";
ot->description = "Toggle the properties region visibility";
ot->idname = "TEXT_OT_properties";
-
+
/* api callbacks */
ot->exec = text_properties_exec;
ot->poll = text_properties_poll;
@@ -105,15 +105,15 @@ static int text_text_search_exec(bContext *C, wmOperator *UNUSED(op))
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = text_has_properties_region(sa);
SpaceText *st = CTX_wm_space_text(C);
-
+
if (ar) {
if (ar->flag & RGN_FLAG_HIDDEN)
ED_region_toggle_hidden(C, ar);
-
+
/* cannot send a button activate yet for case when region wasn't visible yet */
/* flag gets checked and cleared in main draw callback */
st->flags |= ST_FIND_ACTIVATE;
-
+
ED_region_tag_redraw(ar);
}
return OPERATOR_FINISHED;
@@ -126,7 +126,7 @@ void TEXT_OT_start_find(wmOperatorType *ot)
ot->name = "Find";
ot->description = "Start searching text";
ot->idname = "TEXT_OT_start_find";
-
+
/* api callbacks */
ot->exec = text_text_search_exec;
ot->poll = text_properties_poll;
diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h
index 3129c1bfc85..bc902135b50 100644
--- a/source/blender/editors/space_text/text_intern.h
+++ b/source/blender/editors/space_text/text_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 2ce699aa6e2..b3815d73c5c 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -124,7 +124,7 @@ static int text_region_edit_poll(bContext *C)
if (!st || !text)
return 0;
-
+
if (!ar || ar->regiontype != RGN_TYPE_WINDOW)
return 0;
@@ -198,11 +198,11 @@ void TEXT_OT_new(wmOperatorType *ot)
ot->name = "Create Text Block";
ot->idname = "TEXT_OT_new";
ot->description = "Create a new text data-block";
-
+
/* api callbacks */
ot->exec = text_new_exec;
ot->poll = text_new_poll;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
}
@@ -234,7 +234,7 @@ static int text_open_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", str);
- text = BKE_text_load_ex(bmain, str, G.main->name, internal);
+ text = BKE_text_load_ex(bmain, str, BKE_main_blendfile_path(bmain), internal);
if (!text) {
if (op->customdata) MEM_freeN(op->customdata);
@@ -247,15 +247,15 @@ static int text_open_exec(bContext *C, wmOperator *op)
/* hook into UI */
pprop = op->customdata;
+ id_us_ensure_real(&text->id);
+
if (pprop->prop) {
- id_us_ensure_real(&text->id);
RNA_id_pointer_create(&text->id, &idptr);
RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr);
RNA_property_update(C, &pprop->ptr, pprop->prop);
}
else if (st) {
st->text = text;
- id_us_ensure_real(&text->id);
st->left = 0;
st->top = 0;
st->scroll_accum[0] = 0.0f;
@@ -272,15 +272,16 @@ static int text_open_exec(bContext *C, wmOperator *op)
static int text_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
+ Main *bmain = CTX_data_main(C);
Text *text = CTX_data_edit_text(C);
- const char *path = (text && text->name) ? text->name : G.main->name;
+ const char *path = (text && text->name) ? text->name : BKE_main_blendfile_path(bmain);
if (RNA_struct_property_is_set(op->ptr, "filepath"))
return text_open_exec(C, op);
-
+
text_open_init(C, op);
RNA_string_set(op->ptr, "filepath", path);
- WM_event_add_fileselect(C, op);
+ WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
}
@@ -300,7 +301,7 @@ void TEXT_OT_open(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_UNDO;
-
+
/* properties */
WM_operator_properties_filesel(
ot, FILE_TYPE_FOLDER | FILE_TYPE_TEXT | FILE_TYPE_PYSCRIPT, FILE_SPECIAL, FILE_OPENFILE,
@@ -351,7 +352,7 @@ void TEXT_OT_reload(wmOperatorType *ot)
ot->name = "Reload";
ot->idname = "TEXT_OT_reload";
ot->description = "Reload active text data-block from its file";
-
+
/* api callbacks */
ot->exec = text_reload_exec;
ot->invoke = WM_operator_confirm;
@@ -400,12 +401,12 @@ void TEXT_OT_unlink(wmOperatorType *ot)
ot->name = "Unlink";
ot->idname = "TEXT_OT_unlink";
ot->description = "Unlink active text data-block";
-
+
/* api callbacks */
ot->exec = text_unlink_exec;
ot->invoke = WM_operator_confirm;
ot->poll = text_unlink_poll;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
}
@@ -439,7 +440,7 @@ void TEXT_OT_make_internal(wmOperatorType *ot)
/* api callbacks */
ot->exec = text_make_internal_exec;
ot->poll = text_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
}
@@ -452,20 +453,20 @@ static int text_save_poll(bContext *C)
if (!text_edit_poll(C))
return 0;
-
+
return (text->name != NULL && !(text->flags & TXT_ISMEM));
}
-static void txt_write_file(Text *text, ReportList *reports)
+static void txt_write_file(Main *bmain, Text *text, ReportList *reports)
{
FILE *fp;
TextLine *tmp;
BLI_stat_t st;
char filepath[FILE_MAX];
-
+
BLI_strncpy(filepath, text->name, FILE_MAX);
- BLI_path_abs(filepath, G.main->name);
-
+ BLI_path_abs(filepath, BKE_main_blendfile_path(bmain));
+
fp = BLI_fopen(filepath, "w");
if (fp == NULL) {
BKE_reportf(reports, RPT_ERROR, "Unable to save '%s': %s",
@@ -479,7 +480,7 @@ static void txt_write_file(Text *text, ReportList *reports)
fputc('\n', fp);
}
}
-
+
fclose(fp);
if (BLI_stat(filepath, &st) == 0) {
@@ -493,15 +494,16 @@ static void txt_write_file(Text *text, ReportList *reports)
BKE_reportf(reports, RPT_WARNING, "Unable to stat '%s': %s",
filepath, errno ? strerror(errno) : TIP_("unknown error stating file"));
}
-
+
text->flags &= ~TXT_ISDIRTY;
}
static int text_save_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Text *text = CTX_data_edit_text(C);
- txt_write_file(text, op->reports);
+ txt_write_file(bmain, text, op->reports);
text_update_cursor_moved(C);
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
@@ -525,6 +527,7 @@ void TEXT_OT_save(wmOperatorType *ot)
static int text_save_as_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Text *text = CTX_data_edit_text(C);
char str[FILE_MAX];
@@ -537,7 +540,7 @@ static int text_save_as_exec(bContext *C, wmOperator *op)
text->name = BLI_strdup(str);
text->flags &= ~TXT_ISMEM;
- txt_write_file(text, op->reports);
+ txt_write_file(bmain, text, op->reports);
text_update_cursor_moved(C);
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
@@ -547,6 +550,7 @@ static int text_save_as_exec(bContext *C, wmOperator *op)
static int text_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
+ Main *bmain = CTX_data_main(C);
Text *text = CTX_data_edit_text(C);
const char *str;
@@ -558,10 +562,10 @@ static int text_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
else if (text->flags & TXT_ISMEM)
str = text->id.name + 2;
else
- str = G.main->name;
-
+ str = BKE_main_blendfile_path(bmain);
+
RNA_string_set(op->ptr, "filepath", str);
- WM_event_add_fileselect(C, op);
+ WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
}
@@ -572,7 +576,7 @@ void TEXT_OT_save_as(wmOperatorType *ot)
ot->name = "Save As";
ot->idname = "TEXT_OT_save_as";
ot->description = "Save active text file with options";
-
+
/* api callbacks */
ot->exec = text_save_as_exec;
ot->invoke = text_save_as_invoke;
@@ -649,7 +653,7 @@ void TEXT_OT_run_script(wmOperatorType *ot)
ot->name = "Run Script";
ot->idname = "TEXT_OT_run_script";
ot->description = "Run active script";
-
+
/* api callbacks */
ot->poll = text_run_script_poll;
ot->exec = text_run_script_exec;
@@ -668,7 +672,7 @@ static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUS
Object *ob;
bConstraint *con;
short update;
-
+
/* check all pyconstraints */
for (ob = CTX_data_main(C)->object.first; ob; ob = ob->id.next) {
update = 0;
@@ -680,7 +684,7 @@ static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUS
bPythonConstraint *data = con->data;
if (data->text == text) BPY_pyconstraint_update(ob, con);
update = 1;
-
+
}
}
}
@@ -692,7 +696,7 @@ static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUS
update = 1;
}
}
-
+
if (update) {
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
@@ -709,7 +713,7 @@ void TEXT_OT_refresh_pyconstraints(wmOperatorType *ot)
ot->name = "Refresh PyConstraints";
ot->idname = "TEXT_OT_refresh_pyconstraints";
ot->description = "Refresh all pyconstraints";
-
+
/* api callbacks */
ot->exec = text_refresh_pyconstraints_exec;
ot->poll = text_edit_poll;
@@ -753,7 +757,7 @@ void TEXT_OT_paste(wmOperatorType *ot)
ot->name = "Paste";
ot->idname = "TEXT_OT_paste";
ot->description = "Paste text from clipboard";
-
+
/* api callbacks */
ot->exec = text_paste_exec;
ot->poll = text_edit_poll;
@@ -867,7 +871,7 @@ void TEXT_OT_cut(wmOperatorType *ot)
ot->name = "Cut";
ot->idname = "TEXT_OT_cut";
ot->description = "Cut selected text to clipboard";
-
+
/* api callbacks */
ot->exec = text_cut_exec;
ot->poll = text_edit_poll;
@@ -908,7 +912,7 @@ void TEXT_OT_indent(wmOperatorType *ot)
ot->name = "Indent";
ot->idname = "TEXT_OT_indent";
ot->description = "Indent selected text";
-
+
/* api callbacks */
ot->exec = text_indent_exec;
ot->poll = text_edit_poll;
@@ -944,7 +948,7 @@ void TEXT_OT_unindent(wmOperatorType *ot)
ot->name = "Unindent";
ot->idname = "TEXT_OT_unindent";
ot->description = "Unindent selected text";
-
+
/* api callbacks */
ot->exec = text_unindent_exec;
ot->poll = text_edit_poll;
@@ -1073,7 +1077,7 @@ void TEXT_OT_uncomment(wmOperatorType *ot)
ot->name = "Uncomment";
ot->idname = "TEXT_OT_uncomment";
ot->description = "Convert selected comment to text";
-
+
/* api callbacks */
ot->exec = text_uncomment_exec;
ot->poll = text_edit_poll;
@@ -1113,7 +1117,7 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
MEM_freeN(tmp->line);
if (tmp->format)
MEM_freeN(tmp->format);
-
+
/* Put new_line in the tmp->line spot still need to try and set the curc correctly. */
tmp->line = new_line;
tmp->len = strlen(new_line);
@@ -1122,7 +1126,7 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
max_len = tmp->len;
}
}
-
+
if (type == TO_TABS) {
char *tmp_line = MEM_mallocN(sizeof(*tmp_line) * (max_len + 1), __func__);
@@ -1208,7 +1212,7 @@ void TEXT_OT_convert_whitespace(wmOperatorType *ot)
ot->name = "Convert Whitespace";
ot->idname = "TEXT_OT_convert_whitespace";
ot->description = "Convert whitespaces by type";
-
+
/* api callbacks */
ot->exec = text_convert_whitespace_exec;
ot->poll = text_edit_poll;
@@ -1240,7 +1244,7 @@ void TEXT_OT_select_all(wmOperatorType *ot)
ot->name = "Select All";
ot->idname = "TEXT_OT_select_all";
ot->description = "Select all text";
-
+
/* api callbacks */
ot->exec = text_select_all_exec;
ot->poll = text_edit_poll;
@@ -1266,7 +1270,7 @@ void TEXT_OT_select_line(wmOperatorType *ot)
ot->name = "Select Line";
ot->idname = "TEXT_OT_select_line";
ot->description = "Select text by line";
-
+
/* api callbacks */
ot->exec = text_select_line_exec;
ot->poll = text_edit_poll;
@@ -1311,14 +1315,14 @@ static int move_lines_exec(bContext *C, wmOperator *op)
TextUndoBuf *utxt = ED_text_undo_push_init(C);
txt_move_lines(text, utxt, direction);
-
+
text_update_cursor_moved(C);
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
/* run the script while editing, evil but useful */
if (CTX_wm_space_text(C)->live_edit)
text_run_script(C, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1334,7 +1338,7 @@ void TEXT_OT_move_lines(wmOperatorType *ot)
ot->name = "Move Lines";
ot->idname = "TEXT_OT_move_lines";
ot->description = "Move the currently selected line(s) up/down";
-
+
/* api callbacks */
ot->exec = move_lines_exec;
ot->poll = text_edit_poll;
@@ -1753,7 +1757,7 @@ static void cursor_skip(SpaceText *st, ARegion *ar, Text *text, int lines, const
{
TextLine **linep;
int *charp;
-
+
if (sel) { linep = &text->sell; charp = &text->selc; }
else { linep = &text->curl; charp = &text->curc; }
@@ -1798,7 +1802,7 @@ static int text_move_cursor(bContext *C, int type, bool select)
if (st && st->wordwrap && ar) txt_wrap_move_bol(st, ar, select);
else txt_move_bol(text, select);
break;
-
+
case LINE_END:
if (!select) {
txt_sel_clear(text);
@@ -1810,7 +1814,7 @@ static int text_move_cursor(bContext *C, int type, bool select)
case FILE_TOP:
txt_move_bof(text, select);
break;
-
+
case FILE_BOTTOM:
txt_move_eof(text, select);
break;
@@ -1853,7 +1857,7 @@ static int text_move_cursor(bContext *C, int type, bool select)
if (st && st->wordwrap && ar) txt_wrap_move_up(st, ar, select);
else txt_move_up(text, select);
break;
-
+
case NEXT_LINE:
if (st && st->wordwrap && ar) txt_wrap_move_down(st, ar, select);
else txt_move_down(text, select);
@@ -1889,7 +1893,7 @@ void TEXT_OT_move(wmOperatorType *ot)
ot->name = "Move Cursor";
ot->idname = "TEXT_OT_move";
ot->description = "Move cursor to position type";
-
+
/* api callbacks */
ot->exec = text_move_exec;
ot->poll = text_edit_poll;
@@ -1913,7 +1917,7 @@ void TEXT_OT_move_select(wmOperatorType *ot)
ot->name = "Move Select";
ot->idname = "TEXT_OT_move_select";
ot->description = "Move the cursor while selecting";
-
+
/* api callbacks */
ot->exec = text_move_select_exec;
ot->poll = text_space_edit_poll;
@@ -1957,7 +1961,7 @@ void TEXT_OT_jump(wmOperatorType *ot)
ot->name = "Jump";
ot->idname = "TEXT_OT_jump";
ot->description = "Jump cursor to line";
-
+
/* api callbacks */
ot->invoke = text_jump_invoke;
ot->exec = text_jump_exec;
@@ -2048,7 +2052,7 @@ static int text_delete_exec(bContext *C, wmOperator *op)
/* run the script while editing, evil but useful */
if (st->live_edit)
text_run_script(C, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -2058,7 +2062,7 @@ void TEXT_OT_delete(wmOperatorType *ot)
ot->name = "Delete";
ot->idname = "TEXT_OT_delete";
ot->description = "Delete text by cursor position";
-
+
/* api callbacks */
ot->exec = text_delete_exec;
ot->poll = text_edit_poll;
@@ -2089,7 +2093,7 @@ void TEXT_OT_overwrite_toggle(wmOperatorType *ot)
ot->name = "Toggle Overwrite";
ot->idname = "TEXT_OT_overwrite_toggle";
ot->description = "Toggle overwrite while typing";
-
+
/* api callbacks */
ot->exec = text_toggle_overwrite_exec;
ot->poll = text_space_edit_poll;
@@ -2260,20 +2264,20 @@ static int text_scroll_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
SpaceText *st = CTX_wm_space_text(C);
TextScroll *tsc;
-
+
if (RNA_struct_property_is_set(op->ptr, "lines"))
return text_scroll_exec(C, op);
-
+
tsc = MEM_callocN(sizeof(TextScroll), "TextScroll");
tsc->first = 1;
tsc->zone = SCROLLHANDLE_BAR;
op->customdata = tsc;
-
+
st->flags |= ST_SCROLL_SELECT;
-
+
if (event->type == MOUSEPAN) {
text_update_character_width(st);
-
+
tsc->old[0] = event->x;
tsc->old[1] = event->y;
/* Sensitivity of scroll set to 4pix per line/char */
@@ -2287,7 +2291,7 @@ static int text_scroll_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
WM_event_add_modal_handler(C, op);
-
+
return OPERATOR_RUNNING_MODAL;
}
@@ -2296,11 +2300,11 @@ void TEXT_OT_scroll(wmOperatorType *ot)
/* identifiers */
ot->name = "Scroll";
/* don't really see the difference between this and
- * scroll_bar. Both do basically the same thing (aside
+ * scroll_bar. Both do basically the same thing (aside
* from keymaps).*/
ot->idname = "TEXT_OT_scroll";
ot->description = "";
-
+
/* api callbacks */
ot->exec = text_scroll_exec;
ot->invoke = text_scroll_invoke;
@@ -2326,10 +2330,10 @@ static int text_region_scroll_poll(bContext *C)
if (!st || !text)
return 0;
-
+
if (!ar || ar->regiontype != RGN_TYPE_WINDOW)
return 0;
-
+
return 1;
}
@@ -2343,7 +2347,7 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *ev
if (RNA_struct_property_is_set(op->ptr, "lines"))
return text_scroll_exec(C, op);
-
+
/* verify we are in the right zone */
if (mval[0] > st->txtbar.xmin && mval[0] < st->txtbar.xmax) {
if (mval[1] >= st->txtbar.ymin && mval[1] <= st->txtbar.ymax) {
@@ -2388,11 +2392,11 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot)
/* identifiers */
ot->name = "Scrollbar";
/* don't really see the difference between this and
- * scroll. Both do basically the same thing (aside
+ * scroll. Both do basically the same thing (aside
* from keymaps).*/
ot->idname = "TEXT_OT_scroll_bar";
ot->description = "";
-
+
/* api callbacks */
ot->invoke = text_scroll_bar_invoke;
ot->modal = text_scroll_modal;
@@ -2427,7 +2431,7 @@ static int flatten_width(SpaceText *st, const char *str)
total += BLI_str_utf8_char_width_safe(str + i);
}
}
-
+
return total;
}
@@ -2440,14 +2444,14 @@ static int flatten_column_to_offset(SpaceText *st, const char *str, int index)
col = st->tabnumber - i % st->tabnumber;
else
col = BLI_str_utf8_char_width_safe(str + j);
-
+
if (i + col > index)
break;
-
+
i += col;
j += BLI_str_utf8_size_safe(str + j);
}
-
+
return j;
}
@@ -2478,7 +2482,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in
int max = wrap_width(st, ar); /* column */
int charp = -1; /* mem */
bool found = false; /* flags */
-
+
/* Point to line matching given y position, if any. */
TextLine *linep = get_line_pos_wrapped(st, ar, &y);
@@ -2491,7 +2495,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in
for (j = 0 ; !found && ((ch = linep->line[j]) != '\0'); j += BLI_str_utf8_size_safe(linep->line + j)) {
int chars;
int columns = BLI_str_utf8_char_width_safe(linep->line + j); /* = 1 for tab */
-
+
/* Mimic replacement of tabs */
if (ch == '\t') {
chars = st->tabnumber - i % st->tabnumber;
@@ -2500,7 +2504,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in
else {
chars = 1;
}
-
+
while (chars--) {
/* Gone too far, go back to last wrap point */
if (y < 0) {
@@ -2522,22 +2526,22 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in
}
if (i + columns - start > max) {
end = MIN2(end, i);
-
+
if (found) {
/* exact cursor position was found, check if it's still on needed line (hasn't been wrapped) */
if (charp > endj && !chop && ch != '\0')
charp = endj;
break;
}
-
+
if (chop)
endj = j;
start = end;
end += max;
-
+
if (j < linep->len)
y--;
-
+
chop = true;
if (y == 0 && i + columns - start > x) {
charp = curs;
@@ -2549,7 +2553,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in
if (found) {
break;
}
-
+
if (y == 0 && i + columns - start > x) {
charp = curs;
found = true;
@@ -2564,7 +2568,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in
}
BLI_assert(y == 0);
-
+
if (!found) {
/* On correct line but didn't meet cursor, must be at end */
charp = linep->len;
@@ -2602,7 +2606,7 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, con
if (x < 0) x = 0;
x = text_pixel_x_to_column(st, x) + st->left;
-
+
if (st->wordwrap) {
text_cursor_set_to_pos_wrapped(st, ar, x, y, sel);
}
@@ -2610,12 +2614,12 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, con
TextLine **linep;
int *charp;
int w;
-
+
if (sel) { linep = &text->sell; charp = &text->selc; }
else { linep = &text->curl; charp = &text->curc; }
-
+
y -= txt_get_span(text->lines.first, *linep) - st->top;
-
+
if (y > 0) {
while (y-- != 0) {
if ((*linep)->next) *linep = (*linep)->next;
@@ -2627,7 +2631,7 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, con
}
}
-
+
w = flatten_width(st, (*linep)->line);
if (x < w) *charp = flatten_column_to_offset(st, (*linep)->line, x);
else *charp = (*linep)->len;
@@ -2675,7 +2679,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *ev
}
else if (!st->wordwrap && (event->mval[0] < 0 || event->mval[0] > ar->winx)) {
text_cursor_timer_ensure(C, ssel);
-
+
if (event->type == TIMER) {
text_cursor_set_to_pos(st, ar, CLAMPIS(event->mval[0], 0, ar->winx), event->mval[1], 1);
text_scroll_to_cursor(st, ar, false);
@@ -2872,7 +2876,7 @@ void TEXT_OT_line_number(wmOperatorType *ot)
ot->name = "Line Number";
ot->idname = "TEXT_OT_line_number";
ot->description = "The current line number";
-
+
/* api callbacks */
ot->invoke = text_line_number_invoke;
ot->poll = text_region_edit_poll;
@@ -2909,7 +2913,7 @@ static int text_insert_exec(bContext *C, wmOperator *op)
}
MEM_freeN(str);
-
+
if (!done)
return OPERATOR_CANCELLED;
@@ -2937,7 +2941,7 @@ static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
else {
char str[BLI_UTF8_MAX + 1];
size_t len;
-
+
if (event->utf8_buf[0]) {
len = BLI_str_utf8_size_safe(event->utf8_buf);
memcpy(str, event->utf8_buf, len);
@@ -2952,7 +2956,7 @@ static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
ret = text_insert_exec(C, op);
-
+
/* run the script while editing, evil but useful */
if (ret == OPERATOR_FINISHED && CTX_wm_space_text(C)->live_edit)
text_run_script(C, NULL);
@@ -2968,7 +2972,7 @@ void TEXT_OT_insert(wmOperatorType *ot)
ot->name = "Insert";
ot->idname = "TEXT_OT_insert";
ot->description = "Insert text at cursor position";
-
+
/* api callbacks */
ot->exec = text_insert_exec;
ot->invoke = text_insert_invoke;
@@ -3060,7 +3064,7 @@ void TEXT_OT_find(wmOperatorType *ot)
ot->name = "Find Next";
ot->idname = "TEXT_OT_find";
ot->description = "Find specified text";
-
+
/* api callbacks */
ot->exec = text_find_exec;
ot->poll = text_space_edit_poll;
@@ -3112,7 +3116,7 @@ void TEXT_OT_find_set_selected(wmOperatorType *ot)
ot->name = "Find Set Selected";
ot->idname = "TEXT_OT_find_set_selected";
ot->description = "Find specified text and set as selected";
-
+
/* api callbacks */
ot->exec = text_find_set_selected_exec;
ot->poll = text_space_edit_poll;
@@ -3139,7 +3143,7 @@ void TEXT_OT_replace_set_selected(wmOperatorType *ot)
ot->name = "Replace Set Selected";
ot->idname = "TEXT_OT_replace_set_selected";
ot->description = "Replace text with specified text and set as selected";
-
+
/* api callbacks */
ot->exec = text_replace_set_selected_exec;
ot->poll = text_space_edit_poll;
@@ -3255,11 +3259,11 @@ void TEXT_OT_to_3d_object(wmOperatorType *ot)
ot->name = "To 3D Object";
ot->idname = "TEXT_OT_to_3d_object";
ot->description = "Create 3D text object from active text data-block";
-
+
/* api callbacks */
ot->exec = text_to_3d_object_exec;
ot->poll = text_edit_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c
index c6eed9d9b3f..b3f45de518b 100644
--- a/source/blender/editors/space_userpref/space_userpref.c
+++ b/source/blender/editors/space_userpref/space_userpref.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -77,9 +77,9 @@ static SpaceLink *userpref_new(const ScrArea *UNUSED(area), const Scene *UNUSED(
/* not spacelink itself */
static void userpref_free(SpaceLink *UNUSED(sl))
-{
+{
// SpaceUserPref *spref = (SpaceUserPref *)sl;
-
+
}
@@ -105,7 +105,7 @@ static void userpref_main_region_init(wmWindowManager *wm, ARegion *ar)
{
/* do not use here, the properties changed in userprefs do a system-wide refresh, then scroller jumps back */
/* ar->v2d.flag &= ~V2D_IS_INITIALISED; */
-
+
ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
ED_region_panels_init(wm, ar);
@@ -122,7 +122,7 @@ static void userpref_operatortypes(void)
static void userpref_keymap(struct wmKeyConfig *UNUSED(keyconf))
{
-
+
}
/* add handlers, stuff you only do once or on area/region changes */
diff --git a/source/blender/editors/space_userpref/userpref_intern.h b/source/blender/editors/space_userpref/userpref_intern.h
index 03074290d13..d67ba32f68b 100644
--- a/source/blender/editors/space_userpref/userpref_intern.h
+++ b/source/blender/editors/space_userpref/userpref_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/space_userpref/userpref_ops.c b/source/blender/editors/space_userpref/userpref_ops.c
index 0783eacc65c..c5a62f46c36 100644
--- a/source/blender/editors/space_userpref/userpref_ops.c
+++ b/source/blender/editors/space_userpref/userpref_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index b87d6c0b85e..1224c284d5f 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -67,6 +67,7 @@
#include "BKE_lattice.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_material.h"
#include "BKE_mball.h"
#include "BKE_modifier.h"
@@ -709,7 +710,7 @@ void ED_draw_object_facemap(
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
-
+
#if 0
DM_update_materials(dm, ob);
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 6d8d4d45feb..63d7d98b689 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -95,21 +95,21 @@ ARegion *view3d_has_buttons_region(ScrArea *sa)
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
if (ar) return ar;
-
+
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
/* is error! */
if (ar == NULL) return NULL;
-
+
arnew = MEM_callocN(sizeof(ARegion), "buttons for view3d");
-
+
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
arnew->regiontype = RGN_TYPE_UI;
arnew->alignment = RGN_ALIGN_RIGHT;
-
+
arnew->flag = RGN_FLAG_HIDDEN;
-
+
return arnew;
}
@@ -132,12 +132,12 @@ ARegion *view3d_has_tools_region(ScrArea *sa)
for (arhead = sa->regionbase.first; arhead; arhead = arhead->next)
if (arhead->regiontype == RGN_TYPE_HEADER)
break;
-
+
/* is error! */
if (arhead == NULL) return NULL;
-
+
artool = MEM_callocN(sizeof(ARegion), "tools for view3d");
-
+
BLI_insertlinkafter(&sa->regionbase, arhead, artool);
artool->regiontype = RGN_TYPE_TOOLS;
artool->alignment = RGN_ALIGN_LEFT;
@@ -153,7 +153,7 @@ ARegion *view3d_has_tools_region(ScrArea *sa)
RegionView3D *ED_view3d_context_rv3d(bContext *C)
{
RegionView3D *rv3d = CTX_wm_region_view3d(C);
-
+
if (rv3d == NULL) {
ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype == SPACE_VIEW3D) {
@@ -309,10 +309,9 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
ARegion *ar;
View3D *v3d;
RegionView3D *rv3d;
-
+
v3d = MEM_callocN(sizeof(View3D), "initview3d");
v3d->spacetype = SPACE_VIEW3D;
- v3d->blockscale = 0.7f;
v3d->lay = v3d->layact = 1;
if (scene) {
v3d->lay = v3d->layact = scene->lay;
@@ -323,15 +322,23 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
v3d->gridlines = 16;
v3d->gridsubdiv = 10;
v3d->drawtype = OB_SOLID;
+ v3d->shading.flag = V3D_SHADING_SPECULAR_HIGHLIGHT;
v3d->shading.light = V3D_LIGHTING_STUDIO;
- v3d->shading.shadow_intensity = 0.5;
+ v3d->shading.shadow_intensity = 0.5f;
+ v3d->shading.xray_alpha = 0.5f;
+ v3d->shading.cavity_valley_factor = 1.0f;
+ v3d->shading.cavity_ridge_factor = 1.0f;
copy_v3_fl(v3d->shading.single_color, 0.8f);
+ v3d->overlay.flag = V3D_OVERLAY_LOOK_DEV;
+ v3d->overlay.wireframe_threshold = 0.5f;
+ v3d->overlay.bone_selection_alpha = 0.5f;
+
v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR;
-
+
v3d->flag = V3D_SELECT_OUTLINE;
v3d->flag2 = V3D_SHOW_RECONSTRUCTION | V3D_SHOW_GPENCIL;
-
+
v3d->lens = 50.0f;
v3d->near = 0.01f;
v3d->far = 1000.0f;
@@ -349,14 +356,14 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for view3d");
-
+
BLI_addtail(&v3d->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_TOP;
-
+
/* tool shelf */
ar = MEM_callocN(sizeof(ARegion), "toolshelf for view3d");
-
+
BLI_addtail(&v3d->regionbase, ar);
ar->regiontype = RGN_TYPE_TOOLS;
ar->alignment = RGN_ALIGN_LEFT;
@@ -364,25 +371,25 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
/* buttons/list view */
ar = MEM_callocN(sizeof(ARegion), "buttons for view3d");
-
+
BLI_addtail(&v3d->regionbase, ar);
ar->regiontype = RGN_TYPE_UI;
ar->alignment = RGN_ALIGN_RIGHT;
ar->flag = RGN_FLAG_HIDDEN;
-
+
/* main region */
ar = MEM_callocN(sizeof(ARegion), "main region for view3d");
-
+
BLI_addtail(&v3d->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
-
+
ar->regiondata = MEM_callocN(sizeof(RegionView3D), "region view3d");
rv3d = ar->regiondata;
rv3d->viewquat[0] = 1.0f;
rv3d->persp = RV3D_PERSP;
rv3d->view = RV3D_VIEW_USER;
rv3d->dist = 10.0;
-
+
return (SpaceLink *)v3d;
}
@@ -392,9 +399,9 @@ static void view3d_free(SpaceLink *sl)
View3D *vd = (View3D *) sl;
if (vd->localvd) MEM_freeN(vd->localvd);
-
+
if (vd->properties_storage) MEM_freeN(vd->properties_storage);
-
+
if (vd->fx_settings.ssao)
MEM_freeN(vd->fx_settings.ssao);
if (vd->fx_settings.dof)
@@ -412,7 +419,7 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl)
{
View3D *v3do = (View3D *)sl;
View3D *v3dn = MEM_dupallocN(sl);
-
+
/* clear or remove stuff from old */
if (v3dn->localvd) {
@@ -423,7 +430,7 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl)
if (v3dn->drawtype == OB_RENDER)
v3dn->drawtype = OB_SOLID;
-
+
/* copy or clear inside new stuff */
v3dn->properties_storage = NULL;
@@ -449,19 +456,19 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar)
WM_manipulatormap_add_handlers(ar, ar->manipulator_map);
/* object ops. */
-
+
/* important to be before Pose keymap since they can both be enabled at once */
keymap = WM_keymap_find(wm->defaultconf, "Face Mask", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
-
-
+
+
keymap = WM_keymap_find(wm->defaultconf, "Weight Paint Vertex Selection", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
/* pose is not modal, operator poll checks for this */
keymap = WM_keymap_find(wm->defaultconf, "Pose", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
-
+
keymap = WM_keymap_find(wm->defaultconf, "Object Mode", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
@@ -482,13 +489,13 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar)
keymap = WM_keymap_find(wm->defaultconf, "Sculpt", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
-
+
keymap = WM_keymap_find(wm->defaultconf, "Mesh", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
-
+
keymap = WM_keymap_find(wm->defaultconf, "Curve", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
-
+
keymap = WM_keymap_find(wm->defaultconf, "Armature", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
@@ -497,7 +504,7 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar)
keymap = WM_keymap_find(wm->defaultconf, "Metaball", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
-
+
keymap = WM_keymap_find(wm->defaultconf, "Lattice", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
@@ -520,12 +527,12 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar)
keymap = WM_keymap_find(wm->defaultconf, "3D View", SPACE_VIEW3D, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
-
+
/* add drop boxes */
lb = WM_dropboxmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW);
-
+
WM_event_add_dropbox_handler(&ar->handlers, lb);
-
+
}
static void view3d_main_region_exit(wmWindowManager *wm, ARegion *ar)
@@ -628,7 +635,7 @@ static void view3d_ob_drop_copy(wmDrag *drag, wmDropBox *drop)
static void view3d_collection_drop_copy(wmDrag *drag, wmDropBox *drop)
{
ID *id = drag->poin;
-
+
drop->opcontext = WM_OP_EXEC_DEFAULT;
RNA_string_set(drop->ptr, "name", id->name + 2);
}
@@ -636,14 +643,14 @@ static void view3d_collection_drop_copy(wmDrag *drag, wmDropBox *drop)
static void view3d_id_drop_copy(wmDrag *drag, wmDropBox *drop)
{
ID *id = drag->poin;
-
+
RNA_string_set(drop->ptr, "name", id->name + 2);
}
static void view3d_id_path_drop_copy(wmDrag *drag, wmDropBox *drop)
{
ID *id = drag->poin;
-
+
if (id) {
RNA_string_set(drop->ptr, "name", id->name + 2);
RNA_struct_property_unset(drop->ptr, "filepath");
@@ -659,7 +666,7 @@ static void view3d_id_path_drop_copy(wmDrag *drag, wmDropBox *drop)
static void view3d_dropboxes(void)
{
ListBase *lb = WM_dropboxmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW);
-
+
WM_dropbox_add(lb, "OBJECT_OT_add_named", view3d_ob_drop_poll, view3d_ob_drop_copy);
WM_dropbox_add(lb, "OBJECT_OT_drop_named_material", view3d_mat_drop_poll, view3d_id_drop_copy);
WM_dropbox_add(lb, "MESH_OT_drop_named_image", view3d_ima_mesh_drop_poll, view3d_id_path_drop_copy);
@@ -697,14 +704,14 @@ static void view3d_widgets(void)
static void view3d_main_region_free(ARegion *ar)
{
RegionView3D *rv3d = ar->regiondata;
-
+
if (rv3d) {
if (rv3d->localvd) MEM_freeN(rv3d->localvd);
if (rv3d->clipbb) MEM_freeN(rv3d->clipbb);
if (rv3d->render_engine)
RE_engine_free(rv3d->render_engine);
-
+
if (rv3d->depths) {
if (rv3d->depths->depths) MEM_freeN(rv3d->depths->depths);
MEM_freeN(rv3d->depths);
@@ -726,19 +733,19 @@ static void *view3d_main_region_duplicate(void *poin)
{
if (poin) {
RegionView3D *rv3d = poin, *new;
-
+
new = MEM_dupallocN(rv3d);
if (rv3d->localvd)
new->localvd = MEM_dupallocN(rv3d->localvd);
if (rv3d->clipbb)
new->clipbb = MEM_dupallocN(rv3d->clipbb);
-
+
new->depths = NULL;
new->gpuoffscreen = NULL;
new->render_engine = NULL;
new->sms = NULL;
new->smooth_timer = NULL;
-
+
return new;
}
return NULL;
@@ -1104,6 +1111,20 @@ static void view3d_main_region_message_subscribe(
}
}
+static void view3d_tools_region_message_subscribe(
+ const struct bContext *UNUSED(C),
+ struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene),
+ struct bScreen *UNUSED(screen), struct ScrArea *UNUSED(sa), struct ARegion *ar,
+ struct wmMsgBus *mbus)
+{
+ wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
+ .owner = ar,
+ .user_data = ar,
+ .notify = ED_region_do_msg_notify_tag_redraw,
+ };
+ WM_msg_subscribe_rna_anon_prop(mbus, WorkSpace, tools, &msg_sub_value_region_tag_redraw);
+}
+
/* concept is to retrieve cursor type context-less */
static void view3d_main_region_cursor(wmWindow *win, ScrArea *sa, ARegion *ar)
{
@@ -1125,7 +1146,7 @@ static void view3d_main_region_cursor(wmWindow *win, ScrArea *sa, ARegion *ar)
static void view3d_header_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0);
-
+
WM_event_add_keymap_handler(&ar->handlers, keymap);
ED_region_header_init(ar);
@@ -1204,7 +1225,7 @@ static void view3d_buttons_region_init(wmWindowManager *wm, ARegion *ar)
wmKeyMap *keymap;
ED_region_panels_init(wm, ar);
-
+
keymap = WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
@@ -1310,7 +1331,7 @@ static int view3d_tools_region_snap_size(const ARegion *ar, int size, int axis)
{
if (axis == 0) {
/* Note, this depends on the icon size: see #ICON_DEFAULT_HEIGHT_TOOLBAR. */
- const float snap_units[] = {3 + 0.25f, 5 + 0.25};
+ const float snap_units[] = {2 + 0.8f, 4 + 0.8f};
const float aspect = BLI_rctf_size_x(&ar->v2d.cur) / (BLI_rcti_size_x(&ar->v2d.mask) + 1);
int best_diff = INT_MAX;
int best_size = size;
@@ -1331,7 +1352,7 @@ static int view3d_tools_region_snap_size(const ARegion *ar, int size, int axis)
static void view3d_tools_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
-
+
ED_region_panels_init(wm, ar);
keymap = WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0);
@@ -1340,7 +1361,7 @@ static void view3d_tools_region_init(wmWindowManager *wm, ARegion *ar)
static void view3d_tools_region_draw(const bContext *C, ARegion *ar)
{
- ED_region_panels(C, ar, CTX_data_mode_string(C), -1, true);
+ ED_region_panels(C, ar, (const char * []){CTX_data_mode_string(C), NULL}, -1, true);
}
/* area (not region) level listener */
@@ -1401,7 +1422,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, view_layer->basact);
}
}
-
+
return 1;
}
else if (CTX_data_equals(member, "active_object")) {
@@ -1413,7 +1434,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
CTX_data_id_pointer_set(result, &ob->id);
}
}
-
+
return 1;
}
else {
@@ -1472,10 +1493,10 @@ void ED_spacetype_view3d(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype view3d");
ARegionType *art;
-
+
st->spaceid = SPACE_VIEW3D;
strncpy(st->name, "View3D", BKE_ST_MAXNAME);
-
+
st->new = view3d_new;
st->free = view3d_free;
st->init = view3d_init;
@@ -1502,7 +1523,7 @@ void ED_spacetype_view3d(void)
art->cursor = view3d_main_region_cursor;
art->lock = 1; /* can become flag, see BKE_spacedata_draw_locks */
BLI_addhead(&st->regiontypes, art);
-
+
/* regions: listview/buttons */
art = MEM_callocN(sizeof(ARegionType), "spacetype view3d buttons region");
art->regionid = RGN_TYPE_UI;
@@ -1522,11 +1543,12 @@ void ED_spacetype_view3d(void)
art->prefsizey = 50; /* XXX */
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
art->listener = view3d_buttons_region_listener;
+ art->message_subscribe = view3d_tools_region_message_subscribe;
art->snap_size = view3d_tools_region_snap_size;
art->init = view3d_tools_region_init;
art->draw = view3d_tools_region_draw;
BLI_addhead(&st->regiontypes, art);
-
+
#if 0
/* unfinished still */
view3d_toolshelf_register(art);
@@ -1542,6 +1564,6 @@ void ED_spacetype_view3d(void)
art->draw = view3d_header_region_draw;
art->message_subscribe = view3d_header_region_message_subscribe;
BLI_addhead(&st->regiontypes, art);
-
+
BKE_spacetype_register(st);
}
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index 644a6956e54..69e8aa07d3f 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -835,7 +835,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
bcol = uiLayoutColumn(pa->layout, true);
row = uiLayoutRow(bcol, true); /* The filter button row */
-
+
RNA_pointer_create(NULL, &RNA_ToolSettings, ts, &tools_ptr);
uiItemR(row, &tools_ptr, "vertex_group_subset", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
@@ -864,7 +864,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
UI_but_flag_enable(but, UI_BUT_INACTIVE);
}
xco += x;
-
+
row = uiLayoutRow(split, true);
uiLayoutSetEnabled(row, !locked);
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index b44e2da3583..fd2f604651b 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -441,14 +441,14 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View
return;
if (v3d->camera->type == OB_CAMERA)
ca = v3d->camera->data;
-
+
ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewborder, false);
/* the offsets */
x1 = viewborder.xmin;
y1 = viewborder.ymin;
x2 = viewborder.xmax;
y2 = viewborder.ymax;
-
+
glLineWidth(1.0f);
/* apply offsets so the real 3D camera shows through */
@@ -647,7 +647,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View
/* draw */
immUniformThemeColorShade(TH_VIEW_OVERLAY, 100);
-
+
/* TODO Was using UI_draw_roundbox_4fv(false, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 2.0f, color).
* We'll probably need a new imm_draw_line_roundbox_dashed dor that - though in practice the
* 2.0f round corner effect was nearly not visible anyway... */
@@ -777,8 +777,13 @@ static void draw_view_axis(RegionView3D *rv3d, const rcti *rect)
const float k = U.rvisize * U.pixelsize; /* axis size */
const int bright = - 20 * (10 - U.rvibright); /* axis alpha offset (rvibright has range 0-10) */
- const float startx = rect->xmin + k + 1.0f; /* axis center in screen coordinates, x=y */
- const float starty = rect->ymin + k + 1.0f;
+ /* Axis center in screen coordinates.
+ *
+ * - Unit size offset so small text doesn't draw outside the screen
+ * - Extra X offset because of the panel expander.
+ */
+ const float startx = rect->xmax - (k + UI_UNIT_X * 1.5);
+ const float starty = rect->ymax - (k + UI_UNIT_Y);
float axis_pos[3][2];
unsigned char axis_col[3][4];
@@ -885,7 +890,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d)
sub_v3_v3v3(end, o, scaled_axis);
immVertex3fv(pos, end);
immEnd();
-
+
/* -- draw ring around rotation center -- */
{
#define ROT_AXIS_DETAIL 13
@@ -1079,7 +1084,6 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect)
char info[300];
char *s = info;
- short offset = 1.5f * UI_UNIT_X + rect->xmin;
s += sprintf(s, "(%d)", cfra);
@@ -1170,10 +1174,7 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect)
s += sprintf(s, " <%s>", markern);
}
- if (U.uiflag & USER_SHOW_ROTVIEWICON)
- offset = U.widget_unit + (U.rvisize * 2) + rect->xmin;
-
- BLF_draw_default(offset, rect->ymin + 0.5f * U.widget_unit, 0.0f, info, sizeof(info));
+ BLF_draw_default(rect->xmin + UI_UNIT_X, rect->ymax - (2 * U.widget_unit), 0.0f, info, sizeof(info));
}
/* ******************** view loop ***************** */
@@ -1203,37 +1204,47 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int offset)
BLF_batch_draw_begin();
- if (U.uiflag & USER_SHOW_ROTVIEWICON) {
+ if (((U.uiflag & USER_SHOW_ROTVIEWICON) != 0) &&
+ ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) &&
+ /* No need to display manipulator and this info. */
+ ((U.manipulator_flag & USER_MANIPULATOR_DRAW_NAVIGATE) == 0))
+ {
draw_view_axis(rv3d, &rect);
}
- if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_no_scrub(wm)) {
- ED_scene_draw_fps(scene, &rect);
- }
- else if (U.uiflag & USER_SHOW_VIEWPORTNAME) {
- draw_viewport_name(ar, v3d, &rect);
- }
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0 &&
+ (v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) == 0)
+ {
+ if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_no_scrub(wm)) {
+ ED_scene_draw_fps(scene, &rect);
+ }
+ else if (U.uiflag & USER_SHOW_VIEWPORTNAME) {
+ draw_viewport_name(ar, v3d, &rect);
+ }
- if (U.uiflag & USER_DRAWVIEWINFO) {
- ViewLayer *view_layer = CTX_data_view_layer(C);
- Object *ob = OBACT(view_layer);
- draw_selected_name(scene, ob, &rect);
- }
+ if (U.uiflag & USER_DRAWVIEWINFO) {
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *ob = OBACT(view_layer);
+ draw_selected_name(scene, ob, &rect);
+ }
#if 0 /* TODO */
- if (grid_unit) { /* draw below the viewport name */
- char numstr[32] = "";
+ if (grid_unit) { /* draw below the viewport name */
+ char numstr[32] = "";
- UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
- if (v3d->grid != 1.0f) {
- BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid);
- }
+ UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
+ if (v3d->grid != 1.0f) {
+ BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid);
+ }
- BLF_draw_default_ascii(rect.xmin + U.widget_unit,
- rect.ymax - (USER_SHOW_VIEWPORTNAME ? 2 * U.widget_unit : U.widget_unit), 0.0f,
- numstr[0] ? numstr : grid_unit, sizeof(numstr));
- }
+ BLF_draw_default_ascii(
+ rect.xmin + U.widget_unit,
+ rect.ymax - (USER_SHOW_VIEWPORTNAME ? 2 * U.widget_unit : U.widget_unit), 0.0f,
+ numstr[0] ? numstr : grid_unit, sizeof(numstr));
+ }
#endif
+ }
+
BLF_batch_draw_end();
}
@@ -1248,7 +1259,7 @@ static void view3d_draw_view(const bContext *C, ARegion *ar)
RenderEngineType *ED_view3d_engine_type(Scene *scene, int drawtype)
{
/*
- * Tempory viewport draw modes until we have a proper system.
+ * Tempory viewport draw modes until we have a proper system.
* all modes are done in the draw manager, except
* cycles material as it is an external render engine.
*/
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 8505de4c7e0..3a89c910ea8 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -1032,7 +1032,7 @@ void ED_scene_draw_fps(Scene *scene, const rcti *rect)
static bool view3d_main_region_do_render_draw(const Scene *scene)
{
RenderEngineType *type = RE_engines_find(scene->r.engine);
- return (type && type->view_update && type->render_to_view);
+ return (type && type->view_update && type->view_draw);
}
bool ED_view3d_calc_render_border(const Scene *scene, Depsgraph *depsgraph, View3D *v3d, ARegion *ar, rcti *rect)
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 3f59a5db9b3..cdf2106d8bf 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -54,6 +54,7 @@
#include "BKE_font.h"
#include "BKE_layer.h"
#include "BKE_library.h"
+#include "BKE_main.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_report.h"
@@ -130,6 +131,7 @@ static void view3d_operator_properties_common(wmOperatorType *ot, const enum eV3
typedef struct ViewOpsData {
/** Context pointers (assigned by #viewops_data_alloc). */
+ Main *bmain;
Scene *scene;
ScrArea *sa;
ARegion *ar;
@@ -220,6 +222,7 @@ static void viewops_data_alloc(bContext *C, wmOperator *op)
/* store data */
op->customdata = vod;
+ vod->bmain = CTX_data_main(C);
vod->depsgraph = CTX_data_depsgraph(C);
vod->scene = CTX_data_scene(C);
vod->sa = CTX_wm_area(C);
@@ -3089,7 +3092,7 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *ev
ARegion *ar = CTX_wm_region(C);
if (rv3d) {
- struct Depsgraph *graph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
float new_ofs[3];
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
@@ -3097,7 +3100,7 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *ev
view3d_operator_needs_opengl(C);
- if (ED_view3d_autodist(graph, ar, v3d, event->mval, new_ofs, false, NULL)) {
+ if (ED_view3d_autodist(depsgraph, ar, v3d, event->mval, new_ofs, false, NULL)) {
/* pass */
}
else {
@@ -4574,10 +4577,10 @@ void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2])
}
if (U.uiflag & USER_DEPTH_CURSOR) { /* maybe this should be accessed some other way */
- struct Depsgraph *graph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
view3d_operator_needs_opengl(C);
- if (ED_view3d_autodist(graph, ar, v3d, mval, fp, true, NULL)) {
+ if (ED_view3d_autodist(depsgraph, ar, v3d, mval, fp, true, NULL)) {
depth_used = true;
}
}
@@ -4591,6 +4594,7 @@ void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2])
void ED_view3d_cursor3d_update(bContext *C, const int mval[2])
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
@@ -4608,7 +4612,7 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2])
float ray_no[3];
struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
- scene, CTX_data_depsgraph(C), 0, ar, v3d);
+ bmain, scene, CTX_data_depsgraph(C), 0, ar, v3d);
float obmat[4][4];
Object *ob_dummy = NULL;
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index 3715f4672d7..d8cc9ab9828 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
+ *
* Contributor(s): Campbell Barton
*
* ***** END GPL LICENSE BLOCK *****
@@ -151,7 +151,7 @@ void fly_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, KM_ANY, 0, FLY_MODAL_DECELERATE);
WM_modalkeymap_add_item(keymap, MOUSEPAN, 0, 0, 0, FLY_MODAL_SPEED);
-
+
WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_PRESS, KM_ANY, 0, FLY_MODAL_PAN_ENABLE);
/* XXX - Bug in the event system, middle mouse release doesnt work */
WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, FLY_MODAL_PAN_DISABLE);
@@ -550,12 +550,12 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e
case FLY_MODAL_CONFIRM:
fly->state = FLY_CONFIRM;
break;
-
+
/* speed adjusting with mousepan (trackpad) */
case FLY_MODAL_SPEED:
{
float fac = 0.02f * (event->prevy - event->y);
-
+
/* allowing to brake immediate */
if (fac > 0.0f && fly->speed < 0.0f)
fly->speed = 0.0f;
@@ -563,7 +563,7 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e
fly->speed = 0.0f;
else
fly->speed += fly->grid * fac;
-
+
break;
}
case FLY_MODAL_ACCELERATE:
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index e0f3c412c56..4f81fa7585c 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2004-2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -117,7 +117,7 @@ static int view3d_layers_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
int nr = RNA_int_get(op->ptr, "nr");
const bool toggle = RNA_boolean_get(op->ptr, "toggle");
-
+
if (nr < 0)
return OPERATOR_CANCELLED;
@@ -165,13 +165,13 @@ static int view3d_layers_exec(bContext *C, wmOperator *op)
}
}
}
-
+
if (v3d->scenelock) handle_view3d_lock(C);
-
+
DEG_on_visible_update(CTX_data_main(C), false);
ED_area_tag_redraw(sa);
-
+
return OPERATOR_FINISHED;
}
@@ -181,18 +181,18 @@ static int view3d_layers_invoke(bContext *C, wmOperator *op, const wmEvent *even
{
if (event->ctrl || event->oskey)
return OPERATOR_PASS_THROUGH;
-
+
if (event->shift)
RNA_boolean_set(op->ptr, "extend", true);
else
RNA_boolean_set(op->ptr, "extend", false);
-
+
if (event->alt) {
const int nr = RNA_int_get(op->ptr, "nr") + 10;
RNA_int_set(op->ptr, "nr", nr);
}
view3d_layers_exec(C, op);
-
+
return OPERATOR_FINISHED;
}
@@ -207,15 +207,15 @@ void VIEW3D_OT_layers(wmOperatorType *ot)
ot->name = "Layers";
ot->description = "Toggle layer(s) visibility";
ot->idname = "VIEW3D_OT_layers";
-
+
/* api callbacks */
ot->invoke = view3d_layers_invoke;
ot->exec = view3d_layers_exec;
ot->poll = view3d_layers_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_int(ot->srna, "nr", 1, 0, 20, "Number", "The layer number to set, zero for all layers", 0, 20);
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Add this layer to the current view layers");
RNA_def_boolean(ot->srna, "toggle", 1, "Toggle", "Toggle the layer");
@@ -259,6 +259,33 @@ void VIEW3D_OT_toggle_xray_draw_option(wmOperatorType *ot)
/** \} */
+/* -------------------------------------------------------------------- */
+/** \name Toggle Bone selection Overlay Operator
+ * \{ */
+
+static int toggle_matcap_flip(bContext *C, wmOperator *UNUSED(op))
+{
+ View3D *v3d = CTX_wm_view3d(C);
+ v3d->shading.flag ^= V3D_SHADING_MATCAP_FLIP_X;
+ ED_view3d_shade_update(CTX_data_main(C), v3d, CTX_wm_area(C));
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
+ return OPERATOR_FINISHED;
+}
+
+void VIEW3D_OT_toggle_matcap_flip(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Flip MatCap";
+ ot->description = "Flip MatCap";
+ ot->idname = "VIEW3D_OT_toggle_matcap_flip";
+
+ /* api callbacks */
+ ot->exec = toggle_matcap_flip;
+ // ot->poll = toggle_show_xray_poll;
+}
+
+/** \} */
+
static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
{
@@ -371,7 +398,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
ob && !(gpd && (gpd->flag & GP_DATA_STROKE_EDITMODE)) &&
ELEM(ob->mode,
OB_MODE_SCULPT, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT, OB_MODE_TEXTURE_PAINT));
-
+
RNA_pointer_create(&screen->id, &RNA_SpaceView3D, v3d, &v3dptr);
RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &toolsptr);
RNA_pointer_create(&scene->id, &RNA_Scene, scene, &sceneptr);
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index da8afa7a390..017b31a0bf2 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -66,6 +66,7 @@ enum {
/* view3d_header.c */
void VIEW3D_OT_layers(struct wmOperatorType *ot);
void VIEW3D_OT_toggle_xray_draw_option(struct wmOperatorType *ot);
+void VIEW3D_OT_toggle_matcap_flip(struct wmOperatorType *ot);
/* view3d_ops.c */
void view3d_operatortypes(void);
@@ -134,7 +135,8 @@ void VIEW3D_OT_ruler(struct wmOperatorType *ot);
/* drawobject.c */
void draw_object_backbufsel(
- struct Depsgraph *depsgraph, Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob,
+ struct Depsgraph *depsgraph, Scene *scene,
+ View3D *v3d, RegionView3D *rv3d, struct Object *ob,
short select_mode);
int view3d_effective_drawtype(const struct View3D *v3d);
diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c
index 145f57174fd..eae0cf8e459 100644
--- a/source/blender/editors/space_view3d/view3d_iterators.c
+++ b/source/blender/editors/space_view3d/view3d_iterators.c
@@ -42,6 +42,7 @@
#include "BKE_displist.h"
#include "BKE_editmesh.h"
#include "BKE_context.h"
+#include "BKE_mesh_runtime.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_armature.c b/source/blender/editors/space_view3d/view3d_manipulator_armature.c
index 5d3d88ff2a2..abbd6c888b2 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_armature.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_armature.c
@@ -134,7 +134,10 @@ static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmManipulatorGro
const bArmature *arm = ob->data;
if (arm->drawtype == ARM_B_BONE) {
if (arm->act_bone && arm->act_bone->segments > 1) {
- return true;
+ View3D *v3d = CTX_wm_view3d(C);
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
+ return true;
+ }
}
}
}
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_camera.c b/source/blender/editors/space_view3d/view3d_manipulator_camera.c
index d3fe17123a0..49fa83e82fc 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_camera.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_camera.c
@@ -47,8 +47,6 @@
#include "WM_types.h"
#include "WM_message.h"
-#include "DEG_depsgraph_query.h"
-
#include "view3d_intern.h" /* own include */
@@ -65,6 +63,11 @@ struct CameraWidgetGroup {
static bool WIDGETGROUP_camera_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
{
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+ return false;
+ }
+
Object *ob = CTX_data_active_object(C);
if (ob && ob->type == OB_CAMERA) {
Camera *camera = ob->data;
@@ -78,9 +81,7 @@ static bool WIDGETGROUP_camera_poll(const bContext *C, wmManipulatorGroupType *U
static void WIDGETGROUP_camera_setup(const bContext *C, wmManipulatorGroup *mgroup)
{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *ob = CTX_data_active_object(C);
- const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
float dir[3];
const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true);
@@ -88,7 +89,7 @@ static void WIDGETGROUP_camera_setup(const bContext *C, wmManipulatorGroup *mgro
struct CameraWidgetGroup *camgroup = MEM_callocN(sizeof(struct CameraWidgetGroup), __func__);
mgroup->customdata = camgroup;
- negate_v3_v3(dir, ob_eval->obmat[2]);
+ negate_v3_v3(dir, ob->obmat[2]);
/* dof distance */
{
@@ -128,28 +129,26 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg
if (!mgroup->customdata)
return;
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
struct CameraWidgetGroup *camgroup = mgroup->customdata;
Object *ob = CTX_data_active_object(C);
- const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- Camera *ca = ob_eval->data;
+ Camera *ca = ob->data;
PointerRNA camera_ptr;
float dir[3];
const float ob_scale_inv[3] = {
- 1.0f / len_v3(ob_eval->obmat[0]),
- 1.0f / len_v3(ob_eval->obmat[1]),
- 1.0f / len_v3(ob_eval->obmat[2]),
+ 1.0f / len_v3(ob->obmat[0]),
+ 1.0f / len_v3(ob->obmat[1]),
+ 1.0f / len_v3(ob->obmat[2]),
};
const float ob_scale_uniform_inv = (ob_scale_inv[0] + ob_scale_inv[1] + ob_scale_inv[2]) / 3.0f;
RNA_pointer_create(&ca->id, &RNA_Camera, ca, &camera_ptr);
- negate_v3_v3(dir, ob_eval->obmat[2]);
+ negate_v3_v3(dir, ob->obmat[2]);
if (ca->flag & CAM_SHOWLIMITS) {
- WM_manipulator_set_matrix_location(camgroup->dop_dist, ob_eval->obmat[3]);
- WM_manipulator_set_matrix_rotation_from_yz_axis(camgroup->dop_dist, ob_eval->obmat[1], dir);
+ WM_manipulator_set_matrix_location(camgroup->dop_dist, ob->obmat[3]);
+ WM_manipulator_set_matrix_rotation_from_yz_axis(camgroup->dop_dist, ob->obmat[1], dir);
WM_manipulator_set_scale(camgroup->dop_dist, ca->drawsize);
WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, false);
@@ -186,8 +185,8 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg
aspect[1] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? aspy / aspx : 1.0f;
unit_m4(widget->matrix_basis);
- WM_manipulator_set_matrix_location(widget, ob_eval->obmat[3]);
- WM_manipulator_set_matrix_rotation_from_yz_axis(widget, ob_eval->obmat[1], dir);
+ WM_manipulator_set_matrix_location(widget, ob->obmat[3]);
+ WM_manipulator_set_matrix_rotation_from_yz_axis(widget, ob->obmat[1], dir);
if (is_ortho) {
scale_matrix = ca->ortho_scale * 0.5f;
@@ -358,9 +357,13 @@ static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmManipulatorGroupTy
}
}
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+ return false;
+ }
+
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = ar->regiondata;
- View3D *v3d = CTX_wm_view3d(C);
if (rv3d->persp == RV3D_CAMOB) {
if (scene->r.mode & R_BORDER) {
/* TODO: support overrides. */
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_empty.c b/source/blender/editors/space_view3d/view3d_manipulator_empty.c
index 1d56c5ee7f4..75e4a9e3314 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_empty.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_empty.c
@@ -106,6 +106,11 @@ static void manipulator_empty_image_prop_matrix_set(
static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
{
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+ return false;
+ }
+
Object *ob = CTX_data_active_object(C);
if (ob && ob->type == OB_EMPTY) {
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c b/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c
index e76be448be4..2a1fdee8e8a 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c
@@ -54,6 +54,11 @@
static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
{
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+ return false;
+ }
+
Object *ob = CTX_data_active_object(C);
return (ob && ob->pd && ob->pd->forcefield);
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
index e659c67396d..01c38cfd899 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
@@ -45,8 +45,6 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "DEG_depsgraph_query.h"
-
#include "view3d_intern.h" /* own include */
/* -------------------------------------------------------------------- */
@@ -56,6 +54,11 @@
static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
{
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+ return false;
+ }
+
Object *ob = CTX_data_active_object(C);
if (ob && ob->type == OB_LAMP) {
@@ -82,18 +85,16 @@ static void WIDGETGROUP_lamp_spot_setup(const bContext *UNUSED(C), wmManipulator
static void WIDGETGROUP_lamp_spot_refresh(const bContext *C, wmManipulatorGroup *mgroup)
{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
wmManipulatorWrapper *wwrapper = mgroup->customdata;
wmManipulator *mpr = wwrapper->manipulator;
Object *ob = CTX_data_active_object(C);
- const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
Lamp *la = ob->data;
float dir[3];
- negate_v3_v3(dir, ob_eval->obmat[2]);
+ negate_v3_v3(dir, ob->obmat[2]);
WM_manipulator_set_matrix_rotation_from_z_axis(mpr, dir);
- WM_manipulator_set_matrix_location(mpr, ob_eval->obmat[3]);
+ WM_manipulator_set_matrix_location(mpr, ob->obmat[3]);
/* need to set property here for undo. TODO would prefer to do this in _init */
PointerRNA lamp_ptr;
@@ -155,8 +156,12 @@ static void manipulator_area_lamp_prop_matrix_set(
static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
{
- Object *ob = CTX_data_active_object(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+ return false;
+ }
+ Object *ob = CTX_data_active_object(C);
if (ob && ob->type == OB_LAMP) {
Lamp *la = ob->data;
return (la->type == LA_AREA);
@@ -183,13 +188,11 @@ static void WIDGETGROUP_lamp_area_setup(const bContext *UNUSED(C), wmManipulator
static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmManipulatorGroup *mgroup)
{
wmManipulatorWrapper *wwrapper = mgroup->customdata;
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *ob = CTX_data_active_object(C);
- const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- Lamp *la = ob_eval->data;
+ Lamp *la = ob->data;
wmManipulator *mpr = wwrapper->manipulator;
- copy_m4_m4(mpr->matrix_basis, ob_eval->obmat);
+ copy_m4_m4(mpr->matrix_basis, ob->obmat);
int flag = ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE;
if (ELEM(la->area_shape, LA_AREA_SQUARE, LA_AREA_DISK)) {
@@ -232,6 +235,11 @@ void VIEW3D_WGT_lamp_area(wmManipulatorGroupType *wgt)
static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
{
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+ return false;
+ }
+
Object *ob = CTX_data_active_object(C);
if (ob != NULL) {
@@ -272,12 +280,10 @@ static void WIDGETGROUP_lamp_target_setup(const bContext *UNUSED(C), wmManipulat
static void WIDGETGROUP_lamp_target_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
{
wmManipulatorWrapper *wwrapper = mgroup->customdata;
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *ob = CTX_data_active_object(C);
- const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
wmManipulator *mpr = wwrapper->manipulator;
- copy_m4_m4(mpr->matrix_basis, ob_eval->obmat);
+ copy_m4_m4(mpr->matrix_basis, ob->obmat);
unit_m4(mpr->matrix_offset);
mpr->matrix_offset[3][2] = -2.4f / mpr->scale_basis;
WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true);
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_navigate.c b/source/blender/editors/space_view3d/view3d_manipulator_navigate.c
index 75ab32a5b18..c869e23d552 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_navigate.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_navigate.c
@@ -169,15 +169,20 @@ struct NavigateWidgetGroup {
rcti rect_visible;
struct {
char is_persp;
+ char is_camera;
char viewlock;
} rv3d;
} state;
int region_size[2];
- bool is_persp;
};
-static bool WIDGETGROUP_navigate_poll(const bContext *UNUSED(C), wmManipulatorGroupType *UNUSED(wgt))
+static bool WIDGETGROUP_navigate_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
{
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+ return false;
+ }
+
if (U.manipulator_flag & USER_MANIPULATOR_DRAW_NAVIGATE) {
return true;
}
@@ -281,6 +286,7 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr
if ((navgroup->state.rect_visible.xmax == rect_visible.xmax) &&
(navgroup->state.rect_visible.ymax == rect_visible.ymax) &&
(navgroup->state.rv3d.is_persp == rv3d->is_persp) &&
+ (navgroup->state.rv3d.is_camera == (rv3d->persp == RV3D_CAMOB)) &&
(navgroup->state.rv3d.viewlock == rv3d->viewlock))
{
return;
@@ -288,6 +294,7 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr
navgroup->state.rect_visible = rect_visible;
navgroup->state.rv3d.is_persp = rv3d->is_persp;
+ navgroup->state.rv3d.is_camera = (rv3d->persp == RV3D_CAMOB);
navgroup->state.rv3d.viewlock = rv3d->viewlock;
const float icon_size = MANIPULATOR_SIZE;
@@ -302,7 +309,7 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr
WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
}
- if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
+ if (((rv3d->viewlock & RV3D_LOCKED) == 0) && (navgroup->state.rv3d.is_camera == false)) {
mpr = navgroup->mpr_array[MPR_ROTATE];
mpr->matrix_basis[3][0] = co[0];
mpr->matrix_basis[3][1] = co[1];
@@ -329,7 +336,7 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr
WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
}
else {
- /* RV3D_LOCKED: only show supported buttons. */
+ /* RV3D_LOCKED or Camera: only show supported buttons. */
mpr = navgroup->mpr_array[MPR_MOVE];
mpr->matrix_basis[3][0] = co[0] + icon_offset_mini;
mpr->matrix_basis[3][1] = co[1] + icon_offset_mini;
@@ -339,6 +346,13 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr
mpr->matrix_basis[3][0] = co[0];
mpr->matrix_basis[3][1] = co[1] + icon_offset_mini;
WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
+
+ if (navgroup->state.rv3d.is_camera) {
+ mpr = navgroup->mpr_array[MPR_CAMERA];
+ mpr->matrix_basis[3][0] = co[0] - icon_offset_mini;
+ mpr->matrix_basis[3][1] = co[1] + icon_offset_mini;
+ WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
+ }
}
}
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c
index 9cde5ffc5e3..cd918695f60 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c
@@ -31,8 +31,10 @@
#include "BLT_translation.h"
#include "BKE_context.h"
-#include "BKE_object.h"
#include "BKE_gpencil.h"
+#include "BKE_main.h"
+
+#include "BKE_object.h"
#include "BKE_unit.h"
#include "DNA_object_types.h"
@@ -263,6 +265,7 @@ static bool view3d_ruler_pick(
*/
static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state)
{
+ Main *bmain = CTX_data_main(C);
if (state == ruler_info->state) {
return;
}
@@ -278,7 +281,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state)
}
else if (state == RULER_STATE_DRAG) {
ruler_info->snap_context = ED_transform_snap_object_context_create_view3d(
- CTX_data_scene(C), CTX_data_depsgraph(C), 0,
+ bmain, CTX_data_scene(C), CTX_data_depsgraph(C), 0,
ruler_info->ar, CTX_wm_view3d(C));
}
else {
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index 4d362ae5425..b3211ed1108 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -71,9 +71,9 @@ static int view3d_copybuffer_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
char str[FILE_MAX];
-
+
BKE_copybuffer_begin(bmain);
-
+
/* context, selection, could be generalized */
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
{
@@ -93,10 +93,10 @@ static int view3d_copybuffer_exec(bContext *C, wmOperator *op)
}
}
}
-
+
BLI_make_file_string("/", str, BKE_tempdir_base(), "copybuffer.blend");
BKE_copybuffer_save(bmain, str, op->reports);
-
+
BKE_report(op->reports, RPT_INFO, "Copied selected objects to buffer");
return OPERATOR_FINISHED;
@@ -104,12 +104,12 @@ static int view3d_copybuffer_exec(bContext *C, wmOperator *op)
static void VIEW3D_OT_copybuffer(wmOperatorType *ot)
{
-
+
/* identifiers */
ot->name = "Copy Selection to Buffer";
ot->idname = "VIEW3D_OT_copybuffer";
ot->description = "Selected objects are saved in a temp file";
-
+
/* api callbacks */
ot->exec = view3d_copybuffer_exec;
ot->poll = ED_operator_scene;
@@ -141,16 +141,16 @@ static int view3d_pastebuffer_exec(bContext *C, wmOperator *op)
static void VIEW3D_OT_pastebuffer(wmOperatorType *ot)
{
-
+
/* identifiers */
ot->name = "Paste Selection from Buffer";
ot->idname = "VIEW3D_OT_pastebuffer";
ot->description = "Contents of copy buffer gets pasted";
-
+
/* api callbacks */
ot->exec = view3d_pastebuffer_exec;
ot->poll = ED_operator_scene_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -209,10 +209,10 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_layers);
WM_operatortype_append(VIEW3D_OT_copybuffer);
WM_operatortype_append(VIEW3D_OT_pastebuffer);
-
+
WM_operatortype_append(VIEW3D_OT_properties);
WM_operatortype_append(VIEW3D_OT_toolshelf);
-
+
WM_operatortype_append(VIEW3D_OT_snap_selected_to_grid);
WM_operatortype_append(VIEW3D_OT_snap_selected_to_cursor);
WM_operatortype_append(VIEW3D_OT_snap_selected_to_active);
@@ -223,6 +223,7 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_toggle_render);
WM_operatortype_append(VIEW3D_OT_toggle_xray_draw_option);
+ WM_operatortype_append(VIEW3D_OT_toggle_matcap_flip);
WM_operatortype_append(VIEW3D_OT_ruler_add);
@@ -233,17 +234,17 @@ void view3d_keymap(wmKeyConfig *keyconf)
{
wmKeyMap *keymap;
wmKeyMapItem *kmi;
-
+
keymap = WM_keymap_find(keyconf, "3D View Generic", SPACE_VIEW3D, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_properties", NKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_toolshelf", TKEY, KM_PRESS, 0, 0);
-
+
/* only for region 3D window */
keymap = WM_keymap_find(keyconf, "3D View", SPACE_VIEW3D, 0);
WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_CLICK, 0, 0);
-
+
WM_keymap_verify_item(keymap, "VIEW3D_OT_rotate", MIDDLEMOUSE, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "VIEW3D_OT_move", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
WM_keymap_verify_item(keymap, "VIEW3D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
@@ -259,20 +260,20 @@ void view3d_keymap(wmKeyConfig *keyconf)
WM_keymap_verify_item(keymap, "VIEW3D_OT_navigate", FKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_verify_item(keymap, "VIEW3D_OT_smoothview", TIMER1, KM_ANY, KM_ANY, 0);
-
+
WM_keymap_add_item(keymap, "VIEW3D_OT_rotate", MOUSEPAN, 0, 0, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_rotate", MOUSEROTATE, 0, 0, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_move", MOUSEPAN, 0, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MOUSEZOOM, 0, 0, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MOUSEPAN, 0, KM_CTRL, 0);
-
+
/*numpad +/-*/
RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", PADPLUSKEY, KM_PRESS, 0, 0)->ptr, "delta", 1);
RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", PADMINUS, KM_PRESS, 0, 0)->ptr, "delta", -1);
/*ctrl +/-*/
RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", EQUALKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1);
RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MINUSKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1);
-
+
/*wheel mouse forward/back*/
RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", WHEELINMOUSE, KM_PRESS, 0, 0)->ptr, "delta", 1);
RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", WHEELOUTMOUSE, KM_PRESS, 0, 0)->ptr, "delta", -1);
@@ -301,6 +302,8 @@ void view3d_keymap(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_all", CKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "center", true);
+ WM_keymap_add_menu_pie(keymap, "VIEW3D_PIE_view", ACCENTGRAVEKEY, KM_CLICK_DRAG, 0, 0);
+
/* numpad view hotkeys*/
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD0, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_CAMERA);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT);
@@ -308,7 +311,7 @@ void view3d_keymap(wmKeyConfig *keyconf)
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD4, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPLEFT);
WM_keymap_add_item(keymap, "VIEW3D_OT_view_persportho", PAD5, KM_PRESS, 0, 0);
-
+
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD6, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPRIGHT);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD8, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPUP);
@@ -334,7 +337,7 @@ void view3d_keymap(wmKeyConfig *keyconf)
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPRIGHT);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELUPMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPUP);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPDOWN);
-
+
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", WHEELUPMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "type", V3D_VIEW_STEPLEFT);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "type", V3D_VIEW_STEPRIGHT);
@@ -357,7 +360,7 @@ void view3d_keymap(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BOTTOM);
RNA_boolean_set(kmi->ptr, "align_active", true);
-
+
#ifdef WITH_INPUT_NDOF
/* note: positioned here so keymaps show keyboard keys if assigned */
/* 3D mouse */
@@ -376,7 +379,7 @@ void view3d_keymap(wmKeyConfig *keyconf)
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_RIGHT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_TOP, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_BOTTOM, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BOTTOM);
-
+
/* 3D mouse align */
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_FRONT, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_FRONT);
@@ -389,19 +392,6 @@ void view3d_keymap(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "align_active", true);
#endif /* WITH_INPUT_NDOF */
- /* layers, shift + alt are properties set in invoke() */
- RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ACCENTGRAVEKEY, KM_PRESS, 0, 0)->ptr, "nr", 0);
- RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ONEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 1);
- RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", TWOKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 2);
- RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", THREEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 3);
- RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", FOURKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 4);
- RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", FIVEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 5);
- RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", SIXKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 6);
- RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", SEVENKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 7);
- RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", EIGHTKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 8);
- RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", NINEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 9);
- RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ZEROKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 10);
-
/* drawtype */
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, KM_ALT, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.shading.type");
@@ -480,7 +470,7 @@ void view3d_keymap(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT | KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "deselect", true);
WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0);
-
+
WM_keymap_add_item(keymap, "VIEW3D_OT_clip_border", BKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0);
@@ -490,19 +480,19 @@ void view3d_keymap(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "camera_only", false);
WM_keymap_add_item(keymap, "VIEW3D_OT_clear_render_border", BKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
-
+
WM_keymap_add_item(keymap, "VIEW3D_OT_camera_to_view", PAD0, KM_PRESS, KM_ALT | KM_CTRL, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_object_as_camera", PAD0, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_menu(keymap, "VIEW3D_MT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
-
+
#ifdef __APPLE__
WM_keymap_add_item(keymap, "VIEW3D_OT_copybuffer", CKEY, KM_PRESS, KM_OSKEY, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_pastebuffer", VKEY, KM_PRESS, KM_OSKEY, 0);
#endif
WM_keymap_add_item(keymap, "VIEW3D_OT_copybuffer", CKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_pastebuffer", VKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* context ops */
kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.transform_pivot_point");
diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c
index d0fb82eaaf4..30b91c1a8ee 100644
--- a/source/blender/editors/space_view3d/view3d_project.c
+++ b/source/blender/editors/space_view3d/view3d_project.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -57,13 +57,13 @@
void ED_view3d_project_float_v2_m4(const ARegion *ar, const float co[3], float r_co[2], float mat[4][4])
{
float vec4[4];
-
+
copy_v3_v3(vec4, co);
vec4[3] = 1.0;
/* r_co[0] = IS_CLIPPED; */ /* always overwritten */
-
+
mul_m4_v4(mat, vec4);
-
+
if (vec4[3] > FLT_EPSILON) {
r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
@@ -79,13 +79,13 @@ void ED_view3d_project_float_v2_m4(const ARegion *ar, const float co[3], float r
void ED_view3d_project_float_v3_m4(const ARegion *ar, const float vec[3], float r_co[3], float mat[4][4])
{
float vec4[4];
-
+
copy_v3_v3(vec4, vec);
vec4[3] = 1.0;
/* r_co[0] = IS_CLIPPED; */ /* always overwritten */
-
+
mul_m4_v4(mat, vec4);
-
+
if (vec4[3] > FLT_EPSILON) {
r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
@@ -551,10 +551,10 @@ void ED_view3d_win_to_delta(const ARegion *ar, const float mval[2], float out[3]
{
RegionView3D *rv3d = ar->regiondata;
float dx, dy;
-
+
dx = 2.0f * mval[0] * zfac / ar->winx;
dy = 2.0f * mval[1] * zfac / ar->winy;
-
+
out[0] = (rv3d->persinv[0][0] * dx + rv3d->persinv[1][0] * dy);
out[1] = (rv3d->persinv[0][1] * dx + rv3d->persinv[1][1] * dy);
out[2] = (rv3d->persinv[0][2] * dx + rv3d->persinv[1][2] * dy);
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c
index c0af3c7caaa..c30b72bfb95 100644
--- a/source/blender/editors/space_view3d/view3d_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_ruler.c
@@ -38,8 +38,9 @@
#include "BLT_translation.h"
#include "BKE_context.h"
-#include "BKE_unit.h"
#include "BKE_gpencil.h"
+#include "BKE_main.h"
+#include "BKE_unit.h"
#include "BIF_gl.h"
@@ -267,6 +268,7 @@ static bool view3d_ruler_pick(RulerInfo *ruler_info, const float mval[2],
*/
static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state)
{
+ Main *bmain = CTX_data_main(C);
if (state == ruler_info->state) {
return;
}
@@ -282,7 +284,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state)
}
else if (state == RULER_STATE_DRAG) {
ruler_info->snap_context = ED_transform_snap_object_context_create_view3d(
- CTX_data_scene(C), CTX_data_depsgraph(C), 0,
+ bmain, CTX_data_scene(C), CTX_data_depsgraph(C), 0,
ruler_info->ar, CTX_wm_view3d(C));
}
else {
@@ -326,7 +328,7 @@ static bool view3d_ruler_to_gpencil(bContext *C, RulerInfo *ruler_info)
if (palcolor == NULL) {
palcolor = BKE_gpencil_palettecolor_addnew(palette, (char *)ruler_name, true);
}
-
+
gpf = BKE_gpencil_layer_getframe(gpl, CFRA, true);
BKE_gpencil_free_strokes(gpf);
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index be5653a3021..f4e39c7a563 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -116,6 +116,7 @@ void ED_view3d_viewcontext_init(bContext *C, ViewContext *vc)
{
memset(vc, 0, sizeof(ViewContext));
vc->ar = CTX_wm_region(C);
+ vc->bmain = CTX_data_main(C);
vc->depsgraph = CTX_data_depsgraph(C);
vc->scene = CTX_data_scene(C);
vc->view_layer = CTX_data_view_layer(C);
@@ -299,25 +300,25 @@ static bool edge_fully_inside_rect(const rctf *rect, const float v1[2], const fl
static bool edge_inside_rect(const rctf *rect, const float v1[2], const float v2[2])
{
int d1, d2, d3, d4;
-
+
/* check points in rect */
if (edge_fully_inside_rect(rect, v1, v2)) return 1;
-
+
/* check points completely out rect */
if (v1[0] < rect->xmin && v2[0] < rect->xmin) return 0;
if (v1[0] > rect->xmax && v2[0] > rect->xmax) return 0;
if (v1[1] < rect->ymin && v2[1] < rect->ymin) return 0;
if (v1[1] > rect->ymax && v2[1] > rect->ymax) return 0;
-
+
/* simple check lines intersecting. */
d1 = (v1[1] - v2[1]) * (v1[0] - rect->xmin) + (v2[0] - v1[0]) * (v1[1] - rect->ymin);
d2 = (v1[1] - v2[1]) * (v1[0] - rect->xmin) + (v2[0] - v1[0]) * (v1[1] - rect->ymax);
d3 = (v1[1] - v2[1]) * (v1[0] - rect->xmax) + (v2[0] - v1[0]) * (v1[1] - rect->ymax);
d4 = (v1[1] - v2[1]) * (v1[0] - rect->xmax) + (v2[0] - v1[0]) * (v1[1] - rect->ymin);
-
+
if (d1 < 0 && d2 < 0 && d3 < 0 && d4 < 0) return 0;
if (d1 > 0 && d2 > 0 && d3 > 0 && d4 > 0) return 0;
-
+
return 1;
}
@@ -373,7 +374,7 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, const int mcords[]
ViewContext vc_tmp;
LassoSelectUserData data;
rcti rect;
-
+
if ((ob->type != OB_ARMATURE) || (ob->pose == NULL)) {
return;
}
@@ -417,22 +418,24 @@ static void do_lasso_select_objects(
{
bool is_pose_mode = vc->obact ? (vc->obact->mode & OB_MODE_POSE) : false;
Base *base;
-
+
if (extend == false && select)
object_deselect_all_visible(vc->view_layer);
for (base = vc->view_layer->object_bases.first; base; base = base->next) {
if (BASE_SELECTABLE(base)) { /* use this to avoid un-needed lasso lookups */
- if (ED_view3d_project_base(vc->ar, base) == V3D_PROJ_RET_OK) {
+ if (
+#ifdef USE_OBJECT_MODE_STRICT
+ (is_pose_mode == false) &&
+#endif
+ ED_view3d_project_base(vc->ar, base) == V3D_PROJ_RET_OK)
+ {
if (BLI_lasso_is_point_inside(mcords, moves, base->sx, base->sy, IS_CLIPPED)) {
ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT);
}
}
- if (is_pose_mode &&
- ((vc->obact == base->object) || (base->flag & BASE_SELECTED)) &&
- (base->object->mode & OB_MODE_POSE))
- {
+ if (is_pose_mode && (base->object->mode & OB_MODE_POSE)) {
do_lasso_select_pose(vc, base->object, mcords, moves, select);
}
}
@@ -495,7 +498,7 @@ static void do_lasso_select_mesh(
ToolSettings *ts = vc->scene->toolsettings;
rcti rect;
int bbsel;
-
+
/* set editmesh */
vc->em = BKE_editmesh_from_object(vc->obedit);
@@ -511,7 +514,7 @@ static void do_lasso_select_mesh(
gpuLoadMatrix(vc->rv3d->viewmat);
bbsel = EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
-
+
if (ts->selectmode & SCE_SELECT_VERTEX) {
if (bbsel) {
edbm_backbuf_check_and_select_verts(vc->em, select);
@@ -530,7 +533,7 @@ static void do_lasso_select_mesh(
mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
}
}
-
+
if (ts->selectmode & SCE_SELECT_FACE) {
if (bbsel) {
edbm_backbuf_check_and_select_faces(vc->em, select);
@@ -539,7 +542,7 @@ static void do_lasso_select_mesh(
mesh_foreachScreenFace(vc, do_lasso_select_mesh__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
-
+
EDBM_backbuf_free();
EDBM_selectmode_flush(vc->em);
}
@@ -791,7 +794,7 @@ static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], sh
BLI_lasso_boundbox(&rect, mcords, moves);
EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
-
+
edbm_backbuf_check_and_select_tfaces(me, select);
EDBM_backbuf_free();
@@ -803,19 +806,19 @@ static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], sh
static void do_lasso_select_node(int mcords[][2], short moves, const bool select)
{
SpaceNode *snode = sa->spacedata.first;
-
+
bNode *node;
rcti rect;
int node_cent[2];
float node_centf[2];
-
+
BLI_lasso_boundbox(&rect, mcords, moves);
-
+
/* store selection in temp test flag */
for (node = snode->edittree->nodes.first; node; node = node->next) {
node_centf[0] = BLI_RCT_CENTER_X(&node->totr);
node_centf[1] = BLI_RCT_CENTER_Y(&node->totr);
-
+
ipoco_to_areaco_noclip(G.v2d, node_centf, node_cent);
if (BLI_rcti_isect_pt_v(&rect, node_cent) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) {
if (select) {
@@ -896,18 +899,18 @@ static int view3d_lasso_select_exec(bContext *C, wmOperator *op)
ViewContext vc;
int mcords_tot;
const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
-
+
if (mcords) {
bool extend, select;
view3d_operator_needs_opengl(C);
-
+
/* setup view context for argument to callbacks */
ED_view3d_viewcontext_init(C, &vc);
-
+
extend = RNA_boolean_get(op->ptr, "extend");
select = !RNA_boolean_get(op->ptr, "deselect");
view3d_lasso_select(C, &vc, mcords, mcords_tot, extend, select);
-
+
MEM_freeN((void *)mcords);
return OPERATOR_FINISHED;
@@ -920,16 +923,16 @@ void VIEW3D_OT_select_lasso(wmOperatorType *ot)
ot->name = "Lasso Select";
ot->description = "Select items using lasso selection";
ot->idname = "VIEW3D_OT_select_lasso";
-
+
ot->invoke = WM_gesture_lasso_invoke;
ot->modal = WM_gesture_lasso_modal;
ot->exec = view3d_lasso_select_exec;
ot->poll = view3d_selectable_data;
ot->cancel = WM_gesture_lasso_cancel;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
-
+
/* properties */
WM_operator_properties_gesture_lasso_select(ot);
}
@@ -1249,6 +1252,25 @@ static int mixed_bones_object_selectbuffer(
finally:
view3d_opengl_select_cache_end();
+#ifdef USE_OBJECT_MODE_STRICT
+ {
+ const bool is_pose_mode = (vc->obact && vc->obact->mode & OB_MODE_POSE);
+ struct {
+ uint data[4];
+ } *buffer4 = (void *)buffer;
+ uint j = 0;
+ for (uint i = 0; i < hits; i++) {
+ if (((buffer4[i].data[3] & 0xFFFF0000) != 0) == is_pose_mode) {
+ if (i != j) {
+ buffer4[j] = buffer4[i];
+ }
+ j++;
+ }
+ }
+ hits = j;
+ }
+#endif
+
return hits;
}
@@ -1260,12 +1282,12 @@ static Base *mouse_select_eval_buffer(
ViewLayer *view_layer = vc->view_layer;
Base *base, *basact = NULL;
int a;
-
+
if (do_nearest) {
unsigned int min = 0xFFFFFFFF;
int selcol = 0, notcol = 0;
-
-
+
+
if (has_bones) {
/* we skip non-bone hits */
for (a = 0; a < hits; a++) {
@@ -1280,7 +1302,7 @@ static Base *mouse_select_eval_buffer(
if (BASACT(view_layer) && (BASACT(view_layer)->flag & BASE_SELECTED) && hits > 1) {
notcol = BASACT(view_layer)->object->select_color;
}
-
+
for (a = 0; a < hits; a++) {
if (min > buffer[4 * a + 1] && notcol != (buffer[4 * a + 3] & 0xFFFF)) {
min = buffer[4 * a + 1];
@@ -1288,7 +1310,7 @@ static Base *mouse_select_eval_buffer(
}
}
}
-
+
base = FIRSTBASE(view_layer);
while (base) {
if (BASE_SELECTABLE(base)) {
@@ -1299,7 +1321,7 @@ static Base *mouse_select_eval_buffer(
if (base) basact = base;
}
else {
-
+
base = startbase;
while (base) {
/* skip objects with select restriction, to prevent prematurely ending this loop
@@ -1309,7 +1331,7 @@ static Base *mouse_select_eval_buffer(
if (base == NULL) base = FIRSTBASE(view_layer);
if (base == startbase) break;
}
-
+
if (BASE_SELECTABLE(base)) {
for (a = 0; a < hits; a++) {
if (has_bones) {
@@ -1325,15 +1347,15 @@ static Base *mouse_select_eval_buffer(
}
}
}
-
+
if (basact) break;
-
+
base = base->next;
if (base == NULL) base = FIRSTBASE(view_layer);
if (base == startbase) break;
}
}
-
+
return basact;
}
@@ -1345,19 +1367,19 @@ Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2])
unsigned int buffer[MAXPICKBUF];
int hits;
bool do_nearest;
-
+
/* setup view context for argument to callbacks */
view3d_operator_needs_opengl(C);
ED_view3d_viewcontext_init(C, &vc);
-
+
hits = mixed_bones_object_selectbuffer(&vc, buffer, mval, false, false, &do_nearest);
-
+
if (hits > 0) {
const bool has_bones = selectbuffer_has_bones(buffer, hits);
basact = mouse_select_eval_buffer(&vc, buffer, hits, vc.view_layer->object_bases.first, has_bones, do_nearest);
}
-
+
return basact;
}
@@ -1389,14 +1411,14 @@ static bool ed_object_select_pick(
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- Base *base, *startbase = NULL, *basact = NULL, *oldbasact = NULL;
+ Base *base, *startbase = NULL, *basact = NULL, *oldbasact = BASACT(view_layer);
+ const eObjectMode object_mode = oldbasact ? oldbasact->object->mode : OB_MODE_OBJECT;
bool is_obedit;
float dist = ED_view3d_select_dist_px() * 1.3333f;
bool retval = false;
int hits;
const float mval_fl[2] = {(float)mval[0], (float)mval[1]};
-
/* setup view context for argument to callbacks */
ED_view3d_viewcontext_init(C, &vc);
@@ -1412,11 +1434,11 @@ static bool ed_object_select_pick(
/* always start list from basact in wire mode */
startbase = FIRSTBASE(view_layer);
if (BASACT(view_layer) && BASACT(view_layer)->next) startbase = BASACT(view_layer)->next;
-
+
/* This block uses the control key to make the object selected by its center point rather than its contents */
/* in editmode do not activate */
if (obcenter) {
-
+
/* note; shift+alt goes to group-flush-selecting */
if (enumerate) {
basact = object_mouse_select_menu(C, &vc, NULL, 0, mval, toggle);
@@ -1439,11 +1461,24 @@ static bool ed_object_select_pick(
}
}
base = base->next;
-
+
if (base == NULL) base = FIRSTBASE(view_layer);
if (base == startbase) break;
}
}
+#ifdef USE_OBJECT_MODE_STRICT
+ if (is_obedit == false) {
+ if (basact && !BKE_object_is_mode_compat(basact->object, object_mode)) {
+ if (object_mode == OB_MODE_OBJECT) {
+ struct Main *bmain = CTX_data_main(C);
+ ED_object_mode_generic_exit(bmain, vc.depsgraph, scene, basact->object);
+ }
+ if (!BKE_object_is_mode_compat(basact->object, object_mode)) {
+ basact = NULL;
+ }
+ }
+ }
+#endif
}
else {
unsigned int buffer[MAXPICKBUF];
@@ -1467,7 +1502,21 @@ static bool ed_object_select_pick(
else {
basact = mouse_select_eval_buffer(&vc, buffer, hits, startbase, has_bones, do_nearest);
}
-
+
+#ifdef USE_OBJECT_MODE_STRICT
+ if (is_obedit == false) {
+ if (basact && !BKE_object_is_mode_compat(basact->object, object_mode)) {
+ if (object_mode == OB_MODE_OBJECT) {
+ struct Main *bmain = CTX_data_main(C);
+ ED_object_mode_generic_exit(bmain, vc.depsgraph, scene, basact->object);
+ }
+ if (!BKE_object_is_mode_compat(basact->object, object_mode)) {
+ basact = NULL;
+ }
+ }
+ }
+#endif
+
if (has_bones && basact) {
if (basact->object->type == OB_CAMERA) {
if (BASACT(view_layer) == basact) {
@@ -1531,16 +1580,16 @@ static bool ed_object_select_pick(
view_layer, basact, buffer, hits, extend, deselect, toggle, do_nearest))
{
/* then bone is found */
-
- /* we make the armature selected:
+
+ /* we make the armature selected:
* not-selected active object in posemode won't work well for tools */
basact->flag |= BASE_SELECTED;
BKE_scene_object_base_flag_sync_from_base(basact);
-
+
retval = true;
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, basact->object);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, basact->object);
-
+
/* in weightpaint, we use selected bone to select vertexgroup, so no switch to new active object */
if (BASACT(view_layer) && (BASACT(view_layer)->object->mode & OB_MODE_WEIGHT_PAINT)) {
/* prevent activating */
@@ -1554,11 +1603,25 @@ static bool ed_object_select_pick(
}
}
}
-
+
+#ifdef USE_OBJECT_MODE_STRICT
+ /* Disallow switching modes,
+ * special exception for edit-mode - vertex-parent operator. */
+ if (is_obedit == false) {
+ if (oldbasact && basact) {
+ if ((oldbasact->object->mode != basact->object->mode) &&
+ (oldbasact->object->mode & basact->object->mode) == 0)
+ {
+ basact = NULL;
+ }
+ }
+ }
+#endif
+
/* so, do we have something selected? */
if (basact) {
retval = true;
-
+
if (vc.obedit) {
/* only do select */
deselectall_except(view_layer, basact);
@@ -1566,9 +1629,6 @@ static bool ed_object_select_pick(
}
/* also prevent making it active on mouse selection */
else if (BASE_SELECTABLE(basact)) {
-
- oldbasact = BASACT(view_layer);
-
if (extend) {
ED_object_base_select(basact, BA_SELECT);
}
@@ -1768,7 +1828,7 @@ static void do_nurbs_box_select__doSelect(
static int do_nurbs_box_select(ViewContext *vc, rcti *rect, bool select, bool extend)
{
BoxSelectUserData data;
-
+
view3d_userdata_boxselect_init(&data, vc, rect, select);
if (extend == false && select) {
@@ -1802,7 +1862,7 @@ static int do_lattice_box_select(ViewContext *vc, rcti *rect, bool select, bool
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
lattice_foreachScreenVert(vc, do_lattice_box_select__doSelect, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
-
+
return OPERATOR_FINISHED;
}
@@ -1847,7 +1907,7 @@ static int do_mesh_box_select(
BoxSelectUserData data;
ToolSettings *ts = vc->scene->toolsettings;
int bbsel;
-
+
view3d_userdata_boxselect_init(&data, vc, rect, select);
if (extend == false && select)
@@ -1878,7 +1938,7 @@ static int do_mesh_box_select(
mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
}
}
-
+
if (ts->selectmode & SCE_SELECT_FACE) {
if (bbsel) {
edbm_backbuf_check_and_select_faces(vc->em, select);
@@ -1887,11 +1947,11 @@ static int do_mesh_box_select(
mesh_foreachScreenFace(vc, do_mesh_box_select__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
-
+
EDBM_backbuf_free();
-
+
EDBM_selectmode_flush(vc->em);
-
+
return OPERATOR_FINISHED;
}
@@ -1910,7 +1970,7 @@ static int do_meta_box_select(
if (extend == false && select)
BKE_mball_deselect_all(mb);
-
+
for (ml = mb->editelems->first; ml; ml = ml->next) {
for (a = 0; a < hits; a++) {
if (ml->selcol1 == buffer[(4 * a) + 3]) {
@@ -2061,12 +2121,12 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
int bone_only;
int totobj = MAXPICKBUF; /* XXX solve later */
int hits;
-
+
if (vc->obact && (vc->obact->mode & OB_MODE_POSE))
bone_only = 1;
else
bone_only = 0;
-
+
if (extend == false && select) {
if (bone_only) {
FOREACH_OBJECT_IN_MODE_BEGIN (vc->view_layer, OB_MODE_POSE, ob_iter) {
@@ -2172,7 +2232,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
/* mask modifier ('armature' mode), etc. */
DEG_id_tag_update(&vc->obact->id, OB_RECALC_DATA);
}
-
+
/* copy on write tag is needed (for the armature), or else no refresh happens */
DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
}
@@ -2201,7 +2261,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
/* setup view context for argument to callbacks */
ED_view3d_viewcontext_init(C, &vc);
-
+
select = !RNA_boolean_get(op->ptr, "deselect");
extend = RNA_boolean_get(op->ptr, "extend");
WM_operator_properties_border_to_rcti(op, &rect);
@@ -2277,7 +2337,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
}
return ret;
-}
+}
/* *****************Selection Operators******************* */
@@ -2289,17 +2349,17 @@ void VIEW3D_OT_select_border(wmOperatorType *ot)
ot->name = "Border Select";
ot->description = "Select items using border selection";
ot->idname = "VIEW3D_OT_select_border";
-
+
/* api callbacks */
ot->invoke = WM_gesture_border_invoke;
ot->exec = view3d_borderselect_exec;
ot->modal = WM_gesture_border_modal;
ot->poll = view3d_selectable_data;
ot->cancel = WM_gesture_border_cancel;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
-
+
/* rna */
WM_operator_properties_gesture_border_select(ot);
}
@@ -2399,7 +2459,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
retval = ED_mball_select_pick(C, location, extend, deselect, toggle);
else if (obedit->type == OB_FONT)
retval = ED_curve_editfont_select_pick(C, location, extend, deselect, toggle);
-
+
}
else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT)
return PE_mouse_particles(C, location, extend, deselect, toggle);
@@ -2434,15 +2494,15 @@ void VIEW3D_OT_select(wmOperatorType *ot)
ot->name = "Activate/Select";
ot->description = "Activate/select item(s)";
ot->idname = "VIEW3D_OT_select";
-
+
/* api callbacks */
ot->invoke = view3d_select_invoke;
ot->exec = view3d_select_exec;
ot->poll = ED_operator_view3d_active;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
-
+
/* properties */
WM_operator_properties_mouse_select(ot);
@@ -2517,7 +2577,7 @@ static void mesh_circle_select(ViewContext *vc, const bool select, const int mva
ToolSettings *ts = vc->scene->toolsettings;
int bbsel;
CircleSelectUserData data;
-
+
bbsel = EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f));
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
@@ -2542,7 +2602,7 @@ static void mesh_circle_select(ViewContext *vc, const bool select, const int mva
mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
}
}
-
+
if (ts->selectmode & SCE_SELECT_FACE) {
if (bbsel) {
edbm_backbuf_check_and_select_faces(vc->em, select);
@@ -2735,11 +2795,11 @@ static void do_circle_select_pose__doSelectBone(
static void pose_circle_select(ViewContext *vc, const bool select, const int mval[2], float rad)
{
CircleSelectUserData data;
-
+
view3d_userdata_circleselect_init(&data, vc, select, mval, rad);
ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); /* for foreach's screen/vert projection */
-
+
pose_foreachScreenBone(vc, do_circle_select_pose__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
if (data.is_changed) {
@@ -2751,7 +2811,7 @@ static void pose_circle_select(ViewContext *vc, const bool select, const int mva
/* mask modifier ('armature' mode), etc. */
DEG_id_tag_update(&vc->obact->id, OB_RECALC_DATA);
}
-
+
/* copy on write tag is needed (for the armature), or else no refresh happens */
DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
}
@@ -2765,13 +2825,13 @@ static bool armature_circle_doSelectJoint(void *userData, EditBone *ebone, const
if (head) {
if (data->select)
ebone->flag |= BONE_ROOTSEL;
- else
+ else
ebone->flag &= ~BONE_ROOTSEL;
}
else {
if (data->select)
ebone->flag |= BONE_TIPSEL;
- else
+ else
ebone->flag &= ~BONE_TIPSEL;
}
return 1;
@@ -2971,7 +3031,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc.scene);
}
}
-
+
return OPERATOR_FINISHED;
}
@@ -2980,13 +3040,13 @@ void VIEW3D_OT_select_circle(wmOperatorType *ot)
ot->name = "Circle Select";
ot->description = "Select items using circle selection";
ot->idname = "VIEW3D_OT_select_circle";
-
+
ot->invoke = WM_gesture_circle_invoke;
ot->modal = WM_gesture_circle_modal;
ot->exec = view3d_circle_select_exec;
ot->poll = view3d_selectable_data;
ot->cancel = WM_gesture_circle_cancel;
-
+
/* flags */
ot->flag = OPTYPE_UNDO;
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 13d2ceb4ad4..606c07cd1fa 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -140,15 +140,15 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
if (ob->mode & OB_MODE_POSE) {
bPoseChannel *pchan_eval;
bArmature *arm_eval = ob_eval->data;
-
+
invert_m4_m4(ob_eval->imat, ob_eval->obmat);
-
+
for (pchan_eval = ob_eval->pose->chanbase.first; pchan_eval; pchan_eval = pchan_eval->next) {
if (pchan_eval->bone->flag & BONE_SELECTED) {
if (pchan_eval->bone->layer & arm_eval->layer) {
if ((pchan_eval->bone->flag & BONE_CONNECTED) == 0) {
float nLoc[3];
-
+
/* get nearest grid point to snap to */
copy_v3_v3(nLoc, pchan_eval->pose_mat[3]);
/* We must operate in world space! */
@@ -158,10 +158,10 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
vec[2] = gridf * floorf(0.5f + nLoc[2] / gridf);
/* Back in object space... */
mul_m4_v3(ob_eval->imat, vec);
-
+
/* Get location of grid point in pose space. */
BKE_armature_loc_pose_to_bone(pchan_eval, vec, vec);
-
+
/* adjust location on the original pchan*/
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, pchan_eval->name);
if ((pchan->protectflag & OB_LOCK_LOCX) == 0)
@@ -181,18 +181,18 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
}
}
ob->pose->flag |= (POSE_LOCKED | POSE_DO_UNLOCK);
-
+
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
else {
vec[0] = -ob_eval->obmat[3][0] + gridf * floorf(0.5f + ob_eval->obmat[3][0] / gridf);
vec[1] = -ob_eval->obmat[3][1] + gridf * floorf(0.5f + ob_eval->obmat[3][1] / gridf);
vec[2] = -ob_eval->obmat[3][2] + gridf * floorf(0.5f + ob_eval->obmat[3][2] / gridf);
-
+
if (ob->parent) {
float originmat[3][3];
BKE_object_where_is_calc_ex(depsgraph, scene, NULL, ob, originmat);
-
+
invert_m3_m3(imat, originmat);
mul_m3_v3(imat, vec);
}
@@ -202,7 +202,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
ob->loc[1] = ob_eval->loc[1] + vec[1];
if ((ob->protectflag & OB_LOCK_LOCZ) == 0)
ob->loc[2] = ob_eval->loc[2] + vec[2];
-
+
/* auto-keyframing */
ED_autokeyframe_object(C, scene, ob, ks);
@@ -213,7 +213,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
}
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -223,11 +223,11 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot)
ot->name = "Snap Selection to Grid";
ot->description = "Snap selected item(s) to nearest grid division";
ot->idname = "VIEW3D_OT_snap_selected_to_grid";
-
+
/* api callbacks */
ot->exec = snap_sel_to_grid_exec;
ot->poll = ED_operator_region_view3d_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -262,7 +262,7 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global
if (obedit) {
float snap_target_local[3];
-
+
if (ED_transverts_check_obedit(obedit))
ED_transverts_create_from_obedit(&tvs, obedit, 0);
if (tvs.transverts_tot == 0)
@@ -270,7 +270,7 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global
copy_m3_m4(bmat, obedit->obmat);
invert_m3_m3(imat, bmat);
-
+
/* get the cursor in object space */
sub_v3_v3v3(snap_target_local, snap_target_global, obedit->obmat[3]);
mul_m3_v3(imat, snap_target_local);
@@ -291,7 +291,7 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global
copy_v3_v3(tv->loc, snap_target_local);
}
}
-
+
ED_transverts_update_obedit(&tvs, obedit);
ED_transverts_free(&tvs);
}
@@ -423,7 +423,7 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global
}
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -445,11 +445,11 @@ void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot)
ot->name = "Snap Selection to Cursor";
ot->description = "Snap selected item(s) to cursor";
ot->idname = "VIEW3D_OT_snap_selected_to_cursor";
-
+
/* api callbacks */
ot->exec = snap_selected_to_cursor_exec;
ot->poll = ED_operator_view3d_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -500,7 +500,7 @@ static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
curs[0] = gridf * floorf(0.5f + curs[0] / gridf);
curs[1] = gridf * floorf(0.5f + curs[1] / gridf);
curs[2] = gridf * floorf(0.5f + curs[2] / gridf);
-
+
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); /* hrm */
DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
@@ -513,18 +513,18 @@ void VIEW3D_OT_snap_cursor_to_grid(wmOperatorType *ot)
ot->name = "Snap Cursor to Grid";
ot->description = "Snap cursor to nearest grid division";
ot->idname = "VIEW3D_OT_snap_cursor_to_grid";
-
+
/* api callbacks */
ot->exec = snap_curs_to_grid_exec;
ot->poll = ED_operator_region_view3d_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* **************************************************** */
-static void bundle_midpoint(Scene *scene, Object *ob, float vec[3])
+static void bundle_midpoint(Depsgraph *depsgraph, Scene *scene, Object *ob, float vec[3])
{
MovieClip *clip = BKE_object_movieclip_get(scene, ob, false);
MovieTracking *tracking;
@@ -539,7 +539,7 @@ static void bundle_midpoint(Scene *scene, Object *ob, float vec[3])
copy_m4_m4(cammat, ob->obmat);
- BKE_tracking_get_camera_object_matrix(scene, ob, mat);
+ BKE_tracking_get_camera_object_matrix(depsgraph, scene, ob, mat);
INIT_MINMAX(min, max);
@@ -578,7 +578,7 @@ static void bundle_midpoint(Scene *scene, Object *ob, float vec[3])
static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph);
Object *obedit = CTX_data_edit_object(C);
Scene *scene = CTX_data_scene(C);
@@ -602,7 +602,7 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
Object *obedit_eval = DEG_get_evaluated_object(depsgraph, obedit);
copy_m3_m4(bmat, obedit_eval->obmat);
-
+
tv = tvs.transverts;
for (a = 0; a < tvs.transverts_tot; a++, tv++) {
copy_v3_v3(vec, tv->loc);
@@ -611,7 +611,7 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
add_v3_v3(centroid, vec);
minmax_v3v3_v3(min, max, vec);
}
-
+
if (scene->toolsettings->transform_pivot_point == V3D_AROUND_CENTER_MEAN) {
mul_v3_fl(centroid, 1.0f / (float)tvs.transverts_tot);
copy_v3_v3(cursor, centroid);
@@ -650,7 +650,7 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
if (ob_eval->type == OB_CAMERA) {
/* snap to bundles should happen only when bundles are visible */
if (v3d->flag2 & V3D_SHOW_RECONSTRUCTION) {
- bundle_midpoint(scene, DEG_get_original_object(ob_eval), vec);
+ bundle_midpoint(depsgraph, scene, DEG_get_original_object(ob_eval), vec);
}
}
@@ -701,11 +701,11 @@ void VIEW3D_OT_snap_cursor_to_selected(wmOperatorType *ot)
ot->name = "Snap Cursor to Selected";
ot->description = "Snap cursor to center of selected item(s)";
ot->idname = "VIEW3D_OT_snap_cursor_to_selected";
-
+
/* api callbacks */
ot->exec = snap_curs_to_sel_exec;
ot->poll = ED_operator_view3d_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -761,7 +761,7 @@ static int snap_curs_to_active_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
float *curs;
-
+
curs = ED_view3d_cursor3d_get(scene, v3d)->location;
if (snap_calc_active_center(C, false, curs)) {
@@ -781,11 +781,11 @@ void VIEW3D_OT_snap_cursor_to_active(wmOperatorType *ot)
ot->name = "Snap Cursor to Active";
ot->description = "Snap cursor to active item";
ot->idname = "VIEW3D_OT_snap_cursor_to_active";
-
+
/* api callbacks */
ot->exec = snap_curs_to_active_exec;
ot->poll = ED_operator_view3d_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -800,7 +800,7 @@ static int snap_curs_to_center_exec(bContext *C, wmOperator *UNUSED(op))
curs = ED_view3d_cursor3d_get(scene, v3d)->location;
zero_v3(curs);
-
+
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
@@ -813,11 +813,11 @@ void VIEW3D_OT_snap_cursor_to_center(wmOperatorType *ot)
ot->name = "Snap Cursor to Center";
ot->description = "Snap cursor to the Center";
ot->idname = "VIEW3D_OT_snap_cursor_to_center";
-
+
/* api callbacks */
ot->exec = snap_curs_to_center_exec;
ot->poll = ED_operator_view3d_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -847,12 +847,12 @@ bool ED_view3d_minmax_verts(Object *obedit, float min[3], float max[3])
if (ED_transverts_check_obedit(obedit))
ED_transverts_create_from_obedit(&tvs, obedit, TM_ALL_JOINTS);
-
+
if (tvs.transverts_tot == 0)
return false;
copy_m3_m4(bmat, obedit->obmat);
-
+
tv = tvs.transverts;
for (a = 0; a < tvs.transverts_tot; a++, tv++) {
copy_v3_v3(vec, (tv->flag & TX_VERT_USE_MAPLOC) ? tv->maploc : tv->loc);
@@ -861,8 +861,8 @@ bool ED_view3d_minmax_verts(Object *obedit, float min[3], float max[3])
add_v3_v3(centroid, vec);
minmax_v3v3_v3(min, max, vec);
}
-
+
ED_transverts_free(&tvs);
-
+
return true;
}
diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c
index 26dca5bf252..8ea33927c4d 100644
--- a/source/blender/editors/space_view3d/view3d_toolbar.c
+++ b/source/blender/editors/space_view3d/view3d_toolbar.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -73,15 +73,15 @@ typedef struct CustomTool {
static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2)
{
wmOperatorType *ot = arg2;
-
+
if (ot) {
CustomTool *ct = MEM_callocN(sizeof(CustomTool), "CustomTool");
-
+
BLI_addtail(arg_listbase, ct);
BLI_strncpy(ct->opname, ot->idname, OP_MAX_TYPENAME);
BLI_strncpy(ct->context, CTX_data_mode_string(C), OP_MAX_TYPENAME);
}
-
+
}
static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items)
@@ -93,7 +93,7 @@ static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), cons
if (BLI_strcasestr(ot->name, str)) {
if (WM_operator_poll((bContext *)C, ot)) {
-
+
if (false == UI_search_item_add(items, ot->name, ot, 0))
break;
}
@@ -110,30 +110,30 @@ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase)
wmWindow *win = CTX_wm_window(C);
uiBlock *block;
uiBut *but;
-
+
/* clear initial search string, then all items show */
search[0] = 0;
-
+
block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_SEARCH_MENU);
-
+
/* fake button, it holds space for search items */
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 15, UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL);
-
+
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, 19, 0, 0, "");
UI_but_func_search_set(but, NULL, operator_search_cb, arg_listbase, operator_call_cb, NULL);
-
+
UI_block_bounds_set_normal(block, 6);
UI_block_direction_set(block, UI_DIR_DOWN);
UI_block_end(C, block);
-
+
wm_event_init_from_window(win, &event);
event.type = EVT_BUT_OPEN;
event.val = KM_PRESS;
event.customdata = but;
event.customdatafree = false;
wm_event_add(win, &event);
-
+
return block;
}
@@ -144,13 +144,13 @@ static void view3d_panel_tool_shelf(const bContext *C, Panel *pa)
SpaceType *st = NULL;
uiLayout *col;
const char *context = CTX_data_mode_string(C);
-
+
if (sl)
st = BKE_spacetype_from_id(sl->spacetype);
-
+
if (st && st->toolshelf.first) {
CustomTool *ct;
-
+
for (ct = st->toolshelf.first; ct; ct = ct->next) {
if (STREQLEN(context, ct->context, OP_MAX_TYPENAME)) {
col = uiLayoutColumn(pa->layout, true);
@@ -181,7 +181,7 @@ static int view3d_toolshelf_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = view3d_has_tools_region(sa);
-
+
if (ar)
ED_region_toggle_hidden(C, ar);
@@ -193,10 +193,10 @@ void VIEW3D_OT_toolshelf(wmOperatorType *ot)
ot->name = "Tool Shelf";
ot->description = "Toggles tool shelf display";
ot->idname = "VIEW3D_OT_toolshelf";
-
+
ot->exec = view3d_toolshelf_toggle_exec;
ot->poll = ED_operator_view3d_active;
-
+
/* flags */
ot->flag = 0;
}
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index 90b1b043de6..ca5375b6b54 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -46,6 +46,7 @@
#include "BKE_camera.h"
#include "BKE_context.h"
+#include "BKE_main.h"
#include "BKE_object.h"
#include "BKE_screen.h"
@@ -899,7 +900,7 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg
* \param fallback_depth_pt: Use this points depth when no depth can be found.
*/
bool ED_view3d_autodist(
- struct Depsgraph *graph, ARegion *ar, View3D *v3d,
+ Depsgraph *depsgraph, ARegion *ar, View3D *v3d,
const int mval[2], float mouse_worldloc[3],
const bool alphaoverride, const float fallback_depth_pt[3])
{
@@ -909,7 +910,7 @@ bool ED_view3d_autodist(
bool depth_ok = false;
/* Get Z Depths, needed for perspective, nice for ortho */
- ED_view3d_draw_depth(graph, ar, v3d, alphaoverride);
+ ED_view3d_draw_depth(depsgraph, ar, v3d, alphaoverride);
/* Attempt with low margin's first */
i = 0;
@@ -936,19 +937,18 @@ bool ED_view3d_autodist(
}
}
-void ED_view3d_autodist_init(
- struct Depsgraph *graph,
+void ED_view3d_autodist_init(Depsgraph *depsgraph,
ARegion *ar, View3D *v3d, int mode)
{
/* Get Z Depths, needed for perspective, nice for ortho */
switch (mode) {
case 0:
- ED_view3d_draw_depth(graph, ar, v3d, true);
+ ED_view3d_draw_depth(depsgraph, ar, v3d, true);
break;
case 1:
{
- Scene *scene = DEG_get_evaluated_scene(graph);
- ED_view3d_draw_depth_gpencil(graph, scene, ar, v3d);
+ Scene *scene = DEG_get_evaluated_scene(depsgraph);
+ ED_view3d_draw_depth_gpencil(depsgraph, scene, ar, v3d);
break;
}
}
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 0a490a8b494..73b9a67ac56 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -181,11 +181,11 @@ void ED_view3d_smooth_view_ex(
ED_view3d_from_object(ob_camera_eval, sms.dst.ofs, sms.dst.quat, &sms.dst.dist, &sms.dst.lens);
sms.to_camera = true; /* restore view3d values in end */
}
-
+
/* skip smooth viewing for render engine draw */
if (smooth_viewtx && v3d->drawtype != OB_RENDER) {
bool changed = false; /* zero means no difference */
-
+
if (sview->camera_old != sview->camera)
changed = true;
else if (sms.dst.dist != rv3d->dist)
@@ -196,7 +196,7 @@ void ED_view3d_smooth_view_ex(
changed = true;
else if (!equals_v4v4(sms.dst.quat, rv3d->viewquat))
changed = true;
-
+
/* The new view is different from the old one
* so animate the view */
if (changed) {
@@ -214,10 +214,10 @@ void ED_view3d_smooth_view_ex(
}
sms.time_allowed = (double)smooth_viewtx / 1000.0;
-
+
/* if this is view rotation only
* we can decrease the time allowed by
- * the angle between quats
+ * the angle between quats
* this means small rotations wont lag */
if (sview->quat && !sview->ofs && !sview->dist) {
/* scale the time allowed by the rotation */
@@ -235,7 +235,7 @@ void ED_view3d_smooth_view_ex(
}
rv3d->rflag |= RV3D_NAVIGATING;
-
+
/* not essential but in some cases the caller will tag the area for redraw,
* and in that case we can get a flicker of the 'org' user view but we want to see 'src' */
view3d_smooth_view_state_restore(&sms.src, v3d, rv3d);
@@ -254,7 +254,7 @@ void ED_view3d_smooth_view_ex(
ok = true;
}
}
-
+
/* if we get here nothing happens */
if (ok == false) {
if (sms.to_camera == false) {
@@ -298,15 +298,15 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool
RegionView3D *rv3d = ar->regiondata;
struct SmoothView3DStore *sms = rv3d->sms;
float step, step_inv;
-
+
if (sms->time_allowed != 0.0)
step = (float)((rv3d->smooth_timer->duration) / sms->time_allowed);
else
step = 1.0f;
-
+
/* end timer */
if (step >= 1.0f) {
-
+
/* if we went to camera, store the original */
if (sms->to_camera) {
rv3d->persp = RV3D_CAMOB;
@@ -318,14 +318,14 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool
ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true);
}
-
+
if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
rv3d->view = sms->org_view;
}
MEM_freeN(rv3d->sms);
rv3d->sms = NULL;
-
+
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), rv3d->smooth_timer);
rv3d->smooth_timer = NULL;
rv3d->rflag &= ~RV3D_NAVIGATING;
@@ -344,7 +344,7 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool
else {
interp_v3_v3v3(rv3d->ofs, sms->src.ofs, sms->dst.ofs, step);
}
-
+
rv3d->dist = sms->dst.dist * step + sms->src.dist * step_inv;
v3d->lens = sms->dst.lens * step + sms->src.lens * step_inv;
@@ -356,7 +356,7 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool
/* Event handling won't know if a UI item has been moved under the pointer. */
WM_event_add_mousemove(C);
}
-
+
if (sync_boxview && (rv3d->viewlock & RV3D_BOXVIEW)) {
view3d_boxview_copy(CTX_wm_area(C), ar);
}
@@ -456,9 +456,9 @@ static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&v3d->camera->id, OB_RECALC_OB);
rv3d->persp = RV3D_CAMOB;
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, v3d->camera);
-
+
return OPERATOR_FINISHED;
}
@@ -488,11 +488,11 @@ void VIEW3D_OT_camera_to_view(wmOperatorType *ot)
ot->name = "Align Camera To View";
ot->description = "Set camera view to active view";
ot->idname = "VIEW3D_OT_camera_to_view";
-
+
/* api callbacks */
ot->exec = view3d_camera_to_view_exec;
ot->poll = view3d_camera_to_view_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -659,7 +659,7 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
}
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, scene);
}
-
+
return OPERATOR_FINISHED;
}
@@ -677,11 +677,11 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot)
ot->name = "Set Active Object as Camera";
ot->description = "Set the active object as the active camera for this view or scene";
ot->idname = "VIEW3D_OT_object_as_camera";
-
+
/* api callbacks */
ot->exec = view3d_setobjectascamera_exec;
ot->poll = ED_operator_rv3d_user_region_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -701,7 +701,7 @@ void view3d_winmatrix_set(Depsgraph *depsgraph, ARegion *ar, const View3D *v3d,
rctf viewplane;
float clipsta, clipend;
bool is_ortho;
-
+
is_ortho = ED_view3d_viewplane_get(depsgraph, v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend, NULL);
rv3d->is_persp = !is_ortho;
@@ -778,13 +778,13 @@ void view3d_viewmatrix_set(
/* should be moved to better initialize later on XXX */
if (rv3d->viewlock & RV3D_LOCKED)
ED_view3d_lock(rv3d);
-
+
quat_to_mat4(rv3d->viewmat, rv3d->viewquat);
if (rv3d->persp == RV3D_PERSP) rv3d->viewmat[3][2] -= rv3d->dist;
if (v3d->ob_centre) {
Object *ob_eval = DEG_get_evaluated_object(depsgraph, v3d->ob_centre);
float vec[3];
-
+
copy_v3_v3(vec, ob_eval->obmat[3]);
if (ob_eval->type == OB_ARMATURE && v3d->ob_centre_bone[0]) {
bPoseChannel *pchan = BKE_pose_channel_find_name(ob_eval->pose, v3d->ob_centre_bone);
@@ -908,7 +908,7 @@ int view3d_opengl_select(
eV3DSelectMode select_mode)
{
struct bThemeState theme_state;
- Depsgraph *graph = vc->depsgraph;
+ Depsgraph *depsgraph = vc->depsgraph;
Scene *scene = vc->scene;
View3D *v3d = vc->v3d;
ARegion *ar = vc->ar;
@@ -975,7 +975,7 @@ int view3d_opengl_select(
/* Important we use the 'viewmat' and don't re-calculate since
* the object & bone view locking takes 'rect' into account, see: T51629. */
- ED_view3d_draw_setup_view(vc->win, graph, scene, ar, v3d, vc->rv3d->viewmat, NULL, &rect);
+ ED_view3d_draw_setup_view(vc->win, depsgraph, scene, ar, v3d, vc->rv3d->viewmat, NULL, &rect);
if (v3d->drawtype > OB_WIRE) {
v3d->zbuf = true;
@@ -984,7 +984,7 @@ int view3d_opengl_select(
if (vc->rv3d->rflag & RV3D_CLIPPING)
ED_view3d_clipping_set(vc->rv3d);
-
+
#ifdef WITH_OPENGL_LEGACY
if (IS_VIEWPORT_LEGACY(vc->v3d)) {
@@ -1012,7 +1012,7 @@ int view3d_opengl_select(
.gpu_select_mode = gpu_select_mode,
};
DRW_draw_select_loop(
- graph, ar, v3d,
+ depsgraph, ar, v3d,
use_obedit_skip, use_nearest, &rect,
drw_select_loop_pass, &drw_select_loop_user_data);
hits = drw_select_loop_user_data.hits;
@@ -1020,13 +1020,13 @@ int view3d_opengl_select(
#endif /* WITH_OPENGL_LEGACY */
G.f &= ~G_PICKSEL;
- ED_view3d_draw_setup_view(vc->win, graph, scene, ar, v3d, vc->rv3d->viewmat, NULL, NULL);
-
+ ED_view3d_draw_setup_view(vc->win, depsgraph, scene, ar, v3d, vc->rv3d->viewmat, NULL, NULL);
+
if (v3d->drawtype > OB_WIRE) {
v3d->zbuf = 0;
glDisable(GL_DEPTH_TEST);
}
-
+
if (vc->rv3d->rflag & RV3D_CLIPPING)
ED_view3d_clipping_disable();
@@ -1052,28 +1052,28 @@ finally:
int ED_view3d_view_layer_set(int lay, const int *values, int *active)
{
int i, tot = 0;
-
+
/* ensure we always have some layer selected */
for (i = 0; i < 20; i++)
if (values[i])
tot++;
-
+
if (tot == 0)
return lay;
-
+
for (i = 0; i < 20; i++) {
-
+
if (active) {
/* if this value has just been switched on, make that layer active */
if (values[i] && (lay & (1 << i)) == 0) {
*active = (1 << i);
}
}
-
+
if (values[i]) lay |= (1 << i);
else lay &= ~(1 << i);
}
-
+
/* ensure always an active layer */
if (active && (lay & *active) == 0) {
for (i = 0; i < 20; i++) {
@@ -1083,7 +1083,7 @@ int ED_view3d_view_layer_set(int lay, const int *values, int *active)
}
}
}
-
+
return lay;
}
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index a7c97ba4d4a..352e85703bc 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -37,6 +37,7 @@
#include "BLI_utildefines.h"
#include "BKE_context.h"
+#include "BKE_main.h"
#include "BKE_report.h"
#include "BLT_translation.h"
@@ -507,6 +508,7 @@ static float userdef_speed = -1.f;
static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
wmWindow *win = CTX_wm_window(C);
walk->rv3d = CTX_wm_region_view3d(C);
@@ -602,7 +604,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
walk->rv3d->rflag |= RV3D_NAVIGATING;
walk->snap_context = ED_transform_snap_object_context_create_view3d(
- walk->scene, CTX_data_depsgraph(C), 0,
+ bmain, walk->scene, CTX_data_depsgraph(C), 0,
walk->ar, walk->v3d);
walk->v3d_camera_control = ED_view3d_cameracontrol_acquire(
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index b713f18da4c..acb92b1606c 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1539,7 +1539,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
/* confirm transform if launch key is released after mouse move */
if (t->flag & T_RELEASE_CONFIRM) {
/* XXX Keyrepeat bug in Xorg messes this up, will test when fixed */
- if (event->type == t->launch_event && (t->launch_event == LEFTMOUSE || t->launch_event == RIGHTMOUSE)) {
+ if ((event->type == t->launch_event) && ISMOUSE(t->launch_event)) {
t->state = TRANS_CONFIRM;
}
}
@@ -2159,14 +2159,8 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->mode = mode;
- t->launch_event = event ? event->type : -1;
-
- if (t->launch_event == EVT_TWEAK_R) {
- t->launch_event = RIGHTMOUSE;
- }
- else if (t->launch_event == EVT_TWEAK_L) {
- t->launch_event = LEFTMOUSE;
- }
+ /* Needed to translate tweak events to mouse buttons. */
+ t->launch_event = event ? WM_userdef_event_type_from_keymap_type(event->type) : -1;
// XXX Remove this when wm_operator_call_internal doesn't use window->eventstate (which can have type = 0)
// For manipulator only, so assume LEFTMOUSE
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 62356cd4ba6..c2548fe497f 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -724,7 +724,7 @@ int special_transform_moving(TransInfo *t);
void transform_autoik_update(TransInfo *t, short mode);
bool transdata_check_local_islands(TransInfo *t, short around);
-int count_set_pose_transflags(int *out_mode, short around, struct Object *ob);
+int count_set_pose_transflags(struct Object *ob, const int mode, const short around, bool has_translate_rotate[2]);
/* auto-keying stuff used by special_aftertrans_update */
void autokeyframe_ob_cb_func(
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index c8b09eef04b..6c608a0b5e4 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -574,17 +574,14 @@ static short apply_targetless_ik(Object *ob)
return apply;
}
-static void add_pose_transdata(
- TransInfo *t, Object *ob, bPoseChannel *pchan,
- Object *ob_eval, bPoseChannel *pchan_eval,
- TransDataContainer *tc, TransData *td)
+static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, TransDataContainer *tc, TransData *td)
{
- Bone *bone = pchan_eval->bone;
+ Bone *bone = pchan->bone;
float pmat[3][3], omat[3][3];
float cmat[3][3], tmat[3][3];
float vec[3];
- copy_v3_v3(vec, pchan_eval->pose_mat[3]);
+ copy_v3_v3(vec, pchan->pose_mat[3]);
copy_v3_v3(td->center, vec);
td->ob = ob;
@@ -601,10 +598,10 @@ static void add_pose_transdata(
td->protectflag = pchan->protectflag;
td->loc = pchan->loc;
- copy_v3_v3(td->iloc, pchan_eval->loc);
+ copy_v3_v3(td->iloc, pchan->loc);
td->ext->size = pchan->size;
- copy_v3_v3(td->ext->isize, pchan_eval->size);
+ copy_v3_v3(td->ext->isize, pchan->size);
if (pchan->rotmode > 0) {
td->ext->rot = pchan->eul;
@@ -612,7 +609,7 @@ static void add_pose_transdata(
td->ext->rotAngle = NULL;
td->ext->quat = NULL;
- copy_v3_v3(td->ext->irot, pchan_eval->eul);
+ copy_v3_v3(td->ext->irot, pchan->eul);
}
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
td->ext->rot = NULL;
@@ -620,8 +617,8 @@ static void add_pose_transdata(
td->ext->rotAngle = &pchan->rotAngle;
td->ext->quat = NULL;
- td->ext->irotAngle = pchan_eval->rotAngle;
- copy_v3_v3(td->ext->irotAxis, pchan_eval->rotAxis);
+ td->ext->irotAngle = pchan->rotAngle;
+ copy_v3_v3(td->ext->irotAxis, pchan->rotAxis);
}
else {
td->ext->rot = NULL;
@@ -629,20 +626,20 @@ static void add_pose_transdata(
td->ext->rotAngle = NULL;
td->ext->quat = pchan->quat;
- copy_qt_qt(td->ext->iquat, pchan_eval->quat);
+ copy_qt_qt(td->ext->iquat, pchan->quat);
}
td->ext->rotOrder = pchan->rotmode;
/* proper way to get parent transform + own transform + constraints transform */
- copy_m3_m4(omat, ob_eval->obmat);
+ copy_m3_m4(omat, ob->obmat);
/* New code, using "generic" BKE_pchan_to_pose_mat(). */
{
float rotscale_mat[4][4], loc_mat[4][4];
float rpmat[3][3];
- BKE_pchan_to_pose_mat(pchan_eval, rotscale_mat, loc_mat);
+ BKE_pchan_to_pose_mat(pchan, rotscale_mat, loc_mat);
if (t->mode == TFM_TRANSLATION)
copy_m3_m4(pmat, loc_mat);
else
@@ -655,7 +652,7 @@ static void add_pose_transdata(
copy_m3_m4(rpmat, rotscale_mat);
if (constraints_list_needinv(t, &pchan->constraints)) {
- copy_m3_m4(tmat, pchan_eval->constinv);
+ copy_m3_m4(tmat, pchan->constinv);
invert_m3_m3(cmat, tmat);
mul_m3_series(td->mtx, cmat, omat, pmat);
mul_m3_series(td->ext->r_mtx, cmat, omat, rpmat);
@@ -675,7 +672,7 @@ static void add_pose_transdata(
if (pchan->parent) {
/* same as td->smtx but without pchan->bone->bone_mat */
td->flag |= TD_PBONE_LOCAL_MTX_C;
- mul_m3_m3m3(td->ext->l_smtx, pchan_eval->bone->bone_mat, td->smtx);
+ mul_m3_m3m3(td->ext->l_smtx, pchan->bone->bone_mat, td->smtx);
}
else {
td->flag |= TD_PBONE_LOCAL_MTX_P;
@@ -683,7 +680,7 @@ static void add_pose_transdata(
}
/* for axismat we use bone's own transform */
- copy_m3_m4(pmat, pchan_eval->pose_mat);
+ copy_m3_m4(pmat, pchan->pose_mat);
mul_m3_m3m3(td->axismtx, omat, pmat);
normalize_m3(td->axismtx);
@@ -708,10 +705,10 @@ static void add_pose_transdata(
bKinematicConstraint *data = has_targetless_ik(pchan);
if (data) {
if (data->flag & CONSTRAINT_IK_TIP) {
- copy_v3_v3(data->grabtarget, pchan_eval->pose_tail);
+ copy_v3_v3(data->grabtarget, pchan->pose_tail);
}
else {
- copy_v3_v3(data->grabtarget, pchan_eval->pose_head);
+ copy_v3_v3(data->grabtarget, pchan->pose_head);
}
td->loc = data->grabtarget;
copy_v3_v3(td->iloc, td->loc);
@@ -751,12 +748,11 @@ static void bone_children_clear_transflag(int mode, short around, ListBase *lb)
/* sets transform flags in the bones
* returns total number of bones with BONE_TRANSFORM */
-int count_set_pose_transflags(int *out_mode, short around, Object *ob)
+int count_set_pose_transflags(Object *ob, const int mode, short around, bool has_translate_rotate[2])
{
bArmature *arm = ob->data;
bPoseChannel *pchan;
Bone *bone;
- int mode = *out_mode;
int total = 0;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -784,42 +780,34 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob)
}
}
/* now count, and check if we have autoIK or have to switch from translate to rotate */
- bool has_translation = false, has_rotation = false;
-
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
bone = pchan->bone;
if (bone->flag & BONE_TRANSFORM) {
total++;
- if (mode == TFM_TRANSLATION) {
+ if (has_translate_rotate != NULL) {
if (has_targetless_ik(pchan) == NULL) {
if (pchan->parent && (pchan->bone->flag & BONE_CONNECTED)) {
- if (pchan->bone->flag & BONE_HINGE_CHILD_TRANSFORM)
- has_translation = true;
+ if (pchan->bone->flag & BONE_HINGE_CHILD_TRANSFORM) {
+ has_translate_rotate[0] = true;
+ }
}
else {
- if ((pchan->protectflag & OB_LOCK_LOC) != OB_LOCK_LOC)
- has_translation = true;
+ if ((pchan->protectflag & OB_LOCK_LOC) != OB_LOCK_LOC) {
+ has_translate_rotate[0] = true;
+ }
+ }
+ if ((pchan->protectflag & OB_LOCK_ROT) != OB_LOCK_ROT) {
+ has_translate_rotate[1] = true;
}
- if ((pchan->protectflag & OB_LOCK_ROT) != OB_LOCK_ROT)
- has_rotation = true;
}
- else
- has_translation = true;
+ else {
+ has_translate_rotate[1] = true;
+ }
}
}
}
- /* if there are no translatable bones, do rotation */
- if (mode == TFM_TRANSLATION && !has_translation) {
- if (has_rotation) {
- *out_mode = TFM_ROTATION;
- }
- else {
- *out_mode = TFM_RESIZE;
- }
- }
-
return total;
}
@@ -863,6 +851,8 @@ static bool pchan_autoik_adjust(bPoseChannel *pchan, short chainlen)
/* change the chain-length of auto-ik */
void transform_autoik_update(TransInfo *t, short mode)
{
+ Main *bmain = CTX_data_main(t->context);
+
short *chainlen = &t->settings->autoik_chainlen;
bPoseChannel *pchan;
@@ -899,12 +889,12 @@ void transform_autoik_update(TransInfo *t, short mode)
if (changed) {
/* TODO(sergey): Consider doing partial update only. */
- DEG_relations_tag_update(G.main);
+ DEG_relations_tag_update(bmain);
}
}
/* frees temporal IKs */
-static void pose_grab_with_ik_clear(Object *ob)
+static void pose_grab_with_ik_clear(Main *bmain, Object *ob)
{
bKinematicConstraint *data;
bPoseChannel *pchan;
@@ -942,7 +932,7 @@ static void pose_grab_with_ik_clear(Object *ob)
if (relations_changed) {
/* TODO(sergey): Consider doing partial update only. */
- DEG_relations_tag_update(G.main);
+ DEG_relations_tag_update(bmain);
}
}
@@ -1050,7 +1040,7 @@ static short pose_grab_with_ik_children(bPose *pose, Bone *bone)
}
/* main call which adds temporal IK chains */
-static short pose_grab_with_ik(Object *ob)
+static short pose_grab_with_ik(Main *bmain, Object *ob)
{
bArmature *arm;
bPoseChannel *pchan, *parent;
@@ -1096,8 +1086,8 @@ static short pose_grab_with_ik(Object *ob)
/* iTaSC needs clear for new IK constraints */
if (tot_ik) {
BIK_clear_data(ob->pose);
- /* TODO(sergey): Consuder doing partial update only. */
- DEG_relations_tag_update(G.main);
+ /* TODO(sergey): Consider doing partial update only. */
+ DEG_relations_tag_update(bmain);
}
return (tot_ik) ? 1 : 0;
@@ -1120,18 +1110,18 @@ static void createTransPose(TransInfo *t, Object **objects, uint objects_len)
tc->poseobj = objects[th_index];
}
}
+ Main *bmain = CTX_data_main(t->context);
t->data_len_all = 0;
+ bool has_translate_rotate_buf[2] = {false, false};
+ bool *has_translate_rotate = (t->mode == TFM_TRANSLATION) ? has_translate_rotate_buf : NULL;
+
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
Object *ob = tc->poseobj;
bArmature *arm;
- TransData *td;
- TransDataExtension *tdx;
short ik_on = 0;
- int i;
-
/* check validity of state */
arm = BKE_armature_from_object(tc->poseobj);
@@ -1148,16 +1138,34 @@ static void createTransPose(TransInfo *t, Object **objects, uint objects_len)
/* do we need to add temporal IK chains? */
if ((arm->flag & ARM_AUTO_IK) && t->mode == TFM_TRANSLATION) {
- ik_on = pose_grab_with_ik(ob);
+ ik_on = pose_grab_with_ik(bmain, ob);
if (ik_on) t->flag |= T_AUTOIK;
}
/* set flags and count total (warning, can change transform to rotate) */
- tc->data_len = count_set_pose_transflags(&t->mode, t->around, ob);
+ tc->data_len = count_set_pose_transflags(ob, t->mode, t->around, has_translate_rotate);
+ /* len may be zero, skip next iteration. */
+ }
+
+ /* if there are no translatable bones, do rotation */
+ if ((t->mode == TFM_TRANSLATION) && !has_translate_rotate[0]) {
+ if (has_translate_rotate[1]) {
+ t->mode = TFM_ROTATION;
+ }
+ else {
+ t->mode = TFM_RESIZE;
+ }
+ }
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if (tc->data_len == 0) {
continue;
}
+ Object *ob = tc->poseobj;
+ TransData *td;
+ TransDataExtension *tdx;
+ short ik_on = 0;
+ int i;
tc->poseobj = ob; /* we also allow non-active objects to be transformed, in weightpaint */
@@ -1171,15 +1179,9 @@ static void createTransPose(TransInfo *t, Object **objects, uint objects_len)
/* use pose channels to fill trans data */
td = tc->data;
- Object *ob_eval = DEG_get_evaluated_object(CTX_data_depsgraph(t->context), ob);
- bPoseChannel *pchan, *pchan_eval;
- for (pchan = ob->pose->chanbase.first, pchan_eval = ob_eval->pose->chanbase.first;
- pchan && pchan_eval;
- pchan = pchan->next, pchan_eval = pchan_eval->next)
- {
- BLI_assert(pchan == pchan_eval || STREQ(pchan->bone->name, pchan_eval->bone->name));
+ for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->bone->flag & BONE_TRANSFORM) {
- add_pose_transdata(t, ob, pchan, ob_eval, pchan_eval, tc, td);
+ add_pose_transdata(t, pchan, ob, tc, td);
td++;
}
}
@@ -5620,41 +5622,39 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list)
/* transcribe given object into TransData for Transforming */
static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
{
- Depsgraph *depsgraph = t->depsgraph;
Scene *scene = t->scene;
- Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
bool constinv;
bool skip_invert = false;
if (t->mode != TFM_DUMMY && ob->rigidbody_object) {
float rot[3][3], scale[3];
- float ctime = DEG_get_ctime(depsgraph);
+ float ctime = BKE_scene_frame_get(scene);
/* only use rigid body transform if simulation is running, avoids problems with initial setup of rigid bodies */
- // XXX: This needs fixing for COW. May need rigidbody_world from scene
if (BKE_rigidbody_check_sim_running(scene->rigidbody_world, ctime)) {
+
/* save original object transform */
- copy_v3_v3(td->ext->oloc, ob_eval->loc);
+ copy_v3_v3(td->ext->oloc, ob->loc);
if (ob->rotmode > 0) {
- copy_v3_v3(td->ext->orot, ob_eval->rot);
+ copy_v3_v3(td->ext->orot, ob->rot);
}
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
- td->ext->orotAngle = ob_eval->rotAngle;
- copy_v3_v3(td->ext->orotAxis, ob_eval->rotAxis);
+ td->ext->orotAngle = ob->rotAngle;
+ copy_v3_v3(td->ext->orotAxis, ob->rotAxis);
}
else {
- copy_qt_qt(td->ext->oquat, ob_eval->quat);
+ copy_qt_qt(td->ext->oquat, ob->quat);
}
/* update object's loc/rot to get current rigid body transform */
- mat4_to_loc_rot_size(ob->loc, rot, scale, ob_eval->obmat);
- sub_v3_v3(ob->loc, ob_eval->dloc);
+ mat4_to_loc_rot_size(ob->loc, rot, scale, ob->obmat);
+ sub_v3_v3(ob->loc, ob->dloc);
BKE_object_mat3_to_rot(ob, rot, false); /* drot is already corrected here */
}
}
/* axismtx has the real orientation */
- copy_m3_m4(td->axismtx, ob_eval->obmat);
+ copy_m3_m4(td->axismtx, ob->obmat);
normalize_m3(td->axismtx);
td->con = ob->constraints.first;
@@ -5667,7 +5667,6 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
constinv = constraints_list_needinv(t, &ob->constraints);
/* disable constraints inversion for dummy pass */
- // XXX: Should this use ob or ob_eval?! It's not clear!
if (t->mode == TFM_DUMMY)
skip_invert = true;
@@ -5682,7 +5681,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
td->ob = ob;
td->loc = ob->loc;
- copy_v3_v3(td->iloc, ob_eval->loc);
+ copy_v3_v3(td->iloc, td->loc);
if (ob->rotmode > 0) {
td->ext->rot = ob->rot;
@@ -5690,8 +5689,8 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
td->ext->rotAngle = NULL;
td->ext->quat = NULL;
- copy_v3_v3(td->ext->irot, ob_eval->rot);
- copy_v3_v3(td->ext->drot, ob_eval->drot);
+ copy_v3_v3(td->ext->irot, ob->rot);
+ copy_v3_v3(td->ext->drot, ob->drot);
}
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
td->ext->rot = NULL;
@@ -5699,10 +5698,10 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
td->ext->rotAngle = &ob->rotAngle;
td->ext->quat = NULL;
- td->ext->irotAngle = ob_eval->rotAngle;
- copy_v3_v3(td->ext->irotAxis, ob_eval->rotAxis);
- // td->ext->drotAngle = ob_eval->drotAngle; // XXX, not implemented
- // copy_v3_v3(td->ext->drotAxis, ob_eval->drotAxis); // XXX, not implemented
+ td->ext->irotAngle = ob->rotAngle;
+ copy_v3_v3(td->ext->irotAxis, ob->rotAxis);
+ // td->ext->drotAngle = ob->drotAngle; // XXX, not implemented
+ // copy_v3_v3(td->ext->drotAxis, ob->drotAxis); // XXX, not implemented
}
else {
td->ext->rot = NULL;
@@ -5710,18 +5709,18 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
td->ext->rotAngle = NULL;
td->ext->quat = ob->quat;
- copy_qt_qt(td->ext->iquat, ob_eval->quat);
- copy_qt_qt(td->ext->dquat, ob_eval->dquat);
+ copy_qt_qt(td->ext->iquat, ob->quat);
+ copy_qt_qt(td->ext->dquat, ob->dquat);
}
- td->ext->rotOrder = ob_eval->rotmode;
+ td->ext->rotOrder = ob->rotmode;
td->ext->size = ob->size;
- copy_v3_v3(td->ext->isize, ob_eval->size);
- copy_v3_v3(td->ext->dscale, ob_eval->dscale);
+ copy_v3_v3(td->ext->isize, ob->size);
+ copy_v3_v3(td->ext->dscale, ob->dscale);
- copy_v3_v3(td->center, ob_eval->obmat[3]);
+ copy_v3_v3(td->center, ob->obmat[3]);
- copy_m4_m4(td->ext->obmat, ob_eval->obmat);
+ copy_m4_m4(td->ext->obmat, ob->obmat);
/* is there a need to set the global<->data space conversion matrices? */
if (ob->parent || constinv) {
@@ -5731,8 +5730,8 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
* NOTE: some Constraints, and also Tracking should never get this
* done, as it doesn't work well.
*/
- BKE_object_to_mat3(ob_eval, obmtx);
- copy_m3_m4(totmat, ob_eval->obmat);
+ BKE_object_to_mat3(ob, obmtx);
+ copy_m3_m4(totmat, ob->obmat);
invert_m3_m3(obinv, totmat);
mul_m3_m3m3(td->smtx, obmtx, obinv);
invert_m3_m3(td->mtx, td->smtx);
@@ -5780,8 +5779,7 @@ static void trans_object_base_deps_flag_finish(ViewLayer *view_layer)
/* it deselects Bases, so we have to call the clear function always after */
static void set_trans_object_base_flags(TransInfo *t)
{
- /* TODO(sergey): Get rid of global, use explicit main. */
- Main *bmain = G.main;
+ Main *bmain = CTX_data_main(t->context);
ViewLayer *view_layer = t->view_layer;
Scene *scene = t->scene;
Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
@@ -5927,6 +5925,7 @@ static void clear_trans_object_base_flags(TransInfo *t)
// NOTE: context may not always be available, so must check before using it as it's a luxury for a few cases
void autokeyframe_ob_cb_func(bContext *C, Scene *scene, ViewLayer *view_layer, Object *ob, int tmode)
{
+ Main *bmain = CTX_data_main(C);
ID *id = &ob->id;
FCurve *fcu;
@@ -5959,7 +5958,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, ViewLayer *view_layer, O
if (adt && adt->action) {
for (fcu = adt->action->curves.first; fcu; fcu = fcu->next) {
fcu->flag &= ~FCURVE_SELECTED;
- insert_keyframe(depsgraph, reports, id, adt->action,
+ insert_keyframe(bmain, depsgraph, reports, id, adt->action,
(fcu->grp ? fcu->grp->name : NULL),
fcu->rna_path, fcu->array_index, cfra,
ts->keyframe_type, flag);
@@ -6048,6 +6047,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, ViewLayer *view_layer, O
// NOTE: context may not always be available, so must check before using it as it's a luxury for a few cases
void autokeyframe_pose_cb_func(bContext *C, Scene *scene, Object *ob, int tmode, short targetless_ik)
{
+ Main *bmain = CTX_data_main(C);
ID *id = &ob->id;
AnimData *adt = ob->adt;
bAction *act = (adt) ? adt->action : NULL;
@@ -6101,7 +6101,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, Object *ob, int tmode,
* NOTE: this will do constraints too, but those are ok to do here too?
*/
if (pchanName && STREQ(pchanName, pchan->name)) {
- insert_keyframe(depsgraph, reports, id, act,
+ insert_keyframe(bmain, depsgraph, reports, id, act,
((fcu->grp) ? (fcu->grp->name) : (NULL)),
fcu->rna_path, fcu->array_index, cfra,
ts->keyframe_type, flag);
@@ -6331,6 +6331,9 @@ static void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t)
* */
void special_aftertrans_update(bContext *C, TransInfo *t)
{
+ Main *bmain = CTX_data_main(t->context);
+ BLI_assert(bmain == CTX_data_main(C));
+
Object *ob;
// short redrawipo=0, resetslowpar=1;
const bool canceled = (t->state == TRANS_CANCEL);
@@ -6426,7 +6429,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
if (canceled == 0) {
ED_node_post_apply_transform(C, snode->edittree);
- ED_node_link_insert(t->sa);
+ ED_node_link_insert(bmain, t->sa);
}
/* clear link line */
@@ -6519,7 +6522,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
// XXX: BAD! this get gpencil datablocks directly from main db...
// but that's how this currently works :/
- for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) {
+ for (gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
if (ID_REAL_USERS(gpd))
posttrans_gpd_clean(gpd);
}
@@ -6539,7 +6542,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
// XXX: BAD! this get gpencil datablocks directly from main db...
// but that's how this currently works :/
- for (mask = G.main->mask.first; mask; mask = mask->id.next) {
+ for (mask = bmain->mask.first; mask; mask = mask->id.next) {
if (ID_REAL_USERS(mask))
posttrans_mask_clean(mask);
}
@@ -6688,8 +6691,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
/* set BONE_TRANSFORM flags for autokey, manipulator draw might have changed them */
- if (!canceled && (t->mode != TFM_DUMMY))
- count_set_pose_transflags(&t->mode, t->around, ob);
+ if (!canceled && (t->mode != TFM_DUMMY)) {
+ count_set_pose_transflags(ob, t->mode, t->around, NULL);
+ }
/* if target-less IK grabbing, we calculate the pchan transforms and clear flag */
if (!canceled && t->mode == TFM_TRANSLATION)
@@ -6703,7 +6707,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
if (t->mode == TFM_TRANSLATION)
- pose_grab_with_ik_clear(ob);
+ pose_grab_with_ik_clear(bmain, ob);
/* automatic inserting of keys and unkeyed tagging - only if transform wasn't canceled (or TFM_DUMMY) */
if (!canceled && (t->mode != TFM_DUMMY)) {
@@ -8449,6 +8453,7 @@ void createTransData(bContext *C, TransInfo *t)
}
else if (t->spacetype == SPACE_ACTION) {
t->flag |= T_POINTS | T_2D_EDIT;
+ t->obedit_type = -1;
createTransActionData(C, t);
countAndCleanTransDataContainer(t);
@@ -8461,17 +8466,23 @@ void createTransData(bContext *C, TransInfo *t)
}
else if (t->spacetype == SPACE_NLA) {
t->flag |= T_POINTS | T_2D_EDIT;
+ t->obedit_type = -1;
+
createTransNlaData(C, t);
countAndCleanTransDataContainer(t);
}
else if (t->spacetype == SPACE_SEQ) {
t->flag |= T_POINTS | T_2D_EDIT;
+ t->obedit_type = -1;
+
t->num.flag |= NUM_NO_FRACTION; /* sequencer has no use for floating point transformations */
createTransSeqData(C, t);
countAndCleanTransDataContainer(t);
}
else if (t->spacetype == SPACE_IPO) {
t->flag |= T_POINTS | T_2D_EDIT;
+ t->obedit_type = -1;
+
createTransGraphEditData(C, t);
countAndCleanTransDataContainer(t);
@@ -8483,6 +8494,7 @@ void createTransData(bContext *C, TransInfo *t)
}
else if (t->spacetype == SPACE_NODE) {
t->flag |= T_POINTS | T_2D_EDIT;
+ t->obedit_type = -1;
createTransNodeData(C, t);
countAndCleanTransDataContainer(t);
@@ -8495,6 +8507,8 @@ void createTransData(bContext *C, TransInfo *t)
}
else if (t->spacetype == SPACE_CLIP) {
t->flag |= T_POINTS | T_2D_EDIT;
+ t->obedit_type = -1;
+
if (t->options & CTX_MOVIECLIP) {
createTransTrackingData(C, t);
countAndCleanTransDataContainer(t);
@@ -8596,7 +8610,10 @@ void createTransData(bContext *C, TransInfo *t)
countAndCleanTransDataContainer(t);
}
}
-
+ }
+ /* Mark as initialized if above checks fail. */
+ if (t->data_len_all == -1) {
+ t->data_len_all = 0;
}
}
else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_start_edit(PE_get_current(scene, ob))) {
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 576bfddd28c..8bef63dba1a 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -359,6 +359,7 @@ static void recalcData_actedit(TransInfo *t)
/* initialize relevant anim-context 'context' data from TransInfo data */
/* NOTE: sync this with the code in ANIM_animdata_get_context() */
+ ac.bmain = CTX_data_main(t->context);
ac.scene = t->scene;
ac.view_layer = t->view_layer;
ac.obact = OBACT(view_layer);
@@ -386,7 +387,7 @@ static void recalcData_actedit(TransInfo *t)
if ((saction->flag & SACTION_NOREALTIMEUPDATES) == 0) {
for (ale = anim_data.first; ale; ale = ale->next) {
/* set refresh tags for objects using this animation */
- ANIM_list_elem_update(t->scene, ale);
+ ANIM_list_elem_update(CTX_data_main(t->context), t->scene, ale);
}
}
@@ -409,6 +410,7 @@ static void recalcData_graphedit(TransInfo *t)
/* initialize relevant anim-context 'context' data from TransInfo data */
/* NOTE: sync this with the code in ANIM_animdata_get_context() */
+ ac.bmain = CTX_data_main(t->context);
ac.scene = t->scene;
ac.view_layer = t->view_layer;
ac.obact = OBACT(view_layer);
@@ -445,7 +447,7 @@ static void recalcData_graphedit(TransInfo *t)
* BUT only if realtime updates are enabled
*/
if ((sipo->flag & SIPO_NOREALTIMEUPDATES) == 0)
- ANIM_list_elem_update(t->scene, ale);
+ ANIM_list_elem_update(CTX_data_main(t->context), t->scene, ale);
}
/* do resort and other updates? */
@@ -1954,7 +1956,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3])
bPoseChannel *pchan = BKE_pose_channel_active(ob);
if (pchan && (!select_only || (pchan->bone->flag & BONE_SELECTED))) {
copy_v3_v3(r_center, pchan->pose_head);
- mul_m4_v3(tc->obedit->obmat, r_center);
+ mul_m4_v3(ob->obmat, r_center);
ok = true;
}
}
diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_manipulator_3d.c
index b94ccf42325..b6782470f96 100644
--- a/source/blender/editors/transform/transform_manipulator_3d.c
+++ b/source/blender/editors/transform/transform_manipulator_3d.c
@@ -586,7 +586,6 @@ int ED_transform_calc_manipulator_stats(
const struct TransformCalcParams *params,
struct TransformBounds *tbounds)
{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
@@ -596,8 +595,6 @@ int ED_transform_calc_manipulator_stats(
RegionView3D *rv3d = ar->regiondata;
Base *base;
Object *ob = OBACT(view_layer);
- Object *ob_eval = NULL;
- Object *obedit_eval = NULL;
bGPdata *gpd = CTX_data_gpencil_data(C);
const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE));
int a, totsel = 0;
@@ -612,9 +609,6 @@ int ED_transform_calc_manipulator_stats(
rv3d->twdrawflag = 0xFFFF;
- ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- obedit_eval = DEG_get_evaluated_object(depsgraph, obedit);
-
/* global, local or normal orientation?
* if we could check 'totsel' now, this should be skipped with no selection. */
if (ob && !is_gp_edit) {
@@ -629,7 +623,7 @@ int ED_transform_calc_manipulator_stats(
case V3D_MANIP_GIMBAL:
{
float mat[3][3];
- if (gimbal_axis(ob_eval, mat)) {
+ if (gimbal_axis(ob, mat)) {
copy_m4_m3(rv3d->twmat, mat);
break;
}
@@ -659,7 +653,7 @@ int ED_transform_calc_manipulator_stats(
copy_m4_m3(rv3d->twmat, mat);
break;
}
- copy_m4_m4(rv3d->twmat, ob_eval->obmat);
+ copy_m4_m4(rv3d->twmat, ob->obmat);
normalize_m4(rv3d->twmat);
break;
}
@@ -699,7 +693,7 @@ int ED_transform_calc_manipulator_stats(
copy_m3_m4(tbounds->axis, rv3d->twmat);
if (params->use_local_axis && (ob && ob->mode & OB_MODE_EDIT)) {
float diff_mat[3][3];
- copy_m3_m4(diff_mat, ob_eval->obmat);
+ copy_m3_m4(diff_mat, ob->obmat);
normalize_m3(diff_mat);
invert_m3(diff_mat);
mul_m3_m3m3(tbounds->axis, tbounds->axis, diff_mat);
@@ -762,7 +756,6 @@ int ED_transform_calc_manipulator_stats(
}
else if (obedit) {
ob = obedit;
- ob_eval = obedit_eval;
if (obedit->type == OB_MESH) {
BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMEditSelection ese;
@@ -937,9 +930,9 @@ int ED_transform_calc_manipulator_stats(
/* selection center */
if (totsel) {
mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
- mul_m4_v3(obedit_eval->obmat, tbounds->center);
- mul_m4_v3(obedit_eval->obmat, tbounds->min);
- mul_m4_v3(obedit_eval->obmat, tbounds->max);
+ mul_m4_v3(obedit->obmat, tbounds->center);
+ mul_m4_v3(obedit->obmat, tbounds->min);
+ mul_m4_v3(obedit->obmat, tbounds->max);
}
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
@@ -947,7 +940,7 @@ int ED_transform_calc_manipulator_stats(
int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed
bool ok = false;
- if ((pivot_point == V3D_AROUND_ACTIVE) && (pchan = BKE_pose_channel_active(ob_eval))) {
+ if ((pivot_point == V3D_AROUND_ACTIVE) && (pchan = BKE_pose_channel_active(ob))) {
/* doesn't check selection or visibility intentionally */
Bone *bone = pchan->bone;
if (bone) {
@@ -958,11 +951,11 @@ int ED_transform_calc_manipulator_stats(
}
}
else {
- totsel = count_set_pose_transflags(&mode, 0, ob_eval);
+ totsel = count_set_pose_transflags(ob, mode, V3D_AROUND_CENTER_BOUNDS, NULL);
if (totsel) {
/* use channels to get stats */
- for (pchan = ob_eval->pose->chanbase.first; pchan; pchan = pchan->next) {
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
Bone *bone = pchan->bone;
if (bone && (bone->flag & BONE_TRANSFORM)) {
calc_tw_center(tbounds, pchan->pose_head);
@@ -975,9 +968,9 @@ int ED_transform_calc_manipulator_stats(
if (ok) {
mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
- mul_m4_v3(ob_eval->obmat, tbounds->center);
- mul_m4_v3(ob_eval->obmat, tbounds->min);
- mul_m4_v3(ob_eval->obmat, tbounds->max);
+ mul_m4_v3(ob->obmat, tbounds->center);
+ mul_m4_v3(ob->obmat, tbounds->min);
+ mul_m4_v3(ob->obmat, tbounds->max);
}
}
else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) {
@@ -1018,18 +1011,16 @@ int ED_transform_calc_manipulator_stats(
if (!TESTBASELIB(base)) {
continue;
}
- Object *base_object_eval = DEG_get_evaluated_object(depsgraph, base->object);
if (ob == NULL) {
ob = base->object;
- ob_eval = base_object_eval;
}
- if (params->use_only_center || base_object_eval->bb == NULL) {
- calc_tw_center(tbounds, base_object_eval->obmat[3]);
+ if (params->use_only_center || base->object->bb == NULL) {
+ calc_tw_center(tbounds, base->object->obmat[3]);
}
else {
for (uint j = 0; j < 8; j++) {
float co[3];
- mul_v3_m4v3(co, base_object_eval->obmat, base_object_eval->bb->vec[j]);
+ mul_v3_m4v3(co, base->object->obmat, base->object->bb->vec[j]);
calc_tw_center(tbounds, co);
}
}
@@ -1547,12 +1538,6 @@ static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulato
static bool WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmManipulatorGroupType *wgt)
{
/* it's a given we only use this in 3D view */
- ScrArea *sa = CTX_wm_area(C);
- View3D *v3d = sa->spacedata.first;
- if (v3d && ((v3d->twflag & V3D_MANIPULATOR_DRAW)) == 0) {
- return false;
- }
-
bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C);
if ((tref_rt == NULL) ||
!STREQ(wgt->idname, tref_rt->manipulator_group))
@@ -1593,12 +1578,6 @@ struct XFormCageWidgetGroup {
static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmManipulatorGroupType *wgt)
{
- ScrArea *sa = CTX_wm_area(C);
- View3D *v3d = sa->spacedata.first;
- if (v3d && ((v3d->twflag & V3D_MANIPULATOR_DRAW)) == 0) {
- return false;
- }
-
bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C);
if (!STREQ(wgt->idname, tref_rt->manipulator_group)) {
WM_manipulator_group_type_unlink_delayed_ptr(wgt);
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index a1b78403fc4..18d30db7a21 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -1138,9 +1138,6 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap");
- kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
- RNA_string_set(kmi->ptr, "data_path", "tool_settings.snap_element");
-
/* Will fall-through to texture-space transform. */
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_transform_axis_target", TKEY, KM_PRESS, KM_SHIFT, 0);
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 3065007ea6b..19df46455d7 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -56,8 +56,6 @@
#include "BKE_scene.h"
#include "BKE_workspace.h"
-#include "DEG_depsgraph_query.h"
-
#include "BLT_translation.h"
#include "ED_armature.h"
@@ -1016,14 +1014,12 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
}
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
- Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- bArmature *arm = ob_eval->data;
+ bArmature *arm = ob->data;
bPoseChannel *pchan;
float imat[3][3], mat[3][3];
bool ok = false;
- if (activeOnly && (pchan = BKE_pose_channel_active(ob_eval))) {
+ if (activeOnly && (pchan = BKE_pose_channel_active(ob))) {
add_v3_v3(normal, pchan->pose_mat[2]);
add_v3_v3(plane, pchan->pose_mat[1]);
ok = true;
@@ -1034,7 +1030,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
totsel = count_bone_select(arm, &arm->bonebase, true);
if (totsel) {
/* use channels to get stats */
- for (pchan = ob_eval->pose->chanbase.first; pchan; pchan = pchan->next) {
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->bone && pchan->bone->flag & BONE_TRANSFORM) {
add_v3_v3(normal, pchan->pose_mat[2]);
add_v3_v3(plane, pchan->pose_mat[1]);
@@ -1047,7 +1043,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
/* use for both active & all */
if (ok) {
/* we need the transpose of the inverse for a normal... */
- copy_m3_m4(imat, ob_eval->obmat);
+ copy_m3_m4(imat, ob->obmat);
invert_m3_m3(mat, imat);
transpose_m3(mat);
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 10de7f3ea36..704582deaca 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -406,6 +406,11 @@ void applyGridAbsolute(TransInfo *t)
void applySnapping(TransInfo *t, float *vec)
{
+ if (t->tsnap.project && t->tsnap.mode == SCE_SNAP_MODE_FACE) {
+ /* Each Trans Data already makes the snap to face */
+ return;
+ }
+
if (t->tsnap.status & SNAP_FORCED) {
t->tsnap.targetSnap(t);
@@ -495,6 +500,7 @@ static bool bm_face_is_snap_target(BMFace *f, void *UNUSED(user_data))
static void initSnappingMode(TransInfo *t)
{
+ Main *bmain = CTX_data_main(t->context);
ToolSettings *ts = t->settings;
/* All obedit types will match. */
const int obedit_type = t->data_container->obedit ? t->data_container->obedit->type : -1;
@@ -582,7 +588,7 @@ static void initSnappingMode(TransInfo *t)
if (t->spacetype == SPACE_VIEW3D) {
if (t->tsnap.object_context == NULL) {
t->tsnap.object_context = ED_transform_snap_object_context_create_view3d(
- t->scene, t->depsgraph, 0, t->ar, t->view);
+ bmain, t->scene, t->depsgraph, 0, t->ar, t->view);
ED_transform_snap_object_context_set_editmesh_callbacks(
t->tsnap.object_context,
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 29497fe801c..e19320fa220 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -56,6 +56,7 @@
#include "BKE_tracking.h"
#include "BKE_context.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
@@ -113,6 +114,7 @@ typedef struct SnapObjectData_EditMesh {
} SnapObjectData_EditMesh;
struct SnapObjectContext {
+ Main *bmain;
Scene *scene;
Depsgraph *depsgraph;
@@ -1633,6 +1635,7 @@ static short snapCamera(
{
short retval = 0;
+ Depsgraph *depsgraph = sctx->depsgraph;
Scene *scene = sctx->scene;
bool is_persp = snapdata->view_proj == VIEW_PROJ_PERSP;
@@ -1657,7 +1660,7 @@ static short snapCamera(
tracking = &clip->tracking;
- BKE_tracking_get_camera_object_matrix(scene, object, orig_camera_mat);
+ BKE_tracking_get_camera_object_matrix(depsgraph, scene, object, orig_camera_mat);
invert_m4_m4(orig_camera_imat, orig_camera_mat);
invert_m4_m4(imat, obmat);
@@ -2268,12 +2271,13 @@ static short snapObjectsRay(
* \{ */
SnapObjectContext *ED_transform_snap_object_context_create(
- Scene *scene, Depsgraph *depsgraph, int flag)
+ Main *bmain, Scene *scene, Depsgraph *depsgraph, int flag)
{
SnapObjectContext *sctx = MEM_callocN(sizeof(*sctx), __func__);
sctx->flag = flag;
+ sctx->bmain = bmain;
sctx->scene = scene;
sctx->depsgraph = depsgraph;
@@ -2284,11 +2288,11 @@ SnapObjectContext *ED_transform_snap_object_context_create(
}
SnapObjectContext *ED_transform_snap_object_context_create_view3d(
- Scene *scene, Depsgraph *depsgraph, int flag,
+ Main *bmain, Scene *scene, Depsgraph *depsgraph, int flag,
/* extra args for view3d */
const ARegion *ar, const View3D *v3d)
{
- SnapObjectContext *sctx = ED_transform_snap_object_context_create(scene, depsgraph, flag);
+ SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, depsgraph, flag);
sctx->use_v3d = true;
sctx->v3d_data.ar = ar;
@@ -2466,7 +2470,11 @@ static short transform_snap_context_project_view3d_mixed_impl(
const ARegion *ar = sctx->v3d_data.ar;
const RegionView3D *rv3d = ar->regiondata;
- if (snap_to_flag & SCE_SNAP_MODE_FACE || params->use_occlusion_test) {
+ bool use_occlusion_test =
+ params->use_occlusion_test &&
+ !(sctx->v3d_data.v3d->shading.flag & V3D_SHADING_XRAY);
+
+ if (snap_to_flag & SCE_SNAP_MODE_FACE || use_occlusion_test) {
float ray_start[3], ray_normal[3];
if (!ED_view3d_win_to_ray_ex(
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index 3950b056e89..d2ac346df10 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -57,6 +57,7 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "WM_toolsystem.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -106,7 +107,6 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
CLOG_INFO(&LOG, 1, "name='%s', step=%d", undoname, step);
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
- // Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
/* undo during jobs are running can easily lead to freeing data using by jobs,
@@ -135,6 +135,9 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
WM_event_add_notifier(C, NC_WINDOW, NULL);
WM_event_add_notifier(C, NC_WM | ND_UNDO, NULL);
+ Main *bmain = CTX_data_main(C);
+ WM_toolsystem_refresh_screen_all(bmain);
+
if (win) {
win->addmousemove = true;
}
diff --git a/source/blender/editors/undo/undo_intern.h b/source/blender/editors/undo/undo_intern.h
index 671f9637d65..03f9d248ba0 100644
--- a/source/blender/editors/undo/undo_intern.h
+++ b/source/blender/editors/undo/undo_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 61a70d2da42..a829f8c1144 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -129,7 +129,7 @@ void ED_editors_init(bContext *C)
{
Scene *sce = CTX_data_scene(C);
if (sce) {
- ED_space_image_paint_update(wm, sce);
+ ED_space_image_paint_update(bmain, wm, sce);
}
}
@@ -210,7 +210,7 @@ bool ED_editors_flush_edits(const bContext *C, bool for_render)
else if (ob->mode & OB_MODE_EDIT) {
/* get editmode results */
has_edited = true;
- ED_object_editmode_load(ob);
+ ED_object_editmode_load(bmain, ob);
}
}
@@ -227,7 +227,7 @@ void apply_keyb_grid(int shift, int ctrl, float *val, float fac1, float fac2, fl
/* fac1 is for 'nothing', fac2 for CTRL, fac3 for SHIFT */
if (invert)
ctrl = !ctrl;
-
+
if (ctrl && shift) {
if (fac3 != 0.0f) *val = fac3 * floorf(*val / fac3 + 0.5f);
}
@@ -241,6 +241,7 @@ void apply_keyb_grid(int shift, int ctrl, float *val, float fac1, float fac2, fl
void unpack_menu(bContext *C, const char *opname, const char *id_name, const char *abs_name, const char *folder, struct PackedFile *pf)
{
+ Main *bmain = CTX_data_main(C);
PointerRNA props_ptr;
uiPopupMenu *pup;
uiLayout *layout;
@@ -262,7 +263,7 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
BLI_split_file_part(abs_name, fi, sizeof(fi));
BLI_snprintf(local_name, sizeof(local_name), "//%s/%s", folder, fi);
if (!STREQ(abs_name, local_name)) {
- switch (checkPackedFile(local_name, pf)) {
+ switch (checkPackedFile(BKE_main_blendfile_path(bmain), local_name, pf)) {
case PF_NOFILE:
BLI_snprintf(line, sizeof(line), IFACE_("Create %s"), local_name);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
@@ -295,7 +296,7 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
}
}
- switch (checkPackedFile(abs_name, pf)) {
+ switch (checkPackedFile(BKE_main_blendfile_path(bmain), abs_name, pf)) {
case PF_NOFILE:
BLI_snprintf(line, sizeof(line), IFACE_("Create %s"), abs_name);
//uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c
index f037783bd5e..5e867afd58e 100644
--- a/source/blender/editors/uvedit/uvedit_buttons.c
+++ b/source/blender/editors/uvedit/uvedit_buttons.c
@@ -70,7 +70,7 @@ static int uvedit_center(Scene *scene, Object *obedit, BMEditMesh *em, Image *im
int tot = 0;
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
-
+
zero_v2(center);
BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
if (!uvedit_face_visible_test(scene, obedit, ima, f))
@@ -101,7 +101,7 @@ static void uvedit_translate(Scene *scene, Object *obedit, BMEditMesh *em, Image
MLoopUV *luv;
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
-
+
BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
if (!uvedit_face_visible_test(scene, obedit, ima, f))
continue;
@@ -131,7 +131,7 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block)
float width = 8 * UI_UNIT_X;
ED_space_image_get_size(sima, &imx, &imy);
-
+
em = BKE_editmesh_from_object(obedit);
if (uvedit_center(scene, obedit, em, ima, center)) {
@@ -164,7 +164,7 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block)
step = 100;
digits = 2;
}
-
+
UI_block_align_begin(block);
uiDefButF(block, UI_BTYPE_NUM, B_UVEDIT_VERTEX, IFACE_("X:"), 0, 0, width, UI_UNIT_Y, &uvedit_old_center[0],
UNPACK2(range_xy[0]), step, digits, "");
@@ -217,12 +217,12 @@ static int image_panel_uv_poll(const bContext *C, PanelType *UNUSED(pt))
static void image_panel_uv(const bContext *C, Panel *pa)
{
uiBlock *block;
-
+
block = uiLayoutAbsoluteBlock(pa->layout);
UI_block_func_handle_set(block, do_uvedit_vertex, NULL);
uvedit_vertex_buttons(C, block);
-}
+}
void ED_uvedit_buttons_register(ARegionType *art)
{
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 6b8bc957b26..4473922841f 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -87,6 +87,8 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
x_fac = zoom[0];
y_fac = zoom[1];
+ glLineWidth(1.0f);
+
gpuTranslate2fv(cursor);
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -194,12 +196,12 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME
BLI_buffer_declare_static(vec2f, tf_uvorig_buf, BLI_BUFFER_NOP, BM_DEFAULT_NGON_STACK_SIZE);
ED_space_image_get_uv_aspect(sima, &aspx, &aspy);
-
+
switch (sima->dt_uvstretch) {
case SI_UVDT_STRETCH_AREA:
{
float totarea = 0.0f, totuvarea = 0.0f, areadiff, uvarea, area;
-
+
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
const int efa_len = efa->len;
float (*tf_uv)[2] = (float (*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, efa_len);
@@ -214,7 +216,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME
totarea += BM_face_calc_area(efa);
totuvarea += area_poly_v2(tf_uv, efa->len);
-
+
if (uvedit_face_visible_test(scene, obedit, ima, efa)) {
BM_elem_flag_enable(efa, BM_ELEM_TAG);
}
@@ -266,17 +268,17 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME
uv_poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, efa->len);
uvarea = area_poly_v2(tf_uv, efa->len) / totuvarea;
-
+
if (area < FLT_EPSILON || uvarea < FLT_EPSILON)
areadiff = 1.0f;
else if (area > uvarea)
areadiff = 1.0f - (uvarea / area);
else
areadiff = 1.0f - (area / uvarea);
-
+
weight_to_rgb(col, areadiff);
immUniformColor3fv(col);
-
+
/* TODO: use editmesh tessface */
immBegin(GWN_PRIM_TRI_FAN, efa->len);
@@ -455,7 +457,7 @@ static void draw_uvs_other_mesh(Object *ob, const Image *curimage,
for (a = 0; a < totcol; a++) {
Image *image;
-
+
/* if no materials, assume a default material with no image */
if (ob->totcol)
ED_object_get_active_image(ob, a + 1, &image, NULL, NULL, NULL);
@@ -602,7 +604,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
interpedges = (ts->selectmode & SCE_SELECT_VERTEX);
else
interpedges = (ts->uv_selectmode == UV_SELECT_VERTEX);
-
+
/* draw other uvs */
if (sima->flag & SI_DRAW_OTHER) {
Image *curimage;
@@ -618,7 +620,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
}
/* 1. draw shadow mesh */
-
+
if (sima->flag & SI_DRAWSHADOW) {
Object *ob_cage_eval = DEG_get_evaluated_object(depsgraph, obedit);
/* XXX TODO: Need to check if shadow mesh is different than original mesh. */
@@ -632,7 +634,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
}
/* 2. draw colored faces */
-
+
if (sima->flag & SI_DRAW_STRETCH) {
draw_uvs_stretch(sima, scene, obedit, em, efa_act);
}
@@ -899,7 +901,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
pointsize = UI_GetThemeValuef(TH_FACEDOT_SIZE);
glPointSize(pointsize);
-
+
immBeginAtMost(GWN_PRIM_POINTS, bm->totface);
/* unselected faces */
@@ -950,7 +952,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
}
/* 6. draw uv vertices */
-
+
if (drawfaces != 2) { /* 2 means Mesh Face Mode */
pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -975,12 +977,12 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
}
immEnd();
-
+
/* pinned uvs */
/* give odd pointsizes odd pin pointsizes */
glPointSize(pointsize * 2 + (((int)pointsize % 2) ? (-1) : 0));
imm_cpack(0xFF);
-
+
immBeginAtMost(GWN_PRIM_POINTS, bm->totloop);
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
@@ -996,11 +998,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
}
immEnd();
-
+
/* selected uvs */
immUniformThemeColor(TH_VERTEX_SELECT);
glPointSize(pointsize);
-
+
immBeginAtMost(GWN_PRIM_POINTS, bm->totloop);
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
@@ -1033,10 +1035,10 @@ static void draw_uv_shadows_get(
if ((sima->mode == SI_MODE_PAINT) && obedit && obedit->type == OB_MESH) {
struct BMEditMesh *em = BKE_editmesh_from_object(obedit);
-
+
*show_shadow = EDBM_uv_check(em);
}
-
+
*show_texpaint = (ob && ob->type == OB_MESH && ob->mode == OB_MODE_TEXTURE_PAINT);
}
diff --git a/source/blender/editors/uvedit/uvedit_intern.h b/source/blender/editors/uvedit/uvedit_intern.h
index e3db0162f10..eed9d68f39c 100644
--- a/source/blender/editors/uvedit/uvedit_intern.h
+++ b/source/blender/editors/uvedit/uvedit_intern.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index fceb1532077..45a6ccfe28b 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -108,13 +108,13 @@ bool ED_uvedit_test(Object *obedit)
if (!obedit)
return 0;
-
+
if (obedit->type != OB_MESH)
return 0;
em = BKE_editmesh_from_object(obedit);
ret = EDBM_uv_check(em);
-
+
return ret;
}
@@ -167,7 +167,7 @@ bool ED_object_get_active_image(
if (r_ntree) *r_ntree = ntree;
return true;
}
-
+
if (r_ima) *r_ima = NULL;
if (r_iuser) *r_iuser = NULL;
if (r_node) *r_node = node;
@@ -364,7 +364,7 @@ bool uvedit_edge_select_test(
return BM_elem_flag_test(l->e, BM_ELEM_SELECT);
}
else {
- return BM_elem_flag_test(l->v, BM_ELEM_SELECT) &&
+ return BM_elem_flag_test(l->v, BM_ELEM_SELECT) &&
BM_elem_flag_test(l->next->v, BM_ELEM_SELECT);
}
}
@@ -417,7 +417,7 @@ void uvedit_edge_select_enable(
luv1 = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
luv2 = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset);
-
+
luv1->flag |= MLOOPUV_VERTSEL;
luv2->flag |= MLOOPUV_VERTSEL;
}
@@ -445,7 +445,7 @@ void uvedit_edge_select_disable(
luv1 = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
luv2 = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset);
-
+
luv1->flag &= ~MLOOPUV_VERTSEL;
luv2->flag &= ~MLOOPUV_VERTSEL;
}
@@ -667,7 +667,7 @@ static bool UNUSED_FUNCTION(ED_uvedit_median)(Scene *scene, Image *ima, Object *
bool ED_uvedit_center_multi(Scene *scene, Image *ima, Object **objects_edit, uint objects_len, float cent[2], char mode)
{
bool changed = false;
-
+
if (mode == V3D_AROUND_CENTER_BOUNDS) { /* bounding box */
float min[2], max[2];
if (ED_uvedit_minmax_multi(scene, ima, objects_edit, objects_len, min, max)) {
@@ -920,11 +920,11 @@ bool ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, const float
mindist = 1e10f;
copy_v2_v2(r_uv, co);
-
+
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (!uvedit_face_visible_test(scene, obedit, ima, efa))
continue;
-
+
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
dist = len_manhattan_v2v2(co, luv->uv);
@@ -958,7 +958,7 @@ static void uv_select_edgeloop_vertex_loop_flag(UvMapVert *first)
count++;
}
-
+
if (count < 5)
first->flag = 1;
}
@@ -974,7 +974,7 @@ static UvMapVert *uv_select_edgeloop_vertex_map_get(UvVertMap *vmap, BMFace *efa
if (iterv->f == BM_elem_index_get(efa))
return first;
}
-
+
return NULL;
}
@@ -1113,7 +1113,7 @@ static int uv_select_edgeloop(
else {
select = true;
}
-
+
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
iterv_curr = uv_select_edgeloop_vertex_map_get(vmap, efa, l);
@@ -1724,7 +1724,7 @@ static void UV_OT_align(wmOperatorType *ot)
ot->description = "Align selected UV vertices to an axis";
ot->idname = "UV_OT_align";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = uv_align_exec;
ot->poll = ED_operator_uvedit;
@@ -1919,7 +1919,7 @@ static void UV_OT_weld(wmOperatorType *ot)
ot->description = "Weld selected UV vertices together";
ot->idname = "UV_OT_weld";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = uv_weld_exec;
ot->poll = ED_operator_uvedit;
@@ -2073,7 +2073,7 @@ static void UV_OT_select_all(wmOperatorType *ot)
ot->description = "Change selection of all UV vertices";
ot->idname = "UV_OT_select_all";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = uv_select_all_exec;
ot->poll = ED_operator_uvedit;
@@ -2225,7 +2225,7 @@ static int uv_mouse_select_multi(
hituv[i] = luv->uv;
hitv[i] = BM_elem_index_get(l->v);
}
-
+
hitlen = hit.efa->len;
}
else if (selectmode == UV_SELECT_ISLAND) {
@@ -2330,7 +2330,7 @@ static int uv_mouse_select_multi(
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (!uvedit_face_visible_test(scene, obedit, ima, efa))
continue;
-
+
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (sticky == SI_STICKY_DISABLE) continue;
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -2416,7 +2416,7 @@ static void UV_OT_select(wmOperatorType *ot)
ot->description = "Select UV vertices";
ot->idname = "UV_OT_select";
ot->flag = OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = uv_select_exec;
ot->invoke = uv_select_invoke;
@@ -2465,7 +2465,7 @@ static void UV_OT_select_loop(wmOperatorType *ot)
ot->description = "Select a loop of connected UV vertices";
ot->idname = "UV_OT_select_loop";
ot->flag = OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = uv_select_loop_exec;
ot->invoke = uv_select_loop_invoke;
@@ -2568,7 +2568,7 @@ static void UV_OT_select_linked(wmOperatorType *ot)
ot->description = "Select all UV vertices linked to the active UV map";
ot->idname = "UV_OT_select_linked";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = uv_select_linked_exec;
ot->poll = ED_operator_uvedit; /* requires space image */
@@ -2775,19 +2775,19 @@ static void uv_select_flush_from_tag_sticky_loc_internal(
*/
static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object *obedit, const bool select)
{
- /* Selecting UV Faces with some modes requires us to change
+ /* Selecting UV Faces with some modes requires us to change
* the selection in other faces (depending on the sticky mode).
- *
+ *
* This only needs to be done when the Mesh is not used for
* selection (so for sticky modes, vertex or location based). */
-
+
ToolSettings *ts = scene->toolsettings;
BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMFace *efa;
BMLoop *l;
BMIter iter, liter;
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
-
+
if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && sima->sticky == SI_STICKY_VERTEX) {
/* Tag all verts as untouched, then touch the ones that have a face center
* in the loop and select all MLoopUV's that use a touched vert. */
@@ -2816,19 +2816,19 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object
struct UvVertMap *vmap;
float limit[2];
unsigned int efa_index;
-
+
uvedit_pixel_to_float(sima, limit, 0.05);
-
+
BM_mesh_elem_table_ensure(em->bm, BM_FACE);
vmap = BM_uv_vert_map_create(em->bm, limit, false, false);
if (vmap == NULL) {
return;
}
-
+
BM_ITER_MESH_INDEX (efa, &iter, em->bm, BM_FACES_OF_MESH, efa_index) {
if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
/* tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); */ /* UNUSED */
-
+
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
uv_select_flush_from_tag_sticky_loc_internal(
scene, em, vmap, efa_index, l,
@@ -2837,7 +2837,7 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object
}
}
BM_uv_vert_map_free(vmap);
-
+
}
else { /* SI_STICKY_DISABLE or ts->uv_flag & UV_SYNC_SELECTION */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
@@ -3068,17 +3068,17 @@ static void UV_OT_select_border(wmOperatorType *ot)
ot->name = "Border Select";
ot->description = "Select UV vertices using border selection";
ot->idname = "UV_OT_select_border";
-
+
/* api callbacks */
ot->invoke = WM_gesture_border_invoke;
ot->exec = uv_border_select_exec;
ot->modal = WM_gesture_border_modal;
ot->poll = ED_operator_uvedit_space_image; /* requires space image */;
ot->cancel = WM_gesture_border_cancel;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "pinned", 0, "Pinned", "Border select pinned UVs only");
@@ -3137,7 +3137,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op)
ellipse[1] = height * zoomy / radius;
UI_view2d_region_to_view(&ar->v2d, x, y, &offset[0], &offset[1]);
-
+
/* do selection */
if (use_face_center) {
changed = false;
@@ -3193,14 +3193,14 @@ static void UV_OT_circle_select(wmOperatorType *ot)
ot->name = "Circle Select";
ot->description = "Select UV vertices using circle selection";
ot->idname = "UV_OT_circle_select";
-
+
/* api callbacks */
ot->invoke = WM_gesture_circle_invoke;
ot->modal = WM_gesture_circle_modal;
ot->exec = uv_circle_select_exec;
ot->poll = ED_operator_uvedit_space_image; /* requires space image */;
ot->cancel = WM_gesture_circle_cancel;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3416,7 +3416,7 @@ static int uv_snap_cursor_exec(bContext *C, wmOperator *op)
if (!changed)
return OPERATOR_CANCELLED;
-
+
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, sima);
return OPERATOR_FINISHED;
@@ -3434,7 +3434,7 @@ static void UV_OT_snap_cursor(wmOperatorType *ot)
ot->description = "Snap cursor to target type";
ot->idname = "UV_OT_snap_cursor";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = uv_snap_cursor_exec;
ot->poll = ED_operator_uvedit_space_image; /* requires space image */;
@@ -3513,7 +3513,7 @@ static bool uv_snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object
MLoopUV *luv;
bool changed = false;
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
-
+
/* index every vert that has a selected UV using it, but only once so as to
* get unique indices and to count how much to malloc */
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
@@ -3575,7 +3575,7 @@ static bool uv_snap_uvs_to_pixels(SpaceImage *sima, Scene *scene, Object *obedit
ED_space_image_get_size(sima, &width, &height);
w = (float)width;
h = (float)height;
-
+
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (!uvedit_face_visible_test(scene, obedit, ima, efa))
continue;
@@ -3647,7 +3647,7 @@ static void UV_OT_snap_selected(wmOperatorType *ot)
ot->description = "Snap selected UV vertices to target type";
ot->idname = "UV_OT_snap_selected";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = uv_snap_selection_exec;
ot->poll = ED_operator_uvedit_space_image;
@@ -3673,7 +3673,7 @@ static int uv_pin_exec(bContext *C, wmOperator *op)
BMIter iter, liter;
MLoopUV *luv;
const bool clear = RNA_boolean_get(op->ptr, "clear");
-
+
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
@@ -3682,7 +3682,7 @@ static int uv_pin_exec(bContext *C, wmOperator *op)
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
-
+
if (!clear) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset))
luv->flag |= MLOOPUV_PINNED;
@@ -3693,7 +3693,7 @@ static int uv_pin_exec(bContext *C, wmOperator *op)
}
}
}
-
+
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
@@ -3706,7 +3706,7 @@ static void UV_OT_pin(wmOperatorType *ot)
ot->description = "Set/clear selected UV vertices as anchored between multiple unwrap operations";
ot->idname = "UV_OT_pin";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = uv_pin_exec;
ot->poll = ED_operator_uvedit;
@@ -3731,7 +3731,7 @@ static int uv_select_pinned_exec(bContext *C, wmOperator *UNUSED(op))
BMLoop *l;
BMIter iter, liter;
MLoopUV *luv;
-
+
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
@@ -3740,12 +3740,12 @@ static int uv_select_pinned_exec(bContext *C, wmOperator *UNUSED(op))
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
-
+
if (luv->flag & MLOOPUV_PINNED)
uvedit_uv_select_enable(em, scene, l, false, cd_loop_uv_offset);
}
}
-
+
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
@@ -3758,7 +3758,7 @@ static void UV_OT_select_pinned(wmOperatorType *ot)
ot->description = "Select all pinned UV vertices";
ot->idname = "UV_OT_select_pinned";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = uv_select_pinned_exec;
ot->poll = ED_operator_uvedit;
@@ -3878,7 +3878,7 @@ static int uv_hide_exec(bContext *C, wmOperator *op)
/* flush vertex selection changes */
if (em->selectmode != SCE_SELECT_FACE)
EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX | SCE_SELECT_EDGE);
-
+
BM_select_history_validate(em->bm);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
@@ -3894,7 +3894,7 @@ static void UV_OT_hide(wmOperatorType *ot)
ot->description = "Hide (un)selected UV vertices";
ot->idname = "UV_OT_hide";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = uv_hide_exec;
ot->poll = ED_operator_uvedit;
@@ -3961,7 +3961,7 @@ static int uv_reveal_exec(bContext *C, wmOperator *op)
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
totsel += BM_elem_flag_test(l->v, BM_ELEM_SELECT);
}
-
+
if (!totsel) {
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -4018,7 +4018,7 @@ static int uv_reveal_exec(bContext *C, wmOperator *op)
}
}
}
-
+
/* re-select tagged faces */
BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, false, BM_ELEM_TAG);
@@ -4034,7 +4034,7 @@ static void UV_OT_reveal(wmOperatorType *ot)
ot->description = "Reveal all hidden UV vertices";
ot->idname = "UV_OT_reveal";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = uv_reveal_exec;
ot->poll = ED_operator_uvedit;
@@ -4063,9 +4063,9 @@ static int uv_set_2d_cursor_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
RNA_float_get_array(op->ptr, "location", sima->cursor);
-
+
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -4095,7 +4095,7 @@ static void UV_OT_cursor_set(wmOperatorType *ot)
ot->name = "Set 2D Cursor";
ot->description = "Set 2D cursor location";
ot->idname = "UV_OT_cursor_set";
-
+
/* api callbacks */
ot->exec = uv_set_2d_cursor_exec;
ot->invoke = uv_set_2d_cursor_invoke;
@@ -4381,7 +4381,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf)
{
wmKeyMap *keymap;
wmKeyMapItem *kmi;
-
+
keymap = WM_keymap_find(keyconf, "UV Editor", 0, 0);
keymap->poll = ED_operator_uvedit_can_uv_sculpt;
@@ -4391,7 +4391,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf)
/* Mark edge seam */
WM_keymap_add_item(keymap, "UV_OT_mark_seam", EKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* pick selection */
RNA_boolean_set(WM_keymap_add_item(keymap, "UV_OT_select", SELECTMOUSE, KM_PRESS, 0, 0)->ptr, "extend", false);
RNA_boolean_set(WM_keymap_add_item(keymap, "UV_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", true);
@@ -4437,7 +4437,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "UV_OT_select_pinned", PKEY, KM_PRESS, KM_SHIFT, 0);
- WM_keymap_add_menu(keymap, "IMAGE_MT_uvs_weldalign", WKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_menu(keymap, "IMAGE_MT_uvs_weldalign", WKEY, KM_PRESS, KM_SHIFT, 0);
/* uv operations */
WM_keymap_add_item(keymap, "UV_OT_stitch", VKEY, KM_PRESS, 0, 0);
@@ -4462,7 +4462,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf)
/* cursor */
WM_keymap_add_item(keymap, "UV_OT_cursor_set", ACTIONMOUSE, KM_PRESS, 0, 0);
-
+
/* menus */
WM_keymap_add_menu(keymap, "IMAGE_MT_uvs_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_menu(keymap, "IMAGE_MT_uvs_select_mode", TABKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index c510c12ae53..1d2583cf9d4 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -113,7 +113,7 @@ typedef struct PVert {
float uv[2];
unsigned char flag;
-} PVert;
+} PVert;
typedef struct PEdge {
struct PEdge *nextlink;
@@ -242,8 +242,8 @@ typedef struct PHandle {
*/
static int PHashSizes[] = {
- 1, 3, 5, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209,
- 16411, 32771, 65537, 131101, 262147, 524309, 1048583, 2097169,
+ 1, 3, 5, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209,
+ 16411, 32771, 65537, 131101, 262147, 524309, 1048583, 2097169,
4194319, 8388617, 16777259, 33554467, 67108879, 134217757, 268435459
};
@@ -294,7 +294,7 @@ static void phash_insert(PHash *ph, PHashLink *link)
link->next = lookup->next;
lookup->next = link;
}
-
+
ph->size++;
if (ph->size > (size * 3)) {
@@ -323,7 +323,7 @@ static PHashLink *phash_lookup(PHash *ph, PHashKey key)
return link;
else if (PHASH_hash(ph, link->key) != hash)
return NULL;
-
+
return link;
}
@@ -336,7 +336,7 @@ static PHashLink *phash_next(PHash *ph, PHashKey key, PHashLink *link)
return link;
else if (PHASH_hash(ph, link->key) != hash)
return NULL;
-
+
return link;
}
@@ -562,7 +562,7 @@ static PEdge *p_wheel_edge_next(PEdge *e)
}
static PEdge *p_wheel_edge_prev(PEdge *e)
-{
+{
return (e->pair) ? e->pair->next : NULL;
}
@@ -619,7 +619,7 @@ static void p_chart_topological_sanity_check(PChart *chart)
for (v = chart->verts; v; v = v->nextlink)
param_test_equals_ptr("v->edge->vert", v, v->edge->vert);
-
+
for (e = chart->edges; e; e = e->nextlink) {
if (e->pair) {
param_test_equals_ptr("e->pair->pair", e, e->pair->pair);
@@ -867,7 +867,7 @@ static PBool p_edge_implicit_seam(PEdge *e, PEdge *ep)
ep->flag |= PEDGE_SEAM;
return P_TRUE;
}
-
+
return P_FALSE;
}
@@ -881,7 +881,7 @@ static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PEdge **pair, PBool impl
if (e->flag & PEDGE_SEAM)
return P_FALSE;
-
+
key = PHASH_edge(key1, key2);
pe = (PEdge *)phash_lookup(handle->hash_edges, key);
*pair = NULL;
@@ -999,7 +999,7 @@ static void p_split_vert(PChart *chart, PEdge *e)
lastwe = e;
for (we = p_wheel_edge_prev(e); we && (we != e); we = p_wheel_edge_prev(we))
lastwe = we;
-
+
/* go over all edges in wheel */
for (we = lastwe; we; we = p_wheel_edge_next(we)) {
if (we->flag & PEDGE_VERTEX_SPLIT)
@@ -1202,7 +1202,7 @@ static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys
/* Construction: boundary filling */
static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer)
-{
+{
PEdge *e, *be;
float len, maxlen = -1.0;
@@ -1327,7 +1327,7 @@ static void p_chart_fill_boundary(PChart *chart, PEdge *be, int nedges)
}
else {
ne2->vert->edge = ne2;
-
+
ne2->u.heaplink = BLI_heap_insert(heap, p_edge_boundary_angle(ne2), ne2);
e2->u.heaplink = BLI_heap_insert(heap, p_edge_boundary_angle(e2), e2);
}
@@ -1412,7 +1412,7 @@ static void p_polygon_kernel_clip(float (*oldpoints)[2], int noldpoints, float (
newpoints[*nnewpoints][1] = p2[1];
(*nnewpoints)++;
}
-
+
p1in = p2in;
p1 = p2;
}
@@ -1422,7 +1422,7 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent
{
int i, size, nnewpoints = npoints;
float (*oldpoints)[2], (*newpoints)[2], *p1, *p2;
-
+
size = npoints * 3;
oldpoints = MEM_mallocN(sizeof(float) * 2 * size, "PPolygonOldPoints");
newpoints = MEM_mallocN(sizeof(float) * 2 * size, "PPolygonNewPoints");
@@ -1486,7 +1486,7 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent
int NCOLLAPSE = 1;
int NCOLLAPSEX = 0;
-
+
static float p_vert_cotan(float *v1, float *v2, float *v3)
{
float a[3], b[3], c[3], clen;
@@ -1499,10 +1499,10 @@ static float p_vert_cotan(float *v1, float *v2, float *v3)
if (clen == 0.0f)
return 0.0f;
-
+
return dot_v3v3(a, b) / clen;
}
-
+
static PBool p_vert_flipped_wheel_triangle(PVert *v)
{
PEdge *e = v->edge;
@@ -1530,7 +1530,7 @@ static PBool p_vert_map_harmonic_weights(PVert *v)
do {
float t1, t2, weight;
PVert *v1, *v2;
-
+
v1 = e->next->vert;
v2 = e->next->next->vert;
t1 = p_vert_cotan(v2->co, e->vert->co, v1->co);
@@ -1563,7 +1563,7 @@ static PBool p_vert_map_harmonic_weights(PVert *v)
weightsum += t1 + t2;
positionsum[0] += (v2->uv[1] - v1->uv[1]) + (t1 * v2->uv[0] + t2 * v1->uv[0]);
positionsum[1] += (v1->uv[0] - v2->uv[0]) + (t1 * v2->uv[1] + t2 * v1->uv[1]);
-
+
e = p_wheel_edge_next(e);
} while (e && (e != v->edge));
}
@@ -1617,20 +1617,20 @@ static void p_vert_harmonic_insert(PVert *v)
do {
PEdge *nexte = p_wheel_edge_next(e);
- points[i][0] = e->next->vert->uv[0];
- points[i][1] = e->next->vert->uv[1];
+ points[i][0] = e->next->vert->uv[0];
+ points[i][1] = e->next->vert->uv[1];
if (nexte == NULL) {
i++;
- points[i][0] = e->next->next->vert->uv[0];
- points[i][1] = e->next->next->vert->uv[1];
+ points[i][0] = e->next->next->vert->uv[0];
+ points[i][1] = e->next->next->vert->uv[1];
break;
}
e = nexte;
i++;
} while (e != v->edge);
-
+
p_polygon_kernel_center(points, npoints, v->uv);
MEM_freeN(points);
@@ -1653,7 +1653,7 @@ static void p_vert_fix_edge_pointer(PVert *v)
/* set v->edge pointer to the edge with no pair, if there is one */
while (v->edge->pair) {
v->edge = p_wheel_edge_prev(v->edge);
-
+
if (v->edge == start)
break;
}
@@ -1699,7 +1699,7 @@ static void p_collapse_edge(PEdge *edge, PEdge *pair)
else
keepv->edge = pair->next->pair->next;
}
-
+
/* update pairs and v->edge pointers */
if (edge) {
PEdge *e1 = edge->next, *e2 = e1->next;
@@ -1821,7 +1821,7 @@ static PBool p_collapse_allowed_topologic(PEdge *edge, PEdge *pair)
* the chart) */
else if (!p_vert_interior(oldv) && !p_vert_interior(keepv))
return P_FALSE;
-
+
return P_TRUE;
}
@@ -1868,7 +1868,7 @@ static PBool p_collapse_allowed_geometric(PEdge *edge, PEdge *pair)
if (p_collapse_normal_flipped(v1->co, v2->co, oldv->co, keepv->co))
return P_FALSE;
-
+
a[0] = angle;
a[1] = p_vec_angle(v2->co, v1->co, oldv->co);
a[2] = M_PI - a[0] - a[1];
@@ -1903,7 +1903,7 @@ static PBool p_collapse_allowed_geometric(PEdge *edge, PEdge *pair)
/* abf++ criterion 2: avoid collapsing verts inwards */
if (p_vert_interior(keepv))
return P_FALSE;
-
+
/* don't collapse significant boundary changes */
angle = p_vec_angle(v1->co, oldv->co, v2->co);
if (angle < (M_PI * 160.0 / 180.0))
@@ -1921,7 +1921,7 @@ static PBool p_collapse_allowed(PEdge *edge, PEdge *pair)
if (oldv->flag & PVERT_PIN)
return P_FALSE;
-
+
return (p_collapse_allowed_topologic(edge, pair) &&
p_collapse_allowed_geometric(edge, pair));
}
@@ -2010,7 +2010,7 @@ static float p_collapse_cost(PEdge *edge, PEdge *pair)
return cost;
}
-
+
static void p_collapse_cost_vertex(PVert *vert, float *mincost, PEdge **mine)
{
PEdge *e, *enext, *pair;
@@ -2172,7 +2172,7 @@ static void p_chart_simplify_compute(PChart *chart)
for (v = chart->verts; v; v = v->nextlink) {
float cost;
PEdge *e = NULL;
-
+
p_collapse_cost_vertex(v, &cost, &e);
if (e)
@@ -2237,7 +2237,7 @@ static void p_chart_simplify_compute(PChart *chart)
BLI_heap_remove(heap, v->u.heaplink);
v->u.heaplink = NULL;
}
-
+
p_collapse_cost_vertex(v, &cost, &collapse);
if (collapse)
@@ -2331,7 +2331,7 @@ static void p_abf_setup_system(PAbfSystem *sys)
for (i = 0; i < sys->ninterior; i++)
sys->lambdaLength[i] = 1.0;
-
+
sys->minangle = 1.0 * M_PI / 180.0;
sys->maxangle = (float)M_PI - sys->minangle;
}
@@ -2649,7 +2649,7 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
dlambda1 = pre[0] + pre[1] + pre[2];
dlambda1 = sys->dstar[f->u.id] * (sys->bstar[f->u.id] - dlambda1);
-
+
sys->lambdaTriangle[f->u.id] += dlambda1;
dalpha = (sys->bAlpha[e1->u.id] - dlambda1);
@@ -2914,7 +2914,7 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV
if (!maxe1 || !maxe2 || (maxlen < 0.5f * totlen))
return P_FALSE;
-
+
/* find pin1 in the split vertices */
be1 = maxe1;
be2 = maxe2;
@@ -3212,7 +3212,7 @@ static void p_chart_lscm_end(PChart *chart)
{
if (chart->u.lscm.context)
EIG_linear_solver_delete(chart->u.lscm.context);
-
+
if (chart->u.lscm.abf_alpha) {
MEM_freeN(chart->u.lscm.abf_alpha);
chart->u.lscm.abf_alpha = NULL;
@@ -3250,7 +3250,7 @@ static float p_face_stretch(PFace *f)
if (area <= 0.0f) /* flipped face -> infinite stretch */
return 1e10f;
-
+
w = 1.0f / (2.0f * area);
/* compute derivatives */
@@ -3682,7 +3682,7 @@ static SmoothNode *p_node_new(MemArena *arena, SmoothTriangle **tri, int ntri, f
if (ntri <= 10 || depth >= 15)
return node;
-
+
t1 = MEM_mallocN(sizeof(*t1) * ntri, "PNodeTri1");
t2 = MEM_mallocN(sizeof(*t2) * ntri, "PNodeTri1");
@@ -3707,7 +3707,7 @@ static SmoothNode *p_node_new(MemArena *arena, SmoothTriangle **tri, int ntri, f
MEM_freeN(t2);
return node;
}
-
+
node->tri = NULL;
node->ntri = 0;
MEM_freeN(tri);
@@ -3782,7 +3782,7 @@ static float p_smooth_median_edge_length(PChart *chart)
/* ok, so i'm lazy */
for (i = 0, e = chart->edges; e; e = e->nextlink, i++)
lengths[i] = p_edge_length(e);
-
+
qsort(lengths, i, sizeof(float), p_compare_float);
median = lengths[i / 2];
@@ -3876,7 +3876,7 @@ static void p_smooth(PChart *chart)
if ((gridx <= 2) || (gridy <= 2))
return;
-
+
edgesx = gridx - 1;
edgesy = gridy - 1;
nsize = gridx * gridy;
@@ -3936,7 +3936,7 @@ static void p_smooth(PChart *chart)
float p[2], b[3];
i = x + y * gridx;
-
+
p[0] = nodesx[i];
p[1] = nodesy[i];
@@ -3979,7 +3979,7 @@ static void p_smooth(PChart *chart)
for (it2 = 0; it2 < maxiter2; it2++) {
d = 0.0f;
totiter += 1;
-
+
memcpy(oldnodesx, nodesx, sizeof(float) * nsize);
memcpy(oldnodesy, nodesy, sizeof(float) * nsize);
@@ -4011,7 +4011,7 @@ static void p_smooth(PChart *chart)
sum1 += vedges[j] * oldnodesy[i + gridx];
nodesy[i] = sum1 / sum2;
-
+
p[0] = nodesx[i];
p[1] = nodesy[i];
@@ -4089,8 +4089,8 @@ static void p_smooth(PChart *chart)
t2->co3[0] = t->co3[0]; t2->co3[1] = t->co3[1];
t2->oco3[0] = t->oco3[0]; t2->oco3[1] = t->oco3[1];
- *trip = t; trip++; t++;
- *trip = t; trip++; t++;
+ *trip = t; trip++; t++;
+ *trip = t; trip++; t++;
}
}
@@ -4107,7 +4107,7 @@ static void p_smooth(PChart *chart)
p_node_delete(root);
BLI_memarena_free(arena);
-
+
MEM_freeN(triangles);
}
@@ -4149,7 +4149,7 @@ void param_delete(ParamHandle *handle)
for (i = 0; i < phandle->ncharts; i++)
p_chart_delete(phandle->charts[i]);
-
+
if (phandle->charts)
MEM_freeN(phandle->charts);
@@ -4496,24 +4496,24 @@ static void param_pack_rotate(ParamHandle *handle)
}
void param_pack(ParamHandle *handle, float margin, bool do_rotate)
-{
+{
/* box packing variables */
BoxPack *boxarray, *box;
float tot_width, tot_height, scale;
-
+
PChart *chart;
int i, unpacked = 0;
float trans[2];
double area = 0.0;
-
+
PHandle *phandle = (PHandle *)handle;
-
+
if (phandle->ncharts == 0)
return;
-
+
if (phandle->aspx != phandle->aspy)
param_scale(handle, 1.0f / phandle->aspx, 1.0f / phandle->aspy);
-
+
/* this could be its own function */
if (do_rotate) {
param_pack_rotate(handle);
@@ -4521,33 +4521,33 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate)
/* we may not use all these boxes */
boxarray = MEM_mallocN(phandle->ncharts * sizeof(BoxPack), "BoxPack box");
-
-
+
+
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
-
+
if (chart->flag & PCHART_NOPACK) {
unpacked++;
continue;
}
-
+
box = boxarray + (i - unpacked);
-
+
p_chart_uv_bbox(chart, trans, chart->u.pack.size);
-
+
trans[0] = -trans[0];
trans[1] = -trans[1];
-
+
p_chart_uv_translate(chart, trans);
-
+
box->w = chart->u.pack.size[0] + trans[0];
box->h = chart->u.pack.size[1] + trans[1];
box->index = i; /* warning this index skips PCHART_NOPACK boxes */
-
+
if (margin > 0.0f)
area += (double)sqrtf(box->w * box->h);
}
-
+
if (margin > 0.0f) {
/* multiply the margin by the area to give predictable results not dependent on UV scale,
* ...Without using the area running pack multiple times also gives a bad feedback loop.
@@ -4556,12 +4556,12 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate)
unpacked = 0;
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
-
+
if (chart->flag & PCHART_NOPACK) {
unpacked++;
continue;
}
-
+
box = boxarray + (i - unpacked);
trans[0] = margin;
trans[1] = margin;
@@ -4570,19 +4570,19 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate)
box->h += margin * 2;
}
}
-
+
BLI_box_pack_2d(boxarray, phandle->ncharts - unpacked, &tot_width, &tot_height);
-
+
if (tot_height > tot_width)
scale = 1.0f / tot_height;
else
scale = 1.0f / tot_width;
-
+
for (i = 0; i < phandle->ncharts - unpacked; i++) {
box = boxarray + i;
trans[0] = box->x;
trans[1] = box->y;
-
+
chart = phandle->charts[box->index];
p_chart_uv_translate(chart, trans);
p_chart_uv_scale(chart, scale);
@@ -4601,54 +4601,54 @@ void param_average(ParamHandle *handle)
float tot_fac, fac;
float minv[2], maxv[2], trans[2];
PHandle *phandle = (PHandle *)handle;
-
+
if (phandle->ncharts == 0)
return;
-
+
for (i = 0; i < phandle->ncharts; i++) {
PFace *f;
chart = phandle->charts[i];
if (chart->flag & PCHART_NOPACK)
continue;
-
+
chart->u.pack.area = 0.0f; /* 3d area */
chart->u.pack.rescale = 0.0f; /* UV area, abusing rescale for tmp storage, oh well :/ */
-
+
for (f = chart->faces; f; f = f->nextlink) {
chart->u.pack.area += p_face_area(f);
chart->u.pack.rescale += fabsf(p_face_uv_area_signed(f));
}
-
+
tot_facearea += chart->u.pack.area;
tot_uvarea += chart->u.pack.rescale;
}
-
+
if (tot_facearea == tot_uvarea || tot_facearea == 0.0f || tot_uvarea == 0.0f) {
/* nothing to do */
return;
}
-
+
tot_fac = tot_facearea / tot_uvarea;
-
+
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
if (chart->flag & PCHART_NOPACK)
continue;
-
+
if (chart->u.pack.area != 0.0f && chart->u.pack.rescale != 0.0f) {
fac = chart->u.pack.area / chart->u.pack.rescale;
-
+
/* Get the island center */
p_chart_uv_bbox(chart, minv, maxv);
trans[0] = (minv[0] + maxv[0]) / -2.0f;
trans[1] = (minv[1] + maxv[1]) / -2.0f;
-
+
/* Move center to 0,0 */
p_chart_uv_translate(chart, trans);
p_chart_uv_scale(chart, sqrtf(fac / tot_fac));
-
+
/* Move to original center */
trans[0] = -trans[0];
trans[1] = -trans[1];
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h
index eaea781971d..50b4ee66644 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.h
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.h
@@ -30,7 +30,7 @@
#ifdef __cplusplus
extern "C" {
#endif
-
+
#include "BLI_sys_types.h" // for intptr_t support
typedef void ParamHandle; /* handle to a set of charts */
@@ -77,7 +77,7 @@ void param_delete(ParamHandle *chart);
* - lscm is divided in three steps:
* - begin: compute matrix and it's factorization (expensive)
* - solve using pinned coordinates (cheap)
- * - end: clean up
+ * - end: clean up
* - uv coordinates are allowed to change within begin/end, for
* quick re-solving
*/
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index 4c205818329..f39498b08f3 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -2334,7 +2334,7 @@ void UV_OT_stitch(wmOperatorType *ot)
ot->description = "Stitch selected UV vertices by proximity";
ot->idname = "UV_OT_stitch";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->invoke = stitch_invoke;
ot->modal = stitch_modal;
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 521470d4e5f..78b412579e6 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -147,7 +147,7 @@ static bool ED_uvedit_ensure_uvs(bContext *C, Scene *UNUSED(scene), Object *obed
}
}
}
-
+
/* select new UV's (ignore UV_SYNC_SELECTION in this case) */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
BMIter liter;
@@ -170,7 +170,7 @@ static bool uvedit_have_selection(Scene *scene, BMEditMesh *em, bool implicit)
BMLoop *l;
BMIter iter, liter;
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
-
+
if (cd_loop_uv_offset == -1) {
return (em->bm->totfacesel != 0);
}
@@ -184,15 +184,15 @@ static bool uvedit_have_selection(Scene *scene, BMEditMesh *em, bool implicit)
}
else if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
continue;
-
+
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset))
break;
}
-
+
if (implicit && !l)
continue;
-
+
return true;
}
@@ -277,7 +277,7 @@ static ParamHandle *construct_param_handle(
BMEdge *eed;
BMIter iter, liter;
int i;
-
+
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
handle = param_construct_begin();
@@ -290,10 +290,10 @@ static ParamHandle *construct_param_handle(
if (aspx != aspy)
param_aspect_ratio(handle, aspx, aspy);
}
-
+
/* we need the vert indices */
BM_mesh_elem_index_ensure(bm, BM_VERT);
-
+
BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, i) {
if ((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) || (sel && BM_elem_flag_test(efa, BM_ELEM_SELECT) == 0)) {
@@ -494,7 +494,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B
smd.levels = smd_real->levels;
smd.subdivType = smd_real->subdivType;
-
+
initialDerived = CDDM_from_editbmesh(em, false, false);
derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd,
NULL, SUBSURF_IN_EDIT_MODE);
@@ -563,7 +563,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B
co[1] = subsurfedVerts[mloop[1].v].co;
co[2] = subsurfedVerts[mloop[2].v].co;
co[3] = subsurfedVerts[mloop[3].v].co;
-
+
/* This is where all the magic is done. If the vertex exists in the, we pass the original uv pointer to the solver, thus
* flushing the solution to the edit mesh. */
texface_from_original_index(origFace, origVertIndices[mloop[0].v], &uv[0], &pin[0], &select[0], scene, cd_loop_uv_offset);
@@ -791,7 +791,7 @@ void UV_OT_minimize_stretch(wmOperatorType *ot)
ot->idname = "UV_OT_minimize_stretch";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_CURSOR | OPTYPE_BLOCKING;
ot->description = "Reduce UV stretching by relaxing angles";
-
+
/* api callbacks */
ot->exec = minimize_stretch_exec;
ot->invoke = minimize_stretch_invoke;
@@ -869,7 +869,7 @@ void UV_OT_pack_islands(wmOperatorType *ot)
ot->description = "Transform all islands so that they fill up the UV space as much as possible";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = pack_islands_exec;
ot->poll = ED_operator_uvedit;
@@ -897,7 +897,7 @@ static int average_islands_scale_exec(bContext *C, wmOperator *UNUSED(op))
param_average(handle);
param_flush(handle);
param_delete(handle);
-
+
DEG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
@@ -912,7 +912,7 @@ void UV_OT_average_islands_scale(wmOperatorType *ot)
ot->description = "Average the size of separate UV islands, based on their area in 3D space";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = average_islands_scale_exec;
ot->poll = ED_operator_uvedit;
@@ -950,7 +950,7 @@ void ED_uvedit_live_unwrap_re_solve(void)
param_flush(liveHandle);
}
}
-
+
void ED_uvedit_live_unwrap_end(short cancel)
{
if (liveHandle) {
@@ -1139,7 +1139,7 @@ static void uv_map_transform(bContext *C, wmOperator *op, float rotmat[4][4])
/* be compatible to the "old" sphere/cylinder mode */
if (direction == ALIGN_TO_OBJECT)
unit_m4(rotmat);
- else
+ else
uv_map_rotation_matrix(rotmat, rv3d, obedit, upangledeg, sideangledeg, radius);
}
@@ -1174,21 +1174,21 @@ static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em)
MLoopUV *luv;
BMFace *efa;
float scale, aspx, aspy;
-
+
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
ED_uvedit_get_aspect(scene, ob, em->bm, &aspx, &aspy);
-
+
if (aspx == aspy)
return;
-
+
if (aspx > aspy) {
scale = aspy / aspx;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
continue;
-
+
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
luv->uv[0] = ((luv->uv[0] - 0.5f) * scale) + 0.5f;
@@ -1201,7 +1201,7 @@ static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em)
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
continue;
-
+
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
luv->uv[1] = ((luv->uv[1] - 0.5f) * scale) + 0.5f;
@@ -1436,7 +1436,7 @@ void UV_OT_unwrap(wmOperatorType *ot)
ot->description = "Unwrap the mesh of the object being edited";
ot->idname = "UV_OT_unwrap";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = unwrap_exec;
ot->poll = ED_operator_uvmap;
@@ -1596,7 +1596,7 @@ void UV_OT_project_from_view(wmOperatorType *ot)
ot->description = "Project the UV vertices of the mesh as seen in current 3D view";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->invoke = uv_from_view_invoke;
ot->exec = uv_from_view_exec;
@@ -1651,7 +1651,7 @@ void UV_OT_reset(wmOperatorType *ot)
ot->description = "Reset UV projection";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = reset_exec;
ot->poll = ED_operator_uvmap;
@@ -1670,7 +1670,7 @@ static void uv_sphere_project(float target[2], float source[3], float center[3],
/* split line is always zero */
if (target[0] >= 1.0f)
- target[0] -= 1.0f;
+ target[0] -= 1.0f;
}
static void uv_map_mirror(BMEditMesh *em, BMFace *efa)
@@ -1764,7 +1764,7 @@ void UV_OT_sphere_project(wmOperatorType *ot)
ot->description = "Project the UV vertices of the mesh over the curved surface of a sphere";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = sphere_project_exec;
ot->poll = ED_operator_uvmap;
@@ -1787,7 +1787,7 @@ static void uv_cylinder_project(float target[2], float source[3], float center[3
/* split line is always zero */
if (target[0] >= 1.0f)
- target[0] -= 1.0f;
+ target[0] -= 1.0f;
}
static int cylinder_project_exec(bContext *C, wmOperator *op)
@@ -1852,7 +1852,7 @@ void UV_OT_cylinder_project(wmOperatorType *ot)
ot->description = "Project the UV vertices of the mesh over the curved wall of a cylinder";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = cylinder_project_exec;
ot->poll = ED_operator_uvmap;
@@ -1969,7 +1969,7 @@ void UV_OT_cube_project(wmOperatorType *ot)
ot->description = "Project the UV vertices of the mesh over the six faces of a cube";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* api callbacks */
ot->exec = cube_project_exec;
ot->poll = ED_operator_uvmap;
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
index 9cba1d03bd8..f41a9b58085 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
@@ -95,7 +95,7 @@ NodeGroup *BlenderFileLoader::Load()
int id = 0;
DEG_OBJECT_ITER_BEGIN(
- depsgraph, ob, DEG_ITER_OBJECT_MODE_RENDER,
+ depsgraph, ob,
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
DEG_ITER_OBJECT_FLAG_VISIBLE |
@@ -546,7 +546,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
if (mat) {
tmpMat.setLine(mat->line_col[0], mat->line_col[1], mat->line_col[2], mat->line_col[3]);
- tmpMat.setDiffuse(mat->r, mat->g, mat->b, mat->alpha);
+ tmpMat.setDiffuse(mat->r, mat->g, mat->b, 1.0f);
tmpMat.setSpecular(mat->specr, mat->specg, mat->specb, 1.0f);
tmpMat.setShininess(128.f);
tmpMat.setPriority(mat->line_priority);
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index 362b34aa64c..8fc2353bc7a 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -838,7 +838,7 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
material_index++;
} // loop over strokes
- test_object_materials(object_mesh, (ID *)mesh);
+ test_object_materials(freestyle_bmain, object_mesh, (ID *)mesh);
#if 0 // XXX
BLI_assert(mesh->totvert == vertex_index);
diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.h b/source/blender/freestyle/intern/geometry/GeomUtils.h
index 5a5d0809083..8f3abf451c9 100644
--- a/source/blender/freestyle/intern/geometry/GeomUtils.h
+++ b/source/blender/freestyle/intern/geometry/GeomUtils.h
@@ -167,7 +167,7 @@ void fromWorldToImage(const Vec3r& p, Vec3r& q, const real model_view_matrix[4][
* q
* vector in which the result will be stored
* transform
- * The transformation matrix (gathering model view and projection),
+ * The transformation matrix (gathering model view and projection),
* expressed in line major order (OpenGL matrices are column major ordered)
* viewport
* The viewport: x,y coordinates followed by width and height (OpenGL like viewport)
@@ -175,7 +175,7 @@ void fromWorldToImage(const Vec3r& p, Vec3r& q, const real model_view_matrix[4][
void fromWorldToImage(const Vec3r& p, Vec3r& q, const real transform[4][4], const int viewport[4]);
/*! Projects from world coordinates to camera coordinates
- * Returns the point's coordinates expressed in the camera's
+ * Returns the point's coordinates expressed in the camera's
* coordinates system.
* p
* point's coordinates expressed in world coordinates system
@@ -221,8 +221,8 @@ void fromRetinaToImage(const Vec3r& p, Vec3r& q, const int viewport[4]);
void fromImageToRetina(const Vec3r& p, Vec3r& q, const int viewport[4]);
/*! computes the coordinates of q in the camera coordinates system,
- * using the known z coordinates of the 3D point.
- * That means that this method does not inverse any matrices,
+ * using the known z coordinates of the 3D point.
+ * That means that this method does not inverse any matrices,
* it only computes X and Y from x,y and Z)
* p
* point's coordinates expressed in retina system
@@ -235,7 +235,7 @@ void fromImageToRetina(const Vec3r& p, Vec3r& q, const int viewport[4]);
void fromRetinaToCamera(const Vec3r& p, Vec3r& q, real z, const real projection_matrix[4][4]);
/*! Projects from camera coordinates to world coordinates
- * Returns the point's coordinates expressed in the world's
+ * Returns the point's coordinates expressed in the world's
* coordinates system.
* p
* point's coordinates expressed in the camera coordinates system
diff --git a/source/blender/freestyle/intern/geometry/normal_cycle.cpp b/source/blender/freestyle/intern/geometry/normal_cycle.cpp
index 951614c8f22..93d4c006997 100644
--- a/source/blender/freestyle/intern/geometry/normal_cycle.cpp
+++ b/source/blender/freestyle/intern/geometry/normal_cycle.cpp
@@ -21,9 +21,9 @@
* Contact: Bruno Levy
* levy@loria.fr
* ISA Project
- * LORIA, INRIA Lorraine,
+ * LORIA, INRIA Lorraine,
* Campus Scientifique, BP 239
- * 54506 VANDOEUVRE LES NANCY CEDEX
+ * 54506 VANDOEUVRE LES NANCY CEDEX
* FRANCE
*
* Contributor(s): none yet.
diff --git a/source/blender/freestyle/intern/geometry/normal_cycle.h b/source/blender/freestyle/intern/geometry/normal_cycle.h
index 8d06865e31b..7ae6762b394 100644
--- a/source/blender/freestyle/intern/geometry/normal_cycle.h
+++ b/source/blender/freestyle/intern/geometry/normal_cycle.h
@@ -21,9 +21,9 @@
* Contact: Bruno Levy
* levy@loria.fr
* ISA Project
- * LORIA, INRIA Lorraine,
+ * LORIA, INRIA Lorraine,
* Campus Scientifique, BP 239
- * 54506 VANDOEUVRE LES NANCY CEDEX
+ * 54506 VANDOEUVRE LES NANCY CEDEX
* FRANCE
*
* Contributor(s): none yet.
diff --git a/source/blender/freestyle/intern/stroke/CurveIterators.h b/source/blender/freestyle/intern/stroke/CurveIterators.h
index ff7b2d04385..d7a79d6e788 100644
--- a/source/blender/freestyle/intern/stroke/CurveIterators.h
+++ b/source/blender/freestyle/intern/stroke/CurveIterators.h
@@ -36,7 +36,7 @@ namespace Freestyle {
namespace CurveInternal {
/*! iterator on a curve. Allows an iterating outside
- * initial vertices. A CurvePoint is instanciated an returned
+ * initial vertices. A CurvePoint is instanciated an returned
* when the iterator is dereferenced.
*/
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index 95492016f25..0805cc25d04 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -238,7 +238,7 @@ GPUNodeLink *GPU_uniformbuffer_link_out(
void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link);
GPUBuiltin GPU_get_material_builtins(GPUMaterial *material);
-void GPU_material_sss_profile_create(GPUMaterial *material, float *radii, short *falloff_type, float *sharpness);
+void GPU_material_sss_profile_create(GPUMaterial *material, float radii[3], short *falloff_type, float *sharpness);
struct GPUUniformBuffer *GPU_material_sss_profile_get(
GPUMaterial *material, int sample_ct, struct GPUTexture **tex_profile);
@@ -246,22 +246,26 @@ struct GPUUniformBuffer *GPU_material_sss_profile_get(
GPUMaterial *GPU_material_from_nodetree_find(
struct ListBase *gpumaterials, const void *engine_type, int options);
GPUMaterial *GPU_material_from_nodetree(
- struct Scene *scene, struct bNodeTree *ntree, struct ListBase *gpumaterials, const void *engine_type, int options);
-void GPU_material_generate_pass(
- GPUMaterial *mat, const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines);
+ struct Scene *scene, struct bNodeTree *ntree, struct ListBase *gpumaterials, const void *engine_type, int options,
+ const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines);
+void GPU_material_compile(GPUMaterial *mat);
void GPU_material_free(struct ListBase *gpumaterial);
void GPU_materials_free(void);
+void GPU_material_orphans_init(void);
+void GPU_material_orphans_exit(void);
+/* This has to be called from a thread with an ogl context bound. */
+void GPU_material_orphans_delete(void);
+
struct Scene *GPU_material_scene(GPUMaterial *material);
GPUMatType GPU_Material_get_type(GPUMaterial *material);
struct GPUPass *GPU_material_get_pass(GPUMaterial *material);
struct ListBase *GPU_material_get_inputs(GPUMaterial *material);
GPUMaterialStatus GPU_material_status(GPUMaterial *mat);
-struct GPUUniformBuffer *GPU_material_get_uniform_buffer(GPUMaterial *material);
-void GPU_material_create_uniform_buffer(GPUMaterial *material, struct ListBase *inputs);
-void GPU_material_uniform_buffer_tag_dirty(struct ListBase *gpumaterials);
+struct GPUUniformBuffer *GPU_material_uniform_buffer_get(GPUMaterial *material);
+void GPU_material_uniform_buffer_create(GPUMaterial *material, ListBase *inputs);
void GPU_material_vertex_attributes(GPUMaterial *material,
struct GPUVertexAttribs *attrib);
@@ -270,6 +274,7 @@ bool GPU_material_do_color_management(GPUMaterial *mat);
bool GPU_material_use_domain_surface(GPUMaterial *mat);
bool GPU_material_use_domain_volume(GPUMaterial *mat);
+void GPU_pass_cache_init(void);
void GPU_pass_cache_garbage_collect(void);
void GPU_pass_cache_free(void);
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index cc66b5dbf9b..09b351a544a 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -40,7 +40,7 @@ struct Image;
struct ImageUser;
struct PreviewImage;
struct Gwn_VertBuf;
-
+
struct GPUFrameBuffer;
typedef struct GPUTexture GPUTexture;
@@ -156,7 +156,10 @@ GPUTexture *GPU_texture_create_3D(
int w, int h, int d, GPUTextureFormat data_type, const float *pixels, char err_out[256]);
GPUTexture *GPU_texture_create_cube(
int w, GPUTextureFormat data_type, const float *pixels, char err_out[256]);
-GPUTexture *GPU_texture_create_from_vertbuf(struct Gwn_VertBuf *vert);
+GPUTexture *GPU_texture_create_from_vertbuf(
+ struct Gwn_VertBuf *vert);
+GPUTexture *GPU_texture_create_buffer(
+ GPUTextureFormat data_type, const uint buffer);
GPUTexture *GPU_texture_from_blender(
struct Image *ima, struct ImageUser *iuser, int textarget, bool is_data, double time, int mipmap);
@@ -170,6 +173,11 @@ void GPU_invalid_tex_free(void);
void GPU_texture_free(GPUTexture *tex);
+void GPU_texture_orphans_init(void);
+void GPU_texture_orphans_exit(void);
+/* This has to be called from a thread with an ogl context bound. */
+void GPU_texture_orphans_delete(void);
+
void GPU_texture_ref(GPUTexture *tex);
void GPU_texture_bind(GPUTexture *tex, int number);
void GPU_texture_unbind(GPUTexture *tex);
diff --git a/source/blender/gpu/GPU_uniformbuffer.h b/source/blender/gpu/GPU_uniformbuffer.h
index c2480f8ba03..2f422fa1a92 100644
--- a/source/blender/gpu/GPU_uniformbuffer.h
+++ b/source/blender/gpu/GPU_uniformbuffer.h
@@ -35,7 +35,6 @@
struct ListBase;
typedef struct GPUUniformBuffer GPUUniformBuffer;
-typedef struct GPUUniformBufferDynamicItem GPUUniformBufferDynamicItem;
GPUUniformBuffer *GPU_uniformbuffer_create(int size, const void *data, char err_out[256]);
GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(struct ListBase *inputs, char err_out[256]);
@@ -52,7 +51,6 @@ int GPU_uniformbuffer_bindpoint(GPUUniformBuffer *ubo);
bool GPU_uniformbuffer_is_empty(GPUUniformBuffer *ubo);
bool GPU_uniformbuffer_is_dirty(GPUUniformBuffer *ubo);
-void GPU_uniformbuffer_tag_dirty(GPUUniformBuffer *ubo);
#define GPU_UBO_BLOCK_NAME "nodeTree"
diff --git a/source/blender/gpu/intern/gpu_basic_shader.c b/source/blender/gpu/intern/gpu_basic_shader.c
index 620a06ae606..b720bed2d0c 100644
--- a/source/blender/gpu/intern/gpu_basic_shader.c
+++ b/source/blender/gpu/intern/gpu_basic_shader.c
@@ -169,7 +169,7 @@ void GPU_basic_shaders_init(void)
void GPU_basic_shaders_exit(void)
{
int i;
-
+
for (i = 0; i < GPU_SHADER_OPTION_COMBINATIONS; i++)
if (GPU_MATERIAL_STATE.cached_shaders[i])
GPU_shader_free(GPU_MATERIAL_STATE.cached_shaders[i]);
@@ -238,7 +238,7 @@ static GPUShader *gpu_basic_shader(int options)
geom_glsl,
NULL,
defines);
-
+
if (shader) {
/* set texture map to first texture unit */
if (options & (GPU_SHADER_TEXTURE_2D | GPU_SHADER_TEXTURE_RECT)) {
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 9d2a0ceef4d..df8dbb03284 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -460,7 +460,7 @@ void GPU_pbvh_grid_buffers_update(
vbo_index += 1;
}
}
-
+
if (!buffers->smooth) {
for (j = 0; j < key->grid_size - 1; j++) {
for (k = 0; k < key->grid_size - 1; k++) {
@@ -865,7 +865,7 @@ void GPU_pbvh_bmesh_buffers_update(
fmask += BM_ELEM_CD_GET_FLOAT(v[i], cd_vert_mask_offset);
}
fmask /= 3.0f;
-
+
for (i = 0; i < 3; i++) {
gpu_bmesh_vert_to_buffer_copy__gwn(
v[i], buffers->vert_buf,
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 7a4af0521bb..0dd9d1f0908 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -40,10 +40,11 @@
#include "BLI_blenlib.h"
#include "BLI_hash_mm2a.h"
-#include "BLI_linklist.h"
+#include "BLI_link_utils.h"
#include "BLI_utildefines.h"
#include "BLI_dynstr.h"
#include "BLI_ghash.h"
+#include "BLI_threads.h"
#include "PIL_time.h"
@@ -75,39 +76,54 @@ static char *glsl_material_library = NULL;
* same for 2 different Materials. Unused GPUPasses are free by Garbage collection.
**/
-static LinkNode *pass_cache = NULL; /* GPUPass */
+/* Only use one linklist that contains the GPUPasses grouped by hash. */
+static GPUPass *pass_cache = NULL;
+static SpinLock pass_cache_spin;
-static uint32_t gpu_pass_hash(const char *vert, const char *geom, const char *frag, const char *defs)
+static uint32_t gpu_pass_hash(const char *frag_gen, const char *defs)
{
BLI_HashMurmur2A hm2a;
BLI_hash_mm2a_init(&hm2a, 0);
- BLI_hash_mm2a_add(&hm2a, (unsigned char *)frag, strlen(frag));
- BLI_hash_mm2a_add(&hm2a, (unsigned char *)vert, strlen(vert));
+ BLI_hash_mm2a_add(&hm2a, (unsigned char *)frag_gen, strlen(frag_gen));
if (defs)
BLI_hash_mm2a_add(&hm2a, (unsigned char *)defs, strlen(defs));
- if (geom)
- BLI_hash_mm2a_add(&hm2a, (unsigned char *)geom, strlen(geom));
return BLI_hash_mm2a_end(&hm2a);
}
-/* Search by hash then by exact string match. */
-static GPUPass *gpu_pass_cache_lookup(
- const char *vert, const char *geom, const char *frag, const char *defs, uint32_t hash)
+/* Search by hash only. Return first pass with the same hash.
+ * There is hash collision if (pass->next && pass->next->hash == hash) */
+static GPUPass *gpu_pass_cache_lookup(uint32_t hash)
{
- for (LinkNode *ln = pass_cache; ln; ln = ln->next) {
- GPUPass *pass = (GPUPass *)ln->link;
+ BLI_spin_lock(&pass_cache_spin);
+ /* Could be optimized with a Lookup table. */
+ for (GPUPass *pass = pass_cache; pass; pass = pass->next) {
if (pass->hash == hash) {
- /* Note: Could be made faster if that becomes a real bottleneck. */
- if ((defs != NULL) && (strcmp(pass->defines, defs) != 0)) { /* Pass */ }
- else if ((geom != NULL) && (strcmp(pass->geometrycode, geom) != 0)) { /* Pass */ }
- else if ((strcmp(pass->fragmentcode, frag) == 0) &&
- (strcmp(pass->vertexcode, vert) == 0))
- {
- return pass;
- }
+ BLI_spin_unlock(&pass_cache_spin);
+ return pass;
+ }
+ }
+ BLI_spin_unlock(&pass_cache_spin);
+ return NULL;
+}
+
+/* Check all possible passes with the same hash. */
+static GPUPass *gpu_pass_cache_resolve_collision(
+ GPUPass *pass, const char *vert, const char *geom, const char *frag, const char *defs, uint32_t hash)
+{
+ BLI_spin_lock(&pass_cache_spin);
+ /* Collision, need to strcmp the whole shader. */
+ for (; pass && (pass->hash == hash); pass = pass->next) {
+ if ((defs != NULL) && (strcmp(pass->defines, defs) != 0)) { /* Pass */ }
+ else if ((geom != NULL) && (strcmp(pass->geometrycode, geom) != 0)) { /* Pass */ }
+ else if ((strcmp(pass->fragmentcode, frag) == 0) &&
+ (strcmp(pass->vertexcode, vert) == 0))
+ {
+ BLI_spin_unlock(&pass_cache_spin);
+ return pass;
}
}
+ BLI_spin_unlock(&pass_cache_spin);
return NULL;
}
@@ -159,7 +175,7 @@ static int gpu_str_prefix(const char *str, const char *prefix)
str++;
prefix++;
}
-
+
return (*prefix == '\0');
}
@@ -278,7 +294,7 @@ static char *gpu_generate_function_prototyps(GHash *hash)
GPUFunction *function;
char *name, *prototypes;
int a;
-
+
/* automatically generate function prototypes to add to the top of the
* generated code, to avoid have to add the actual code & recompile all */
ghi = BLI_ghashIterator_new(hash);
@@ -656,7 +672,7 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, DynStr *ds,
/* Handle the UBO block separately. */
if ((material != NULL) && !BLI_listbase_is_empty(&ubo_inputs)) {
- GPU_material_create_uniform_buffer(material, &ubo_inputs);
+ GPU_material_uniform_buffer_create(material, &ubo_inputs);
/* Inputs are sorted */
BLI_dynstr_appendf(ds, "\nlayout (std140) uniform %s {\n", GPU_UBO_BLOCK_NAME);
@@ -716,7 +732,7 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final
for (node = nodes->first; node; node = node->next) {
BLI_dynstr_appendf(ds, "\t%s(", node->name);
-
+
for (input = node->inputs.first; input; input = input->next) {
if (input->source == GPU_SOURCE_TEX) {
BLI_dynstr_appendf(ds, "samp%d", input->texid);
@@ -895,6 +911,15 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
GPUInput *input;
char *code;
+ /* Hairs uv and col attribs are passed by bufferTextures. */
+ BLI_dynstr_append(ds,
+ "#ifdef HAIR_SHADER\n"
+ "#define DEFINE_ATTRIB(type, attr) uniform samplerBuffer attr\n"
+ "#else\n"
+ "#define DEFINE_ATTRIB(type, attr) in type attr\n"
+ "#endif\n"
+ );
+
for (node = nodes->first; node; node = node->next) {
for (input = node->inputs.first; input; input = input->next) {
if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
@@ -905,12 +930,12 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
BLI_dynstr_appendf(ds, "uniform vec3 OrcoTexCoFactors[2];\n");
}
else if (input->attribname[0] == '\0') {
- BLI_dynstr_appendf(ds, "in %s %s;\n", GPU_DATATYPE_STR[input->type], attrib_prefix_get(input->attribtype));
+ BLI_dynstr_appendf(ds, "DEFINE_ATTRIB(%s, %s);\n", GPU_DATATYPE_STR[input->type], attrib_prefix_get(input->attribtype));
BLI_dynstr_appendf(ds, "#define att%d %s\n", input->attribid, attrib_prefix_get(input->attribtype));
}
else {
unsigned int hash = BLI_ghashutil_strhash_p(input->attribname);
- BLI_dynstr_appendf(ds, "in %s %s%u;\n",
+ BLI_dynstr_appendf(ds, "DEFINE_ATTRIB(%s, %s%u);\n",
GPU_DATATYPE_STR[input->type], attrib_prefix_get(input->attribtype), hash);
BLI_dynstr_appendf(ds, "#define att%d %s%u\n",
input->attribid, attrib_prefix_get(input->attribtype), hash);
@@ -932,6 +957,7 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
BLI_dynstr_append(ds,
"#define ATTRIB\n"
"uniform mat3 NormalMatrix;\n"
+ "uniform mat4 ModelMatrixInverse;\n"
"vec3 srgb_to_linear_attrib(vec3 c) {\n"
"\tc = max(c, vec3(0.0));\n"
"\tvec3 c1 = c * (1.0 / 12.92);\n"
@@ -940,8 +966,41 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
"}\n\n"
);
+ /* Prototype because defined later. */
+ BLI_dynstr_append(ds,
+ "vec2 hair_get_customdata_vec2(const samplerBuffer);\n"
+ "vec3 hair_get_customdata_vec3(const samplerBuffer);\n"
+ "vec4 hair_get_customdata_vec4(const samplerBuffer);\n"
+ "vec3 hair_get_strand_pos(void);\n"
+ "\n"
+ );
+
BLI_dynstr_append(ds, "void pass_attrib(in vec3 position) {\n");
+ BLI_dynstr_append(ds, "#ifdef HAIR_SHADER\n");
+
+ for (node = nodes->first; node; node = node->next) {
+ for (input = node->inputs.first; input; input = input->next) {
+ if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
+ if (input->attribtype == CD_TANGENT) {
+ /* Not supported by hairs */
+ BLI_dynstr_appendf(ds, "\tvar%d%s = vec4(0.0);\n",
+ input->attribid, use_geom ? "g" : "");
+ }
+ else if (input->attribtype == CD_ORCO) {
+ BLI_dynstr_appendf(ds, "\tvar%d%s = OrcoTexCoFactors[0] + (ModelMatrixInverse * vec4(hair_get_strand_pos(), 1.0)).xyz * OrcoTexCoFactors[1];\n",
+ input->attribid, use_geom ? "g" : "");
+ }
+ else {
+ BLI_dynstr_appendf(ds, "\tvar%d%s = hair_get_customdata_%s(att%d);\n",
+ input->attribid, use_geom ? "g" : "", GPU_DATATYPE_STR[input->type], input->attribid);
+ }
+ }
+ }
+ }
+
+ BLI_dynstr_append(ds, "#else /* MESH_SHADER */\n");
+
for (node = nodes->first; node; node = node->next) {
for (input = node->inputs.first; input; input = input->next) {
if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
@@ -973,6 +1032,7 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
}
}
}
+ BLI_dynstr_append(ds, "#endif /* HAIR_SHADER */\n");
BLI_dynstr_append(ds, "}\n");
@@ -1055,12 +1115,12 @@ void GPU_code_generate_glsl_lib(void)
/* GPU pass binding/unbinding */
-GPUShader *GPU_pass_shader(GPUPass *pass)
+GPUShader *GPU_pass_shader_get(GPUPass *pass)
{
return pass->shader;
}
-static void gpu_nodes_extract_dynamic_inputs(GPUShader *shader, ListBase *inputs, ListBase *nodes)
+void GPU_nodes_extract_dynamic_inputs(GPUShader *shader, ListBase *inputs, ListBase *nodes)
{
GPUNode *node;
GPUInput *next, *input;
@@ -1102,8 +1162,12 @@ static void gpu_nodes_extract_dynamic_inputs(GPUShader *shader, ListBase *inputs
if (input->bindtex)
extract = 1;
}
- else if (input->dynamicvec)
+ else if (input->dynamictype == GPU_DYNAMIC_UBO) {
+ /* Don't extract UBOs */
+ }
+ else if (input->dynamicvec) {
extract = 1;
+ }
if (extract)
input->shaderloc = GPU_shader_get_uniform(shader, input->shadername);
@@ -1186,7 +1250,7 @@ void GPU_pass_unbind(GPUPass *pass, ListBase *inputs)
if (input->ima || input->prv)
input->tex = NULL;
}
-
+
GPU_shader_unbind();
}
@@ -1207,7 +1271,7 @@ static void gpu_node_link_free(GPUNodeLink *link)
if (link->users < 0)
fprintf(stderr, "GPU_node_link_free: negative refcount\n");
-
+
if (link->users == 0) {
if (link->output)
link->output->link = NULL;
@@ -1248,7 +1312,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const GPUType
return;
}
}
-
+
input = MEM_callocN(sizeof(GPUInput), "GPUInput");
input->node = node;
@@ -1639,10 +1703,10 @@ GPUNodeLink *GPU_cube_map(Image *ima, ImageUser *iuser, bool is_data)
GPUNodeLink *GPU_image_preview(PreviewImage *prv)
{
GPUNodeLink *link = GPU_node_link_create();
-
+
link->image = GPU_NODE_LINK_IMAGE_PREVIEW;
link->ptr1 = prv;
-
+
return link;
}
@@ -1826,7 +1890,7 @@ static void gpu_nodes_tag(GPUNodeLink *link)
node = link->output->node;
if (node->tag)
return;
-
+
node->tag = true;
for (input = node->inputs.first; input; input = input->next)
if (input->link)
@@ -1852,16 +1916,25 @@ void GPU_nodes_prune(ListBase *nodes, GPUNodeLink *outlink)
}
}
+static bool gpu_pass_is_valid(GPUPass *pass)
+{
+ /* Shader is not null if compilation is successful,
+ * refcount is positive if compilation as not yet been done. */
+ return (pass->shader != NULL || pass->refcount > 0);
+}
+
GPUPass *GPU_generate_pass_new(
GPUMaterial *material,
- GPUNodeLink *frag_outlink, struct GPUVertexAttribs *attribs,
- ListBase *nodes, ListBase *inputs,
- const char *vert_code, const char *geom_code,
- const char *frag_lib, const char *defines)
+ GPUNodeLink *frag_outlink,
+ struct GPUVertexAttribs *attribs,
+ ListBase *nodes,
+ const char *vert_code,
+ const char *geom_code,
+ const char *frag_lib,
+ const char *defines)
{
char *vertexcode, *geometrycode, *fragmentcode;
- GPUShader *shader;
- GPUPass *pass;
+ GPUPass *pass = NULL, *pass_hash = NULL;
/* prune unused nodes */
GPU_nodes_prune(nodes, frag_outlink);
@@ -1870,6 +1943,24 @@ GPUPass *GPU_generate_pass_new(
/* generate code */
char *fragmentgen = code_generate_fragment(material, nodes, frag_outlink->output);
+
+ /* Cache lookup: Reuse shaders already compiled */
+ uint32_t hash = gpu_pass_hash(fragmentgen, defines);
+ pass_hash = gpu_pass_cache_lookup(hash);
+
+ if (pass_hash && (pass_hash->next == NULL || pass_hash->next->hash != hash)) {
+ /* No collision, just return the pass. */
+ MEM_freeN(fragmentgen);
+ if (!gpu_pass_is_valid(pass_hash)) {
+ /* Shader has already been created but failed to compile. */
+ return NULL;
+ }
+ pass_hash->refcount += 1;
+ return pass_hash;
+ }
+
+ /* Either the shader is not compiled or there is a hash collision...
+ * continue generating the shader strings. */
char *tmp = BLI_strdupcat(frag_lib, glsl_material_library);
vertexcode = code_generate_vertex(nodes, vert_code, (geom_code != NULL));
@@ -1879,51 +1970,62 @@ GPUPass *GPU_generate_pass_new(
MEM_freeN(fragmentgen);
MEM_freeN(tmp);
- /* Cache lookup: Reuse shaders already compiled */
- uint32_t hash = gpu_pass_hash(vertexcode, geometrycode, fragmentcode, defines);
- pass = gpu_pass_cache_lookup(vertexcode, geometrycode, fragmentcode, defines, hash);
+ if (pass_hash) {
+ /* Cache lookup: Reuse shaders already compiled */
+ pass = gpu_pass_cache_resolve_collision(pass_hash, vertexcode, geometrycode, fragmentcode, defines, hash);
+ }
+
if (pass) {
/* Cache hit. Reuse the same GPUPass and GPUShader. */
- shader = pass->shader;
- pass->refcount += 1;
+ if (!gpu_pass_is_valid(pass)) {
+ /* Shader has already been created but failed to compile. */
+ return NULL;
+ }
MEM_SAFE_FREE(vertexcode);
MEM_SAFE_FREE(fragmentcode);
MEM_SAFE_FREE(geometrycode);
+
+ pass->refcount += 1;
}
else {
- /* Cache miss. (Re)compile the shader. */
- shader = GPU_shader_create(vertexcode,
- fragmentcode,
- geometrycode,
- NULL,
- defines);
-
/* We still create a pass even if shader compilation
* fails to avoid trying to compile again and again. */
pass = MEM_callocN(sizeof(GPUPass), "GPUPass");
- pass->shader = shader;
+ pass->shader = NULL;
pass->refcount = 1;
pass->hash = hash;
pass->vertexcode = vertexcode;
pass->fragmentcode = fragmentcode;
pass->geometrycode = geometrycode;
- pass->libcode = glsl_material_library;
pass->defines = (defines) ? BLI_strdup(defines) : NULL;
+ pass->compiled = false;
- BLI_linklist_prepend(&pass_cache, pass);
+ BLI_spin_lock(&pass_cache_spin);
+ if (pass_hash != NULL) {
+ /* Add after the first pass having the same hash. */
+ pass->next = pass_hash->next;
+ pass_hash->next = pass;
+ }
+ else {
+ /* No other pass have same hash, just prepend to the list. */
+ BLI_LINKS_PREPEND(pass_cache, pass);
+ }
+ BLI_spin_unlock(&pass_cache_spin);
}
- /* did compilation failed ? */
- if (!shader) {
- gpu_nodes_free(nodes);
- /* Pass will not be used. Don't increment refcount. */
- pass->refcount--;
- return NULL;
- }
- else {
- gpu_nodes_extract_dynamic_inputs(shader, inputs, nodes);
- return pass;
+ return pass;
+}
+
+void GPU_pass_compile(GPUPass *pass)
+{
+ if (!pass->compiled) {
+ pass->shader = GPU_shader_create(pass->vertexcode,
+ pass->fragmentcode,
+ pass->geometrycode,
+ NULL,
+ pass->defines);
+ pass->compiled = true;
}
}
@@ -1962,23 +2064,36 @@ void GPU_pass_cache_garbage_collect(void)
lasttime = ctime;
- LinkNode *next, **prev_ln = &pass_cache;
- for (LinkNode *ln = pass_cache; ln; ln = next) {
- GPUPass *pass = (GPUPass *)ln->link;
- next = ln->next;
+ BLI_spin_lock(&pass_cache_spin);
+ GPUPass *next, **prev_pass = &pass_cache;
+ for (GPUPass *pass = pass_cache; pass; pass = next) {
+ next = pass->next;
if (pass->refcount == 0) {
- gpu_pass_free(pass);
/* Remove from list */
- MEM_freeN(ln);
- *prev_ln = next;
+ *prev_pass = next;
+ gpu_pass_free(pass);
}
else {
- prev_ln = &ln->next;
+ prev_pass = &pass->next;
}
}
+ BLI_spin_unlock(&pass_cache_spin);
+}
+
+void GPU_pass_cache_init(void)
+{
+ BLI_spin_init(&pass_cache_spin);
}
void GPU_pass_cache_free(void)
{
- BLI_linklist_free(pass_cache, (LinkNodeFreeFP)gpu_pass_free);
+ BLI_spin_lock(&pass_cache_spin);
+ while (pass_cache) {
+ GPUPass *next = pass_cache->next;
+ gpu_pass_free(pass_cache);
+ pass_cache = next;
+ }
+ BLI_spin_unlock(&pass_cache_spin);
+
+ BLI_spin_end(&pass_cache_spin);
}
diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h
index 328da36c3de..04bee545a7e 100644
--- a/source/blender/gpu/intern/gpu_codegen.h
+++ b/source/blender/gpu/intern/gpu_codegen.h
@@ -157,33 +157,30 @@ typedef struct GPUInput {
} GPUInput;
struct GPUPass {
+ struct GPUPass *next;
+
struct GPUShader *shader;
char *fragmentcode;
char *geometrycode;
char *vertexcode;
char *defines;
- const char *libcode;
unsigned int refcount; /* Orphaned GPUPasses gets freed by the garbage collector. */
uint32_t hash; /* Identity hash generated from all GLSL code. */
+ bool compiled; /* Did we already tried to compile the attached GPUShader. */
};
-
typedef struct GPUPass GPUPass;
GPUPass *GPU_generate_pass_new(
GPUMaterial *material,
GPUNodeLink *frag_outlink, struct GPUVertexAttribs *attribs,
- ListBase *nodes, ListBase *inputs,
+ ListBase *nodes,
const char *vert_code, const char *geom_code,
const char *frag_lib, const char *defines);
-GPUPass *GPU_generate_pass(
- ListBase *nodes, ListBase *inputs, struct GPUNodeLink *outlink,
- struct GPUVertexAttribs *attribs, int *builtin,
- const GPUMatType type, const char *name,
- const bool use_opensubdiv);
-struct GPUShader *GPU_pass_shader(GPUPass *pass);
+struct GPUShader *GPU_pass_shader_get(GPUPass *pass);
+void GPU_nodes_extract_dynamic_inputs(struct GPUShader *shader, ListBase *inputs, ListBase *nodes);
void GPU_nodes_get_vertex_attributes(ListBase *nodes, struct GPUVertexAttribs *attribs);
void GPU_nodes_prune(ListBase *nodes, struct GPUNodeLink *outlink);
@@ -191,6 +188,7 @@ void GPU_pass_bind(GPUPass *pass, ListBase *inputs, double time, int mipmap);
void GPU_pass_update_uniforms(GPUPass *pass, ListBase *inputs);
void GPU_pass_unbind(GPUPass *pass, ListBase *inputs);
+void GPU_pass_compile(GPUPass *pass);
void GPU_pass_release(GPUPass *pass);
void GPU_pass_free_nodes(ListBase *nodes);
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 73e86c1b391..226711e230f 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -174,7 +174,7 @@ void gpu_extensions_init(void)
const char *renderer = (const char *)glGetString(GL_RENDERER);
const char *version = (const char *)glGetString(GL_VERSION);
- if (strstr(vendor, "ATI")) {
+ if (strstr(vendor, "ATI") || strstr(vendor, "AMD")) {
GG.device = GPU_DEVICE_ATI;
GG.driver = GPU_DRIVER_OFFICIAL;
}
@@ -191,6 +191,7 @@ void gpu_extensions_init(void)
GG.driver = GPU_DRIVER_OFFICIAL;
}
else if ((strstr(renderer, "Mesa DRI R")) ||
+ (strstr(renderer, "Radeon") && strstr(vendor, "X.Org")) ||
(strstr(renderer, "Gallium ") && strstr(renderer, " on ATI ")) ||
(strstr(renderer, "Gallium ") && strstr(renderer, " on AMD ")))
{
@@ -214,6 +215,7 @@ void gpu_extensions_init(void)
GG.driver = GPU_DRIVER_SOFTWARE;
}
else {
+ printf("Warning: Could not find a matching GPU name. Things may not behave as expected.\n");
GG.device = GPU_DEVICE_ANY;
GG.driver = GPU_DRIVER_ANY;
}
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index 75576c35f51..f86da2eb064 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -680,7 +680,7 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, bool dept
if (!GPU_framebuffer_check_valid(ofs->fb, err_out)) {
GPU_offscreen_free(ofs);
gpuPopAttrib();
- return NULL;
+ return NULL;
}
GPU_framebuffer_restore();
@@ -698,7 +698,7 @@ void GPU_offscreen_free(GPUOffScreen *ofs)
GPU_texture_free(ofs->color);
if (ofs->depth)
GPU_texture_free(ofs->depth);
-
+
MEM_freeN(ofs);
}
diff --git a/source/blender/gpu/intern/gpu_init_exit.c b/source/blender/gpu/intern/gpu_init_exit.c
index c2f14687ff5..92ad9d81b6c 100644
--- a/source/blender/gpu/intern/gpu_init_exit.c
+++ b/source/blender/gpu/intern/gpu_init_exit.c
@@ -34,6 +34,7 @@
#include "GPU_init_exit.h" /* interface */
#include "GPU_immediate.h"
#include "GPU_batch.h"
+#include "GPU_texture.h"
#include "BKE_global.h"
#include "intern/gpu_codegen.h"
@@ -56,6 +57,8 @@ void GPU_init(void)
gpu_extensions_init(); /* must come first */
+ GPU_texture_orphans_init();
+ GPU_material_orphans_init();
gpu_codegen_init();
if (G.debug & G_DEBUG_GPU)
@@ -80,6 +83,9 @@ void GPU_exit(void)
gpu_batch_exit();
+ GPU_texture_orphans_exit();
+ GPU_material_orphans_exit();
+
if (G.debug & G_DEBUG_GPU)
gpu_debug_exit();
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 769c60f8e61..302ddc62188 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -46,6 +46,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_rand.h"
+#include "BLI_threads.h"
#include "BKE_anim.h"
#include "BKE_colorband.h"
@@ -74,6 +75,9 @@
# include "BKE_DerivedMesh.h"
#endif
+static ListBase g_orphaned_mat = {NULL, NULL};
+static ThreadMutex g_orphan_lock;
+
/* Structs */
struct GPUMaterial {
@@ -87,7 +91,7 @@ struct GPUMaterial {
const void *engine_type; /* attached engine type */
int options; /* to identify shader variations (shadow, probe, world background...) */
-
+
/* for creating the material */
ListBase nodes;
GPUNodeLink *outlink;
@@ -127,10 +131,11 @@ struct GPUMaterial {
/* Eevee SSS */
GPUUniformBuffer *sss_profile; /* UBO containing SSS profile. */
GPUTexture *sss_tex_profile; /* Texture containing SSS profile. */
- float *sss_radii; /* UBO containing SSS profile. */
+ float sss_enabled;
+ float sss_radii[3];
int sss_samples;
- short int *sss_falloff;
- float *sss_sharpness;
+ short int sss_falloff;
+ float sss_sharpness;
bool sss_dirty;
};
@@ -142,36 +147,70 @@ enum {
/* Functions */
-void GPU_material_free(ListBase *gpumaterial)
+static void gpu_material_free_single(GPUMaterial *material)
{
- for (LinkData *link = gpumaterial->first; link; link = link->next) {
- GPUMaterial *material = link->data;
+ /* Cancel / wait any pending lazy compilation. */
+ DRW_deferred_shader_remove(material);
- /* Cancel / wait any pending lazy compilation. */
- DRW_deferred_shader_remove(material);
+ GPU_pass_free_nodes(&material->nodes);
+ GPU_inputs_free(&material->inputs);
- GPU_pass_free_nodes(&material->nodes);
- GPU_inputs_free(&material->inputs);
+ if (material->pass)
+ GPU_pass_release(material->pass);
- if (material->pass)
- GPU_pass_release(material->pass);
+ if (material->ubo != NULL) {
+ GPU_uniformbuffer_free(material->ubo);
+ }
- if (material->ubo != NULL) {
- GPU_uniformbuffer_free(material->ubo);
- }
+ if (material->sss_tex_profile != NULL) {
+ GPU_texture_free(material->sss_tex_profile);
+ }
- if (material->sss_tex_profile != NULL) {
- GPU_texture_free(material->sss_tex_profile);
- }
+ if (material->sss_profile != NULL) {
+ GPU_uniformbuffer_free(material->sss_profile);
+ }
+}
- if (material->sss_profile != NULL) {
- GPU_uniformbuffer_free(material->sss_profile);
+void GPU_material_free(ListBase *gpumaterial)
+{
+ for (LinkData *link = gpumaterial->first; link; link = link->next) {
+ GPUMaterial *material = link->data;
+
+ /* TODO(fclem): Check if the thread has an ogl context. */
+ if (BLI_thread_is_main()) {
+ gpu_material_free_single(material);
+ MEM_freeN(material);
+ }
+ else {
+ BLI_mutex_lock(&g_orphan_lock);
+ BLI_addtail(&g_orphaned_mat, BLI_genericNodeN(material));
+ BLI_mutex_unlock(&g_orphan_lock);
}
+ }
+ BLI_freelistN(gpumaterial);
+}
- MEM_freeN(material);
+void GPU_material_orphans_init(void)
+{
+ BLI_mutex_init(&g_orphan_lock);
+}
+
+void GPU_material_orphans_delete(void)
+{
+ BLI_mutex_lock(&g_orphan_lock);
+ LinkData *link;
+ while ((link = BLI_pophead(&g_orphaned_mat))) {
+ gpu_material_free_single((GPUMaterial *)link->data);
+ MEM_freeN(link->data);
+ MEM_freeN(link);
}
+ BLI_mutex_unlock(&g_orphan_lock);
+}
- BLI_freelistN(gpumaterial);
+void GPU_material_orphans_exit(void)
+{
+ GPU_material_orphans_delete();
+ BLI_mutex_end(&g_orphan_lock);
}
GPUBuiltin GPU_get_material_builtins(GPUMaterial *material)
@@ -199,7 +238,7 @@ ListBase *GPU_material_get_inputs(GPUMaterial *material)
return &material->inputs;
}
-GPUUniformBuffer *GPU_material_get_uniform_buffer(GPUMaterial *material)
+GPUUniformBuffer *GPU_material_uniform_buffer_get(GPUMaterial *material)
{
return material->ubo;
}
@@ -208,24 +247,11 @@ GPUUniformBuffer *GPU_material_get_uniform_buffer(GPUMaterial *material)
* Create dynamic UBO from parameters
* \param ListBase of BLI_genericNodeN(GPUInput)
*/
-void GPU_material_create_uniform_buffer(GPUMaterial *material, ListBase *inputs)
+void GPU_material_uniform_buffer_create(GPUMaterial *material, ListBase *inputs)
{
material->ubo = GPU_uniformbuffer_dynamic_create(inputs, NULL);
}
-void GPU_material_uniform_buffer_tag_dirty(ListBase *gpumaterials)
-{
- for (LinkData *link = gpumaterials->first; link; link = link->next) {
- GPUMaterial *material = link->data;
- if (material->ubo != NULL) {
- GPU_uniformbuffer_tag_dirty(material->ubo);
- }
- if (material->sss_profile != NULL) {
- material->sss_dirty = true;
- }
- }
-}
-
/* Eevee Subsurface scattering. */
/* Based on Separable SSS. by Jorge Jimenez and Diego Gutierrez */
@@ -328,7 +354,7 @@ static float eval_integral(float x0, float x1, short falloff_type, float sharpne
#undef INTEGRAL_RESOLUTION
static void compute_sss_kernel(
- GPUSssKernelData *kd, float *radii, int sample_ct, int falloff_type, float sharpness)
+ GPUSssKernelData *kd, float radii[3], int sample_ct, int falloff_type, float sharpness)
{
float rad[3];
/* Minimum radius */
@@ -483,12 +509,13 @@ static void compute_sss_translucence_kernel(
}
#undef INTEGRAL_RESOLUTION
-void GPU_material_sss_profile_create(GPUMaterial *material, float *radii, short *falloff_type, float *sharpness)
+void GPU_material_sss_profile_create(GPUMaterial *material, float radii[3], short *falloff_type, float *sharpness)
{
- material->sss_radii = radii;
- material->sss_falloff = falloff_type;
- material->sss_sharpness = sharpness;
+ copy_v3_v3(material->sss_radii, radii);
+ material->sss_falloff = (falloff_type) ? *falloff_type : 0.0;
+ material->sss_sharpness = (sharpness) ? *sharpness : 0.0;
material->sss_dirty = true;
+ material->sss_enabled = true;
/* Update / Create UBO */
if (material->sss_profile == NULL) {
@@ -498,25 +525,25 @@ void GPU_material_sss_profile_create(GPUMaterial *material, float *radii, short
struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int sample_ct, GPUTexture **tex_profile)
{
- if (material->sss_radii == NULL)
+ if (!material->sss_enabled)
return NULL;
if (material->sss_dirty || (material->sss_samples != sample_ct)) {
GPUSssKernelData kd;
- float sharpness = (material->sss_sharpness != NULL) ? *material->sss_sharpness : 0.0f;
+ float sharpness = material->sss_sharpness;
/* XXX Black magic but it seems to fit. Maybe because we integrate -1..1 */
sharpness *= 0.5f;
- compute_sss_kernel(&kd, material->sss_radii, sample_ct, *material->sss_falloff, sharpness);
+ compute_sss_kernel(&kd, material->sss_radii, sample_ct, material->sss_falloff, sharpness);
/* Update / Create UBO */
GPU_uniformbuffer_update(material->sss_profile, &kd);
/* Update / Create Tex */
float *translucence_profile;
- compute_sss_translucence_kernel(&kd, 64, *material->sss_falloff, sharpness, &translucence_profile);
+ compute_sss_translucence_kernel(&kd, 64, material->sss_falloff, sharpness, &translucence_profile);
if (material->sss_tex_profile != NULL) {
GPU_texture_free(material->sss_tex_profile);
@@ -602,7 +629,8 @@ GPUMaterial *GPU_material_from_nodetree_find(
* so only do this when they are needed.
*/
GPUMaterial *GPU_material_from_nodetree(
- Scene *scene, struct bNodeTree *ntree, ListBase *gpumaterials, const void *engine_type, int options)
+ Scene *scene, struct bNodeTree *ntree, ListBase *gpumaterials, const void *engine_type, int options,
+ const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines)
{
LinkData *link;
bool has_volume_output, has_surface_output;
@@ -631,11 +659,38 @@ GPUMaterial *GPU_material_from_nodetree(
* generated VBOs are ready to accept the future shader. */
GPU_nodes_prune(&mat->nodes, mat->outlink);
GPU_nodes_get_vertex_attributes(&mat->nodes, &mat->attribs);
- mat->status = GPU_MAT_QUEUED;
+ /* Create source code and search pass cache for an already compiled version. */
+ mat->pass = GPU_generate_pass_new(mat,
+ mat->outlink,
+ &mat->attribs,
+ &mat->nodes,
+ vert_code,
+ geom_code,
+ frag_lib,
+ defines);
+
+ if (mat->pass == NULL) {
+ /* We had a cache hit and the shader has already failed to compile. */
+ mat->status = GPU_MAT_FAILED;
+ }
+ else {
+ GPUShader *sh = GPU_pass_shader_get(mat->pass);
+ if (sh != NULL) {
+ /* We had a cache hit and the shader is already compiled. */
+ mat->status = GPU_MAT_SUCCESS;
+ GPU_nodes_extract_dynamic_inputs(sh, &mat->inputs, &mat->nodes);
+ }
+ else {
+ mat->status = GPU_MAT_QUEUED;
+ }
+ }
+ }
+ else {
+ mat->status = GPU_MAT_FAILED;
}
/* note that even if building the shader fails in some way, we still keep
- * it to avoid trying to compile again and again, and simple do not use
+ * it to avoid trying to compile again and again, and simply do not use
* the actual shader on drawing */
link = MEM_callocN(sizeof(LinkData), "GPUMaterialLink");
@@ -645,17 +700,26 @@ GPUMaterial *GPU_material_from_nodetree(
return mat;
}
-void GPU_material_generate_pass(
- GPUMaterial *mat, const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines)
+void GPU_material_compile(GPUMaterial *mat)
{
- BLI_assert(mat->pass == NULL); /* Only run once! */
- if (mat->outlink) {
- mat->pass = GPU_generate_pass_new(
- mat, mat->outlink, &mat->attribs, &mat->nodes, &mat->inputs, vert_code, geom_code, frag_lib, defines);
- mat->status = (mat->pass) ? GPU_MAT_SUCCESS : GPU_MAT_FAILED;
+ /* Only run once! */
+ BLI_assert(mat->status == GPU_MAT_QUEUED);
+ BLI_assert(mat->pass);
+
+ /* NOTE: The shader may have already been compiled here since we are
+ * sharing GPUShader across GPUMaterials. In this case it's a no-op. */
+ GPU_pass_compile(mat->pass);
+ GPUShader *sh = GPU_pass_shader_get(mat->pass);
+
+ if (sh != NULL) {
+ mat->status = GPU_MAT_SUCCESS;
+ GPU_nodes_extract_dynamic_inputs(sh, &mat->inputs, &mat->nodes);
}
else {
mat->status = GPU_MAT_FAILED;
+ GPU_pass_free_nodes(&mat->nodes);
+ GPU_pass_release(mat->pass);
+ mat->pass = NULL;
}
}
@@ -670,6 +734,6 @@ void GPU_materials_free(void)
for (wo = G.main->world.first; wo; wo = wo->id.next)
GPU_material_free(&wo->gpumaterial);
-
+
GPU_material_free(&defmaterial.gpumaterial);
}
diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c
index 4aef80934ad..fecac55087f 100644
--- a/source/blender/gpu/intern/gpu_select_pick.c
+++ b/source/blender/gpu/intern/gpu_select_pick.c
@@ -36,7 +36,7 @@
#include "GPU_select.h"
#include "GPU_extensions.h"
#include "GPU_glew.h"
-
+
#include "MEM_guardedalloc.h"
#include "BLI_rect.h"
@@ -337,7 +337,7 @@ void gpu_select_pick_begin(
}
float viewport[4];
- glGetFloatv(GL_SCISSOR_BOX, viewport);
+ glGetFloatv(GL_VIEWPORT, viewport);
ps->src.clip_rect = *input;
ps->src.rect_len = rect_len;
diff --git a/source/blender/gpu/intern/gpu_select_sample_query.c b/source/blender/gpu/intern/gpu_select_sample_query.c
index 12390e5cdb0..4520025ea7f 100644
--- a/source/blender/gpu/intern/gpu_select_sample_query.c
+++ b/source/blender/gpu/intern/gpu_select_sample_query.c
@@ -37,7 +37,7 @@
#include "GPU_select.h"
#include "GPU_extensions.h"
#include "GPU_glew.h"
-
+
#include "MEM_guardedalloc.h"
#include "BLI_rect.h"
@@ -103,10 +103,10 @@ void gpu_select_query_begin(
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
/* In order to save some fill rate we minimize the viewport using rect.
- * We need to get the region of the scissor so that our geometry doesn't
+ * We need to get the region of the viewport so that our geometry doesn't
* get rejected before the depth test. Should probably cull rect against
- * scissor for viewport but this is a rare case I think */
- glGetFloatv(GL_SCISSOR_BOX, viewport);
+ * the viewport but this is a rare case I think */
+ glGetFloatv(GL_VIEWPORT, viewport);
glViewport(viewport[0], viewport[1], BLI_rcti_size_x(input), BLI_rcti_size_y(input));
/* occlusion queries operates on fragments that pass tests and since we are interested on all
@@ -116,7 +116,6 @@ void gpu_select_query_begin(
glDepthMask(GL_FALSE);
}
else if (mode == GPU_SELECT_NEAREST_FIRST_PASS) {
- glDisable(GL_SCISSOR_TEST); /* allows fast clear */
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index 2068c5a6a75..8c978be81c1 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -189,11 +189,11 @@ static void shader_print_errors(const char *task, const char *log, const char **
c = pos + 1;
line++;
}
-
+
fprintf(stderr, "%s", c);
}
}
-
+
fprintf(stderr, "%s\n", log);
}
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index 9bd4bbd89e9..aac75014b3e 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -32,6 +32,8 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_math_base.h"
+#include "BLI_listbase.h"
+#include "BLI_threads.h"
#include "BKE_global.h"
@@ -49,6 +51,9 @@ static struct GPUTextureGlobal {
GPUTexture *invalid_tex_3D;
} GG = {NULL, NULL, NULL};
+static ListBase g_orphaned_tex = {NULL, NULL};
+static ThreadMutex g_orphan_lock;
+
/* Maximum number of FBOs a texture can be attached to. */
#define GPU_TEX_MAX_FBO_ATTACHED 8
@@ -187,6 +192,7 @@ static GLenum gpu_texture_get_format(
break;
case GPU_RG32F:
case GPU_RGBA16F:
+ case GPU_RGBA16:
*bytesize = 16;
break;
case GPU_RGB16F:
@@ -202,6 +208,7 @@ static GLenum gpu_texture_get_format(
case GPU_R11F_G11F_B10F:
case GPU_R32F:
case GPU_R32UI:
+ case GPU_R32I:
*bytesize = 4;
break;
case GPU_DEPTH_COMPONENT24:
@@ -227,6 +234,7 @@ static GLenum gpu_texture_get_format(
/* Formats texture & renderbuffer */
case GPU_RGBA32F: return GL_RGBA32F;
case GPU_RGBA16F: return GL_RGBA16F;
+ case GPU_RGBA16: return GL_RGBA16;
case GPU_RG32F: return GL_RG32F;
case GPU_RGB16F: return GL_RGB16F;
case GPU_RG16F: return GL_RG16F;
@@ -235,6 +243,7 @@ static GLenum gpu_texture_get_format(
case GPU_RGBA8: return GL_RGBA8;
case GPU_R32F: return GL_R32F;
case GPU_R32UI: return GL_R32UI;
+ case GPU_R32I: return GL_R32I;
case GPU_R16F: return GL_R16F;
case GPU_R16I: return GL_R16I;
case GPU_R16UI: return GL_R16UI;
@@ -263,6 +272,7 @@ static int gpu_texture_get_component_count(GPUTextureFormat format)
switch (format) {
case GPU_RGBA8:
case GPU_RGBA16F:
+ case GPU_RGBA16:
case GPU_RGBA32F:
return 4;
case GPU_RGB16F:
@@ -613,7 +623,7 @@ static GPUTexture *GPU_texture_cube_create(
}
/* Special buffer textures. data_type must be compatible with the buffer content. */
-static GPUTexture *GPU_texture_create_buffer(GPUTextureFormat data_type, const GLuint buffer)
+GPUTexture *GPU_texture_create_buffer(GPUTextureFormat data_type, const GLuint buffer)
{
GPUTexture *tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture");
tex->number = -1;
@@ -726,10 +736,10 @@ GPUTexture *GPU_texture_from_preview(PreviewImage *prv, int mipmap)
{
GPUTexture *tex = prv->gputexture[0];
GLuint bindcode = 0;
-
+
if (tex)
bindcode = tex->bindcode;
-
+
/* this binds a texture, so that's why we restore it to 0 */
if (bindcode == 0) {
GPU_create_gl_tex(&bindcode, prv->rect[0], NULL, prv->w[0], prv->h[0], GL_TEXTURE_2D, mipmap, 0, NULL);
@@ -748,9 +758,9 @@ GPUTexture *GPU_texture_from_preview(PreviewImage *prv, int mipmap)
tex->target_base = GL_TEXTURE_2D;
tex->format = -1;
tex->components = -1;
-
+
prv->gputexture[0] = tex;
-
+
if (!glIsTexture(tex->bindcode)) {
GPU_print_error_debug("Blender Texture Not Loaded");
}
@@ -760,13 +770,13 @@ GPUTexture *GPU_texture_from_preview(PreviewImage *prv, int mipmap)
glBindTexture(GL_TEXTURE_2D, tex->bindcode);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
-
+
tex->w = w;
tex->h = h;
}
-
+
glBindTexture(GL_TEXTURE_2D, 0);
-
+
return tex;
}
@@ -1078,13 +1088,23 @@ void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat)
glTexParameteri(tex->target_base, GL_TEXTURE_WRAP_R, repeat);
}
+static void gpu_texture_delete(GPUTexture *tex)
+{
+ if (tex->bindcode && !tex->fromblender)
+ glDeleteTextures(1, &tex->bindcode);
+
+ gpu_texture_memory_footprint_remove(tex);
+
+ MEM_freeN(tex);
+}
+
void GPU_texture_free(GPUTexture *tex)
{
tex->refcount--;
if (tex->refcount < 0)
fprintf(stderr, "GPUTexture: negative refcount\n");
-
+
if (tex->refcount == 0) {
for (int i = 0; i < GPU_TEX_MAX_FBO_ATTACHED; ++i) {
if (tex->fb[i] != NULL) {
@@ -1092,13 +1112,38 @@ void GPU_texture_free(GPUTexture *tex)
}
}
- if (tex->bindcode && !tex->fromblender)
- glDeleteTextures(1, &tex->bindcode);
+ /* TODO(fclem): Check if the thread has an ogl context. */
+ if (BLI_thread_is_main()) {
+ gpu_texture_delete(tex);
+ }
+ else {
+ BLI_mutex_lock(&g_orphan_lock);
+ BLI_addtail(&g_orphaned_tex, BLI_genericNodeN(tex));
+ BLI_mutex_unlock(&g_orphan_lock);
+ }
+ }
+}
- gpu_texture_memory_footprint_remove(tex);
+void GPU_texture_orphans_init(void)
+{
+ BLI_mutex_init(&g_orphan_lock);
+}
- MEM_freeN(tex);
+void GPU_texture_orphans_delete(void)
+{
+ BLI_mutex_lock(&g_orphan_lock);
+ LinkData *link;
+ while ((link = BLI_pophead(&g_orphaned_tex))) {
+ gpu_texture_delete((GPUTexture *)link->data);
+ MEM_freeN(link);
}
+ BLI_mutex_unlock(&g_orphan_lock);
+}
+
+void GPU_texture_orphans_exit(void)
+{
+ GPU_texture_orphans_delete();
+ BLI_mutex_end(&g_orphan_lock);
}
void GPU_texture_ref(GPUTexture *tex)
diff --git a/source/blender/gpu/intern/gpu_uniformbuffer.c b/source/blender/gpu/intern/gpu_uniformbuffer.c
index afd43600d9b..1e39b2ea5b7 100644
--- a/source/blender/gpu/intern/gpu_uniformbuffer.c
+++ b/source/blender/gpu/intern/gpu_uniformbuffer.c
@@ -62,26 +62,14 @@ struct GPUUniformBuffer {
typedef struct GPUUniformBufferDynamic {
GPUUniformBuffer buffer;
- ListBase items; /* GPUUniformBufferDynamicItem */
- void *data;
+ void *data; /* Continuous memory block to copy to GPU. */
char flag;
} GPUUniformBufferDynamic;
-struct GPUUniformBufferDynamicItem {
- struct GPUUniformBufferDynamicItem *next, *prev;
- GPUType gputype;
- float *data;
- int size;
-};
-
-
/* Prototypes */
static GPUType get_padded_gpu_type(struct LinkData *link);
static void gpu_uniformbuffer_inputs_sort(struct ListBase *inputs);
-static GPUUniformBufferDynamicItem *gpu_uniformbuffer_populate(
- GPUUniformBufferDynamic *ubo, const GPUType gputype, float *num);
-
/* Only support up to this type, if you want to extend it, make sure the
* padding logic is correct for the new types. */
#define MAX_UBO_GPU_TYPE GPU_VEC4
@@ -159,34 +147,47 @@ GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_ou
gpu_uniformbuffer_inputs_sort(inputs);
for (LinkData *link = inputs->first; link; link = link->next) {
- GPUInput *input = link->data;
- GPUType gputype = get_padded_gpu_type(link);
- gpu_uniformbuffer_populate(ubo, gputype, input->dynamicvec);
+ const GPUType gputype = get_padded_gpu_type(link);
+ ubo->buffer.size += gputype * sizeof(float);
}
+ /* Allocate the data. */
ubo->data = MEM_mallocN(ubo->buffer.size, __func__);
- /* Initialize buffer data. */
- GPU_uniformbuffer_dynamic_update(&ubo->buffer);
+ /* Now that we know the total ubo size we can start populating it. */
+ float *offset = ubo->data;
+ for (LinkData *link = inputs->first; link; link = link->next) {
+ GPUInput *input = link->data;
+ const GPUType gputype = get_padded_gpu_type(link);
+ memcpy(offset, input->dynamicvec, gputype * sizeof(float));
+ offset += gputype;
+ }
+
+ /* Note since we may create the UBOs in the CPU in a different thread than the main drawing one,
+ * we don't create the UBO in the GPU here. This will happen when we first bind the UBO.
+ */
+
return &ubo->buffer;
}
/**
- * Free the data, and clean the items list.
+ * Free the data
*/
-static void gpu_uniformbuffer_dynamic_reset(GPUUniformBufferDynamic *ubo)
+static void gpu_uniformbuffer_dynamic_free(GPUUniformBuffer *ubo_)
{
+ BLI_assert(ubo_->type == GPU_UBO_DYNAMIC);
+ GPUUniformBufferDynamic *ubo = (GPUUniformBufferDynamic *)ubo_;
+
ubo->buffer.size = 0;
if (ubo->data) {
MEM_freeN(ubo->data);
}
- BLI_freelistN(&ubo->items);
}
void GPU_uniformbuffer_free(GPUUniformBuffer *ubo)
{
if (ubo->type == GPU_UBO_DYNAMIC) {
- gpu_uniformbuffer_dynamic_reset((GPUUniformBufferDynamic *)ubo);
+ gpu_uniformbuffer_dynamic_free(ubo);
}
glDeleteBuffers(1, &ubo->bindcode);
@@ -215,12 +216,6 @@ void GPU_uniformbuffer_dynamic_update(GPUUniformBuffer *ubo_)
BLI_assert(ubo_->type == GPU_UBO_DYNAMIC);
GPUUniformBufferDynamic *ubo = (GPUUniformBufferDynamic *)ubo_;
- float *offset = ubo->data;
- for (GPUUniformBufferDynamicItem *item = ubo->items.first; item; item = item->next) {
- memcpy(offset, item->data, item->size);
- offset += item->gputype;
- }
-
if (ubo->flag & GPU_UBO_FLAG_INITIALIZED) {
gpu_uniformbuffer_update(ubo_, ubo->data);
}
@@ -316,27 +311,6 @@ static void gpu_uniformbuffer_inputs_sort(ListBase *inputs)
}
}
-/**
- * This may now happen from the main thread, so we can't update the UBO
- * We simply flag it as dirty
- */
-static GPUUniformBufferDynamicItem *gpu_uniformbuffer_populate(
- GPUUniformBufferDynamic *ubo, const GPUType gputype, float *num)
-{
- BLI_assert(gputype <= MAX_UBO_GPU_TYPE);
- GPUUniformBufferDynamicItem *item = MEM_callocN(sizeof(GPUUniformBufferDynamicItem), __func__);
-
- item->gputype = gputype;
- item->data = num;
- item->size = gputype * sizeof(float);
- ubo->buffer.size += item->size;
-
- ubo->flag |= GPU_UBO_FLAG_DIRTY;
- BLI_addtail(&ubo->items, item);
-
- return item;
-}
-
void GPU_uniformbuffer_bind(GPUUniformBuffer *ubo, int number)
{
if (number >= GPU_max_ubo_binds()) {
@@ -368,11 +342,4 @@ int GPU_uniformbuffer_bindpoint(GPUUniformBuffer *ubo)
return ubo->bindpoint;
}
-void GPU_uniformbuffer_tag_dirty(GPUUniformBuffer *ubo_)
-{
- BLI_assert(ubo_->type == GPU_UBO_DYNAMIC);
- GPUUniformBufferDynamic *ubo = (GPUUniformBufferDynamic *)ubo_;
- ubo->flag |= GPU_UBO_FLAG_DIRTY;
-}
-
#undef MAX_UBO_GPU_TYPE
diff --git a/source/blender/gpu/shaders/gpu_shader_basic_vert.glsl b/source/blender/gpu/shaders/gpu_shader_basic_vert.glsl
index dbf6c267f14..bc940222f85 100644
--- a/source/blender/gpu/shaders/gpu_shader_basic_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_basic_vert.glsl
@@ -58,8 +58,8 @@ void main()
#elif !defined(GPU_ATI)
// Setting gl_ClipVertex is necessary to get glClipPlane working on NVIDIA
// graphic cards, while on ATI it can cause a software fallback.
- gl_ClipVertex = co;
-#endif
+ gl_ClipVertex = co;
+#endif
#ifdef USE_COLOR
#ifdef DRAW_LINE
diff --git a/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_vert.glsl b/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_vert.glsl
index 1dd5bf42b25..86b338e528e 100644
--- a/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_vert.glsl
@@ -59,4 +59,4 @@ void main()
#else
vert_dof_final();
#endif
-} \ No newline at end of file
+}
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index a6bfb09141c..4c77dd038af 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -1,10 +1,13 @@
uniform mat4 ModelMatrix;
-uniform mat4 ModelMatrixInverse;
uniform mat4 ModelViewMatrix;
uniform mat4 ModelViewMatrixInverse;
uniform mat3 NormalMatrix;
+#ifndef ATTRIB
+uniform mat4 ModelMatrixInverse;
+#endif
+
/* Old glsl mode compat. */
#ifndef CLOSURE_DEFAULT
@@ -2476,6 +2479,23 @@ void node_bevel(float radius, vec3 N, out vec3 result)
result = N;
}
+void node_hair_info(out float is_strand, out float intercept, out float thickness, out vec3 tangent, out float random)
+{
+#ifdef HAIR_SHADER
+ is_strand = 1.0;
+ intercept = hairTime;
+ thickness = hairThickness;
+ tangent = normalize(hairTangent);
+ random = wang_hash_noise(uint(hairStrandID)); /* TODO: could be precomputed per strand instead. */
+#else
+ is_strand = 0.0;
+ intercept = 0.0;
+ thickness = 0.0;
+ tangent = vec3(1.0);
+ random = 0.0;
+#endif
+}
+
void node_displacement_object(float height, float midlevel, float scale, vec3 N, mat4 obmat, out vec3 result)
{
N = (vec4(N, 0.0) * obmat).xyz;
@@ -2538,7 +2558,23 @@ void node_output_world(Closure surface, Closure volume, out Closure result)
/* EEVEE output */
void world_normals_get(out vec3 N)
{
+#ifdef HAIR_SHADER
+ vec3 B = normalize(cross(worldNormal, hairTangent));
+ float cos_theta;
+ if (hairThicknessRes == 1) {
+ vec4 rand = texelFetch(utilTex, ivec3(ivec2(gl_FragCoord.xy) % LUT_SIZE, 2.0), 0);
+ /* Random cosine normal distribution on the hair surface. */
+ cos_theta = rand.x * 2.0 - 1.0;
+ }
+ else {
+ /* Shade as a cylinder. */
+ cos_theta = hairThickTime / hairThickness;
+ }
+ float sin_theta = sqrt(max(0.0, 1.0f - cos_theta*cos_theta));;
+ N = normalize(worldNormal * sin_theta + B * cos_theta);
+#else
N = gl_FrontFacing ? worldNormal : -worldNormal;
+#endif
}
void node_eevee_specular(
diff --git a/source/blender/gpu/shaders/gpu_shader_vertex.glsl b/source/blender/gpu/shaders/gpu_shader_vertex.glsl
index 2a6c137e195..e297c242044 100644
--- a/source/blender/gpu/shaders/gpu_shader_vertex.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_vertex.glsl
@@ -103,8 +103,8 @@ void main()
#elif !defined(GPU_ATI)
// Setting gl_ClipVertex is necessary to get glClipPlane working on NVIDIA
// graphic cards, while on ATI it can cause a software fallback.
- gl_ClipVertex = co;
-#endif
+ gl_ClipVertex = co;
+#endif
#ifdef USE_OPENSUBDIV
outpt.v.position = co;
diff --git a/source/blender/ikplugin/BIK_api.h b/source/blender/ikplugin/BIK_api.h
index 2a7a473db51..07a223b738e 100644
--- a/source/blender/ikplugin/BIK_api.h
+++ b/source/blender/ikplugin/BIK_api.h
@@ -21,7 +21,7 @@
* The Original Code is: all of this file.
*
* Original author: Benoit Bolsee
- * Contributor(s):
+ * Contributor(s):
*
* ***** END GPL LICENSE BLOCK *****
*/
diff --git a/source/blender/ikplugin/CMakeLists.txt b/source/blender/ikplugin/CMakeLists.txt
index 8991e113410..eb34e50715e 100644
--- a/source/blender/ikplugin/CMakeLists.txt
+++ b/source/blender/ikplugin/CMakeLists.txt
@@ -25,7 +25,7 @@
remove_extra_strict_flags()
-set(INC
+set(INC
.
../blenkernel
../blenlib
diff --git a/source/blender/ikplugin/intern/ikplugin_api.c b/source/blender/ikplugin/intern/ikplugin_api.c
index 9330f969ae7..791b74e4bc9 100644
--- a/source/blender/ikplugin/intern/ikplugin_api.c
+++ b/source/blender/ikplugin/intern/ikplugin_api.c
@@ -21,7 +21,7 @@
* The Original Code is: all of this file.
*
* Original author: Benoit Bolsee
- * Contributor(s):
+ * Contributor(s):
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -105,7 +105,7 @@ void BIK_execute_tree(struct Depsgraph *depsgraph, struct Scene *scene, Object *
plugin->execute_tree_func(depsgraph, scene, ob, pchan, ctime);
}
-void BIK_release_tree(struct Scene *scene, Object *ob, float ctime)
+void BIK_release_tree(struct Scene *scene, Object *ob, float ctime)
{
IKPlugin *plugin = get_plugin(ob->pose);
diff --git a/source/blender/ikplugin/intern/ikplugin_api.h b/source/blender/ikplugin/intern/ikplugin_api.h
index 1c55639c33b..139a50f44f0 100644
--- a/source/blender/ikplugin/intern/ikplugin_api.h
+++ b/source/blender/ikplugin/intern/ikplugin_api.h
@@ -21,7 +21,7 @@
* The Original Code is: all of this file.
*
* Original author: Benoit Bolsee
- * Contributor(s):
+ * Contributor(s):
*
* ***** END GPL LICENSE BLOCK *****
*/
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.h b/source/blender/ikplugin/intern/iksolver_plugin.h
index 9925d3c45d4..cce9511630f 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.h
+++ b/source/blender/ikplugin/intern/iksolver_plugin.h
@@ -21,7 +21,7 @@
* The Original Code is: all of this file.
*
* Original author: Benoit Bolsee
- * Contributor(s):
+ * Contributor(s):
*
* ***** END GPL LICENSE BLOCK *****
*/
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index af303556090..9ad98755be1 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -881,7 +881,7 @@ static int convert_channels(struct Depsgraph *depsgraph, IK_Scene *ikscene, Pose
ikchan->owner = ikscene->blArmature;
// the constraint and channels must be applied before we build the iTaSC scene,
- // this is because some of the pose data (e.g. pose head) don't have corresponding
+ // this is because some of the pose data (e.g. pose head) don't have corresponding
// joint angles and can't be applied to the iTaSC armature dynamically
if (!(pchan->flag & POSE_DONE))
BKE_pose_where_is_bone(depsgraph, ikscene->blscene, ikscene->blArmature, pchan, ctime, 1);
diff --git a/source/blender/ikplugin/intern/itasc_plugin.h b/source/blender/ikplugin/intern/itasc_plugin.h
index 0ab9a67dce4..2853ae095db 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.h
+++ b/source/blender/ikplugin/intern/itasc_plugin.h
@@ -21,7 +21,7 @@
* The Original Code is: all of this file.
*
* Original author: Benoit Bolsee
- * Contributor(s):
+ * Contributor(s):
*
* ***** END GPL LICENSE BLOCK *****
*/
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index e5cd21a3248..4289f98643d 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -495,7 +495,7 @@ void IMB_alpha_under_color_byte(unsigned char *rect, int x, int y, float backcol
/**
*
* \attention defined in readimage.c
- */
+ */
struct ImBuf *IMB_loadifffile(int file, const char *filepath, int flags, char colorspace[IM_MAX_SPACE], const char *descr);
/**
diff --git a/source/blender/imbuf/IMB_thumbs.h b/source/blender/imbuf/IMB_thumbs.h
index 6ca4b919c1d..cedd9fb4d9f 100644
--- a/source/blender/imbuf/IMB_thumbs.h
+++ b/source/blender/imbuf/IMB_thumbs.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c
index 93b605b74f6..902fc6482da 100644
--- a/source/blender/imbuf/intern/filter.c
+++ b/source/blender/imbuf/intern/filter.c
@@ -398,7 +398,7 @@ static int check_pixel_assigned(const void *buffer, const char *mask, const int
}
/* if alpha is zero, it checks surrounding pixels and averages color. sets new alphas to 1.0
- *
+ *
* When a mask is given, only effect pixels with a mask value of 1, defined as BAKE_MASK_MARGIN in rendercore.c
* */
void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index 55727ed6697..11b1fd7b1c2 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -245,8 +245,8 @@ int imb_is_a_iris(const uchar *mem)
}
/*
- * longimagedata -
- * read in a B/W RGB or RGBA iris image file and return a
+ * longimagedata -
+ * read in a B/W RGB or RGBA iris image file and return a
* pointer to an array of ints.
*
*/
diff --git a/source/blender/imbuf/intern/metadata.c b/source/blender/imbuf/intern/metadata.c
index ef103f7afcf..e6d778a4ea2 100644
--- a/source/blender/imbuf/intern/metadata.c
+++ b/source/blender/imbuf/intern/metadata.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.h b/source/blender/imbuf/intern/openexr/openexr_api.h
index ec4ae94795d..165cc968701 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.h
+++ b/source/blender/imbuf/intern/openexr/openexr_api.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/imbuf/intern/openexr/openexr_multi.h b/source/blender/imbuf/intern/openexr/openexr_multi.h
index d9338c888a7..5b4cdcd5e8e 100644
--- a/source/blender/imbuf/intern/openexr/openexr_multi.h
+++ b/source/blender/imbuf/intern/openexr/openexr_multi.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/imbuf/intern/openexr/openexr_stub.cpp b/source/blender/imbuf/intern/openexr/openexr_stub.cpp
index 301e827d739..b7138ee464a 100644
--- a/source/blender/imbuf/intern/openexr/openexr_stub.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_stub.cpp
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c
index 86e1fba9af7..831924b780a 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c
index efcd7d1f35f..7ed725ae163 100644
--- a/source/blender/imbuf/intern/thumbs_blend.c
+++ b/source/blender/imbuf/intern/thumbs_blend.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c
index a68b2aa966b..914fcc4e847 100644
--- a/source/blender/imbuf/intern/tiff.c
+++ b/source/blender/imbuf/intern/tiff.c
@@ -32,10 +32,10 @@
* already loaded the file into a memory buffer. libtiff is not well
* configured to handle files in memory, so a client wrapper is written to
* surround the memory and turn it into a virtual file. Currently, reading
- * of TIFF files is done using libtiff's RGBAImage support. This is a
+ * of TIFF files is done using libtiff's RGBAImage support. This is a
* high-level routine that loads all images as 32-bit RGBA, handling all the
* required conversions between many different TIFF types internally.
- *
+ *
* Saving supports RGB, RGBA and BW (grayscale) images correctly, with
* 8 bits per channel in all cases. The "deflate" compression algorithm is
* used to compress images.
@@ -371,7 +371,7 @@ static void imb_read_tiff_resolution(ImBuf *ibuf, TIFF *image)
/*
* Use the libTIFF scanline API to read a TIFF image.
- * This method is most flexible and can handle multiple different bit depths
+ * This method is most flexible and can handle multiple different bit depths
* and RGB channel orderings.
*/
static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image)
@@ -694,7 +694,7 @@ void imb_loadtiletiff(ImBuf *ibuf, const unsigned char *mem, size_t size, int tx
/**
* Saves a TIFF file.
*
- * ImBuf structures with 1, 3 or 4 bytes per pixel (GRAY, RGB, RGBA
+ * ImBuf structures with 1, 3 or 4 bytes per pixel (GRAY, RGB, RGBA
* respectively) are accepted, and interpreted correctly. Note that the TIFF
* convention is to use pre-multiplied alpha, which can be achieved within
* Blender by setting "Premul" alpha handling. Other alpha conventions are
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 4d59a7c9669..8043e01a147 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -229,7 +229,7 @@ typedef struct ID {
/* Only set for datablocks which are coming from copy-on-write, points to
* the original version of it.
*/
- void *orig_id;
+ struct ID *orig_id;
void *py_instance;
} ID;
@@ -381,7 +381,8 @@ typedef enum ID_Type {
#define ID_CHECK_UNDO(id) ((GS((id)->name) != ID_SCR) && (GS((id)->name) != ID_WM) && (GS((id)->name) != ID_WS))
-#define ID_BLEND_PATH(_bmain, _id) ((_id)->lib ? (_id)->lib->filepath : (_bmain)->name)
+#define ID_BLEND_PATH(_bmain, _id) ((_id)->lib ? (_id)->lib->filepath : BKE_main_blendfile_path((_bmain)))
+#define ID_BLEND_PATH_FROM_GLOBAL(_id) ((_id)->lib ? (_id)->lib->filepath : BKE_main_blendfile_path_from_global())
#define ID_MISSING(_id) (((_id)->tag & LIB_TAG_MISSING) != 0)
@@ -467,8 +468,8 @@ enum {
LIB_TAG_PRE_EXISTING = 1 << 11,
/* The datablock is a copy-on-write/localized version. */
- LIB_TAG_COPY_ON_WRITE = 1 << 12,
- LIB_TAG_COPY_ON_WRITE_EVAL = 1 << 13,
+ LIB_TAG_COPIED_ON_WRITE = 1 << 12,
+ LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT = 1 << 13,
LIB_TAG_LOCALIZED = 1 << 14,
/* RESET_NEVER tag datablock for freeing etc. behavior (usually set when copying real one into temp/runtime one). */
@@ -491,9 +492,7 @@ enum {
ID_RECALC_DRAW_CACHE = 1 << 3,
ID_RECALC_GEOMETRY = 1 << 4,
ID_RECALC_TRANSFORM = 1 << 5,
- ID_RECALC_COLLECTIONS = 1 << 6,
- ID_RECALC_COPY_ON_WRITE = 1 << 7,
- ID_RECALC_TIME = 1 << 8,
+ ID_RECALC_COPY_ON_WRITE = 1 << 6,
/* Special flag to check if SOMETHING was changed. */
ID_RECALC_ALL = (~(int)0),
};
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 2e73f5754d3..2266390d348 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -61,7 +61,8 @@ typedef struct bMotionPathVert {
/* bMotionPathVert->flag */
typedef enum eMotionPathVert_Flag {
/* vert is selected */
- MOTIONPATH_VERT_SEL = (1 << 0)
+ MOTIONPATH_VERT_SEL = (1 << 0),
+ MOTIONPATH_VERT_KEY = (1 << 1),
} eMotionPathVert_Flag;
/* ........ */
@@ -79,6 +80,12 @@ typedef struct bMotionPath {
float color[3]; /* optional custom color */
int line_thickness; /* line thickness */
int flag; /* baking settings - eMotionPath_Flag */
+
+ /* Used for drawing. */
+ struct Gwn_VertBuf *points_vbo;
+ struct Gwn_Batch *batch_line;
+ struct Gwn_Batch *batch_points;
+ void *pad;
} bMotionPath;
/* bMotionPath->flag */
@@ -199,8 +206,8 @@ typedef struct bPoseChannelDrawData {
/* PoseChannel
*
- * A PoseChannel stores the results of Actions and transform information
- * with respect to the restposition of Armature bones
+ * A PoseChannel stores the results of Actions and transform information
+ * with respect to the restposition of Armature bones
*/
typedef struct bPoseChannel {
struct bPoseChannel *next, *prev;
@@ -277,6 +284,9 @@ typedef struct bPoseChannel {
void *temp; /* use for outliner */
/* Runtime data for color and bbone segment matrix. */
bPoseChannelDrawData *draw_data;
+
+ /* Points to an original pose channel. */
+ struct bPoseChannel *orig_pchan;
} bPoseChannel;
@@ -489,14 +499,14 @@ typedef enum eItasc_Solver {
/* Action-Channel Group (agrp)
*
- * These are stored as a list per-Action, and are only used to
- * group that Action's channels in an Animation Editor.
+ * These are stored as a list per-Action, and are only used to
+ * group that Action's channels in an Animation Editor.
*
* Even though all FCurves live in a big list per Action, each group they are in also
* holds references to the achans within that list which belong to it. Care must be taken to
* ensure that action-groups never end up being the sole 'owner' of a channel.
- *
- * This is also exploited for bone-groups. Bone-Groups are stored per bPose, and are used
+ *
+ * This is also exploited for bone-groups. Bone-Groups are stored per bPose, and are used
* primarily to color bones in the 3d-view. There are other benefits too, but those are mostly related
* to Action-Groups.
*
@@ -543,13 +553,13 @@ typedef enum eActionGroup_Flag {
/* Action - reusable F-Curve 'bag' (act)
*
- * This contains F-Curves that may affect settings from more than one ID blocktype and/or
- * datablock (i.e. sub-data linked/used directly to the ID block that the animation data is linked to),
+ * This contains F-Curves that may affect settings from more than one ID blocktype and/or
+ * datablock (i.e. sub-data linked/used directly to the ID block that the animation data is linked to),
* but with the restriction that the other unrelated data (i.e. data that is not directly used or linked to
* by the source ID block).
*
- * It serves as a 'unit' of reusable animation information (i.e. keyframes/motion data), that
- * affects a group of related settings (as defined by the user).
+ * It serves as a 'unit' of reusable animation information (i.e. keyframes/motion data), that
+ * affects a group of related settings (as defined by the user).
*/
typedef struct bAction {
ID id; /* ID-serialisation for relinking */
@@ -667,10 +677,10 @@ typedef enum eDopeSheet_Flag {
typedef struct SpaceAction {
struct SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
- float blockscale;
-
- short blockhandler[8];
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
View2D v2d DNA_DEPRECATED; /* copied to region */
@@ -764,14 +774,14 @@ typedef enum eTimeline_Cache_Flag {
/* WARNING: Action Channels are now deprecated... they were part of the old animation system!
* (ONLY USED FOR DO_VERSIONS...)
- *
- * Action Channels belong to Actions. They are linked with an IPO block, and can also own
- * Constraint Channels in certain situations.
+ *
+ * Action Channels belong to Actions. They are linked with an IPO block, and can also own
+ * Constraint Channels in certain situations.
*
* Action-Channels can only belong to one group at a time, but they still live the Action's
* list of achans (to preserve backwards compatibility, and also minimize the code
* that would need to be recoded). Grouped achans are stored at the start of the list, according
- * to the position of the group in the list, and their position within the group.
+ * to the position of the group in the list, and their position within the group.
*/
typedef struct bActionChannel {
struct bActionChannel *next, *prev;
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index c2248778c46..63dc8920a4b 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -47,7 +47,7 @@ extern "C" {
/* F-Curve Modifiers (fcm)
*
* These alter the way F-Curves behave, by altering the value that is returned
- * when evaluating the curve's data at some time (t).
+ * when evaluating the curve's data at some time (t).
*/
typedef struct FModifier {
struct FModifier *next, *prev;
@@ -134,7 +134,7 @@ typedef enum eFMod_Generator_Flags {
/* 'Built-In Function' Generator modifier data
- *
+ *
* This uses the general equation for equations:
* y = amplitude * fn(phase_multiplier*x + phase_offset) + y_offset
*
@@ -397,14 +397,14 @@ typedef enum eDriverVar_Flags {
/* Channel Driver (i.e. Drivers / Expressions) (driver)
*
- * Channel Drivers are part of the dependency system, and are executed in addition to
+ * Channel Drivers are part of the dependency system, and are executed in addition to
* normal user-defined animation. They take the animation result of some channel(s), and
* use that (optionally combined with its own F-Curve for modification of results) to define
* the value of some setting semi-procedurally.
*
* Drivers are stored as part of F-Curve data, so that the F-Curve's RNA-path settings (for storing
* what setting the driver will affect). The order in which they are stored defines the order that they're
- * evaluated in. This order is set by the Depsgraph's sorting stuff.
+ * evaluated in. This order is set by the Depsgraph's sorting stuff.
*/
typedef struct ChannelDriver {
ListBase variables; /* targets for this driver (i.e. list of DriverVar) */
@@ -583,8 +583,8 @@ typedef struct AnimMapPair {
/* Retargetting Information for Actions
*
- * This should only be used if it is strictly necessary (i.e. user will need to explicitly
- * add this when they find that some channels do not match, or motion is not going to right
+ * This should only be used if it is strictly necessary (i.e. user will need to explicitly
+ * add this when they find that some channels do not match, or motion is not going to right
* places). When executing an action, this will be checked to see if it provides any useful
* remaps for the given paths.
*
@@ -607,7 +607,7 @@ typedef struct AnimMapper {
/* NLA Strip (strip)
*
* A NLA Strip is a container for the reuse of Action data, defining parameters
- * to control the remapping of the Action data to some destination.
+ * to control the remapping of the Action data to some destination.
*/
typedef struct NlaStrip {
struct NlaStrip *next, *prev;
@@ -716,7 +716,7 @@ typedef enum eNlaStrip_Type {
/* NLA Track (nlt)
*
- * A track groups a bunch of 'strips', which should form a continuous set of
+ * A track groups a bunch of 'strips', which should form a continuous set of
* motion, on top of which other such groups can be layered. This should allow
* for animators to work in a non-destructive manner, layering tweaks, etc. over
* 'rough' blocks of their work.
@@ -759,7 +759,7 @@ typedef enum eNlaTrack_Flag {
* dynamic data-block - such as PoseChannels - to act upon, ala
* Maya's 'Character Sets' and XSI's 'Marking Sets'), or they may
* be generic (using various placeholder template tags that will be
- * replaced with appropriate information from the context).
+ * replaced with appropriate information from the context).
*/
typedef struct KS_Path {
struct KS_Path *next, *prev;
@@ -807,7 +807,7 @@ typedef enum eKSP_Grouping {
* be keyframed together, providing a convenient way for animators
* to insert keyframes without resorting to Auto-Keyframing.
*
- * A few 'generic' (non-absolute and dependent on templates) KeyingSets
+ * A few 'generic' (non-absolute and dependent on templates) KeyingSets
* are defined 'built-in' to facilitate easy animating for the casual
* animator without the need to add extra steps to the rigging process.
*/
@@ -864,7 +864,7 @@ typedef enum eInsertKeyFlags {
*
* This is used to as temporary storage of values which have been changed by the user, but not
* yet keyframed (thus, would get overwritten by the animation system before the user had a chance
- * to see the changes that were made).
+ * to see the changes that were made).
*
* It is probably not needed for overriding keyframed values in most cases, as those will only get evaluated
* on frame-change now. That situation may change in future.
@@ -881,11 +881,11 @@ typedef struct AnimOverride {
/* AnimData ------------------------------------- */
/* Animation data for some ID block (adt)
- *
+ *
* This block of data is used to provide all of the necessary animation data for a datablock.
* Currently, this data will not be reusable, as there shouldn't be any need to do so.
- *
- * This information should be made available for most if not all ID-blocks, which should
+ *
+ * This information should be made available for most if not all ID-blocks, which should
* enable all of its settings to be animatable locally. Animation from 'higher-up' ID-AnimData
* blocks may override local settings.
*
@@ -917,6 +917,8 @@ typedef struct AnimData {
ListBase drivers; /* standard user-created Drivers/Expressions (used as part of a rig) */
ListBase overrides; /* temp storage (AnimOverride) of values for settings that are animated (but the value hasn't been keyframed) */
+ FCurve **driver_array; /* runtime data, for depsgraph evaluation */
+
/* settings for animation evaluation */
int flag; /* user-defined settings */
int recalc; /* depsgraph recalculation flags */
@@ -961,8 +963,6 @@ typedef enum eAnimData_Flag {
typedef enum eAnimData_Recalc {
ADT_RECALC_DRIVERS = (1 << 0),
ADT_RECALC_ANIM = (1 << 1),
- /* Only apply f-curve value if its original DNA value matches current DNA value. */
- ADT_RECALC_CHECK_ORIG_DNA = (1 << 2),
ADT_RECALC_ALL = (ADT_RECALC_DRIVERS | ADT_RECALC_ANIM)
} eAnimData_Recalc;
diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h
index f0f8c3fe2bd..6f6ce7d08db 100644
--- a/source/blender/makesdna/DNA_constraint_types.h
+++ b/source/blender/makesdna/DNA_constraint_types.h
@@ -157,7 +157,7 @@ typedef enum eConstraint_IK_Type {
/* Spline IK Constraint
* Aligns 'n' bones to the curvature defined by the curve,
- * with the chain ending on the bone that owns this constraint,
+ * with the chain ending on the bone that owns this constraint,
* and starting on the nth parent.
*/
typedef struct bSplineIKConstraint {
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index fd0170b9766..f1b0c32e53b 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -92,7 +92,7 @@ typedef struct BevList {
/**
* Keyframes on F-Curves (allows code reuse of Bezier eval code) and
- * Points on Bezier Curves/Paths are generally BezTriples
+ * Points on Bezier Curves/Paths are generally BezTriples
*
* \note alfa location in struct is abused by Key system
*
diff --git a/source/blender/makesdna/DNA_freestyle_types.h b/source/blender/makesdna/DNA_freestyle_types.h
index 158bdf573b3..36cf151b76e 100644
--- a/source/blender/makesdna/DNA_freestyle_types.h
+++ b/source/blender/makesdna/DNA_freestyle_types.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index d5a5a1d5d4a..c7ca92ba5cc 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/makesdna/DNA_ipo_types.h b/source/blender/makesdna/DNA_ipo_types.h
index 374104d8b13..5ba822616eb 100644
--- a/source/blender/makesdna/DNA_ipo_types.h
+++ b/source/blender/makesdna/DNA_ipo_types.h
@@ -29,7 +29,7 @@
* \ingroup DNA
* \deprecated
* The contents of this file are now officially deprecated. They were used for the 'old' animation system,
- * which has (as of 2.50) been replaced with a completely new system by Joshua Leung (aligorith). All defines,
+ * which has (as of 2.50) been replaced with a completely new system by Joshua Leung (aligorith). All defines,
* etc. are only still maintained to provide backwards compatibility for old files.
*/
diff --git a/source/blender/makesdna/DNA_linestyle_types.h b/source/blender/makesdna/DNA_linestyle_types.h
index f9b9f8a4641..fa9ce358549 100644
--- a/source/blender/makesdna/DNA_linestyle_types.h
+++ b/source/blender/makesdna/DNA_linestyle_types.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index 564e6aee3fc..64c40cc3efa 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -73,7 +73,13 @@ typedef struct Material {
/* Colors from Blender Internal that we are still using. */
float r, g, b;
float specr, specg, specb;
- float alpha, ray_mirror, spec, gloss_mir;
+ float alpha DNA_DEPRECATED;
+ float ray_mirror DNA_DEPRECATED;
+ float spec;
+ float gloss_mir DNA_DEPRECATED; /* renamed and inversed to roughness */
+ float roughness;
+ float metallic;
+ float pad4[2];
/* Ror buttons and render. */
char pr_type, use_nodes;
diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h
index 6d38fe22ea1..4014db72adf 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -164,8 +164,8 @@ typedef struct MLoop {
* MEdge *ed = &medge[mloop[lt->tri[j]].e];
* unsigned int tri_edge[2] = {mloop[lt->tri[j]].v, mloop[lt->tri[j_next]].v};
*
- * if (((ed->v1 == tri_edge[0]) && (ed->v1 == tri_edge[1])) ||
- * ((ed->v1 == tri_edge[1]) && (ed->v1 == tri_edge[0])))
+ * if (((ed->v1 == tri_edge[0]) && (ed->v2 == tri_edge[1])) ||
+ * ((ed->v1 == tri_edge[1]) && (ed->v2 == tri_edge[0])))
* {
* printf("real edge found %u %u\n", tri_edge[0], tri_edge[1]);
* }
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index af1045ee059..7d8d1883100 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/makesdna/DNA_object_enums.h b/source/blender/makesdna/DNA_object_enums.h
index 524c85948f3..802ca6c7d0d 100644
--- a/source/blender/makesdna/DNA_object_enums.h
+++ b/source/blender/makesdna/DNA_object_enums.h
@@ -47,6 +47,7 @@ typedef enum eObjectMode {
#define OB_MODE_ALL_SCULPT (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)
/* Any mode that has data we need to free when switching modes, see: #ED_object_mode_generic_exit */
-#define OB_MODE_ALL_MODE_DATA (OB_MODE_EDIT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_SCULPT)
+#define OB_MODE_ALL_MODE_DATA \
+ (OB_MODE_EDIT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_SCULPT | OB_MODE_POSE)
#endif /* __DNA_OBJECT_ENUMS_H__ */
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 64c67f7d325..f37bccbfe4e 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -143,6 +143,23 @@ typedef struct ObjectDisplay {
int flag;
} ObjectDisplay;
+/* Not saved in file! */
+typedef struct Object_Runtime {
+ /* Original mesh pointer, before object->data was changed to point
+ * to mesh_eval.
+ * Is assigned by dependency graph's copy-on-write evaluation.
+ */
+ struct Mesh *mesh_orig;
+ /* Mesh structure created during object evaluation.
+ * It has all modifiers applied.
+ */
+ struct Mesh *mesh_eval;
+ /* Mesh structure created during object evaluation.
+ * It has deforemation only modifiers applied on it.
+ */
+ struct Mesh *mesh_deform_eval;
+} Object_Runtime;
+
typedef struct Object {
ID id;
struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
@@ -299,10 +316,8 @@ typedef struct Object {
int pad6;
int select_color;
- /* Mesh structure created during object evaluation.
- * It has all modifiers applied.
- */
- struct Mesh *mesh_evaluated;
+ /* Runtime evaluation data. */
+ Object_Runtime runtime;
/* Object Display */
struct ObjectDisplay display;
@@ -327,26 +342,6 @@ typedef struct ObHook {
float force;
} ObHook;
-/* runtime only, but include here for rna access */
-typedef struct DupliObject {
- struct DupliObject *next, *prev;
- struct Object *ob;
- float mat[4][4];
- float orco[3], uv[2];
-
- short type; /* from Object.transflag */
- char no_draw, animated;
-
- /* persistent identifier for a dupli object, for inter-frame matching of
- * objects with motion blur, or inter-update matching for syncing */
- int persistent_id[16]; /* 2*MAX_DUPLI_RECUR */
-
- /* particle this dupli was generated from */
- struct ParticleSystem *particle_system;
- unsigned int random_id;
- unsigned int pad;
-} DupliObject;
-
/* **************** OBJECT ********************* */
/* used many places... should be specialized */
@@ -389,6 +384,10 @@ enum {
#define OB_TYPE_SUPPORT_PARVERT(_type) \
(ELEM(_type, OB_MESH, OB_SURF, OB_CURVE, OB_LATTICE))
+/** Matches #OB_TYPE_SUPPORT_EDITMODE. */
+#define OB_DATA_SUPPORT_EDITMODE(_type) \
+ (ELEM(_type, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR))
+
/* is this ID type used as object data */
#define OB_DATA_SUPPORT_ID(_id_type) \
(ELEM(_id_type, ID_ME, ID_CU, ID_MB, ID_LA, ID_SPK, ID_LP, ID_CA, ID_LT, ID_AR))
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index 583b8504524..8437c93a722 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -255,12 +255,18 @@ typedef struct ParticleSettings {
/* modified dm support */
short use_modifier_stack;
-
short pad5;
- int pad8;
- float twist;
- float pad6;
+ /* hair shape */
+ short shape_flag;
+ short pad6;
+
+ float twist, pad8;
+
+ /* hair thickness shape */
+ float shape;
+ float rad_root, rad_tip, rad_scale;
+
struct CurveMapping *twistcurve;
void *pad7;
} ParticleSettings;
@@ -449,6 +455,11 @@ typedef enum eParticleChildFlag {
PART_CHILD_USE_TWIST_CURVE = (1<<3),
} eParticleChildFlag;
+/* part->shape_flag */
+typedef enum eParticleShapeFlag {
+ PART_SHAPE_CLOSE_TIP = (1<<0),
+} eParticleShapeFlag;
+
/* part->draw_col */
#define PART_DRAW_COL_NONE 0
#define PART_DRAW_COL_MAT 1
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 0559df7950d..7d26fc6af3f 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -713,12 +713,21 @@ typedef struct RenderData {
ListBase views; /* SceneRenderView */
short actview;
short views_format;
- short pad8[2];
+
+ /* Hair Display */
+ short hair_type, hair_subdiv;
/* Motion blur shutter */
struct CurveMapping mblur_shutter_curve;
} RenderData;
+/* RenderData.hair_type */
+typedef enum eHairType {
+ SCE_HAIR_SHAPE_STRAND = 0,
+ SCE_HAIR_SHAPE_STRIP = 1,
+} eHairType;
+
+
/* *************************************************************** */
/* Render Conversion/Simplfication Settings */
@@ -1379,6 +1388,7 @@ typedef struct SceneDisplay {
float matcap_ssao_factor_edge;
float matcap_hair_brightness_randomness;
int matcap_ssao_samples;
+
} SceneDisplay;
typedef struct SceneEEVEE {
@@ -1617,7 +1627,7 @@ enum {
/* #define R_DEPRECATED 0x10000 */
/* #define R_RECURS_PROTECTION 0x20000 */
#define R_TEXNODE_PREVIEW 0x40000
-#define R_VIEWPORT_PREVIEW 0x80000
+/* #define R_VIEWPORT_PREVIEW 0x80000 */
#define R_EXR_CACHE_FILE 0x100000
#define R_MULTIVIEW 0x200000
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index ef0dbceef38..91bf1bbddbd 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -121,7 +121,9 @@ typedef struct Panel { /* the part from uiBlock that needs saved in file */
char panelname[64], tabname[64]; /* defined as UI_MAX_NAME_STR */
char drawname[64]; /* panelname is identifier for restoring location */
- int ofsx, ofsy, sizex, sizey;
+ int ofsx, ofsy; /* offset within the region */
+ int sizex, sizey; /* panel size including children */
+ int blocksizex, blocksizey; /* panel size excluding children */
short labelofs, pad;
short flag, runtime_flag;
short control;
@@ -129,6 +131,7 @@ typedef struct Panel { /* the part from uiBlock that needs saved in file */
int sortorder; /* panels are aligned according to increasing sortorder */
struct Panel *paneltab; /* this panel is tabbed in *paneltab */
void *activedata; /* runtime for panel manipulation */
+ ListBase children; /* sub panels */
} Panel;
@@ -274,11 +277,12 @@ typedef struct ScrArea {
* SPACE_EMPTY. Also, versioning uses it to nicely replace deprecated
* editors. It's been there for ages, name doesn't fit any more... */
char butspacetype; /* eSpace_Type (SPACE_FOO) */
+ short butspacetype_subtype;
short winx, winy; /* size */
- short headertype DNA_DEPRECATED;/* OLD! 0=no header, 1= down, 2= up */
- short do_refresh; /* private, for spacetype refresh callback */
+ char headertype DNA_DEPRECATED;/* OLD! 0=no header, 1= down, 2= up */
+ char do_refresh; /* private, for spacetype refresh callback */
short flag;
short region_active_win; /* index of last used region of 'RGN_TYPE_WINDOW'
* runtime variable, updated by executing operators */
@@ -386,6 +390,7 @@ enum {
/*PNL_TABBED = (1 << 3), */ /*UNUSED*/
PNL_OVERLAP = (1 << 4),
PNL_PIN = (1 << 5),
+ PNL_POPOVER = (1 << 6),
};
/* Panel->snap - for snapping to screen edges */
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 3bc5118c996..18fd17c006e 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -72,7 +72,9 @@ struct BLI_mempool;
//#define WITH_GLOBAL_AREA_WRITING
-/* SpaceLink (Base) ==================================== */
+/* -------------------------------------------------------------------- */
+/** \name SpaceLink (Base)
+ * \{ */
/**
* The base structure all the other spaces
@@ -82,22 +84,26 @@ struct BLI_mempool;
typedef struct SpaceLink {
struct SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
- float blockscale DNA_DEPRECATED; /* XXX make deprecated */
- short blockhandler[8] DNA_DEPRECATED; /* XXX make deprecated */
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
} SpaceLink;
+/** \} */
-/* Space Info ========================================== */
+/* -------------------------------------------------------------------- */
+/** \name Space Info
+ * \{ */
/* Info Header */
typedef struct SpaceInfo {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
- float blockscale DNA_DEPRECATED;
- short blockhandler[8] DNA_DEPRECATED; /* XXX make deprecated */
-
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
+
char rpt_mask;
char pad[7];
} SpaceInfo;
@@ -111,27 +117,32 @@ typedef enum eSpaceInfo_RptMask {
INFO_RPT_ERR = (1 << 4),
} eSpaceInfo_RptMask;
+/** \} */
-/* Properties Editor ==================================== */
+/* -------------------------------------------------------------------- */
+/** \name Properties Editor
+ * \{ */
/* Properties Editor */
typedef struct SpaceButs {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
- float blockscale DNA_DEPRECATED;
-
- short blockhandler[8] DNA_DEPRECATED;
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
-
+
+ /* For different kinds of property editors (exposed in the space type selector). */
+ short space_subtype;
+
short mainb, mainbo, mainbuser; /* context tabs */
short re_align, align; /* align for panels */
short preview; /* preview is signal to refresh */
char flag;
char collection_context;
- char pad[2];
-
+
void *path; /* runtime */
int pathflag, dataicon; /* runtime */
ID *pinid;
@@ -140,18 +151,18 @@ typedef struct SpaceButs {
} SpaceButs;
/* button defines (deprecated) */
-/* warning: the values of these defines are used in sbuts->tabs[8] */
-/* sbuts->mainb new */
+#ifdef DNA_DEPRECATED_ALLOW
+/* warning: the values of these defines are used in SpaceButs.tabs[8] */
+/* SpaceButs.mainb new */
#define CONTEXT_SCENE 0
#define CONTEXT_OBJECT 1
-#define CONTEXT_TYPES 2
+// #define CONTEXT_TYPES 2
#define CONTEXT_SHADING 3
#define CONTEXT_EDITING 4
-#define CONTEXT_SCRIPT 5
-//#define CONTEXT_LOGIC 6
+// #define CONTEXT_SCRIPT 5
+// #define CONTEXT_LOGIC 6
-/* sbuts->mainb old (deprecated) */
-#ifdef DNA_DEPRECATED_ALLOW
+/* SpaceButs.mainb old (deprecated) */
// #define BUTS_VIEW 0
#define BUTS_LAMP 1
#define BUTS_MAT 2
@@ -167,9 +178,9 @@ typedef struct SpaceButs {
// #define BUTS_SOUND 12
#define BUTS_CONSTRAINT 13
// #define BUTS_EFFECTS 14
-#endif
+#endif /* DNA_DEPRECATED_ALLOW */
-/* buts->mainb new */
+/* SpaceButs.mainb new */
typedef enum eSpaceButtons_Context {
BCONTEXT_RENDER = 0,
BCONTEXT_SCENE = 1,
@@ -185,13 +196,14 @@ typedef enum eSpaceButtons_Context {
BCONTEXT_CONSTRAINT = 11,
BCONTEXT_BONE_CONSTRAINT = 12,
BCONTEXT_VIEW_LAYER = 13,
+ BCONTEXT_TOOL = 14,
BCONTEXT_WORKSPACE = 15,
/* always as last... */
BCONTEXT_TOT
} eSpaceButtons_Context;
-/* sbuts->flag */
+/* SpaceButs.flag */
typedef enum eSpaceButtons_Flag {
SB_PRV_OSA = (1 << 0),
SB_PIN_CONTEXT = (1 << 1),
@@ -201,7 +213,7 @@ typedef enum eSpaceButtons_Flag {
SB_SHADING_CONTEXT = (1 << 4),
} eSpaceButtons_Flag;
-/* sbuts->align */
+/* SpaceButs.align */
typedef enum eSpaceButtons_Align {
BUT_FREE = 0,
BUT_HORIZONTAL = 1,
@@ -209,35 +221,25 @@ typedef enum eSpaceButtons_Align {
BUT_AUTO = 3,
} eSpaceButtons_Align;
-/* sbuts->scaflag */
-#define BUTS_SENS_SEL 1
-#define BUTS_SENS_ACT 2
-#define BUTS_SENS_LINK 4
-#define BUTS_CONT_SEL 8
-#define BUTS_CONT_ACT 16
-#define BUTS_CONT_LINK 32
-#define BUTS_ACT_SEL 64
-#define BUTS_ACT_ACT 128
-#define BUTS_ACT_LINK 256
-#define BUTS_SENS_STATE 512
-#define BUTS_ACT_STATE 1024
-#define BUTS_CONT_INIT_STATE 2048
+/** \} */
-
-/* Outliner =============================================== */
+/* -------------------------------------------------------------------- */
+/** \name Outliner
+ * \{ */
/* Outliner */
typedef struct SpaceOops {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
- float blockscale DNA_DEPRECATED;
- short blockhandler[8] DNA_DEPRECATED;
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
-
+
ListBase tree;
-
+
/* treestore is an ordered list of TreeStoreElem's from outliner tree;
* Note that treestore may contain duplicate elements if element
* is used multiple times in outliner tree (e. g. linked objects)
@@ -245,7 +247,7 @@ typedef struct SpaceOops {
* therefore readfile.c/writefile.c linearize treestore into TreeStore structure
*/
struct BLI_mempool *treestore;
-
+
/* search stuff */
char search_string[64];
struct TreeStoreElem search_tse;
@@ -255,13 +257,13 @@ typedef struct SpaceOops {
char filter_state;
char pad;
short filter_id_type;
-
+
/* pointers to treestore elements, grouped by (id, type, nr) in hashtable for faster searching */
void *treehash;
} SpaceOops;
-/* SpaceOops->flag */
+/* SpaceOops.flag */
typedef enum eSpaceOutliner_Flag {
SO_TESTBLOCKS = (1 << 0),
SO_NEWSELECTED = (1 << 1),
@@ -270,7 +272,7 @@ typedef enum eSpaceOutliner_Flag {
SO_SKIP_SORT_ALPHA = (1 << 4),
} eSpaceOutliner_Flag;
-/* SpaceOops->filter */
+/* SpaceOops.filter */
typedef enum eSpaceOutliner_Filter {
SO_FILTER_SEARCH = (1 << 0),
/* SO_FILTER_ENABLE = (1 << 1), */ /* Deprecated */
@@ -312,7 +314,7 @@ typedef enum eSpaceOutliner_Filter {
SO_FILTER_OB_STATE | \
SO_FILTER_NO_COLLECTION)
-/* SpaceOops->filter_state */
+/* SpaceOops.filter_state */
typedef enum eSpaceOutliner_StateFilter {
SO_FILTER_OB_ALL = 0,
SO_FILTER_OB_VISIBLE = 1,
@@ -320,7 +322,7 @@ typedef enum eSpaceOutliner_StateFilter {
SO_FILTER_OB_ACTIVE = 3,
} eSpaceOutliner_StateFilter;
-/* SpaceOops->outlinevis */
+/* SpaceOops.outlinevis */
typedef enum eSpaceOutliner_Mode {
SO_SCENES = 0,
/* SO_CUR_SCENE = 1, */ /* deprecated! */
@@ -340,7 +342,7 @@ typedef enum eSpaceOutliner_Mode {
SO_VIEW_LAYER = 15,
} eSpaceOutliner_Mode;
-/* SpaceOops->storeflag */
+/* SpaceOops.storeflag */
typedef enum eSpaceOutliner_StoreFlag {
/* cleanup tree */
SO_TREESTORE_CLEANUP = (1 << 0),
@@ -350,34 +352,38 @@ typedef enum eSpaceOutliner_StoreFlag {
SO_TREESTORE_REBUILD = (1 << 2),
} eSpaceOutliner_StoreFlag;
-/* outliner search flags (SpaceOops->search_flags) */
+/* outliner search flags (SpaceOops.search_flags) */
typedef enum eSpaceOutliner_Search_Flags {
SO_FIND_CASE_SENSITIVE = (1 << 0),
SO_FIND_COMPLETE = (1 << 1),
SO_SEARCH_RECURSIVE = (1 << 2),
} eSpaceOutliner_Search_Flags;
+/** \} */
-/* Graph Editor ========================================= */
+/* -------------------------------------------------------------------- */
+/** \name Graph Editor
+ * \{ */
/* 'Graph' Editor (formerly known as the IPO Editor) */
typedef struct SpaceIpo {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
- float blockscale DNA_DEPRECATED;
- short blockhandler[8] DNA_DEPRECATED;
-
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
+
View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
-
+
struct bDopeSheet *ads; /* settings for filtering animation data (NOTE: we use a pointer due to code-linking issues) */
-
+
ListBase ghostCurves; /* sampled snapshots of F-Curves used as in-session guides */
-
+
short mode; /* mode for the Graph editor (eGraphEdit_Mode) */
short autosnap; /* time-transform autosnapping settings for Graph editor (eAnimEdit_AutoSnap in DNA_action_types.h) */
int flag; /* settings for Graph editor (eGraphEdit_Flag) */
-
+
float cursorTime; /* time value for cursor (when in drivers mode; animation uses current frame) */
float cursorVal; /* cursor value (y-value, x-value is current frame) */
int around; /* pivot point for transforms */
@@ -385,11 +391,11 @@ typedef struct SpaceIpo {
} SpaceIpo;
-/* SpaceIpo->flag (Graph Editor Settings) */
+/* SpaceIpo.flag (Graph Editor Settings) */
typedef enum eGraphEdit_Flag {
/* OLD DEPRECEATED SETTING */
/* SIPO_LOCK_VIEW = (1 << 0), */
-
+
/* don't merge keyframes on the same frame after a transform */
SIPO_NOTRANSKEYCULL = (1 << 1),
/* don't show any keyframe handles at all */
@@ -422,7 +428,7 @@ typedef enum eGraphEdit_Flag {
SIPO_NORMALIZE_FREEZE = (1 << 15),
} eGraphEdit_Flag;
-/* SpaceIpo->mode (Graph Editor Mode) */
+/* SpaceIpo.mode (Graph Editor Mode) */
typedef enum eGraphEdit_Mode {
/* all animation curves (from all over Blender) */
SIPO_MODE_ANIMATION = 0,
@@ -430,26 +436,30 @@ typedef enum eGraphEdit_Mode {
SIPO_MODE_DRIVERS = 1,
} eGraphEdit_Mode;
+/** \} */
-/* NLA Editor ============================================= */
+/* -------------------------------------------------------------------- */
+/** \name NLA Editor
+ * \{ */
/* NLA Editor */
typedef struct SpaceNla {
struct SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
- float blockscale DNA_DEPRECATED;
- short blockhandler[8] DNA_DEPRECATED;
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
short autosnap; /* this uses the same settings as autosnap for Action Editor */
short flag;
int pad;
-
+
struct bDopeSheet *ads;
View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
} SpaceNla;
-/* nla->flag */
+/* SpaceNla.flag */
typedef enum eSpaceNla_Flag {
/* flags (1<<0), (1<<1), and (1<<3) are deprecated flags from old verisons */
@@ -465,10 +475,13 @@ typedef enum eSpaceNla_Flag {
SNLA_NOLOCALMARKERS = (1 << 7),
} eSpaceNla_Flag;
+/** \} */
-/* Timeline =============================================== */
+/* -------------------------------------------------------------------- */
+/** \name Timeline
+ * \{ */
-/* time->redraws (now screen->redraws_flag) */
+/* SpaceTime.redraws (now bScreen.redraws_flag) */
typedef enum eScreen_Redraws_Flag {
TIME_REGION = (1 << 0),
TIME_ALL_3D_WIN = (1 << 1),
@@ -484,19 +497,23 @@ typedef enum eScreen_Redraws_Flag {
TIME_FOLLOW = (1 << 15),
} eScreen_Redraws_Flag;
-/* Sequence Editor ======================================= */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Sequence Editor
+ * \{ */
/* Sequencer */
typedef struct SpaceSeq {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
- float blockscale DNA_DEPRECATED;
-
- short blockhandler[8] DNA_DEPRECATED;
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
-
+
float xof DNA_DEPRECATED, yof DNA_DEPRECATED; /* deprecated: offset for drawing the image preview */
short mainb; /* weird name for the sequencer subtype (seq, image, luma... etc) */
short render_size; /* eSpaceSeq_Proxy_RenderSize */
@@ -521,7 +538,7 @@ typedef struct SpaceSeq {
} SpaceSeq;
-/* sseq->mainb */
+/* SpaceSeq.mainb */
typedef enum eSpaceSeq_RegionType {
SEQ_DRAW_SEQUENCE = 0,
SEQ_DRAW_IMG_IMBUF = 1,
@@ -530,14 +547,14 @@ typedef enum eSpaceSeq_RegionType {
SEQ_DRAW_IMG_HISTOGRAM = 4,
} eSpaceSeq_RegionType;
-/* sseq->draw_flag */
+/* SpaceSeq.draw_flag */
typedef enum eSpaceSeq_DrawFlag {
SEQ_DRAW_BACKDROP = (1 << 0),
SEQ_DRAW_OFFSET_EXT = (1 << 1),
} eSpaceSeq_DrawFlag;
-/* sseq->flag */
+/* SpaceSeq.flag */
typedef enum eSpaceSeq_Flag {
SEQ_DRAWFRAMES = (1 << 0),
SEQ_MARKER_TRANS = (1 << 1),
@@ -552,14 +569,14 @@ typedef enum eSpaceSeq_Flag {
SEQ_SHOW_METADATA = (1 << 10),
} eSpaceSeq_Flag;
-/* sseq->view */
+/* SpaceSeq.view */
typedef enum eSpaceSeq_Displays {
SEQ_VIEW_SEQUENCE = 1,
SEQ_VIEW_PREVIEW = 2,
SEQ_VIEW_SEQUENCE_PREVIEW = 3,
} eSpaceSeq_Dispays;
-/* sseq->render_size */
+/* SpaceSeq.render_size */
typedef enum eSpaceSeq_Proxy_RenderSize {
SEQ_PROXY_RENDER_SIZE_NONE = -1,
SEQ_PROXY_RENDER_SIZE_SCENE = 0,
@@ -580,14 +597,18 @@ typedef struct MaskSpaceInfo {
char pad3[5];
} MaskSpaceInfo;
-/* sseq->mainb */
+/* SpaceSeq.mainb */
typedef enum eSpaceSeq_OverlayType {
SEQ_DRAW_OVERLAY_RECT = 0,
SEQ_DRAW_OVERLAY_REFERENCE = 1,
SEQ_DRAW_OVERLAY_CURRENT = 2
} eSpaceSeq_OverlayType;
-/* File Selector ========================================== */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name File Selector
+ * \{ */
/* Config and Input for File Selector */
typedef struct FileSelectParams {
@@ -631,29 +652,33 @@ typedef struct FileSelectParams {
typedef struct SpaceFile {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
-
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
+
+ char _pad1[4];
int scroll_offset;
struct FileSelectParams *params; /* config and input for file select */
-
+
struct FileList *files; /* holds the list of files to show */
ListBase *folders_prev; /* holds the list of previous directories to show */
ListBase *folders_next; /* holds the list of next directories (pushed from previous) to show */
- /* operator that is invoking fileselect
+ /* operator that is invoking fileselect
* op->exec() will be called on the 'Load' button.
* if operator provides op->cancel(), then this will be invoked
* on the cancel button.
*/
- struct wmOperator *op;
+ struct wmOperator *op;
struct wmTimer *smoothscroll_timer;
struct wmTimer *previews_timer;
struct FileLayout *layout;
-
+
short recentnr, bookmarknr;
short systemnr, system_bookmarknr;
} SpaceFile;
@@ -862,15 +887,20 @@ enum {
FILE_ENTRY_INVALID_PREVIEW = 1 << 0, /* The preview for this entry could not be generated. */
};
-/* Image/UV Editor ======================================== */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Image/UV Editor
+ * \{ */
/* Image/UV Editor */
typedef struct SpaceImage {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
-
- int flag;
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
struct Image *image;
struct ImageUser iuser;
@@ -897,13 +927,14 @@ typedef struct SpaceImage {
/* Filter settings when editor shows other object's UVs. */
int other_uv_filter;
- int pad2;
+
+ int flag;
MaskSpaceInfo mask_info;
} SpaceImage;
-/* SpaceImage->dt_uv */
+/* SpaceImage.dt_uv */
typedef enum eSpaceImage_UVDT {
SI_UVDT_OUTLINE = 0,
SI_UVDT_DASH = 1,
@@ -911,20 +942,20 @@ typedef enum eSpaceImage_UVDT {
SI_UVDT_WHITE = 3,
} eSpaceImage_UVDT;
-/* SpaceImage->dt_uvstretch */
+/* SpaceImage.dt_uvstretch */
typedef enum eSpaceImage_UVDT_Stretch {
SI_UVDT_STRETCH_ANGLE = 0,
SI_UVDT_STRETCH_AREA = 1,
} eSpaceImage_UVDT_Stretch;
-/* SpaceImage->mode */
+/* SpaceImage.mode */
typedef enum eSpaceImage_Mode {
SI_MODE_VIEW = 0,
SI_MODE_PAINT = 1,
SI_MODE_MASK = 2 /* note: mesh edit mode overrides mask */
} eSpaceImage_Mode;
-/* SpaceImage->sticky
+/* SpaceImage.sticky
* Note DISABLE should be 0, however would also need to re-arrange icon order,
* also, sticky loc is the default mode so this means we don't need to 'do_versions' */
typedef enum eSpaceImage_Sticky {
@@ -933,7 +964,7 @@ typedef enum eSpaceImage_Sticky {
SI_STICKY_VERTEX = 2,
} eSpaceImage_Sticky;
-/* SpaceImage->flag */
+/* SpaceImage.flag */
typedef enum eSpaceImage_Flag {
/* SI_BE_SQUARE = (1 << 0), */ /* deprecated */
/* SI_EDITTILE = (1 << 1), */ /* deprecated */
@@ -950,14 +981,14 @@ typedef enum eSpaceImage_Flag {
SI_USE_ALPHA = (1 << 12),
SI_SHOW_ALPHA = (1 << 13),
SI_SHOW_ZBUF = (1 << 14),
-
+
/* next two for render window display */
SI_PREVSPACE = (1 << 15),
SI_FULLWINDOW = (1 << 16),
-
+
/* SI_DEPRECATED4 = (1 << 17), */ /* deprecated */
/* SI_DEPRECATED5 = (1 << 18), */ /* deprecated */
-
+
/* this means that the image is drawn until it reaches the view edge,
* in the image view, it's unrelated to the 'tile' mode for texface
*/
@@ -977,21 +1008,26 @@ typedef enum eSpaceImage_Flag {
SI_SHOW_B = (1 << 29),
} eSpaceImage_Flag;
-/* SpaceImage->other_uv_filter */
+/* SpaceImage.other_uv_filter */
typedef enum eSpaceImage_OtherUVFilter {
SI_FILTER_SAME_IMAGE = 0,
SI_FILTER_ALL = 1,
} eSpaceImage_OtherUVFilter;
-/* Text Editor ============================================ */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Text Editor
+ * \{ */
/* Text Editor */
typedef struct SpaceText {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
- float blockscale DNA_DEPRECATED;
- short blockhandler[8] DNA_DEPRECATED;
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
struct Text *text;
@@ -1032,20 +1068,24 @@ typedef enum eSpaceText_Flags {
/* scrollable */
ST_SCROLL_SELECT = (1 << 0),
/* clear namespace after script execution (BPY_main.c) */
- ST_CLEAR_NAMESPACE = (1 << 4),
-
+ ST_CLEAR_NAMESPACE = (1 << 4),
+
ST_FIND_WRAP = (1 << 5),
ST_FIND_ALL = (1 << 6),
ST_SHOW_MARGIN = (1 << 7),
ST_MATCH_CASE = (1 << 8),
-
+
ST_FIND_ACTIVATE = (1 << 9),
} eSpaceText_Flags;
-/* stext->findstr/replacestr */
+/* SpaceText.findstr/replacestr */
#define ST_MAX_FIND_STR 256
-/* Script View (Obsolete) ================================== */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Script View (Obsolete)
+ * \{ */
/* Script Runtime Data - Obsolete (pre 2.5) */
typedef struct Script {
@@ -1068,62 +1108,68 @@ typedef struct Script {
typedef struct SpaceScript {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
- float blockscale DNA_DEPRECATED;
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
+
struct Script *script;
short flags, menunr;
int pad1;
-
+
void *but_refs;
} SpaceScript;
-/* Nodes Editor =========================================== */
+/** \} */
-/* Node Editor */
+/* -------------------------------------------------------------------- */
+/** \name Nodes Editor
+ * \{ */
typedef struct bNodeTreePath {
struct bNodeTreePath *next, *prev;
-
+
struct bNodeTree *nodetree;
bNodeInstanceKey parent_key; /* base key for nodes in this tree instance */
int pad;
float view_center[2]; /* v2d center point, so node trees can have different offsets in editors */
-
+
char node_name[64]; /* MAX_NAME */
} bNodeTreePath;
typedef struct SpaceNode {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
- float blockscale DNA_DEPRECATED;
- short blockhandler[8] DNA_DEPRECATED;
-
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
+
View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
-
+
struct ID *id, *from; /* context, no need to save in file? well... pinning... */
short flag, pad1; /* menunr: browse id block in header */
float aspect, pad2; /* internal state variables */
-
+
float xof, yof; /* offset for drawing the backdrop */
float zoom; /* zoom for backdrop */
float cursor[2]; /* mouse pos for drawing socketless link and adding nodes */
-
+
/* XXX nodetree pointer info is all in the path stack now,
* remove later on and use bNodeTreePath instead. For now these variables are set when pushing/popping
* from path stack, to avoid having to update all the functions and operators. Can be done when
* design is accepted and everything is properly tested.
*/
ListBase treepath;
-
+
struct bNodeTree *nodetree, *edittree;
-
+
/* tree type for the current node tree */
char tree_idname[64];
int treetype DNA_DEPRECATED; /* treetype: as same nodetree->type */
int pad3;
-
+
short texfrom; /* texfrom object, world or brush */
short shaderfrom; /* shader from object or world */
short recalc; /* currently on 0/1, for auto compo */
@@ -1138,7 +1184,7 @@ typedef struct SpaceNode {
struct bGPdata *gpd; /* grease-pencil data */
} SpaceNode;
-/* snode->flag */
+/* SpaceNode.flag */
typedef enum eSpaceNode_Flag {
SNODE_BACKDRAW = (1 << 1),
SNODE_SHOW_GPENCIL = (1 << 2),
@@ -1149,13 +1195,13 @@ typedef enum eSpaceNode_Flag {
SNODE_SHOW_B = (1 << 9),
SNODE_AUTO_RENDER = (1 << 5),
// SNODE_SHOW_HIGHLIGHT = (1 << 6), DNA_DEPRECATED
-// SNODE_USE_HIDDEN_PREVIEW = (1 << 10), DNA_DEPRECATED December2013
+// SNODE_USE_HIDDEN_PREVIEW = (1 << 10), DNA_DEPRECATED December2013
// SNODE_NEW_SHADERS = (1 << 11), DNA_DEPRECATED
SNODE_PIN = (1 << 12),
SNODE_SKIP_INSOFFSET = (1 << 13), /* automatically offset following nodes in a chain on insertion */
} eSpaceNode_Flag;
-/* snode->texfrom */
+/* SpaceNode.texfrom */
typedef enum eSpaceNode_TexFrom {
/* SNODE_TEX_OBJECT = 0, */
SNODE_TEX_WORLD = 1,
@@ -1163,30 +1209,34 @@ typedef enum eSpaceNode_TexFrom {
SNODE_TEX_LINESTYLE = 3,
} eSpaceNode_TexFrom;
-/* snode->shaderfrom */
+/* SpaceNode.shaderfrom */
typedef enum eSpaceNode_ShaderFrom {
SNODE_SHADER_OBJECT = 0,
SNODE_SHADER_WORLD = 1,
SNODE_SHADER_LINESTYLE = 2,
} eSpaceNode_ShaderFrom;
-/* snode->insert_ofs_dir */
+/* SpaceNode.insert_ofs_dir */
enum {
SNODE_INSERTOFS_DIR_RIGHT = 0,
SNODE_INSERTOFS_DIR_LEFT = 1,
};
-/* Console ================================================ */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Console
+ * \{ */
/* Console content */
typedef struct ConsoleLine {
struct ConsoleLine *next, *prev;
-
+
/* keep these 3 vars so as to share free, realloc funcs */
int len_alloc; /* allocated length */
int len; /* real len - strlen() */
- char *line;
-
+ char *line;
+
int cursor;
int type; /* only for use when in the 'scrollback' listbase */
} ConsoleLine;
@@ -1204,10 +1254,11 @@ typedef enum eConsoleLine_Type {
typedef struct SpaceConsole {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
- float blockscale DNA_DEPRECATED; // XXX are these needed?
- short blockhandler[8] DNA_DEPRECATED; // XXX are these needed?
-
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
+
/* space vars */
int lheight, pad;
@@ -1215,32 +1266,46 @@ typedef struct SpaceConsole {
ListBase history; /* ConsoleLine; command history, current edited line is the first */
char prompt[256];
char language[32]; /* multiple consoles are possible, not just python */
-
+
int sel_start;
int sel_end;
} SpaceConsole;
+/** \} */
-/* User Preferences ======================================= */
+/* -------------------------------------------------------------------- */
+/** \name User Preferences
+ * \{ */
-/* User Preferences View */
typedef struct SpaceUserPref {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
-
- char pad[3];
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
+
+ char _pad1[7];
char filter_type;
char filter[64]; /* search term for filtering in the UI */
} SpaceUserPref;
-/* Motion Tracking ======================================== */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Motion Tracking
+ * \{ */
/* Clip Editor */
typedef struct SpaceClip {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
+
+ char _pad1[4];
float xof, yof; /* user defined offset, image is centered */
float xlockof, ylockof; /* user defined offset from locked position */
@@ -1275,7 +1340,7 @@ typedef struct SpaceClip {
MaskSpaceInfo mask_info;
} SpaceClip;
-/* SpaceClip->flag */
+/* SpaceClip.flag */
typedef enum eSpaceClip_Flag {
SC_SHOW_MARKER_PATTERN = (1 << 0),
SC_SHOW_MARKER_SEARCH = (1 << 1),
@@ -1302,7 +1367,7 @@ typedef enum eSpaceClip_Flag {
SC_SHOW_METADATA = (1 << 22),
} eSpaceClip_Flag;
-/* SpaceClip->mode */
+/* SpaceClip.mode */
typedef enum eSpaceClip_Mode {
SC_MODE_TRACKING = 0,
/*SC_MODE_RECONSTRUCTION = 1,*/ /* DEPRECATED */
@@ -1310,21 +1375,25 @@ typedef enum eSpaceClip_Mode {
SC_MODE_MASKEDIT = 3,
} eSpaceClip_Mode;
-/* SpaceClip->view */
+/* SpaceClip.view */
typedef enum eSpaceClip_View {
SC_VIEW_CLIP = 0,
SC_VIEW_GRAPH = 1,
SC_VIEW_DOPESHEET = 2,
} eSpaceClip_View;
-/* SpaceClip->gpencil_src */
+/* SpaceClip.gpencil_src */
typedef enum eSpaceClip_GPencil_Source {
SC_GPENCIL_SRC_CLIP = 0,
SC_GPENCIL_SRC_TRACK = 1,
} eSpaceClip_GPencil_Source;
-/* Top Bar ======================================= */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Top Bar
+ * \{ */
/* These two lines with # tell makesdna this struct can be excluded.
* Should be: #ifndef WITH_GLOBAL_AREA_WRITING */
@@ -1333,12 +1402,17 @@ typedef enum eSpaceClip_GPencil_Source {
typedef struct SpaceTopBar {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
-
- int pad;
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
} SpaceTopBar;
-/* Status Bar ======================================= */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Status Bar
+ * \{ */
/* These two lines with # tell makesdna this struct can be excluded.
* Should be: #ifndef WITH_GLOBAL_AREA_WRITING */
@@ -1347,13 +1421,17 @@ typedef struct SpaceTopBar {
typedef struct SpaceStatusBar {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
-
- int pad;
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
} SpaceStatusBar;
+/** \} */
-/* **************** SPACE DEFINES ********************* */
+/* -------------------------------------------------------------------- */
+/** \name Space Defines (eSpace_Type)
+ * \{ */
/* space types, moved from DNA_screen_types.h */
/* Do NOT change order, append on end. types are hardcoded needed */
@@ -1391,7 +1469,8 @@ typedef enum eSpace_Type {
/* use for function args */
#define SPACE_TYPE_ANY -1
-
#define IMG_SIZE_FALLBACK 256
+/** \} */
+
#endif /* __DNA_SPACE_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 9817d44c96b..17f520fdfa9 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -150,9 +150,9 @@ typedef struct uiWidgetStateColors {
typedef struct uiPanelColors {
char header[4];
char back[4];
+ char sub_back[4];
short show_header;
short show_back;
- int pad;
} uiPanelColors;
typedef struct uiGradientColors {
@@ -617,6 +617,7 @@ typedef enum eUserPref_Section {
USER_SECTION_THEME = 4,
USER_SECTION_INPUT = 5,
USER_SECTION_ADDONS = 6,
+ USER_SECTION_LIGHT = 7,
} eUserPref_Section;
/* UserDef.flag */
diff --git a/source/blender/makesdna/DNA_vec_types.h b/source/blender/makesdna/DNA_vec_types.h
index 1420ca48c22..7ec259370b5 100644
--- a/source/blender/makesdna/DNA_vec_types.h
+++ b/source/blender/makesdna/DNA_vec_types.h
@@ -23,7 +23,7 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- *
+ *
*/
/** \file DNA_vec_types.h
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index dd3e0c25992..9686981d674 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -140,15 +140,19 @@ typedef struct View3DShading {
short light;
char pad[2];
char studio_light[256]; /* FILE_MAXFILE */
+ char matcap[256]; /* FILE_MAXFILE */
float shadow_intensity;
float single_color[3];
float studiolight_rot_z;
- float pad2;
+ float studiolight_background;
float object_outline_color[3];
- float pad3;
+ float xray_alpha;
+
+ float cavity_valley_factor;
+ float cavity_ridge_factor;
} View3DShading;
/* 3D Viewport Overlay setings */
@@ -165,15 +169,20 @@ typedef struct View3DOverlay {
/* Armature edit/pose mode settings */
int arm_flag;
+ float bone_selection_alpha;
+
+ /* Other settings */
+ float wireframe_threshold;
} View3DOverlay;
/* 3D ViewPort Struct */
typedef struct View3D {
struct SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
- float blockscale;
- short blockhandler[8];
+ char spacetype;
+ char link_flag;
+ char _pad0[6];
+ /* End 'SpaceLink' header. */
float viewquat[4] DNA_DEPRECATED;
float dist DNA_DEPRECATED;
@@ -199,7 +208,7 @@ typedef struct View3D {
int layact;
short ob_centre_cursor; /* optional bool for 3d cursor to define center */
- short scenelock, _pad0;
+ short scenelock, _pad1;
short flag, flag2, pad2;
float lens, grid;
@@ -332,14 +341,18 @@ typedef struct View3D {
enum {
V3D_LIGHTING_FLAT = 0,
V3D_LIGHTING_STUDIO = 1,
- V3D_LIGHTING_SCENE = 2
+ V3D_LIGHTING_MATCAP = 2,
};
/* View3DShading->flag */
enum {
- V3D_SHADING_OBJECT_OUTLINE = (1 << 0),
- V3D_SHADING_XRAY = (1 << 1),
- V3D_SHADING_SHADOW = (1 << 2),
+ V3D_SHADING_OBJECT_OUTLINE = (1 << 0),
+ V3D_SHADING_XRAY = (1 << 1),
+ V3D_SHADING_SHADOW = (1 << 2),
+ V3D_SHADING_SCENE_LIGHT = (1 << 3),
+ V3D_SHADING_SPECULAR_HIGHLIGHT = (1 << 4),
+ V3D_SHADING_CAVITY = (1 << 5),
+ V3D_SHADING_MATCAP_FLIP_X = (1 << 6),
};
/* View3DShading->single_color_type */
@@ -347,7 +360,6 @@ enum {
V3D_SHADING_MATERIAL_COLOR = 0,
V3D_SHADING_RANDOM_COLOR = 1,
V3D_SHADING_SINGLE_COLOR = 2,
- V3D_SHADING_OBJECT_COLOR = 3,
};
/* View3DOverlay->flag */
@@ -355,6 +367,11 @@ enum {
V3D_OVERLAY_FACE_ORIENTATION = (1 << 0),
V3D_OVERLAY_HIDE_CURSOR = (1 << 1),
V3D_OVERLAY_BONE_SELECTION = (1 << 2),
+ V3D_OVERLAY_LOOK_DEV = (1 << 3),
+ V3D_OVERLAY_WIREFRAMES = (1 << 4),
+ V3D_OVERLAY_HIDE_TEXT = (1 << 5),
+ V3D_OVERLAY_HIDE_MOTION_PATHS = (1 << 6),
+ V3D_OVERLAY_ONION_SKINS = (1 << 7),
};
/* View3DOverlay->edit_flag */
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 7d7fa5fcf23..6d5d2c380e2 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt
index 5b8dcd97108..06fd23cdff2 100644
--- a/source/blender/makesdna/intern/CMakeLists.txt
+++ b/source/blender/makesdna/intern/CMakeLists.txt
@@ -53,6 +53,7 @@ endif()
# SRC_DNA_INC is defined in the parent dir
add_cc_flags_custom_test(makesdna)
+setup_platform_linker_flags()
add_executable(makesdna ${SRC} ${SRC_DNA_INC})
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index c1f8341ddc6..b0da028127c 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -172,7 +172,7 @@ static int additional_slen_offset;
static int add_type(const char *str, int len);
/**
- * Add variable \c str to
+ * Add variable \c str to
* \param str
*/
static int add_name(const char *str);
@@ -191,22 +191,22 @@ static int preprocess_include(char *maindata, int len);
/**
* Scan this file for serializable types.
- */
+ */
static int convert_include(const char *filename);
/**
* Determine how many bytes are needed for an array.
- */
+ */
static int arraysize(const char *str);
/**
* Determine how many bytes are needed for each struct.
- */
+ */
static int calculate_structlens(int);
/**
* Construct the DNA.c file
- */
+ */
static void dna_write(FILE *file, const void *pntr, const int size);
/**
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 7431f48367c..2582af767be 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -210,7 +210,8 @@ extern StructRNA RNA_CurveMapping;
extern StructRNA RNA_CurveModifier;
extern StructRNA RNA_CurvePoint;
extern StructRNA RNA_Depsgraph;
-extern StructRNA RNA_DepsgraphIter;
+extern StructRNA RNA_DepsgraphObjectInstance;
+extern StructRNA RNA_DepsgraphUpdate;
extern StructRNA RNA_DampedTrackConstraint;
extern StructRNA RNA_DataTransferModifier;
extern StructRNA RNA_DecimateModifier;
@@ -225,7 +226,6 @@ extern StructRNA RNA_DopeSheet;
extern StructRNA RNA_Driver;
extern StructRNA RNA_DriverTarget;
extern StructRNA RNA_DriverVariable;
-extern StructRNA RNA_DupliObject;
extern StructRNA RNA_DynamicPaintBrushSettings;
extern StructRNA RNA_DynamicPaintCanvasSettings;
extern StructRNA RNA_DynamicPaintModifier;
@@ -807,6 +807,7 @@ PropertyType RNA_property_type(PropertyRNA *prop);
PropertySubType RNA_property_subtype(PropertyRNA *prop);
PropertyUnit RNA_property_unit(PropertyRNA *prop);
int RNA_property_flag(PropertyRNA *prop);
+int RNA_property_override_flag(PropertyRNA *prop);
int RNA_property_tags(PropertyRNA *prop);
bool RNA_property_builtin(PropertyRNA *prop);
void *RNA_property_py_data_get(PropertyRNA *prop);
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
index 4e32651d356..d56ccbcfa01 100644
--- a/source/blender/makesrna/RNA_define.h
+++ b/source/blender/makesrna/RNA_define.h
@@ -149,6 +149,8 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname,
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag);
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag);
+void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag);
+void RNA_def_property_override_clear_flag(PropertyRNA *prop, PropertyOverrideFlag flag);
void RNA_def_property_tags(PropertyRNA *prop, int tags);
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype);
void RNA_def_property_array(PropertyRNA *prop, int length);
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index bb09fe585ba..da2705d4660 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -245,4 +245,7 @@ const EnumPropertyItem *RNA_movieclip_local_itemf(struct bContext *C, struct Poi
const EnumPropertyItem *RNA_mask_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free);
const EnumPropertyItem *RNA_mask_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free);
+/* Non confirming, utility function. */
+const EnumPropertyItem *RNA_enum_node_tree_types_itemf_impl(struct bContext *C, bool *r_free);
+
#endif /* __RNA_ENUM_TYPES_H__ */
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 5d6f309ad65..9d304018990 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -158,7 +158,7 @@ typedef enum PropertySubType {
/* Make sure enums are updated with these */
/* HIGHEST FLAG IN USE: 1 << 31
- * FREE FLAGS: 11, 13, 14, 15, 30 */
+ * FREE FLAGS: 2, 9, 11, 13, 14, 15, 30 */
typedef enum PropertyFlag {
/* editable means the property is editable in the user
* interface, properties are editable by default except
@@ -176,15 +176,6 @@ typedef enum PropertyFlag {
* and collections */
PROP_ANIMATABLE = (1 << 1),
- /* Means the property can be overriden by a local 'proxy' of some linked datablock. */
- PROP_OVERRIDABLE_STATIC = (1 << 2),
- /* The property supports insertion (collections only). */
- PROP_OVERRIDABLE_STATIC_INSERTION = (1 << 9),
-
- /* Forbid usage of this property in comparison (& hence override) code.
- * Useful e.g. for collections of data like mesh's geometry, particles, etc. */
- PROP_NO_COMPARISON = (1 << 3),
-
/* This flag means when the property's widget is in 'textedit' mode, it will be updated
* after every typed char, instead of waiting final validation. Used e.g. for text searchbox.
* It will also cause UI_BUT_VALUE_CLEAR to be set for text buttons. We could add an own flag
@@ -253,6 +244,27 @@ typedef enum PropertyFlag {
PROP_ENUM_NO_TRANSLATE = (1 << 29), /* for enums not to be translated (e.g. viewlayers' names in nodes) */
} PropertyFlag;
+/* Flags related to comparing and overriding RNA properties. Make sure enums are updated with these */
+/* FREE FLAGS: 2, 3, 4, 5, 6, 7, 8, 9, 12 and above. */
+typedef enum PropertyOverrideFlag {
+ /* Means the property can be overriden by a local 'proxy' of some linked datablock. */
+ PROPOVERRIDE_OVERRIDABLE_STATIC = (1 << 0),
+
+ /* Forbid usage of this property in comparison (& hence override) code.
+ * Useful e.g. for collections of data like mesh's geometry, particles, etc. */
+ PROPOVERRIDE_NO_COMPARISON = (1 << 1),
+
+ /*** Collections-related ***/
+
+ /* The property supports insertion (collections only). */
+ PROPOVERRIDE_STATIC_INSERTION = (1 << 10),
+
+ /* Only use indices to compare items in the property, never names (collections only). */
+ /* Useful when nameprop of the items is generated from other data
+ * (e.g. name of material slots is actually name of assigned material). */
+ PROPOVERRIDE_NO_PROP_NAME = (1 << 11),
+} PropertyOverrideFlag;
+
/* Function parameters flags.
* WARNING: 16bits only. */
typedef enum ParameterFlag {
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index c62e8ed4da8..134ec2cc170 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -352,6 +352,7 @@ blender_include_dirs_sys(
)
add_cc_flags_custom_test(makesrna)
+setup_platform_linker_flags()
add_executable(makesrna ${SRC} ${SRC_RNA_INC} ${SRC_DNA_INC})
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 80d1897f604..fe063a8e335 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -290,7 +290,7 @@ static void rna_sortlist(ListBase *listbase, int (*cmp)(const void *, const void
Link *link;
void **array;
int a, size;
-
+
if (listbase->first == listbase->last)
return;
@@ -497,7 +497,7 @@ static int rna_enum_bitmask(PropertyRNA *prop)
if (eprop->item[a].identifier[0])
mask |= eprop->item[a].value;
}
-
+
return mask;
}
@@ -1416,7 +1416,7 @@ static void rna_set_raw_property(PropertyDefRNA *dp, PropertyRNA *prop)
return;
if (!dp->dnatype || !dp->dnaname || !dp->dnastructname)
return;
-
+
if (STREQ(dp->dnatype, "char")) {
prop->rawtype = PROP_RAW_CHAR;
prop->flag_internal |= PROP_INTERN_RAW_ACCESS;
@@ -1677,7 +1677,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
if (sprop->maxlength) {
fprintf(f, "#define %s_%s_MAX %d\n\n", srna->identifier, prop->identifier, sprop->maxlength);
}
-
+
fprintf(f, "void %sget(PointerRNA *ptr, char *value);\n", func);
fprintf(f, "int %slength(PointerRNA *ptr);\n", func);
fprintf(f, "void %sset(PointerRNA *ptr, const char *value);\n", func);
@@ -1733,7 +1733,7 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
if (prop->flag & PROP_IDPROPERTY || prop->flag_internal & PROP_INTERN_BUILTIN) {
return;
}
-
+
/* disabled for now to avoid msvc compiler error due to large file size */
#if 0
if (prop->name && prop->description && prop->description[0] != '\0')
@@ -2259,7 +2259,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
fprintf(f, "\n{\n");
/* variable definitions */
-
+
if (func->flag & FUNC_USE_SELF_ID) {
fprintf(f, "\tstruct ID *_selfid;\n");
}
@@ -2301,7 +2301,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
/* for dynamic parameters we pass an additional int for the length of the parameter */
if (flag & PROP_DYNAMIC)
fprintf(f, "\tint %s%s_len;\n", pout ? "*" : "", dparm->prop->identifier);
-
+
fprintf(f, "\t%s%s %s%s;\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop),
ptrstr, dparm->prop->identifier);
}
@@ -2317,7 +2317,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
if (func->flag & FUNC_USE_SELF_ID) {
fprintf(f, "\t_selfid = (struct ID *)_ptr->id.data;\n");
}
-
+
if ((func->flag & FUNC_NO_SELF) == 0) {
if (dsrna->dnafromprop) fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", dsrna->dnafromname);
else if (dsrna->dnaname) fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", dsrna->dnaname);
@@ -2886,7 +2886,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
{
char *strnest = (char *)"", *errnest = (char *)"";
int len, freenest = 0;
-
+
if (nest != NULL) {
len = strlen(nest);
@@ -3056,7 +3056,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
else fprintf(f, "NULL,\n");
fprintf(f, "\t%d, ", prop->magic);
rna_print_c_string(f, prop->identifier);
- fprintf(f, ", %d, %d, %d, %d, ", prop->flag, prop->flag_parameter, prop->flag_internal, prop->tags);
+ fprintf(f, ", %d, %d, %d, %d, %d, ", prop->flag, prop->flag_override, prop->flag_parameter, prop->flag_internal, prop->tags);
rna_print_c_string(f, prop->name); fprintf(f, ",\n\t");
rna_print_c_string(f, prop->description); fprintf(f, ",\n\t");
fprintf(f, "%d, ", prop->icon);
@@ -3441,7 +3441,7 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const
StructDefRNA *ds;
PropertyDefRNA *dp;
FunctionDefRNA *dfunc;
-
+
fprintf(f,
"\n"
"/* Automatically generated struct definitions for the Data API.\n"
@@ -3940,7 +3940,7 @@ static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f)
fprintf(f,
"/* Automatically generated classes for the Data API.\n"
" * Do not edit manually, changes will be overwritten. */\n\n");
-
+
fprintf(f, "#include \"RNA_blender.h\"\n");
fprintf(f, "#include \"RNA_types.h\"\n");
fprintf(f, "#include \"RNA_access.h\"\n");
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 1ea452bf389..11e45bc688d 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -156,13 +156,13 @@ void rna_ID_name_set(PointerRNA *ptr, const char *value)
static int rna_ID_name_editable(PointerRNA *ptr, const char **UNUSED(r_info))
{
ID *id = (ID *)ptr->data;
-
+
if (GS(id->name) == ID_VF) {
VFont *vfont = (VFont *)id;
if (BKE_vfont_is_builtin(vfont))
return false;
}
-
+
return PROP_EDITABLE;
}
@@ -333,7 +333,7 @@ static ID *rna_ID_copy(ID *id, Main *bmain)
if (newid) id_us_min(newid);
return newid;
}
-
+
return NULL;
}
@@ -456,7 +456,7 @@ int rna_IDMaterials_assign_int(PointerRNA *ptr, int key, const PointerRNA *assig
short *totcol = give_totcolp_id(id);
Material *mat_id = assign_ptr->id.data;
if (totcol && (key >= 0 && key < *totcol)) {
- assign_material_id(id, mat_id, key + 1);
+ assign_material_id(G.main, id, mat_id, key + 1);
return 1;
}
else {
@@ -512,7 +512,7 @@ static void rna_IDMaterials_clear_id(ID *id, Main *bmain, int remove_material_sl
static void rna_Library_filepath_set(PointerRNA *ptr, const char *value)
{
Library *lib = (Library *)ptr->data;
- BKE_library_filepath_set(lib, value);
+ BKE_library_filepath_set(G.main, lib, value);
}
/* ***** ImagePreview ***** */
@@ -797,27 +797,6 @@ static PointerRNA rna_IDPreview_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_ImagePreview, prv_img);
}
-static int rna_ID_is_updated_get(PointerRNA *ptr)
-{
- ID *id = (ID *)ptr->data;
- /* TODO(sergey): Do we need to limit some of flags here? */
- return ((id->recalc & ID_RECALC_ALL) != 0);
-}
-
-static int rna_ID_is_updated_data_get(PointerRNA *ptr)
-{
- ID *id = (ID *)ptr->data;
- if (GS(id->name) != ID_OB) {
- return 0;
- }
- Object *object = (Object *)id;
- ID *data = object->data;
- if (data == NULL) {
- return 0;
- }
- return ((data->recalc & ID_RECALC_ALL) != 0);
-}
-
static IDProperty *rna_IDPropertyWrapPtr_idprops(PointerRNA *ptr, bool UNUSED(create))
{
if (ptr == NULL) {
@@ -838,7 +817,7 @@ static void rna_def_ID_properties(BlenderRNA *brna)
srna = RNA_def_struct(brna, "PropertyGroupItem", NULL);
RNA_def_struct_sdna(srna, "IDProperty");
RNA_def_struct_ui_text(srna, "ID Property", "Property that stores arbitrary, user defined properties");
-
+
/* IDP_STRING */
prop = RNA_def_property(srna, "string", PROP_STRING, PROP_NONE);
RNA_def_property_flag(prop, PROP_EXPORT | PROP_IDPROPERTY);
@@ -924,7 +903,7 @@ static void rna_def_ID_materials(BlenderRNA *brna)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
-
+
/* for mesh/mball/curve materials */
srna = RNA_def_struct(brna, "IDMaterials", NULL);
RNA_def_struct_sdna(srna, "ID");
@@ -1170,16 +1149,6 @@ static void rna_def_ID(BlenderRNA *brna)
"Tools can use this to tag data for their own purposes "
"(initial state is undefined)");
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_ID_is_updated_get", NULL);
- RNA_def_property_ui_text(prop, "Is Updated", "Data-block is tagged for recalculation");
-
- prop = RNA_def_property(srna, "is_updated_data", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_ID_is_updated_data_get", NULL);
- RNA_def_property_ui_text(prop, "Is Updated Data", "Data-block data is tagged for recalculation");
-
prop = RNA_def_property(srna, "is_library_indirect", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "tag", LIB_TAG_INDIRECT);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -1275,7 +1244,7 @@ static void rna_def_library(BlenderRNA *brna)
RNA_def_property_string_sdna(prop, NULL, "name");
RNA_def_property_ui_text(prop, "File Path", "Path to the library .blend file");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Library_filepath_set");
-
+
prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Library");
RNA_def_property_ui_text(prop, "Parent", "");
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 5a0dec28324..0532aac1bc3 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -107,9 +107,9 @@ void RNA_init(void)
void RNA_exit(void)
{
StructRNA *srna;
-
+
RNA_property_update_cache_free();
-
+
for (srna = BLENDER_RNA.structs.first; srna; srna = srna->cont.next) {
if (srna->cont.prophash) {
BLI_ghash_free(srna->cont.prophash, NULL, NULL);
@@ -137,7 +137,7 @@ void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
PointerRNA tmp = {{NULL}};
tmp.data = id;
idtype = rna_ID_refine(&tmp);
-
+
while (idtype->refine) {
type = idtype->refine(&tmp);
@@ -147,7 +147,7 @@ void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
idtype = type;
}
}
-
+
r_ptr->id.data = id;
r_ptr->type = idtype;
r_ptr->data = id;
@@ -289,7 +289,7 @@ IDProperty *RNA_struct_idprops(PointerRNA *ptr, bool create)
if (type && type->idproperties) {
return type->idproperties(ptr, create);
}
-
+
return NULL;
}
@@ -380,7 +380,7 @@ static bool rna_idproperty_verify_valid(PointerRNA *ptr, PropertyRNA *prop, IDPr
* description and otherwise removes it. this is to ensure that
* rna property access is type safe, e.g. if you defined the rna
* to have a certain array length you can count on that staying so */
-
+
switch (idprop->type) {
case IDP_IDPARRAY:
if (prop->type != PROP_COLLECTION)
@@ -693,7 +693,7 @@ bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
for (base = type; base; base = base->base)
if (base == srna)
return true;
-
+
return false;
}
@@ -718,7 +718,7 @@ PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
if (RNA_property_collection_lookup_string(ptr, iterprop, identifier, &propptr))
return propptr.data;
}
-
+
return NULL;
}
@@ -1005,6 +1005,11 @@ int RNA_property_flag(PropertyRNA *prop)
return rna_ensure_property(prop)->flag;
}
+int RNA_property_override_flag(PropertyRNA *prop)
+{
+ return rna_ensure_property(prop)->flag_override;
+}
+
/**
* Get the tags set for \a prop as int bitfield.
* \note Doesn't perform any validity check on the set bits. #RNA_def_property_tags does this
@@ -1175,7 +1180,7 @@ void RNA_property_int_ui_range(PointerRNA *ptr, PropertyRNA *prop, int *softmin,
{
IntPropertyRNA *iprop = (IntPropertyRNA *)rna_ensure_property(prop);
int hardmin, hardmax;
-
+
if (prop->magic != RNA_MAGIC) {
/* attempt to get the local ID values */
IDProperty *idp_ui = rna_idproperty_ui(prop);
@@ -1688,7 +1693,7 @@ bool RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *pro
{
const EnumPropertyItem *item = NULL;
bool free;
-
+
RNA_property_enum_items(C, ptr, prop, &item, NULL, &free);
if (item) {
bool result;
@@ -1705,7 +1710,7 @@ bool RNA_property_enum_name(bContext *C, PointerRNA *ptr, PropertyRNA *prop, con
{
const EnumPropertyItem *item = NULL;
bool free;
-
+
RNA_property_enum_items(C, ptr, prop, &item, NULL, &free);
if (item) {
bool result;
@@ -1713,7 +1718,7 @@ bool RNA_property_enum_name(bContext *C, PointerRNA *ptr, PropertyRNA *prop, con
if (free) {
MEM_freeN((void *)item);
}
-
+
return result;
}
return false;
@@ -1927,7 +1932,7 @@ bool RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop)
/* check that base ID-block can support animation data */
if (!id_can_have_animdata(ptr->id.data))
return false;
-
+
prop = rna_ensure_property(prop);
if (!(prop->flag & PROP_ANIMATABLE))
@@ -1976,11 +1981,11 @@ bool RNA_property_overridable_get(PointerRNA *ptr, PropertyRNA *prop)
}
}
/* If this is a RNA-defined property (real or 'virtual' IDProp), we want to use RNA prop flag. */
- return !(prop->flag & PROP_NO_COMPARISON) && (prop->flag & PROP_OVERRIDABLE_STATIC);
+ return !(prop->flag_override & PROPOVERRIDE_NO_COMPARISON) && (prop->flag_override & PROPOVERRIDE_OVERRIDABLE_STATIC);
}
else {
/* If this is a real 'pure' IDProp (aka custom property), we want to use the IDProp flag. */
- return !(prop->flag & PROP_NO_COMPARISON) && (((IDProperty *)prop)->flag & IDP_FLAG_OVERRIDABLE_STATIC);
+ return !(prop->flag_override & PROPOVERRIDE_NO_COMPARISON) && (((IDProperty *)prop)->flag & IDP_FLAG_OVERRIDABLE_STATIC);
}
}
@@ -2016,7 +2021,7 @@ bool RNA_property_comparable(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
{
prop = rna_ensure_property(prop);
- return !(prop->flag & PROP_NO_COMPARISON);
+ return !(prop->flag_override & PROPOVERRIDE_NO_COMPARISON);
}
/* this function is to check if its possible to create a valid path from the ID
@@ -2142,7 +2147,7 @@ void RNA_property_update_main(Main *bmain, Scene *scene, PointerRNA *ptr, Proper
/* cache element */
typedef struct tRnaUpdateCacheElem {
struct tRnaUpdateCacheElem *next, *prev;
-
+
PointerRNA ptr; /* L1 key - id as primary, data secondary/ignored? */
ListBase L2Funcs; /* L2 functions (LinkData<RnaUpdateFuncRef>) */
} tRnaUpdateCacheElem;
@@ -2158,18 +2163,18 @@ void RNA_property_update_cache_add(PointerRNA *ptr, PropertyRNA *prop)
tRnaUpdateCacheElem *uce = NULL;
UpdateFunc fn = NULL;
LinkData *ld;
-
+
/* sanity check */
if (NULL == ptr)
return;
-
+
prop = rna_ensure_property(prop);
-
+
/* we can only handle update calls with no context args for now (makes animsys updates easier) */
if ((is_rna == false) || (prop->update == NULL) || (prop->flag & PROP_CONTEXT_UPDATE))
return;
fn = prop->update;
-
+
/* find cache element for which key matches... */
for (uce = rna_updates_cache.first; uce; uce = uce->next) {
/* just match by id only for now, since most update calls that we'll encounter only really care about this */
@@ -2182,11 +2187,11 @@ void RNA_property_update_cache_add(PointerRNA *ptr, PropertyRNA *prop)
/* create new instance */
uce = MEM_callocN(sizeof(tRnaUpdateCacheElem), "tRnaUpdateCacheElem");
BLI_addtail(&rna_updates_cache, uce);
-
+
/* copy pointer */
RNA_pointer_create(ptr->id.data, ptr->type, ptr->data, &uce->ptr);
}
-
+
/* check on the update func */
for (ld = uce->L2Funcs.first; ld; ld = ld->next) {
/* stop on match - function already cached */
@@ -2200,13 +2205,13 @@ void RNA_property_update_cache_add(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_update_cache_flush(Main *bmain, Scene *scene)
{
tRnaUpdateCacheElem *uce;
-
+
/* TODO: should we check that bmain and scene are valid? The above stuff doesn't! */
-
+
/* execute the cached updates */
for (uce = rna_updates_cache.first; uce; uce = uce->next) {
LinkData *ld;
-
+
for (ld = uce->L2Funcs.first; ld; ld = ld->next) {
UpdateFunc fn = (UpdateFunc)ld->data;
fn(bmain, scene, &uce->ptr);
@@ -2217,13 +2222,13 @@ void RNA_property_update_cache_flush(Main *bmain, Scene *scene)
void RNA_property_update_cache_free(void)
{
tRnaUpdateCacheElem *uce, *ucn;
-
+
for (uce = rna_updates_cache.first; uce; uce = ucn) {
ucn = uce->next;
-
+
/* free L2 cache */
BLI_freelistN(&uce->L2Funcs);
-
+
/* remove self */
BLI_freelinkN(&rna_updates_cache, uce);
}
@@ -2424,7 +2429,7 @@ int RNA_property_boolean_get_default(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
void RNA_property_boolean_get_default_array(PointerRNA *UNUSED(ptr), PropertyRNA *prop, int *values)
{
BoolPropertyRNA *bprop = (BoolPropertyRNA *)rna_ensure_property(prop);
-
+
BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN);
BLI_assert(RNA_property_array_check(prop) != false);
@@ -2679,7 +2684,7 @@ int RNA_property_int_get_default(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
void RNA_property_int_get_default_array(PointerRNA *UNUSED(ptr), PropertyRNA *prop, int *values)
{
IntPropertyRNA *iprop = (IntPropertyRNA *)rna_ensure_property(prop);
-
+
BLI_assert(RNA_property_type(prop) == PROP_INT);
BLI_assert(RNA_property_array_check(prop) != false);
@@ -2966,7 +2971,7 @@ float RNA_property_float_get_default(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
void RNA_property_float_get_default_array(PointerRNA *UNUSED(ptr), PropertyRNA *prop, float *values)
{
FloatPropertyRNA *fprop = (FloatPropertyRNA *)rna_ensure_property(prop);
-
+
BLI_assert(RNA_property_type(prop) == PROP_FLOAT);
BLI_assert(RNA_property_array_check(prop) != false);
@@ -3402,7 +3407,7 @@ void RNA_property_pointer_remove(PointerRNA *ptr, PropertyRNA *prop)
if ((idprop = rna_idproperty_check(&prop, ptr))) {
group = RNA_struct_idprops(ptr, 0);
-
+
if (group) {
IDP_FreeFromGroup(group, idprop);
}
@@ -3683,7 +3688,7 @@ int RNA_property_collection_lookup_index(PointerRNA *ptr, PropertyRNA *prop, Poi
{
CollectionPropertyIterator iter;
int index = 0;
-
+
BLI_assert(RNA_property_type(prop) == PROP_COLLECTION);
RNA_property_collection_begin(ptr, prop, &iter);
@@ -3692,7 +3697,7 @@ int RNA_property_collection_lookup_index(PointerRNA *ptr, PropertyRNA *prop, Poi
break;
}
RNA_property_collection_end(&iter);
-
+
/* did we find it? */
if (iter.valid)
return index;
@@ -3885,7 +3890,7 @@ static int rna_property_array_length_all_dimensions(PointerRNA *ptr, PropertyRNA
for (size = 1, i = 0; i < dim; i++)
size *= len[i];
-
+
return size;
}
@@ -3938,7 +3943,7 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro
out.len * arraylen, in.len);
return 0;
}
-
+
/* matching raw types */
if (out.type == in.type) {
void *inp = in.array;
@@ -4296,7 +4301,7 @@ void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int i
internal->itemsize = itemsize;
internal->skip = skip;
internal->length = length;
-
+
iter->valid = (internal->ptr != internal->endptr);
if (skip && iter->valid && skip(iter, internal->ptr))
@@ -4337,7 +4342,7 @@ void *rna_iterator_array_dereference_get(CollectionPropertyIterator *iter)
void rna_iterator_array_end(CollectionPropertyIterator *iter)
{
ArrayIterator *internal = &iter->internal.array;
-
+
if (internal->free_ptr) {
MEM_freeN(internal->free_ptr);
internal->free_ptr = NULL;
@@ -4392,7 +4397,7 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int
len++;
p++;
}
-
+
/* skip the last quoted char to get the ']' */
len++;
p++;
@@ -4409,11 +4414,11 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int
p++;
}
}
-
+
/* empty, return */
if (len == 0)
return NULL;
-
+
/* try to use fixed buffer if possible */
if (len + 1 < fixedlen)
buf = fixedbuf;
@@ -4459,22 +4464,22 @@ static bool rna_path_parse_collection_key(const char **path, PointerRNA *ptr, Pr
{
char fixedbuf[256];
int intkey;
-
+
*r_nextptr = *ptr;
/* end of path, ok */
if (!(**path))
return true;
-
+
if (**path == '[') {
char *token;
/* resolve the lookup with [] brackets */
token = rna_path_token(path, fixedbuf, sizeof(fixedbuf), 1);
-
+
if (!token)
return false;
-
+
/* check for "" to see if it is a string */
if (rna_token_strip_quotes(token)) {
if (RNA_property_collection_lookup_string(ptr, prop, token + 1, r_nextptr)) {
@@ -4497,7 +4502,7 @@ static bool rna_path_parse_collection_key(const char **path, PointerRNA *ptr, Pr
r_nextptr->data = NULL;
}
}
-
+
if (token != fixedbuf) {
MEM_freeN(token);
}
@@ -4511,7 +4516,7 @@ static bool rna_path_parse_collection_key(const char **path, PointerRNA *ptr, Pr
r_nextptr->data = NULL;
}
}
-
+
return true;
}
@@ -4522,21 +4527,21 @@ static bool rna_path_parse_array_index(const char **path, PointerRNA *ptr, Prope
int len[RNA_MAX_ARRAY_DIMENSION];
const int dim = RNA_property_array_dimension(ptr, prop, len);
int i;
-
+
*r_index = -1;
-
+
/* end of path, ok */
if (!(**path))
return true;
-
+
for (i = 0; i < dim; i++) {
int temp_index = -1;
char *token;
-
+
/* multi index resolve */
if (**path == '[') {
token = rna_path_token(path, fixedbuf, sizeof(fixedbuf), 1);
-
+
if (token == NULL) {
/* invalid syntax blah[] */
return false;
@@ -4548,12 +4553,12 @@ static bool rna_path_parse_array_index(const char **path, PointerRNA *ptr, Prope
else {
/* otherwise do int lookup */
temp_index = atoi(token);
-
+
if (temp_index == 0 && (token[0] != '0' || token[1] != '\0')) {
if (token != fixedbuf) {
MEM_freeN(token);
}
-
+
return false;
}
}
@@ -4571,33 +4576,33 @@ static bool rna_path_parse_array_index(const char **path, PointerRNA *ptr, Prope
/* just to avoid uninitialized pointer use */
token = fixedbuf;
}
-
+
if (token != fixedbuf) {
MEM_freeN(token);
}
-
+
/* out of range */
if (temp_index < 0 || temp_index >= len[i])
return false;
-
+
index_arr[i] = temp_index;
/* end multi index resolve */
}
-
+
/* arrays always contain numbers so further values are not valid */
if (**path)
return false;
-
+
/* flatten index over all dimensions */
{
int totdim = 1;
int flat_index = 0;
-
+
for (i = dim - 1; i >= 0; i--) {
flat_index += index_arr[i] * totdim;
totdim *= len[i];
}
-
+
*r_index = flat_index;
}
return true;
@@ -4673,7 +4678,7 @@ static bool rna_path_parse(PointerRNA *ptr, const char *path,
*/
if (eval_pointer || *path) {
PointerRNA nextptr = RNA_property_pointer_get(&curptr, prop);
-
+
curptr = nextptr;
prop = NULL; /* now we have a PointerRNA, the prop is our parent so forget it */
index = -1;
@@ -4690,7 +4695,7 @@ static bool rna_path_parse(PointerRNA *ptr, const char *path,
PointerRNA nextptr;
if (!rna_path_parse_collection_key(&path, &curptr, prop, &nextptr))
return false;
-
+
curptr = nextptr;
prop = NULL; /* now we have a PointerRNA, the prop is our parent so forget it */
index = -1;
@@ -4807,7 +4812,7 @@ char *RNA_path_append(const char *path, PointerRNA *UNUSED(ptr), PropertyRNA *pr
DynStr *dynstr;
const char *s;
char appendstr[128], *result;
-
+
dynstr = BLI_dynstr_new();
/* add .identifier */
@@ -4882,7 +4887,7 @@ char *RNA_path_back(const char *path)
token = rna_path_token(&current, fixedbuf, sizeof(fixedbuf), 1);
if (token && token != fixedbuf)
MEM_freeN(token);
-
+
if (!*current)
break;
@@ -5053,7 +5058,7 @@ char *RNA_path_from_ID_to_struct(PointerRNA *ptr)
if (!ptr->id.data || !ptr->data)
return NULL;
-
+
if (!RNA_struct_is_ID(ptr->type)) {
if (ptr->type->path) {
/* if type has a path to some ID, use it */
@@ -5062,13 +5067,13 @@ char *RNA_path_from_ID_to_struct(PointerRNA *ptr)
else if (ptr->type->nested && RNA_struct_is_ID(ptr->type->nested)) {
PointerRNA parentptr;
PropertyRNA *userprop;
-
+
/* find the property in the struct we're nested in that references this struct, and
* use its identifier as the first part of the path used...
*/
RNA_id_pointer_create(ptr->id.data, &parentptr);
userprop = RNA_struct_find_nested(&parentptr, ptr->type);
-
+
if (userprop)
ptrpath = BLI_strdup(RNA_property_identifier(userprop));
else
@@ -5081,7 +5086,7 @@ char *RNA_path_from_ID_to_struct(PointerRNA *ptr)
else
return NULL;
}
-
+
return ptrpath;
}
@@ -5133,7 +5138,7 @@ char *RNA_path_from_ID_to_property_index(PointerRNA *ptr, PropertyRNA *prop, int
if (!ptr->id.data || !ptr->data)
return NULL;
-
+
/* path from ID to the struct holding this property */
ptrpath = RNA_path_from_ID_to_struct(ptr);
@@ -5863,23 +5868,23 @@ char *RNA_pointer_as_string_id(bContext *C, PointerRNA *ptr)
{
DynStr *dynstr = BLI_dynstr_new();
char *cstring;
-
+
const char *propname;
int first_time = 1;
-
+
BLI_dynstr_append(dynstr, "{");
-
+
RNA_STRUCT_BEGIN (ptr, prop)
{
propname = RNA_property_identifier(prop);
-
+
if (STREQ(propname, "rna_type"))
continue;
-
+
if (first_time == 0)
BLI_dynstr_append(dynstr, ", ");
first_time = 0;
-
+
cstring = RNA_property_as_string(C, ptr, prop, -1, INT_MAX);
BLI_dynstr_appendf(dynstr, "\"%s\":%s", propname, cstring);
MEM_freeN(cstring);
@@ -5887,8 +5892,8 @@ char *RNA_pointer_as_string_id(bContext *C, PointerRNA *ptr)
RNA_STRUCT_END;
BLI_dynstr_append(dynstr, "}");
-
-
+
+
cstring = BLI_dynstr_get_cstring(dynstr);
BLI_dynstr_free(dynstr);
return cstring;
@@ -6041,7 +6046,7 @@ char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop, in
DynStr *dynstr = BLI_dynstr_new();
char *cstring;
-
+
/* see if we can coerce into a python type - PropertyType */
switch (type) {
@@ -6212,7 +6217,7 @@ char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop, in
BLI_dynstr_append(dynstr, cstring);
MEM_freeN(cstring);
}
-
+
RNA_property_collection_end(&collect_iter);
BLI_dynstr_append(dynstr, "]");
break;
@@ -6318,7 +6323,7 @@ ParameterList *RNA_parameter_list_create(ParameterList *parms, PointerRNA *UNUSE
data_alloc->array_tot = 0;
data_alloc->array = NULL;
}
-
+
if (!(parm->flag_parameter & PARM_REQUIRED) && !(parm->flag & PROP_DYNAMIC)) {
switch (parm->type) {
case PROP_BOOLEAN:
@@ -6747,7 +6752,7 @@ static int rna_function_parameter_parse(PointerRNA *ptr, PropertyRNA *prop, Prop
*((PointerRNA *)dest) = *((PointerRNA *)src);
break;
}
-
+
if (ptype != srna && !RNA_struct_is_a(srna, ptype)) {
fprintf(stderr, "%s.%s: wrong type for parameter %s, "
"an object of type %s was expected, passed an object of type %s\n",
@@ -6774,7 +6779,7 @@ static int rna_function_parameter_parse(PointerRNA *ptr, PropertyRNA *prop, Prop
lb = (ListBase *)src;
clb = (ListBase *)dest;
ptype = RNA_property_pointer_type(ptr, prop);
-
+
if (ptype != srna && !RNA_struct_is_a(srna, ptype)) {
fprintf(stderr, "%s.%s: wrong type for parameter %s, "
"a collection of objects of type %s was expected, "
@@ -7020,17 +7025,17 @@ bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
/* get the length of the array to work with */
len = RNA_property_array_length(ptr, prop);
-
+
/* get and set the default values as appropriate for the various types */
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
if (len) {
if (index == -1) {
int *tmparray = MEM_callocN(sizeof(int) * len, "reset_defaults - boolean");
-
+
RNA_property_boolean_get_default_array(ptr, prop, tmparray);
RNA_property_boolean_set_array(ptr, prop, tmparray);
-
+
MEM_freeN(tmparray);
}
else {
@@ -7047,10 +7052,10 @@ bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
if (len) {
if (index == -1) {
int *tmparray = MEM_callocN(sizeof(int) * len, "reset_defaults - int");
-
+
RNA_property_int_get_default_array(ptr, prop, tmparray);
RNA_property_int_set_array(ptr, prop, tmparray);
-
+
MEM_freeN(tmparray);
}
else {
@@ -7067,10 +7072,10 @@ bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
if (len) {
if (index == -1) {
float *tmparray = MEM_callocN(sizeof(float) * len, "reset_defaults - float");
-
+
RNA_property_float_get_default_array(ptr, prop, tmparray);
RNA_property_float_set_array(ptr, prop, tmparray);
-
+
MEM_freeN(tmparray);
}
else {
@@ -7089,7 +7094,7 @@ bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
RNA_property_enum_set(ptr, prop, value);
return true;
}
-
+
case PROP_STRING:
{
char *value = RNA_property_string_get_default_alloc(ptr, prop, NULL, 0);
@@ -7097,14 +7102,14 @@ bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
MEM_freeN(value);
return true;
}
-
+
case PROP_POINTER:
{
PointerRNA value = RNA_property_pointer_get_default(ptr, prop);
RNA_property_pointer_set(ptr, prop, value);
return true;
}
-
+
default:
/* FIXME: are there still any cases that haven't been handled? comment out "default" block to check :) */
return false;
diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c
index b06038a50e4..5b225b18a78 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -61,13 +61,13 @@ static void rna_ActionGroup_channels_next(CollectionPropertyIterator *iter)
ListBaseIterator *internal = &iter->internal.listbase;
FCurve *fcu = (FCurve *)internal->link;
bActionGroup *grp = fcu->grp;
-
+
/* only continue if the next F-Curve (if existent) belongs in the same group */
if ((fcu->next) && (fcu->next->grp == grp))
internal->link = (Link *)fcu->next;
else
internal->link = NULL;
-
+
iter->valid = (internal->link != NULL);
}
@@ -80,7 +80,7 @@ static void rna_Action_groups_remove(bAction *act, ReportList *reports, PointerR
{
bActionGroup *agrp = agrp_ptr->data;
FCurve *fcu, *fcn;
-
+
/* try to remove the F-Curve from the action */
if (BLI_remlink_safe(&act->groups, agrp) == false) {
BKE_reportf(reports, RPT_ERROR, "Action group '%s' not found in action '%s'", agrp->name, act->id.name + 2);
@@ -141,7 +141,7 @@ static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, PointerR
fcu->grp->name, act->id.name + 2);
return;
}
-
+
action_groups_remove_channel(act, fcu);
free_fcurve(fcu);
RNA_POINTER_INVALIDATE(fcu_ptr);
@@ -151,7 +151,7 @@ static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, PointerR
BKE_reportf(reports, RPT_ERROR, "F-Curve not found in action '%s'", act->id.name + 2);
return;
}
-
+
BLI_remlink(&act->curves, fcu);
free_fcurve(fcu);
RNA_POINTER_INVALIDATE(fcu_ptr);
@@ -227,7 +227,7 @@ int rna_Action_id_poll(PointerRNA *ptr, PointerRNA value)
{
ID *srcId = (ID *)ptr->id.data;
bAction *act = (bAction *)value.id.data;
-
+
if (act) {
/* there can still be actions that will have undefined id-root
* (i.e. floating "action-library" members) which we will not
@@ -238,7 +238,7 @@ int rna_Action_id_poll(PointerRNA *ptr, PointerRNA value)
else if (srcId)
return GS(srcId->name) == act->idroot;
}
-
+
return 0;
}
@@ -247,7 +247,7 @@ int rna_Action_actedit_assign_poll(PointerRNA *ptr, PointerRNA value)
{
SpaceAction *saction = (SpaceAction *)ptr->data;
bAction *act = (bAction *)value.id.data;
-
+
if (act) {
/* there can still be actions that will have undefined id-root
* (i.e. floating "action-library" members) which we will not
@@ -255,7 +255,7 @@ int rna_Action_actedit_assign_poll(PointerRNA *ptr, PointerRNA value)
*/
if (act->idroot == 0)
return 1;
-
+
if (saction) {
if (saction->mode == SACTCONT_ACTION) {
/* this is only Object-level for now... */
@@ -267,7 +267,7 @@ int rna_Action_actedit_assign_poll(PointerRNA *ptr, PointerRNA value)
}
}
}
-
+
return 0;
}
@@ -281,14 +281,14 @@ static void rna_def_dopesheet(BlenderRNA *brna)
srna = RNA_def_struct(brna, "DopeSheet", NULL);
RNA_def_struct_sdna(srna, "bDopeSheet");
RNA_def_struct_ui_text(srna, "Dope Sheet", "Settings for filtering the channels shown in animation editors");
-
+
/* Source of DopeSheet data */
/* XXX: make this obsolete? */
prop = RNA_def_property(srna, "source", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "ID");
RNA_def_property_ui_text(prop, "Source",
"ID-Block representing source data, usually ID_SCE (i.e. Scene)");
-
+
/* Show data-block filters */
prop = RNA_def_property(srna, "show_datablock_filters", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ADS_FLAG_SHOW_DBFILTERS);
@@ -296,20 +296,20 @@ static void rna_def_dopesheet(BlenderRNA *brna)
"Show options for whether channels related to certain types of data are included");
RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN, NULL);
-
+
/* General Filtering Settings */
prop = RNA_def_property(srna, "show_only_selected", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYSEL);
RNA_def_property_ui_text(prop, "Only Selected", "Only include channels relating to selected objects and data");
RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_hidden", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_INCL_HIDDEN);
RNA_def_property_ui_text(prop, "Display Hidden", "Include channels from objects/bone that are not visible");
RNA_def_property_ui_icon(prop, ICON_GHOST_ENABLED, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "use_datablock_sort", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ADS_FLAG_NO_DB_SORT);
RNA_def_property_ui_text(prop, "Sort Data-Blocks",
@@ -317,14 +317,14 @@ static void rna_def_dopesheet(BlenderRNA *brna)
"(disable to increase viewport speed)");
RNA_def_property_ui_icon(prop, ICON_SORTALPHA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
/* Debug Filtering Settings */
prop = RNA_def_property(srna, "show_only_errors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLY_ERRORS);
RNA_def_property_ui_text(prop, "Show Errors", "Only include F-Curves and drivers that are disabled or have errors");
RNA_def_property_ui_icon(prop, ICON_HELP, 0); /* XXX: this doesn't quite fit */
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
/* Object Collection Filtering Settings */
prop = RNA_def_property(srna, "show_only_collection_objects", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYOBGROUP);
@@ -332,13 +332,13 @@ static void rna_def_dopesheet(BlenderRNA *brna)
"Only include channels from objects in the specified collection");
RNA_def_property_ui_icon(prop, ICON_GROUP, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "filter_collection", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "filter_grp");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Filtering Collection", "Collection that included object should be a member of");
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
/* FCurve Display Name Search Settings */
prop = RNA_def_property(srna, "show_only_matching_fcurves", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_BY_FCU_NAME);
@@ -346,13 +346,13 @@ static void rna_def_dopesheet(BlenderRNA *brna)
"Only include F-Curves with names containing search text");
RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "filter_fcurve_name", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "searchstr");
RNA_def_property_ui_text(prop, "F-Curve Name Filter", "F-Curve live filtering string");
RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
/* NLA Name Search Settings (Shared with FCurve setting, but with different labels) */
prop = RNA_def_property(srna, "use_filter_text", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_BY_FCU_NAME);
@@ -360,13 +360,13 @@ static void rna_def_dopesheet(BlenderRNA *brna)
"Only include channels with names containing search text");
RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "filter_text", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "searchstr");
RNA_def_property_ui_text(prop, "Name Filter", "Live filtering string");
RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
/* Multi-word fuzzy search option for name/text filters */
prop = RNA_def_property(srna, "use_multi_word_filter", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ADS_FLAG_FUZZY_NAMES);
@@ -374,7 +374,7 @@ static void rna_def_dopesheet(BlenderRNA *brna)
"Perform fuzzy/multi-word matching (WARNING: May be slow)");
RNA_def_property_ui_icon(prop, ICON_SORTALPHA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
/* NLA Specific Settings */
prop = RNA_def_property(srna, "show_missing_nla", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NLA_NOACT);
@@ -382,21 +382,21 @@ static void rna_def_dopesheet(BlenderRNA *brna)
"Include animation data-blocks with no NLA data (NLA editor only)");
RNA_def_property_ui_icon(prop, ICON_ACTION, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
/* Summary Settings (DopeSheet editors only) */
prop = RNA_def_property(srna, "show_summary", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_SUMMARY);
RNA_def_property_ui_text(prop, "Display Summary", "Display an additional 'summary' line (Dope Sheet editors only)");
RNA_def_property_ui_icon(prop, ICON_BORDERMOVE, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_expanded_summary", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ADS_FLAG_SUMMARY_COLLAPSED);
RNA_def_property_ui_text(prop, "Collapse Summary",
"Collapse summary when shown, so all other channels get hidden (Dope Sheet editors only)");
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
-
+
+
/* General DataType Filtering Settings */
prop = RNA_def_property(srna, "show_transforms", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOOBJ);
@@ -404,98 +404,98 @@ static void rna_def_dopesheet(BlenderRNA *brna)
"Include visualization of object-level animation data (mostly transforms)");
RNA_def_property_ui_icon(prop, ICON_MANIPUL, 0); /* XXX? */
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_shapekeys", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSHAPEKEYS);
RNA_def_property_ui_text(prop, "Display Shapekeys", "Include visualization of shape key related animation data");
RNA_def_property_ui_icon(prop, ICON_SHAPEKEY_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_modifiers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMODIFIERS);
RNA_def_property_ui_text(prop, "Display Modifier Data",
"Include visualization of animation data related to data-blocks linked to modifiers");
RNA_def_property_ui_icon(prop, ICON_MODIFIER, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_meshes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMESH);
RNA_def_property_ui_text(prop, "Display Meshes", "Include visualization of mesh related animation data");
RNA_def_property_ui_icon(prop, ICON_MESH_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_lattices", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAT);
RNA_def_property_ui_text(prop, "Display Lattices", "Include visualization of lattice related animation data");
RNA_def_property_ui_icon(prop, ICON_LATTICE_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_cameras", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOCAM);
RNA_def_property_ui_text(prop, "Display Camera", "Include visualization of camera related animation data");
RNA_def_property_ui_icon(prop, ICON_CAMERA_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_materials", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMAT);
RNA_def_property_ui_text(prop, "Display Material", "Include visualization of material related animation data");
RNA_def_property_ui_icon(prop, ICON_MATERIAL_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_lamps", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAM);
RNA_def_property_ui_text(prop, "Display Lamp", "Include visualization of lamp related animation data");
RNA_def_property_ui_icon(prop, ICON_LAMP_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_linestyles", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLINESTYLE);
RNA_def_property_ui_text(prop, "Display Line Style", "Include visualization of Line Style related Animation data");
RNA_def_property_ui_icon(prop, ICON_LINE_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_textures", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOTEX);
RNA_def_property_ui_text(prop, "Display Texture", "Include visualization of texture related animation data");
RNA_def_property_ui_icon(prop, ICON_TEXTURE_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_curves", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOCUR);
RNA_def_property_ui_text(prop, "Display Curve", "Include visualization of curve related animation data");
RNA_def_property_ui_icon(prop, ICON_CURVE_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_worlds", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOWOR);
RNA_def_property_ui_text(prop, "Display World", "Include visualization of world related animation data");
RNA_def_property_ui_icon(prop, ICON_WORLD_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_scenes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSCE);
RNA_def_property_ui_text(prop, "Display Scene", "Include visualization of scene related animation data");
RNA_def_property_ui_icon(prop, ICON_SCENE_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_particles", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOPART);
RNA_def_property_ui_text(prop, "Display Particle", "Include visualization of particle related animation data");
RNA_def_property_ui_icon(prop, ICON_PARTICLE_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_metaballs", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMBA);
RNA_def_property_ui_text(prop, "Display Metaball", "Include visualization of metaball related animation data");
RNA_def_property_ui_icon(prop, ICON_META_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_armatures", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOARM);
RNA_def_property_ui_text(prop, "Display Armature", "Include visualization of armature related animation data");
RNA_def_property_ui_icon(prop, ICON_ARMATURE_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_nodes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NONTREE);
RNA_def_property_ui_text(prop, "Display Node", "Include visualization of node related animation data");
@@ -507,17 +507,17 @@ static void rna_def_dopesheet(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Display Speaker", "Include visualization of speaker related animation data");
RNA_def_property_ui_icon(prop, ICON_SPEAKER, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_gpencil", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOGPENCIL);
RNA_def_property_ui_text(prop, "Display Grease Pencil", "Include visualization of Grease Pencil related animation data and frames");
RNA_def_property_ui_icon(prop, ICON_GREASEPENCIL, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
/* GPencil Mode Settings */
prop = RNA_def_property(srna, "show_gpencil_3d_only", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_GP_3DONLY);
- RNA_def_property_ui_text(prop, "Active Scene Only",
+ RNA_def_property_ui_text(prop, "Active Scene Only",
"Only show Grease Pencil data-blocks used as part of the active scene");
RNA_def_property_ui_icon(prop, ICON_SCENE_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
@@ -527,16 +527,16 @@ static void rna_def_action_group(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "ActionGroup", NULL);
RNA_def_struct_sdna(srna, "bActionGroup");
RNA_def_struct_ui_text(srna, "Action Group", "Groups of F-Curves");
-
+
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "");
RNA_def_struct_name_property(srna, prop);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
/* WARNING: be very careful when working with this list, since the endpoint is not
* defined like a standard ListBase. Adding/removing channels from this list needs
* extreme care, otherwise the F-Curve list running through adjacent groups does
@@ -552,22 +552,22 @@ static void rna_def_action_group(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "FCurve");
RNA_def_property_collection_funcs(prop, NULL, "rna_ActionGroup_channels_next", NULL, NULL, NULL, NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Channels", "F-Curves in this group");
-
+
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_SELECTED);
RNA_def_property_ui_text(prop, "Select", "Action group is selected");
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
-
+
prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_PROTECTED);
RNA_def_property_ui_text(prop, "Lock", "Action group is locked");
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_EXPANDED);
RNA_def_property_ui_text(prop, "Expanded", "Action group is expanded");
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
/* color set */
rna_def_actionbone_group_common(srna, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
}
@@ -672,14 +672,14 @@ static void rna_def_action_pose_markers(BlenderRNA *brna, PropertyRNA *cprop)
parm = RNA_def_pointer(func, "marker", "TimelineMarker", "", "Timeline marker to remove");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
-
+
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "TimelineMarker");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_LIB_EXCEPTION);
RNA_def_property_pointer_funcs(prop, "rna_Action_active_pose_marker_get",
"rna_Action_active_pose_marker_set", NULL, NULL);
RNA_def_property_ui_text(prop, "Active Pose Marker", "Active pose marker for this action");
-
+
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "active_marker");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
@@ -692,25 +692,25 @@ static void rna_def_action(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "Action", "ID");
RNA_def_struct_sdna(srna, "bAction");
RNA_def_struct_ui_text(srna, "Action", "A collection of F-Curves for animation");
RNA_def_struct_ui_icon(srna, ICON_ACTION);
-
+
/* collections */
prop = RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "curves", NULL);
RNA_def_property_struct_type(prop, "FCurve");
RNA_def_property_ui_text(prop, "F-Curves", "The individual F-Curves that make up the action");
rna_def_action_fcurves(brna, prop);
-
+
prop = RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "groups", NULL);
RNA_def_property_struct_type(prop, "ActionGroup");
RNA_def_property_ui_text(prop, "Groups", "Convenient groupings of F-Curves");
rna_def_action_groups(brna, prop);
-
+
prop = RNA_def_property(srna, "pose_markers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "markers", NULL);
RNA_def_property_struct_type(prop, "TimelineMarker");
@@ -718,13 +718,13 @@ static void rna_def_action(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
RNA_def_property_ui_text(prop, "Pose Markers", "Markers specific to this action, for labeling poses");
rna_def_action_pose_markers(brna, prop);
-
+
/* properties */
prop = RNA_def_float_vector(srna, "frame_range", 2, NULL, 0, 0, "Frame Range",
"The final frame range of all F-Curves within this action", 0, 0);
RNA_def_property_float_funcs(prop, "rna_Action_frame_range_get", NULL, NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
+
/* special "type" limiter - should not really be edited in general,
* but is still available/editable in 'emergencies' */
prop = RNA_def_property(srna, "id_root", PROP_ENUM, PROP_NONE);
@@ -734,7 +734,7 @@ static void rna_def_action(BlenderRNA *brna)
"Type of ID block that action can be used on - "
"DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ID);
-
+
/* API calls */
RNA_api_action(srna);
}
diff --git a/source/blender/makesrna/intern/rna_action_api.c b/source/blender/makesrna/intern/rna_action_api.c
index fe429d8698b..3d5252b8cdc 100644
--- a/source/blender/makesrna/intern/rna_action_api.c
+++ b/source/blender/makesrna/intern/rna_action_api.c
@@ -53,7 +53,7 @@
void RNA_api_action(StructRNA *UNUSED(srna))
{
-
+
}
#endif
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index 84764187b62..d89e3e68492 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -85,9 +85,9 @@ const EnumPropertyItem rna_enum_keying_flag_items[] = {
static void rna_AnimData_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
ID *id = ptr->id.data;
-
- /* tag for refresh so that scheduled updates (e.g. action changed) will
- * get computed and reflected in the scene [#34869]
+
+ /* tag for refresh so that scheduled updates (e.g. action changed) will
+ * get computed and reflected in the scene [#34869]
*/
DEG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA);
}
@@ -95,7 +95,7 @@ static void rna_AnimData_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Point
static int rna_AnimData_action_editable(PointerRNA *ptr, const char **UNUSED(r_info))
{
AnimData *adt = (AnimData *)ptr->data;
-
+
/* active action is only editable when it is not a tweaking strip */
if ((adt->flag & ADT_NLA_EDIT_ON) || (adt->actstrip) || (adt->tmpact))
return 0;
@@ -107,10 +107,10 @@ static void rna_AnimData_action_set(PointerRNA *ptr, PointerRNA value)
{
ID *ownerId = (ID *)ptr->id.data;
AnimData *adt;
-
+
/* set action */
BKE_animdata_set_action(NULL, ownerId, value.data);
-
+
/* force action to get evaluated [#34869] */
adt = BKE_animdata_from_id(ownerId);
if (adt) {
@@ -157,16 +157,16 @@ static int RKS_POLL_rna_internal(KeyingSetInfo *ksi, bContext *C)
/* hook up arguments */
RNA_parameter_set_lookup(&list, "ksi", &ksi);
RNA_parameter_set_lookup(&list, "context", &C);
-
+
/* execute the function */
ksi->ext.call(C, &ptr, func, &list);
-
+
/* read the result */
RNA_parameter_get_lookup(&list, "ok", &ret);
ok = *(int *)ret;
}
RNA_parameter_list_free(&list);
-
+
return ok;
}
@@ -188,7 +188,7 @@ static void RKS_ITER_rna_internal(KeyingSetInfo *ksi, bContext *C, KeyingSet *ks
RNA_parameter_set_lookup(&list, "ksi", &ksi);
RNA_parameter_set_lookup(&list, "context", &C);
RNA_parameter_set_lookup(&list, "ks", &ks);
-
+
/* execute the function */
ksi->ext.call(C, &ptr, func, &list);
}
@@ -214,7 +214,7 @@ static void RKS_GEN_rna_internal(KeyingSetInfo *ksi, bContext *C, KeyingSet *ks,
RNA_parameter_set_lookup(&list, "context", &C);
RNA_parameter_set_lookup(&list, "ks", &ks);
RNA_parameter_set_lookup(&list, "data", data);
-
+
/* execute the function */
ksi->ext.call(C, &ptr, func, &list);
}
@@ -236,11 +236,11 @@ static void rna_KeyingSetInfo_unregister(Main *bmain, StructRNA *type)
if (ksi == NULL)
return;
-
+
/* free RNA data referencing this */
RNA_struct_free_extension(type, &ksi->ext);
RNA_struct_free(&BLENDER_RNA, type);
-
+
WM_main_add_notifier(NC_WINDOW, NULL);
/* unlink Blender-side data */
@@ -259,17 +259,17 @@ static StructRNA *rna_KeyingSetInfo_register(
/* setup dummy type info to store static properties in */
/* TODO: perhaps we want to get users to register as if they're using 'KeyingSet' directly instead? */
RNA_pointer_create(NULL, &RNA_KeyingSetInfo, &dummyksi, &dummyptr);
-
+
/* validate the python class */
if (validate(&dummyptr, data, have_function) != 0)
return NULL;
-
+
if (strlen(identifier) >= sizeof(dummyksi.idname)) {
BKE_reportf(reports, RPT_ERROR, "Registering keying set info class: '%s' is too long, maximum length is %d",
identifier, (int)sizeof(dummyksi.idname));
return NULL;
}
-
+
/* check if we have registered this info before, and remove it */
ksi = ANIM_keyingset_info_find_name(dummyksi.idname);
if (ksi && ksi->ext.srna) {
@@ -279,23 +279,23 @@ static StructRNA *rna_KeyingSetInfo_register(
/* create a new KeyingSetInfo type */
ksi = MEM_callocN(sizeof(KeyingSetInfo), "python keying set info");
memcpy(ksi, &dummyksi, sizeof(KeyingSetInfo));
-
+
/* set RNA-extensions info */
ksi->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, ksi->idname, &RNA_KeyingSetInfo);
ksi->ext.data = data;
ksi->ext.call = call;
ksi->ext.free = free;
RNA_struct_blender_type_set(ksi->ext.srna, ksi);
-
+
/* set callbacks */
/* NOTE: we really should have all of these... */
ksi->poll = (have_function[0]) ? RKS_POLL_rna_internal : NULL;
ksi->iter = (have_function[1]) ? RKS_ITER_rna_internal : NULL;
ksi->generate = (have_function[2]) ? RKS_GEN_rna_internal : NULL;
-
+
/* add and register with other info as needed */
ANIM_keyingset_info_register(ksi);
-
+
WM_main_add_notifier(NC_WINDOW, NULL);
/* return the struct-rna added */
@@ -319,7 +319,7 @@ static int rna_ksPath_id_editable(PointerRNA *ptr, const char **UNUSED(r_info))
static void rna_ksPath_id_type_set(PointerRNA *ptr, int value)
{
KS_Path *data = (KS_Path *)(ptr->data);
-
+
/* set the driver type, then clear the id-block if the type is invalid */
data->idtype = value;
if ((data->id) && (GS(data->id->name) != data->idtype))
@@ -339,7 +339,7 @@ static void rna_ksPath_RnaPath_get(PointerRNA *ptr, char *value)
static int rna_ksPath_RnaPath_length(PointerRNA *ptr)
{
KS_Path *ksp = (KS_Path *)ptr->data;
-
+
if (ksp->rna_path)
return strlen(ksp->rna_path);
else
@@ -352,7 +352,7 @@ static void rna_ksPath_RnaPath_set(PointerRNA *ptr, const char *value)
if (ksp->rna_path)
MEM_freeN(ksp->rna_path);
-
+
if (value[0])
ksp->rna_path = BLI_strdup(value);
else
@@ -364,20 +364,20 @@ static void rna_ksPath_RnaPath_set(PointerRNA *ptr, const char *value)
static void rna_KeyingSet_name_set(PointerRNA *ptr, const char *value)
{
KeyingSet *ks = (KeyingSet *)ptr->data;
-
+
/* update names of corresponding groups if name changes */
if (!STREQ(ks->name, value)) {
KS_Path *ksp;
-
+
for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
if ((ksp->groupmode == KSP_GROUP_KSNAME) && (ksp->id)) {
AnimData *adt = BKE_animdata_from_id(ksp->id);
-
+
/* TODO: NLA strips? */
if (adt && adt->action) {
bActionGroup *agrp;
-
- /* lazy check - should really find the F-Curve for the affected path and check its group
+
+ /* lazy check - should really find the F-Curve for the affected path and check its group
* but this way should be faster and work well for most cases, as long as there are no
* conflicts
*/
@@ -392,7 +392,7 @@ static void rna_KeyingSet_name_set(PointerRNA *ptr, const char *value)
}
}
}
-
+
/* finally, update name to new value */
BLI_strncpy(ks->name, value, sizeof(ks->name));
}
@@ -401,7 +401,7 @@ static void rna_KeyingSet_name_set(PointerRNA *ptr, const char *value)
static int rna_KeyingSet_active_ksPath_editable(PointerRNA *ptr, const char **UNUSED(r_info))
{
KeyingSet *ks = (KeyingSet *)ptr->data;
-
+
/* only editable if there are some paths to change to */
return (BLI_listbase_is_empty(&ks->paths) == false) ? PROP_EDITABLE : 0;
}
@@ -444,7 +444,7 @@ static PointerRNA rna_KeyingSet_typeinfo_get(PointerRNA *ptr)
{
KeyingSet *ks = (KeyingSet *)ptr->data;
KeyingSetInfo *ksi = NULL;
-
+
/* keying set info is only for builtin Keying Sets */
if ((ks->flag & KEYINGSET_ABSOLUTE) == 0)
ksi = ANIM_keyingset_info_find_name(ks->typeinfo);
@@ -458,13 +458,13 @@ static KS_Path *rna_KeyingSet_paths_add(KeyingSet *keyingset, ReportList *report
{
KS_Path *ksp = NULL;
short flag = 0;
-
+
/* special case when index = -1, we key the whole array (as with other places where index is used) */
if (index == -1) {
flag |= KSP_FLAG_WHOLE_ARRAY;
index = 0;
}
-
+
/* if data is valid, call the API function for this */
if (keyingset) {
ksp = BKE_keyingset_add_path(keyingset, id, group_name, rna_path, index, flag, group_method);
@@ -473,7 +473,7 @@ static KS_Path *rna_KeyingSet_paths_add(KeyingSet *keyingset, ReportList *report
else {
BKE_report(reports, RPT_ERROR, "Keying set path could not be added");
}
-
+
/* return added path */
return ksp;
}
@@ -502,13 +502,13 @@ static void rna_KeyingSet_paths_clear(KeyingSet *keyingset, ReportList *reports)
/* if data is valid, call the API function for this */
if (keyingset) {
KS_Path *ksp, *kspn;
-
+
/* free each path as we go to avoid looping twice */
for (ksp = keyingset->paths.first; ksp; ksp = kspn) {
kspn = ksp->next;
BKE_keyingset_free_path(keyingset, ksp);
}
-
+
/* reset the active path, since there aren't any left */
keyingset->active_path = 0;
}
@@ -567,7 +567,7 @@ static FCurve *rna_Driver_from_existing(AnimData *adt, bContext *C, FCurve *src_
else {
/* just make a copy of the existing one and add to self */
FCurve *new_fcu = copy_fcurve(src_driver);
-
+
/* XXX: if we impose any ordering on these someday, this will be problematic */
BLI_addtail(&adt->drivers, new_fcu);
return new_fcu;
@@ -619,39 +619,39 @@ bool rna_AnimaData_override_apply(
static void rna_def_common_keying_flags(StructRNA *srna, short reg)
{
PropertyRNA *prop;
-
+
/* override scene/userpref defaults? */
prop = RNA_def_property(srna, "use_insertkey_override_needed", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "keyingoverride", INSERTKEY_NEEDED);
- RNA_def_property_ui_text(prop, "Override Insert Keyframes Default- Only Needed",
+ RNA_def_property_ui_text(prop, "Override Insert Keyframes Default- Only Needed",
"Override default setting to only insert keyframes where they're needed in the relevant F-Curves");
if (reg) RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
-
+
prop = RNA_def_property(srna, "use_insertkey_override_visual", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "keyingoverride", INSERTKEY_MATRIX);
- RNA_def_property_ui_text(prop, "Override Insert Keyframes Default - Visual",
+ RNA_def_property_ui_text(prop, "Override Insert Keyframes Default - Visual",
"Override default setting to insert keyframes based on 'visual transforms'");
if (reg) RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
-
+
prop = RNA_def_property(srna, "use_insertkey_override_xyz_to_rgb", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "keyingoverride", INSERTKEY_XYZ2RGB);
RNA_def_property_ui_text(prop, "Override F-Curve Colors - XYZ to RGB",
"Override default setting to set color for newly added transformation F-Curves "
"(Location, Rotation, Scale) to be based on the transform axis");
if (reg) RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
-
-
+
+
/* value to override defaults with */
prop = RNA_def_property(srna, "use_insertkey_needed", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "keyingflag", INSERTKEY_NEEDED);
RNA_def_property_ui_text(prop, "Insert Keyframes - Only Needed", "Only insert keyframes where they're needed in the relevant F-Curves");
if (reg) RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
-
+
prop = RNA_def_property(srna, "use_insertkey_visual", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "keyingflag", INSERTKEY_MATRIX);
RNA_def_property_ui_text(prop, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'");
if (reg) RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
-
+
prop = RNA_def_property(srna, "use_insertkey_xyz_to_rgb", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "keyingflag", INSERTKEY_XYZ2RGB);
RNA_def_property_ui_text(prop, "F-Curve Colors - XYZ to RGB", "Color for newly added transformation F-Curves (Location, Rotation, Scale) is based on the transform axis");
@@ -674,36 +674,36 @@ static void rna_def_keyingset_info(BlenderRNA *brna)
PropertyRNA *prop;
FunctionRNA *func;
PropertyRNA *parm;
-
+
srna = RNA_def_struct(brna, "KeyingSetInfo", NULL);
RNA_def_struct_sdna(srna, "KeyingSetInfo");
RNA_def_struct_ui_text(srna, "Keying Set Info", "Callback function defines for builtin Keying Sets");
RNA_def_struct_refine_func(srna, "rna_KeyingSetInfo_refine");
RNA_def_struct_register_funcs(srna, "rna_KeyingSetInfo_register", "rna_KeyingSetInfo_unregister", NULL);
-
+
/* Properties --------------------- */
-
+
RNA_define_verify_sdna(0); /* not in sdna */
-
+
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "idname");
RNA_def_property_flag(prop, PROP_REGISTER);
RNA_def_property_ui_text(prop, "ID Name", KEYINGSET_IDNAME_DOC);
-
+
prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "name");
RNA_def_property_ui_text(prop, "UI Name", "");
RNA_def_struct_name_property(srna, prop);
RNA_def_property_flag(prop, PROP_REGISTER);
-
+
prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "description");
RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
RNA_def_property_ui_text(prop, "Description", "A short description of the keying set");
-
+
/* Regarding why we don't use rna_def_common_keying_flags() here:
- * - Using it would keep this case in sync with the other places
+ * - Using it would keep this case in sync with the other places
* where these options are exposed (which are optimized for being
* used in the UI).
* - Unlike all the other places, this case is used for defining
@@ -716,9 +716,9 @@ static void rna_def_keyingset_info(BlenderRNA *brna)
RNA_def_property_enum_items(prop, rna_enum_keying_flag_items);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
RNA_def_property_ui_text(prop, "Options", "Keying Set options to use when inserting keyframes");
-
+
RNA_define_verify_sdna(1);
-
+
/* Function Callbacks ------------- */
/* poll */
func = RNA_def_function(srna, "poll", NULL);
@@ -727,7 +727,7 @@ static void rna_def_keyingset_info(BlenderRNA *brna)
RNA_def_function_return(func, RNA_def_boolean(func, "ok", 1, "", ""));
parm = RNA_def_pointer(func, "context", "Context", "", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
+
/* iterator */
func = RNA_def_function(srna, "iterator", NULL);
RNA_def_function_ui_description(func, "Call generate() on the structs which have properties to be keyframed");
@@ -736,7 +736,7 @@ static void rna_def_keyingset_info(BlenderRNA *brna)
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_pointer(func, "ks", "KeyingSet", "", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
+
/* generate */
func = RNA_def_function(srna, "generate", NULL);
RNA_def_function_ui_description(func, "Add Paths to the Keying Set to keyframe the properties of the given data");
@@ -753,11 +753,11 @@ static void rna_def_keyingset_path(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "KeyingSetPath", NULL);
RNA_def_struct_sdna(srna, "KS_Path");
RNA_def_struct_ui_text(srna, "Keying Set Path", "Path to a setting for use in a Keying Set");
-
+
/* ID */
prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "ID");
@@ -768,7 +768,7 @@ static void rna_def_keyingset_path(BlenderRNA *brna)
"ID-Block that keyframes for Keying Set should be added to "
"(for Absolute Keying Sets only)");
RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_EDITED, NULL); /* XXX: maybe a bit too noisy */
-
+
prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "idtype");
RNA_def_property_enum_items(prop, rna_enum_id_type_items);
@@ -777,19 +777,19 @@ static void rna_def_keyingset_path(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ID);
RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_EDITED, NULL); /* XXX: maybe a bit too noisy */
-
+
/* Group */
prop = RNA_def_property(srna, "group", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Group Name", "Name of Action Group to assign setting(s) for this path to");
RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_EDITED, NULL); /* XXX: maybe a bit too noisy */
-
+
/* Grouping */
prop = RNA_def_property(srna, "group_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "groupmode");
RNA_def_property_enum_items(prop, rna_enum_keyingset_path_grouping_items);
RNA_def_property_ui_text(prop, "Grouping Method", "Method used to define which Group-name to use");
RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_EDITED, NULL); /* XXX: maybe a bit too noisy */
-
+
/* Path + Array Index */
prop = RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, "rna_ksPath_RnaPath_get", "rna_ksPath_RnaPath_length",
@@ -802,7 +802,7 @@ static void rna_def_keyingset_path(BlenderRNA *brna)
prop = RNA_def_property(srna, "array_index", PROP_INT, PROP_NONE);
RNA_def_property_ui_text(prop, "RNA Array Index", "Index to the specific setting if applicable");
RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_EDITED, NULL); /* XXX: maybe a bit too noisy */
-
+
/* Flags */
prop = RNA_def_property(srna, "use_entire_array", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", KSP_FLAG_WHOLE_ARRAY);
@@ -810,7 +810,7 @@ static void rna_def_keyingset_path(BlenderRNA *brna)
"When an 'array/vector' type is chosen (Location, Rotation, Color, etc.), "
"entire array is to be used");
RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_EDITED, NULL); /* XXX: maybe a bit too noisy */
-
+
/* Keyframing Settings */
rna_def_common_keying_flags(srna, 0);
}
@@ -823,7 +823,7 @@ static void rna_def_keyingset_paths(BlenderRNA *brna, PropertyRNA *cprop)
FunctionRNA *func;
PropertyRNA *parm;
-
+
PropertyRNA *prop;
RNA_def_property_srna(cprop, "KeyingSetPaths");
@@ -831,7 +831,7 @@ static void rna_def_keyingset_paths(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_struct_sdna(srna, "KeyingSet");
RNA_def_struct_ui_text(srna, "Keying set paths", "Collection of keying set paths");
-
+
/* Add Path */
func = RNA_def_function(srna, "add", "rna_KeyingSet_paths_add");
RNA_def_function_ui_description(func, "Add a new path for the Keying Set");
@@ -871,7 +871,7 @@ static void rna_def_keyingset_paths(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "clear", "rna_KeyingSet_paths_clear");
RNA_def_function_ui_description(func, "Remove all the paths from the Keying Set");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
-
+
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "KeyingSetPath");
RNA_def_property_flag(prop, PROP_EDITABLE);
@@ -891,17 +891,17 @@ static void rna_def_keyingset(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "KeyingSet", NULL);
RNA_def_struct_ui_text(srna, "Keying Set", "Settings that should be keyframed together");
-
+
/* Id/Label */
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "idname");
RNA_def_property_flag(prop, PROP_REGISTER);
RNA_def_property_ui_text(prop, "ID Name", KEYINGSET_IDNAME_DOC);
/* RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL); */ /* NOTE: disabled, as ID name shouldn't be editable */
-
+
prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "name");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_KeyingSet_name_set");
@@ -909,19 +909,19 @@ static void rna_def_keyingset(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_KEYINGSET);
RNA_def_struct_name_property(srna, prop);
RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL);
-
+
prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "description");
RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
RNA_def_property_ui_text(prop, "Description", "A short description of the keying set");
-
+
/* KeyingSetInfo (Type Info) for Builtin Sets only */
prop = RNA_def_property(srna, "type_info", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "KeyingSetInfo");
RNA_def_property_pointer_funcs(prop, "rna_KeyingSet_typeinfo_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Type Info", "Callback function defines for built-in Keying Sets");
-
+
/* Paths */
prop = RNA_def_property(srna, "paths", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "paths", NULL);
@@ -936,11 +936,11 @@ static void rna_def_keyingset(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Absolute",
"Keying Set defines specific paths/settings to be keyframed "
"(i.e. is not reliant on context info)");
-
+
/* Keyframing Flags */
rna_def_common_keying_flags(srna, 0);
-
-
+
+
/* Keying Set API */
RNA_api_keyingset(srna);
}
@@ -955,12 +955,12 @@ static void rna_api_animdata_nla_tracks(BlenderRNA *brna, PropertyRNA *cprop)
FunctionRNA *func;
PropertyRNA *prop;
-
+
RNA_def_property_srna(cprop, "NlaTracks");
srna = RNA_def_struct(brna, "NlaTracks", NULL);
RNA_def_struct_sdna(srna, "AnimData");
RNA_def_struct_ui_text(srna, "NLA Tracks", "Collection of NLA Tracks");
-
+
func = RNA_def_function(srna, "new", "rna_NlaTrack_new");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Add a new NLA Track");
@@ -968,7 +968,7 @@ static void rna_api_animdata_nla_tracks(BlenderRNA *brna, PropertyRNA *cprop)
/* return type */
parm = RNA_def_pointer(func, "track", "NlaTrack", "", "New NLA Track");
RNA_def_function_return(func, parm);
-
+
func = RNA_def_function(srna, "remove", "rna_NlaTrack_remove");
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Remove a NLA Track");
@@ -992,12 +992,12 @@ static void rna_api_animdata_drivers(BlenderRNA *brna, PropertyRNA *cprop)
FunctionRNA *func;
/* PropertyRNA *prop; */
-
+
RNA_def_property_srna(cprop, "AnimDataDrivers");
srna = RNA_def_struct(brna, "AnimDataDrivers", NULL);
RNA_def_struct_sdna(srna, "AnimData");
RNA_def_struct_ui_text(srna, "Drivers", "Collection of Driver F-Curves");
-
+
/* AnimData.drivers.from_existing(...) */
func = RNA_def_function(srna, "from_existing", "rna_Driver_from_existing");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
@@ -1006,7 +1006,7 @@ static void rna_api_animdata_drivers(BlenderRNA *brna, PropertyRNA *cprop)
/* return type */
parm = RNA_def_pointer(func, "driver", "FCurve", "", "New Driver F-Curve");
RNA_def_function_return(func, parm);
-
+
/* AnimData.drivers.find(...) */
func = RNA_def_function(srna, "find", "rna_Driver_find");
RNA_def_function_ui_description(func, "Find a driver F-Curve. Note that this function performs a linear scan "
@@ -1023,11 +1023,11 @@ static void rna_api_animdata_drivers(BlenderRNA *brna, PropertyRNA *cprop)
void rna_def_animdata_common(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "animation_data", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "adt");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_override_funcs(prop, NULL, NULL, "rna_AnimaData_override_apply");
RNA_def_property_ui_text(prop, "Animation Data", "Animation data for this data-block");
}
@@ -1036,11 +1036,11 @@ static void rna_def_animdata(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "AnimData", NULL);
RNA_def_struct_ui_text(srna, "Animation Data", "Animation data for data-block");
RNA_def_struct_ui_icon(srna, ICON_ANIM_DATA);
-
+
/* NLA */
prop = RNA_def_property(srna, "nla_tracks", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "nla_tracks", NULL);
@@ -1048,11 +1048,12 @@ static void rna_def_animdata(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "NLA Tracks", "NLA Tracks (i.e. Animation Layers)");
rna_api_animdata_nla_tracks(brna, prop);
-
+
/* Active Action */
prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE);
/* this flag as well as the dynamic test must be defined for this to be editable... */
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT | PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_pointer_funcs(prop, NULL, "rna_AnimData_action_set", NULL, "rna_Action_id_poll");
RNA_def_property_editable_func(prop, "rna_AnimData_action_editable");
RNA_def_property_ui_text(prop, "Action", "Active Action for this data-block");
@@ -1065,31 +1066,31 @@ static void rna_def_animdata(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Action Extrapolation",
"Action to take for gaps past the Active Action's range (when evaluating with NLA)");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL);
-
+
prop = RNA_def_property(srna, "action_blend_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "act_blendmode");
RNA_def_property_enum_items(prop, rna_enum_nla_mode_blend_items);
RNA_def_property_ui_text(prop, "Action Blending",
"Method used for combining Active Action's result with result of NLA stack");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL); /* this will do? */
-
- prop = RNA_def_property(srna, "action_influence", PROP_FLOAT, PROP_NONE);
+
+ prop = RNA_def_property(srna, "action_influence", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "act_influence");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Action Influence",
"Amount the Active Action contributes to the result of the NLA stack");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL); /* this will do? */
-
+
/* Drivers */
prop = RNA_def_property(srna, "drivers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "drivers", NULL);
RNA_def_property_struct_type(prop, "FCurve");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Drivers", "The Drivers/Expressions for this data-block");
-
+
rna_api_animdata_drivers(brna, prop);
-
+
/* General Settings */
prop = RNA_def_property(srna, "use_nla", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ADT_NLA_EVAL_OFF);
@@ -1108,7 +1109,7 @@ static void rna_def_animdata(BlenderRNA *brna)
void RNA_def_animation(BlenderRNA *brna)
{
rna_def_animdata(brna);
-
+
rna_def_keyingset(brna);
rna_def_keyingset_path(brna);
rna_def_keyingset_info(brna);
diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c
index 492659fdc2e..0b8f1acbd74 100644
--- a/source/blender/makesrna/intern/rna_animation_api.c
+++ b/source/blender/makesrna/intern/rna_animation_api.c
@@ -52,13 +52,13 @@ static void rna_KeyingSet_context_refresh(KeyingSet *ks, bContext *C, ReportList
{
/* TODO: enable access to providing a list of overrides (dsources)? */
int success = ANIM_validate_keyingset(C, NULL, ks);
-
+
if (success != 0) {
switch (success) {
case MODIFYKEY_INVALID_CONTEXT:
BKE_report(reports, RPT_ERROR, "Invalid context for keying set");
break;
-
+
case MODIFYKEY_MISSING_TYPEINFO:
BKE_report(reports, RPT_ERROR, "Incomplete built-in keying set, appears to be missing type info");
break;
@@ -72,7 +72,7 @@ void RNA_api_keyingset(StructRNA *srna)
{
FunctionRNA *func;
/*PropertyRNA *parm; */
-
+
/* validate relative Keying Set (used to ensure paths are ok for context) */
func = RNA_def_function(srna, "refresh", "rna_KeyingSet_context_refresh");
RNA_def_function_ui_description(func,
diff --git a/source/blender/makesrna/intern/rna_animviz.c b/source/blender/makesrna/intern/rna_animviz.c
index 2ba067629a9..94b4d60ca25 100644
--- a/source/blender/makesrna/intern/rna_animviz.c
+++ b/source/blender/makesrna/intern/rna_animviz.c
@@ -65,7 +65,7 @@ static PointerRNA rna_AnimViz_motion_paths_get(PointerRNA *ptr)
static void rna_AnimViz_ghost_start_frame_set(PointerRNA *ptr, int value)
{
bAnimVizSettings *data = (bAnimVizSettings *)ptr->data;
-
+
data->ghost_sf = value;
CLAMP(data->ghost_ef, data->ghost_sf, MAXFRAME / 2);
}
@@ -73,7 +73,7 @@ static void rna_AnimViz_ghost_start_frame_set(PointerRNA *ptr, int value)
static void rna_AnimViz_ghost_end_frame_set(PointerRNA *ptr, int value)
{
bAnimVizSettings *data = (bAnimVizSettings *)ptr->data;
-
+
data->ghost_ef = value;
CLAMP(data->ghost_sf, 1, data->ghost_ef);
}
@@ -81,7 +81,7 @@ static void rna_AnimViz_ghost_end_frame_set(PointerRNA *ptr, int value)
static void rna_AnimViz_path_start_frame_set(PointerRNA *ptr, int value)
{
bAnimVizSettings *data = (bAnimVizSettings *)ptr->data;
-
+
/* XXX: watchit! Path Start > MAXFRAME/2 could be a problem... */
data->path_sf = value;
CLAMP(data->path_ef, data->path_sf + 1, MAXFRAME / 2);
@@ -90,7 +90,7 @@ static void rna_AnimViz_path_start_frame_set(PointerRNA *ptr, int value)
static void rna_AnimViz_path_end_frame_set(PointerRNA *ptr, int value)
{
bAnimVizSettings *data = (bAnimVizSettings *)ptr->data;
-
+
data->path_ef = value;
CLAMP(data->path_sf, 1, data->path_ef - 1);
}
@@ -100,7 +100,7 @@ static void rna_AnimViz_path_end_frame_set(PointerRNA *ptr, int value)
void rna_def_motionpath_common(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "motion_path", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "mpath");
RNA_def_property_ui_text(prop, "Motion Path", "Motion Path for this element");
@@ -110,15 +110,15 @@ static void rna_def_animviz_motionpath_vert(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "MotionPathVert", NULL);
RNA_def_struct_sdna(srna, "bMotionPathVert");
RNA_def_struct_ui_text(srna, "Motion Path Cache Point", "Cached location on path");
-
+
prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_XYZ);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Coordinates", "");
-
+
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOTIONPATH_VERT_SEL);
RNA_def_property_ui_text(prop, "Select", "Path point is selected for editing");
@@ -128,28 +128,28 @@ static void rna_def_animviz_motion_path(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "MotionPath", NULL);
RNA_def_struct_sdna(srna, "bMotionPath");
RNA_def_struct_ui_text(srna, "Motion Path", "Cache of the worldspace positions of an element over a frame range");
-
+
/* Collections */
prop = RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "points", "length");
RNA_def_property_struct_type(prop, "MotionPathVert");
RNA_def_property_ui_text(prop, "Motion Path Points", "Cached positions per frame");
-
+
/* Playback Ranges */
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "start_frame");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Start Frame", "Starting frame of the stored range");
-
+
prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "end_frame");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "End Frame", "End frame of the stored range");
-
+
prop = RNA_def_property(srna, "length", PROP_INT, PROP_TIME);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Length", "Number of frames cached");
@@ -173,7 +173,7 @@ static void rna_def_animviz_motion_path(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* xxx */
RNA_def_property_ui_text(prop, "Use Bone Heads",
"For PoseBone paths, use the bone head location when calculating this path");
-
+
/* FIXME: Motion Paths are not currently editable... */
prop = RNA_def_property(srna, "is_modified", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOTIONPATH_FLAG_EDIT);
@@ -199,7 +199,7 @@ static void rna_def_animviz_ghosts(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem prop_type_items[] = {
{GHOST_TYPE_NONE, "NONE", 0, "No Ghosts", "Do not show any ghosts"},
{GHOST_TYPE_ACFRA, "CURRENT_FRAME", 0, "Around Current Frame", "Show ghosts from around the current frame"},
@@ -207,8 +207,8 @@ static void rna_def_animviz_ghosts(BlenderRNA *brna)
{GHOST_TYPE_KEYS, "KEYS", 0, "On Keyframes", "Show ghosts on keyframes"},
{0, NULL, 0, NULL, NULL}
};
-
-
+
+
srna = RNA_def_struct(brna, "AnimVizOnionSkinning", NULL);
RNA_def_struct_sdna(srna, "bAnimVizSettings");
RNA_def_struct_nested(brna, srna, "AnimViz");
@@ -220,21 +220,21 @@ static void rna_def_animviz_ghosts(BlenderRNA *brna)
RNA_def_property_enum_items(prop, prop_type_items);
RNA_def_property_ui_text(prop, "Type", "Method used for determining what ghosts get drawn");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
/* Settings */
prop = RNA_def_property(srna, "show_only_selected", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ghost_flag", GHOST_FLAG_ONLYSEL);
RNA_def_property_ui_text(prop, "On Selected Bones Only",
"For Pose-Mode drawing, only draw ghosts for selected bones");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
prop = RNA_def_property(srna, "frame_step", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "ghost_step");
RNA_def_property_range(prop, 1, 20);
RNA_def_property_ui_text(prop, "Frame Step",
"Number of frames between ghosts shown (not for 'On Keyframes' Onion-skinning method)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
/* Playback Ranges */
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "ghost_sf");
@@ -243,7 +243,7 @@ static void rna_def_animviz_ghosts(BlenderRNA *brna)
"Starting frame of range of Ghosts to display "
"(not for 'Around Current Frame' Onion-skinning method)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "ghost_ef");
RNA_def_property_int_funcs(prop, NULL, "rna_AnimViz_ghost_end_frame_set", NULL);
@@ -251,7 +251,7 @@ static void rna_def_animviz_ghosts(BlenderRNA *brna)
"End frame of range of Ghosts to display "
"(not for 'Around Current Frame' Onion-skinning method)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
/* Around Current Ranges */
prop = RNA_def_property(srna, "frame_before", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "ghost_bc");
@@ -260,7 +260,7 @@ static void rna_def_animviz_ghosts(BlenderRNA *brna)
"Number of frames to show before the current frame "
"(only for 'Around Current Frame' Onion-skinning method)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
prop = RNA_def_property(srna, "frame_after", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "ghost_ac");
RNA_def_property_range(prop, 0, 30);
@@ -274,63 +274,63 @@ static void rna_def_animviz_paths(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem prop_type_items[] = {
{MOTIONPATH_TYPE_ACFRA, "CURRENT_FRAME", 0, "Around Frame",
"Display Paths of poses within a fixed number of frames around the current frame"},
{MOTIONPATH_TYPE_RANGE, "RANGE", 0, "In Range", "Display Paths of poses within specified range"},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "AnimVizMotionPaths", NULL);
RNA_def_struct_sdna(srna, "bAnimVizSettings");
RNA_def_struct_nested(brna, srna, "AnimViz");
RNA_def_struct_ui_text(srna, "Motion Path Settings", "Motion Path settings for animation visualization");
-
+
/* Enums */
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "path_type");
RNA_def_property_enum_items(prop, prop_type_items);
RNA_def_property_ui_text(prop, "Paths Type", "Type of range to show for Motion Paths");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
prop = RNA_def_property(srna, "bake_location", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "path_bakeflag");
RNA_def_property_enum_items(prop, rna_enum_motionpath_bake_location_items);
RNA_def_property_ui_text(prop, "Bake Location", "When calculating Bone Paths, use Head or Tips");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
/* Settings */
prop = RNA_def_property(srna, "show_frame_numbers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "path_viewflag", MOTIONPATH_VIEW_FNUMS);
RNA_def_property_ui_text(prop, "Show Frame Numbers", "Show frame numbers on Motion Paths");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
prop = RNA_def_property(srna, "show_keyframe_highlight", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "path_viewflag", MOTIONPATH_VIEW_KFRAS);
RNA_def_property_ui_text(prop, "Highlight Keyframes", "Emphasize position of keyframes on Motion Paths");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
prop = RNA_def_property(srna, "show_keyframe_numbers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "path_viewflag", MOTIONPATH_VIEW_KFNOS);
RNA_def_property_ui_text(prop, "Show Keyframe Numbers", "Show frame numbers of Keyframes on Motion Paths");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
prop = RNA_def_property(srna, "show_keyframe_action_all", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "path_viewflag", MOTIONPATH_VIEW_KFACT);
RNA_def_property_ui_text(prop, "All Action Keyframes",
"For bone motion paths, search whole Action for keyframes instead of in group"
" with matching name only (is slower)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
prop = RNA_def_property(srna, "frame_step", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "path_step");
RNA_def_property_range(prop, 1, 100);
RNA_def_property_ui_text(prop, "Frame Step",
"Number of frames between paths shown (not for 'On Keyframes' Onion-skinning method)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
-
+
+
/* Playback Ranges */
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "path_sf");
@@ -339,7 +339,7 @@ static void rna_def_animviz_paths(BlenderRNA *brna)
"Starting frame of range of paths to display/calculate "
"(not for 'Around Current Frame' Onion-skinning method)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "path_ef");
RNA_def_property_int_funcs(prop, NULL, "rna_AnimViz_path_end_frame_set", NULL);
@@ -347,7 +347,7 @@ static void rna_def_animviz_paths(BlenderRNA *brna)
"End frame of range of paths to display/calculate "
"(not for 'Around Current Frame' Onion-skinning method)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
/* Around Current Ranges */
prop = RNA_def_property(srna, "frame_before", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "path_bc");
@@ -356,7 +356,7 @@ static void rna_def_animviz_paths(BlenderRNA *brna)
"Number of frames to show before the current frame "
"(only for 'Around Current Frame' Onion-skinning method)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
prop = RNA_def_property(srna, "frame_after", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "path_ac");
RNA_def_property_range(prop, 1, MAXFRAMEF / 2);
@@ -365,7 +365,7 @@ static void rna_def_animviz_paths(BlenderRNA *brna)
"(only for 'Around Current Frame' Onion-skinning method)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
-
+
/* Readonly Property - Do any motion paths exist/need updating? (Mainly for bone paths) */
prop = RNA_def_property(srna, "has_motion_paths", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "path_bakeflag", MOTIONPATH_BAKE_HAS_PATHS);
@@ -378,7 +378,7 @@ static void rna_def_animviz_paths(BlenderRNA *brna)
void rna_def_animviz_common(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "animation_visualization", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, NULL, "avs");
@@ -389,18 +389,18 @@ static void rna_def_animviz(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "AnimViz", NULL);
RNA_def_struct_sdna(srna, "bAnimVizSettings");
RNA_def_struct_ui_text(srna, "Animation Visualization", "Settings for the visualization of motion");
-
+
/* onion-skinning settings (nested struct) */
prop = RNA_def_property(srna, "onion_skin_frames", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "AnimVizOnionSkinning");
RNA_def_property_pointer_funcs(prop, "rna_AnimViz_onion_skinning_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Onion Skinning", "Onion Skinning (ghosting) settings for visualization");
-
+
/* motion path settings (nested struct) */
prop = RNA_def_property(srna, "motion_path", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
@@ -416,7 +416,7 @@ void RNA_def_animviz(BlenderRNA *brna)
rna_def_animviz(brna);
rna_def_animviz_ghosts(brna);
rna_def_animviz_paths(brna);
-
+
rna_def_animviz_motion_path(brna);
rna_def_animviz_motionpath_vert(brna);
}
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index 30c643388af..44a21e797f1 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -44,6 +44,7 @@
#ifdef RNA_RUNTIME
#include "BKE_context.h"
+#include "BKE_global.h"
#include "BKE_idprop.h"
#include "BKE_main.h"
@@ -72,13 +73,13 @@ static void rna_Armature_act_bone_set(PointerRNA *ptr, PointerRNA value)
else {
if (value.id.data != arm) {
Object *ob = (Object *)value.id.data;
-
+
if (GS(ob->id.name) != ID_OB || (ob->data != arm)) {
printf("ERROR: armature set active bone - new active doesn't come from this armature\n");
return;
}
}
-
+
arm->act_bone = value.data;
arm->act_bone->flag |= BONE_SELECTED;
}
@@ -147,7 +148,7 @@ static void rna_Armature_update_layers(Main *bmain, Scene *UNUSED(scene), Pointe
static void rna_Armature_redraw_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
ID *id = ptr->id.data;
-
+
DEG_id_tag_update(id, DEG_TAG_COPY_ON_WRITE);
WM_main_add_notifier(NC_GEOM | ND_DATA, id);
}
@@ -156,10 +157,10 @@ static void rna_Armature_redraw_data(Main *UNUSED(bmain), Scene *UNUSED(scene),
static void rna_Bone_update_renamed(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
ID *id = ptr->id.data;
-
+
/* redraw view */
WM_main_add_notifier(NC_GEOM | ND_DATA, id);
-
+
/* update animation channels */
WM_main_add_notifier(NC_ANIMATION | ND_ANIMCHAN, id);
}
@@ -167,7 +168,7 @@ static void rna_Bone_update_renamed(Main *UNUSED(bmain), Scene *UNUSED(scene), P
static void rna_Bone_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
ID *id = ptr->id.data;
-
+
/* 1) special updates for cases where rigs try to hook into armature drawing stuff
* e.g. Mask Modifier - 'Armature' option
* 2) tag armature for copy-on-write, so that selection status (set by addons)
@@ -176,25 +177,25 @@ static void rna_Bone_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po
if (id) {
if (GS(id->name) == ID_AR) {
bArmature *arm = (bArmature *)id;
-
+
if (arm->flag & ARM_HAS_VIZ_DEPS) {
DEG_id_tag_update(id, OB_RECALC_DATA);
}
-
+
DEG_id_tag_update(id, DEG_TAG_COPY_ON_WRITE);
}
else if (GS(id->name) == ID_OB) {
Object *ob = (Object *)id;
bArmature *arm = (bArmature *)ob->data;
-
+
if (arm->flag & ARM_HAS_VIZ_DEPS) {
DEG_id_tag_update(id, OB_RECALC_DATA);
}
-
+
DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
}
}
-
+
WM_main_add_notifier(NC_GEOM | ND_DATA, id);
/* spaces that show animation data of the selected bone need updating */
@@ -206,7 +207,7 @@ static char *rna_Bone_path(PointerRNA *ptr)
ID *id = ptr->id.data;
Bone *bone = (Bone *)ptr->data;
char name_esc[sizeof(bone->name) * 2];
-
+
BLI_strescape(name_esc, bone->name, sizeof(name_esc));
/* special exception for trying to get the path where ID-block is Object
@@ -217,7 +218,7 @@ static char *rna_Bone_path(PointerRNA *ptr)
return BLI_sprintfN("pose.bones[\"%s\"].bone", name_esc);
}
}
-
+
/* from armature... */
return BLI_sprintfN("bones[\"%s\"]", name_esc);
}
@@ -266,7 +267,7 @@ static void rna_bone_layer_set(int *layer, const int *values)
for (i = 0; i < 32; i++)
if (values[i])
tot++;
-
+
if (tot == 0)
return;
@@ -280,9 +281,9 @@ static void rna_Bone_layer_set(PointerRNA *ptr, const int *values)
{
bArmature *arm = (bArmature *)ptr->id.data;
Bone *bone = (Bone *)ptr->data;
-
+
rna_bone_layer_set(&bone->layer, values);
-
+
arm->layer_used = 0;
rna_Armature_layer_used_refresh(arm, &arm->bonebase);
}
@@ -296,7 +297,7 @@ static void rna_Armature_layer_set(PointerRNA *ptr, const int *values)
for (i = 0; i < 32; i++)
if (values[i])
tot++;
-
+
if (tot == 0)
return;
@@ -335,12 +336,12 @@ static void rna_EditBone_name_set(PointerRNA *ptr, const char *value)
bArmature *arm = (bArmature *)ptr->id.data;
EditBone *ebone = (EditBone *)ptr->data;
char oldname[sizeof(ebone->name)], newname[sizeof(ebone->name)];
-
+
/* need to be on the stack */
BLI_strncpy_utf8(newname, value, sizeof(ebone->name));
BLI_strncpy(oldname, ebone->name, sizeof(ebone->name));
-
- ED_armature_bone_rename(arm, oldname, newname);
+
+ ED_armature_bone_rename(G.main, arm, oldname, newname);
}
static void rna_Bone_name_set(PointerRNA *ptr, const char *value)
@@ -348,12 +349,12 @@ static void rna_Bone_name_set(PointerRNA *ptr, const char *value)
bArmature *arm = (bArmature *)ptr->id.data;
Bone *bone = (Bone *)ptr->data;
char oldname[sizeof(bone->name)], newname[sizeof(bone->name)];
-
+
/* need to be on the stack */
BLI_strncpy_utf8(newname, value, sizeof(bone->name));
BLI_strncpy(oldname, bone->name, sizeof(bone->name));
- ED_armature_bone_rename(arm, oldname, newname);
+ ED_armature_bone_rename(G.main, arm, oldname, newname);
}
static void rna_EditBone_layer_set(PointerRNA *ptr, const int values[])
@@ -414,7 +415,7 @@ static void rna_EditBone_parent_set(PointerRNA *ptr, PointerRNA value)
/* make sure this is a valid child */
if (parbone == ebone)
return;
-
+
for (pbone = parbone->parent; pbone; pbone = pbone->parent)
if (pbone == ebone)
return;
@@ -441,7 +442,7 @@ static void rna_Armature_editbone_transform_update(Main *bmain, Scene *scene, Po
bArmature *arm = (bArmature *)ptr->id.data;
EditBone *ebone = (EditBone *)ptr->data;
EditBone *child, *eboflip;
-
+
/* update our parent */
if (ebone->parent && ebone->flag & BONE_CONNECTED)
copy_v3_v3(ebone->parent->tail, ebone->head);
@@ -459,11 +460,11 @@ static void rna_Armature_editbone_transform_update(Main *bmain, Scene *scene, Po
eboflip->head[0] = -ebone->head[0];
eboflip->tail[0] = -ebone->tail[0];
-
+
/* update our parent */
if (eboflip->parent && eboflip->flag & BONE_CONNECTED)
copy_v3_v3(eboflip->parent->tail, eboflip->head);
-
+
/* update our children if necessary */
for (child = arm->edbo->first; child; child = child->next)
if (child->parent == eboflip && (child->flag & BONE_CONNECTED))
@@ -504,9 +505,9 @@ static int rna_Armature_is_editmode_get(PointerRNA *ptr)
return (arm->edbo != NULL);
}
-static void rna_Armature_transform(struct bArmature *arm, float *mat)
+static void rna_Armature_transform(struct bArmature *arm, Main *bmain, float *mat)
{
- ED_armature_transform(arm, (float (*)[4])mat, true);
+ ED_armature_transform(bmain, arm, (float (*)[4])mat, true);
}
#else
@@ -521,48 +522,48 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
else \
RNA_def_property_update(prop, 0, "rna_Armature_update_data"); \
} (void)0;
-
+
PropertyRNA *prop;
-
+
/* Roll In/Out */
prop = RNA_def_property(srna, "bbone_rollin", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "roll1");
RNA_def_property_range(prop, -M_PI * 2.0, M_PI * 2.0);
RNA_def_property_ui_text(prop, "Roll In", "Roll offset for the start of the B-Bone, adjusts twist");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
-
+
prop = RNA_def_property(srna, "bbone_rollout", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "roll2");
RNA_def_property_range(prop, -M_PI * 2.0, M_PI * 2.0);
RNA_def_property_ui_text(prop, "Roll Out", "Roll offset for the end of the B-Bone, adjusts twist");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
-
+
if (is_posebone == false) {
prop = RNA_def_property(srna, "use_endroll_as_inroll", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "Inherit End Roll", "Use Roll Out of parent bone as Roll In of its children");
RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_ADD_PARENT_END_ROLL);
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
}
-
+
/* Curve X/Y Offsets */
prop = RNA_def_property(srna, "bbone_curveinx", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "curveInX");
RNA_def_property_range(prop, -5.0f, 5.0f);
RNA_def_property_ui_text(prop, "In X", "X-axis handle offset for start of the B-Bone's curve, adjusts curvature");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
-
+
prop = RNA_def_property(srna, "bbone_curveiny", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "curveInY");
RNA_def_property_range(prop, -5.0f, 5.0f);
RNA_def_property_ui_text(prop, "In Y", "Y-axis handle offset for start of the B-Bone's curve, adjusts curvature");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
-
+
prop = RNA_def_property(srna, "bbone_curveoutx", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "curveOutX");
RNA_def_property_range(prop, -5.0f, 5.0f);
RNA_def_property_ui_text(prop, "Out X", "X-axis handle offset for end of the B-Bone's curve, adjusts curvature");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
-
+
prop = RNA_def_property(srna, "bbone_curveouty", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "curveOutY");
RNA_def_property_range(prop, -5.0f, 5.0f);
@@ -576,7 +577,7 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Ease In", "Length of first Bezier Handle (for B-Bones only)");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
-
+
prop = RNA_def_property(srna, "bbone_easeout", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ease2");
RNA_def_property_range(prop, -5.0f, 5.0f);
@@ -591,14 +592,14 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Scale In", "Scale factor for start of the B-Bone, adjusts thickness (for tapering effects)");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
-
+
prop = RNA_def_property(srna, "bbone_scaleout", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "scaleOut");
RNA_def_property_range(prop, 0.0f, 5.0f);
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Scale Out", "Scale factor for end of the B-Bone, adjusts thickness (for tapering effects)");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
-
+
#undef RNA_DEF_CURVEBONE_UPDATE
}
@@ -630,23 +631,23 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Connected", "When bone has a parent, bone's head is stuck to the parent's tail");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
-
+
prop = RNA_def_property(srna, "use_inherit_rotation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_HINGE);
RNA_def_property_ui_text(prop, "Inherit Rotation", "Bone inherits rotation or scale from parent bone");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
-
+
prop = RNA_def_property(srna, "use_envelope_multiply", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_MULT_VG_ENV);
RNA_def_property_ui_text(prop, "Multiply Vertex Group with Envelope",
"When deforming bone, multiply effects of Vertex Group weights with Envelope influence");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
-
+
prop = RNA_def_property(srna, "use_deform", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_DEFORM);
RNA_def_property_ui_text(prop, "Deform", "Enable Bone to deform geometry");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
-
+
prop = RNA_def_property(srna, "use_inherit_scale", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "Inherit Scale", "Bone inherits scaling from parent bone");
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_SCALE);
@@ -656,19 +657,19 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
RNA_def_property_ui_text(prop, "Local Location", "Bone location is set in local space");
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_LOCAL_LOCATION);
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
-
+
prop = RNA_def_property(srna, "use_relative_parent", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "Relative Parenting", "Object children will use relative transform, like deform");
RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_RELATIVE_PARENTING);
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
-
+
prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_DRAWWIRE);
RNA_def_property_ui_text(prop, "Draw Wire",
"Bone is always drawn as Wireframe regardless of viewport draw mode "
"(useful for non-obstructive custom bone shapes)");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
-
+
/* XXX: use_cyclic_offset is deprecated in 2.5. May/may not return */
prop = RNA_def_property(srna, "use_cyclic_offset", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_CYCLICOFFSET);
@@ -676,7 +677,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
"When bone doesn't have a parent, it receives cyclic offset effects (Deprecated)");
// "When bone doesn't have a parent, it receives cyclic offset effects");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
-
+
prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_UNSELECTABLE);
RNA_def_property_ui_text(prop, "Selectable", "Bone is able to be selected");
@@ -689,13 +690,13 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Envelope Deform Distance", "Bone deformation distance (for Envelope deform only)");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
-
+
prop = RNA_def_property(srna, "envelope_weight", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "weight");
RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Envelope Deform Weight", "Bone deformation weight (for Envelope deform only)");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
-
+
prop = RNA_def_property(srna, "head_radius", PROP_FLOAT, PROP_UNSIGNED);
if (editbone) RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
else RNA_def_property_update(prop, 0, "rna_Armature_update_data");
@@ -704,7 +705,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
/*RNA_def_property_range(prop, 0, 1000); */
RNA_def_property_ui_range(prop, 0.01, 100, 0.1, 3);
RNA_def_property_ui_text(prop, "Envelope Head Radius", "Radius of head of bone (for Envelope deform only)");
-
+
prop = RNA_def_property(srna, "tail_radius", PROP_FLOAT, PROP_UNSIGNED);
if (editbone) RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
else RNA_def_property_update(prop, 0, "rna_Armature_update_data");
@@ -713,20 +714,20 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
/*RNA_def_property_range(prop, 0, 1000); */
RNA_def_property_ui_range(prop, 0.01, 100, 0.1, 3);
RNA_def_property_ui_text(prop, "Envelope Tail Radius", "Radius of tail of bone (for Envelope deform only)");
-
+
/* b-bones deform settings */
prop = RNA_def_property(srna, "bbone_segments", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "segments");
RNA_def_property_range(prop, 1, 32);
RNA_def_property_ui_text(prop, "B-Bone Segments", "Number of subdivisions of bone (for B-Bones only)");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
-
+
prop = RNA_def_property(srna, "bbone_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "xwidth");
RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "B-Bone Display X Width", "B-Bone X size");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
-
+
prop = RNA_def_property(srna, "bbone_z", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "zwidth");
RNA_def_property_range(prop, 0.0f, 1000.0f);
@@ -739,13 +740,13 @@ static void rna_def_bone(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "Bone", NULL);
RNA_def_struct_ui_text(srna, "Bone", "Bone in an Armature data-block");
RNA_def_struct_ui_icon(srna, ICON_BONE_DATA);
RNA_def_struct_path_func(srna, "rna_Bone_path");
RNA_def_struct_idprops_func(srna, "rna_Bone_idprops");
-
+
/* pointers/collections */
/* parent (pointer) */
prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
@@ -754,7 +755,7 @@ static void rna_def_bone(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP);
RNA_def_property_ui_text(prop, "Parent", "Parent bone (in same Armature)");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
-
+
/* children (collection) */
prop = RNA_def_property(srna, "children", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "childbase", NULL);
@@ -778,13 +779,13 @@ static void rna_def_bone(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Select", "");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* XXX: review whether this could be used for interesting effects... */
RNA_def_property_update(prop, 0, "rna_Bone_select_update");
-
+
prop = RNA_def_property(srna, "select_head", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_ROOTSEL);
RNA_def_property_ui_text(prop, "Select Head", "");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
-
+
prop = RNA_def_property(srna, "select_tail", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_TIPSEL);
RNA_def_property_ui_text(prop, "Select Tail", "");
@@ -839,13 +840,13 @@ static void rna_def_edit_bone(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "EditBone", NULL);
RNA_def_struct_sdna(srna, "EditBone");
RNA_def_struct_idprops_func(srna, "rna_EditBone_idprops");
RNA_def_struct_ui_text(srna, "Edit Bone", "Editmode bone in an Armature data-block");
RNA_def_struct_ui_icon(srna, ICON_BONE_DATA);
-
+
RNA_define_verify_sdna(0); /* not in sdna */
prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
@@ -854,7 +855,7 @@ static void rna_def_edit_bone(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Parent", "Parent edit bone (in same Armature)");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
-
+
prop = RNA_def_property(srna, "roll", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "roll");
RNA_def_property_ui_range(prop, -M_PI * 2, M_PI * 2, 10, 2);
@@ -902,7 +903,7 @@ static void rna_def_edit_bone(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Head Select", "");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
-
+
prop = RNA_def_property(srna, "select_tail", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_TIPSEL);
RNA_def_property_ui_text(prop, "Tail Select", "");
@@ -1026,7 +1027,7 @@ static void rna_def_armature(BlenderRNA *brna)
{ARM_RESTPOS, "REST", 0, "Rest Position", "Show Armature in binding pose state (no posing possible)"},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "Armature", "ID");
RNA_def_struct_ui_text(srna, "Armature",
"Armature data-block containing a hierarchy of bones, usually used for rigging characters");
@@ -1034,13 +1035,14 @@ static void rna_def_armature(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "bArmature");
func = RNA_def_function(srna, "transform", "rna_Armature_transform");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
RNA_def_function_ui_description(func, "Transform armature bones by a matrix");
parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
/* Animation Data */
rna_def_animdata_common(srna);
-
+
/* Collections */
prop = RNA_def_property(srna, "bones", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "bonebase", NULL);
@@ -1062,7 +1064,7 @@ static void rna_def_armature(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Pose Position", "Show armature in binding pose or final posed state");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
-
+
prop = RNA_def_property(srna, "draw_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "drawtype");
RNA_def_property_enum_items(prop, prop_drawtype_items);
@@ -1088,7 +1090,7 @@ static void rna_def_armature(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, NULL, "rna_Armature_layer_set");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Armature_update_layers");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
-
+
/* layer protection */
prop = RNA_def_property(srna, "layers_protected", PROP_BOOLEAN, PROP_LAYER);
RNA_def_property_boolean_sdna(prop, NULL, "layer_protected", 1);
@@ -1097,47 +1099,47 @@ static void rna_def_armature(BlenderRNA *brna)
"Protected layers in Proxy Instances are restored to Proxy settings "
"on file reload and undo");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
-
+
/* flag */
prop = RNA_def_property(srna, "show_axes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DRAWAXES);
RNA_def_property_ui_text(prop, "Draw Axes", "Draw bone axes");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
-
+
prop = RNA_def_property(srna, "show_names", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DRAWNAMES);
RNA_def_property_ui_text(prop, "Draw Names", "Draw bone names");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
-
+
prop = RNA_def_property(srna, "use_deform_delay", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DELAYDEFORM);
RNA_def_property_ui_text(prop, "Delay Deform", "Don't deform children when manipulating bones in Pose Mode");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
-
+
prop = RNA_def_property(srna, "use_mirror_x", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_MIRROR_EDIT);
RNA_def_property_ui_text(prop, "X-Axis Mirror", "Apply changes to matching bone on opposite side of X-Axis");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
-
+
prop = RNA_def_property(srna, "use_auto_ik", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_AUTO_IK);
RNA_def_property_ui_text(prop, "Auto IK", "Add temporary IK constraints while grabbing bones in Pose Mode");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
-
+
prop = RNA_def_property(srna, "show_bone_custom_shapes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ARM_NO_CUSTOM);
RNA_def_property_ui_text(prop, "Draw Custom Bone Shapes", "Draw bones with their custom shapes");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
-
+
prop = RNA_def_property(srna, "show_group_colors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_COL_CUSTOM);
RNA_def_property_ui_text(prop, "Draw Bone Group Colors", "Draw bone group colors");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
-
+
/* XXX deprecated ....... old animviz for armatures only */
prop = RNA_def_property(srna, "show_only_ghost_selected", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_GHOST_ONLYSEL);
@@ -1157,7 +1159,7 @@ static void rna_def_armature(BlenderRNA *brna)
"(only for 'Around Current Frame' Onion-skinning method)");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
-
+
prop = RNA_def_property(srna, "ghost_size", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "ghostsize");
RNA_def_property_range(prop, 1, 20);
@@ -1165,7 +1167,7 @@ static void rna_def_armature(BlenderRNA *brna)
"Frame step for Ghosts (not for 'On Keyframes' Onion-skinning method)");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
-
+
prop = RNA_def_property(srna, "ghost_frame_start", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "ghostsf");
RNA_def_property_int_funcs(prop, NULL, "rna_Armature_ghost_start_frame_set", NULL);
@@ -1174,7 +1176,7 @@ static void rna_def_armature(BlenderRNA *brna)
"'Around Current Frame' Onion-skinning method)");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
-
+
prop = RNA_def_property(srna, "ghost_frame_end", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "ghostef");
RNA_def_property_int_funcs(prop, NULL, "rna_Armature_ghost_end_frame_set", NULL);
diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c
index 98ca58e0edd..413cb10422a 100644
--- a/source/blender/makesrna/intern/rna_boid.c
+++ b/source/blender/makesrna/intern/rna_boid.c
@@ -96,7 +96,7 @@ static void rna_Boids_reset(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRN
{
if (ptr->type == &RNA_ParticleSystem) {
ParticleSystem *psys = (ParticleSystem *)ptr->data;
-
+
psys->recalc = PSYS_RECALC_RESET;
DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
@@ -110,7 +110,7 @@ static void rna_Boids_reset_deps(Main *bmain, Scene *UNUSED(scene), PointerRNA *
{
if (ptr->type == &RNA_ParticleSystem) {
ParticleSystem *psys = (ParticleSystem *)ptr->data;
-
+
psys->recalc = PSYS_RECALC_RESET;
DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
@@ -211,10 +211,10 @@ static int particle_id_check(PointerRNA *ptr)
static char *rna_BoidSettings_path(PointerRNA *ptr)
{
BoidSettings *boids = (BoidSettings *)ptr->data;
-
+
if (particle_id_check(ptr)) {
ParticleSettings *part = (ParticleSettings *)ptr->id.data;
-
+
if (part->boids == boids)
return BLI_sprintfN("boids");
}
@@ -418,36 +418,36 @@ static void rna_def_boidrule(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
/* data */
srna = RNA_def_struct(brna, "BoidRule", NULL);
RNA_def_struct_ui_text(srna, "Boid Rule", "");
RNA_def_struct_refine_func(srna, "rna_BoidRule_refine");
RNA_def_struct_path_func(srna, "rna_BoidRule_path");
-
+
/* strings */
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "Boid rule name");
RNA_def_struct_name_property(srna, prop);
-
+
/* enums */
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, rna_enum_boidrule_type_items);
RNA_def_property_ui_text(prop, "Type", "");
-
+
/* flags */
prop = RNA_def_property(srna, "use_in_air", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BOIDRULE_IN_AIR);
RNA_def_property_ui_text(prop, "In Air", "Use rule when boid is flying");
RNA_def_property_update(prop, 0, "rna_Boids_reset");
-
+
prop = RNA_def_property(srna, "use_on_land", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BOIDRULE_ON_LAND);
RNA_def_property_ui_text(prop, "On Land", "Use rule when boid is on land");
RNA_def_property_update(prop, 0, "rna_Boids_reset");
-
+
/*prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); */
/*RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Expanded); */
/*RNA_def_property_ui_text(prop, "Expanded", "Set modifier expanded in the user interface"); */
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index d227d7a3dbe..75d05115006 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -111,7 +111,7 @@ const EnumPropertyItem rna_enum_brush_vertex_tool_items[] = {
{0, NULL, 0, NULL, NULL}
};
-
+
const EnumPropertyItem rna_enum_brush_image_tool_items[] = {
{PAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_TEXDRAW, "Draw", ""},
{PAINT_TOOL_SOFTEN, "SOFTEN", ICON_BRUSH_SOFTEN, "Soften", ""},
@@ -403,14 +403,14 @@ static void rna_Brush_sculpt_tool_update(Main *bmain, Scene *scene, PointerRNA *
rna_Brush_reset_icon(br, "sculpt");
rna_Brush_update(bmain, scene, ptr);
}
-
+
static void rna_Brush_vertex_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
rna_Brush_reset_icon(br, "vertex_paint");
rna_Brush_update(bmain, scene, ptr);
}
-
+
static void rna_Brush_imagepaint_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
@@ -656,8 +656,8 @@ static void rna_def_brush_texture_slot(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, "rna_TextureCapabilities_" \
#prop_name_ "_get", NULL); \
RNA_def_property_ui_text(prop, ui_name_, NULL)
-
-
+
+
srna = RNA_def_struct(brna, "BrushTextureSlot", "TextureSlot");
RNA_def_struct_sdna(srna, "MTex");
RNA_def_struct_ui_text(srna, "Brush Texture Slot", "Texture slot for textures in a Brush data-block");
@@ -707,10 +707,10 @@ static void rna_def_brush_texture_slot(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Random Angle", "Brush texture random angle");
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
-
+
TEXTURE_CAPABILITY(has_texture_angle_source, "Has Texture Angle Source");
TEXTURE_CAPABILITY(has_random_texture_angle, "Has Random Texture Angle");
- TEXTURE_CAPABILITY(has_texture_angle, "Has Texture Angle Source");
+ TEXTURE_CAPABILITY(has_texture_angle, "Has Texture Angle Source");
}
static void rna_def_sculpt_capabilities(BlenderRNA *brna)
@@ -813,7 +813,7 @@ static void rna_def_brush(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem prop_blend_items[] = {
{IMB_BLEND_MIX, "MIX", 0, "Mix", "Use mix blending mode while painting"},
{IMB_BLEND_ADD, "ADD", 0, "Add", "Use add blending mode while painting"},
@@ -841,7 +841,7 @@ static void rna_def_brush(BlenderRNA *brna)
{IMB_BLEND_COLOR, "COLOR", 0, "Color", "Use color blending mode while painting"},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem brush_sculpt_plane_items[] = {
{SCULPT_DISP_DIR_AREA, "AREA", 0, "Area Plane", ""},
{SCULPT_DISP_DIR_VIEW, "VIEW", 0, "View Plane", ""},
@@ -903,7 +903,7 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_enum_items(prop, rna_enum_brush_vertex_tool_items);
RNA_def_property_ui_text(prop, "Blending mode", "Brush blending mode");
RNA_def_property_update(prop, 0, "rna_Brush_vertex_tool_update");
-
+
prop = RNA_def_property(srna, "image_tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "imagepaint_tool");
RNA_def_property_enum_items(prop, rna_enum_brush_image_tool_items);
@@ -933,7 +933,7 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_enum_items(prop, brush_mask_tool_items);
RNA_def_property_ui_text(prop, "Mask Tool", "");
RNA_def_property_update(prop, 0, "rna_Brush_update");
-
+
/* number values */
prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL);
RNA_def_property_int_funcs(prop, NULL, "rna_Brush_set_size", NULL);
@@ -941,7 +941,7 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, -1);
RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels");
RNA_def_property_update(prop, 0, "rna_Brush_size_update");
-
+
prop = RNA_def_property(srna, "unprojected_radius", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_funcs(prop, NULL, "rna_Brush_set_unprojected_radius", NULL);
RNA_def_property_range(prop, 0.001, FLT_MAX);
@@ -985,14 +985,14 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_range(prop, 0.5, 0.99);
RNA_def_property_ui_text(prop, "Smooth Stroke Factor", "Higher values give a smoother stroke");
RNA_def_property_update(prop, 0, "rna_Brush_update");
-
+
prop = RNA_def_property(srna, "rate", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "rate");
RNA_def_property_range(prop, 0.0001f, 10000.0f);
RNA_def_property_ui_range(prop, 0.01f, 1.0f, 1, 3);
RNA_def_property_ui_text(prop, "Rate", "Interval between paints for Airbrush");
RNA_def_property_update(prop, 0, "rna_Brush_update");
-
+
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_float_sdna(prop, NULL, "rgb");
@@ -1149,20 +1149,20 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_AIRBRUSH);
RNA_def_property_ui_text(prop, "Airbrush", "Keep applying paint effect while holding mouse (spray)");
RNA_def_property_update(prop, 0, "rna_Brush_update");
-
+
prop = RNA_def_property(srna, "use_original_normal", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ORIGINAL_NORMAL);
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true);
RNA_def_property_ui_text(prop, "Original Normal",
"When locked keep using normal of surface where stroke was initiated");
RNA_def_property_update(prop, 0, "rna_Brush_update");
-
+
prop = RNA_def_property(srna, "use_pressure_strength", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ALPHA_PRESSURE);
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
RNA_def_property_ui_text(prop, "Strength Pressure", "Enable tablet pressure sensitivity for strength");
RNA_def_property_update(prop, 0, "rna_Brush_update");
-
+
prop = RNA_def_property(srna, "use_offset_pressure", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_OFFSET_PRESSURE);
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
@@ -1204,7 +1204,7 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
RNA_def_property_ui_text(prop, "Inverse Smooth Pressure", "Lighter pressure causes more smoothing to be applied");
RNA_def_property_update(prop, 0, "rna_Brush_update");
-
+
prop = RNA_def_property(srna, "use_relative_jitter", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BRUSH_ABSOLUTE_JITTER);
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true);
@@ -1260,7 +1260,7 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ACCUMULATE);
RNA_def_property_ui_text(prop, "Accumulate", "Accumulate stroke daubs on top of each other");
RNA_def_property_update(prop, 0, "rna_Brush_update");
-
+
prop = RNA_def_property(srna, "use_space_attenuation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SPACE_ATTEN);
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true);
@@ -1379,7 +1379,7 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "mtex");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Texture Slot", "");
-
+
prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "mtex.tex");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE);
@@ -1444,7 +1444,7 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Clone Image", "Image for clone tool");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_Brush_update");
-
+
prop = RNA_def_property(srna, "clone_alpha", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "clone.alpha");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -1524,7 +1524,7 @@ static void rna_def_operator_stroke_element(BlenderRNA *brna)
prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_flag(prop, PROP_IDPROPERTY);
RNA_def_property_ui_text(prop, "Time", "");
-
+
/* used for Grease Pencil sketching sessions */
prop = RNA_def_property(srna, "is_start", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_flag(prop, PROP_IDPROPERTY);
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index 3d1a1458102..0958011a7f0 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -89,11 +89,11 @@ static void rna_ClothSettings_bending_set(struct PointerRNA *ptr, float value)
static void rna_ClothSettings_max_bend_set(struct PointerRNA *ptr, float value)
{
ClothSimSettings *settings = (ClothSimSettings *)ptr->data;
-
+
/* check for clipping */
if (value < settings->bending)
value = settings->bending;
-
+
settings->max_bend = value;
}
@@ -111,11 +111,11 @@ static void rna_ClothSettings_structural_set(struct PointerRNA *ptr, float value
static void rna_ClothSettings_max_struct_set(struct PointerRNA *ptr, float value)
{
ClothSimSettings *settings = (ClothSimSettings *)ptr->data;
-
+
/* check for clipping */
if (value < settings->structural)
value = settings->structural;
-
+
settings->max_struct = value;
}
@@ -291,7 +291,7 @@ static void rna_def_cloth_solver_result(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem status_items[] = {
{BPH_SOLVER_SUCCESS, "SUCCESS", 0, "Success", "Computation was successful"},
{BPH_SOLVER_NUMERICAL_ISSUE, "NUMERICAL_ISSUE", 0, "Numerical Issue", "The provided data did not satisfy the prerequisites"},
@@ -299,49 +299,49 @@ static void rna_def_cloth_solver_result(BlenderRNA *brna)
{BPH_SOLVER_INVALID_INPUT, "INVALID_INPUT", 0, "Invalid Input", "The inputs are invalid, or the algorithm has been improperly called"},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "ClothSolverResult", NULL);
RNA_def_struct_ui_text(srna, "Solver Result", "Result of cloth solver iteration");
-
+
RNA_define_verify_sdna(0);
-
+
prop = RNA_def_property(srna, "status", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, status_items);
RNA_def_property_enum_sdna(prop, NULL, "status");
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Status", "Status of the solver iteration");
-
+
prop = RNA_def_property(srna, "max_error", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "max_error");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Maximum Error", "Maximum error during substeps");
-
+
prop = RNA_def_property(srna, "min_error", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "min_error");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Minimum Error", "Minimum error during substeps");
-
+
prop = RNA_def_property(srna, "avg_error", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "avg_error");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Average Error", "Average error during substeps");
-
+
prop = RNA_def_property(srna, "max_iterations", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "max_iterations");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Maximum Iterations", "Maximum iterations during substeps");
-
+
prop = RNA_def_property(srna, "min_iterations", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "min_iterations");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Minimum Iterations", "Minimum iterations during substeps");
-
+
prop = RNA_def_property(srna, "avg_iterations", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "avg_iterations");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Average Iterations", "Average iterations during substeps");
-
+
RNA_define_verify_sdna(1);
}
@@ -349,14 +349,14 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "ClothSettings", NULL);
RNA_def_struct_ui_text(srna, "Cloth Settings", "Cloth simulation settings for an object");
RNA_def_struct_sdna(srna, "ClothSimSettings");
RNA_def_struct_path_func(srna, "rna_ClothSettings_path");
-
+
/* goal */
-
+
prop = RNA_def_property(srna, "goal_min", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "mingoal");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -377,13 +377,13 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Goal Default",
"Default Goal (vertex target position) value, when no Vertex Group used");
RNA_def_property_update(prop, 0, "rna_cloth_update");
-
+
prop = RNA_def_property(srna, "goal_spring", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "goalspring");
RNA_def_property_range(prop, 0.0f, 0.999f);
RNA_def_property_ui_text(prop, "Goal Stiffness", "Goal (vertex target position) spring stiffness");
RNA_def_property_update(prop, 0, "rna_cloth_update");
-
+
prop = RNA_def_property(srna, "goal_friction", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "goalfrict");
RNA_def_property_range(prop, 0.0f, 50.0f);
@@ -426,7 +426,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
"rna_ClothSettings_mass_vgroup_set");
RNA_def_property_ui_text(prop, "Mass Vertex Group", "Vertex Group for pinning of vertices");
RNA_def_property_update(prop, 0, "rna_cloth_pinning_changed");
-
+
prop = RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION);
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, -100.0, 100.0);
@@ -510,14 +510,14 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
"If enabled, stiffness can be scaled along a weight painted vertex group");
RNA_def_property_update(prop, 0, "rna_cloth_update");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-
+
prop = RNA_def_property(srna, "spring_damping", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "Cdis");
RNA_def_property_range(prop, 0.0f, 50.0f);
RNA_def_property_ui_text(prop, "Spring Damping",
"Damping of cloth velocity (higher = more smooth, less jiggling)");
RNA_def_property_update(prop, 0, "rna_cloth_update");
-
+
prop = RNA_def_property(srna, "structural_stiffness", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "structural");
RNA_def_property_range(prop, 0.0f, 10000.0f);
@@ -650,7 +650,7 @@ static void rna_def_cloth_collision_settings(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "ClothCollisionSettings", NULL);
RNA_def_struct_ui_text(srna, "Cloth Collision Settings",
"Cloth simulation settings for self collision and collision with other objects");
@@ -678,7 +678,7 @@ static void rna_def_cloth_collision_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Repulsion Distance",
"Maximum distance to apply repulsion force, must be greater than minimum distance");
RNA_def_property_update(prop, 0, "rna_cloth_update");
-
+
prop = RNA_def_property(srna, "distance_min", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "epsilon");
RNA_def_property_range(prop, 0.001f, 1.0f);
@@ -712,13 +712,13 @@ static void rna_def_cloth_collision_settings(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_COLLSETTINGS_FLAG_SELF);
RNA_def_property_ui_text(prop, "Enable Self Collision", "Enable self collisions");
RNA_def_property_update(prop, 0, "rna_cloth_update");
-
+
prop = RNA_def_property(srna, "self_distance_min", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "selfepsilon");
RNA_def_property_range(prop, 0.5f, 1.0f);
RNA_def_property_ui_text(prop, "Self Minimum Distance", "0.5 means no distance at all, 1.0 is maximum distance");
RNA_def_property_update(prop, 0, "rna_cloth_update");
-
+
prop = RNA_def_property(srna, "self_friction", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0f, 80.0f);
RNA_def_property_ui_text(prop, "Self Friction", "Friction/damping with self contact");
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index f895cfbbf0c..99fa532452f 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -75,7 +75,7 @@ static int rna_CurveMapping_curves_length(PointerRNA *ptr)
for (len = 0; len < CM_TOT; len++)
if (!cumap->cm[len].curve)
break;
-
+
return len;
}
@@ -154,11 +154,11 @@ static void rna_CurveMapping_clipmaxy_range(PointerRNA *ptr, float *min, float *
static char *rna_ColorRamp_path(PointerRNA *ptr)
{
char *path = NULL;
-
+
/* handle the cases where a single data-block may have 2 ramp types */
if (ptr->id.data) {
ID *id = ptr->id.data;
-
+
switch (GS(id->name)) {
case ID_NT:
{
@@ -166,7 +166,7 @@ static char *rna_ColorRamp_path(PointerRNA *ptr)
bNode *node;
PointerRNA node_ptr;
char *node_path;
-
+
for (node = ntree->nodes.first; node; node = node->next) {
if (ELEM(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
if (node->storage == ptr->data) {
@@ -182,14 +182,14 @@ static char *rna_ColorRamp_path(PointerRNA *ptr)
}
break;
}
-
+
case ID_LS:
{
/* may be NULL */
path = BKE_linestyle_path_to_color_ramp((FreestyleLineStyle *)id, (ColorBand *)ptr->data);
break;
}
-
+
default:
/* everything else just uses 'color_ramp' */
path = BLI_strdup("color_ramp");
@@ -200,7 +200,7 @@ static char *rna_ColorRamp_path(PointerRNA *ptr)
/* everything else just uses 'color_ramp' */
path = BLI_strdup("color_ramp");
}
-
+
return path;
}
@@ -210,7 +210,7 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr)
PropertyRNA *prop;
char *path = NULL;
int index;
-
+
/* helper macro for use here to try and get the path
* - this calls the standard code for getting a path to a texture...
*/
@@ -232,13 +232,13 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr)
/* FIXME: this is a very slow way to do it, but it will have to suffice... */
if (ptr->id.data) {
ID *id = ptr->id.data;
-
+
switch (GS(id->name)) {
case ID_NT:
{
bNodeTree *ntree = (bNodeTree *)id;
bNode *node;
-
+
for (node = ntree->nodes.first; node; node = node->next) {
if (ELEM(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
RNA_pointer_create(id, &RNA_ColorRamp, node->storage, &ramp_ptr);
@@ -272,10 +272,10 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr)
}
}
}
-
+
/* cleanup the macro we defined */
#undef COLRAMP_GETPATH
-
+
return path;
}
@@ -283,12 +283,12 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *
{
if (ptr->id.data) {
ID *id = ptr->id.data;
-
+
switch (GS(id->name)) {
case ID_MA:
{
Material *ma = ptr->id.data;
-
+
DEG_id_tag_update(&ma->id, 0);
WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, ma);
break;
@@ -323,7 +323,7 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *
case ID_PA:
{
ParticleSettings *part = ptr->id.data;
-
+
DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_REDO);
WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, part);
}
@@ -548,7 +548,7 @@ static const EnumPropertyItem *rna_ColorManagedColorspaceSettings_colorspace_ite
return items;
}
-static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
ID *id = ptr->id.data;
@@ -557,7 +557,7 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain)
DEG_id_tag_update(&ima->id, 0);
- BKE_image_signal(ima, NULL, IMA_SIGNAL_COLORMANAGE);
+ BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE);
WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id);
WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id);
@@ -565,7 +565,7 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain)
else if (GS(id->name) == ID_MC) {
MovieClip *clip = (MovieClip *) id;
- BKE_movieclip_reload(clip);
+ BKE_movieclip_reload(bmain, clip);
/* all sequencers for now, we don't know which scenes are using this clip as a strip */
BKE_sequencer_cache_cleanup();
@@ -761,7 +761,7 @@ static void rna_def_curvemapping(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "CurveMapping",
"Curve mapping to map color, vector and scalar values to other values using "
"a user defined curve");
-
+
prop = RNA_def_property(srna, "use_clip", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CUMA_DO_CLIP);
RNA_def_property_ui_text(prop, "Clip", "Force the curve view to fit a defined boundary");
@@ -828,7 +828,7 @@ static void rna_def_color_ramp_element(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "CBData");
RNA_def_struct_path_func(srna, "rna_ColorRampElement_path");
RNA_def_struct_ui_text(srna, "Color Ramp Element", "Element defining a color at a position in the color ramp");
-
+
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "r");
RNA_def_property_array(prop, 4);
@@ -893,7 +893,7 @@ static void rna_def_color_ramp(BlenderRNA *brna)
{COLBAND_INTERP_CONSTANT, "CONSTANT", 0, "Constant", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem prop_mode_items[] = {
{COLBAND_BLEND_RGB, "RGB", 0, "RGB", ""},
{COLBAND_BLEND_HSV, "HSV", 0, "HSV", ""},
@@ -913,7 +913,7 @@ static void rna_def_color_ramp(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "ColorBand");
RNA_def_struct_path_func(srna, "rna_ColorRamp_path");
RNA_def_struct_ui_text(srna, "Color Ramp", "Color ramp mapping a scalar value to a color");
-
+
prop = RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_COLOR);
RNA_def_property_collection_sdna(prop, NULL, "data", "tot");
RNA_def_property_struct_type(prop, "ColorRampElement");
@@ -948,7 +948,7 @@ static void rna_def_color_ramp(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Total", "Total number of elements");
RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
#endif
-
+
func = RNA_def_function(srna, "evaluate", "rna_ColorRamp_eval");
RNA_def_function_ui_description(func, "Evaluate ColorRamp");
parm = RNA_def_float(func, "position", 1.0f, 0.0f, 1.0f, "Position", "Evaluate ColorRamp at position", 0.0f, 1.0f);
@@ -964,7 +964,7 @@ static void rna_def_histogram(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem prop_mode_items[] = {
{HISTO_MODE_LUMA, "LUMA", 0, "Luma", "Luma"},
{HISTO_MODE_RGB, "RGB", 0, "RGB", "Red Green Blue"},
@@ -977,7 +977,7 @@ static void rna_def_histogram(BlenderRNA *brna)
srna = RNA_def_struct(brna, "Histogram", NULL);
RNA_def_struct_ui_text(srna, "Histogram", "Statistical view of the levels of color in an image");
-
+
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "mode");
RNA_def_property_enum_items(prop, prop_mode_items);
@@ -1006,12 +1006,12 @@ static void rna_def_scopes(BlenderRNA *brna)
srna = RNA_def_struct(brna, "Scopes", NULL);
RNA_def_struct_ui_text(srna, "Scopes", "Scopes for statistical view of an image");
-
+
prop = RNA_def_property(srna, "use_full_resolution", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, "Scopes", "sample_full", 1);
RNA_def_property_ui_text(prop, "Full Sample", "Sample every pixel of the image");
RNA_def_property_update(prop, 0, "rna_Scopes_update");
-
+
prop = RNA_def_property(srna, "accuracy", PROP_FLOAT, PROP_PERCENTAGE);
RNA_def_property_float_sdna(prop, "Scopes", "accuracy");
RNA_def_property_range(prop, 0.0, 100.0);
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index f964550e30d..a01f2afa26e 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -52,59 +52,59 @@ const EnumPropertyItem rna_enum_constraint_type_items[] = {
{CONSTRAINT_TYPE_FOLLOWTRACK, "FOLLOW_TRACK", ICON_CONSTRAINT_DATA, "Follow Track", ""},
{CONSTRAINT_TYPE_OBJECTSOLVER, "OBJECT_SOLVER", ICON_CONSTRAINT_DATA, "Object Solver", ""},
{0, "", 0, N_("Transform"), ""},
- {CONSTRAINT_TYPE_LOCLIKE, "COPY_LOCATION", ICON_CONSTRAINT_DATA, "Copy Location",
+ {CONSTRAINT_TYPE_LOCLIKE, "COPY_LOCATION", ICON_CONSTRAINT_DATA, "Copy Location",
"Copy the location of a target (with an optional offset), so that they move together"},
- {CONSTRAINT_TYPE_ROTLIKE, "COPY_ROTATION", ICON_CONSTRAINT_DATA, "Copy Rotation",
+ {CONSTRAINT_TYPE_ROTLIKE, "COPY_ROTATION", ICON_CONSTRAINT_DATA, "Copy Rotation",
"Copy the rotation of a target (with an optional offset), so that they rotate together"},
- {CONSTRAINT_TYPE_SIZELIKE, "COPY_SCALE", ICON_CONSTRAINT_DATA, "Copy Scale",
+ {CONSTRAINT_TYPE_SIZELIKE, "COPY_SCALE", ICON_CONSTRAINT_DATA, "Copy Scale",
"Copy the scale factors of a target (with an optional offset), so that they are scaled by the same amount"},
- {CONSTRAINT_TYPE_TRANSLIKE, "COPY_TRANSFORMS", ICON_CONSTRAINT_DATA, "Copy Transforms",
+ {CONSTRAINT_TYPE_TRANSLIKE, "COPY_TRANSFORMS", ICON_CONSTRAINT_DATA, "Copy Transforms",
"Copy all the transformations of a target, so that they move together"},
- {CONSTRAINT_TYPE_DISTLIMIT, "LIMIT_DISTANCE", ICON_CONSTRAINT_DATA, "Limit Distance",
+ {CONSTRAINT_TYPE_DISTLIMIT, "LIMIT_DISTANCE", ICON_CONSTRAINT_DATA, "Limit Distance",
"Restrict movements to within a certain distance of a target (at the time of constraint evaluation only)"},
- {CONSTRAINT_TYPE_LOCLIMIT, "LIMIT_LOCATION", ICON_CONSTRAINT_DATA, "Limit Location",
+ {CONSTRAINT_TYPE_LOCLIMIT, "LIMIT_LOCATION", ICON_CONSTRAINT_DATA, "Limit Location",
"Restrict movement along each axis within given ranges"},
- {CONSTRAINT_TYPE_ROTLIMIT, "LIMIT_ROTATION", ICON_CONSTRAINT_DATA, "Limit Rotation",
+ {CONSTRAINT_TYPE_ROTLIMIT, "LIMIT_ROTATION", ICON_CONSTRAINT_DATA, "Limit Rotation",
"Restrict rotation along each axis within given ranges"},
- {CONSTRAINT_TYPE_SIZELIMIT, "LIMIT_SCALE", ICON_CONSTRAINT_DATA, "Limit Scale",
+ {CONSTRAINT_TYPE_SIZELIMIT, "LIMIT_SCALE", ICON_CONSTRAINT_DATA, "Limit Scale",
"Restrict scaling along each axis with given ranges"},
- {CONSTRAINT_TYPE_SAMEVOL, "MAINTAIN_VOLUME", ICON_CONSTRAINT_DATA, "Maintain Volume",
+ {CONSTRAINT_TYPE_SAMEVOL, "MAINTAIN_VOLUME", ICON_CONSTRAINT_DATA, "Maintain Volume",
"Compensate for scaling one axis by applying suitable scaling to the other two axes"},
- {CONSTRAINT_TYPE_TRANSFORM, "TRANSFORM", ICON_CONSTRAINT_DATA, "Transformation",
+ {CONSTRAINT_TYPE_TRANSFORM, "TRANSFORM", ICON_CONSTRAINT_DATA, "Transformation",
"Use one transform property from target to control another (or same) property on owner"},
{CONSTRAINT_TYPE_TRANSFORM_CACHE, "TRANSFORM_CACHE", ICON_CONSTRAINT_DATA, "Transform Cache",
"Look up the transformation matrix from an external file"},
{0, "", 0, N_("Tracking"), ""},
- {CONSTRAINT_TYPE_CLAMPTO, "CLAMP_TO", ICON_CONSTRAINT_DATA, "Clamp To",
+ {CONSTRAINT_TYPE_CLAMPTO, "CLAMP_TO", ICON_CONSTRAINT_DATA, "Clamp To",
"Restrict movements to lie along a curve by remapping location along curve's longest axis"},
{CONSTRAINT_TYPE_DAMPTRACK, "DAMPED_TRACK", ICON_CONSTRAINT_DATA, "Damped Track",
"Point towards a target by performing the smallest rotation necessary"},
- {CONSTRAINT_TYPE_KINEMATIC, "IK", ICON_CONSTRAINT_DATA, "Inverse Kinematics",
+ {CONSTRAINT_TYPE_KINEMATIC, "IK", ICON_CONSTRAINT_DATA, "Inverse Kinematics",
"Control a chain of bones by specifying the endpoint target (Bones only)"},
{CONSTRAINT_TYPE_LOCKTRACK, "LOCKED_TRACK", ICON_CONSTRAINT_DATA, "Locked Track",
"Rotate around the specified ('locked') axis to point towards a target"},
- {CONSTRAINT_TYPE_SPLINEIK, "SPLINE_IK", ICON_CONSTRAINT_DATA, "Spline IK",
+ {CONSTRAINT_TYPE_SPLINEIK, "SPLINE_IK", ICON_CONSTRAINT_DATA, "Spline IK",
"Align chain of bones along a curve (Bones only)"},
- {CONSTRAINT_TYPE_STRETCHTO, "STRETCH_TO", ICON_CONSTRAINT_DATA, "Stretch To",
+ {CONSTRAINT_TYPE_STRETCHTO, "STRETCH_TO", ICON_CONSTRAINT_DATA, "Stretch To",
"Stretch along Y-Axis to point towards a target"},
{CONSTRAINT_TYPE_TRACKTO, "TRACK_TO", ICON_CONSTRAINT_DATA, "Track To",
"Legacy tracking constraint prone to twisting artifacts"},
{0, "", 0, N_("Relationship"), ""},
- {CONSTRAINT_TYPE_ACTION, "ACTION", ICON_CONSTRAINT_DATA, "Action",
+ {CONSTRAINT_TYPE_ACTION, "ACTION", ICON_CONSTRAINT_DATA, "Action",
"Use transform property of target to look up pose for owner from an Action"},
- {CONSTRAINT_TYPE_CHILDOF, "CHILD_OF", ICON_CONSTRAINT_DATA, "Child Of",
+ {CONSTRAINT_TYPE_CHILDOF, "CHILD_OF", ICON_CONSTRAINT_DATA, "Child Of",
"Make target the 'detachable' parent of owner"},
- {CONSTRAINT_TYPE_MINMAX, "FLOOR", ICON_CONSTRAINT_DATA, "Floor",
+ {CONSTRAINT_TYPE_MINMAX, "FLOOR", ICON_CONSTRAINT_DATA, "Floor",
"Use position (and optionally rotation) of target to define a 'wall' or 'floor' that the owner can not cross"},
- {CONSTRAINT_TYPE_FOLLOWPATH, "FOLLOW_PATH", ICON_CONSTRAINT_DATA, "Follow Path",
+ {CONSTRAINT_TYPE_FOLLOWPATH, "FOLLOW_PATH", ICON_CONSTRAINT_DATA, "Follow Path",
"Use to animate an object/bone following a path"},
- {CONSTRAINT_TYPE_PIVOT, "PIVOT", ICON_CONSTRAINT_DATA, "Pivot",
+ {CONSTRAINT_TYPE_PIVOT, "PIVOT", ICON_CONSTRAINT_DATA, "Pivot",
"Change pivot point for transforms (buggy)"},
/* {CONSTRAINT_TYPE_RIGIDBODYJOINT, "RIGID_BODY_JOINT", ICON_CONSTRAINT_DATA, "Rigid Body Joint",
"Use to define a Rigid Body Constraint (for Game Engine use only)"}, */
- /* {CONSTRAINT_TYPE_PYTHON, "SCRIPT", ICON_CONSTRAINT_DATA, "Script",
+ /* {CONSTRAINT_TYPE_PYTHON, "SCRIPT", ICON_CONSTRAINT_DATA, "Script",
"Custom constraint(s) written in Python (Not yet implemented)"}, */
- {CONSTRAINT_TYPE_SHRINKWRAP, "SHRINKWRAP", ICON_CONSTRAINT_DATA, "Shrinkwrap",
+ {CONSTRAINT_TYPE_SHRINKWRAP, "SHRINKWRAP", ICON_CONSTRAINT_DATA, "Shrinkwrap",
"Restrict movements to surface of target mesh"},
{0, NULL, 0, NULL, NULL}
};
@@ -229,23 +229,23 @@ static void rna_Constraint_name_set(PointerRNA *ptr, const char *value)
{
bConstraint *con = ptr->data;
char oldname[sizeof(con->name)];
-
+
/* make a copy of the old name first */
BLI_strncpy(oldname, con->name, sizeof(con->name));
-
+
/* copy the new name into the name slot */
BLI_strncpy_utf8(con->name, value, sizeof(con->name));
-
+
/* make sure name is unique */
if (ptr->id.data) {
Object *ob = ptr->id.data;
ListBase *list = get_constraint_lb(ob, con, NULL);
-
+
/* if we have the list, check for unique name, otherwise give up */
if (list)
BKE_constraint_unique_name(con, list);
}
-
+
/* fix all the animation data which may link to this */
BKE_animdata_fix_paths_rename_all(NULL, "constraints", oldname, con->name);
}
@@ -275,9 +275,9 @@ static char *rna_Constraint_path(PointerRNA *ptr)
}
}
-static void rna_Constraint_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_Constraint_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
- ED_object_constraint_tag_update(ptr->id.data, ptr->data);
+ ED_object_constraint_tag_update(bmain, ptr->id.data, ptr->data);
}
static void rna_Constraint_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
@@ -291,7 +291,7 @@ static void rna_Constraint_influence_update(Main *bmain, Scene *scene, PointerRN
if (ob->pose)
ob->pose->flag |= (POSE_LOCKED | POSE_DO_UNLOCK);
-
+
rna_Constraint_update(bmain, scene, ptr);
}
@@ -318,7 +318,7 @@ static const EnumPropertyItem *rna_Constraint_owner_space_itemf(bContext *UNUSED
{
Object *ob = (Object *)ptr->id.data;
bConstraint *con = (bConstraint *)ptr->data;
-
+
if (BLI_findindex(&ob->constraints, con) == -1)
return owner_space_pchan_items;
else /* object */
@@ -332,14 +332,14 @@ static const EnumPropertyItem *rna_Constraint_target_space_itemf(bContext *UNUSE
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
-
+
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
-
+
for (ct = targets.first; ct; ct = ct->next)
if (ct->tar && ct->tar->type == OB_ARMATURE)
break;
-
+
if (cti->flush_constraint_targets)
cti->flush_constraint_targets(con, &targets, 1);
@@ -384,7 +384,7 @@ static void rna_SplineIKConstraint_joint_bindings_get(PointerRNA *ptr, float *va
{
bConstraint *con = (bConstraint *)ptr->data;
bSplineIKConstraint *ikData = (bSplineIKConstraint *)con->data;
-
+
memcpy(values, ikData->points, ikData->numpoints * sizeof(float));
}
@@ -392,7 +392,7 @@ static void rna_SplineIKConstraint_joint_bindings_set(PointerRNA *ptr, const flo
{
bConstraint *con = (bConstraint *)ptr->data;
bSplineIKConstraint *ikData = (bSplineIKConstraint *)con->data;
-
+
memcpy(ikData->points, values, ikData->numpoints * sizeof(float));
}
@@ -508,12 +508,12 @@ static const EnumPropertyItem constraint_distance_items[] = {
static void rna_def_constraint_headtail_common(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, "bConstraint", "headtail");
RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
prop = RNA_def_property(srna, "use_bbone_shape", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, "bConstraint", "flag", CONSTRAINT_BBONE_SHAPE);
RNA_def_property_ui_text(prop, "Follow B-Bone", "Follow shape of B-Bone segments when calculating Head/Tail position");
@@ -604,13 +604,13 @@ static void rna_def_constraint_childof(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_SIZEZ);
RNA_def_property_ui_text(prop, "Scale Z", "Use Z Scale of Parent");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
prop = RNA_def_property(srna, "inverse_matrix", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_float_sdna(prop, NULL, "invmat");
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Inverse Matrix", "Transformation matrix to apply before");
-
+
}
static void rna_def_constraint_python(BlenderRNA *brna)
@@ -1001,7 +1001,7 @@ static void rna_def_constraint_transform_like(BlenderRNA *brna)
srna = RNA_def_struct(brna, "CopyTransformsConstraint", "Constraint");
RNA_def_struct_ui_text(srna, "Copy Transforms Constraint", "Copy all the transforms of the target");
-
+
rna_def_constraint_headtail_common(srna);
RNA_def_struct_sdna_from(srna, "bTransLikeConstraint", "data");
@@ -1149,9 +1149,9 @@ static void rna_def_constraint_locked_track(BlenderRNA *brna)
srna = RNA_def_struct(brna, "LockedTrackConstraint", "Constraint");
RNA_def_struct_ui_text(srna, "Locked Track Constraint",
"Point toward the target along the track axis, while locking the other axis");
-
+
rna_def_constraint_headtail_common(srna);
-
+
RNA_def_struct_sdna_from(srna, "bLockTrackConstraint", "data");
rna_def_constraint_target_common(srna);
@@ -1206,7 +1206,7 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna)
RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
RNA_def_property_ui_text(prop, "Offset", "Offset from the position corresponding to the time frame");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
prop = RNA_def_property(srna, "offset_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "offset_fac");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -1229,7 +1229,7 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "followflag", FOLLOWPATH_FOLLOW);
RNA_def_property_ui_text(prop, "Follow Curve", "Object will follow the heading and banking of the curve");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
prop = RNA_def_property(srna, "use_fixed_location", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "followflag", FOLLOWPATH_STATIC);
RNA_def_property_ui_text(prop, "Fixed Position",
@@ -1866,9 +1866,9 @@ static void rna_def_constraint_distance_limit(BlenderRNA *brna)
srna = RNA_def_struct(brna, "LimitDistanceConstraint", "Constraint");
RNA_def_struct_ui_text(srna, "Limit Distance Constraint", "Limit the distance from target object");
-
+
rna_def_constraint_headtail_common(srna);
-
+
RNA_def_struct_sdna_from(srna, "bDistLimitConstraint", "data");
rna_def_constraint_target_common(srna);
@@ -1884,7 +1884,7 @@ static void rna_def_constraint_distance_limit(BlenderRNA *brna)
RNA_def_property_enum_items(prop, constraint_distance_items);
RNA_def_property_ui_text(prop, "Limit Mode", "Distances in relation to sphere of influence to allow");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
prop = RNA_def_property(srna, "use_transform_limit", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMITDIST_TRANSFORM);
RNA_def_property_ui_text(prop, "For Transform", "Transforms are affected by this constraint as well");
@@ -1895,7 +1895,7 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem type_items[] = {
{MOD_SHRINKWRAP_NEAREST_SURFACE, "NEAREST_SURFACE", 0, "Nearest Surface Point",
"Shrink the location to the nearest target surface"},
@@ -1905,24 +1905,24 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna)
"Shrink the location to the nearest target vertex"},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "ShrinkwrapConstraint", "Constraint");
RNA_def_struct_ui_text(srna, "Shrinkwrap Constraint", "Create constraint-based shrinkwrap relationship");
RNA_def_struct_sdna_from(srna, "bShrinkwrapConstraint", "data");
-
+
prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "target"); /* TODO, mesh type */
RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Mesh_object_poll");
RNA_def_property_ui_text(prop, "Target", "Target Mesh object");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
+
prop = RNA_def_property(srna, "shrinkwrap_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "shrinkType");
RNA_def_property_enum_items(prop, type_items);
RNA_def_property_ui_text(prop, "Shrinkwrap Type", "Select type of shrinkwrap algorithm for target position");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "dist");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
@@ -1968,9 +1968,9 @@ static void rna_def_constraint_damped_track(BlenderRNA *brna)
srna = RNA_def_struct(brna, "DampedTrackConstraint", "Constraint");
RNA_def_struct_ui_text(srna, "Damped Track Constraint",
"Point toward target by taking the shortest rotation path");
-
+
rna_def_constraint_headtail_common(srna);
-
+
RNA_def_struct_sdna_from(srna, "bDampTrackConstraint", "data");
rna_def_constraint_target_common(srna);
@@ -1986,7 +1986,7 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem splineik_xz_scale_mode[] = {
{CONSTRAINT_SPLINEIK_XZS_NONE, "NONE", 0, "None", "Don't scale the X and Z axes (Default)"},
{CONSTRAINT_SPLINEIK_XZS_ORIGINAL, "BONE_ORIGINAL", 0, "Bone Original",
@@ -2001,7 +2001,7 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna)
srna = RNA_def_struct(brna, "SplineIKConstraint", "Constraint");
RNA_def_struct_ui_text(srna, "Spline IK Constraint", "Align 'n' bones along a curve");
RNA_def_struct_sdna_from(srna, "bSplineIKConstraint", "data");
-
+
/* target chain */
prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "tar");
@@ -2009,7 +2009,7 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Target", "Curve that controls this relationship");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
+
prop = RNA_def_property(srna, "chain_count", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "chainlen");
/* TODO: this should really check the max length of the chain the constraint is attached to */
@@ -2017,7 +2017,7 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Chain Length", "How many bones are included in the chain");
/* XXX: this update goes wrong... needs extra flush? */
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
+
/* direct access to bindings */
/* NOTE: only to be used by experienced users */
prop = RNA_def_property(srna, "joint_bindings", PROP_FLOAT, PROP_FACTOR);
@@ -2030,31 +2030,31 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna)
"(EXPERIENCED USERS ONLY) The relative positions of the joints along the chain, "
"as percentages");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
/* settings */
prop = RNA_def_property(srna, "use_chain_offset", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_NO_ROOT);
RNA_def_property_ui_text(prop, "Chain Offset", "Offset the entire chain relative to the root joint");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
prop = RNA_def_property(srna, "use_even_divisions", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_EVENSPLITS);
RNA_def_property_ui_text(prop, "Even Divisions",
"Ignore the relative lengths of the bones when fitting to the curve");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
prop = RNA_def_property(srna, "use_y_stretch", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_SCALE_LIMITED);
RNA_def_property_ui_text(prop, "Y Stretch", "Stretch the Y axis of the bones to fit the curve");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
prop = RNA_def_property(srna, "use_curve_radius", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_NO_CURVERAD);
RNA_def_property_ui_text(prop, "Use Curve Radius",
"Average radius of the endpoints is used to tweak the X and Z Scaling of the bones, "
"on top of XZ Scale mode");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
/* xz scaling mode */
prop = RNA_def_property(srna, "xz_scale_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "xzScaleMode");
@@ -2062,33 +2062,33 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "XZ Scale Mode",
"Method used for determining the scaling of the X and Z axes of the bones");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
/* volume presevation for "volumetric" scale mode */
prop = RNA_def_property(srna, "bulge", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0, 100.f);
RNA_def_property_ui_text(prop, "Volume Variation", "Factor between volume variation and stretching");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
prop = RNA_def_property(srna, "use_bulge_min", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_USE_BULGE_MIN);
RNA_def_property_ui_text(prop, "Use Volume Variation Minimum", "Use lower limit for volume variation");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
prop = RNA_def_property(srna, "use_bulge_max", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_USE_BULGE_MAX);
RNA_def_property_ui_text(prop, "Use Volume Variation Maximum", "Use upper limit for volume variation");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
prop = RNA_def_property(srna, "bulge_min", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0, 1.0f);
RNA_def_property_ui_text(prop, "Volume Variation Minimum", "Minimum volume stretching factor");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
prop = RNA_def_property(srna, "bulge_max", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 1.0, 100.0f);
RNA_def_property_ui_text(prop, "Volume Variation Maximum", "Maximum volume stretching factor");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
prop = RNA_def_property(srna, "bulge_smooth", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0.0, 1.0f);
RNA_def_property_ui_text(prop, "Volume Variation Smoothness", "Strength of volume stretching clamping");
@@ -2116,37 +2116,37 @@ static void rna_def_constraint_pivot(BlenderRNA *brna)
srna = RNA_def_struct(brna, "PivotConstraint", "Constraint");
RNA_def_struct_ui_text(srna, "Pivot Constraint", "Rotate around a different point");
-
+
rna_def_constraint_headtail_common(srna);
-
+
RNA_def_struct_sdna_from(srna, "bPivotConstraint", "data");
-
+
/* target-defined pivot */
prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "tar");
RNA_def_property_ui_text(prop, "Target", "Target Object, defining the position of the pivot when defined");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
+
prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "subtarget");
RNA_def_property_ui_text(prop, "Sub-Target", "");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
+
/* pivot offset */
prop = RNA_def_property(srna, "use_relative_location", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PIVOTCON_FLAG_OFFSET_ABS);
RNA_def_property_ui_text(prop, "Use Relative Offset",
"Offset will be an absolute point in space instead of relative to the target");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "offset");
RNA_def_property_ui_text(prop, "Offset",
"Offset of pivot from target (when set), or from owner's location "
"(when Fixed Position is off), or the absolute pivot point");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
+
/* rotation-based activation */
prop = RNA_def_property(srna, "rotation_range", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "rotAxis");
@@ -2324,21 +2324,21 @@ void RNA_def_constraint(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
/* data */
srna = RNA_def_struct(brna, "Constraint", NULL);
RNA_def_struct_ui_text(srna, "Constraint", "Constraint modifying the transformation of objects and bones");
RNA_def_struct_refine_func(srna, "rna_ConstraintType_refine");
RNA_def_struct_path_func(srna, "rna_Constraint_path");
RNA_def_struct_sdna(srna, "bConstraint");
-
+
/* strings */
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Constraint_name_set");
RNA_def_property_ui_text(prop, "Name", "Constraint name");
RNA_def_struct_name_property(srna, prop);
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT | NA_RENAME, NULL);
-
+
/* enums */
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -2361,12 +2361,12 @@ void RNA_def_constraint(BlenderRNA *brna)
/* flags */
prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_OFF);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Disable", "Enable/Disable Constraint");
-
+
prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_EXPAND);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Expanded", "Constraint's panel is expanded in UI");
RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
@@ -2375,17 +2375,17 @@ void RNA_def_constraint(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_DISABLE);
RNA_def_property_ui_text(prop, "Valid", "Constraint has valid settings and can be evaluated");
-
+
/* TODO: setting this to true must ensure that all others in stack are turned off too... */
prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_ACTIVE);
RNA_def_property_ui_text(prop, "Active", "Constraint is the one being edited ");
-
+
prop = RNA_def_property(srna, "is_proxy_local", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_PROXY_LOCAL);
RNA_def_property_ui_text(prop, "Proxy Local",
"Constraint was added in this proxy instance (i.e. did not belong to source Armature)");
-
+
/* values */
prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "enforce");
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index 894af338c12..0681a449aa2 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -55,7 +55,7 @@ static const EnumPropertyItem beztriple_handle_type_items[] = {
{0, NULL, 0, NULL, NULL}
};
#endif
-
+
const EnumPropertyItem rna_enum_keyframe_handle_type_items[] = {
{HD_FREE, "FREE", 0, "Free", ""},
{HD_VECT, "VECTOR", 0, "Vector", ""},
@@ -71,7 +71,7 @@ const EnumPropertyItem rna_enum_beztriple_interpolation_mode_items[] = {
{BEZT_IPO_CONST, "CONSTANT", ICON_IPO_CONSTANT, "Constant", "No interpolation, value of A gets held until B is encountered"},
{BEZT_IPO_LIN, "LINEAR", ICON_IPO_LINEAR, "Linear", "Straight-line interpolation between A and B (i.e. no ease in/out)"},
{BEZT_IPO_BEZ, "BEZIER", ICON_IPO_BEZIER, "Bezier", "Smooth interpolation between A and B, with some control over curve shape"},
-
+
/* easing */
{0, "", 0, N_("Easing (by strength)"), "Predefined inertial transitions, useful for motion graphics (from least to most ''dramatic'')"},
{BEZT_IPO_SINE, "SINE", ICON_IPO_SINE, "Sinusoidal", "Sinusoidal easing (weakest, almost linear but with a slight curvature)"},
@@ -81,12 +81,12 @@ const EnumPropertyItem rna_enum_beztriple_interpolation_mode_items[] = {
{BEZT_IPO_QUINT, "QUINT", ICON_IPO_QUINT, "Quintic", "Quintic easing"},
{BEZT_IPO_EXPO, "EXPO", ICON_IPO_EXPO, "Exponential", "Exponential easing (dramatic)"},
{BEZT_IPO_CIRC, "CIRC", ICON_IPO_CIRC, "Circular", "Circular easing (strongest and most dynamic)"},
-
+
{0, "", 0, N_("Dynamic Effects"), "Simple physics-inspired easing effects"},
{BEZT_IPO_BACK, "BACK", ICON_IPO_BACK, "Back", "Cubic easing with overshoot and settle"},
{BEZT_IPO_BOUNCE, "BOUNCE", ICON_IPO_BOUNCE, "Bounce", "Exponentially decaying parabolic bounce, like when objects collide"},
{BEZT_IPO_ELASTIC, "ELASTIC", ICON_IPO_ELASTIC, "Elastic", "Exponentially decaying sine wave, like an elastic band"},
-
+
{0, NULL, 0, NULL, NULL}
};
@@ -159,7 +159,7 @@ static Nurb *curve_nurb_from_point(Curve *cu, const void *point, int *nu_index,
if (nu_index) {
*nu_index = i;
}
-
+
if (pt_index) {
if (nu->type == CU_BEZIER) *pt_index = (int)((BezTriple *)point - nu->bezt);
else *pt_index = (int)((BPoint *)point - nu->bp);
@@ -173,7 +173,7 @@ static StructRNA *rna_Curve_refine(PointerRNA *ptr)
{
Curve *cu = (Curve *)ptr->data;
short obtype = BKE_curve_type_get(cu);
-
+
if (obtype == OB_FONT) return &RNA_TextCurve;
else if (obtype == OB_SURF) return &RNA_SurfaceCurve;
else return &RNA_Curve;
@@ -218,7 +218,7 @@ static void rna_BezTriple_ctrlpoint_set(PointerRNA *ptr, const float *values)
static void rna_Curve_texspace_set(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
Curve *cu = (Curve *)ptr->data;
-
+
if (cu->texflag & CU_AUTOSPACE)
BKE_curve_texspace_calc(cu);
}
@@ -232,34 +232,34 @@ static int rna_Curve_texspace_editable(PointerRNA *ptr, const char **UNUSED(r_in
static void rna_Curve_texspace_loc_get(PointerRNA *ptr, float *values)
{
Curve *cu = (Curve *)ptr->data;
-
+
if (!cu->bb)
BKE_curve_texspace_calc(cu);
-
+
copy_v3_v3(values, cu->loc);
}
static void rna_Curve_texspace_loc_set(PointerRNA *ptr, const float *values)
{
Curve *cu = (Curve *)ptr->data;
-
+
copy_v3_v3(cu->loc, values);
}
static void rna_Curve_texspace_size_get(PointerRNA *ptr, float *values)
{
Curve *cu = (Curve *)ptr->data;
-
+
if (!cu->bb)
BKE_curve_texspace_calc(cu);
-
+
copy_v3_v3(values, cu->size);
}
static void rna_Curve_texspace_size_set(PointerRNA *ptr, const float *values)
{
Curve *cu = (Curve *)ptr->data;
-
+
copy_v3_v3(cu->size, values);
}
@@ -448,7 +448,7 @@ static void rna_Curve_resolution_u_update_data(Main *bmain, Scene *scene, Pointe
nu->resolu = cu->resolu;
nu = nu->next;
}
-
+
rna_Curve_update_data(bmain, scene, ptr);
}
@@ -900,7 +900,7 @@ static void rna_def_beztriple(BlenderRNA *brna)
static void rna_def_path(BlenderRNA *UNUSED(brna), StructRNA *srna)
{
PropertyRNA *prop;
-
+
/* number values */
prop = RNA_def_property(srna, "path_duration", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "pathlen");
@@ -909,18 +909,18 @@ static void rna_def_path(BlenderRNA *UNUSED(brna), StructRNA *srna)
"The number of frames that are needed to traverse the path, "
"defining the maximum value for the 'Evaluation Time' setting");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
/* flags */
prop = RNA_def_property(srna, "use_path", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_PATH);
RNA_def_property_ui_text(prop, "Path", "Enable the curve to become a translation path");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "use_path_follow", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FOLLOW);
RNA_def_property_ui_text(prop, "Follow", "Make curve path children to rotate along the path");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "use_stretch", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_STRETCH);
RNA_def_property_ui_text(prop, "Stretch", "Option for curve-deform: "
@@ -943,7 +943,7 @@ static void rna_def_path(BlenderRNA *UNUSED(brna), StructRNA *srna)
static void rna_def_nurbs(BlenderRNA *UNUSED(brna), StructRNA *srna)
{
PropertyRNA *prop;
-
+
/* flags */
prop = RNA_def_property(srna, "use_uv_as_generated", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UV_ORCO);
@@ -992,7 +992,7 @@ static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna)
RNA_def_property_ui_range(prop, 0.01, 10, 1, 3);
RNA_def_property_ui_text(prop, "Font size", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "small_caps_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "smallcaps_scale");
RNA_def_property_ui_range(prop, 0, 1.0, 1, 2);
@@ -1004,51 +1004,51 @@ static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna)
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(prop, "Distance between lines of text", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "space_word", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "wordspace");
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(prop, "Spacing between words", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "space_character", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "spacing");
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(prop, "Global spacing between characters", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "shear", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "shear");
RNA_def_property_range(prop, -1.0f, 1.0f);
RNA_def_property_ui_text(prop, "Shear", "Italic angle of the characters");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "offset_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "xof");
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
RNA_def_property_ui_range(prop, -50.0f, 50.0f, 10, 3);
RNA_def_property_ui_text(prop, "X Offset", "Horizontal offset from the object origin");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "offset_y", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "yof");
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
RNA_def_property_ui_range(prop, -50.0f, 50.0f, 10, 3);
RNA_def_property_ui_text(prop, "Y Offset", "Vertical offset from the object origin");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "underline_position", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ulpos");
RNA_def_property_range(prop, -0.2f, 0.8f);
RNA_def_property_ui_text(prop, "Underline Position", "Vertical position of underline");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "underline_height", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ulheight");
RNA_def_property_range(prop, 0.0f, 0.8f);
RNA_def_property_ui_text(prop, "Underline Thickness", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "text_boxes", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "tb", "totbox");
RNA_def_property_struct_type(prop, "TextBox");
@@ -1058,7 +1058,7 @@ static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna)
RNA_def_property_int_sdna(prop, NULL, "actbox");
RNA_def_property_ui_text(prop, "The active text box", "");
RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Curve_active_textbox_index_range");
-
+
/* strings */
prop = RNA_def_property(srna, "family", PROP_STRING, PROP_NONE);
RNA_def_property_string_maxlength(prop, MAX_ID_NAME - 2);
@@ -1067,7 +1067,7 @@ static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna)
"followed by the character they represent, eg. 'family-a', 'family-b', etc, "
"set this setting to 'family-', and turn on Vertex Duplication)");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "body", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "str");
RNA_def_property_ui_text(prop, "Body Text", "Content of this text object");
@@ -1079,7 +1079,7 @@ static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna)
RNA_def_property_collection_sdna(prop, NULL, "strinfo", "len_wchar");
RNA_def_property_struct_type(prop, "TextCharacterFormat");
RNA_def_property_ui_text(prop, "Character Info", "Stores the style of each character");
-
+
/* pointers */
prop = RNA_def_property(srna, "follow_curve", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "textoncurve");
@@ -1087,7 +1087,7 @@ static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Text on Curve", "Curve deforming text object");
RNA_def_property_update(prop, 0, "rna_Curve_update_deps");
-
+
prop = RNA_def_property(srna, "font", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "vfont");
RNA_def_property_ui_text(prop, "Font", "");
@@ -1128,10 +1128,10 @@ static void rna_def_textbox(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "TextBox", NULL);
RNA_def_struct_ui_text(srna, "Text Box", "Text bounding box for layout");
-
+
/* number values */
prop = RNA_def_property(srna, "x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "x");
@@ -1139,7 +1139,7 @@ static void rna_def_textbox(BlenderRNA *brna)
RNA_def_property_ui_range(prop, -50.0f, 50.0f, 10, 3);
RNA_def_property_ui_text(prop, "Textbox X Offset", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "y", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "y");
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
@@ -1160,7 +1160,7 @@ static void rna_def_textbox(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.0f, 50.0f, 10, 3);
RNA_def_property_ui_text(prop, "Textbox Height", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
RNA_def_struct_path_func(srna, "rna_TextBox_path");
}
@@ -1168,27 +1168,27 @@ static void rna_def_charinfo(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "TextCharacterFormat", NULL);
RNA_def_struct_sdna(srna, "CharInfo");
RNA_def_struct_ui_text(srna, "Text Character Format", "Text character formatting settings");
-
+
/* flags */
prop = RNA_def_property(srna, "use_bold", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_BOLD);
RNA_def_property_ui_text(prop, "Bold", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "use_italic", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_ITALIC);
RNA_def_property_ui_text(prop, "Italic", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "use_underline", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_UNDERLINE);
RNA_def_property_ui_text(prop, "Underline", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
/* probably there is no reason to expose this */
#if 0
prop = RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE);
@@ -1212,7 +1212,7 @@ static void rna_def_charinfo(BlenderRNA *brna)
static void rna_def_surface(BlenderRNA *brna)
{
StructRNA *srna;
-
+
srna = RNA_def_struct(brna, "SurfaceCurve", "Curve");
RNA_def_struct_sdna(srna, "Curve");
RNA_def_struct_ui_text(srna, "Surface Curve", "Curve data-block used for storing surfaces");
@@ -1224,7 +1224,7 @@ static void rna_def_surface(BlenderRNA *brna)
static void rna_def_text(BlenderRNA *brna)
{
StructRNA *srna;
-
+
srna = RNA_def_struct(brna, "TextCurve", "Curve");
RNA_def_struct_sdna(srna, "Curve");
RNA_def_struct_ui_text(srna, "Text Curve", "Curve data-block used for storing text");
@@ -1335,7 +1335,7 @@ static void rna_def_curve(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem curve_twist_mode_items[] = {
{CU_TWIST_Z_UP, "Z_UP", 0, "Z-Up", "Use Z-Up axis to calculate the curve twist at each point"},
{CU_TWIST_MINIMUM, "MINIMUM", 0, "Minimum", "Use the least twist over the entire curve"},
@@ -1392,7 +1392,7 @@ static void rna_def_curve(BlenderRNA *brna)
RNA_def_property_update(prop, NC_GEOM | ND_DATA, NULL);
rna_def_path(brna, srna);
-
+
/* Number values */
prop = RNA_def_property(srna, "bevel_resolution", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "bevresol");
@@ -1401,63 +1401,63 @@ static void rna_def_curve(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Bevel Resolution",
"Bevel resolution when depth is non-zero and no specific bevel object has been defined");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
RNA_def_property_float_sdna(prop, NULL, "width");
RNA_def_property_ui_range(prop, -1.0, 1.0, 0.1, 3);
RNA_def_property_float_funcs(prop, "rna_Curve_offset_get", "rna_Curve_offset_set", NULL);
RNA_def_property_ui_text(prop, "Offset", "Offset the curve to adjust the width of a text");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "extrude", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
RNA_def_property_float_sdna(prop, NULL, "ext1");
RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 3);
RNA_def_property_range(prop, 0.0, FLT_MAX);
RNA_def_property_ui_text(prop, "Extrude", "Amount of curve extrusion when not using a bevel object");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "bevel_depth", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
RNA_def_property_float_sdna(prop, NULL, "ext2");
RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 3);
RNA_def_property_ui_text(prop, "Bevel Depth", "Bevel depth when not using a bevel object");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "resolution_u", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "resolu");
RNA_def_property_range(prop, 1, 1024);
RNA_def_property_ui_range(prop, 1, 64, 1, -1);
RNA_def_property_ui_text(prop, "Resolution U", "Surface resolution in U direction");
RNA_def_property_update(prop, 0, "rna_Curve_resolution_u_update_data");
-
+
prop = RNA_def_property(srna, "resolution_v", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "resolv");
RNA_def_property_ui_range(prop, 1, 64, 1, -1);
RNA_def_property_range(prop, 1, 1024);
RNA_def_property_ui_text(prop, "Resolution V", "Surface resolution in V direction");
RNA_def_property_update(prop, 0, "rna_Curve_resolution_v_update_data");
-
+
prop = RNA_def_property(srna, "render_resolution_u", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "resolu_ren");
RNA_def_property_range(prop, 0, 1024);
RNA_def_property_ui_range(prop, 0, 64, 1, -1);
RNA_def_property_ui_text(prop, "Render Resolution U",
"Surface resolution in U direction used while rendering (zero uses preview resolution)");
-
+
prop = RNA_def_property(srna, "render_resolution_v", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "resolv_ren");
RNA_def_property_ui_range(prop, 0, 64, 1, -1);
RNA_def_property_range(prop, 0, 1024);
RNA_def_property_ui_text(prop, "Render Resolution V",
"Surface resolution in V direction used while rendering (zero uses preview resolution)");
-
-
+
+
prop = RNA_def_property(srna, "eval_time", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ctime");
RNA_def_property_ui_text(prop, "Evaluation Time",
"Parametric position along the length of the curve that Objects 'following' it should be "
"at (position is evaluated by dividing by the 'Path Length' value)");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
/* pointers */
prop = RNA_def_property(srna, "bevel_object", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
@@ -1485,7 +1485,7 @@ static void rna_def_curve(BlenderRNA *brna)
RNA_def_property_enum_funcs(prop, NULL, "rna_Curve_dimension_set", NULL);
RNA_def_property_ui_text(prop, "Dimensions", "Select 2D or 3D curve type");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "fill_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, curve3d_fill_mode_items);
@@ -1547,7 +1547,7 @@ static void rna_def_curve(BlenderRNA *brna)
RNA_def_property_editable_func(prop, "rna_Curve_texspace_editable");
RNA_def_property_float_funcs(prop, "rna_Curve_texspace_loc_get", "rna_Curve_texspace_loc_set", NULL);
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ);
RNA_def_property_array(prop, 3);
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
@@ -1555,7 +1555,7 @@ static void rna_def_curve(BlenderRNA *brna)
RNA_def_property_editable_func(prop, "rna_Curve_texspace_editable");
RNA_def_property_float_funcs(prop, "rna_Curve_texspace_size_get", "rna_Curve_texspace_size_set", NULL);
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
/* not supported yet */
#if 0
prop = RNA_def_property(srna, "texspace_rot", PROP_FLOAT, PROP_EULER);
@@ -1564,12 +1564,12 @@ static void rna_def_curve(BlenderRNA *brna)
RNA_def_property_editable_func(prop, texspace_editable);
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
#endif
-
+
prop = RNA_def_property(srna, "use_uv_as_generated", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UV_ORCO);
RNA_def_property_ui_text(prop, "Use UV for mapping", "Uses the UV values as Generated textured coordinates");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
/* materials */
prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
@@ -1633,7 +1633,7 @@ static void rna_def_curve_nurb(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Bezier Points", "Collection of points for Bezier curves only");
rna_def_curve_spline_bezpoints(brna, prop);
-
+
prop = RNA_def_property(srna, "tilt_interpolation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "tilt_interp");
RNA_def_property_enum_items(prop, spline_interpolation_items);
@@ -1752,7 +1752,7 @@ static void rna_def_curve_nurb(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Material Index", "");
RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Curve_material_index_range");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-
+
prop = RNA_def_property(srna, "character_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "charidx");
RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 03e58f8f78e..5b91a3e43d2 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -128,12 +128,12 @@ void rna_freelinkN(ListBase *listbase, void *vlink)
void rna_freelistN(ListBase *listbase)
{
Link *link, *next;
-
+
for (link = listbase->first; link; link = next) {
next = link->next;
MEM_freeN(link);
}
-
+
listbase->first = listbase->last = NULL;
}
@@ -335,13 +335,13 @@ typedef struct DNAStructMember {
static int rna_member_cmp(const char *name, const char *oname)
{
int a = 0;
-
+
/* compare without pointer or array part */
while (name[0] == '*')
name++;
while (oname[0] == '*')
oname++;
-
+
while (1) {
if (name[a] == '[' && oname[a] == 0) return 1;
if (name[a] == '[' && oname[a] == '[') return 1;
@@ -419,7 +419,7 @@ static int rna_find_sdna_member(SDNA *sdna, const char *structname, const char *
static int rna_validate_identifier(const char *identifier, char *error, bool property)
{
int a = 0;
-
+
/* list is from...
* ", ".join(['"%s"' % kw for kw in __import__("keyword").kwlist if kw not in {"False", "None", "True"}])
*/
@@ -431,13 +431,13 @@ static int rna_validate_identifier(const char *identifier, char *error, bool pro
"is", "lambda", "nonlocal", "not", "or", "pass", "raise",
"return", "try", "while", "with", "yield", NULL
};
-
-
+
+
if (!isalpha(identifier[0])) {
strcpy(error, "first character failed isalpha() check");
return 0;
}
-
+
for (a = 0; identifier[a]; a++) {
if (DefRNA.preprocess && property) {
if (isalpha(identifier[a]) && isupper(identifier[a])) {
@@ -445,7 +445,7 @@ static int rna_validate_identifier(const char *identifier, char *error, bool pro
return 0;
}
}
-
+
if (identifier[a] == '_') {
continue;
}
@@ -460,7 +460,7 @@ static int rna_validate_identifier(const char *identifier, char *error, bool pro
return 0;
}
}
-
+
for (a = 0; kwlist[a]; a++) {
if (STREQ(identifier, kwlist[a])) {
strcpy(error, "this keyword is reserved by python");
@@ -482,14 +482,14 @@ static int rna_validate_identifier(const char *identifier, char *error, bool pro
}
}
}
-
+
return 1;
}
void RNA_identifier_sanitize(char *identifier, int property)
{
int a = 0;
-
+
/* list from http://docs.python.org/py3k/reference/lexical_analysis.html#keywords */
static const char *kwlist[] = {
/* "False", "None", "True", */
@@ -499,13 +499,13 @@ void RNA_identifier_sanitize(char *identifier, int property)
"is", "lambda", "nonlocal", "not", "or", "pass", "raise",
"return", "try", "while", "with", "yield", NULL
};
-
-
+
+
if (!isalpha(identifier[0])) {
/* first character failed isalpha() check */
identifier[0] = '_';
}
-
+
for (a = 0; identifier[a]; a++) {
if (DefRNA.preprocess && property) {
if (isalpha(identifier[a]) && isupper(identifier[a])) {
@@ -513,7 +513,7 @@ void RNA_identifier_sanitize(char *identifier, int property)
identifier[a] = tolower(identifier[a]);
}
}
-
+
if (identifier[a] == '_') {
continue;
}
@@ -528,7 +528,7 @@ void RNA_identifier_sanitize(char *identifier, int property)
identifier[a] = '_';
}
}
-
+
for (a = 0; kwlist[a]; a++) {
if (STREQ(identifier, kwlist[a])) {
/* this keyword is reserved by python.
@@ -703,7 +703,7 @@ void RNA_free(BlenderRNA *brna)
}
rna_freelistN(&brna->structs);
-
+
MEM_freeN(brna);
}
else {
@@ -1078,13 +1078,13 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier
if (DefRNA.preprocess) {
char error[512];
-
+
if (rna_validate_identifier(identifier, error, true) == 0) {
fprintf(stderr, "%s: property identifier \"%s.%s\" - %s\n", __func__,
CONTAINER_RNA_ID(cont), identifier, error);
DefRNA.error = 1;
}
-
+
dcont = rna_find_container_def(cont);
/* XXX - toto, detect supertype collisions */
@@ -1198,7 +1198,7 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier
if (type != PROP_COLLECTION && type != PROP_POINTER) {
prop->flag = PROP_EDITABLE;
-
+
if (type != PROP_STRING) {
#ifdef RNA_RUNTIME
prop->flag |= PROP_ANIMATABLE;
@@ -1293,6 +1293,16 @@ void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
prop->flag &= ~flag;
}
+void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
+{
+ prop->flag_override |= flag;
+}
+
+void RNA_def_property_override_clear_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
+{
+ prop->flag_override &= ~flag;
+}
+
/**
* Add the property-tags passed as \a tags to \a prop (if valid).
*
@@ -1372,7 +1382,7 @@ void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int le
{
StructRNA *srna = DefRNA.laststruct;
int i;
-
+
if (dimension < 1 || dimension > RNA_MAX_ARRAY_DIMENSION) {
fprintf(stderr, "%s: \"%s.%s\", array dimension must be between 1 and %d.\n",
__func__, srna->identifier, prop->identifier, RNA_MAX_ARRAY_DIMENSION);
@@ -1884,7 +1894,7 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop, const char *stru
prop->arraydimension = 0;
prop->totarraylength = 0;
}
-
+
dp->dnastructname = structname;
dp->dnastructfromname = ds->dnafromname;
dp->dnastructfromprop = ds->dnafromprop;
@@ -1900,7 +1910,7 @@ void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, co
{
PropertyDefRNA *dp;
StructRNA *srna = DefRNA.laststruct;
-
+
if (!DefRNA.preprocess) {
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
return;
@@ -1946,7 +1956,7 @@ void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const
PropertyDefRNA *dp;
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
StructRNA *srna = DefRNA.laststruct;
-
+
if (!DefRNA.preprocess) {
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
return;
@@ -2036,7 +2046,7 @@ void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const
{
/* PropertyDefRNA *dp; */
StructRNA *srna = DefRNA.laststruct;
-
+
if (!DefRNA.preprocess) {
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
return;
@@ -2104,7 +2114,7 @@ void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, co
{
/* PropertyDefRNA *dp; */
StructRNA *srna = DefRNA.laststruct;
-
+
if (!DefRNA.preprocess) {
fprintf(stderr, "%s: only during preprocessing.\n", __func__);
return;
@@ -2660,7 +2670,7 @@ PropertyRNA *RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier,
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_default(prop, default_value);
RNA_def_property_ui_text(prop, ui_name, ui_description);
@@ -2673,7 +2683,7 @@ PropertyRNA *RNA_def_boolean_array(StructOrFunctionRNA *cont_, const char *ident
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_NONE);
if (len != 0) RNA_def_property_array(prop, len);
if (default_value) RNA_def_property_boolean_array_default(prop, default_value);
@@ -2687,7 +2697,7 @@ PropertyRNA *RNA_def_boolean_layer(StructOrFunctionRNA *cont_, const char *ident
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_LAYER);
if (len != 0) RNA_def_property_array(prop, len);
if (default_value) RNA_def_property_boolean_array_default(prop, default_value);
@@ -2701,7 +2711,7 @@ PropertyRNA *RNA_def_boolean_layer_member(StructOrFunctionRNA *cont_, const char
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_LAYER_MEMBER);
if (len != 0) RNA_def_property_array(prop, len);
if (default_value) RNA_def_property_boolean_array_default(prop, default_value);
@@ -2715,7 +2725,7 @@ PropertyRNA *RNA_def_boolean_vector(StructOrFunctionRNA *cont_, const char *iden
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_XYZ); /* XXX */
if (len != 0) RNA_def_property_array(prop, len);
if (default_value) RNA_def_property_boolean_array_default(prop, default_value);
@@ -2730,7 +2740,7 @@ PropertyRNA *RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
ASSERT_SOFT_HARD_LIMITS;
prop = RNA_def_property(cont, identifier, PROP_INT, PROP_NONE);
@@ -2748,7 +2758,7 @@ PropertyRNA *RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifi
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
ASSERT_SOFT_HARD_LIMITS;
prop = RNA_def_property(cont, identifier, PROP_INT, PROP_XYZ); /* XXX */
@@ -2767,7 +2777,7 @@ PropertyRNA *RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifie
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
ASSERT_SOFT_HARD_LIMITS;
prop = RNA_def_property(cont, identifier, PROP_INT, PROP_NONE);
@@ -2854,7 +2864,7 @@ PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, co
printf("%s: items not allowed to be NULL.\n", __func__);
return NULL;
}
-
+
prop = RNA_def_property(cont, identifier, PROP_ENUM, PROP_NONE);
if (items) RNA_def_property_enum_items(prop, items);
RNA_def_property_enum_default(prop, default_value);
@@ -2896,7 +2906,7 @@ PropertyRNA *RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, f
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
ASSERT_SOFT_HARD_LIMITS;
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_NONE);
@@ -2914,7 +2924,7 @@ PropertyRNA *RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identi
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
ASSERT_SOFT_HARD_LIMITS;
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_XYZ);
@@ -2932,7 +2942,7 @@ PropertyRNA *RNA_def_float_vector_xyz(StructOrFunctionRNA *cont_, const char *id
const char *ui_description, float softmin, float softmax)
{
PropertyRNA *prop;
-
+
prop = RNA_def_float_vector(cont_, identifier, len, default_value, hardmin, hardmax, ui_name, ui_description,
softmin, softmax);
prop->subtype = PROP_XYZ_LENGTH;
@@ -2946,7 +2956,7 @@ PropertyRNA *RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identif
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
ASSERT_SOFT_HARD_LIMITS;
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_COLOR);
@@ -3023,7 +3033,7 @@ PropertyRNA *RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identif
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
ASSERT_SOFT_HARD_LIMITS;
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_NONE);
@@ -3042,7 +3052,7 @@ PropertyRNA *RNA_def_float_percentage(StructOrFunctionRNA *cont_, const char *id
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
ASSERT_SOFT_HARD_LIMITS;
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_PERCENTAGE);
@@ -3060,7 +3070,7 @@ PropertyRNA *RNA_def_float_factor(StructOrFunctionRNA *cont_, const char *identi
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
ASSERT_SOFT_HARD_LIMITS;
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_FACTOR);
@@ -3077,7 +3087,7 @@ PropertyRNA *RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier,
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
prop = RNA_def_property(cont, identifier, PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, type);
RNA_def_property_ui_text(prop, ui_name, ui_description);
@@ -3090,7 +3100,7 @@ PropertyRNA *RNA_def_pointer_runtime(StructOrFunctionRNA *cont_, const char *ide
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
prop = RNA_def_property(cont, identifier, PROP_POINTER, PROP_NONE);
RNA_def_property_struct_runtime(prop, type);
if ((type->flag & STRUCT_ID) != 0) {
@@ -3106,7 +3116,7 @@ PropertyRNA *RNA_def_collection(StructOrFunctionRNA *cont_, const char *identifi
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
prop = RNA_def_property(cont, identifier, PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, type);
RNA_def_property_ui_text(prop, ui_name, ui_description);
@@ -3119,7 +3129,7 @@ PropertyRNA *RNA_def_collection_runtime(StructOrFunctionRNA *cont_, const char *
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
prop = RNA_def_property(cont, identifier, PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, type);
RNA_def_property_ui_text(prop, ui_name, ui_description);
@@ -3576,7 +3586,7 @@ void RNA_def_property_free_pointers(PropertyRNA *prop)
static void rna_def_property_free(StructOrFunctionRNA *cont_, PropertyRNA *prop)
{
ContainerRNA *cont = cont_;
-
+
if (prop->flag_internal & PROP_INTERN_RUNTIME) {
if (cont->prophash)
BLI_ghash_remove(cont->prophash, prop->identifier, NULL, NULL);
@@ -3594,7 +3604,7 @@ int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *ide
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
for (prop = cont->properties.first; prop; prop = prop->next) {
if (STREQ(prop->identifier, identifier)) {
if (prop->flag_internal & PROP_INTERN_RUNTIME) {
diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c
index f3c8da39db0..3e85e225d27 100644
--- a/source/blender/makesrna/intern/rna_depsgraph.c
+++ b/source/blender/makesrna/intern/rna_depsgraph.c
@@ -44,21 +44,23 @@
#include "BLI_iterator.h"
+#include "BKE_anim.h"
+
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_debug.h"
#include "DEG_depsgraph_query.h"
#include "MEM_guardedalloc.h"
-/* **************** Depsgraph **************** */
+/* **************** Object Instance **************** */
-static PointerRNA rna_DepsgraphIter_object_get(PointerRNA *ptr)
+static PointerRNA rna_DepsgraphObjectInstance_object_get(PointerRNA *ptr)
{
BLI_Iterator *iterator = ptr->data;
return rna_pointer_inherit_refine(ptr, &RNA_Object, iterator->current);
}
-static PointerRNA rna_DepsgraphIter_instance_object_get(PointerRNA *ptr)
+static PointerRNA rna_DepsgraphObjectInstance_instance_object_get(PointerRNA *ptr)
{
BLI_Iterator *iterator = ptr->data;
DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
@@ -69,7 +71,7 @@ static PointerRNA rna_DepsgraphIter_instance_object_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_Object, instance_object);
}
-static PointerRNA rna_DepsgraphIter_parent_get(PointerRNA *ptr)
+static PointerRNA rna_DepsgraphObjectInstance_parent_get(PointerRNA *ptr)
{
BLI_Iterator *iterator = ptr->data;
DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
@@ -80,7 +82,7 @@ static PointerRNA rna_DepsgraphIter_parent_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_Object, dupli_parent);
}
-static PointerRNA rna_DepsgraphIter_particle_system_get(PointerRNA *ptr)
+static PointerRNA rna_DepsgraphObjectInstance_particle_system_get(PointerRNA *ptr)
{
BLI_Iterator *iterator = ptr->data;
DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
@@ -88,7 +90,7 @@ static PointerRNA rna_DepsgraphIter_particle_system_get(PointerRNA *ptr)
deg_iter->dupli_object_current->particle_system);
}
-static void rna_DepsgraphIter_persistent_id_get(PointerRNA *ptr, int *persistent_id)
+static void rna_DepsgraphObjectInstance_persistent_id_get(PointerRNA *ptr, int *persistent_id)
{
BLI_Iterator *iterator = ptr->data;
DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
@@ -96,7 +98,7 @@ static void rna_DepsgraphIter_persistent_id_get(PointerRNA *ptr, int *persistent
sizeof(deg_iter->dupli_object_current->persistent_id));
}
-static void rna_DepsgraphIter_orco_get(PointerRNA *ptr, float *orco)
+static void rna_DepsgraphObjectInstance_orco_get(PointerRNA *ptr, float *orco)
{
BLI_Iterator *iterator = ptr->data;
DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
@@ -104,14 +106,14 @@ static void rna_DepsgraphIter_orco_get(PointerRNA *ptr, float *orco)
sizeof(deg_iter->dupli_object_current->orco));
}
-static unsigned int rna_DepsgraphIter_random_id_get(PointerRNA *ptr)
+static unsigned int rna_DepsgraphObjectInstance_random_id_get(PointerRNA *ptr)
{
BLI_Iterator *iterator = ptr->data;
DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
return deg_iter->dupli_object_current->random_id;
}
-static void rna_DepsgraphIter_uv_get(PointerRNA *ptr, float *uv)
+static void rna_DepsgraphObjectInstance_uv_get(PointerRNA *ptr, float *uv)
{
BLI_Iterator *iterator = ptr->data;
DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
@@ -119,13 +121,51 @@ static void rna_DepsgraphIter_uv_get(PointerRNA *ptr, float *uv)
sizeof(deg_iter->dupli_object_current->uv));
}
-static int rna_DepsgraphIter_is_instance_get(PointerRNA *ptr)
+static int rna_DepsgraphObjectInstance_is_instance_get(PointerRNA *ptr)
{
BLI_Iterator *iterator = ptr->data;
DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
return (deg_iter->dupli_object_current != NULL);
}
+/* ******************** Sorted ***************** */
+
+static int rna_Depsgraph_mode_get(PointerRNA *ptr)
+{
+ Depsgraph *depsgraph = ptr->data;
+ return DEG_get_mode(depsgraph);
+}
+
+/* ******************** Updates ***************** */
+
+static PointerRNA rna_DepsgraphUpdate_id_get(PointerRNA *ptr)
+{
+ return rna_pointer_inherit_refine(ptr, &RNA_ID, ptr->data);
+}
+
+static int rna_DepsgraphUpdate_updated_transform_get(PointerRNA *ptr)
+{
+ ID *id = ptr->data;
+ return ((id->recalc & ID_RECALC_TRANSFORM) != 0);
+}
+
+static int rna_DepsgraphUpdate_updated_geometry_get(PointerRNA *ptr)
+{
+ ID *id = ptr->data;
+ if (id->recalc & ID_RECALC_GEOMETRY) {
+ return true;
+ }
+ if (GS(id->name) != ID_OB) {
+ return false;
+ }
+ Object *object = (Object *)id;
+ ID *data = object->data;
+ if (data == NULL) {
+ return 0;
+ }
+ return ((data->recalc & ID_RECALC_ALL) != 0);
+}
+
/* **************** Depsgraph **************** */
static void rna_Depsgraph_debug_relations_graphviz(Depsgraph *depsgraph,
@@ -176,7 +216,6 @@ static void rna_Depsgraph_objects_begin(CollectionPropertyIterator *iter, Pointe
data->flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
DEG_ITER_OBJECT_FLAG_VISIBLE |
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET;
- data->mode = DEG_ITER_OBJECT_MODE_RENDER;
((BLI_Iterator *)iter->internal.custom)->valid = true;
DEG_iterator_objects_begin(iter->internal.custom, data);
@@ -207,7 +246,7 @@ static PointerRNA rna_Depsgraph_objects_get(CollectionPropertyIterator *iter)
* Contains extra information about duplicator and persistent ID.
*/
-static void rna_Depsgraph_duplis_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+static void rna_Depsgraph_object_instances_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__);
DEGObjectIterData *data = MEM_callocN(sizeof(DEGObjectIterData), __func__);
@@ -217,30 +256,81 @@ static void rna_Depsgraph_duplis_begin(CollectionPropertyIterator *iter, Pointer
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
DEG_ITER_OBJECT_FLAG_VISIBLE |
DEG_ITER_OBJECT_FLAG_DUPLI;
- data->mode = DEG_ITER_OBJECT_MODE_RENDER;
((BLI_Iterator *)iter->internal.custom)->valid = true;
DEG_iterator_objects_begin(iter->internal.custom, data);
iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
}
-static void rna_Depsgraph_duplis_next(CollectionPropertyIterator *iter)
+static void rna_Depsgraph_object_instances_next(CollectionPropertyIterator *iter)
{
DEG_iterator_objects_next(iter->internal.custom);
iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
}
-static void rna_Depsgraph_duplis_end(CollectionPropertyIterator *iter)
+static void rna_Depsgraph_object_instances_end(CollectionPropertyIterator *iter)
{
DEG_iterator_objects_end(iter->internal.custom);
MEM_freeN(((BLI_Iterator *)iter->internal.custom)->data);
MEM_freeN(iter->internal.custom);
}
-static PointerRNA rna_Depsgraph_duplis_get(CollectionPropertyIterator *iter)
+static PointerRNA rna_Depsgraph_object_instances_get(CollectionPropertyIterator *iter)
{
BLI_Iterator *iterator = (BLI_Iterator *)iter->internal.custom;
- return rna_pointer_inherit_refine(&iter->parent, &RNA_DepsgraphIter, iterator);
+ return rna_pointer_inherit_refine(&iter->parent, &RNA_DepsgraphObjectInstance, iterator);
+}
+
+/* Iteration over evaluated IDs */
+
+static void rna_Depsgraph_ids_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__);
+ DEGIDIterData *data = MEM_callocN(sizeof(DEGIDIterData), __func__);
+
+ data->graph = (Depsgraph *)ptr->data;
+
+ ((BLI_Iterator *)iter->internal.custom)->valid = true;
+ DEG_iterator_ids_begin(iter->internal.custom, data);
+ iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
+}
+
+static void rna_Depsgraph_ids_next(CollectionPropertyIterator *iter)
+{
+ DEG_iterator_ids_next(iter->internal.custom);
+ iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
+}
+
+static void rna_Depsgraph_ids_end(CollectionPropertyIterator *iter)
+{
+ DEG_iterator_ids_end(iter->internal.custom);
+ MEM_freeN(((BLI_Iterator *)iter->internal.custom)->data);
+ MEM_freeN(iter->internal.custom);
+}
+
+static PointerRNA rna_Depsgraph_ids_get(CollectionPropertyIterator *iter)
+{
+ ID *id = ((BLI_Iterator *)iter->internal.custom)->current;
+ return rna_pointer_inherit_refine(&iter->parent, &RNA_ID, id);
+}
+
+static void rna_Depsgraph_updates_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__);
+ DEGIDIterData *data = MEM_callocN(sizeof(DEGIDIterData), __func__);
+
+ data->graph = (Depsgraph *)ptr->data;
+ data->only_updated = true;
+
+ ((BLI_Iterator *)iter->internal.custom)->valid = true;
+ DEG_iterator_ids_begin(iter->internal.custom, data);
+ iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
+}
+
+static PointerRNA rna_Depsgraph_updates_get(CollectionPropertyIterator *iter)
+{
+ ID *id = ((BLI_Iterator *)iter->internal.custom)->current;
+ return rna_pointer_inherit_refine(&iter->parent, &RNA_DepsgraphUpdate, id);
}
static ID *rna_Depsgraph_id_eval_get(Depsgraph *depsgraph, ID *id_orig)
@@ -248,6 +338,11 @@ static ID *rna_Depsgraph_id_eval_get(Depsgraph *depsgraph, ID *id_orig)
return DEG_get_evaluated_id(depsgraph, id_orig);
}
+static int rna_Depsgraph_id_type_updated(Depsgraph *depsgraph, int id_type)
+{
+ return DEG_id_type_updated(depsgraph, id_type);
+}
+
static PointerRNA rna_Depsgraph_scene_get(PointerRNA *ptr)
{
Depsgraph *depsgraph = (Depsgraph *)ptr->data;
@@ -278,45 +373,45 @@ static PointerRNA rna_Depsgraph_view_layer_eval_get(PointerRNA *ptr)
#else
-static void rna_def_depsgraph_iter(BlenderRNA *brna)
+static void rna_def_depsgraph_instance(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
- srna = RNA_def_struct(brna, "DepsgraphIter", NULL);
- RNA_def_struct_ui_text(srna, "Dependency Graph Iterator",
+ srna = RNA_def_struct(brna, "DepsgraphObjectInstance", NULL);
+ RNA_def_struct_ui_text(srna, "Dependency Graph Object Instance",
"Extended information about dependency graph object iterator");
prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_ui_text(prop, "Object", "Object the iterator points to");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_pointer_funcs(prop, "rna_DepsgraphIter_object_get", NULL, NULL, NULL);
+ RNA_def_property_pointer_funcs(prop, "rna_DepsgraphObjectInstance_object_get", NULL, NULL, NULL);
prop = RNA_def_property(srna, "instance_object", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_ui_text(prop, "Instance Object", "Object which is being instanced by this iterator");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_pointer_funcs(prop, "rna_DepsgraphIter_instance_object_get", NULL, NULL, NULL);
+ RNA_def_property_pointer_funcs(prop, "rna_DepsgraphObjectInstance_instance_object_get", NULL, NULL, NULL);
prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_ui_text(prop, "Parent", "Parent of the duplication list");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_pointer_funcs(prop, "rna_DepsgraphIter_parent_get", NULL, NULL, NULL);
+ RNA_def_property_pointer_funcs(prop, "rna_DepsgraphObjectInstance_parent_get", NULL, NULL, NULL);
prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "ParticleSystem");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Particle System", "Particle system that this object was instanced from");
- RNA_def_property_pointer_funcs(prop, "rna_DepsgraphIter_particle_system_get", NULL, NULL, NULL);
+ RNA_def_property_pointer_funcs(prop, "rna_DepsgraphObjectInstance_particle_system_get", NULL, NULL, NULL);
prop = RNA_def_property(srna, "persistent_id", PROP_INT, PROP_NONE);
RNA_def_property_ui_text(prop, "Persistent ID",
"Persistent identifier for inter-frame matching of objects with motion blur");
RNA_def_property_array(prop, 2 * MAX_DUPLI_RECUR);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_int_funcs(prop, "rna_DepsgraphIter_persistent_id_get", NULL, NULL);
+ RNA_def_property_int_funcs(prop, "rna_DepsgraphObjectInstance_persistent_id_get", NULL, NULL);
prop = RNA_def_property(srna, "orco", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
@@ -325,23 +420,49 @@ static void rna_def_depsgraph_iter(BlenderRNA *brna)
*/
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Generated Coordinates", "Generated coordinates in parent object space");
- RNA_def_property_float_funcs(prop, "rna_DepsgraphIter_orco_get", NULL, NULL);
+ RNA_def_property_float_funcs(prop, "rna_DepsgraphObjectInstance_orco_get", NULL, NULL);
prop = RNA_def_property(srna, "random_id", PROP_INT, PROP_UNSIGNED);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Dupli random id", "Random id for this dupli object");
- RNA_def_property_int_funcs(prop, "rna_DepsgraphIter_random_id_get", NULL, NULL);
+ RNA_def_property_int_funcs(prop, "rna_DepsgraphObjectInstance_random_id_get", NULL, NULL);
prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space");
RNA_def_property_array(prop, 2);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_float_funcs(prop, "rna_DepsgraphIter_uv_get", NULL, NULL);
+ RNA_def_property_float_funcs(prop, "rna_DepsgraphObjectInstance_uv_get", NULL, NULL);
prop = RNA_def_property(srna, "is_instance", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Is Instance", "Denotes whether the object is ocming from dupli-list");
- RNA_def_property_boolean_funcs(prop, "rna_DepsgraphIter_is_instance_get", NULL);
+ RNA_def_property_ui_text(prop, "Is Instance", "Denotes whether the object is coming from dupli-list");
+ RNA_def_property_boolean_funcs(prop, "rna_DepsgraphObjectInstance_is_instance_get", NULL);
+}
+
+static void rna_def_depsgraph_update(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "DepsgraphUpdate", NULL);
+ RNA_def_struct_ui_text(srna, "Dependency Graph Update",
+ "Information about ID that was updated");
+
+ prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "ID");
+ RNA_def_property_ui_text(prop, "ID", "Updated datablock");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
+ RNA_def_property_pointer_funcs(prop, "rna_DepsgraphUpdate_id_get", NULL, NULL, NULL);
+
+ prop = RNA_def_property(srna, "updated_transform", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Transform", "Object transformation was updated");
+ RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_updated_transform_get", NULL);
+
+ prop = RNA_def_property(srna, "updated_geometry", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Geometry", "Object geometry was updated");
+ RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_updated_geometry_get", NULL);
}
static void rna_def_depsgraph(BlenderRNA *brna)
@@ -351,9 +472,19 @@ static void rna_def_depsgraph(BlenderRNA *brna)
PropertyRNA *parm;
PropertyRNA *prop;
+ static EnumPropertyItem enum_depsgraph_mode_items[] = {
+ {DAG_EVAL_VIEWPORT, "VIEWPORT", 0, "Viewport", "Viewport non-rendered mode"},
+ {DAG_EVAL_RENDER, "RENDER", 0, "Render", "Render"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
srna = RNA_def_struct(brna, "Depsgraph", NULL);
RNA_def_struct_ui_text(srna, "Dependency Graph", "");
+ prop = RNA_def_enum(srna, "mode", enum_depsgraph_mode_items, 0, "Mode", "Evaluation mode");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_enum_funcs(prop, "rna_Depsgraph_mode_get", NULL, NULL);
+
/* Debug helpers. */
func = RNA_def_function(srna, "debug_relations_graphviz", "rna_Depsgraph_debug_relations_graphviz");
@@ -400,6 +531,12 @@ static void rna_def_depsgraph(BlenderRNA *brna)
parm = RNA_def_pointer(func, "id_eval", "ID", "", "Evaluated ID for the given original one");
RNA_def_function_return(func, parm);
+ func = RNA_def_function(srna, "id_type_updated", "rna_Depsgraph_id_type_updated");
+ parm = RNA_def_enum(func, "id_type", rna_enum_id_type_items, 0, "ID Type", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_boolean(func, "updated", false, "Updated", "True if any datablock with this type was added, updated or removed");
+ RNA_def_function_return(func, parm);
+
prop = RNA_def_property(srna, "scene_eval", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Scene");
RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_scene_eval_get", NULL, NULL, NULL);
@@ -414,6 +551,16 @@ static void rna_def_depsgraph(BlenderRNA *brna)
/* Iterators. */
+ prop = RNA_def_property(srna, "ids", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_struct_type(prop, "ID");
+ RNA_def_property_collection_funcs(prop,
+ "rna_Depsgraph_ids_begin",
+ "rna_Depsgraph_ids_next",
+ "rna_Depsgraph_ids_end",
+ "rna_Depsgraph_ids_get",
+ NULL, NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop, "IDs", "All evaluated datablocks");
+
prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_collection_funcs(prop,
@@ -422,21 +569,33 @@ static void rna_def_depsgraph(BlenderRNA *brna)
"rna_Depsgraph_objects_end",
"rna_Depsgraph_objects_get",
NULL, NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop, "Objects", "Evaluated objects in the dependency graph");
+
+ prop = RNA_def_property(srna, "object_instances", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_struct_type(prop, "DepsgraphObjectInstance");
+ RNA_def_property_collection_funcs(prop,
+ "rna_Depsgraph_object_instances_begin",
+ "rna_Depsgraph_object_instances_next",
+ "rna_Depsgraph_object_instances_end",
+ "rna_Depsgraph_object_instances_get",
+ NULL, NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop, "Object Instances", "All object instances to display or render");
- /* TODO(sergey): Find a better name. */
- prop = RNA_def_property(srna, "duplis", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_struct_type(prop, "DepsgraphIter");
+ prop = RNA_def_property(srna, "updates", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_struct_type(prop, "DepsgraphUpdate");
RNA_def_property_collection_funcs(prop,
- "rna_Depsgraph_duplis_begin",
- "rna_Depsgraph_duplis_next",
- "rna_Depsgraph_duplis_end",
- "rna_Depsgraph_duplis_get",
+ "rna_Depsgraph_updates_begin",
+ "rna_Depsgraph_ids_next",
+ "rna_Depsgraph_ids_end",
+ "rna_Depsgraph_updates_get",
NULL, NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop, "Updates", "Updates to datablocks");
}
void RNA_def_depsgraph(BlenderRNA *brna)
{
- rna_def_depsgraph_iter(brna);
+ rna_def_depsgraph_instance(brna);
+ rna_def_depsgraph_update(brna);
rna_def_depsgraph(brna);
}
diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c
index 0358efff266..509265c04df 100644
--- a/source/blender/makesrna/intern/rna_dynamicpaint.c
+++ b/source/blender/makesrna/intern/rna_dynamicpaint.c
@@ -438,7 +438,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_dissolve", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DISSOLVE);
RNA_def_property_ui_text(prop, "Dissolve", "Enable to make surface changes disappear over time");
-
+
prop = RNA_def_property(srna, "dissolve_speed", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "diss_speed");
RNA_def_property_range(prop, 1.0, 10000.0);
@@ -448,12 +448,12 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_drying", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_USE_DRYING);
RNA_def_property_ui_text(prop, "Dry", "Enable to make surface wetness dry over time");
-
+
prop = RNA_def_property(srna, "dry_speed", PROP_INT, PROP_NONE);
RNA_def_property_range(prop, 1.0, 10000.0);
RNA_def_property_ui_range(prop, 1.0, 10000.0, 5, -1);
RNA_def_property_ui_text(prop, "Dry Speed", "Approximately in how many frames should drying happen");
-
+
/*
* Simulation settings
*/
@@ -462,12 +462,12 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_range(prop, 16.0, 4096.0);
RNA_def_property_ui_range(prop, 16.0, 4096.0, 1, -1);
RNA_def_property_ui_text(prop, "Resolution", "Output image resolution");
-
+
prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "uvlayer_name");
RNA_def_property_ui_text(prop, "UV Map", "UV map name");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_DynamicPaint_uvlayer_set");
-
+
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "start_frame");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -475,7 +475,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 1.0, 9999, 1, -1);
RNA_def_property_ui_text(prop, "Start Frame", "Simulation start frame");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurfaces_updateFrames");
-
+
prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "end_frame");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -483,13 +483,13 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 1.0, 9999.0, 1, -1);
RNA_def_property_ui_text(prop, "End Frame", "Simulation end frame");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurfaces_updateFrames");
-
+
prop = RNA_def_property(srna, "frame_substeps", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "substeps");
RNA_def_property_range(prop, 0.0, 20.0);
RNA_def_property_ui_range(prop, 0.0, 10, 1, -1);
RNA_def_property_ui_text(prop, "Sub-Steps", "Do extra frames between scene frames to ensure smooth motion");
-
+
prop = RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_ANTIALIAS);
@@ -542,7 +542,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_items(prop, prop_dynamicpaint_effecttype);
RNA_def_property_ui_text(prop, "Effect Type", "");
-
+
prop = RNA_def_property(srna, "use_dry_log", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DRY_LOG);
RNA_def_property_ui_text(prop, "Slow", "Use logarithmic drying (makes high values to dry faster than low values)");
@@ -551,13 +551,13 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DISSOLVE_LOG);
RNA_def_property_ui_text(prop, "Slow",
"Use logarithmic dissolve (makes high values to fade faster than low values)");
-
+
prop = RNA_def_property(srna, "use_spread", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "effect", MOD_DPAINT_EFFECT_DO_SPREAD);
RNA_def_property_ui_text(prop, "Use Spread", "Process spread effect (spread wet paint around surface)");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurface_reset");
-
+
prop = RNA_def_property(srna, "spread_speed", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "spread_speed");
RNA_def_property_range(prop, 0.001, 10.0);
@@ -575,19 +575,19 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0, 2.0);
RNA_def_property_ui_range(prop, 0.0, 2.0, 1, 2);
RNA_def_property_ui_text(prop, "Color Spread", "How fast colors get mixed within wet paint");
-
+
prop = RNA_def_property(srna, "use_drip", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "effect", MOD_DPAINT_EFFECT_DO_DRIP);
RNA_def_property_ui_text(prop, "Use Drip", "Process drip effect (drip wet paint to gravity direction)");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurface_reset");
-
+
prop = RNA_def_property(srna, "use_shrink", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "effect", MOD_DPAINT_EFFECT_DO_SHRINK);
RNA_def_property_ui_text(prop, "Use Shrink", "Process shrink effect (shrink paint areas)");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurface_reset");
-
+
prop = RNA_def_property(srna, "shrink_speed", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "shrink_speed");
RNA_def_property_range(prop, 0.001, 10.0);
@@ -618,7 +618,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_MULALPHA);
RNA_def_property_ui_text(prop, "Premultiply alpha", "Multiply color by alpha (recommended for Blender input)");
-
+
prop = RNA_def_property(srna, "image_output_path", PROP_STRING, PROP_DIRPATH);
RNA_def_property_string_sdna(prop, NULL, "image_output_path");
RNA_def_property_ui_text(prop, "Output Path", "Directory to save the textures");
@@ -658,7 +658,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
/* return type */
parm = RNA_def_boolean(func, "exists", 0, "", "");
RNA_def_function_return(func, parm);
-
+
prop = RNA_def_property(srna, "depth_clamp", PROP_FLOAT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.00, 50.0);
@@ -674,12 +674,12 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_ui_range(prop, -5.0, 5.0, 1, 2);
RNA_def_property_ui_text(prop, "Displace Factor", "Strength of displace when applied to the mesh");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
+
prop = RNA_def_property(srna, "image_fileformat", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_items(prop, prop_dynamicpaint_image_fileformat);
RNA_def_property_ui_text(prop, "File Format", "");
-
+
prop = RNA_def_property(srna, "displace_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "disp_type");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -824,12 +824,12 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.0, 1.0, 5, 2);
RNA_def_property_ui_text(prop, "Paint Alpha", "Paint alpha");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
+
prop = RNA_def_property(srna, "use_absolute_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_ABS_ALPHA);
RNA_def_property_ui_text(prop, "Absolute Alpha",
"Only increase alpha value if paint alpha is higher than existing");
-
+
prop = RNA_def_property(srna, "paint_wetness", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "wetness");
RNA_def_property_range(prop, 0.0, 1.0);
@@ -837,7 +837,7 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Paint Wetness",
"Paint wetness, visible in wetmap (some effects only affect wet paint)");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
+
prop = RNA_def_property(srna, "use_paint_erase", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_ERASE);
RNA_def_property_ui_text(prop, "Erase Paint", "Erase / remove paint instead of adding it");
@@ -890,7 +890,7 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_VELOCITY_COLOR);
RNA_def_property_ui_text(prop, "Replace Color", "Replace brush color by velocity color ramp");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
+
/*
* Paint Area / Collision
*/
@@ -900,7 +900,7 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna)
RNA_def_property_enum_items(prop, prop_dynamicpaint_collisiontype);
RNA_def_property_ui_text(prop, "Paint Source", "");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
+
prop = RNA_def_property(srna, "paint_distance", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "paint_distance");
RNA_def_property_range(prop, 0.0, 500.0);
@@ -908,19 +908,19 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Proximity Distance",
"Maximum distance from brush to mesh surface to affect paint");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
+
prop = RNA_def_property(srna, "use_proximity_ramp_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_RAMP_ALPHA);
RNA_def_property_ui_text(prop, "Only Use Alpha", "Only read color ramp alpha");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
+
prop = RNA_def_property(srna, "proximity_falloff", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_sdna(prop, NULL, "proximity_falloff");
RNA_def_property_enum_items(prop, prop_dynamicpaint_prox_falloff);
RNA_def_property_ui_text(prop, "Falloff", "Proximity falloff type");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
+
prop = RNA_def_property(srna, "use_proximity_project", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_PROX_PROJECT);
RNA_def_property_ui_text(prop, "Project",
@@ -944,7 +944,7 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_NEGATE_VOLUME);
RNA_def_property_ui_text(prop, "Negate Volume", "Negate influence inside the volume");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
+
/*
* Particle
@@ -956,12 +956,12 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Particle Systems", "The particle system to paint with");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_reset_dependency");
-
+
prop = RNA_def_property(srna, "use_particle_radius", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_PART_RAD);
RNA_def_property_ui_text(prop, "Use Particle Radius", "Use radius from particle settings");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
+
prop = RNA_def_property(srna, "solid_radius", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "particle_radius");
RNA_def_property_range(prop, 0.01, 10.0);
@@ -975,7 +975,7 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.0, 1.0, 5, -1);
RNA_def_property_ui_text(prop, "Smooth Radius", "Smooth falloff added after solid radius");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
+
/*
* Color ramps
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index d48a0cacd18..64d6960d0ff 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -85,7 +85,7 @@ const EnumPropertyItem rna_enum_beztriple_interpolation_easing_items[] = {
{BEZT_IPO_EASE_AUTO, "AUTO", ICON_IPO_EASE_IN_OUT, "Automatic Easing",
"Easing type is chosen automatically based on what the type of interpolation used "
"(e.g. 'Ease In' for transitional types, and 'Ease Out' for dynamic effects)"},
-
+
{BEZT_IPO_EASE_IN, "EASE_IN", ICON_IPO_EASE_IN, "Ease In", "Only on the end closest to the next keyframe"},
{BEZT_IPO_EASE_OUT, "EASE_OUT", ICON_IPO_EASE_OUT, "Ease Out", "Only on the end closest to the first keyframe"},
{BEZT_IPO_EASE_IN_OUT, "EASE_IN_OUT", ICON_IPO_EASE_IN_OUT, "Ease In and Out", "Segment between both keyframes"},
@@ -138,21 +138,21 @@ static void rna_ChannelDriver_update_data(Main *bmain, Scene *scene, PointerRNA
ChannelDriver *driver = ptr->data;
driver->flag &= ~DRIVER_FLAG_INVALID;
-
+
/* TODO: this really needs an update guard... */
DEG_relations_tag_update(bmain);
DEG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA);
-
+
WM_main_add_notifier(NC_SCENE | ND_FRAME, scene);
}
static void rna_ChannelDriver_update_expr(Main *bmain, Scene *scene, PointerRNA *ptr)
{
ChannelDriver *driver = ptr->data;
-
+
/* tag driver as needing to be recompiled */
driver->flag |= DRIVER_FLAG_RECOMPILE;
-
+
/* update_data() clears invalid flag and schedules for updates */
rna_ChannelDriver_update_data(bmain, scene, ptr);
}
@@ -168,7 +168,7 @@ static void rna_DriverTarget_update_data(Main *bmain, Scene *scene, PointerRNA *
for (fcu = adt->drivers.first; fcu; fcu = fcu->next) {
driver = fcu->driver;
fcu->flag &= ~FCURVE_DISABLED;
-
+
if (driver) {
/* FIXME: need to be able to search targets for required one... */
/*BLI_findindex(&driver->targets, ptr->data) != -1) */
@@ -212,7 +212,7 @@ static int rna_DriverTarget_id_editable(PointerRNA *ptr, const char **UNUSED(r_i
static int rna_DriverTarget_id_type_editable(PointerRNA *ptr, const char **UNUSED(r_info))
{
DriverTarget *dtar = (DriverTarget *)ptr->data;
-
+
/* when the id-type can only be object, don't allow editing
* otherwise, there may be strange crashes
*/
@@ -222,7 +222,7 @@ static int rna_DriverTarget_id_type_editable(PointerRNA *ptr, const char **UNUSE
static void rna_DriverTarget_id_type_set(PointerRNA *ptr, int value)
{
DriverTarget *data = (DriverTarget *)(ptr->data);
-
+
/* check if ID-type is settable */
if ((data->flag & DTAR_FLAG_ID_OB_ONLY) == 0) {
/* change ID-type to the new type */
@@ -232,7 +232,7 @@ static void rna_DriverTarget_id_type_set(PointerRNA *ptr, int value)
/* make sure ID-type is Object */
data->idtype = ID_OB;
}
-
+
/* clear the id-block if the type is invalid */
if ((data->id) && (GS(data->id->name) != data->idtype))
data->id = NULL;
@@ -251,7 +251,7 @@ static void rna_DriverTarget_RnaPath_get(PointerRNA *ptr, char *value)
static int rna_DriverTarget_RnaPath_length(PointerRNA *ptr)
{
DriverTarget *dtar = (DriverTarget *)ptr->data;
-
+
if (dtar->rna_path)
return strlen(dtar->rna_path);
else
@@ -261,11 +261,11 @@ static int rna_DriverTarget_RnaPath_length(PointerRNA *ptr)
static void rna_DriverTarget_RnaPath_set(PointerRNA *ptr, const char *value)
{
DriverTarget *dtar = (DriverTarget *)ptr->data;
-
+
/* XXX in this case we need to be very careful, as this will require some new dependencies to be added! */
if (dtar->rna_path)
MEM_freeN(dtar->rna_path);
-
+
if (value[0])
dtar->rna_path = BLI_strdup(value);
else
@@ -275,7 +275,7 @@ static void rna_DriverTarget_RnaPath_set(PointerRNA *ptr, const char *value)
static void rna_DriverVariable_type_set(PointerRNA *ptr, int value)
{
DriverVar *dvar = (DriverVar *)ptr->data;
-
+
/* call the API function for this */
driver_change_variable_type(dvar, value);
}
@@ -283,7 +283,7 @@ static void rna_DriverVariable_type_set(PointerRNA *ptr, int value)
void rna_DriverVariable_name_set(PointerRNA *ptr, const char *value)
{
DriverVar *data = (DriverVar *)(ptr->data);
-
+
BLI_strncpy_utf8(data->name, value, 64);
driver_variable_name_validate(data);
}
@@ -314,7 +314,7 @@ static void rna_Driver_remove_variable(ChannelDriver *driver, ReportList *report
static void rna_FKeyframe_handle1_get(PointerRNA *ptr, float *values)
{
BezTriple *bezt = (BezTriple *)ptr->data;
-
+
values[0] = bezt->vec[0][0];
values[1] = bezt->vec[0][1];
}
@@ -322,7 +322,7 @@ static void rna_FKeyframe_handle1_get(PointerRNA *ptr, float *values)
static void rna_FKeyframe_handle1_set(PointerRNA *ptr, const float *values)
{
BezTriple *bezt = (BezTriple *)ptr->data;
-
+
bezt->vec[0][0] = values[0];
bezt->vec[0][1] = values[1];
}
@@ -330,7 +330,7 @@ static void rna_FKeyframe_handle1_set(PointerRNA *ptr, const float *values)
static void rna_FKeyframe_handle2_get(PointerRNA *ptr, float *values)
{
BezTriple *bezt = (BezTriple *)ptr->data;
-
+
values[0] = bezt->vec[2][0];
values[1] = bezt->vec[2][1];
}
@@ -338,7 +338,7 @@ static void rna_FKeyframe_handle2_get(PointerRNA *ptr, float *values)
static void rna_FKeyframe_handle2_set(PointerRNA *ptr, const float *values)
{
BezTriple *bezt = (BezTriple *)ptr->data;
-
+
bezt->vec[2][0] = values[0];
bezt->vec[2][1] = values[1];
}
@@ -346,7 +346,7 @@ static void rna_FKeyframe_handle2_set(PointerRNA *ptr, const float *values)
static void rna_FKeyframe_ctrlpoint_get(PointerRNA *ptr, float *values)
{
BezTriple *bezt = (BezTriple *)ptr->data;
-
+
values[0] = bezt->vec[1][0];
values[1] = bezt->vec[1][1];
}
@@ -354,7 +354,7 @@ static void rna_FKeyframe_ctrlpoint_get(PointerRNA *ptr, float *values)
static void rna_FKeyframe_ctrlpoint_set(PointerRNA *ptr, const float *values)
{
BezTriple *bezt = (BezTriple *)ptr->data;
-
+
bezt->vec[1][0] = values[0];
bezt->vec[1][1] = values[1];
}
@@ -374,7 +374,7 @@ static void rna_FCurve_RnaPath_get(PointerRNA *ptr, char *value)
static int rna_FCurve_RnaPath_length(PointerRNA *ptr)
{
FCurve *fcu = (FCurve *)ptr->data;
-
+
if (fcu->rna_path)
return strlen(fcu->rna_path);
else
@@ -387,7 +387,7 @@ static void rna_FCurve_RnaPath_set(PointerRNA *ptr, const char *value)
if (fcu->rna_path)
MEM_freeN(fcu->rna_path);
-
+
if (value[0]) {
fcu->rna_path = BLI_strdup(value);
fcu->flag &= ~FCURVE_DISABLED;
@@ -402,7 +402,7 @@ static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
ID *vid = (ID *)value.id.data;
FCurve *fcu = ptr->data;
bAction *act = NULL;
-
+
/* get action */
if (ELEM(NULL, pid, vid)) {
printf("ERROR: one of the ID's for the groups to assign to is invalid (ptr=%p, val=%p)\n", pid, vid);
@@ -413,7 +413,7 @@ static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
printf("ERROR: ID's differ - ptr=%p vs value=%p\n", pid, vid);
return;
}
-
+
if (GS(pid->name) == ID_AC && GS(vid->name) == ID_AC) {
/* the ID given is the action already - usually when F-Curve is obtained from an action's pointer */
act = (bAction *)pid;
@@ -423,14 +423,14 @@ static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
AnimData *adt = BKE_animdata_from_id(ptr->id.data);
act = (adt) ? adt->action : NULL;
}
-
+
/* already belongs to group? */
if (fcu->grp == value.data) {
/* nothing to do */
printf("ERROR: F-Curve already belongs to this group\n");
return;
}
-
+
/* can only change group if we have info about the action the F-Curve is in
* (i.e. for drivers or random F-Curves, this cannot be done)
*/
@@ -444,10 +444,10 @@ static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
printf("ERROR: F-Curve (%p) doesn't exist in action '%s'\n", fcu, act->id.name);
return;
}
-
+
/* try to remove F-Curve from action (including from any existing groups) */
action_groups_remove_channel(act, fcu);
-
+
/* add the F-Curve back to the action now in the right place */
/* TODO: make the api function handle the case where there isn't any group to assign to */
if (value.data) {
@@ -481,6 +481,18 @@ static void rna_FCurve_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), Po
rna_FCurve_update_data_ex((FCurve *)ptr->data);
}
+/* RNA update callback for F-Curves to indicate that there are copy-on-write tagging/flushing needed
+ * (e.g. for properties that affect how animation gets evaluated)
+ */
+static void rna_FCurve_update_eval(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+{
+ IdAdtTemplate *iat = (IdAdtTemplate *)ptr->id.data;
+ if (iat && iat->adt && iat->adt->action) {
+ /* action is separate datablock, needs separate tag */
+ DEG_id_tag_update(&iat->adt->action->id, DEG_TAG_COPY_ON_WRITE);
+ }
+}
+
static PointerRNA rna_FCurve_active_modifier_get(PointerRNA *ptr)
{
@@ -523,10 +535,10 @@ static void rna_FModifier_active_set(PointerRNA *ptr, int UNUSED(value))
static void rna_FModifier_start_frame_set(PointerRNA *ptr, float value)
{
FModifier *fcm = (FModifier *)ptr->data;
-
+
CLAMP(value, MINAFRAMEF, MAXFRAMEF);
fcm->sfra = value;
-
+
/* XXX: maintain old offset? */
if (fcm->sfra >= fcm->efra) {
fcm->efra = fcm->sfra;
@@ -536,10 +548,10 @@ static void rna_FModifier_start_frame_set(PointerRNA *ptr, float value)
static void rna_FModifer_end_frame_set(PointerRNA *ptr, float value)
{
FModifier *fcm = (FModifier *)ptr->data;
-
+
CLAMP(value, MINAFRAMEF, MAXFRAMEF);
fcm->efra = value;
-
+
/* XXX: maintain old offset? */
if (fcm->efra <= fcm->sfra) {
fcm->sfra = fcm->efra;
@@ -550,11 +562,11 @@ static void rna_FModifier_start_frame_range(PointerRNA *UNUSED(ptr), float *min,
float *UNUSED(softmin), float *UNUSED(softmax))
{
// FModifier *fcm = (FModifier *)ptr->data;
-
- /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that,
- * or else it becomes tricky to adjust the range... [#36844]
- *
- * NOTE: we do not set soft-limits on lower bounds, as it's too confusing when you
+
+ /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that,
+ * or else it becomes tricky to adjust the range... [#36844]
+ *
+ * NOTE: we do not set soft-limits on lower bounds, as it's too confusing when you
* can't easily use the slider to set things here
*/
*min = MINAFRAMEF;
@@ -565,13 +577,13 @@ static void rna_FModifier_end_frame_range(PointerRNA *ptr, float *min, float *ma
float *softmin, float *softmax)
{
FModifier *fcm = (FModifier *)ptr->data;
-
- /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that,
- * or else it becomes tricky to adjust the range... [#36844]
+
+ /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that,
+ * or else it becomes tricky to adjust the range... [#36844]
*/
*min = MINAFRAMEF;
*softmin = (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) ? fcm->sfra : MINAFRAMEF;
-
+
*softmax = MAXFRAMEF;
*max = MAXFRAMEF;
}
@@ -590,10 +602,22 @@ static void rna_FModifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin
ID *id = ptr->id.data;
FModifier *fcm = (FModifier *)ptr->data;
AnimData *adt = BKE_animdata_from_id(id);
+
DEG_id_tag_update(id, (GS(id->name) == ID_OB) ? OB_RECALC_OB : OB_RECALC_DATA);
+
+ /* tag datablock for time update so that animation is recalculated,
+ * as FModifiers affect how animation plays...
+ */
+ DEG_id_tag_update(id, DEG_TAG_TIME);
if (adt != NULL) {
adt->recalc |= ADT_RECALC_ANIM;
+
+ if (adt->action != NULL) {
+ /* action is separate datablock, needs separate tag */
+ DEG_id_tag_update(&adt->action->id, DEG_TAG_COPY_ON_WRITE);
+ }
}
+
if (fcm->curve && fcm->type == FMODIFIER_TYPE_CYCLES) {
calchandles_fcurve(fcm->curve);
}
@@ -658,9 +682,9 @@ static void rna_FModifierLimits_minx_set(PointerRNA *ptr, float value)
{
FModifier *fcm = (FModifier *)ptr->data;
FMod_Limits *data = fcm->data;
-
+
data->rect.xmin = value;
-
+
if (data->rect.xmin >= data->rect.xmax) {
data->rect.xmax = data->rect.xmin;
}
@@ -670,9 +694,9 @@ static void rna_FModifierLimits_maxx_set(PointerRNA *ptr, float value)
{
FModifier *fcm = (FModifier *)ptr->data;
FMod_Limits *data = fcm->data;
-
+
data->rect.xmax = value;
-
+
if (data->rect.xmax <= data->rect.xmin) {
data->rect.xmin = data->rect.xmax;
}
@@ -682,9 +706,9 @@ static void rna_FModifierLimits_miny_set(PointerRNA *ptr, float value)
{
FModifier *fcm = (FModifier *)ptr->data;
FMod_Limits *data = fcm->data;
-
+
data->rect.ymin = value;
-
+
if (data->rect.ymin >= data->rect.ymax) {
data->rect.ymax = data->rect.ymin;
}
@@ -694,9 +718,9 @@ static void rna_FModifierLimits_maxy_set(PointerRNA *ptr, float value)
{
FModifier *fcm = (FModifier *)ptr->data;
FMod_Limits *data = fcm->data;
-
+
data->rect.ymax = value;
-
+
if (data->rect.ymax <= data->rect.ymin) {
data->rect.ymin = data->rect.ymax;
}
@@ -707,7 +731,7 @@ static void rna_FModifierLimits_minx_range(PointerRNA *UNUSED(ptr), float *min,
{
// FModifier *fcm = (FModifier *)ptr->data;
// FMod_Limits *data = fcm->data;
-
+
/* no soft-limits on lower bound - it's too confusing when you can't easily use the slider to set things here */
*min = MINAFRAMEF;
*max = MAXFRAMEF;
@@ -718,10 +742,10 @@ static void rna_FModifierLimits_maxx_range(PointerRNA *ptr, float *min, float *m
{
FModifier *fcm = (FModifier *)ptr->data;
FMod_Limits *data = fcm->data;
-
+
*min = MINAFRAMEF;
*softmin = (data->flag & FCM_LIMIT_XMIN) ? data->rect.xmin : MINAFRAMEF;
-
+
*softmax = MAXFRAMEF;
*max = MAXFRAMEF;
}
@@ -731,7 +755,7 @@ static void rna_FModifierLimits_miny_range(PointerRNA *UNUSED(ptr), float *min,
{
// FModifier *fcm = (FModifier *)ptr->data;
// FMod_Limits *data = fcm->data;
-
+
/* no soft-limits on lower bound - it's too confusing when you can't easily use the slider to set things here */
*min = -FLT_MAX;
*max = FLT_MAX;
@@ -742,12 +766,12 @@ static void rna_FModifierLimits_maxy_range(PointerRNA *ptr, float *min, float *m
{
FModifier *fcm = (FModifier *)ptr->data;
FMod_Limits *data = fcm->data;
-
+
*min = -FLT_MAX;
*softmin = (data->flag & FCM_LIMIT_YMIN) ? data->rect.ymin : -FLT_MAX;
-
+
*softmax = FLT_MAX;
- *max = FLT_MAX;
+ *max = FLT_MAX;
}
@@ -756,7 +780,7 @@ static void rna_FModifierStepped_start_frame_range(PointerRNA *ptr, float *min,
{
FModifier *fcm = (FModifier *)ptr->data;
FMod_Stepped *data = fcm->data;
-
+
*min = MINAFRAMEF;
*max = (data->flag & FCM_STEPPED_NO_AFTER) ? data->end_frame : MAXFRAMEF;
}
@@ -775,12 +799,12 @@ static void rna_FModifierStepped_frame_start_set(PointerRNA *ptr, float value)
{
FModifier *fcm = (FModifier *)ptr->data;
FMod_Stepped *data = fcm->data;
-
+
float prop_clamp_min = -FLT_MAX, prop_clamp_max = FLT_MAX, prop_soft_min, prop_soft_max;
rna_FModifierStepped_start_frame_range(ptr, &prop_clamp_min, &prop_clamp_max, &prop_soft_min, &prop_soft_max);
value = CLAMPIS(value, prop_clamp_min, prop_clamp_max);
-
- /* Need to set both step-data's start/end and the start/end on the base-data,
+
+ /* Need to set both step-data's start/end and the start/end on the base-data,
* or else Restrict-Range doesn't work due to RNA-property shadowing (T52009)
*/
data->start_frame = value;
@@ -791,12 +815,12 @@ static void rna_FModifierStepped_frame_end_set(PointerRNA *ptr, float value)
{
FModifier *fcm = (FModifier *)ptr->data;
FMod_Stepped *data = fcm->data;
-
+
float prop_clamp_min = -FLT_MAX, prop_clamp_max = FLT_MAX, prop_soft_min, prop_soft_max;
rna_FModifierStepped_end_frame_range(ptr, &prop_clamp_min, &prop_clamp_max, &prop_soft_min, &prop_soft_max);
value = CLAMPIS(value, prop_clamp_min, prop_clamp_max);
-
- /* Need to set both step-data's start/end and the start/end on the base-data,
+
+ /* Need to set both step-data's start/end and the start/end on the base-data,
* or else Restrict-Range doesn't work due to RNA-property shadowing (T52009)
*/
data->end_frame = value;
@@ -815,10 +839,10 @@ static void rna_FKeyframe_points_add(FCurve *fcu, int tot)
BezTriple *bezt;
fcu->bezt = MEM_recallocN(fcu->bezt, sizeof(BezTriple) * (fcu->totvert + tot));
-
+
bezt = fcu->bezt + fcu->totvert;
fcu->totvert += tot;
-
+
while (tot--) {
/* defaults, no userprefs gives predictable results for API */
bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
@@ -922,17 +946,17 @@ static void rna_def_fmodifier_generator(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem generator_mode_items[] = {
{FCM_GENERATOR_POLYNOMIAL, "POLYNOMIAL", 0, "Expanded Polynomial", ""},
{FCM_GENERATOR_POLYNOMIAL_FACTORISED, "POLYNOMIAL_FACTORISED", 0, "Factorized Polynomial", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "FModifierGenerator", "FModifier");
RNA_def_struct_ui_text(srna, "Generator F-Modifier", "Deterministically generate values for the modified F-Curve");
RNA_def_struct_sdna_from(srna, "FMod_Generator", "data");
-
+
/* define common props */
prop = RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_GENERATOR_ADDITIVE);
@@ -940,19 +964,19 @@ static void rna_def_fmodifier_generator(BlenderRNA *brna)
"Values generated by this modifier are applied on top of "
"the existing values instead of overwriting them");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, generator_mode_items);
RNA_def_property_ui_text(prop, "Mode", "Type of generator to use");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_verify_data_update");
-
+
/* order of the polynomial */
prop = RNA_def_property(srna, "poly_order", PROP_INT, PROP_NONE);
RNA_def_property_ui_text(prop, "Polynomial Order",
"The highest power of 'x' for this polynomial (number of coefficients - 1)");
RNA_def_property_range(prop, 1, 100);
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_verify_data_update");
-
+
/* coefficients array */
prop = RNA_def_property(srna, "coefficients", PROP_FLOAT, PROP_NONE);
RNA_def_property_array(prop, 32);
@@ -969,7 +993,7 @@ static void rna_def_fmodifier_function_generator(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem prop_type_items[] = {
{0, "SIN", 0, "Sine", ""},
{1, "COS", 0, "Cosine", ""},
@@ -979,28 +1003,28 @@ static void rna_def_fmodifier_function_generator(BlenderRNA *brna)
{5, "SINC", 0, "Normalized Sine", "sin(x) / x"},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "FModifierFunctionGenerator", "FModifier");
RNA_def_struct_ui_text(srna, "Built-In Function F-Modifier", "Generate values using a Built-In Function");
RNA_def_struct_sdna_from(srna, "FMod_FunctionGenerator", "data");
-
+
/* coefficients */
prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_text(prop, "Amplitude", "Scale factor determining the maximum/minimum values");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "phase_multiplier", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_text(prop, "Phase Multiplier", "Scale factor determining the 'speed' of the function");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "phase_offset", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_text(prop, "Phase Offset", "Constant factor to offset time by for function");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "value_offset", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_text(prop, "Value Offset", "Constant factor to offset values by");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
/* flags */
prop = RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_GENERATOR_ADDITIVE);
@@ -1008,7 +1032,7 @@ static void rna_def_fmodifier_function_generator(BlenderRNA *brna)
"Values generated by this modifier are applied on top of "
"the existing values instead of overwriting them");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "function_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, prop_type_items);
@@ -1022,11 +1046,11 @@ static void rna_def_fmodifier_envelope_ctrl(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "FModifierEnvelopeControlPoint", NULL);
RNA_def_struct_ui_text(srna, "Envelope Control Point", "Control point for envelope F-Modifier");
RNA_def_struct_sdna(srna, "FCM_EnvelopeData");
-
+
/* min/max extents
* - for now, these are allowed to go past each other, so that we can have inverted action
* - technically, the range is limited by the settings in the envelope-modifier data, not here...
@@ -1035,18 +1059,18 @@ static void rna_def_fmodifier_envelope_ctrl(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "min");
RNA_def_property_ui_text(prop, "Minimum Value", "Lower bound of envelope at this control-point");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "max");
RNA_def_property_ui_text(prop, "Maximum Value", "Upper bound of envelope at this control-point");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
/* Frame */
prop = RNA_def_property(srna, "frame", PROP_FLOAT, PROP_TIME);
RNA_def_property_float_sdna(prop, NULL, "time");
RNA_def_property_ui_text(prop, "Frame", "Frame this control-point occurs on");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
/* TODO: */
/* - selection flags (not implemented in UI yet though) */
}
@@ -1085,29 +1109,29 @@ static void rna_def_fmodifier_envelope(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "FModifierEnvelope", "FModifier");
RNA_def_struct_ui_text(srna, "Envelope F-Modifier", "Scale the values of the modified F-Curve");
RNA_def_struct_sdna_from(srna, "FMod_Envelope", "data");
-
+
/* Collections */
prop = RNA_def_property(srna, "control_points", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "data", "totvert");
RNA_def_property_struct_type(prop, "FModifierEnvelopeControlPoint");
RNA_def_property_ui_text(prop, "Control Points", "Control points defining the shape of the envelope");
rna_def_fmodifier_envelope_control_points(brna, prop);
-
+
/* Range Settings */
prop = RNA_def_property(srna, "reference_value", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "midval");
RNA_def_property_ui_text(prop, "Reference Value", "Value that envelope's influence is centered around / based on");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "default_min", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "min");
RNA_def_property_ui_text(prop, "Default Minimum", "Lower distance from Reference Value for 1:1 default influence");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "default_max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "max");
RNA_def_property_ui_text(prop, "Default Maximum", "Upper distance from Reference Value for 1:1 default influence");
@@ -1120,7 +1144,7 @@ static void rna_def_fmodifier_cycles(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem prop_type_items[] = {
{FCM_EXTRAPOLATE_NONE, "NONE", 0, "No Cycles", "Don't do anything"},
{FCM_EXTRAPOLATE_CYCLIC, "REPEAT", 0, "Repeat Motion", "Repeat keyframe range as-is"},
@@ -1131,31 +1155,31 @@ static void rna_def_fmodifier_cycles(BlenderRNA *brna)
"Alternate between forward and reverse playback of keyframe range"},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "FModifierCycles", "FModifier");
RNA_def_struct_ui_text(srna, "Cycles F-Modifier", "Repeat the values of the modified F-Curve");
RNA_def_struct_sdna_from(srna, "FMod_Cycles", "data");
-
+
/* before */
prop = RNA_def_property(srna, "mode_before", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "before_mode");
RNA_def_property_enum_items(prop, prop_type_items);
RNA_def_property_ui_text(prop, "Before Mode", "Cycling mode to use before first keyframe");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "cycles_before", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "before_cycles");
RNA_def_property_ui_text(prop, "Before Cycles",
"Maximum number of cycles to allow before first keyframe (0 = infinite)");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
/* after */
prop = RNA_def_property(srna, "mode_after", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "after_mode");
RNA_def_property_enum_items(prop, prop_type_items);
RNA_def_property_ui_text(prop, "After Mode", "Cycling mode to use after last keyframe");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "cycles_after", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "after_cycles");
RNA_def_property_ui_text(prop, "After Cycles",
@@ -1169,7 +1193,7 @@ static void rna_def_fmodifier_python(BlenderRNA *brna)
{
StructRNA *srna;
/*PropertyRNA *prop; */
-
+
srna = RNA_def_struct(brna, "FModifierPython", "FModifier");
RNA_def_struct_ui_text(srna, "Python F-Modifier", "Perform user-defined operation on the modified F-Curve");
RNA_def_struct_sdna_from(srna, "FMod_Python", "data");
@@ -1181,49 +1205,49 @@ static void rna_def_fmodifier_limits(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "FModifierLimits", "FModifier");
RNA_def_struct_ui_text(srna, "Limit F-Modifier", "Limit the time/value ranges of the modified F-Curve");
RNA_def_struct_sdna_from(srna, "FMod_Limits", "data");
-
+
prop = RNA_def_property(srna, "use_min_x", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_XMIN);
RNA_def_property_ui_text(prop, "Minimum X", "Use the minimum X value");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "use_min_y", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_YMIN);
RNA_def_property_ui_text(prop, "Minimum Y", "Use the minimum Y value");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "use_max_x", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_XMAX);
RNA_def_property_ui_text(prop, "Maximum X", "Use the maximum X value");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "use_max_y", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_YMAX);
RNA_def_property_ui_text(prop, "Maximum Y", "Use the maximum Y value");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "rect.xmin");
RNA_def_property_float_funcs(prop, NULL, "rna_FModifierLimits_minx_set", "rna_FModifierLimits_minx_range");
RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "rect.ymin");
RNA_def_property_float_funcs(prop, NULL, "rna_FModifierLimits_miny_set", "rna_FModifierLimits_miny_range");
RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "rect.xmax");
RNA_def_property_float_funcs(prop, NULL, "rna_FModifierLimits_maxx_set", "rna_FModifierLimits_maxx_range");
RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "rect.ymax");
RNA_def_property_float_funcs(prop, NULL, "rna_FModifierLimits_maxy_set", "rna_FModifierLimits_maxy_range");
@@ -1237,7 +1261,7 @@ static void rna_def_fmodifier_noise(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem prop_modification_items[] = {
{FCM_NOISE_MODIF_REPLACE, "REPLACE", 0, "Replace", ""},
{FCM_NOISE_MODIF_ADD, "ADD", 0, "Add", ""},
@@ -1245,28 +1269,28 @@ static void rna_def_fmodifier_noise(BlenderRNA *brna)
{FCM_NOISE_MODIF_MULTIPLY, "MULTIPLY", 0, "Multiply", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "FModifierNoise", "FModifier");
RNA_def_struct_ui_text(srna, "Noise F-Modifier", "Give randomness to the modified F-Curve");
RNA_def_struct_sdna_from(srna, "FMod_Noise", "data");
-
+
prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "modification");
RNA_def_property_enum_items(prop, prop_modification_items);
RNA_def_property_ui_text(prop, "Blend Type", "Method of modifying the existing F-Curve");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "size");
RNA_def_property_ui_text(prop, "Scale", "Scaling (in time) of the noise");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "strength");
RNA_def_property_ui_text(prop, "Strength",
"Amplitude of the noise - the amount that it modifies the underlying curve");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "phase", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "phase");
RNA_def_property_ui_text(prop, "Phase", "A random seed for the noise effect");
@@ -1276,7 +1300,7 @@ static void rna_def_fmodifier_noise(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "offset");
RNA_def_property_ui_text(prop, "Offset", "Time offset for the noise effect");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "depth");
RNA_def_property_ui_text(prop, "Depth", "Amount of fine level detail present in the noise");
@@ -1290,42 +1314,42 @@ static void rna_def_fmodifier_stepped(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "FModifierStepped", "FModifier");
RNA_def_struct_ui_text(srna, "Stepped Interpolation F-Modifier",
"Hold each interpolated value from the F-Curve for several frames without "
"changing the timing");
RNA_def_struct_sdna_from(srna, "FMod_Stepped", "data");
-
+
/* properties */
prop = RNA_def_property(srna, "frame_step", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "step_size");
RNA_def_property_ui_text(prop, "Step Size", "Number of frames to hold each value");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "frame_offset", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "offset");
RNA_def_property_ui_text(prop, "Offset",
"Reference number of frames before frames get held "
"(use to get hold for '1-3' vs '5-7' holding patterns)");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "use_frame_start", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_STEPPED_NO_BEFORE);
RNA_def_property_ui_text(prop, "Use Start Frame", "Restrict modifier to only act after its 'start' frame");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "use_frame_end", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_STEPPED_NO_AFTER);
RNA_def_property_ui_text(prop, "Use End Frame", "Restrict modifier to only act before its 'end' frame");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "start_frame");
RNA_def_property_float_funcs(prop, NULL, "rna_FModifierStepped_frame_start_set", "rna_FModifierStepped_start_frame_range");
RNA_def_property_ui_text(prop, "Start Frame", "Frame that modifier's influence starts (if applicable)");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "end_frame");
RNA_def_property_float_funcs(prop, NULL, "rna_FModifierStepped_frame_end_set", "rna_FModifierStepped_end_frame_range");
@@ -1340,43 +1364,43 @@ static void rna_def_fmodifier(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
/* base struct definition */
srna = RNA_def_struct(brna, "FModifier", NULL);
RNA_def_struct_refine_func(srna, "rna_FModifierType_refine");
RNA_def_struct_ui_text(srna, "F-Modifier", "Modifier for values of F-Curve");
-
+
#if 0 /* XXX not used yet */
/* name */
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_struct_name_property(srna, prop);
RNA_def_property_ui_text(prop, "Name", "Short description of F-Curve Modifier");
#endif /* XXX not used yet */
-
+
/* type */
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_enum_items(prop, rna_enum_fmodifier_type_items);
RNA_def_property_ui_text(prop, "Type", "F-Curve Modifier Type");
-
+
/* settings */
prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_EXPANDED);
RNA_def_property_ui_text(prop, "Expanded", "F-Curve Modifier's panel is expanded in UI");
RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
-
+
prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_MUTED);
RNA_def_property_ui_text(prop, "Muted", "F-Curve Modifier will not be evaluated");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
RNA_def_property_ui_icon(prop, ICON_MUTE_IPO_OFF, 1);
-
+
prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FMODIFIER_FLAG_DISABLED);
RNA_def_property_ui_text(prop, "Disabled", "F-Curve Modifier has invalid settings and will not be evaluated");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
-
+
/* TODO: setting this to true must ensure that all others in stack are turned off too... */
prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_ACTIVE);
@@ -1384,7 +1408,7 @@ static void rna_def_fmodifier(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, NULL, "rna_FModifier_active_set");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_active_update");
RNA_def_property_ui_icon(prop, ICON_RADIOBUT_OFF, 1);
-
+
/* restricted range */
prop = RNA_def_property(srna, "use_restricted_range", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_RANGERESTRICT);
@@ -1393,40 +1417,40 @@ static void rna_def_fmodifier(BlenderRNA *brna)
"mask off effects in order to chain them");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); /* XXX: depends on UI implementation */
-
+
prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "sfra");
RNA_def_property_float_funcs(prop, NULL, "rna_FModifier_start_frame_set", "rna_FModifier_start_frame_range");
RNA_def_property_ui_text(prop, "Start Frame",
"Frame that modifier's influence starts (if Restrict Frame Range is in use)");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "efra");
RNA_def_property_float_funcs(prop, NULL, "rna_FModifer_end_frame_set", "rna_FModifier_end_frame_range");
RNA_def_property_ui_text(prop, "End Frame",
"Frame that modifier's influence ends (if Restrict Frame Range is in use)");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "blend_in", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "blendin");
RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_blending_range");
RNA_def_property_ui_text(prop, "Blend In", "Number of frames from start frame for influence to take effect");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
-
+
prop = RNA_def_property(srna, "blend_out", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "blendout");
RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_blending_range");
RNA_def_property_ui_text(prop, "Blend Out", "Number of frames from end frame for influence to fade out");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
-
+
/* influence */
prop = RNA_def_property(srna, "use_influence", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_USEINFLUENCE);
RNA_def_property_ui_text(prop, "Use Influence", "F-Curve Modifier's effects will be tempered by a default factor");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); /* XXX: depends on UI implementation */
-
+
prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "influence");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -1442,7 +1466,7 @@ static void rna_def_drivertarget(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem prop_trans_chan_items[] = {
{DTAR_TRANSCHAN_LOCX, "LOC_X", 0, "X Location", ""},
{DTAR_TRANSCHAN_LOCY, "LOC_Y", 0, "Y Location", ""},
@@ -1455,7 +1479,7 @@ static void rna_def_drivertarget(BlenderRNA *brna)
{DTAR_TRANSCHAN_SCALEZ, "SCALE_Z", 0, "Z Scale", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem prop_local_space_items[] = {
{0, "WORLD_SPACE", 0, "World Space", "Transforms include effects of parenting/restpose and constraints"},
{DTAR_FLAG_LOCALSPACE, "TRANSFORM_SPACE", 0, "Transform Space",
@@ -1465,15 +1489,15 @@ static void rna_def_drivertarget(BlenderRNA *brna)
"parenting/restpose"},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "DriverTarget", NULL);
RNA_def_struct_ui_text(srna, "Driver Target", "Source of input values for driver variables");
-
+
/* Target Properties - ID-block to Drive */
prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "ID");
RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_editable_func(prop, "rna_DriverTarget_id_editable");
/* note: custom set function is ONLY to avoid rna setting a user for this. */
RNA_def_property_pointer_funcs(prop, NULL, "rna_DriverTarget_id_set", "rna_DriverTarget_id_typef", NULL);
@@ -1481,7 +1505,7 @@ static void rna_def_drivertarget(BlenderRNA *brna)
"ID-block that the specific property used can be found from "
"(id_type property must be set first)");
RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
-
+
prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "idtype");
RNA_def_property_enum_items(prop, rna_enum_id_type_items);
@@ -1491,25 +1515,25 @@ static void rna_def_drivertarget(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ID);
RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
-
+
/* Target Properties - Property to Drive */
prop = RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, "rna_DriverTarget_RnaPath_get", "rna_DriverTarget_RnaPath_length",
"rna_DriverTarget_RnaPath_set");
RNA_def_property_ui_text(prop, "Data Path", "RNA Path (from ID-block) to property used");
RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
-
+
prop = RNA_def_property(srna, "bone_target", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "pchan_name");
RNA_def_property_ui_text(prop, "Bone Name", "Name of PoseBone to use as target");
RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
-
+
prop = RNA_def_property(srna, "transform_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "transChan");
RNA_def_property_enum_items(prop, prop_trans_chan_items);
RNA_def_property_ui_text(prop, "Type", "Driver variable type");
RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
-
+
prop = RNA_def_property(srna, "transform_space", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, prop_local_space_items);
@@ -1521,7 +1545,7 @@ static void rna_def_drivervar(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem prop_type_items[] = {
{DVAR_TYPE_SINGLE_PROP, "SINGLE_PROP", ICON_RNA, "Single Property", "Use the value from some RNA property (Default)"},
{DVAR_TYPE_TRANSFORM_CHAN, "TRANSFORMS", ICON_MANIPUL, "Transform Channel",
@@ -1530,12 +1554,12 @@ static void rna_def_drivervar(BlenderRNA *brna)
{DVAR_TYPE_LOC_DIFF, "LOC_DIFF", ICON_FULLSCREEN_ENTER, "Distance", "Distance between two bones or objects"}, /* XXX: Icon... */
{0, NULL, 0, NULL, NULL}
};
-
-
+
+
srna = RNA_def_struct(brna, "DriverVariable", NULL);
RNA_def_struct_sdna(srna, "DriverVar");
RNA_def_struct_ui_text(srna, "Driver Variable", "Variable from some source/target for driver relationship");
-
+
/* Variable Name */
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_struct_name_property(srna, prop);
@@ -1544,28 +1568,28 @@ static void rna_def_drivervar(BlenderRNA *brna)
"Name to use in scripted expressions/functions (no spaces or dots are allowed, "
"and must start with a letter)");
RNA_def_property_update(prop, 0, "rna_DriverTarget_update_name"); /* XXX */
-
+
/* Enums */
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_type_items);
RNA_def_property_enum_funcs(prop, NULL, "rna_DriverVariable_type_set", NULL);
RNA_def_property_ui_text(prop, "Type", "Driver variable type");
RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data"); /* XXX */
-
+
/* Targets */
/* TODO: for nicer api, only expose the relevant props via subclassing,
* instead of exposing the collection of targets */
prop = RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "targets", "num_targets");
RNA_def_property_struct_type(prop, "DriverTarget");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Targets", "Sources of input data for evaluating this variable");
-
+
/* Name Validity Flags */
prop = RNA_def_property(srna, "is_name_valid", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", DVAR_FLAG_INVALID_NAME);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Is Name Valid", "Is this a valid name for a driver variable");
+ RNA_def_property_ui_text(prop, "Is Name Valid", "Is this a valid name for a driver variable");
}
@@ -1574,16 +1598,16 @@ static void rna_def_channeldriver_variables(BlenderRNA *brna, PropertyRNA *cprop
{
StructRNA *srna;
/* PropertyRNA *prop; */
-
+
FunctionRNA *func;
PropertyRNA *parm;
-
+
RNA_def_property_srna(cprop, "ChannelDriverVariables");
srna = RNA_def_struct(brna, "ChannelDriverVariables", NULL);
RNA_def_struct_sdna(srna, "ChannelDriver");
RNA_def_struct_ui_text(srna, "ChannelDriver Variables", "Collection of channel driver Variables");
-
-
+
+
/* add variable */
func = RNA_def_function(srna, "new", "rna_Driver_new_variable");
RNA_def_function_ui_description(func, "Add a new variable for the driver");
@@ -1605,7 +1629,7 @@ static void rna_def_channeldriver(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem prop_type_items[] = {
{DRIVER_TYPE_AVERAGE, "AVERAGE", 0, "Averaged Value", ""},
{DRIVER_TYPE_SUM, "SUM", 0, "Sum Values", ""},
@@ -1635,10 +1659,10 @@ static void rna_def_channeldriver(BlenderRNA *brna)
prop = RNA_def_property(srna, "variables", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "variables", NULL);
RNA_def_property_struct_type(prop, "DriverVariable");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Variables", "Properties acting as inputs for this driver");
rna_def_channeldriver_variables(brna, prop);
-
+
/* Settings */
prop = RNA_def_property(srna, "use_self", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", DRIVER_FLAG_USE_SELF);
@@ -1650,8 +1674,8 @@ static void rna_def_channeldriver(BlenderRNA *brna)
prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", DRIVER_FLAG_INVALID);
RNA_def_property_ui_text(prop, "Invalid", "Driver could not be evaluated in past, so should be skipped");
-
-
+
+
/* Functions */
RNA_api_drivers(srna);
}
@@ -1662,17 +1686,17 @@ static void rna_def_fpoint(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "FCurveSample", NULL);
RNA_def_struct_sdna(srna, "FPoint");
RNA_def_struct_ui_text(srna, "F-Curve Sample", "Sample point for F-Curve");
-
+
/* Boolean values */
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", 1);
RNA_def_property_ui_text(prop, "Select", "Selection status");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
/* Vector value */
prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
RNA_def_property_float_sdna(prop, NULL, "vec");
@@ -1689,40 +1713,40 @@ static void rna_def_fkeyframe(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "Keyframe", NULL);
RNA_def_struct_sdna(srna, "BezTriple");
RNA_def_struct_ui_text(srna, "Keyframe", "Bezier curve point with two handles defining a Keyframe on an F-Curve");
-
+
/* Boolean values */
prop = RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "f1", 0);
RNA_def_property_ui_text(prop, "Handle 1 selected", "Left handle selection status");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
prop = RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "f3", 0);
RNA_def_property_ui_text(prop, "Handle 2 selected", "Right handle selection status");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
prop = RNA_def_property(srna, "select_control_point", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "f2", 0);
RNA_def_property_ui_text(prop, "Select", "Control point selection status");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
/* Enums */
prop = RNA_def_property(srna, "handle_left_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "h1");
RNA_def_property_enum_items(prop, rna_enum_keyframe_handle_type_items);
RNA_def_property_ui_text(prop, "Left Handle Type", "Handle types");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
prop = RNA_def_property(srna, "handle_right_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "h2");
RNA_def_property_enum_items(prop, rna_enum_keyframe_handle_type_items);
RNA_def_property_ui_text(prop, "Right Handle Type", "Handle types");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "ipo");
RNA_def_property_enum_items(prop, rna_enum_beztriple_interpolation_mode_items);
@@ -1730,18 +1754,18 @@ static void rna_def_fkeyframe(BlenderRNA *brna)
"Interpolation method to use for segment of the F-Curve from "
"this Keyframe until the next Keyframe");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "hide");
RNA_def_property_enum_items(prop, rna_enum_beztriple_keyframe_type_items);
RNA_def_property_ui_text(prop, "Type", "Type of keyframe (for visual purposes only)");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
-
+
+
prop = RNA_def_property(srna, "easing", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "easing");
RNA_def_property_enum_items(prop, rna_enum_beztriple_interpolation_easing_items);
- RNA_def_property_ui_text(prop, "Easing",
+ RNA_def_property_ui_text(prop, "Easing",
"Which ends of the segment between this and the next keyframe easing "
"interpolation is applied to");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
@@ -1761,20 +1785,20 @@ static void rna_def_fkeyframe(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "period");
RNA_def_property_ui_text(prop, "Period", "Time between bounces for elastic easing");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
/* Vector values */
prop = RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
RNA_def_property_array(prop, 2);
RNA_def_property_float_funcs(prop, "rna_FKeyframe_handle1_get", "rna_FKeyframe_handle1_set", NULL);
RNA_def_property_ui_text(prop, "Left Handle", "Coordinates of the left handle (before the control point)");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
RNA_def_property_array(prop, 2);
RNA_def_property_float_funcs(prop, "rna_FKeyframe_ctrlpoint_get", "rna_FKeyframe_ctrlpoint_set", NULL);
RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
RNA_def_property_array(prop, 2);
RNA_def_property_float_funcs(prop, "rna_FKeyframe_handle2_get", "rna_FKeyframe_handle2_set", NULL);
@@ -1909,16 +1933,16 @@ static void rna_def_fcurve(BlenderRNA *brna)
prop = RNA_def_property(srna, "extrapolation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "extend");
RNA_def_property_enum_items(prop, prop_mode_extend_items);
- RNA_def_property_ui_text(prop, "Extrapolation",
+ RNA_def_property_ui_text(prop, "Extrapolation",
"Method used for evaluating value of F-Curve outside first and last keyframes");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FCurve_update_data");
/* Pointers */
prop = RNA_def_property(srna, "driver", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Driver", "Channel Driver (only set for Driver F-Curves)");
-
+
prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "grp");
RNA_def_property_flag(prop, PROP_EDITABLE);
@@ -1940,35 +1964,35 @@ static void rna_def_fcurve(BlenderRNA *brna)
"Index to the specific property affected by F-Curve if applicable");
/* XXX need an update callback for this so that animation gets evaluated */
RNA_def_property_update(prop, NC_ANIMATION, NULL);
-
+
/* Color */
prop = RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_mode_color_items);
RNA_def_property_ui_text(prop, "Color Mode", "Method used to determine color of F-Curve in Graph Editor");
RNA_def_property_update(prop, NC_ANIMATION, NULL);
-
+
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Color", "Color of the F-Curve in the Graph Editor");
RNA_def_property_update(prop, NC_ANIMATION, NULL);
-
+
/* Flags */
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_SELECTED);
RNA_def_property_ui_text(prop, "Select", "F-Curve is selected for editing");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-
+
prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_PROTECTED);
RNA_def_property_ui_text(prop, "Lock", "F-Curve's settings cannot be edited");
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_MUTED);
RNA_def_property_ui_text(prop, "Muted", "F-Curve is not evaluated");
- RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
-
+ RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, "rna_FCurve_update_eval");
+
prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FCURVE_VISIBLE);
RNA_def_property_ui_text(prop, "Hide", "F-Curve and its keyframes are hidden in the Graph Editor graphs");
@@ -1986,7 +2010,7 @@ static void rna_def_fcurve(BlenderRNA *brna)
"False when F-Curve could not be evaluated in past, so should be skipped "
"when evaluating");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
/* Collections */
prop = RNA_def_property(srna, "sampled_points", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fpt", "totvert");
@@ -1998,7 +2022,7 @@ static void rna_def_fcurve(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "Keyframe");
RNA_def_property_ui_text(prop, "Keyframes", "User-editable keyframes");
rna_def_fcurve_keyframe_points(brna, prop);
-
+
prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "FModifier");
RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the shape of the F-Curve");
@@ -2014,11 +2038,11 @@ static void rna_def_fcurve(BlenderRNA *brna)
/* return value */
parm = RNA_def_float(func, "value", 0, -FLT_MAX, FLT_MAX, "Value", "Value of F-Curve specific frame", -FLT_MAX, FLT_MAX);
RNA_def_function_return(func, parm);
-
+
/* -- update / recalculate -- */
func = RNA_def_function(srna, "update", "rna_FCurve_update_data_ex");
RNA_def_function_ui_description(func, "Ensure keyframes are sorted in chronological order and handles are set correctly");
-
+
/* -- time extents/range -- */
func = RNA_def_function(srna, "range", "rna_FCurve_range");
RNA_def_function_ui_description(func, "Get the time extents for F-Curve");
@@ -2027,7 +2051,7 @@ static void rna_def_fcurve(BlenderRNA *brna)
"Min/Max values", -FLT_MAX, FLT_MAX);
RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_function_output(func, parm);
-
+
/* -- auto-flag validity (ensures valid handling for data type) -- */
func = RNA_def_function(srna, "update_autoflags", "update_autoflags_fcurve"); /* calls the C/API direct */
RNA_def_function_ui_description(func, "Update FCurve flags set automatically from affected property "
@@ -2049,13 +2073,13 @@ void RNA_def_fcurve(BlenderRNA *brna)
rna_def_fcurve(brna);
rna_def_fkeyframe(brna);
rna_def_fpoint(brna);
-
+
rna_def_drivertarget(brna);
rna_def_drivervar(brna);
rna_def_channeldriver(brna);
-
+
rna_def_fmodifier(brna);
-
+
rna_def_fmodifier_generator(brna);
rna_def_fmodifier_function_generator(brna);
diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c
index a75aceb6f7e..23d9155fccd 100644
--- a/source/blender/makesrna/intern/rna_fluidsim.c
+++ b/source/blender/makesrna/intern/rna_fluidsim.c
@@ -87,14 +87,14 @@ static void rna_fluid_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
}
-static int fluidsim_find_lastframe(Object *ob, FluidsimSettings *fss)
+static int fluidsim_find_lastframe(Main *bmain, Object *ob, FluidsimSettings *fss)
{
char targetFileTest[FILE_MAX];
char targetFile[FILE_MAX];
int curFrame = 1;
BLI_join_dirfile(targetFile, sizeof(targetFile), fss->surfdataPath, OB_FLUIDSIM_SURF_FINAL_OBJ_FNAME);
- BLI_path_abs(targetFile, modifier_path_relbase(ob));
+ BLI_path_abs(targetFile, modifier_path_relbase(bmain, ob));
do {
BLI_strncpy(targetFileTest, targetFile, sizeof(targetFileTest));
@@ -110,7 +110,7 @@ static void rna_fluid_find_enframe(Main *bmain, Scene *scene, PointerRNA *ptr)
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
if (fluidmd->fss->flag & OB_FLUIDSIM_REVERSE) {
- fluidmd->fss->lastgoodframe = fluidsim_find_lastframe(ob, fluidmd->fss);
+ fluidmd->fss->lastgoodframe = fluidsim_find_lastframe(bmain, ob, fluidmd->fss);
}
else {
fluidmd->fss->lastgoodframe = -1;
@@ -125,7 +125,7 @@ static void rna_FluidSettings_update_type(Main *bmain, Scene *scene, PointerRNA
ParticleSystemModifierData *psmd;
ParticleSystem *psys, *next_psys;
ParticleSettings *part;
-
+
fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
fluidmd->fss->flag &= ~OB_FLUIDSIM_REVERSE; /* clear flag */
@@ -243,7 +243,7 @@ static void rna_def_fluid_mesh_vertices(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "FluidVertexVelocity", NULL);
RNA_def_struct_ui_text(srna, "Fluid Mesh Velocity", "Velocity of a simulated fluid mesh");
RNA_def_struct_ui_icon(srna, ICON_VERTEXSEL);
@@ -279,7 +279,7 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "threads");
RNA_def_property_range(prop, 0, BLENDER_MAX_THREADS);
RNA_def_property_ui_text(prop, "Simulation Threads", "Override number of threads for the simulation, 0 is automatic");
-
+
prop = RNA_def_property(srna, "resolution", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "resolutionxyz");
RNA_def_property_range(prop, 1, 1024);
@@ -327,32 +327,32 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, -1000.1, 1000.1);
RNA_def_property_ui_text(prop, "Gravity", "Gravity in X, Y and Z direction");
-
+
prop = RNA_def_property(srna, "use_time_override", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_FLUIDSIM_OVERRIDE_TIME);
RNA_def_property_ui_text(prop, "Override Time",
"Use a custom start and end time (in seconds) instead of the scene's timeline");
-
+
prop = RNA_def_property(srna, "start_time", PROP_FLOAT, PROP_TIME);
RNA_def_property_float_sdna(prop, NULL, "animStart");
RNA_def_property_range(prop, 0, FLT_MAX);
RNA_def_property_ui_text(prop, "Start Time", "Simulation time of the first blender frame (in seconds)");
-
+
prop = RNA_def_property(srna, "end_time", PROP_FLOAT, PROP_TIME);
RNA_def_property_float_sdna(prop, NULL, "animEnd");
RNA_def_property_range(prop, 0, FLT_MAX);
RNA_def_property_ui_text(prop, "End Time", "Simulation time of the last blender frame (in seconds)");
-
+
prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "frameOffset");
RNA_def_property_ui_text(prop, "Cache Offset", "Offset when reading baked cache");
RNA_def_property_update(prop, NC_OBJECT, "rna_fluid_update");
-
+
prop = RNA_def_property(srna, "simulation_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "realsize");
RNA_def_property_range(prop, 0.001, 10);
RNA_def_property_ui_text(prop, "Real World Size", "Size of the simulation domain in meters");
-
+
prop = RNA_def_property(srna, "simulation_rate", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "animRate");
RNA_def_property_range(prop, 0.0, 100.0);
@@ -431,7 +431,7 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.0, 10.0);
RNA_def_property_ui_text(prop, "Generate Particles", "Amount of particles to generate (0=off, 1=normal, >1=more)");
-
+
/* simulated fluid mesh data */
prop = RNA_def_property(srna, "fluid_mesh_vertices", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "meshVelocities", "totvert");
@@ -471,7 +471,7 @@ static void rna_def_fluidsim_volume(StructRNA *srna)
static void rna_def_fluidsim_active(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_FLUIDSIM_ACTIVE);
RNA_def_property_ui_text(prop, "Enabled", "Object contributes to the fluid simulation");
@@ -489,7 +489,7 @@ static void rna_def_fluidsim_fluid(BlenderRNA *brna)
rna_def_fluidsim_active(srna);
rna_def_fluidsim_volume(srna);
-
+
prop = RNA_def_property(srna, "initial_velocity", PROP_FLOAT, PROP_VELOCITY);
RNA_def_property_float_sdna(prop, NULL, "iniVelx");
RNA_def_property_array(prop, 3);
@@ -615,12 +615,12 @@ static void rna_def_fluidsim_control(BlenderRNA *brna)
"Fluid simulation settings for objects controlling the motion of fluid in the simulation");
rna_def_fluidsim_active(srna);
-
+
prop = RNA_def_property(srna, "start_time", PROP_FLOAT, PROP_TIME);
RNA_def_property_float_sdna(prop, NULL, "cpsTimeStart");
RNA_def_property_range(prop, 0.0, FLT_MAX);
RNA_def_property_ui_text(prop, "Start Time", "Time when the control particles are activated");
-
+
prop = RNA_def_property(srna, "end_time", PROP_FLOAT, PROP_TIME);
RNA_def_property_float_sdna(prop, NULL, "cpsTimeEnd");
RNA_def_property_range(prop, 0.0, FLT_MAX);
@@ -636,7 +636,7 @@ static void rna_def_fluidsim_control(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "attractforceRadius");
RNA_def_property_range(prop, 0.0, 10.0);
RNA_def_property_ui_text(prop, "Attraction Radius", "Force field radius around the control object");
-
+
prop = RNA_def_property(srna, "velocity_strength", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "velocityforceStrength");
RNA_def_property_range(prop, 0.0, 10.0);
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index b15f6dbccfa..51aed1ff296 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -82,7 +82,7 @@ static void rna_GPencil_onion_skinning_update(Main *bmain, Scene *scene, Pointer
bGPdata *gpd = (bGPdata *)ptr->id.data;
bGPDlayer *gpl;
bool enabled = false;
-
+
/* Ensure that the datablock's onionskinning toggle flag
* stays in sync with the status of the actual layers
*/
@@ -91,13 +91,13 @@ static void rna_GPencil_onion_skinning_update(Main *bmain, Scene *scene, Pointer
enabled = true;
}
}
-
+
if (enabled)
gpd->flag |= GP_DATA_SHOW_ONIONSKINS;
else
gpd->flag &= ~GP_DATA_SHOW_ONIONSKINS;
-
-
+
+
/* Now do standard updates... */
rna_GPencil_update(bmain, scene, ptr);
}
@@ -116,9 +116,9 @@ static char *rna_GPencilLayer_path(PointerRNA *ptr)
{
bGPDlayer *gpl = (bGPDlayer *)ptr->data;
char name_esc[sizeof(gpl->info) * 2];
-
+
BLI_strescape(name_esc, gpl->info, sizeof(name_esc));
-
+
return BLI_sprintfN("layers[\"%s\"]", name_esc);
}
@@ -137,7 +137,7 @@ static void rna_GPencilLayer_line_width_range(PointerRNA *ptr, int *min, int *ma
int *softmin, int *softmax)
{
bGPDlayer *gpl = ptr->data;
-
+
/* The restrictions on max width here are due to OpenGL on Windows not supporting
* any widths greater than 10 (for driver-drawn) strokes/points.
*
@@ -150,14 +150,14 @@ static void rna_GPencilLayer_line_width_range(PointerRNA *ptr, int *min, int *ma
if (gpl->flag & GP_LAYER_VOLUMETRIC) {
*min = -300;
*max = 300;
-
+
*softmin = -100;
*softmax = 100;
}
else {
*min = -10;
*max = 10;
-
+
*softmin = -10;
*softmax = 10;
}
@@ -196,7 +196,7 @@ static void set_parent(bGPDlayer *gpl, Object *par, const int type, const char *
static void rna_GPencilLayer_parent_set(PointerRNA *ptr, PointerRNA value)
{
bGPDlayer *gpl = (bGPDlayer *)ptr->data;
- Object *par = (Object *)value.data;
+ Object *par = (Object *)value.data;
if (par != NULL) {
set_parent(gpl, par, gpl->partype, gpl->parsubstr);
@@ -317,7 +317,7 @@ static void rna_GPencil_active_layer_set(PointerRNA *ptr, PointerRNA value)
gl->flag &= ~GP_LAYER_ACTIVE;
}
}
-
+
WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
}
}
@@ -326,7 +326,7 @@ static int rna_GPencil_active_layer_index_get(PointerRNA *ptr)
{
bGPdata *gpd = (bGPdata *)ptr->id.data;
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
-
+
return BLI_findindex(&gpd->layers, gpl);
}
@@ -370,7 +370,7 @@ static void rna_GPencil_use_onion_skinning_set(PointerRNA *ptr, const int value)
{
bGPdata *gpd = ptr->id.data;
bGPDlayer *gpl;
-
+
/* set new value */
if (value) {
/* enable on active layer (it's the one that's most likely to be of interest right now) */
@@ -378,7 +378,7 @@ static void rna_GPencil_use_onion_skinning_set(PointerRNA *ptr, const int value)
if (gpl) {
gpl->flag |= GP_LAYER_ONIONSKIN;
}
-
+
gpd->flag |= GP_DATA_SHOW_ONIONSKINS;
}
else {
@@ -386,7 +386,7 @@ static void rna_GPencil_use_onion_skinning_set(PointerRNA *ptr, const int value)
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
gpl->flag &= ~GP_LAYER_ONIONSKIN;
}
-
+
gpd->flag &= ~GP_DATA_SHOW_ONIONSKINS;
}
}
@@ -395,15 +395,15 @@ static bGPDstroke *rna_GPencil_stroke_point_find_stroke(const bGPdata *gpd, cons
{
bGPDlayer *gpl;
bGPDstroke *gps;
-
+
/* sanity checks */
if (ELEM(NULL, gpd, pt)) {
return NULL;
}
-
+
if (r_gpl) *r_gpl = NULL;
if (r_gpf) *r_gpf = NULL;
-
+
/* there's no faster alternative than just looping over everything... */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if (gpl->actframe) {
@@ -412,13 +412,13 @@ static bGPDstroke *rna_GPencil_stroke_point_find_stroke(const bGPdata *gpd, cons
/* found it */
if (r_gpl) *r_gpl = gpl;
if (r_gpf) *r_gpf = gpl->actframe;
-
+
return gps;
}
}
}
}
-
+
/* didn't find it */
return NULL;
}
@@ -428,8 +428,8 @@ static void rna_GPencil_stroke_point_select_set(PointerRNA *ptr, const int value
bGPdata *gpd = ptr->id.data;
bGPDspoint *pt = ptr->data;
bGPDstroke *gps = NULL;
-
- /* Ensure that corresponding stroke is set
+
+ /* Ensure that corresponding stroke is set
* - Since we don't have direct access, we're going to have to search
* - We don't apply selection value unless we can find the corresponding
* stroke, so that they don't get out of sync
@@ -441,7 +441,7 @@ static void rna_GPencil_stroke_point_select_set(PointerRNA *ptr, const int value
pt->flag |= GP_SPOINT_SELECT;
else
pt->flag &= ~GP_SPOINT_SELECT;
-
+
/* Check if the stroke should be selected or not... */
BKE_gpencil_stroke_sync_selection(gps);
}
@@ -454,7 +454,7 @@ static void rna_GPencil_stroke_point_add(bGPDstroke *stroke, int count, float pr
stroke->points = MEM_recallocN_id(stroke->points,
sizeof(bGPDspoint) * (stroke->totpoints + count),
"gp_stroke_points");
-
+
/* init the pressure and strength values so that old scripts won't need to
* be modified to give these initial values...
*/
@@ -463,7 +463,7 @@ static void rna_GPencil_stroke_point_add(bGPDstroke *stroke, int count, float pr
pt->pressure = pressure;
pt->strength = strength;
}
-
+
stroke->totpoints += count;
}
}
@@ -530,13 +530,13 @@ static void rna_GPencil_stroke_select_set(PointerRNA *ptr, const int value)
bGPDstroke *gps = ptr->data;
bGPDspoint *pt;
int i;
-
+
/* set new value */
if (value)
gps->flag |= GP_STROKE_SELECT;
else
gps->flag &= ~GP_STROKE_SELECT;
-
+
/* ensure that the stroke's points are selected in the same way */
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
if (value)
@@ -800,9 +800,9 @@ static char *rna_GPencilPalette_path(PointerRNA *ptr)
{
bGPDpalette *palette = ptr->data;
char name_esc[sizeof(palette->info) * 2];
-
+
BLI_strescape(name_esc, palette->info, sizeof(name_esc));
-
+
return BLI_sprintfN("palettes[\"%s\"]", name_esc);
}
@@ -826,7 +826,7 @@ static void rna_GPencilPaletteColor_info_set(PointerRNA *ptr, const char *value)
bGPdata *gpd = ptr->id.data;
bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd);
bGPDpalettecolor *palcolor = ptr->data;
-
+
char oldname[64] = "";
BLI_strncpy(oldname, palcolor->info, sizeof(oldname));
@@ -834,7 +834,7 @@ static void rna_GPencilPaletteColor_info_set(PointerRNA *ptr, const char *value)
BLI_strncpy_utf8(palcolor->info, value, sizeof(palcolor->info));
BLI_uniquename(&palette->colors, palcolor, DATA_("Color"), '.', offsetof(bGPDpalettecolor, info),
sizeof(palcolor->info));
-
+
/* rename all strokes */
BKE_gpencil_palettecolor_changename(gpd, oldname, palcolor->info);
@@ -895,23 +895,23 @@ static void rna_def_gpencil_stroke_point(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "GPencilStrokePoint", NULL);
RNA_def_struct_sdna(srna, "bGPDspoint");
RNA_def_struct_ui_text(srna, "Grease Pencil Stroke Point", "Data point for freehand stroke curve");
-
+
prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "x");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Coordinates", "");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
prop = RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "pressure");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Pressure", "Pressure of tablet at point when drawing it");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "strength");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -988,18 +988,18 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna)
{GP_STROKE_2DIMAGE, "2DIMAGE", 0, "2D Image", "Stroke is in 2D-space (but with special 'image' scaling)"},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "GPencilStroke", NULL);
RNA_def_struct_sdna(srna, "bGPDstroke");
RNA_def_struct_ui_text(srna, "Grease Pencil Stroke", "Freehand curve defining part of a sketch");
-
+
/* Points */
prop = RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "points", "totpoints");
RNA_def_property_struct_type(prop, "GPencilStrokePoint");
RNA_def_property_ui_text(prop, "Stroke Points", "Stroke data points");
rna_def_gpencil_stroke_points_api(brna, prop);
-
+
/* Triangles */
prop = RNA_def_property(srna, "triangles", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "triangles", "tot_triangles");
@@ -1019,7 +1019,7 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna)
RNA_def_property_enum_items(prop, stroke_draw_mode_items);
RNA_def_property_ui_text(prop, "Draw Mode", "");
RNA_def_property_update(prop, 0, "rna_GPencil_update");
-
+
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STROKE_SELECT);
RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencil_stroke_select_set");
@@ -1080,11 +1080,11 @@ static void rna_def_gpencil_frame(BlenderRNA *brna)
PropertyRNA *prop;
FunctionRNA *func;
-
+
srna = RNA_def_struct(brna, "GPencilFrame", NULL);
RNA_def_struct_sdna(srna, "bGPDframe");
RNA_def_struct_ui_text(srna, "Grease Pencil Frame", "Collection of related sketches on a particular frame");
-
+
/* Strokes */
prop = RNA_def_property(srna, "strokes", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "strokes", NULL);
@@ -1098,17 +1098,17 @@ static void rna_def_gpencil_frame(BlenderRNA *brna)
/* XXX note: this cannot occur on the same frame as another sketch */
RNA_def_property_range(prop, -MAXFRAME, MAXFRAME);
RNA_def_property_ui_text(prop, "Frame Number", "The frame on which this sketch appears");
-
+
/* Flags */
prop = RNA_def_property(srna, "is_edited", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_FRAME_PAINT); /* XXX should it be editable? */
RNA_def_property_ui_text(prop, "Paint Lock", "Frame is being edited (painted on)");
-
+
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_FRAME_SELECT);
RNA_def_property_ui_text(prop, "Select", "Frame is selected for editing in the Dope Sheet");
-
-
+
+
/* API */
func = RNA_def_function(srna, "clear", "rna_GPencil_frame_clear");
RNA_def_function_ui_description(func, "Remove all the grease pencil frame data");
@@ -1156,12 +1156,12 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
PropertyRNA *prop;
FunctionRNA *func;
-
+
srna = RNA_def_struct(brna, "GPencilLayer", NULL);
RNA_def_struct_sdna(srna, "bGPDlayer");
RNA_def_struct_ui_text(srna, "Grease Pencil Layer", "Collection of related sketches");
RNA_def_struct_path_func(srna, "rna_GPencilLayer_path");
-
+
/* Name */
prop = RNA_def_property(srna, "info", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Info", "Layer name");
@@ -1190,13 +1190,13 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Volumetric Strokes",
"Draw strokes as a series of circular blobs, resulting in a volumetric effect");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
prop = RNA_def_property(srna, "opacity", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "opacity");
RNA_def_property_range(prop, 0.0, 1.0f);
RNA_def_property_ui_text(prop, "Opacity", "Layer Opacity");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
/* Tint Color */
prop = RNA_def_property(srna, "tint_color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "tintcolor");
@@ -1204,14 +1204,14 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Tint Color", "Color for tinting stroke colors");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
/* Tint factor */
prop = RNA_def_property(srna, "tint_factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "tintcolor[3]");
RNA_def_property_range(prop, 0.0, 1.0f);
RNA_def_property_ui_text(prop, "Tint Factor", "Factor of tinting color");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
/* Line Thickness change */
prop = RNA_def_property(srna, "line_change", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "thickness");
@@ -1219,13 +1219,13 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_int_funcs(prop, NULL, NULL, "rna_GPencilLayer_line_width_range");
RNA_def_property_ui_text(prop, "Thickness", "Thickness change to apply to current strokes (in pixels)");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
/* Onion-Skinning */
prop = RNA_def_property(srna, "use_onion_skinning", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_ONIONSKIN);
RNA_def_property_ui_text(prop, "Onion Skinning", "Ghost frames on either side of frame");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_onion_skinning_update");
-
+
prop = RNA_def_property(srna, "ghost_before_range", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "gstep");
RNA_def_property_range(prop, -1, 120);
@@ -1233,7 +1233,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
"Maximum number of frames to show before current frame "
"(0 = show only the previous sketch, -1 = don't show any frames before current)");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
prop = RNA_def_property(srna, "ghost_after_range", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "gstep_next");
RNA_def_property_range(prop, -1, 120);
@@ -1241,46 +1241,46 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
"Maximum number of frames to show after current frame "
"(0 = show only the next sketch, -1 = don't show any frames after current)");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
prop = RNA_def_property(srna, "use_ghost_custom_colors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_GHOST_PREVCOL | GP_LAYER_GHOST_NEXTCOL);
RNA_def_property_ui_text(prop, "Use Custom Ghost Colors", "Use custom colors for ghost frames");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
prop = RNA_def_property(srna, "before_color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "gcolor_prev");
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Before Color", "Base color for ghosts before the active frame");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
prop = RNA_def_property(srna, "after_color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "gcolor_next");
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "After Color", "Base color for ghosts after the active frame");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
prop = RNA_def_property(srna, "use_ghosts_always", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_GHOST_ALWAYS);
RNA_def_property_ui_text(prop, "Always Show Ghosts",
"Ghosts are shown in renders and animation playback. Useful for special effects (e.g. motion blur)");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
-
+
+
/* Flags */
prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_HIDE);
RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1);
RNA_def_property_ui_text(prop, "Hide", "Set layer Visibility");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_LOCKED);
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
RNA_def_property_ui_text(prop, "Locked", "Protect layer from further editing and/or frame changes");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
prop = RNA_def_property(srna, "lock_frame", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_FRAMELOCK);
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
@@ -1309,23 +1309,23 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_SELECT);
RNA_def_property_ui_text(prop, "Select", "Layer is selected for editing in the Dope Sheet");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, "rna_GPencil_update");
-
+
/* XXX keep this option? */
prop = RNA_def_property(srna, "show_points", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_DRAWDEBUG);
RNA_def_property_ui_text(prop, "Show Points", "Draw the points which make up the strokes (for debugging purposes)");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
/* X-Ray */
prop = RNA_def_property(srna, "show_x_ray", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_LAYER_NO_XRAY);
RNA_def_property_ui_text(prop, "X Ray", "Make the layer draw in front of objects");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
+
/* Parent object */
prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_funcs(prop, NULL, "rna_GPencilLayer_parent_set", NULL, NULL);
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
RNA_def_property_ui_text(prop, "Parent", "Parent Object");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
@@ -1397,11 +1397,11 @@ static void rna_def_gpencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Active Layer", "Active grease pencil layer");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
-
+
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_funcs(prop,
- "rna_GPencil_active_layer_index_get",
- "rna_GPencil_active_layer_index_set",
+ "rna_GPencil_active_layer_index_get",
+ "rna_GPencil_active_layer_index_set",
"rna_GPencil_active_layer_index_range");
RNA_def_property_ui_text(prop, "Active Layer Index", "Index of active grease pencil layer");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
@@ -1620,14 +1620,14 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "bGPdata");
RNA_def_struct_ui_text(srna, "Grease Pencil", "Freehand annotation sketchbook");
RNA_def_struct_ui_icon(srna, ICON_GREASEPENCIL);
-
+
/* Layers */
prop = RNA_def_property(srna, "layers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "layers", NULL);
RNA_def_property_struct_type(prop, "GPencilLayer");
RNA_def_property_ui_text(prop, "Layers", "");
rna_def_gpencil_layers_api(brna, prop);
-
+
/* Palettes */
prop = RNA_def_property(srna, "palettes", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "palettes", NULL);
@@ -1637,20 +1637,20 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
/* Animation Data */
rna_def_animdata_common(srna);
-
+
/* Flags */
prop = RNA_def_property(srna, "use_stroke_edit_mode", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_EDITMODE);
RNA_def_property_ui_text(prop, "Stroke Edit Mode", "Edit Grease Pencil strokes instead of viewport data");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_editmode_update");
-
+
prop = RNA_def_property(srna, "use_onion_skinning", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_SHOW_ONIONSKINS);
RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencil_use_onion_skinning_set");
- RNA_def_property_ui_text(prop, "Onion Skins",
+ RNA_def_property_ui_text(prop, "Onion Skins",
"Show ghosts of the frames before and after the current frame, toggle to enable on active layer or disable all");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
-
+
prop = RNA_def_property(srna, "show_stroke_direction", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_SHOW_DIRECTION);
RNA_def_property_ui_text(prop, "Show Direction", "Show stroke drawing direction with a bigger green dot (start) "
diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c
index 116c0bc4a26..de6c6883977 100644
--- a/source/blender/makesrna/intern/rna_group.c
+++ b/source/blender/makesrna/intern/rna_group.c
@@ -158,7 +158,7 @@ static void rna_def_collection_objects(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
-
+
RNA_def_property_srna(cprop, "CollectionObjects");
srna = RNA_def_struct(brna, "CollectionObjects", NULL);
RNA_def_struct_sdna(srna, "Collection");
@@ -227,6 +227,7 @@ void RNA_def_collections(BlenderRNA *brna)
prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Objects", "Objects that are directly in this collection");
RNA_def_property_collection_funcs(prop, "rna_Collection_objects_begin",
"rna_iterator_listbase_next",
@@ -257,21 +258,21 @@ void RNA_def_collections(BlenderRNA *brna)
/* Flags */
prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_SELECT);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1);
RNA_def_property_ui_text(prop, "Restrict Select", "Disable collection object selection in the 3D viewport");
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_flag_update");
prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_VIEW);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1);
RNA_def_property_ui_text(prop, "Restrict Viewport", "Hide collection objects in the 3D viewport");
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_flag_update");
prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_RENDER);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
RNA_def_property_ui_text(prop, "Restrict Render", "Hide collection objects in renders");
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_flag_update");
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index c554ab8e0fd..cf486ee399f 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -92,12 +92,12 @@ static void rna_Image_source_set(PointerRNA *ptr, int value)
if (value != ima->source) {
ima->source = value;
- BKE_image_signal(ima, NULL, IMA_SIGNAL_SRC_CHANGE);
+ BKE_image_signal(G.main, ima, NULL, IMA_SIGNAL_SRC_CHANGE);
DEG_id_tag_update(&ima->id, 0);
}
}
-static void rna_Image_fields_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_Image_fields_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
Image *ima = ptr->id.data;
ImBuf *ibuf;
@@ -112,36 +112,36 @@ static void rna_Image_fields_update(Main *UNUSED(bmain), Scene *UNUSED(scene), P
if ((ima->flag & IMA_FIELDS) && !(ibuf->flags & IB_fields)) nr = 1;
if (nr)
- BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
+ BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_FREE);
}
BKE_image_release_ibuf(ima, ibuf, lock);
}
-static void rna_Image_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_Image_reload_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
Image *ima = ptr->id.data;
- BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
+ BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_RELOAD);
WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id);
DEG_id_tag_update(&ima->id, 0);
}
-static void rna_Image_generated_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_Image_generated_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
Image *ima = ptr->id.data;
- BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
+ BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_FREE);
}
-static void rna_Image_colormanage_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_Image_colormanage_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
Image *ima = ptr->id.data;
- BKE_image_signal(ima, NULL, IMA_SIGNAL_COLORMANAGE);
+ BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE);
DEG_id_tag_update(&ima->id, 0);
WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id);
WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id);
}
-static void rna_Image_views_format_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
+static void rna_Image_views_format_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Image *ima = ptr->id.data;
ImBuf *ibuf;
@@ -152,7 +152,7 @@ static void rna_Image_views_format_update(Main *UNUSED(bmain), Scene *scene, Poi
if (ibuf) {
ImageUser iuser = {NULL};
iuser.scene = scene;
- BKE_image_signal(ima, &iuser, IMA_SIGNAL_FREE);
+ BKE_image_signal(bmain, ima, &iuser, IMA_SIGNAL_FREE);
}
BKE_image_release_ibuf(ima, ibuf, lock);
@@ -175,7 +175,7 @@ static char *rna_ImageUser_path(PointerRNA *ptr)
{
if (ptr->id.data) {
/* ImageUser *iuser = ptr->data; */
-
+
switch (GS(((ID *)ptr->id.data)->name)) {
case ID_OB:
case ID_TE:
@@ -190,7 +190,7 @@ static char *rna_ImageUser_path(PointerRNA *ptr)
break;
}
}
-
+
return BLI_strdup("");
}
@@ -200,7 +200,7 @@ static const EnumPropertyItem *rna_Image_source_itemf(bContext *UNUSED(C), Point
Image *ima = (Image *)ptr->data;
EnumPropertyItem *item = NULL;
int totitem = 0;
-
+
if (ima->source == IMA_SRC_VIEWER) {
RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_VIEWER);
}
@@ -304,7 +304,7 @@ static int rna_Image_depth_get(PointerRNA *ptr)
ImBuf *ibuf;
void *lock;
int planes;
-
+
ibuf = BKE_image_acquire_ibuf(im, NULL, &lock);
if (!ibuf)
@@ -652,7 +652,7 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_IMAGE_DATA);
prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_string_sdna(prop, NULL, "name");
RNA_def_property_ui_text(prop, "File Name", "Image/Movie file name");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_reload_update");
@@ -692,7 +692,7 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Packed Files", "Collection of packed images");
prop = RNA_def_property(srna, "field_order", PROP_ENUM, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, prop_field_order_items);
RNA_def_property_ui_text(prop, "Field Order", "Order of video fields (select which lines are displayed first)");
@@ -700,51 +700,51 @@ static void rna_def_image(BlenderRNA *brna)
/* booleans */
prop = RNA_def_property(srna, "use_fields", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_FIELDS);
RNA_def_property_ui_text(prop, "Fields", "Use fields of the image");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_fields_update");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-
+
prop = RNA_def_property(srna, "use_view_as_render", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_VIEW_AS_RENDER);
RNA_def_property_ui_text(prop, "View as Render", "Apply render part of display transformation when displaying this image on the screen");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMA_IGNORE_ALPHA);
RNA_def_property_ui_text(prop, "Use Alpha", "Use the alpha channel information from the image or make image fully opaque");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_colormanage_update");
prop = RNA_def_property(srna, "use_deinterlace", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_DEINTERLACE);
RNA_def_property_ui_text(prop, "Deinterlace", "Deinterlace movie file on load");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_reload_update");
prop = RNA_def_property(srna, "use_multiview", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_USE_VIEWS);
RNA_def_property_ui_text(prop, "Use Multi-View", "Use Multiple Views (when available)");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_views_format_update");
prop = RNA_def_property(srna, "is_stereo_3d", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_boolean_funcs(prop, "rna_Image_is_stereo_3d_get", NULL);
RNA_def_property_ui_text(prop, "Stereo 3D", "Image has left and right views");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
prop = RNA_def_property(srna, "is_multiview", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_boolean_funcs(prop, "rna_Image_is_multiview_get", NULL);
RNA_def_property_ui_text(prop, "Multiple Views", "Image has more than one view");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
prop = RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_boolean_funcs(prop, "rna_Image_dirty_get", NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Dirty", "Image has changed and is not saved");
@@ -756,7 +756,7 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Generated Type", "Generated image type");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-
+
prop = RNA_def_property(srna, "generated_width", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "gen_x");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
@@ -764,7 +764,7 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Generated Width", "Generated image width");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-
+
prop = RNA_def_property(srna, "generated_height", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "gen_y");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
@@ -772,7 +772,7 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Generated Height", "Generated image height");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-
+
prop = RNA_def_property(srna, "use_generated_float", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gen_flag", IMA_GEN_FLOAT);
RNA_def_property_ui_text(prop, "Float Buffer", "Generate floating point buffer");
@@ -787,7 +787,7 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_float_sdna(prop, NULL, "aspx");
RNA_def_property_array(prop, 2);
RNA_def_property_range(prop, 0.1f, FLT_MAX);
@@ -829,7 +829,7 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
prop = RNA_def_float_vector(srna, "resolution", 2, NULL, 0, 0, "Resolution", "X/Y pixels per meter", 0, 0);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_float_funcs(prop, "rna_Image_resolution_get", "rna_Image_resolution_set", NULL);
prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_UNSIGNED);
@@ -864,14 +864,14 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings");
prop = RNA_def_property(srna, "alpha_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_enum_items(prop, alpha_mode_items);
RNA_def_property_ui_text(prop, "Alpha Mode", "Representation of alpha information in the RGBA pixels");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_colormanage_update");
/* multiview */
prop = RNA_def_property(srna, "views_format", PROP_ENUM, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_enum_sdna(prop, NULL, "views_format");
RNA_def_property_enum_items(prop, rna_enum_views_format_items);
RNA_def_property_ui_text(prop, "Views Format", "Mode to load image views");
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index 7f0ddf04724..39164430140 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -61,9 +61,9 @@
#include "MEM_guardedalloc.h"
-static void rna_ImagePackedFile_save(ImagePackedFile *imapf, ReportList *reports)
+static void rna_ImagePackedFile_save(ImagePackedFile *imapf, Main *bmain, ReportList *reports)
{
- if (writePackedFile(reports, imapf->filepath, imapf->packedfile, 0) != RET_OK) {
+ if (writePackedFile(reports, BKE_main_blendfile_path(bmain), imapf->filepath, imapf->packedfile, 0) != RET_OK) {
BKE_reportf(reports, RPT_ERROR, "Could not save packed file to disk as '%s'",
imapf->filepath);
}
@@ -174,7 +174,7 @@ static void rna_Image_pack(
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, image);
}
-static void rna_Image_unpack(Image *image, ReportList *reports, int method)
+static void rna_Image_unpack(Image *image, Main *bmain, ReportList *reports, int method)
{
if (!BKE_image_has_packedfile(image)) {
BKE_report(reports, RPT_ERROR, "Image not packed");
@@ -185,13 +185,13 @@ static void rna_Image_unpack(Image *image, ReportList *reports, int method)
}
else {
/* reports its own error on failure */
- unpackImage(reports, image, method);
+ unpackImage(bmain, reports, image, method);
}
}
-static void rna_Image_reload(Image *image)
+static void rna_Image_reload(Image *image, Main *bmain)
{
- BKE_image_signal(image, NULL, IMA_SIGNAL_RELOAD);
+ BKE_image_signal(bmain, image, NULL, IMA_SIGNAL_RELOAD);
}
static void rna_Image_update(Image *image, ReportList *reports)
@@ -301,7 +301,7 @@ void RNA_api_image_packed_file(StructRNA *srna)
func = RNA_def_function(srna, "save", "rna_ImagePackedFile_save");
RNA_def_function_ui_description(func, "Save the packed file to its filepath");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
}
void RNA_api_image(StructRNA *srna)
@@ -331,10 +331,11 @@ void RNA_api_image(StructRNA *srna)
func = RNA_def_function(srna, "unpack", "rna_Image_unpack");
RNA_def_function_ui_description(func, "Save an image packed in the .blend file to disk");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
RNA_def_enum(func, "method", rna_enum_unpack_method_items, PF_USE_LOCAL, "method", "How to unpack");
func = RNA_def_function(srna, "reload", "rna_Image_reload");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
RNA_def_function_ui_description(func, "Reload the image from its source path");
func = RNA_def_function(srna, "update", "rna_Image_update");
diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h
index 88efff30481..4536b970f91 100644
--- a/source/blender/makesrna/intern/rna_internal_types.h
+++ b/source/blender/makesrna/intern/rna_internal_types.h
@@ -206,6 +206,8 @@ struct PropertyRNA {
const char *identifier;
/* various options */
int flag;
+ /* various override options */
+ int flag_override;
/* Function parameters flags. */
short flag_parameter;
/* Internal ("private") flags. */
diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c
index 472298a3053..11fb5f7f94b 100644
--- a/source/blender/makesrna/intern/rna_key.c
+++ b/source/blender/makesrna/intern/rna_key.c
@@ -75,20 +75,20 @@ static void rna_ShapeKey_name_set(PointerRNA *ptr, const char *value)
{
KeyBlock *kb = ptr->data;
char oldname[sizeof(kb->name)];
-
+
/* make a copy of the old name first */
BLI_strncpy(oldname, kb->name, sizeof(kb->name));
-
+
/* copy the new name into the name slot */
BLI_strncpy_utf8(kb->name, value, sizeof(kb->name));
-
+
/* make sure the name is truly unique */
if (ptr->id.data) {
Key *key = rna_ShapeKey_find_key(ptr->id.data);
BLI_uniquename(&key->block, kb, CTX_DATA_(BLT_I18NCONTEXT_ID_SHAPEKEY, "Key"), '.',
offsetof(KeyBlock, name), sizeof(kb->name));
}
-
+
/* fix all the animation data which may link to this */
BKE_animdata_fix_paths_rename_all(NULL, "key_blocks", oldname, kb->name);
}
@@ -131,7 +131,7 @@ static void rna_ShapeKey_slider_min_set(PointerRNA *ptr, float value)
{
KeyBlock *data = (KeyBlock *)ptr->data;
float min, max, softmin, softmax;
-
+
rna_ShapeKey_slider_min_range(ptr, &min, &max, &softmin, &softmax);
CLAMP(value, min, max);
data->slidermin = value;
@@ -150,7 +150,7 @@ static void rna_ShapeKey_slider_max_set(PointerRNA *ptr, float value)
{
KeyBlock *data = (KeyBlock *)ptr->data;
float min, max, softmin, softmax;
-
+
rna_ShapeKey_slider_max_range(ptr, &min, &max, &softmin, &softmax);
CLAMP(value, min, max);
data->slidermax = value;
@@ -274,7 +274,7 @@ PointerRNA rna_object_shapekey_index_get(ID *id, int value)
if (key && value < key->totkey)
kb = BLI_findlink(&key->block, value);
-
+
RNA_pointer_create(id, &RNA_ShapeKey, kb, &ptr);
return ptr;
@@ -288,7 +288,7 @@ int rna_object_shapekey_index_set(ID *id, PointerRNA value, int current)
int a = BLI_findindex(&key->block, value.data);
if (a != -1) return a;
}
-
+
return current;
}
@@ -411,17 +411,17 @@ static void rna_ShapeKey_data_begin(CollectionPropertyIterator *iter, PointerRNA
Curve *cu;
Nurb *nu;
int tot = kb->totelem, size = key->elemsize;
-
+
if (GS(key->from->name) == ID_CU) {
cu = (Curve *)key->from;
nu = cu->nurb.first;
-
+
if (nu->bezt) {
tot /= 3;
size *= 3;
}
}
-
+
rna_iterator_array_begin(iter, (void *)kb->data, size, tot, 0, NULL);
}
@@ -432,15 +432,15 @@ static int rna_ShapeKey_data_length(PointerRNA *ptr)
Curve *cu;
Nurb *nu;
int tot = kb->totelem;
-
+
if (GS(key->from->name) == ID_CU) {
cu = (Curve *)key->from;
nu = cu->nurb.first;
-
+
if (nu->bezt)
tot /= 3;
}
-
+
return tot;
}
@@ -450,11 +450,11 @@ static PointerRNA rna_ShapeKey_data_get(CollectionPropertyIterator *iter)
StructRNA *type;
Curve *cu;
Nurb *nu;
-
+
if (GS(key->from->name) == ID_CU) {
cu = (Curve *)key->from;
nu = cu->nurb.first;
-
+
if (nu->bezt)
type = &RNA_ShapeKeyBezierPoint;
else
@@ -462,7 +462,7 @@ static PointerRNA rna_ShapeKey_data_get(CollectionPropertyIterator *iter)
}
else
type = &RNA_ShapeKeyPoint;
-
+
return rna_pointer_inherit_refine(&iter->parent, type, rna_iterator_array_get(iter));
}
@@ -496,11 +496,11 @@ static void rna_Key_update_data(Main *bmain, Scene *UNUSED(scene), PointerRNA *p
static KeyBlock *rna_ShapeKeyData_find_keyblock(Key *key, float *point)
{
KeyBlock *kb;
-
+
/* sanity checks */
if (ELEM(NULL, key, point))
return NULL;
-
+
/* we'll need to manually search through the keyblocks and check
* if the point is somewhere in the middle of each block's data
*/
@@ -508,7 +508,7 @@ static KeyBlock *rna_ShapeKeyData_find_keyblock(Key *key, float *point)
if (kb->data) {
float *start = (float *)kb->data;
float *end;
-
+
/* easy cases first */
if ((start == NULL) || (start > point)) {
/* there's no chance point is in array */
@@ -518,12 +518,12 @@ static KeyBlock *rna_ShapeKeyData_find_keyblock(Key *key, float *point)
/* exact match - point is first in array */
return kb;
}
-
+
/* determine where end of array is
* - elemsize is in bytes, so use (char *) cast to get array in terms of bytes
*/
end = (float *)((char *)start + (key->elemsize * kb->totelem));
-
+
/* if point's address is less than the end, then it is somewhere between start and end, so in array */
if (end > point) {
/* we've found the owner of the point data */
@@ -531,7 +531,7 @@ static KeyBlock *rna_ShapeKeyData_find_keyblock(Key *key, float *point)
}
}
}
-
+
return NULL;
}
@@ -543,18 +543,18 @@ static int rna_ShapeKeyPoint_get_index(Key *key, KeyBlock *kb, float *point)
*/
char *start = (char *)kb->data;
char *pt = (char *)point;
-
+
return (int)(pt - start) / key->elemsize;
}
static int rna_ShapeKeyBezierPoint_get_index(KeyBlock *kb, float *point)
{
float *start = (float *)kb->data;
-
+
/* Unlike with rna_ShapeKeyPoint_get_index(), we cannot use key->elemsize here
* since the default value for curves (16) is actually designed for BPoints
* (i.e. NURBS Surfaces). The magic number "12" here was found by empirical
- * testing on a 64-bit system, and is similar to what's used for meshes and
+ * testing on a 64-bit system, and is similar to what's used for meshes and
* lattices. For more details, see T38013
*/
return (int)(point - start) / 12;
@@ -566,21 +566,21 @@ static char *rna_ShapeKeyPoint_path(PointerRNA *ptr)
Key *key = rna_ShapeKey_find_key(ptr->id.data);
KeyBlock *kb;
float *point = (float *)ptr->data;
-
+
/* if we can get a key block, we can construct a path */
kb = rna_ShapeKeyData_find_keyblock(key, point);
-
+
if (kb) {
char name_esc_kb[sizeof(kb->name) * 2];
int index;
-
+
if (ptr->type == &RNA_ShapeKeyBezierPoint)
index = rna_ShapeKeyBezierPoint_get_index(kb, point);
else
index = rna_ShapeKeyPoint_get_index(key, kb, point);
BLI_strescape(name_esc_kb, kb->name, sizeof(name_esc_kb));
-
+
if (GS(id->name) == ID_KE)
return BLI_sprintfN("key_blocks[\"%s\"].data[%d]", name_esc_kb, index);
else
@@ -690,7 +690,7 @@ static void rna_def_keyblock(BlenderRNA *brna)
RNA_def_property_float_funcs(prop, "rna_ShapeKey_frame_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Frame", "Frame for absolute keys");
RNA_def_property_update(prop, 0, "rna_Key_update_data");
-
+
/* for now, this is editable directly, as users can set this even if they're not animating them
* (to test results) */
prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_FACTOR);
diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c
index d123cdb9773..dff27e1c625 100644
--- a/source/blender/makesrna/intern/rna_lamp.c
+++ b/source/blender/makesrna/intern/rna_lamp.c
@@ -105,7 +105,7 @@ static void rna_Lamp_use_nodes_update(bContext *C, PointerRNA *ptr)
if (la->use_nodes && la->nodetree == NULL)
ED_node_shader_default(C, &la->id);
-
+
rna_Lamp_update(CTX_data_main(C), CTX_data_scene(C), ptr);
}
@@ -155,6 +155,13 @@ static void rna_def_lamp(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Color", "Light color");
RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ prop = RNA_def_property(srna, "specular_factor", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "spec_fac");
+ RNA_def_property_range(prop, 0.0f, 9999.0f);
+ RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 2);
+ RNA_def_property_ui_text(prop, "Specular Factor", "Specular reflection multiplier");
+ RNA_def_property_update(prop, 0, "rna_Lamp_update");
+
/* nodes */
prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
@@ -166,7 +173,7 @@ static void rna_def_lamp(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the lamp");
RNA_def_property_update(prop, 0, "rna_Lamp_use_nodes_update");
-
+
/* common */
rna_def_animdata_common(srna);
}
@@ -189,7 +196,7 @@ static void rna_def_lamp_falloff(StructRNA *srna)
RNA_def_property_enum_items(prop, prop_fallofftype_items);
RNA_def_property_ui_text(prop, "Falloff Type", "Intensity Decay with distance");
RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
+
prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "curfalloff");
RNA_def_property_ui_text(prop, "Falloff Curve", "Custom Lamp Falloff Curve");
@@ -312,13 +319,6 @@ static void rna_def_lamp_shadow(StructRNA *srna, int sun)
"in shadow maps");
RNA_def_property_update(prop, 0, "rna_Lamp_update");
- prop = RNA_def_property(srna, "specular_factor", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "spec_fac");
- RNA_def_property_range(prop, 0.0f, 9999.0f);
- RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 2);
- RNA_def_property_ui_text(prop, "Specular Factor", "Specular reflection multiplier");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
prop = RNA_def_property(srna, "contact_shadow_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "contact_dist");
RNA_def_property_range(prop, 0.0f, 9999.0f);
diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c
index 904a6289fc1..ace7ac30408 100644
--- a/source/blender/makesrna/intern/rna_lattice.c
+++ b/source/blender/makesrna/intern/rna_lattice.c
@@ -216,19 +216,19 @@ static char *rna_LatticePoint_path(PointerRNA *ptr)
Lattice *lt = (Lattice *)ptr->id.data;
void *point = ptr->data;
BPoint *points = NULL;
-
+
if (lt->editlatt && lt->editlatt->latt->def)
points = lt->editlatt->latt->def;
else
points = lt->def;
-
+
if (points && point) {
int tot = lt->pntsu * lt->pntsv * lt->pntsw;
-
+
/* only return index if in range */
if ((point >= (void *)points) && (point < (void *)(points + tot))) {
int pt_index = (int)((BPoint *)point - points);
-
+
return BLI_sprintfN("points[%d]", pt_index);
}
}
@@ -345,7 +345,7 @@ static void rna_def_lattice(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, NULL, "rna_Lattice_use_outside_set");
RNA_def_property_ui_text(prop, "Outside", "Only draw, and take into account, the outer vertices");
RNA_def_property_update(prop, 0, "rna_Lattice_update_data_editlatt");
-
+
prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "vgroup");
RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group to apply the influence of the lattice");
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index 8dc4f8c5e7b..060b075cb29 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -49,6 +49,10 @@
#ifdef RNA_RUNTIME
+#ifdef WITH_PYTHON
+# include "BPY_extern.h"
+#endif
+
#include "DNA_group_types.h"
#include "DNA_object_types.h"
@@ -163,22 +167,20 @@ static void rna_LayerObjects_selected_begin(CollectionPropertyIterator *iter, Po
rna_iterator_listbase_begin(iter, &view_layer->object_bases, rna_ViewLayer_objects_selected_skip);
}
-static void rna_ViewLayer_update_tagged(ViewLayer *UNUSED(view_layer), bContext *C)
+static void rna_ViewLayer_update_tagged(ID *id_ptr, ViewLayer *view_layer, Main *bmain)
{
- Depsgraph *graph = CTX_data_depsgraph(C);
- DEG_OBJECT_ITER_BEGIN(
- graph, ob, DEG_ITER_OBJECT_MODE_VIEWPORT,
- DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
- DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
- DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY |
- DEG_ITER_OBJECT_FLAG_VISIBLE |
- DEG_ITER_OBJECT_FLAG_DUPLI)
- {
- /* Don't do anything, we just need to run the iterator to flush
- * the base info to the objects. */
- UNUSED_VARS(ob);
- }
- DEG_OBJECT_ITER_END;
+#ifdef WITH_PYTHON
+ /* Allow drivers to be evaluated */
+ BPy_BEGIN_ALLOW_THREADS;
+#endif
+
+ Scene *scene = (Scene *)id_ptr;
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ BKE_scene_graph_update_tagged(depsgraph, bmain);
+
+#ifdef WITH_PYTHON
+ BPy_END_ALLOW_THREADS;
+#endif
}
static void rna_ObjectBase_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -351,7 +353,7 @@ void RNA_def_view_layer(BlenderRNA *brna)
/* debug update routine */
func = RNA_def_function(srna, "update", "rna_ViewLayer_update_tagged");
- RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
RNA_def_function_ui_description(func,
"Update data tagged to be updated from previous access to data or operators");
diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c
index d727b896223..7b9184eb5df 100644
--- a/source/blender/makesrna/intern/rna_main.c
+++ b/source/blender/makesrna/intern/rna_main.c
@@ -386,7 +386,7 @@ void RNA_def_main(BlenderRNA *brna)
};
int i;
-
+
srna = RNA_def_struct(brna, "BlendData", NULL);
RNA_def_struct_ui_text(srna, "Blendfile Data",
"Main data structure representing a .blend file and all its data-blocks");
@@ -397,7 +397,7 @@ void RNA_def_main(BlenderRNA *brna)
RNA_def_property_string_funcs(prop, "rna_Main_filepath_get", "rna_Main_filepath_length", "rna_Main_filepath_set");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Filename", "Path to the .blend file");
-
+
prop = RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_boolean_funcs(prop, "rna_Main_is_dirty_get", NULL);
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index 56035f8239c..331bf4a580d 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -251,7 +251,7 @@ static Object *rna_Main_objects_new(Main *bmain, ReportList *reports, const char
ob = BKE_object_add_only_object(bmain, type, safe_name);
ob->data = data;
- test_object_materials(ob, ob->data);
+ test_object_materials(bmain, ob, ob->data);
return ob;
}
@@ -346,7 +346,7 @@ static Image *rna_Main_images_load(Main *bmain, ReportList *reports, const char
errno = 0;
if (check_existing) {
- ima = BKE_image_load_exists(filepath);
+ ima = BKE_image_load_exists(bmain, filepath);
}
else {
ima = BKE_image_load(bmain, filepath);
@@ -489,7 +489,7 @@ static Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *f
Text *txt;
errno = 0;
- txt = BKE_text_load_ex(bmain, filepath, bmain->name, is_internal);
+ txt = BKE_text_load_ex(bmain, filepath, BKE_main_blendfile_path(bmain), is_internal);
if (!txt)
BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath,
@@ -591,14 +591,11 @@ static LightProbe *rna_Main_lightprobe_new(Main *bmain, const char *name)
return probe;
}
-/* tag and is_updated functions, all the same */
+/* tag functions, all the same */
#define RNA_MAIN_ID_TAG_FUNCS_DEF(_func_name, _listbase_name, _id_type) \
static void rna_Main_##_func_name##_tag(Main *bmain, int value) { \
BKE_main_id_tag_listbase(&bmain->_listbase_name, LIB_TAG_DOIT, value); \
} \
- static int rna_Main_##_func_name##_is_updated_get(PointerRNA *ptr) { \
- return DEG_id_type_tagged(ptr->data, _id_type) != 0; \
- }
RNA_MAIN_ID_TAG_FUNCS_DEF(cameras, camera, ID_CA)
RNA_MAIN_ID_TAG_FUNCS_DEF(scenes, scene, ID_SCE)
@@ -662,7 +659,6 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataCameras");
srna = RNA_def_struct(brna, "BlendDataCameras", NULL);
@@ -694,10 +690,6 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_cameras_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_cameras_is_updated_get", NULL);
}
void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop)
@@ -705,7 +697,6 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataScenes");
srna = RNA_def_struct(brna, "BlendDataScenes", NULL);
@@ -731,10 +722,6 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_scenes_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_scenes_is_updated_get", NULL);
}
void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop)
@@ -742,7 +729,6 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataObjects");
srna = RNA_def_struct(brna, "BlendDataObjects", NULL);
@@ -776,10 +762,6 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_objects_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_objects_is_updated_get", NULL);
}
void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop)
@@ -787,7 +769,6 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataMaterials");
srna = RNA_def_struct(brna, "BlendDataMaterials", NULL);
@@ -817,17 +798,12 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_materials_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_materials_is_updated_get", NULL);
}
void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
static const EnumPropertyItem dummy_items[] = {
{0, "DUMMY", 0, "", ""},
@@ -865,17 +841,12 @@ void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_node_groups_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_node_groups_is_updated_get", NULL);
}
void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataMeshes");
srna = RNA_def_struct(brna, "BlendDataMeshes", NULL);
@@ -922,17 +893,12 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_meshes_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_meshes_is_updated_get", NULL);
}
void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataLamps");
srna = RNA_def_struct(brna, "BlendDataLamps", NULL);
@@ -966,10 +932,6 @@ void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_lamps_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_lamps_is_updated_get", NULL);
}
void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop)
@@ -977,7 +939,6 @@ void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataLibraries");
srna = RNA_def_struct(brna, "BlendDataLibraries", NULL);
@@ -987,10 +948,6 @@ void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_libraries_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_libraries_is_updated_get", NULL);
}
void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop)
@@ -998,7 +955,6 @@ void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataScreens");
srna = RNA_def_struct(brna, "BlendDataScreens", NULL);
@@ -1008,10 +964,6 @@ void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_screens_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_screens_is_updated_get", NULL);
}
void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1019,7 +971,6 @@ void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataWindowManagers");
srna = RNA_def_struct(brna, "BlendDataWindowManagers", NULL);
@@ -1029,17 +980,12 @@ void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_window_managers_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_window_managers_is_updated_get", NULL);
}
void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataImages");
srna = RNA_def_struct(brna, "BlendDataImages", NULL);
@@ -1086,10 +1032,6 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_images_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_images_is_updated_get", NULL);
}
void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1097,7 +1039,6 @@ void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataLattices");
srna = RNA_def_struct(brna, "BlendDataLattices", NULL);
@@ -1129,17 +1070,12 @@ void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_lattices_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_lattices_is_updated_get", NULL);
}
void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataCurves");
srna = RNA_def_struct(brna, "BlendDataCurves", NULL);
@@ -1173,17 +1109,12 @@ void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_curves_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_curves_is_updated_get", NULL);
}
void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataMetaBalls");
srna = RNA_def_struct(brna, "BlendDataMetaBalls", NULL);
@@ -1215,17 +1146,12 @@ void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_metaballs_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_metaballs_is_updated_get", NULL);
}
void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataFonts");
srna = RNA_def_struct(brna, "BlendDataFonts", NULL);
@@ -1257,17 +1183,12 @@ void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_fonts_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_fonts_is_updated_get", NULL);
}
void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataTextures");
srna = RNA_def_struct(brna, "BlendDataTextures", NULL);
@@ -1299,17 +1220,12 @@ void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_textures_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_textures_is_updated_get", NULL);
}
void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataBrushes");
srna = RNA_def_struct(brna, "BlendDataBrushes", NULL);
@@ -1340,10 +1256,6 @@ void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_brushes_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_brushes_is_updated_get", NULL);
}
void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1351,7 +1263,6 @@ void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataWorlds");
srna = RNA_def_struct(brna, "BlendDataWorlds", NULL);
@@ -1381,10 +1292,6 @@ void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_worlds_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_worlds_is_updated_get", NULL);
}
void RNA_def_main_collections(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1392,7 +1299,6 @@ void RNA_def_main_collections(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataCollections");
srna = RNA_def_struct(brna, "BlendDataCollections", NULL);
@@ -1422,10 +1328,6 @@ void RNA_def_main_collections(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_collections_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_collections_is_updated_get", NULL);
}
void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1433,7 +1335,6 @@ void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataSpeakers");
srna = RNA_def_struct(brna, "BlendDataSpeakers", NULL);
@@ -1465,10 +1366,6 @@ void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_speakers_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_speakers_is_updated_get", NULL);
}
void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1476,7 +1373,6 @@ void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataTexts");
srna = RNA_def_struct(brna, "BlendDataTexts", NULL);
@@ -1517,10 +1413,6 @@ void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_texts_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_texts_is_updated_get", NULL);
}
void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1528,7 +1420,6 @@ void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataSounds");
srna = RNA_def_struct(brna, "BlendDataSounds", NULL);
@@ -1560,10 +1451,6 @@ void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_sounds_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_sounds_is_updated_get", NULL);
}
void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1571,7 +1458,6 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataArmatures");
srna = RNA_def_struct(brna, "BlendDataArmatures", NULL);
@@ -1603,17 +1489,12 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_armatures_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_armatures_is_updated_get", NULL);
}
void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataActions");
srna = RNA_def_struct(brna, "BlendDataActions", NULL);
@@ -1643,17 +1524,12 @@ void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_actions_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_actions_is_updated_get", NULL);
}
void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataParticles");
srna = RNA_def_struct(brna, "BlendDataParticles", NULL);
@@ -1683,10 +1559,6 @@ void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_particles_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_particles_is_updated_get", NULL);
}
void RNA_def_main_palettes(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1694,7 +1566,6 @@ void RNA_def_main_palettes(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataPalettes");
srna = RNA_def_struct(brna, "BlendDataPalettes", NULL);
@@ -1724,17 +1595,12 @@ void RNA_def_main_palettes(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_palettes_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_palettes_is_updated_get", NULL);
}
void RNA_def_main_cachefiles(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataCacheFiles");
srna = RNA_def_struct(brna, "BlendDataCacheFiles", NULL);
@@ -1744,17 +1610,12 @@ void RNA_def_main_cachefiles(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_cachefiles_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_cachefiles_is_updated_get", NULL);
}
void RNA_def_main_paintcurves(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataPaintCurves");
srna = RNA_def_struct(brna, "BlendDataPaintCurves", NULL);
@@ -1764,17 +1625,12 @@ void RNA_def_main_paintcurves(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_paintcurves_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_paintcurves_is_updated_get", NULL);
}
void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataGreasePencils");
srna = RNA_def_struct(brna, "BlendDataGreasePencils", NULL);
@@ -1804,10 +1660,6 @@ void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop)
"Decrement user counter of all datablocks used by this grease pencil");
RNA_def_boolean(func, "do_ui_user", true, "",
"Make sure interface does not reference this grease pencil");
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_gpencil_is_updated_get", NULL);
}
void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1815,7 +1667,6 @@ void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataMovieClips");
srna = RNA_def_struct(brna, "BlendDataMovieClips", NULL);
@@ -1851,10 +1702,6 @@ void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop)
/* return type */
parm = RNA_def_pointer(func, "clip", "MovieClip", "", "New movie clip data-block");
RNA_def_function_return(func, parm);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_movieclips_is_updated_get", NULL);
}
void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1862,7 +1709,6 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataMasks");
srna = RNA_def_struct(brna, "BlendDataMasks", NULL);
@@ -1893,10 +1739,6 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop)
"Decrement user counter of all datablocks used by this mask");
RNA_def_boolean(func, "do_ui_user", true, "",
"Make sure interface does not reference this mask");
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_masks_is_updated_get", NULL);
}
void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1904,7 +1746,6 @@ void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataLineStyles");
srna = RNA_def_struct(brna, "BlendDataLineStyles", NULL);
@@ -1934,10 +1775,6 @@ void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop)
"Decrement user counter of all datablocks used by this line style");
RNA_def_boolean(func, "do_ui_user", true, "",
"Make sure interface does not reference this line style");
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_linestyle_is_updated_get", NULL);
}
void RNA_def_main_workspaces(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1945,7 +1782,6 @@ void RNA_def_main_workspaces(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataWorkSpaces");
srna = RNA_def_struct(brna, "BlendDataWorkSpaces", NULL);
@@ -1955,10 +1791,6 @@ void RNA_def_main_workspaces(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_workspaces_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_workspaces_is_updated_get", NULL);
}
void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1966,7 +1798,6 @@ void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
- PropertyRNA *prop;
RNA_def_property_srna(cprop, "BlendDataProbes");
srna = RNA_def_struct(brna, "BlendDataProbes", NULL);
@@ -1998,10 +1829,6 @@ void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "tag", "rna_Main_lightprobes_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_Main_lightprobes_is_updated_get", NULL);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index a40606018e7..858dd0ec972 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -97,10 +97,10 @@ static void rna_Material_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Point
static void rna_Material_update_previews(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
Material *ma = ptr->id.data;
-
+
if (ma->nodetree)
BKE_node_preview_clear_tree(ma->nodetree);
-
+
WM_main_add_notifier(NC_MATERIAL | ND_SHADING_PREVIEW, ma);
}
@@ -112,11 +112,6 @@ static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, ma);
}
-static PointerRNA rna_Material_mirror_get(PointerRNA *ptr)
-{
- return rna_pointer_inherit_refine(ptr, &RNA_MaterialRaytraceMirror, ptr->id.data);
-}
-
static void rna_Material_texpaint_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Material *ma = (Material *)ptr->data;
@@ -165,7 +160,7 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *s
if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
if (!sima->pin) {
- ED_space_image_set(sima, scene, obedit, image);
+ ED_space_image_set(bmain, sima, scene, obedit, image);
}
}
}
@@ -231,7 +226,7 @@ void rna_mtex_texture_slots_clear(ID *self_id, struct bContext *C, ReportList *r
BKE_report(reports, RPT_ERROR, "Mtex not found for this type");
return;
}
-
+
if (index < 0 || index >= MAX_MTEX) {
BKE_reportf(reports, RPT_ERROR, "Index %d is invalid", index);
return;
@@ -250,7 +245,7 @@ void rna_mtex_texture_slots_clear(ID *self_id, struct bContext *C, ReportList *r
#else
-static void rna_def_material_colors(StructRNA *srna)
+static void rna_def_material_display(StructRNA *srna)
{
PropertyRNA *prop;
@@ -259,23 +254,32 @@ static void rna_def_material_colors(StructRNA *srna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Diffuse Color", "Diffuse color of the material");
RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
+
prop = RNA_def_property(srna, "specular_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "specr");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Specular Color", "Specular color of the material");
RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
+
+ prop = RNA_def_property(srna, "roughness", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "roughness");
+ RNA_def_property_float_default(prop, 0.25f);
+ RNA_def_property_range(prop, 0, 1);
+ RNA_def_property_ui_text(prop, "Roughness", "Roughness of the material");
+ RNA_def_property_update(prop, 0, "rna_Material_draw_update");
+
prop = RNA_def_property(srna, "specular_intensity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "spec");
+ RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, 0, 1);
- RNA_def_property_ui_text(prop, "Specular Intensity", "How intense (bright) the specular reflection is");
+ RNA_def_property_ui_text(prop, "Specular", "How intense (bright) the specular reflection is");
RNA_def_property_update(prop, 0, "rna_Material_draw_update");
- prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_FACTOR);
+ prop = RNA_def_property(srna, "metallic", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "metallic");
RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Alpha", "Alpha transparency of the material");
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
+ RNA_def_property_ui_text(prop, "Metallic", "Amount of mirror reflection for raytrace");
+ RNA_def_property_update(prop, 0, "rna_Material_update");
/* Freestyle line color */
prop = RNA_def_property(srna, "line_color", PROP_FLOAT, PROP_COLOR);
@@ -292,30 +296,6 @@ static void rna_def_material_colors(StructRNA *srna)
RNA_def_property_update(prop, 0, "rna_Material_update");
}
-static void rna_def_material_raymirror(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "MaterialRaytraceMirror", NULL);
- RNA_def_struct_sdna(srna, "Material");
- RNA_def_struct_nested(brna, srna, "Material");
- RNA_def_struct_ui_text(srna, "Material Raytrace Mirror", "Raytraced reflection settings for a Material data-block");
-
- prop = RNA_def_property(srna, "reflect_factor", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "ray_mirror");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Reflectivity", "Amount of mirror reflection for raytrace");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "gloss_factor", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "gloss_mir");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Gloss Amount",
- "The shininess of the reflection (values < 1.0 give diffuse, blurry reflections)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-}
-
void RNA_def_material(BlenderRNA *brna)
{
StructRNA *srna;
@@ -354,7 +334,7 @@ void RNA_def_material(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Material",
"Material data-block to define the appearance of geometric objects for rendering");
RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
-
+
/* Blending (only Eevee for now) */
prop = RNA_def_property(srna, "blend_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_eevee_blend_items);
@@ -406,19 +386,12 @@ void RNA_def_material(BlenderRNA *brna)
RNA_def_property_enum_items(prop, preview_type_items);
RNA_def_property_ui_text(prop, "Preview render type", "Type of preview render");
RNA_def_property_update(prop, 0, "rna_Material_update_previews");
-
+
prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "index");
RNA_def_property_ui_text(prop, "Pass Index", "Index number for the \"Material Index\" render pass");
RNA_def_property_update(prop, NC_OBJECT, "rna_Material_update");
- /* nested structs */
- prop = RNA_def_property(srna, "raytrace_mirror", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_struct_type(prop, "MaterialRaytraceMirror");
- RNA_def_property_pointer_funcs(prop, "rna_Material_mirror_get", NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Raytrace Mirror", "Raytraced reflection settings for the material");
-
/* nodetree */
prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
@@ -435,8 +408,7 @@ void RNA_def_material(BlenderRNA *brna)
rna_def_animdata_common(srna);
rna_def_texpaint_slots(brna, srna);
- rna_def_material_colors(srna);
- rna_def_material_raymirror(brna);
+ rna_def_material_display(srna);
RNA_api_material(srna);
}
@@ -460,14 +432,14 @@ static void rna_def_texture_slots(BlenderRNA *brna, PropertyRNA *cprop, const ch
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_NO_SELF | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "mtex", structname, "", "The newly initialized mtex");
RNA_def_function_return(func, parm);
-
+
func = RNA_def_function(srna, "create", "rna_mtex_texture_slots_create");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_NO_SELF | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
parm = RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Slot index to initialize", 0, INT_MAX);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_pointer(func, "mtex", structname, "", "The newly initialized mtex");
RNA_def_function_return(func, parm);
-
+
func = RNA_def_function(srna, "clear", "rna_mtex_texture_slots_clear");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_NO_SELF | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
parm = RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Slot index to clear", 0, INT_MAX);
@@ -518,7 +490,7 @@ static void rna_def_tex_slot(BlenderRNA *brna)
RNA_def_property_string_sdna(prop, NULL, "uvname");
RNA_def_property_ui_text(prop, "UV Map", "Name of UV map");
RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Material_update");
-
+
prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "valid", 1);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index 9ec196034f3..d664415b8ad 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -3142,7 +3142,7 @@ static void rna_def_skin_vertices(BlenderRNA *brna, PropertyRNA *UNUSED(cprop))
RNA_def_property_boolean_sdna(prop, NULL, "flag", MVERT_SKIN_ROOT);
RNA_def_property_ui_text(prop, "Root", "Vertex is a root for rotation calculations and armature generation");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
+
prop = RNA_def_property(srna, "use_loose", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MVERT_SKIN_LOOSE);
RNA_def_property_ui_text(prop, "Loose", "If vertex has multiple adjacent edges, it is hulled to them directly");
diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c
index f1f7c9a3b99..ed19877ec0f 100644
--- a/source/blender/makesrna/intern/rna_mesh_api.c
+++ b/source/blender/makesrna/intern/rna_mesh_api.c
@@ -55,10 +55,10 @@
static const char *rna_Mesh_unit_test_compare(struct Mesh *mesh, struct Mesh *mesh2)
{
const char *ret = BKE_mesh_cmp(mesh, mesh2, FLT_EPSILON * 60);
-
+
if (!ret)
ret = "Same";
-
+
return ret;
}
diff --git a/source/blender/makesrna/intern/rna_mesh_utils.h b/source/blender/makesrna/intern/rna_mesh_utils.h
index a85e2095121..b16a7254a86 100644
--- a/source/blender/makesrna/intern/rna_mesh_utils.h
+++ b/source/blender/makesrna/intern/rna_mesh_utils.h
@@ -23,7 +23,7 @@
/** \file blender/makesrna/intern/rna_mesh_utils.h
* \ingroup RNA
*/
-
+
#ifndef __RNA_MESH_UTILS_H__
#define __RNA_MESH_UTILS_H__
diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c
index 124f3a2fbe2..cdecba0760c 100644
--- a/source/blender/makesrna/intern/rna_meta.c
+++ b/source/blender/makesrna/intern/rna_meta.c
@@ -64,32 +64,32 @@ static int rna_Meta_texspace_editable(PointerRNA *ptr, const char **UNUSED(r_inf
static void rna_Meta_texspace_loc_get(PointerRNA *ptr, float *values)
{
MetaBall *mb = (MetaBall *)ptr->data;
-
+
/* tex_space_mball() needs object.. ugh */
-
+
copy_v3_v3(values, mb->loc);
}
static void rna_Meta_texspace_loc_set(PointerRNA *ptr, const float *values)
{
MetaBall *mb = (MetaBall *)ptr->data;
-
+
copy_v3_v3(mb->loc, values);
}
static void rna_Meta_texspace_size_get(PointerRNA *ptr, float *values)
{
MetaBall *mb = (MetaBall *)ptr->data;
-
+
/* tex_space_mball() needs object.. ugh */
-
+
copy_v3_v3(values, mb->size);
}
static void rna_Meta_texspace_size_set(PointerRNA *ptr, const float *values)
{
MetaBall *mb = (MetaBall *)ptr->data;
-
+
copy_v3_v3(mb->size, values);
}
@@ -104,7 +104,7 @@ static void rna_MetaBall_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
for (ob = bmain->object.first; ob; ob = ob->id.next)
if (ob->data == mb)
BKE_mball_properties_copy(scene, ob);
-
+
DEG_id_tag_update(&mb->id, 0);
WM_main_add_notifier(NC_GEOM | ND_DATA, mb);
}
@@ -200,7 +200,7 @@ static void rna_def_metaelement(BlenderRNA *brna)
RNA_def_property_enum_items(prop, rna_enum_metaelem_type_items);
RNA_def_property_ui_text(prop, "Type", "Metaball types");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
-
+
/* number values */
prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "x");
@@ -239,19 +239,19 @@ static void rna_def_metaelement(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 20.0f);
RNA_def_property_ui_text(prop, "Size Z", "Size of element, use of components depends on element type");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
-
+
prop = RNA_def_property(srna, "stiffness", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "s");
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(prop, "Stiffness", "Stiffness defines how much of the element to fill");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
-
+
/* flags */
prop = RNA_def_property(srna, "use_negative", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MB_NEGATIVE);
RNA_def_property_ui_text(prop, "Negative", "Set metaball as negative one");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
-
+
prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MB_HIDE);
RNA_def_property_ui_text(prop, "Hide", "Hide element");
@@ -304,7 +304,7 @@ static void rna_def_metaball(BlenderRNA *brna)
{MB_UPDATE_NEVER, "NEVER", 0, "Never", "While editing, don't update metaball at all"},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "MetaBall", "ID");
RNA_def_struct_ui_text(srna, "MetaBall", "Metaball data-block to defined blobby surfaces");
RNA_def_struct_ui_icon(srna, ICON_META_DATA);
@@ -321,7 +321,7 @@ static void rna_def_metaball(BlenderRNA *brna)
RNA_def_property_enum_items(prop, prop_update_items);
RNA_def_property_ui_text(prop, "Update", "Metaball edit update behavior");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
-
+
/* number values */
prop = RNA_def_property(srna, "resolution", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "wiresize");
@@ -329,14 +329,14 @@ static void rna_def_metaball(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.05f, 1000.0f, 2.5f, 3);
RNA_def_property_ui_text(prop, "Wire Size", "Polygonization resolution in the 3D viewport");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
-
+
prop = RNA_def_property(srna, "render_resolution", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "rendersize");
RNA_def_property_range(prop, 0.005f, 10000.0f);
RNA_def_property_ui_range(prop, 0.025f, 1000.0f, 2.5f, 3);
RNA_def_property_ui_text(prop, "Render Size", "Polygonization resolution in rendering");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
-
+
prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "thresh");
RNA_def_property_range(prop, 0.0f, 5.0f);
@@ -348,14 +348,14 @@ static void rna_def_metaball(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "texflag", MB_AUTOSPACE);
RNA_def_property_ui_text(prop, "Auto Texture Space",
"Adjust active object's texture space automatically when transforming object");
-
+
prop = RNA_def_property(srna, "texspace_location", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location");
RNA_def_property_editable_func(prop, "rna_Meta_texspace_editable");
RNA_def_property_float_funcs(prop, "rna_Meta_texspace_loc_get", "rna_Meta_texspace_loc_set", NULL);
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
-
+
prop = RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ);
RNA_def_property_array(prop, 3);
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
@@ -363,7 +363,7 @@ static void rna_def_metaball(BlenderRNA *brna)
RNA_def_property_editable_func(prop, "rna_Meta_texspace_editable");
RNA_def_property_float_funcs(prop, "rna_Meta_texspace_size_get", "rna_Meta_texspace_size_set", NULL);
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
-
+
/* not supported yet */
#if 0
prop = RNA_def_property(srna, "texspace_rot", PROP_FLOAT, PROP_EULER);
@@ -372,7 +372,7 @@ static void rna_def_metaball(BlenderRNA *brna)
RNA_def_property_editable_func(prop, "rna_Meta_texspace_editable");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
#endif
-
+
/* materials */
prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
@@ -380,7 +380,7 @@ static void rna_def_metaball(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Materials", "");
RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int");
-
+
prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Meta_is_editmode_get", NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 37bb54cbe9e..04d8613c8d8 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -430,19 +430,19 @@ static void rna_Modifier_name_set(PointerRNA *ptr, const char *value)
{
ModifierData *md = ptr->data;
char oldname[sizeof(md->name)];
-
+
/* make a copy of the old name first */
BLI_strncpy(oldname, md->name, sizeof(md->name));
-
+
/* copy the new name into the name slot */
BLI_strncpy_utf8(md->name, value, sizeof(md->name));
-
+
/* make sure the name is truly unique */
if (ptr->id.data) {
Object *ob = ptr->id.data;
modifier_unique_name(&ob->modifiers, md);
}
-
+
/* fix all the animation data which may link to this */
BKE_animdata_fix_paths_rename_all(NULL, "modifiers", oldname, md->name);
}
@@ -701,7 +701,7 @@ static int rna_ShrinkwrapModifier_face_cull_get(PointerRNA *ptr)
static void rna_ShrinkwrapModifier_face_cull_set(struct PointerRNA *ptr, int value)
{
ShrinkwrapModifierData *swm = (ShrinkwrapModifierData *)ptr->data;
-
+
swm->shrinkOpts =
(swm->shrinkOpts & ~(MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE | MOD_SHRINKWRAP_CULL_TARGET_BACKFACE)) | value;
}
@@ -742,27 +742,27 @@ static void rna_UVProjectModifier_num_projectors_set(PointerRNA *ptr, int value)
static void rna_OceanModifier_init_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
OceanModifierData *omd = (OceanModifierData *)ptr->data;
-
+
omd->refresh |= (MOD_OCEAN_REFRESH_RESET | MOD_OCEAN_REFRESH_SIM | MOD_OCEAN_REFRESH_CLEAR_CACHE);
-
+
rna_Modifier_update(bmain, scene, ptr);
}
static void rna_OceanModifier_sim_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
OceanModifierData *omd = (OceanModifierData *)ptr->data;
-
+
omd->refresh |= MOD_OCEAN_REFRESH_SIM;
-
+
rna_Modifier_update(bmain, scene, ptr);
}
static void rna_OceanModifier_topology_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
OceanModifierData *omd = (OceanModifierData *)ptr->data;
-
+
omd->refresh |= MOD_OCEAN_REFRESH_TOPOLOGY;
-
+
rna_Modifier_update(bmain, scene, ptr);
}
@@ -770,9 +770,9 @@ static void rna_OceanModifier_ocean_chop_set(PointerRNA *ptr, float value)
{
OceanModifierData *omd = (OceanModifierData *)ptr->data;
float old_value = omd->chop_amount;
-
+
omd->chop_amount = value;
-
+
if ((old_value == 0.0f && value > 0.0f) ||
(old_value > 0.0f && value == 0.0f))
{
@@ -1247,7 +1247,7 @@ static void rna_def_modifier_subsurf(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flags", eSubsurfModifierFlag_ControlEdges);
RNA_def_property_ui_text(prop, "Optimal Display", "Skip drawing/rendering of interior subdivided edges");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "use_subsurf_uv", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", eSubsurfModifierFlag_SubsurfUv);
RNA_def_property_ui_text(prop, "Subdivide UVs", "Use subsurf to subdivide UVs");
@@ -1433,7 +1433,7 @@ static void rna_def_modifier_lattice(BlenderRNA *brna)
"Name of Vertex Group which determines influence of modifier per point");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_LatticeModifier_name_set");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
RNA_def_property_ui_range(prop, 0, 1, 10, 2);
@@ -1507,7 +1507,7 @@ static void rna_def_modifier_build(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_BUILD_FLAG_REVERSE);
RNA_def_property_ui_text(prop, "Reversed", "Deconstruct the mesh instead of building it");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "use_random_order", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_BUILD_FLAG_RANDOMIZE);
RNA_def_property_ui_text(prop, "Randomize", "Randomize the faces or edges during build");
@@ -1553,7 +1553,7 @@ static void rna_def_modifier_mirror(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MIR_VGROUP);
RNA_def_property_ui_text(prop, "Mirror Vertex Groups", "Mirror vertex groups (e.g. .R->.L)");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "use_mirror_merge", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", MOD_MIR_NO_MERGE);
RNA_def_property_ui_text(prop, "Merge Vertices", "Merge vertices within the merge threshold");
@@ -1858,7 +1858,8 @@ static void rna_def_modifier_armature(BlenderRNA *brna)
prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Object", "Armature object to deform with");
RNA_def_property_pointer_funcs(prop, NULL, "rna_ArmatureModifier_object_set", NULL, "rna_Armature_object_poll");
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK | PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop = RNA_def_property(srna, "use_bone_envelopes", PROP_BOOLEAN, PROP_NONE);
@@ -1870,7 +1871,7 @@ static void rna_def_modifier_armature(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_VGROUP);
RNA_def_property_ui_text(prop, "Use Vertex Groups", "Bind vertex groups to armature modifier");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "use_deform_preserve_volume", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_QUATERNION);
RNA_def_property_ui_text(prop, "Preserve Volume", "Deform rotation interpolation with quaternions");
@@ -1881,7 +1882,7 @@ static void rna_def_modifier_armature(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Multi Modifier",
"Use same input as previous modifier, and mix results using overall vgroup");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
RNA_def_property_ui_text(prop, "Vertex Group",
@@ -1945,7 +1946,7 @@ static void rna_def_modifier_hook(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
RNA_def_property_pointer_funcs(prop, NULL, "rna_HookModifier_object_set", NULL, NULL);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
-
+
prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "subtarget");
RNA_def_property_ui_text(prop, "Sub-Target",
@@ -2091,7 +2092,7 @@ static void rna_def_modifier_array(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "offset_type", MOD_ARR_OFF_CONST);
RNA_def_property_ui_text(prop, "Constant Offset", "Add a constant offset");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "constant_offset_displace", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "offset");
RNA_def_property_ui_text(prop, "Constant Offset Displacement", "Value for the distance between arrayed items");
@@ -2141,7 +2142,7 @@ static void rna_def_modifier_array(BlenderRNA *brna)
"rotational change between arrayed items");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
-
+
/* Caps */
prop = RNA_def_property(srna, "start_cap", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Start Cap", "Mesh object to use as a start cap");
@@ -2154,7 +2155,7 @@ static void rna_def_modifier_array(BlenderRNA *brna)
RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_end_cap_set", NULL, "rna_Mesh_object_poll");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
-
+
prop = RNA_def_property(srna, "offset_u", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "uv_offset[0]");
RNA_def_property_range(prop, -1, 1);
@@ -2303,7 +2304,7 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 1, 1000, 1, 3);
RNA_def_property_ui_text(prop, "Vertical Aspect Ratio", "");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "scale_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "scalex");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
@@ -2368,7 +2369,7 @@ static void rna_def_modifier_smooth(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0, 30, 1, -1);
RNA_def_property_ui_text(prop, "Repeat", "");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
RNA_def_property_ui_text(prop, "Vertex Group",
@@ -2490,7 +2491,7 @@ static void rna_def_modifier_laplaciansmooth(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME);
RNA_def_property_ui_text(prop, "Preserve Volume", "Apply volume preservation after smooth");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "use_normalized", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_NORMALIZED);
RNA_def_property_ui_text(prop, "Normalized", "Improve and stabilize the enhanced shape");
@@ -2515,7 +2516,7 @@ static void rna_def_modifier_laplaciansmooth(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0, 200, 1, -1);
RNA_def_property_ui_text(prop, "Repeat", "");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
RNA_def_property_ui_text(prop, "Vertex Group",
@@ -2546,7 +2547,7 @@ static void rna_def_modifier_cast(BlenderRNA *brna)
RNA_def_property_enum_items(prop, prop_cast_type_items);
RNA_def_property_ui_text(prop, "Cast Type", "Target object shape");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Object",
"Control object: if available, its location determines the center of the effect");
@@ -2568,17 +2569,17 @@ static void rna_def_modifier_cast(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CAST_Z);
RNA_def_property_ui_text(prop, "Z", "");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "use_radius_as_size", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CAST_SIZE_FROM_RADIUS);
RNA_def_property_ui_text(prop, "From Radius", "Use radius as size of projection shape (0 = auto)");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "use_transform", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CAST_USE_OB_TRANSFORM);
RNA_def_property_ui_text(prop, "Use transform", "Use object transform to control projection shape");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "fac");
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
@@ -2629,12 +2630,12 @@ static void rna_def_modifier_meshdeform(BlenderRNA *brna)
RNA_def_property_pointer_funcs(prop, NULL, "rna_MeshDeformModifier_object_set", NULL, "rna_Mesh_object_poll");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
-
+
prop = RNA_def_property(srna, "is_bound", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_MeshDeformModifier_is_bound_get", NULL);
RNA_def_property_ui_text(prop, "Bound", "Whether geometry has been bound to control cage");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
+
prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MDEF_INVERT_VGROUP);
RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
@@ -2676,7 +2677,7 @@ static void rna_def_modifier_particlesystem(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "ParticleSystem Modifier", "Particle system simulation modifier");
RNA_def_struct_sdna(srna, "ParticleSystemModifierData");
RNA_def_struct_ui_icon(srna, ICON_MOD_PARTICLES);
-
+
prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, NULL, "psys");
@@ -2880,22 +2881,22 @@ static void rna_def_modifier_cloth(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Cloth Modifier", "Cloth simulation modifier");
RNA_def_struct_sdna(srna, "ClothModifierData");
RNA_def_struct_ui_icon(srna, ICON_MOD_CLOTH);
-
+
prop = RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, NULL, "sim_parms");
RNA_def_property_ui_text(prop, "Cloth Settings", "");
-
+
prop = RNA_def_property(srna, "collision_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, NULL, "coll_parms");
RNA_def_property_ui_text(prop, "Cloth Collision Settings", "");
-
+
prop = RNA_def_property(srna, "solver_result", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "ClothSolverResult");
RNA_def_property_pointer_sdna(prop, NULL, "solver_result");
RNA_def_property_ui_text(prop, "Solver Result", "");
-
+
prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Point Cache", "");
@@ -2920,7 +2921,7 @@ static void rna_def_modifier_smoke(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem prop_smoke_type_items[] = {
{0, "NONE", 0, "None", ""},
{MOD_SMOKE_TYPE_DOMAIN, "DOMAIN", 0, "Domain", ""},
@@ -2928,24 +2929,24 @@ static void rna_def_modifier_smoke(BlenderRNA *brna)
{MOD_SMOKE_TYPE_COLL, "COLLISION", 0, "Collision", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "SmokeModifier", "Modifier");
RNA_def_struct_ui_text(srna, "Smoke Modifier", "Smoke simulation modifier");
RNA_def_struct_sdna(srna, "SmokeModifierData");
RNA_def_struct_ui_icon(srna, ICON_MOD_SMOKE);
-
+
prop = RNA_def_property(srna, "domain_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "domain");
RNA_def_property_ui_text(prop, "Domain Settings", "");
-
+
prop = RNA_def_property(srna, "flow_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "flow");
RNA_def_property_ui_text(prop, "Flow Settings", "");
-
+
prop = RNA_def_property(srna, "coll_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "coll");
RNA_def_property_ui_text(prop, "Collision Settings", "");
-
+
prop = RNA_def_property(srna, "smoke_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, prop_smoke_type_items);
@@ -2958,16 +2959,16 @@ static void rna_def_modifier_dynamic_paint(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "DynamicPaintModifier", "Modifier");
RNA_def_struct_ui_text(srna, "Dynamic Paint Modifier", "Dynamic Paint modifier");
RNA_def_struct_sdna(srna, "DynamicPaintModifierData");
RNA_def_struct_ui_icon(srna, ICON_MOD_DYNAMICPAINT);
-
+
prop = RNA_def_property(srna, "canvas_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "canvas");
RNA_def_property_ui_text(prop, "Canvas Settings", "");
-
+
prop = RNA_def_property(srna, "brush_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "brush");
RNA_def_property_ui_text(prop, "Brush Settings", "");
@@ -3147,7 +3148,7 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna)
"Shrink the mesh to the nearest target vertex"},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem shrink_face_cull_items[] = {
{0, "OFF", 0, "Off", "No culling"},
{MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE, "FRONT", 0, "Front", "No projection when in front of the face"},
@@ -3223,7 +3224,7 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "projAxis", MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS);
RNA_def_property_ui_text(prop, "Z", "");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "subsurf_levels", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "subsurfLevels");
RNA_def_property_range(prop, 0, 6);
@@ -4066,7 +4067,7 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem geometry_items[] = {
{MOD_OCEAN_GEOM_GENERATE, "GENERATE", 0, "Generate",
"Generate ocean surface geometry at the specified resolution"},
@@ -4077,24 +4078,24 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
#endif
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "OceanModifier", "Modifier");
RNA_def_struct_ui_text(srna, "Ocean Modifier", "Simulate an ocean surface");
RNA_def_struct_sdna(srna, "OceanModifierData");
RNA_def_struct_ui_icon(srna, ICON_MOD_OCEAN);
-
+
prop = RNA_def_property(srna, "geometry_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "geometry_mode");
RNA_def_property_enum_items(prop, geometry_items);
RNA_def_property_ui_text(prop, "Geometry", "Method of modifying geometry");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_sdna(prop, NULL, "size");
RNA_def_property_ui_text(prop, "Size", "Surface scale factor (does not affect the height of the waves)");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, -1);
RNA_def_property_update(prop, 0, "rna_OceanModifier_topology_update");
-
+
prop = RNA_def_property(srna, "repeat_x", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "repeat_x");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -4102,7 +4103,7 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 1, 100, 1, -1);
RNA_def_property_ui_text(prop, "Repeat X", "Repetitions of the generated surface in X");
RNA_def_property_update(prop, 0, "rna_OceanModifier_topology_update");
-
+
prop = RNA_def_property(srna, "repeat_y", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "repeat_y");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -4117,13 +4118,13 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Generate Normals",
"Output normals for bump mapping - disabling can speed up performance if its not needed");
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
-
+
prop = RNA_def_property(srna, "use_foam", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_OCEAN_GENERATE_FOAM);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Generate Foam", "Generate foam mask as a vertex color channel");
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
-
+
prop = RNA_def_property(srna, "resolution", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "resolution");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -4131,7 +4132,7 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 1, 32, 1, -1);
RNA_def_property_ui_text(prop, "Resolution", "Resolution of the generated surface");
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
-
+
prop = RNA_def_property(srna, "spatial_size", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "spatial_size");
RNA_def_property_ui_range(prop, 1, 512, 2, -1);
@@ -4139,66 +4140,66 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Spatial Size",
"Size of the simulation domain (in meters), and of the generated geometry (in BU)");
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
-
+
prop = RNA_def_property(srna, "wind_velocity", PROP_FLOAT, PROP_VELOCITY);
RNA_def_property_float_sdna(prop, NULL, "wind_velocity");
RNA_def_property_ui_text(prop, "Wind Velocity", "Wind speed");
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
-
+
prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "damp");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Damping", "Damp reflected waves going in opposite direction to the wind");
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
-
+
prop = RNA_def_property(srna, "wave_scale_min", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "smallest_wave");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.0, FLT_MAX);
RNA_def_property_ui_text(prop, "Smallest Wave", "Shortest allowed wavelength");
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
-
+
prop = RNA_def_property(srna, "wave_alignment", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_sdna(prop, NULL, "wave_alignment");
RNA_def_property_range(prop, 0.0, 10.0);
RNA_def_property_ui_text(prop, "Wave Alignment", "How much the waves are aligned to each other");
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
-
+
prop = RNA_def_property(srna, "wave_direction", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "wave_direction");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Wave Direction", "Main direction of the waves when they are (partially) aligned");
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
-
+
prop = RNA_def_property(srna, "wave_scale", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_sdna(prop, NULL, "wave_scale");
RNA_def_property_ui_text(prop, "Wave Scale", "Scale of the displacement effect");
RNA_def_property_update(prop, 0, "rna_OceanModifier_sim_update");
-
+
prop = RNA_def_property(srna, "depth", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "depth");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Depth", "Depth of the solid ground below the water surface");
RNA_def_property_ui_range(prop, 0, 250, 1, -1);
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
-
+
prop = RNA_def_property(srna, "foam_coverage", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "foam_coverage");
RNA_def_property_ui_text(prop, "Foam Coverage", "Amount of generated foam");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "bake_foam_fade", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_sdna(prop, NULL, "foam_fade");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Foam Fade", "How much foam accumulates over time (baked ocean only)");
RNA_def_property_ui_range(prop, 0.0, 10.0, 1, -1);
RNA_def_property_update(prop, 0, NULL);
-
+
prop = RNA_def_property(srna, "foam_layer_name", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "foamlayername");
RNA_def_property_ui_text(prop, "Foam Layer Name", "Name of the vertex color layer used for foam");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "choppiness", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_sdna(prop, NULL, "chop_amount");
RNA_def_property_ui_text(prop, "Choppiness",
@@ -4206,31 +4207,31 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.0, 4.0, 3, -1);
RNA_def_property_float_funcs(prop, NULL, "rna_OceanModifier_ocean_chop_set", NULL);
RNA_def_property_update(prop, 0, "rna_OceanModifier_sim_update");
-
+
prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_sdna(prop, NULL, "time");
RNA_def_property_ui_text(prop, "Time", "Current time of the simulation");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, -1);
RNA_def_property_update(prop, 0, "rna_OceanModifier_sim_update");
-
+
prop = RNA_def_property(srna, "random_seed", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "seed");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Random Seed", "Seed of the random generator");
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
-
+
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "bakestart");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Bake Start", "Start frame of the ocean baking");
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
-
+
prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "bakeend");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Bake End", "End frame of the ocean baking");
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
-
+
prop = RNA_def_property(srna, "is_cached", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cached", 1);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -4989,58 +4990,59 @@ void RNA_def_modifier(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
/* data */
srna = RNA_def_struct(brna, "Modifier", NULL);
RNA_def_struct_ui_text(srna, "Modifier", "Modifier affecting the geometry data of an object");
RNA_def_struct_refine_func(srna, "rna_Modifier_refine");
RNA_def_struct_path_func(srna, "rna_Modifier_path");
RNA_def_struct_sdna(srna, "ModifierData");
-
+
/* strings */
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Modifier_name_set");
RNA_def_property_ui_text(prop, "Name", "Modifier name");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER | NA_RENAME, NULL);
RNA_def_struct_name_property(srna, prop);
-
+
/* enums */
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, rna_enum_object_modifier_type_items);
RNA_def_property_ui_text(prop, "Type", "");
-
+
/* flags */
prop = RNA_def_property(srna, "show_viewport", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Realtime);
RNA_def_property_ui_text(prop, "Realtime", "Display modifier in viewport");
- RNA_def_property_flag(prop, PROP_LIB_EXCEPTION | PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_update(prop, 0, "rna_Modifier_update");
RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 0);
-
+
prop = RNA_def_property(srna, "show_render", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Render);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Render", "Use modifier during render");
RNA_def_property_ui_icon(prop, ICON_SCENE, 0);
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
-
+
prop = RNA_def_property(srna, "show_in_editmode", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Editmode);
RNA_def_property_ui_text(prop, "Edit Mode", "Display modifier in Edit mode");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0);
-
+
prop = RNA_def_property(srna, "show_on_cage", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_OnCage);
RNA_def_property_ui_text(prop, "On Cage", "Adjust edit cage to modifier result");
RNA_def_property_ui_icon(prop, ICON_MESH_DATA, 0);
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Expanded);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Expanded", "Set modifier expanded in the user interface");
RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c
index c663119eb42..aa976775ad1 100644
--- a/source/blender/makesrna/intern/rna_movieclip.c
+++ b/source/blender/makesrna/intern/rna_movieclip.c
@@ -56,11 +56,11 @@
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
-static void rna_MovieClip_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_MovieClip_reload_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
MovieClip *clip = (MovieClip *)ptr->id.data;
- BKE_movieclip_reload(clip);
+ BKE_movieclip_reload(bmain, clip);
DEG_id_tag_update(&clip->id, 0);
}
diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c
index 1301762a4bc..404d9089cd9 100644
--- a/source/blender/makesrna/intern/rna_nla.c
+++ b/source/blender/makesrna/intern/rna_nla.c
@@ -63,10 +63,10 @@
static void rna_NlaStrip_name_set(PointerRNA *ptr, const char *value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
-
+
/* copy the name first */
BLI_strncpy_utf8(data->name, value, sizeof(data->name));
-
+
/* validate if there's enough info to do so */
if (ptr->id.data) {
AnimData *adt = BKE_animdata_from_id(ptr->id.data);
@@ -78,12 +78,12 @@ static char *rna_NlaStrip_path(PointerRNA *ptr)
{
NlaStrip *strip = (NlaStrip *)ptr->data;
AnimData *adt = BKE_animdata_from_id(ptr->id.data);
-
+
/* if we're attached to AnimData, try to resolve path back to AnimData */
if (adt) {
NlaTrack *nlt;
NlaStrip *nls;
-
+
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (nls = nlt->strips.first; nls; nls = nls->next) {
if (nls == strip) {
@@ -99,7 +99,7 @@ static char *rna_NlaStrip_path(PointerRNA *ptr)
}
}
}
-
+
/* no path */
return BLI_strdup("");
}
@@ -133,7 +133,7 @@ static void rna_NlaStrip_transform_update(Main *bmain, Scene *scene, PointerRNA
static void rna_NlaStrip_start_frame_set(PointerRNA *ptr, float value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
-
+
/* clamp value to lie within valid limits
* - cannot start past the end of the strip + some flexibility threshold
* - cannot start before the previous strip (if present) ends
@@ -144,7 +144,7 @@ static void rna_NlaStrip_start_frame_set(PointerRNA *ptr, float value)
if (data->prev) {
if (data->prev->type == NLASTRIP_TYPE_TRANSITION) {
CLAMP(value, data->prev->start + NLASTRIP_MIN_LEN_THRESH, data->end - NLASTRIP_MIN_LEN_THRESH);
-
+
/* re-adjust the transition to stick to the endpoints of the action-clips */
data->prev->end = value;
}
@@ -161,7 +161,7 @@ static void rna_NlaStrip_start_frame_set(PointerRNA *ptr, float value)
static void rna_NlaStrip_end_frame_set(PointerRNA *ptr, float value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
-
+
/* clamp value to lie within valid limits
* - must not have zero or negative length strip, so cannot start before the first frame
* + some minimum-strip-length threshold
@@ -172,7 +172,7 @@ static void rna_NlaStrip_end_frame_set(PointerRNA *ptr, float value)
if (data->next) {
if (data->next->type == NLASTRIP_TYPE_TRANSITION) {
CLAMP(value, data->start + NLASTRIP_MIN_LEN_THRESH, data->next->end - NLASTRIP_MIN_LEN_THRESH);
-
+
/* readjust the transition to stick to the endpoints of the action-clips */
data->next->start = value;
}
@@ -184,16 +184,16 @@ static void rna_NlaStrip_end_frame_set(PointerRNA *ptr, float value)
CLAMP(value, data->start + NLASTRIP_MIN_LEN_THRESH, MAXFRAME);
}
data->end = value;
-
-
+
+
/* calculate the lengths the strip and its action (if applicable) */
if (data->type == NLASTRIP_TYPE_CLIP) {
float len, actlen;
-
+
len = data->end - data->start;
actlen = data->actend - data->actstart;
if (IS_EQF(actlen, 0.0f)) actlen = 1.0f;
-
+
/* now, adjust the 'scale' setting to reflect this (so that this change can be valid) */
data->scale = len / ((actlen) * data->repeat);
}
@@ -202,12 +202,12 @@ static void rna_NlaStrip_end_frame_set(PointerRNA *ptr, float value)
static void rna_NlaStrip_scale_set(PointerRNA *ptr, float value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
-
+
/* set scale value */
/* NOTE: these need to be synced with the values in the property definition in rna_def_nlastrip() */
CLAMP(value, 0.0001f, 1000.0f);
data->scale = value;
-
+
/* adjust the strip extents in response to this */
BKE_nlastrip_recalculate_bounds(data);
}
@@ -215,12 +215,12 @@ static void rna_NlaStrip_scale_set(PointerRNA *ptr, float value)
static void rna_NlaStrip_repeat_set(PointerRNA *ptr, float value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
-
+
/* set repeat value */
/* NOTE: these need to be synced with the values in the property definition in rna_def_nlastrip() */
CLAMP(value, 0.01f, 1000.0f);
data->repeat = value;
-
+
/* adjust the strip extents in response to this */
BKE_nlastrip_recalculate_bounds(data);
}
@@ -229,11 +229,11 @@ static void rna_NlaStrip_blend_in_set(PointerRNA *ptr, float value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
float len;
-
+
/* blend-in is limited to the length of the strip, and also cannot overlap with blendout */
len = (data->end - data->start) - data->blendout;
CLAMP(value, 0, len);
-
+
data->blendin = value;
}
@@ -241,30 +241,30 @@ static void rna_NlaStrip_blend_out_set(PointerRNA *ptr, float value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
float len;
-
+
/* blend-out is limited to the length of the strip */
len = (data->end - data->start);
CLAMP(value, 0, len);
-
+
/* it also cannot overlap with blendin */
if ((len - value) < data->blendin)
value = len - data->blendin;
-
+
data->blendout = value;
}
static void rna_NlaStrip_use_auto_blend_set(PointerRNA *ptr, int value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
-
+
if (value) {
/* set the flag */
data->flag |= NLASTRIP_FLAG_AUTO_BLENDS;
-
+
/* validate state to ensure that auto-blend gets applied immediately */
if (ptr->id.data) {
IdAdtTemplate *iat = (IdAdtTemplate *)ptr->id.data;
-
+
if (iat->adt) {
BKE_nla_validate_state(iat->adt);
}
@@ -273,7 +273,7 @@ static void rna_NlaStrip_use_auto_blend_set(PointerRNA *ptr, int value)
else {
/* clear the flag */
data->flag &= ~NLASTRIP_FLAG_AUTO_BLENDS;
-
+
/* clear the values too, so that it's clear that there has been an effect */
/* TODO: it's somewhat debatable whether it's better to leave these in instead... */
data->blendin = 0.0f;
@@ -284,22 +284,22 @@ static void rna_NlaStrip_use_auto_blend_set(PointerRNA *ptr, int value)
static int rna_NlaStrip_action_editable(PointerRNA *ptr, const char **UNUSED(r_info))
{
NlaStrip *strip = (NlaStrip *)ptr->data;
-
+
/* strip actions shouldn't be editable if NLA tweakmode is on */
if (ptr->id.data) {
AnimData *adt = BKE_animdata_from_id(ptr->id.data);
-
+
if (adt) {
/* active action is only editable when it is not a tweaking strip */
if ((adt->flag & ADT_NLA_EDIT_ON) || (adt->actstrip) || (adt->tmpact))
return 0;
}
}
-
+
/* check for clues that strip probably shouldn't be used... */
if (strip->flag & NLASTRIP_FLAG_TWEAKUSER)
return 0;
-
+
/* should be ok, though we may still miss some cases */
return PROP_EDITABLE;
}
@@ -307,11 +307,11 @@ static int rna_NlaStrip_action_editable(PointerRNA *ptr, const char **UNUSED(r_i
static void rna_NlaStrip_action_start_frame_set(PointerRNA *ptr, float value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
-
+
/* prevent start frame from occurring after end of action */
CLAMP(value, MINAFRAME, data->actend);
data->actstart = value;
-
+
/* adjust the strip extents in response to this */
/* TODO: should the strip be moved backwards instead as a special case? */
BKE_nlastrip_recalculate_bounds(data);
@@ -320,11 +320,11 @@ static void rna_NlaStrip_action_start_frame_set(PointerRNA *ptr, float value)
static void rna_NlaStrip_action_end_frame_set(PointerRNA *ptr, float value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
-
+
/* prevent end frame from starting before start of action */
CLAMP(value, data->actstart, MAXFRAME);
data->actend = value;
-
+
/* adjust the strip extents in response to this */
BKE_nlastrip_recalculate_bounds(data);
}
@@ -332,7 +332,7 @@ static void rna_NlaStrip_action_end_frame_set(PointerRNA *ptr, float value)
static void rna_NlaStrip_animated_influence_set(PointerRNA *ptr, int value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
-
+
if (value) {
/* set the flag, then make sure a curve for this exists */
data->flag |= NLASTRIP_FLAG_USR_INFLUENCE;
@@ -345,7 +345,7 @@ static void rna_NlaStrip_animated_influence_set(PointerRNA *ptr, int value)
static void rna_NlaStrip_animated_time_set(PointerRNA *ptr, int value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
-
+
if (value) {
/* set the flag, then make sure a curve for this exists */
data->flag |= NLASTRIP_FLAG_USR_TIME;
@@ -371,22 +371,22 @@ static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *repo
int start, bAction *action)
{
NlaStrip *strip = BKE_nlastrip_new(action);
-
+
if (strip == NULL) {
BKE_report(reports, RPT_ERROR, "Unable to create new strip");
return NULL;
}
-
+
strip->end += (start - strip->start);
strip->start = start;
-
+
if (BKE_nlastrips_add_strip(&track->strips, strip) == 0) {
BKE_report(reports, RPT_ERROR,
"Unable to add strip (the track does not have any space to accommodate this new strip)");
BKE_nlastrip_free(NULL, strip);
return NULL;
}
-
+
/* create dummy AnimData block so that BKE_nlastrip_validate_name()
* can be used to ensure a valid name, as we don't have one here...
* - only the nla_tracks list is needed there, which we aim to reverse engineer here...
@@ -394,25 +394,25 @@ static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *repo
{
AnimData adt = {NULL};
NlaTrack *nlt, *nlt_p;
-
+
/* 'first' NLA track is found by going back up chain of given track's parents until we fall off */
nlt_p = track; nlt = track;
while ((nlt = nlt->prev) != NULL)
nlt_p = nlt;
adt.nla_tracks.first = nlt_p;
-
+
/* do the same thing to find the last track */
nlt_p = track; nlt = track;
while ((nlt = nlt->next) != NULL)
nlt_p = nlt;
adt.nla_tracks.last = nlt_p;
-
+
/* now we can just auto-name as usual */
BKE_nlastrip_validate_name(&adt, strip);
}
-
+
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL);
-
+
return strip;
}
@@ -442,7 +442,7 @@ static void rna_NlaTrack_solo_set(PointerRNA *ptr, int value)
if (data == NULL) {
return;
}
-
+
/* firstly, make sure 'solo' flag for all tracks is disabled */
for (nt = data; nt; nt = nt->next) {
nt->flag &= ~NLATRACK_SOLO;
@@ -450,12 +450,12 @@ static void rna_NlaTrack_solo_set(PointerRNA *ptr, int value)
for (nt = data; nt; nt = nt->prev) {
nt->flag &= ~NLATRACK_SOLO;
}
-
+
/* now, enable 'solo' for the given track if appropriate */
if (value) {
/* set solo status */
data->flag |= NLATRACK_SOLO;
-
+
/* set solo-status on AnimData */
adt->flag |= ADT_NLA_SOLO_TRACK;
}
@@ -518,7 +518,7 @@ static void rna_def_nlastrip(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
/* enum defs */
static const EnumPropertyItem prop_type_items[] = {
{NLASTRIP_TYPE_CLIP, "CLIP", 0, "Action Clip", "NLA Strip references some Action"},
@@ -527,20 +527,20 @@ static void rna_def_nlastrip(BlenderRNA *brna)
{NLASTRIP_TYPE_SOUND, "SOUND", 0, "Sound Clip", "NLA Strip representing a sound event for speakers"},
{0, NULL, 0, NULL, NULL}
};
-
+
/* struct definition */
srna = RNA_def_struct(brna, "NlaStrip", NULL);
RNA_def_struct_ui_text(srna, "NLA Strip", "A container referencing an existing Action");
RNA_def_struct_path_func(srna, "rna_NlaStrip_path");
RNA_def_struct_ui_icon(srna, ICON_NLA); /* XXX */
-
+
/* name property */
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_NlaStrip_name_set");
RNA_def_struct_name_property(srna, prop);
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL); /* this will do? */
-
+
/* Enums */
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
@@ -548,19 +548,19 @@ static void rna_def_nlastrip(BlenderRNA *brna)
RNA_def_property_enum_items(prop, prop_type_items);
RNA_def_property_ui_text(prop, "Type", "Type of NLA Strip");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
-
+
prop = RNA_def_property(srna, "extrapolation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "extendmode");
RNA_def_property_enum_items(prop, rna_enum_nla_mode_extend_items);
RNA_def_property_ui_text(prop, "Extrapolation", "Action to take for gaps past the strip extents");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
-
+
prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "blendmode");
RNA_def_property_enum_items(prop, rna_enum_nla_mode_blend_items);
RNA_def_property_ui_text(prop, "Blending", "Method used for combining strip's result with accumulated result");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
-
+
/* Strip extents */
prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_TIME);
RNA_def_property_float_sdna(prop, NULL, "start");
@@ -573,20 +573,20 @@ static void rna_def_nlastrip(BlenderRNA *brna)
RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_end_frame_set", NULL);
RNA_def_property_ui_text(prop, "End Frame", "");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
-
+
/* Blending */
prop = RNA_def_property(srna, "blend_in", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "blendin");
RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_blend_in_set", NULL);
RNA_def_property_ui_text(prop, "Blend In", "Number of frames at start of strip to fade in influence");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
-
+
prop = RNA_def_property(srna, "blend_out", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "blendout");
RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_blend_out_set", NULL);
RNA_def_property_ui_text(prop, "Blend Out", "");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
-
+
prop = RNA_def_property(srna, "use_auto_blend", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_AUTO_BLENDS);
RNA_def_property_boolean_funcs(prop, NULL, "rna_NlaStrip_use_auto_blend_set");
@@ -594,7 +594,7 @@ static void rna_def_nlastrip(BlenderRNA *brna)
"Number of frames for Blending In/Out is automatically determined from "
"overlapping strips");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
-
+
/* Action */
prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "act");
@@ -603,20 +603,20 @@ static void rna_def_nlastrip(BlenderRNA *brna)
RNA_def_property_editable_func(prop, "rna_NlaStrip_action_editable");
RNA_def_property_ui_text(prop, "Action", "Action referenced by this strip");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
-
+
/* Action extents */
prop = RNA_def_property(srna, "action_frame_start", PROP_FLOAT, PROP_TIME);
RNA_def_property_float_sdna(prop, NULL, "actstart");
RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_action_start_frame_set", NULL);
RNA_def_property_ui_text(prop, "Action Start Frame", "First frame from action to use");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
-
+
prop = RNA_def_property(srna, "action_frame_end", PROP_FLOAT, PROP_TIME);
RNA_def_property_float_sdna(prop, NULL, "actend");
RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_action_end_frame_set", NULL);
RNA_def_property_ui_text(prop, "Action End Frame", "Last frame from action to use");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
-
+
/* Action Reuse */
prop = RNA_def_property(srna, "repeat", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "repeat");
@@ -626,7 +626,7 @@ static void rna_def_nlastrip(BlenderRNA *brna)
RNA_def_property_range(prop, 0.1f, 1000.0f);
RNA_def_property_ui_text(prop, "Repeat", "Number of times to repeat the action range");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
-
+
prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "scale");
RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_scale_set", NULL);
@@ -635,7 +635,7 @@ static void rna_def_nlastrip(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0001f, 1000.0f);
RNA_def_property_ui_text(prop, "Scale", "Scaling factor for action");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
-
+
/* Strip's F-Curves */
prop = RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fcurves", NULL);
@@ -647,29 +647,29 @@ static void rna_def_nlastrip(BlenderRNA *brna)
prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "FModifier");
RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting all the F-Curves in the referenced Action");
-
+
/* Strip's Sub-Strips (for Meta-Strips) */
prop = RNA_def_property(srna, "strips", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "NlaStrip");
RNA_def_property_ui_text(prop, "NLA Strips",
"NLA Strips that this strip acts as a container for (if it is of type Meta)");
-
+
/* Settings - Values necessary for evaluation */
- prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_NONE);
+ prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Influence", "Amount the strip contributes to the current result");
/* XXX: Update temporarily disabled so that the property can be edited at all!
* Even autokey only applies after the curves have been re-evaluated, causing the unkeyed values to be lost
*/
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, /*"rna_NlaStrip_update"*/ NULL);
-
+
prop = RNA_def_property(srna, "strip_time", PROP_FLOAT, PROP_TIME);
RNA_def_property_ui_text(prop, "Strip Time", "Frame of referenced Action to evaluate");
/* XXX: Update temporarily disabled so that the property can be edited at all!
* Even autokey only applies after the curves have been re-evaluated, causing the unkeyed values to be lost
*/
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, /*"rna_NlaStrip_update"*/ NULL);
-
+
/* TODO: should the animated_influence/time settings be animatable themselves? */
prop = RNA_def_property(srna, "use_animated_influence", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_USR_INFLUENCE);
@@ -677,19 +677,19 @@ static void rna_def_nlastrip(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Animated Influence",
"Influence setting is controlled by an F-Curve rather than automatically determined");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
-
+
prop = RNA_def_property(srna, "use_animated_time", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_USR_TIME);
RNA_def_property_boolean_funcs(prop, NULL, "rna_NlaStrip_animated_time_set");
RNA_def_property_ui_text(prop, "Animated Strip Time",
"Strip time is controlled by an F-Curve rather than automatically determined");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
-
+
prop = RNA_def_property(srna, "use_animated_time_cyclic", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_USR_TIME_CYCLIC);
RNA_def_property_ui_text(prop, "Cyclic Strip Time", "Cycle the animated time within the action start & end");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
-
+
/* settings */
prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
/* can be made editable by hooking it up to the necessary NLA API methods */
@@ -697,24 +697,24 @@ static void rna_def_nlastrip(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_ACTIVE);
RNA_def_property_ui_text(prop, "Active", "NLA Strip is active");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL); /* this will do? */
-
+
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_SELECT);
RNA_def_property_ui_text(prop, "Select", "NLA Strip is selected");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL); /* this will do? */
-
+
prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_MUTED);
RNA_def_property_ui_text(prop, "Muted", "NLA Strip is not evaluated");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
-
+
prop = RNA_def_property(srna, "use_reverse", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_REVERSE);
RNA_def_property_ui_text(prop, "Reversed",
"NLA Strip is played back in reverse order (only when timing is "
"automatically determined)");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
-
+
prop = RNA_def_property(srna, "use_sync_length", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_SYNC_LENGTH);
RNA_def_property_ui_text(prop, "Sync Action Length",
@@ -760,11 +760,11 @@ static void rna_def_nlatrack(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "NlaTrack", NULL);
RNA_def_struct_ui_text(srna, "NLA Track", "A animation layer containing Actions referenced as NLA strips");
RNA_def_struct_ui_icon(srna, ICON_NLA);
-
+
/* strips collection */
prop = RNA_def_property(srna, "strips", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "NlaStrip");
@@ -777,7 +777,7 @@ static void rna_def_nlatrack(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Name", "");
RNA_def_struct_name_property(srna, prop);
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL); /* this will do? */
-
+
/* settings */
prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
/* can be made editable by hooking it up to the necessary NLA API methods */
@@ -785,7 +785,7 @@ static void rna_def_nlatrack(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_ACTIVE);
RNA_def_property_ui_text(prop, "Active", "NLA Track is active");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL); /* this will do? */
-
+
prop = RNA_def_property(srna, "is_solo", PROP_BOOLEAN, PROP_NONE);
/* can be made editable by hooking it up to the necessary NLA API methods */
RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_SOLO);
@@ -799,7 +799,7 @@ static void rna_def_nlatrack(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_SELECTED);
RNA_def_property_ui_text(prop, "Select", "NLA Track is selected");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL); /* this will do? */
-
+
prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_MUTED);
RNA_def_property_ui_text(prop, "Muted", "NLA Track is not evaluated");
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index d2fb9d19acc..3790dffec3b 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -261,15 +261,15 @@ const EnumPropertyItem *rna_node_tree_type_itemf(void *data, int (*poll)(void *d
++i;
continue;
}
-
+
tmp.value = i;
tmp.identifier = nt->idname;
tmp.icon = nt->ui_icon;
tmp.name = nt->ui_name;
tmp.description = nt->ui_description;
-
+
RNA_enum_item_add(&item, &totitem, &tmp);
-
+
++i;
}
NODE_TREE_TYPES_END;
@@ -336,15 +336,15 @@ const EnumPropertyItem *rna_node_type_itemf(void *data, int (*poll)(void *data,
++i;
continue;
}
-
+
tmp.value = i;
tmp.identifier = ntype->idname;
tmp.icon = ntype->ui_icon;
tmp.name = ntype->ui_name;
tmp.description = ntype->ui_description;
-
+
RNA_enum_item_add(&item, &totitem, &tmp);
-
+
++i;
NODE_TYPES_END
@@ -412,16 +412,16 @@ const EnumPropertyItem *rna_node_socket_type_itemf(
++i;
continue;
}
-
+
srna = stype->ext_socket.srna;
tmp.value = i;
tmp.identifier = stype->idname;
tmp.icon = RNA_struct_ui_icon(srna);
tmp.name = RNA_struct_ui_name(srna);
tmp.description = RNA_struct_ui_description(srna);
-
+
RNA_enum_item_add(&item, &totitem, &tmp);
-
+
++i;
NODE_SOCKET_TYPES_END
@@ -525,7 +525,7 @@ static const EnumPropertyItem *rna_node_static_type_itemf(bContext *UNUSED(C), P
static StructRNA *rna_NodeTree_refine(struct PointerRNA *ptr)
{
bNodeTree *ntree = (bNodeTree *)ptr->data;
-
+
if (ntree->typeinfo->ext.srna)
return ntree->typeinfo->ext.srna;
else
@@ -590,7 +590,7 @@ static void rna_NodeTree_get_from_context(const bContext *C, bNodeTreeType *ntre
RNA_parameter_list_create(&list, &ptr, func);
RNA_parameter_set_lookup(&list, "context", &C);
ntreetype->ext.call((bContext *)C, &ptr, func, &list);
-
+
RNA_parameter_get_lookup(&list, "result_1", &ret1);
RNA_parameter_get_lookup(&list, "result_2", &ret2);
RNA_parameter_get_lookup(&list, "result_3", &ret3);
@@ -654,7 +654,7 @@ static StructRNA *rna_NodeTree_register(
nt->type = NTREE_CUSTOM;
- nt->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, nt->idname, &RNA_NodeTree);
+ nt->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, nt->idname, &RNA_NodeTree);
nt->ext.data = data;
nt->ext.call = call;
nt->ext.free = free;
@@ -671,7 +671,7 @@ static StructRNA *rna_NodeTree_register(
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
-
+
return nt->ext.srna;
}
@@ -680,7 +680,7 @@ static bool rna_NodeTree_check(bNodeTree *ntree, ReportList *reports)
if (!ntreeIsRegistered(ntree)) {
if (reports)
BKE_reportf(reports, RPT_ERROR, "Node tree '%s' has undefined type %s", ntree->id.name + 2, ntree->idname);
-
+
return false;
}
else
@@ -702,28 +702,28 @@ static bNode *rna_NodeTree_node_new(bNodeTree *ntree, bContext *C, ReportList *r
{
bNodeType *ntype;
bNode *node;
-
+
if (!rna_NodeTree_check(ntree, reports))
return NULL;
-
+
ntype = nodeTypeFind(type);
if (!ntype) {
BKE_reportf(reports, RPT_ERROR, "Node type %s undefined", type);
return NULL;
}
-
+
if (ntype->poll && !ntype->poll(ntype, ntree)) {
BKE_reportf(reports, RPT_ERROR, "Cannot add node of type %s to node tree '%s'", type, ntree->id.name + 2);
return NULL;
}
-
+
node = nodeAddNode(C, ntree, type);
BLI_assert(node && node->typeinfo);
-
+
if (ntree->type == NTREE_TEXTURE) {
ntreeTexCheckCyclics(ntree);
}
-
+
ntreeUpdateTree(CTX_data_main(C), ntree);
nodeUpdate(ntree, node);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
@@ -734,10 +734,10 @@ static bNode *rna_NodeTree_node_new(bNodeTree *ntree, bContext *C, ReportList *r
static void rna_NodeTree_node_remove(bNodeTree *ntree, Main *bmain, ReportList *reports, PointerRNA *node_ptr)
{
bNode *node = node_ptr->data;
-
+
if (!rna_NodeTree_check(ntree, reports))
return;
-
+
if (BLI_findindex(&ntree->nodes, node) == -1) {
BKE_reportf(reports, RPT_ERROR, "Unable to locate node '%s' in node tree", node->name);
return;
@@ -785,7 +785,7 @@ static void rna_NodeTree_active_node_set(PointerRNA *ptr, const PointerRNA value
{
bNodeTree *ntree = (bNodeTree *)ptr->data;
bNode *node = (bNode *)value.data;
-
+
if (node && BLI_findindex(&ntree->nodes, node) != -1)
nodeSetActive(ntree, node);
else
@@ -809,7 +809,7 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, Main *bmain, ReportLis
*/
if (!fromnode || !tonode)
return NULL;
-
+
if (&fromsock->in_out == &tosock->in_out) {
BKE_report(reports, RPT_ERROR, "Same input/output direction of sockets");
return NULL;
@@ -824,7 +824,7 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, Main *bmain, ReportLis
}
ret = nodeAddLink(ntree, fromnode, fromsock, tonode, tosock);
-
+
if (ret) {
/* not an issue from the UI, clear hidden from API to keep valid state. */
@@ -897,7 +897,7 @@ static void rna_NodeTree_active_input_set(PointerRNA *ptr, int value)
bNodeTree *ntree = (bNodeTree *)ptr->data;
bNodeSocket *gsock;
int index;
-
+
for (gsock = ntree->inputs.first, index = 0; gsock; gsock = gsock->next, ++index) {
if (index == value)
gsock->flag |= SELECT;
@@ -926,7 +926,7 @@ static void rna_NodeTree_active_output_set(PointerRNA *ptr, int value)
bNodeTree *ntree = (bNodeTree *)ptr->data;
bNodeSocket *gsock;
int index;
-
+
for (gsock = ntree->inputs.first; gsock; gsock = gsock->next) {
gsock->flag &= ~SELECT;
}
@@ -941,30 +941,30 @@ static void rna_NodeTree_active_output_set(PointerRNA *ptr, int value)
static bNodeSocket *rna_NodeTree_inputs_new(bNodeTree *ntree, Main *bmain, ReportList *reports, const char *type, const char *name)
{
bNodeSocket *sock;
-
+
if (!rna_NodeTree_check(ntree, reports))
return NULL;
-
+
sock = ntreeAddSocketInterface(ntree, SOCK_IN, type, name);
-
+
ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
-
+
return sock;
}
static bNodeSocket *rna_NodeTree_outputs_new(bNodeTree *ntree, Main *bmain, ReportList *reports, const char *type, const char *name)
{
bNodeSocket *sock;
-
+
if (!rna_NodeTree_check(ntree, reports))
return NULL;
-
+
sock = ntreeAddSocketInterface(ntree, SOCK_OUT, type, name);
-
+
ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
-
+
return sock;
}
@@ -972,13 +972,13 @@ static void rna_NodeTree_socket_remove(bNodeTree *ntree, Main *bmain, ReportList
{
if (!rna_NodeTree_check(ntree, reports))
return;
-
+
if (BLI_findindex(&ntree->inputs, sock) == -1 && BLI_findindex(&ntree->outputs, sock) == -1) {
BKE_reportf(reports, RPT_ERROR, "Unable to locate socket '%s' in node", sock->identifier);
}
else {
ntreeRemoveSocketInterface(ntree, sock);
-
+
ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
@@ -987,10 +987,10 @@ static void rna_NodeTree_socket_remove(bNodeTree *ntree, Main *bmain, ReportList
static void rna_NodeTree_inputs_clear(bNodeTree *ntree, Main *bmain, ReportList *reports)
{
bNodeSocket *sock, *nextsock;
-
+
if (!rna_NodeTree_check(ntree, reports))
return;
-
+
for (sock = ntree->inputs.first; sock; sock = nextsock) {
nextsock = sock->next;
ntreeRemoveSocketInterface(ntree, sock);
@@ -1003,10 +1003,10 @@ static void rna_NodeTree_inputs_clear(bNodeTree *ntree, Main *bmain, ReportList
static void rna_NodeTree_outputs_clear(bNodeTree *ntree, Main *bmain, ReportList *reports)
{
bNodeSocket *sock, *nextsock;
-
+
if (!rna_NodeTree_check(ntree, reports))
return;
-
+
for (sock = ntree->outputs.first; sock; sock = nextsock) {
nextsock = sock->next;
ntreeRemoveSocketInterface(ntree, sock);
@@ -1019,12 +1019,12 @@ static void rna_NodeTree_outputs_clear(bNodeTree *ntree, Main *bmain, ReportList
static void rna_NodeTree_inputs_move(bNodeTree *ntree, Main *bmain, int from_index, int to_index)
{
bNodeSocket *sock;
-
+
if (from_index == to_index)
return;
if (from_index < 0 || to_index < 0)
return;
-
+
sock = BLI_findlink(&ntree->inputs, from_index);
if (to_index < from_index) {
bNodeSocket *nextsock = BLI_findlink(&ntree->inputs, to_index);
@@ -1040,9 +1040,9 @@ static void rna_NodeTree_inputs_move(bNodeTree *ntree, Main *bmain, int from_ind
BLI_insertlinkafter(&ntree->inputs, prevsock, sock);
}
}
-
+
ntree->update |= NTREE_UPDATE_GROUP_IN;
-
+
ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
@@ -1050,12 +1050,12 @@ static void rna_NodeTree_inputs_move(bNodeTree *ntree, Main *bmain, int from_ind
static void rna_NodeTree_outputs_move(bNodeTree *ntree, Main *bmain, int from_index, int to_index)
{
bNodeSocket *sock;
-
+
if (from_index == to_index)
return;
if (from_index < 0 || to_index < 0)
return;
-
+
sock = BLI_findlink(&ntree->outputs, from_index);
if (to_index < from_index) {
bNodeSocket *nextsock = BLI_findlink(&ntree->outputs, to_index);
@@ -1071,9 +1071,9 @@ static void rna_NodeTree_outputs_move(bNodeTree *ntree, Main *bmain, int from_in
BLI_insertlinkafter(&ntree->outputs, prevsock, sock);
}
}
-
+
ntree->update |= NTREE_UPDATE_GROUP_OUT;
-
+
ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
@@ -1084,7 +1084,7 @@ static void rna_NodeTree_interface_update(bNodeTree *ntree, bContext *C)
ntree->update |= NTREE_UPDATE_GROUP;
ntreeUpdateTree(bmain, ntree);
-
+
ED_node_tag_update_nodetree(bmain, ntree, NULL);
}
@@ -1103,7 +1103,7 @@ static int rna_NodeLink_is_hidden_get(PointerRNA *ptr)
static StructRNA *rna_Node_refine(struct PointerRNA *ptr)
{
bNode *node = (bNode *)ptr->data;
-
+
if (node->typeinfo->ext.srna)
return node->typeinfo->ext.srna;
else
@@ -1412,7 +1412,7 @@ static bNodeType *rna_Node_register_base(Main *bmain, ReportList *reports, Struc
if (nt) {
rna_Node_unregister(bmain, nt->ext.srna);
}
-
+
/* create a new node type */
nt = MEM_callocN(sizeof(bNodeType), "node type");
memcpy(nt, &dummynt, sizeof(dummynt));
@@ -1447,7 +1447,7 @@ static bNodeType *rna_Node_register_base(Main *bmain, ReportList *reports, Struc
nt->draw_buttons = (have_function[7]) ? rna_Node_draw_buttons : NULL;
nt->draw_buttons_ex = (have_function[8]) ? rna_Node_draw_buttons_ext : NULL;
nt->labelfunc = (have_function[9]) ? rna_Node_draw_label : NULL;
-
+
/* sanitize size values in case not all have been registered */
if (nt->maxwidth < nt->minwidth)
nt->maxwidth = nt->minwidth;
@@ -1455,7 +1455,7 @@ static bNodeType *rna_Node_register_base(Main *bmain, ReportList *reports, Struc
nt->maxheight = nt->minheight;
CLAMP(nt->width, nt->minwidth, nt->maxwidth);
CLAMP(nt->height, nt->minheight, nt->maxheight);
-
+
return nt;
}
@@ -1467,12 +1467,12 @@ static StructRNA *rna_Node_register(
bNodeType *nt = rna_Node_register_base(bmain, reports, &RNA_Node, data, identifier, validate, call, free);
if (!nt)
return NULL;
-
+
nodeRegisterType(nt);
-
+
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
-
+
return nt->ext.srna;
}
@@ -1484,12 +1484,12 @@ static StructRNA *rna_ShaderNode_register(
bNodeType *nt = rna_Node_register_base(bmain, reports, &RNA_ShaderNode, data, identifier, validate, call, free);
if (!nt)
return NULL;
-
+
nodeRegisterType(nt);
-
+
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
-
+
return nt->ext.srna;
}
@@ -1501,12 +1501,12 @@ static StructRNA *rna_CompositorNode_register(
bNodeType *nt = rna_Node_register_base(bmain, reports, &RNA_CompositorNode, data, identifier, validate, call, free);
if (!nt)
return NULL;
-
+
nodeRegisterType(nt);
-
+
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
-
+
return nt->ext.srna;
}
@@ -1518,24 +1518,24 @@ static StructRNA *rna_TextureNode_register(
bNodeType *nt = rna_Node_register_base(bmain, reports, &RNA_TextureNode, data, identifier, validate, call, free);
if (!nt)
return NULL;
-
+
nodeRegisterType(nt);
-
+
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
-
+
return nt->ext.srna;
}
static IDProperty *rna_Node_idprops(PointerRNA *ptr, bool create)
{
bNode *node = ptr->data;
-
+
if (create && !node->prop) {
IDPropertyTemplate val = {0};
node->prop = IDP_New(IDP_GROUP, &val, "RNA_Node ID properties");
}
-
+
return node->prop;
}
@@ -1543,19 +1543,19 @@ static void rna_Node_parent_set(PointerRNA *ptr, PointerRNA value)
{
bNode *node = ptr->data;
bNode *parent = value.data;
-
+
if (parent) {
/* XXX only Frame node allowed for now,
* in the future should have a poll function or so to test possible attachment.
*/
if (parent->type != NODE_FRAME)
return;
-
+
/* make sure parent is not attached to the node */
if (nodeAttachNodeCheck(parent, node))
return;
}
-
+
nodeDetachNode(node);
if (parent) {
nodeAttachNode(node, parent);
@@ -1566,17 +1566,17 @@ static int rna_Node_parent_poll(PointerRNA *ptr, PointerRNA value)
{
bNode *node = ptr->data;
bNode *parent = value.data;
-
+
/* XXX only Frame node allowed for now,
* in the future should have a poll function or so to test possible attachment.
*/
if (parent->type != NODE_FRAME)
return false;
-
+
/* make sure parent is not attached to the node */
if (nodeAttachNodeCheck(parent, node))
return false;
-
+
return true;
}
@@ -1603,14 +1603,14 @@ static void rna_Node_name_set(PointerRNA *ptr, const char *value)
bNodeTree *ntree = (bNodeTree *)ptr->id.data;
bNode *node = (bNode *)ptr->data;
char oldname[sizeof(node->name)];
-
+
/* make a copy of the old name first */
BLI_strncpy(oldname, node->name, sizeof(node->name));
/* set new name */
BLI_strncpy_utf8(node->name, value, sizeof(node->name));
-
+
nodeUniqueName(ntree, node);
-
+
/* fix all the animation data which may link to this */
BKE_animdata_fix_paths_rename_all(NULL, "nodes", oldname, node->name);
}
@@ -1619,9 +1619,9 @@ static bNodeSocket *rna_Node_inputs_new(ID *id, bNode *node, Main *bmain, Report
{
bNodeTree *ntree = (bNodeTree *)id;
bNodeSocket *sock;
-
+
sock = nodeAddSocket(ntree, node, SOCK_IN, type, identifier, name);
-
+
if (sock == NULL) {
BKE_report(reports, RPT_ERROR, "Unable to create socket");
}
@@ -1629,7 +1629,7 @@ static bNodeSocket *rna_Node_inputs_new(ID *id, bNode *node, Main *bmain, Report
ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
-
+
return sock;
}
@@ -1637,9 +1637,9 @@ static bNodeSocket *rna_Node_outputs_new(ID *id, bNode *node, Main *bmain, Repor
{
bNodeTree *ntree = (bNodeTree *)id;
bNodeSocket *sock;
-
+
sock = nodeAddSocket(ntree, node, SOCK_OUT, type, identifier, name);
-
+
if (sock == NULL) {
BKE_report(reports, RPT_ERROR, "Unable to create socket");
}
@@ -1647,20 +1647,20 @@ static bNodeSocket *rna_Node_outputs_new(ID *id, bNode *node, Main *bmain, Repor
ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
-
+
return sock;
}
static void rna_Node_socket_remove(ID *id, bNode *node, Main *bmain, ReportList *reports, bNodeSocket *sock)
{
bNodeTree *ntree = (bNodeTree *)id;
-
+
if (BLI_findindex(&node->inputs, sock) == -1 && BLI_findindex(&node->outputs, sock) == -1) {
BKE_reportf(reports, RPT_ERROR, "Unable to locate socket '%s' in node", sock->identifier);
}
else {
nodeRemoveSocket(ntree, node, sock);
-
+
ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
@@ -1670,7 +1670,7 @@ static void rna_Node_inputs_clear(ID *id, bNode *node, Main *bmain)
{
bNodeTree *ntree = (bNodeTree *)id;
bNodeSocket *sock, *nextsock;
-
+
for (sock = node->inputs.first; sock; sock = nextsock) {
nextsock = sock->next;
nodeRemoveSocket(ntree, node, sock);
@@ -1684,7 +1684,7 @@ static void rna_Node_outputs_clear(ID *id, bNode *node, Main *bmain)
{
bNodeTree *ntree = (bNodeTree *)id;
bNodeSocket *sock, *nextsock;
-
+
for (sock = node->outputs.first; sock; sock = nextsock) {
nextsock = sock->next;
nodeRemoveSocket(ntree, node, sock);
@@ -1698,12 +1698,12 @@ static void rna_Node_inputs_move(ID *id, bNode *node, Main *bmain, int from_inde
{
bNodeTree *ntree = (bNodeTree *)id;
bNodeSocket *sock;
-
+
if (from_index == to_index)
return;
if (from_index < 0 || to_index < 0)
return;
-
+
sock = BLI_findlink(&node->inputs, from_index);
if (to_index < from_index) {
bNodeSocket *nextsock = BLI_findlink(&node->inputs, to_index);
@@ -1719,7 +1719,7 @@ static void rna_Node_inputs_move(ID *id, bNode *node, Main *bmain, int from_inde
BLI_insertlinkafter(&node->inputs, prevsock, sock);
}
}
-
+
ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
@@ -1728,12 +1728,12 @@ static void rna_Node_outputs_move(ID *id, bNode *node, Main *bmain, int from_ind
{
bNodeTree *ntree = (bNodeTree *)id;
bNodeSocket *sock;
-
+
if (from_index == to_index)
return;
if (from_index < 0 || to_index < 0)
return;
-
+
sock = BLI_findlink(&node->outputs, from_index);
if (to_index < from_index) {
bNodeSocket *nextsock = BLI_findlink(&node->outputs, to_index);
@@ -1749,7 +1749,7 @@ static void rna_Node_outputs_move(ID *id, bNode *node, Main *bmain, int from_ind
BLI_insertlinkafter(&node->outputs, prevsock, sock);
}
}
-
+
ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
@@ -1825,7 +1825,7 @@ static void rna_NodeSocket_unregister(Main *UNUSED(bmain), StructRNA *type)
bNodeSocketType *st = RNA_struct_blender_type_get(type);
if (!st)
return;
-
+
RNA_struct_free_extension(type, &st->ext_socket);
RNA_struct_free(&BLENDER_RNA, type);
@@ -1847,7 +1847,7 @@ static StructRNA *rna_NodeSocket_register(
/* setup dummy socket & socket type to store static properties in */
memset(&dummyst, 0, sizeof(bNodeSocketType));
-
+
memset(&dummysock, 0, sizeof(bNodeSocket));
dummysock.typeinfo = &dummyst;
RNA_pointer_create(NULL, &RNA_NodeSocket, &dummysock, &dummyptr);
@@ -1855,7 +1855,7 @@ static StructRNA *rna_NodeSocket_register(
/* validate the python class */
if (validate(&dummyptr, data, have_function) != 0)
return NULL;
-
+
if (strlen(identifier) >= sizeof(dummyst.idname)) {
BKE_reportf(reports, RPT_ERROR, "Registering node socket class: '%s' is too long, maximum length is %d",
identifier, (int)sizeof(dummyst.idname));
@@ -1868,22 +1868,22 @@ static StructRNA *rna_NodeSocket_register(
/* create a new node socket type */
st = MEM_callocN(sizeof(bNodeSocketType), "node socket type");
memcpy(st, &dummyst, sizeof(dummyst));
-
+
nodeRegisterSocketType(st);
}
-
+
/* if RNA type is already registered, unregister first */
if (st->ext_socket.srna) {
StructRNA *srna = st->ext_socket.srna;
RNA_struct_free_extension(srna, &st->ext_socket);
RNA_struct_free(&BLENDER_RNA, srna);
}
- st->ext_socket.srna = RNA_def_struct_ptr(&BLENDER_RNA, st->idname, &RNA_NodeSocket);
+ st->ext_socket.srna = RNA_def_struct_ptr(&BLENDER_RNA, st->idname, &RNA_NodeSocket);
st->ext_socket.data = data;
st->ext_socket.call = call;
st->ext_socket.free = free;
RNA_struct_blender_type_set(st->ext_socket.srna, st);
-
+
/* XXX bad level call! needed to initialize the basic draw functions ... */
ED_init_custom_node_socket_type(st);
@@ -1892,14 +1892,14 @@ static StructRNA *rna_NodeSocket_register(
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
-
+
return st->ext_socket.srna;
}
static StructRNA *rna_NodeSocket_refine(PointerRNA *ptr)
{
bNodeSocket *sock = (bNodeSocket *)ptr->data;
-
+
if (sock->typeinfo->ext_socket.srna)
return sock->typeinfo->ext_socket.srna;
else
@@ -1913,10 +1913,10 @@ static char *rna_NodeSocket_path(PointerRNA *ptr)
bNode *node;
int socketindex;
char name_esc[sizeof(node->name) * 2];
-
+
if (!nodeFindNode(ntree, sock, &node, &socketindex))
return NULL;
-
+
BLI_strescape(name_esc, node->name, sizeof(name_esc));
if (sock->in_out == SOCK_IN) {
@@ -1930,12 +1930,12 @@ static char *rna_NodeSocket_path(PointerRNA *ptr)
static IDProperty *rna_NodeSocket_idprops(PointerRNA *ptr, bool create)
{
bNodeSocket *sock = ptr->data;
-
+
if (create && !sock->prop) {
IDPropertyTemplate val = {0};
sock->prop = IDP_New(IDP_GROUP, &val, "RNA_NodeSocket ID properties");
}
-
+
return sock->prop;
}
@@ -1945,9 +1945,9 @@ static PointerRNA rna_NodeSocket_node_get(PointerRNA *ptr)
bNodeSocket *sock = (bNodeSocket *)ptr->data;
bNode *node;
PointerRNA r_ptr;
-
+
nodeFindNode(ntree, sock, &node, NULL);
-
+
RNA_pointer_create((ID *)ntree, &RNA_Node, node, &r_ptr);
return r_ptr;
}
@@ -1977,11 +1977,11 @@ static void rna_NodeSocket_link_limit_set(PointerRNA *ptr, int value)
static void rna_NodeSocket_hide_set(PointerRNA *ptr, int value)
{
bNodeSocket *sock = (bNodeSocket *)ptr->data;
-
+
/* don't hide linked sockets */
if (sock->flag & SOCK_IN_USE)
return;
-
+
if (value)
sock->flag |= SOCK_HIDDEN;
else
@@ -2109,11 +2109,11 @@ static void rna_NodeSocketInterface_unregister(Main *UNUSED(bmain), StructRNA *t
bNodeSocketType *st = RNA_struct_blender_type_get(type);
if (!st)
return;
-
+
RNA_struct_free_extension(type, &st->ext_interface);
-
+
RNA_struct_free(&BLENDER_RNA, type);
-
+
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
}
@@ -2129,7 +2129,7 @@ static StructRNA *rna_NodeSocketInterface_register(
/* setup dummy socket & socket type to store static properties in */
memset(&dummyst, 0, sizeof(bNodeSocketType));
-
+
memset(&dummysock, 0, sizeof(bNodeSocket));
dummysock.typeinfo = &dummyst;
RNA_pointer_create(NULL, &RNA_NodeSocketInterface, &dummysock, &dummyptr);
@@ -2147,38 +2147,38 @@ static StructRNA *rna_NodeSocketInterface_register(
/* create a new node socket type */
st = MEM_callocN(sizeof(bNodeSocketType), "node socket type");
memcpy(st, &dummyst, sizeof(dummyst));
-
+
nodeRegisterSocketType(st);
}
-
+
/* if RNA type is already registered, unregister first */
if (st->ext_interface.srna) {
StructRNA *srna = st->ext_interface.srna;
RNA_struct_free_extension(srna, &st->ext_interface);
RNA_struct_free(&BLENDER_RNA, srna);
}
- st->ext_interface.srna = RNA_def_struct_ptr(&BLENDER_RNA, identifier, &RNA_NodeSocketInterface);
+ st->ext_interface.srna = RNA_def_struct_ptr(&BLENDER_RNA, identifier, &RNA_NodeSocketInterface);
st->ext_interface.data = data;
st->ext_interface.call = call;
st->ext_interface.free = free;
RNA_struct_blender_type_set(st->ext_interface.srna, st);
-
+
st->interface_draw = (have_function[0]) ? rna_NodeSocketInterface_draw : NULL;
st->interface_draw_color = (have_function[1]) ? rna_NodeSocketInterface_draw_color : NULL;
st->interface_register_properties = (have_function[2]) ? rna_NodeSocketInterface_register_properties : NULL;
st->interface_init_socket = (have_function[3]) ? rna_NodeSocketInterface_init_socket : NULL;
st->interface_from_socket = (have_function[4]) ? rna_NodeSocketInterface_from_socket : NULL;
-
+
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
-
+
return st->ext_interface.srna;
}
static StructRNA *rna_NodeSocketInterface_refine(PointerRNA *ptr)
{
bNodeSocket *sock = (bNodeSocket *)ptr->data;
-
+
if (sock->typeinfo && sock->typeinfo->ext_interface.srna)
return sock->typeinfo->ext_interface.srna;
else
@@ -2190,27 +2190,27 @@ static char *rna_NodeSocketInterface_path(PointerRNA *ptr)
bNodeTree *ntree = (bNodeTree *)ptr->id.data;
bNodeSocket *sock = (bNodeSocket *)ptr->data;
int socketindex;
-
+
socketindex = BLI_findindex(&ntree->inputs, sock);
if (socketindex != -1)
return BLI_sprintfN("inputs[%d]", socketindex);
-
+
socketindex = BLI_findindex(&ntree->outputs, sock);
if (socketindex != -1)
return BLI_sprintfN("outputs[%d]", socketindex);
-
+
return NULL;
}
static IDProperty *rna_NodeSocketInterface_idprops(PointerRNA *ptr, bool create)
{
bNodeSocket *sock = ptr->data;
-
+
if (create && !sock->prop) {
IDPropertyTemplate val = {0};
sock->prop = IDP_New(IDP_GROUP, &val, "RNA_NodeSocketInterface ID properties");
}
-
+
return sock->prop;
}
@@ -2218,13 +2218,13 @@ static void rna_NodeSocketInterface_update(Main *bmain, Scene *UNUSED(scene), Po
{
bNodeTree *ntree = ptr->id.data;
bNodeSocket *stemp = ptr->data;
-
+
if (!stemp->typeinfo)
return;
-
+
ntree->update |= NTREE_UPDATE_GROUP;
ntreeUpdateTree(bmain, ntree);
-
+
ED_node_tag_update_nodetree(bmain, ntree, NULL);
}
@@ -2265,11 +2265,11 @@ static void rna_NodeSocketStandard_float_range(PointerRNA *ptr, float *min, floa
bNodeSocket *sock = ptr->data;
bNodeSocketValueFloat *dval = sock->default_value;
int subtype = sock->typeinfo->subtype;
-
+
if (dval->max < dval->min) {
dval->max = dval->min;
}
-
+
*min = (subtype == PROP_UNSIGNED ? 0.0f : -FLT_MAX);
*max = FLT_MAX;
*softmin = dval->min;
@@ -2281,11 +2281,11 @@ static void rna_NodeSocketStandard_int_range(PointerRNA *ptr, int *min, int *max
bNodeSocket *sock = ptr->data;
bNodeSocketValueInt *dval = sock->default_value;
int subtype = sock->typeinfo->subtype;
-
+
if (dval->max < dval->min) {
dval->max = dval->min;
}
-
+
*min = (subtype == PROP_UNSIGNED ? 0 : INT_MIN);
*max = INT_MAX;
*softmin = dval->min;
@@ -2296,49 +2296,31 @@ static void rna_NodeSocketStandard_vector_range(PointerRNA *ptr, float *min, flo
{
bNodeSocket *sock = ptr->data;
bNodeSocketValueVector *dval = sock->default_value;
-
+
if (dval->max < dval->min) {
dval->max = dval->min;
}
-
+
*min = -FLT_MAX;
*max = FLT_MAX;
*softmin = dval->min;
*softmax = dval->max;
}
-static void rna_NodeSocket_value_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- bNodeTree *ntree = (bNodeTree *)ptr->id.data;
- bNodeSocket *sock = ptr->data;
-
- if (ntree->type == NTREE_SHADER) {
- DEG_id_tag_update_ex(bmain, &ntree->id, DEG_TAG_SHADING_UPDATE);
- WM_main_add_notifier(NC_MATERIAL | ND_SHADING, NULL);
-
- if (sock->type == SOCK_STRING) {
- rna_NodeSocket_update(bmain, scene, ptr);
- }
- }
- else {
- rna_NodeSocket_update(bmain, scene, ptr);
- }
-}
-
/* using a context update function here, to avoid searching the node if possible */
static void rna_NodeSocketStandard_value_update(struct bContext *C, PointerRNA *ptr)
{
bNode *node;
-
+
/* default update */
- rna_NodeSocket_value_update(CTX_data_main(C), CTX_data_scene(C), ptr);
-
+ rna_NodeSocket_update(CTX_data_main(C), CTX_data_scene(C), ptr);
+
/* try to use node from context, faster */
node = CTX_data_pointer_get(C, "node").data;
if (!node) {
bNodeTree *ntree = ptr->id.data;
bNodeSocket *sock = ptr->data;
-
+
/* fall back to searching node in the tree */
nodeFindNode(ntree, sock, &node, NULL);
}
@@ -2471,15 +2453,15 @@ static StructRNA *rna_NodeCustomGroup_register(
bNodeType *nt = rna_Node_register_base(bmain, reports, &RNA_NodeCustomGroup, data, identifier, validate, call, free);
if (!nt)
return NULL;
-
+
/* this updates the group node instance from the tree's interface */
nt->verifyfunc = node_group_verify;
-
+
nodeRegisterType(nt);
-
+
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
-
+
return nt->ext.srna;
}
@@ -2501,10 +2483,10 @@ static void rna_NodeGroup_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *
{
bNodeTree *ntree = (bNodeTree *)ptr->id.data;
bNode *node = (bNode *)ptr->data;
-
+
if (node->id)
ntreeUpdateTree(bmain, (bNodeTree *)node->id);
-
+
ED_node_tag_update_nodetree(bmain, ntree, node);
}
@@ -2513,13 +2495,13 @@ static void rna_NodeGroup_node_tree_set(PointerRNA *ptr, const PointerRNA value)
bNodeTree *ntree = ptr->id.data;
bNode *node = ptr->data;
bNodeTree *ngroup = value.data;
-
+
if (nodeGroupPoll(ntree, ngroup)) {
if (node->id)
id_us_min(node->id);
if (ngroup)
id_us_plus(&ngroup->id);
-
+
node->id = &ngroup->id;
}
}
@@ -2528,11 +2510,11 @@ static int rna_NodeGroup_node_tree_poll(PointerRNA *ptr, const PointerRNA value)
{
bNodeTree *ntree = ptr->id.data;
bNodeTree *ngroup = value.data;
-
+
/* only allow node trees of the same type as the group node's tree */
if (ngroup->type != ntree->type)
return false;
-
+
return nodeGroupPoll(ntree, ngroup);
}
@@ -2553,7 +2535,7 @@ static StructRNA *rna_NodeGroup_interface_typef(PointerRNA *ptr)
static StructRNA *rna_NodeGroupInputOutput_interface_typef(PointerRNA *ptr)
{
bNodeTree *ntree = ptr->id.data;
-
+
if (ntree) {
StructRNA *srna = ntreeInterfaceTypeGet(ntree, true);
if (srna)
@@ -2599,10 +2581,10 @@ static void rna_Matte_t1_set(PointerRNA *ptr, float value)
{
bNode *node = (bNode *)ptr->data;
NodeChroma *chroma = node->storage;
-
+
chroma->t1 = value;
-
- if (value < chroma->t2)
+
+ if (value < chroma->t2)
chroma->t2 = value;
}
@@ -2610,10 +2592,10 @@ static void rna_Matte_t2_set(PointerRNA *ptr, float value)
{
bNode *node = (bNode *)ptr->data;
NodeChroma *chroma = node->storage;
-
- if (value > chroma->t1)
+
+ if (value > chroma->t1)
value = chroma->t1;
-
+
chroma->t2 = value;
}
@@ -2636,10 +2618,10 @@ static void rna_Node_image_layer_update(Main *bmain, Scene *scene, PointerRNA *p
bNode *node = (bNode *)ptr->data;
Image *ima = (Image *)node->id;
ImageUser *iuser = node->storage;
-
+
BKE_image_multilayer_index(ima->rr, iuser);
- BKE_image_signal(ima, iuser, IMA_SIGNAL_SRC_CHANGE);
-
+ BKE_image_signal(bmain, ima, iuser, IMA_SIGNAL_SRC_CHANGE);
+
rna_Node_update(bmain, scene, ptr);
if (scene->nodetree != NULL) {
@@ -2794,7 +2776,7 @@ static const EnumPropertyItem *rna_Node_channel_itemf(bContext *UNUSED(C), Point
EnumPropertyItem *item = NULL;
EnumPropertyItem tmp = {0};
int totitem = 0;
-
+
switch (node->custom1) {
case CMP_NODE_CHANNEL_MATTE_CS_RGB:
tmp.identifier = "R"; tmp.name = "R"; tmp.value = 1;
@@ -2834,7 +2816,7 @@ static const EnumPropertyItem *rna_Node_channel_itemf(bContext *UNUSED(C), Point
RNA_enum_item_end(&item, &totitem);
*r_free = true;
-
+
return item;
}
@@ -2894,7 +2876,7 @@ static int rna_NodeOutputFileSocket_find_node(bNodeTree *ntree, NodeImageMultiFi
{
bNode *node;
bNodeSocket *sock;
-
+
for (node = ntree->nodes.first; node; node = node->next) {
for (sock = node->inputs.first; sock; sock = sock->next) {
NodeImageMultiFileSocket *sockdata = sock->storage;
@@ -2905,7 +2887,7 @@ static int rna_NodeOutputFileSocket_find_node(bNodeTree *ntree, NodeImageMultiFi
}
}
}
-
+
*nodep = NULL;
*sockp = NULL;
return 0;
@@ -2917,7 +2899,7 @@ static void rna_NodeOutputFileSlotFile_path_set(PointerRNA *ptr, const char *val
NodeImageMultiFileSocket *sockdata = ptr->data;
bNode *node;
bNodeSocket *sock;
-
+
if (rna_NodeOutputFileSocket_find_node(ntree, sockdata, &node, &sock)) {
ntreeCompositOutputFileSetPath(node, sock, value);
}
@@ -2929,7 +2911,7 @@ static void rna_NodeOutputFileSlotLayer_name_set(PointerRNA *ptr, const char *va
NodeImageMultiFileSocket *sockdata = ptr->data;
bNode *node;
bNodeSocket *sock;
-
+
if (rna_NodeOutputFileSocket_find_node(ntree, sockdata, &node, &sock)) {
ntreeCompositOutputFileSetLayer(node, sock, value);
}
@@ -2943,12 +2925,12 @@ static bNodeSocket *rna_NodeOutputFile_slots_new(ID *id, bNode *node, bContext *
bNodeSocket *sock;
if (scene)
im_format = &scene->r.im_format;
-
+
sock = ntreeCompositOutputFileAddSocket(ntree, node, name, im_format);
-
+
ntreeUpdateTree(CTX_data_main(C), ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
-
+
return sock;
}
@@ -2967,7 +2949,7 @@ static void rna_ShaderNodeTexIES_mode_set(PointerRNA *ptr, int value)
if (value == NODE_IES_EXTERNAL && text->name) {
BLI_strncpy(nss->filepath, text->name, sizeof(nss->filepath));
- BLI_path_rel(nss->filepath, G.main->name);
+ BLI_path_rel(nss->filepath, BKE_main_blendfile_path_from_global());
}
id_us_min(node->id);
@@ -2992,7 +2974,7 @@ static void rna_ShaderNodeScript_mode_set(PointerRNA *ptr, int value)
if (value == NODE_SCRIPT_EXTERNAL && text->name) {
BLI_strncpy(nss->filepath, text->name, sizeof(nss->filepath));
- BLI_path_rel(nss->filepath, G.main->name);
+ BLI_path_rel(nss->filepath, BKE_main_blendfile_path_from_global());
}
id_us_min(node->id);
@@ -3342,7 +3324,7 @@ static const EnumPropertyItem node_subsurface_method_items[] = {
static void def_group_input(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "interface", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_funcs(prop, NULL, NULL, "rna_NodeGroupInputOutput_interface_typef", NULL);
RNA_def_property_struct_type(prop, "PropertyGroup");
@@ -3353,13 +3335,13 @@ static void def_group_input(StructRNA *srna)
static void def_group_output(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "interface", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_funcs(prop, NULL, NULL, "rna_NodeGroupInputOutput_interface_typef", NULL);
RNA_def_property_struct_type(prop, "PropertyGroup");
RNA_def_property_flag(prop, PROP_IDPROPERTY);
RNA_def_property_ui_text(prop, "Interface", "Interface socket data");
-
+
prop = RNA_def_property(srna, "is_active_output", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_DO_OUTPUT);
RNA_def_property_ui_text(prop, "Active Output", "True if this node is used as the active group output");
@@ -3369,7 +3351,7 @@ static void def_group_output(StructRNA *srna)
static void def_group(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "id");
RNA_def_property_struct_type(prop, "NodeTree");
@@ -3388,7 +3370,7 @@ static void def_group(StructRNA *srna)
static void def_custom_group(BlenderRNA *brna)
{
StructRNA *srna;
-
+
srna = RNA_def_struct(brna, "NodeCustomGroup", "Node");
RNA_def_struct_ui_text(srna, "Custom Group", "Base node type for custom registered node group types");
RNA_def_struct_sdna(srna, "bNode");
@@ -3400,8 +3382,8 @@ static void def_custom_group(BlenderRNA *brna)
static void def_frame(StructRNA *srna)
{
- PropertyRNA *prop;
-
+ PropertyRNA *prop;
+
prop = RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "id");
RNA_def_property_struct_type(prop, "Text");
@@ -3411,7 +3393,7 @@ static void def_frame(StructRNA *srna)
RNA_def_struct_sdna_from(srna, "NodeFrame", "storage");
RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_ID_NODETREE);
-
+
prop = RNA_def_property(srna, "shrink", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_FRAME_SHRINK);
RNA_def_property_ui_text(prop, "Shrink", "Shrink the frame to minimal bounding box");
@@ -3427,7 +3409,7 @@ static void def_frame(StructRNA *srna)
static void def_math(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, rna_enum_node_math_items);
@@ -3443,7 +3425,7 @@ static void def_math(StructRNA *srna)
static void def_vector_math(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, rna_enum_node_vec_math_items);
@@ -3454,7 +3436,7 @@ static void def_vector_math(StructRNA *srna)
static void def_rgb_curve(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "mapping", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "storage");
RNA_def_property_struct_type(prop, "CurveMapping");
@@ -3465,7 +3447,7 @@ static void def_rgb_curve(StructRNA *srna)
static void def_vector_curve(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "mapping", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "storage");
RNA_def_property_struct_type(prop, "CurveMapping");
@@ -3476,18 +3458,18 @@ static void def_vector_curve(StructRNA *srna)
static void def_time(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "storage");
RNA_def_property_struct_type(prop, "CurveMapping");
RNA_def_property_ui_text(prop, "Curve", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "custom1");
RNA_def_property_ui_text(prop, "Start Frame", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "custom2");
RNA_def_property_ui_text(prop, "End Frame", "");
@@ -3497,7 +3479,7 @@ static void def_time(StructRNA *srna)
static void def_colorramp(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "color_ramp", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "storage");
RNA_def_property_struct_type(prop, "ColorRamp");
@@ -3508,13 +3490,13 @@ static void def_colorramp(StructRNA *srna)
static void def_mix_rgb(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, rna_enum_ramp_blend_items);
RNA_def_property_ui_text(prop, "Blend Type", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "custom2", SHD_MIXRGB_USE_ALPHA);
RNA_def_property_ui_text(prop, "Alpha", "Include alpha of second input in this operation");
@@ -3529,14 +3511,14 @@ static void def_mix_rgb(StructRNA *srna)
static void def_texture(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "id");
RNA_def_property_struct_type(prop, "Texture");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Texture", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "node_output", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "custom1");
RNA_def_property_ui_text(prop, "Node Output", "For node-based textures, which output node to use");
@@ -3549,7 +3531,7 @@ static void def_texture(StructRNA *srna)
static void def_sh_output(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "is_active_output", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_DO_OUTPUT);
RNA_def_property_ui_text(prop, "Active Output", "True if this node is used as the active output");
@@ -3575,7 +3557,7 @@ static void def_sh_mapping(StructRNA *srna)
static float default_1[3] = {1.f, 1.f, 1.f};
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "TexMapping", "storage");
prop = RNA_def_property(srna, "vector_type", PROP_ENUM, PROP_NONE);
@@ -3588,36 +3570,36 @@ static void def_sh_mapping(StructRNA *srna)
RNA_def_property_float_sdna(prop, NULL, "loc");
RNA_def_property_ui_text(prop, "Location", "");
RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
-
+
/* Not PROP_XYZ, this is now in radians, no more degrees */
prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER);
RNA_def_property_float_sdna(prop, NULL, "rot");
RNA_def_property_ui_text(prop, "Rotation", "");
RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
-
+
prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "size");
RNA_def_property_float_array_default(prop, default_1);
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
RNA_def_property_ui_text(prop, "Scale", "");
RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
-
+
prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "min");
RNA_def_property_ui_text(prop, "Minimum", "Minimum value for clipping");
RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
-
+
prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "max");
RNA_def_property_float_array_default(prop, default_1);
RNA_def_property_ui_text(prop, "Maximum", "Maximum value for clipping");
RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
-
+
prop = RNA_def_property(srna, "use_min", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MIN);
RNA_def_property_ui_text(prop, "Has Minimum", "Whether to use minimum clipping value");
RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
-
+
prop = RNA_def_property(srna, "use_max", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MAX);
RNA_def_property_ui_text(prop, "Has Maximum", "Whether to use maximum clipping value");
@@ -3627,9 +3609,9 @@ static void def_sh_mapping(StructRNA *srna)
static void def_sh_attribute(StructRNA *srna)
{
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeShaderAttribute", "storage");
-
+
prop = RNA_def_property(srna, "attribute_name", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "name");
RNA_def_property_ui_text(prop, "Attribute Name", "");
@@ -3659,9 +3641,9 @@ static void def_sh_tex_sky(StructRNA *srna)
{0, NULL, 0, NULL, NULL}
};
static float default_dir[3] = {0.0f, 0.0f, 1.0f};
-
+
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeTexSky", "storage");
def_sh_tex(srna);
@@ -3670,19 +3652,19 @@ static void def_sh_tex_sky(StructRNA *srna)
RNA_def_property_enum_items(prop, prop_sky_type);
RNA_def_property_ui_text(prop, "Sky Type", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "sun_direction", PROP_FLOAT, PROP_DIRECTION);
RNA_def_property_ui_text(prop, "Sun Direction", "Direction from where the sun is shining");
RNA_def_property_array(prop, 3);
RNA_def_property_float_array_default(prop, default_dir);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "turbidity", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 1.0f, 10.0f);
RNA_def_property_ui_range(prop, 1.0f, 10.0f, 10, 3);
RNA_def_property_ui_text(prop, "Turbidity", "Atmospheric turbidity");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "ground_albedo", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Ground Albedo", "Ground color that is subtly reflected in the sky");
@@ -3837,7 +3819,7 @@ static void def_sh_tex_gradient(StructRNA *srna)
};
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeTexGradient", "storage");
def_sh_tex(srna);
@@ -3862,44 +3844,44 @@ static void def_sh_tex_checker(StructRNA *srna)
static void def_sh_tex_brick(StructRNA *srna)
{
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeTexBrick", "storage");
def_sh_tex(srna);
-
+
prop = RNA_def_property(srna, "offset_frequency", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "offset_freq");
RNA_def_property_int_default(prop, 2);
RNA_def_property_range(prop, 1, 99);
RNA_def_property_ui_text(prop, "Offset Frequency", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "squash_frequency", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "squash_freq");
RNA_def_property_int_default(prop, 2);
RNA_def_property_range(prop, 1, 99);
RNA_def_property_ui_text(prop, "Squash Frequency", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "offset");
RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Offset Amount", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "squash", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "squash");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0.0f, 99.0f);
RNA_def_property_ui_text(prop, "Squash Amount", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
-
+
}
static void def_sh_tex_magic(StructRNA *srna)
{
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeTexMagic", "storage");
def_sh_tex(srna);
@@ -3922,7 +3904,7 @@ static void def_sh_tex_musgrave(StructRNA *srna)
};
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeTexMusgrave", "storage");
def_sh_tex(srna);
@@ -3942,7 +3924,7 @@ static void def_sh_tex_voronoi(StructRNA *srna)
};
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeTexVoronoi", "storage");
def_sh_tex(srna);
@@ -3968,7 +3950,7 @@ static void def_sh_tex_wave(StructRNA *srna)
};
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeTexWave", "storage");
def_sh_tex(srna);
@@ -4019,20 +4001,20 @@ static void def_sh_vect_transform(StructRNA *srna)
};
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeShaderVectTransform", "storage");
-
+
prop = RNA_def_property(srna, "vector_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, prop_vect_type_items);
RNA_def_property_ui_text(prop, "Type", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "convert_from", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_vect_space_items);
RNA_def_property_ui_text(prop, "Convert From", "Space to convert from");
RNA_def_property_update(prop, 0, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "convert_to", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_vect_space_items);
RNA_def_property_ui_text(prop, "Convert To", "Space to convert to");
@@ -4042,7 +4024,7 @@ static void def_sh_vect_transform(StructRNA *srna)
static void def_sh_tex_wireframe(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "use_pixel_size", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1);
RNA_def_property_ui_text(prop, "Pixel Size", "Use screen pixel size instead of world units");
@@ -4185,7 +4167,7 @@ static void def_sh_tex_pointdensity(StructRNA *srna)
static void def_glossy(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "distribution", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, node_glossy_items);
@@ -4196,7 +4178,7 @@ static void def_glossy(StructRNA *srna)
static void def_glass(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "distribution", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, node_glass_items);
@@ -4224,7 +4206,7 @@ static void def_principled(StructRNA *srna)
static void def_refraction(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "distribution", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, node_refraction_items);
@@ -4235,7 +4217,7 @@ static void def_refraction(StructRNA *srna)
static void def_anisotropic(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "distribution", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, node_anisotropic_items);
@@ -4246,7 +4228,7 @@ static void def_anisotropic(StructRNA *srna)
static void def_toon(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "component", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, node_toon_items);
@@ -4257,7 +4239,7 @@ static void def_toon(StructRNA *srna)
static void def_sh_bump(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1);
RNA_def_property_ui_text(prop, "Invert", "Invert the bump mapping direction to push into the surface instead of out");
@@ -4267,7 +4249,7 @@ static void def_sh_bump(StructRNA *srna)
static void def_hair(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "component", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, node_hair_items);
@@ -4427,7 +4409,7 @@ static void def_sh_subsurface(StructRNA *srna)
};
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "falloff", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, prop_subsurface_falloff_items);
@@ -4471,9 +4453,9 @@ static void def_sh_script(StructRNA *srna)
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
RNA_def_property_ui_text(prop, "Script", "Internal shader script to define the shader");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNodeScript_update");
-
+
RNA_def_struct_sdna_from(srna, "NodeShaderScript", "storage");
-
+
prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
RNA_def_property_ui_text(prop, "File Path", "Shader script path");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNodeScript_update");
@@ -4488,7 +4470,7 @@ static void def_sh_script(StructRNA *srna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_SCRIPT_AUTO_UPDATE);
RNA_def_property_ui_text(prop, "Auto Update",
"Automatically update the shader when the .osl file changes (external scripts only)");
-
+
prop = RNA_def_property(srna, "bytecode", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, "rna_ShaderNodeScript_bytecode_get", "rna_ShaderNodeScript_bytecode_length",
"rna_ShaderNodeScript_bytecode_set");
@@ -4501,7 +4483,7 @@ static void def_sh_script(StructRNA *srna)
/* needs to be reset to avoid bad pointer type in API functions below */
RNA_def_struct_sdna_from(srna, "bNode", NULL);
-
+
/* API functions */
#if 0 /* XXX TODO use general node api for this */
@@ -4512,7 +4494,7 @@ static void def_sh_script(StructRNA *srna)
/*parm =*/ RNA_def_boolean(func, "is_output", false, "Output", "Whether the socket is an output");
parm = RNA_def_pointer(func, "result", "NodeSocket", "", "");
RNA_def_function_return(func, parm);
-
+
func = RNA_def_function(srna, "add_socket", "rna_ShaderNodeScript_add_socket");
RNA_def_function_ui_description(func, "Add a socket socket");
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
@@ -4523,7 +4505,7 @@ static void def_sh_script(StructRNA *srna)
/*parm =*/ RNA_def_boolean(func, "is_output", false, "Output", "Whether the socket is an output");
parm = RNA_def_pointer(func, "result", "NodeSocket", "", "");
RNA_def_function_return(func, parm);
-
+
func = RNA_def_function(srna, "remove_socket", "rna_ShaderNodeScript_remove_socket");
RNA_def_function_ui_description(func, "Remove a socket socket");
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
@@ -4537,15 +4519,15 @@ static void def_sh_script(StructRNA *srna)
static void def_cmp_alpha_over(StructRNA *srna)
{
PropertyRNA *prop;
-
+
/* XXX: Tooltip */
prop = RNA_def_property(srna, "use_premultiply", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1);
RNA_def_property_ui_text(prop, "Convert Premul", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
RNA_def_struct_sdna_from(srna, "NodeTwoFloats", "storage");
-
+
prop = RNA_def_property(srna, "premul", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "x");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -4556,7 +4538,7 @@ static void def_cmp_alpha_over(StructRNA *srna)
static void def_cmp_blur(StructRNA *srna)
{
PropertyRNA *prop;
-
+
static const EnumPropertyItem filter_type_items[] = {
{R_FILTER_BOX, "FLAT", 0, "Flat", ""},
{R_FILTER_TENT, "TENT", 0, "Tent", ""},
@@ -4588,13 +4570,13 @@ static void def_cmp_blur(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
RNA_def_struct_sdna_from(srna, "NodeBlurData", "storage");
-
+
prop = RNA_def_property(srna, "size_x", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "sizex");
RNA_def_property_range(prop, 0, 2048);
RNA_def_property_ui_text(prop, "Size X", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "size_y", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "sizey");
RNA_def_property_range(prop, 0, 2048);
@@ -4605,7 +4587,7 @@ static void def_cmp_blur(StructRNA *srna)
RNA_def_property_boolean_sdna(prop, NULL, "relative", 1);
RNA_def_property_ui_text(prop, "Relative", "Use relative (percent) values to define blur radius");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "aspect_correction", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "aspect");
RNA_def_property_enum_items(prop, aspect_correction_type_items);
@@ -4617,30 +4599,30 @@ static void def_cmp_blur(StructRNA *srna)
RNA_def_property_range(prop, 0.0f, 2.0f);
RNA_def_property_ui_text(prop, "Factor", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "factor_x", PROP_FLOAT, PROP_PERCENTAGE);
RNA_def_property_float_sdna(prop, NULL, "percentx");
RNA_def_property_range(prop, 0.0f, 100.0f);
RNA_def_property_ui_text(prop, "Relative Size X", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "factor_y", PROP_FLOAT, PROP_PERCENTAGE);
RNA_def_property_float_sdna(prop, NULL, "percenty");
RNA_def_property_range(prop, 0.0f, 100.0f);
RNA_def_property_ui_text(prop, "Relative Size Y", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "filtertype");
RNA_def_property_enum_items(prop, filter_type_items);
RNA_def_property_ui_text(prop, "Filter Type", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "use_bokeh", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "bokeh", 1);
RNA_def_property_ui_text(prop, "Bokeh", "Use circular filter (slower)");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "use_gamma_correction", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gamma", 1);
RNA_def_property_ui_text(prop, "Gamma", "Apply filter on gamma corrected values");
@@ -4661,40 +4643,40 @@ static void def_cmp_filter(StructRNA *srna)
static void def_cmp_map_value(StructRNA *srna)
{
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "TexMapping", "storage");
-
+
prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "loc");
RNA_def_property_array(prop, 1);
RNA_def_property_range(prop, -1000.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Offset", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "size");
RNA_def_property_array(prop, 1);
RNA_def_property_range(prop, -1000.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Size", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "use_min", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MIN);
RNA_def_property_ui_text(prop, "Use Minimum", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "use_max", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MAX);
RNA_def_property_ui_text(prop, "Use Maximum", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "min");
RNA_def_property_array(prop, 1);
RNA_def_property_range(prop, -1000.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Minimum", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "max");
RNA_def_property_array(prop, 1);
@@ -4706,7 +4688,7 @@ static void def_cmp_map_value(StructRNA *srna)
static void def_cmp_map_range(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "use_clamp", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1);
RNA_def_property_ui_text(prop, "Clamp", "Clamp result of the node to 0..1 range");
@@ -4716,28 +4698,28 @@ static void def_cmp_map_range(StructRNA *srna)
static void def_cmp_vector_blur(StructRNA *srna)
{
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeBlurData", "storage");
-
+
prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "samples");
RNA_def_property_range(prop, 1, 256);
RNA_def_property_ui_text(prop, "Samples", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "speed_min", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "minspeed");
RNA_def_property_range(prop, 0, 1024);
RNA_def_property_ui_text(prop, "Min Speed",
"Minimum speed for a pixel to be blurred (used to separate background from foreground)");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "speed_max", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "maxspeed");
RNA_def_property_range(prop, 0, 1024);
RNA_def_property_ui_text(prop, "Max Speed", "Maximum speed, or zero for none");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "fac");
RNA_def_property_range(prop, 0.0, 20.0);
@@ -4745,7 +4727,7 @@ static void def_cmp_vector_blur(StructRNA *srna)
RNA_def_property_ui_text(prop, "Blur Factor",
"Scaling factor for motion vectors (actually, 'shutter speed', in frames)");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "use_curved", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "curved", 1);
RNA_def_property_ui_text(prop, "Curved", "Interpolate between frames in a Bezier curve, rather than linearly");
@@ -4755,7 +4737,7 @@ static void def_cmp_vector_blur(StructRNA *srna)
static void def_cmp_levels(StructRNA *srna)
{
PropertyRNA *prop;
-
+
static const EnumPropertyItem channel_items[] = {
{1, "COMBINED_RGB", 0, "C", "Combined RGB"},
{2, "RED", 0, "R", "Red Channel"},
@@ -4764,7 +4746,7 @@ static void def_cmp_levels(StructRNA *srna)
{5, "LUMINANCE", 0, "L", "Luminance Channel"},
{0, NULL, 0, NULL, NULL}
};
-
+
prop = RNA_def_property(srna, "channel", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, channel_items);
@@ -4781,7 +4763,7 @@ static void def_node_image_user(StructRNA *srna)
RNA_def_property_range(prop, 0, MAXFRAMEF);
RNA_def_property_ui_text(prop, "Frames", "Number of images of a movie to use"); /* copied from the rna_image.c */
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "sfra");
RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
@@ -4789,19 +4771,19 @@ static void def_node_image_user(StructRNA *srna)
RNA_def_property_ui_text(prop, "Start Frame",
"Global starting frame of the movie/sequence, assuming first picture has a #1");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "offset");
RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
/* copied from the rna_image.c */
RNA_def_property_ui_text(prop, "Offset", "Offset the number of the frame to use in the animation");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cycl", 1);
RNA_def_property_ui_text(prop, "Cyclic", "Cycle the images in the movie"); /* copied from the rna_image.c */
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "use_auto_refresh", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_ANIM_ALWAYS);
/* copied from the rna_image.c */
@@ -4838,7 +4820,7 @@ static void def_node_image_user(StructRNA *srna)
static void def_cmp_image(StructRNA *srna)
{
PropertyRNA *prop;
-
+
#if 0
static const EnumPropertyItem type_items[] = {
{IMA_SRC_FILE, "IMAGE", 0, "Image", ""},
@@ -4848,7 +4830,7 @@ static void def_cmp_image(StructRNA *srna)
{0, NULL, 0, NULL, NULL}
};
#endif
-
+
prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "id");
RNA_def_property_struct_type(prop, "Image");
@@ -4872,7 +4854,7 @@ static void def_cmp_image(StructRNA *srna)
static void def_cmp_render_layers(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "id");
RNA_def_property_pointer_funcs(prop, NULL, "rna_Node_scene_set", NULL, NULL);
@@ -4880,7 +4862,7 @@ static void def_cmp_render_layers(StructRNA *srna)
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
RNA_def_property_ui_text(prop, "Scene", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_view_layer_update");
-
+
prop = RNA_def_property(srna, "layer", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, prop_view_layer_items);
@@ -4894,19 +4876,19 @@ static void rna_def_cmp_output_file_slot_file(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "NodeOutputFileSlotFile", NULL);
RNA_def_struct_sdna(srna, "NodeImageMultiFileSocket");
RNA_def_struct_ui_text(srna, "Output File Slot", "Single layer file slot of the file output node");
-
+
prop = RNA_def_property(srna, "use_node_format", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "use_node_format", 1);
RNA_def_property_ui_text(prop, "Use Node Format", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, NULL);
-
+
prop = RNA_def_property(srna, "format", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "ImageFormatSettings");
-
+
prop = RNA_def_property(srna, "path", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "path");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_NodeOutputFileSlotFile_path_set");
@@ -4918,11 +4900,11 @@ static void rna_def_cmp_output_file_slot_layer(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "NodeOutputFileSlotLayer", NULL);
RNA_def_struct_sdna(srna, "NodeImageMultiFileSocket");
RNA_def_struct_ui_text(srna, "Output File Layer Slot", "Multilayer slot of the file output node");
-
+
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "layer");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_NodeOutputFileSlotLayer_name_set");
@@ -4975,33 +4957,33 @@ static void rna_def_cmp_output_file_slots_api(BlenderRNA *brna, PropertyRNA *cpr
static void def_cmp_output_file(BlenderRNA *brna, StructRNA *srna)
{
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeImageMultiFile", "storage");
-
+
prop = RNA_def_property(srna, "base_path", PROP_STRING, PROP_FILEPATH);
RNA_def_property_string_sdna(prop, NULL, "base_path");
RNA_def_property_ui_text(prop, "Base Path", "Base output path for the image");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "active_input_index", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "active_input");
RNA_def_property_ui_text(prop, "Active Input Index", "Active input index in details view list");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "format", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "ImageFormatSettings");
-
+
/* XXX using two different collections here for the same basic DNA list!
* Details of the output slots depend on whether the node is in Multilayer EXR mode.
*/
-
+
prop = RNA_def_property(srna, "file_slots", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_funcs(prop, "rna_NodeOutputFile_slots_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end",
"rna_NodeOutputFile_slot_file_get", NULL, NULL, NULL, NULL);
RNA_def_property_struct_type(prop, "NodeOutputFileSlotFile");
RNA_def_property_ui_text(prop, "File Slots", "");
rna_def_cmp_output_file_slots_api(brna, prop, "CompositorNodeOutputFileFileSlots");
-
+
prop = RNA_def_property(srna, "layer_slots", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_funcs(prop, "rna_NodeOutputFile_slots_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end",
"rna_NodeOutputFile_slot_layer_get", NULL, NULL, NULL, NULL);
@@ -5021,13 +5003,13 @@ static void def_cmp_dilate_erode(StructRNA *srna)
{CMP_NODE_DILATEERODE_DISTANCE_FEATHER, "FEATHER", 0, "Feather", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, mode_items);
RNA_def_property_ui_text(prop, "Mode", "Growing/shrinking mode");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "distance", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "custom2");
RNA_def_property_range(prop, -5000, 5000);
@@ -5065,7 +5047,7 @@ static void def_cmp_inpaint(StructRNA *srna)
RNA_def_property_ui_text(prop, "Type", "Type of inpaint algorithm");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
#endif
-
+
prop = RNA_def_property(srna, "distance", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "custom2");
RNA_def_property_range(prop, 1, 10000);
@@ -5101,7 +5083,7 @@ static void def_cmp_scale(StructRNA *srna)
{CMP_SCALE_RENDERPERCENT, "RENDER_SIZE", 0, "Render Size", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
/* matching bgpic_camera_frame_items[] */
static const EnumPropertyItem space_frame_items[] = {
{0, "STRETCH", 0, "Stretch", ""},
@@ -5137,7 +5119,7 @@ static void def_cmp_scale(StructRNA *srna)
static void def_cmp_rotate(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, node_sampler_type_items);
@@ -5150,14 +5132,14 @@ static void def_cmp_diff_matte(StructRNA *srna)
PropertyRNA *prop;
RNA_def_struct_sdna_from(srna, "NodeChroma", "storage");
-
+
prop = RNA_def_property(srna, "tolerance", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t1");
RNA_def_property_float_funcs(prop, NULL, "rna_difference_matte_t1_set", NULL);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Tolerance", "Color distances below this threshold are keyed");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t2");
RNA_def_property_float_funcs(prop, NULL, "rna_difference_matte_t2_set", NULL);
@@ -5169,7 +5151,7 @@ static void def_cmp_diff_matte(StructRNA *srna)
static void def_cmp_color_matte(StructRNA *srna)
{
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeChroma", "storage");
prop = RNA_def_property(srna, "color_hue", PROP_FLOAT, PROP_NONE);
@@ -5177,13 +5159,13 @@ static void def_cmp_color_matte(StructRNA *srna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "H", "Hue tolerance for colors to be considered a keying color");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "color_saturation", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t2");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "S", "Saturation Tolerance for the color");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "color_value", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t3");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -5194,7 +5176,7 @@ static void def_cmp_color_matte(StructRNA *srna)
static void def_cmp_distance_matte(StructRNA *srna)
{
PropertyRNA *prop;
-
+
static const EnumPropertyItem color_space_items[] = {
{1, "RGB", 0, "RGB", "RGB color space"},
{2, "YCC", 0, "YCC", "YCbCr Suppression"},
@@ -5209,14 +5191,14 @@ static void def_cmp_distance_matte(StructRNA *srna)
RNA_def_property_ui_text(prop, "Channel", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "tolerance", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t1");
RNA_def_property_float_funcs(prop, NULL, "rna_distance_matte_t1_set", NULL);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Tolerance", "Color distances below this threshold are keyed");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t2");
RNA_def_property_float_funcs(prop, NULL, "rna_distance_matte_t2_set", NULL);
@@ -5248,13 +5230,13 @@ static void def_cmp_color_spill(StructRNA *srna)
{1, "AVERAGE", 0, "Average", "Average Limit Algorithm"},
{0, NULL, 0, NULL, NULL}
};
-
+
prop = RNA_def_property(srna, "channel", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, channel_items);
RNA_def_property_ui_text(prop, "Channel", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "limit_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom2");
RNA_def_property_enum_items(prop, algorithm_items);
@@ -5302,16 +5284,16 @@ static void def_cmp_color_spill(StructRNA *srna)
static void def_cmp_luma_matte(StructRNA *srna)
{
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeChroma", "storage");
-
+
prop = RNA_def_property(srna, "limit_max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t1");
RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t1_set", NULL);
RNA_def_property_ui_range(prop, 0, 1, 0.1f, 3);
RNA_def_property_ui_text(prop, "High", "Values higher than this setting are 100% opaque");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "limit_min", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t2");
RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t2_set", NULL);
@@ -5333,16 +5315,16 @@ static void def_cmp_brightcontrast(StructRNA *srna)
static void def_cmp_chroma_matte(StructRNA *srna)
{
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeChroma", "storage");
-
+
prop = RNA_def_property(srna, "tolerance", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "t1");
RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t1_set", NULL);
RNA_def_property_range(prop, DEG2RADF(1.0f), DEG2RADF(80.0f));
RNA_def_property_ui_text(prop, "Acceptance", "Tolerance for a color to be considered a keying color");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "t2");
RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t2_set", NULL);
@@ -5355,13 +5337,13 @@ static void def_cmp_chroma_matte(StructRNA *srna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Lift", "Alpha lift");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "fstrength");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Falloff", "Alpha falloff");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "shadow_adjust", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t3");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -5372,7 +5354,7 @@ static void def_cmp_chroma_matte(StructRNA *srna)
static void def_cmp_channel_matte(StructRNA *srna)
{
PropertyRNA *prop;
-
+
static const EnumPropertyItem color_space_items[] = {
{CMP_NODE_CHANNEL_MATTE_CS_RGB, "RGB", 0, "RGB", "RGB Color Space"},
{CMP_NODE_CHANNEL_MATTE_CS_HSV, "HSV", 0, "HSV", "HSV Color Space"},
@@ -5386,13 +5368,13 @@ static void def_cmp_channel_matte(StructRNA *srna)
{1, "MAX", 0, "Max", "Limit by max of other channels "},
{0, NULL, 0, NULL, NULL}
};
-
+
prop = RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, color_space_items);
RNA_def_property_ui_text(prop, "Color Space", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "matte_channel", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom2");
RNA_def_property_enum_items(prop, prop_tri_channel_items);
@@ -5414,14 +5396,14 @@ static void def_cmp_channel_matte(StructRNA *srna)
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_channel_itemf");
RNA_def_property_ui_text(prop, "Limit Channel", "Limit by this channel's value");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "limit_max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t1");
RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t1_set", NULL);
RNA_def_property_ui_range(prop, 0, 1, 0.1f, 3);
RNA_def_property_ui_text(prop, "High", "Values higher than this setting are 100% opaque");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "limit_min", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t2");
RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t2_set", NULL);
@@ -5433,7 +5415,7 @@ static void def_cmp_channel_matte(StructRNA *srna)
static void def_cmp_flip(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, node_flip_items);
@@ -5444,7 +5426,7 @@ static void def_cmp_flip(StructRNA *srna)
static void def_cmp_splitviewer(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom2");
RNA_def_property_enum_items(prop, rna_enum_axis_xy_items);
@@ -5461,7 +5443,7 @@ static void def_cmp_splitviewer(StructRNA *srna)
static void def_cmp_id_mask(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "custom1");
RNA_def_property_range(prop, 0, 32767);
@@ -5551,7 +5533,7 @@ static void def_cmp_defocus(StructRNA *srna)
RNA_def_property_range(prop, 0.0f, DEG2RADF(90.0f));
RNA_def_property_ui_text(prop, "Angle", "Bokeh shape rotation offset");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "use_gamma_correction", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gamco", 1);
RNA_def_property_ui_text(prop, "Gamma Correction", "Enable gamma correction before and after main process");
@@ -5565,20 +5547,20 @@ static void def_cmp_defocus(StructRNA *srna)
"Amount of focal blur, 128=infinity=perfect focus, half the value doubles "
"the blur radius");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "blur_max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "maxblur");
RNA_def_property_range(prop, 0.0f, 10000.0f);
RNA_def_property_ui_text(prop, "Max Blur", "Blur limit, maximum CoC radius");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "bthresh");
RNA_def_property_range(prop, 0.0f, 100.0f);
RNA_def_property_ui_text(prop, "Threshold",
"CoC radius threshold, prevents background bleed on in-focus midground, 0=off");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "use_preview", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "preview", 1);
RNA_def_property_ui_text(prop, "Preview", "Enable low quality mode, useful for preview");
@@ -5590,7 +5572,7 @@ static void def_cmp_defocus(StructRNA *srna)
"Disable when using an image as input instead of actual z-buffer "
"(auto enabled if node not image based, eg. time node)");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "z_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "scale");
RNA_def_property_range(prop, 0.0f, 1000.0f);
@@ -5603,12 +5585,12 @@ static void def_cmp_defocus(StructRNA *srna)
static void def_cmp_invert(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "invert_rgb", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "custom1", CMP_CHAN_RGB);
RNA_def_property_ui_text(prop, "RGB", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "invert_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "custom1", CMP_CHAN_A);
RNA_def_property_ui_text(prop, "Alpha", "");
@@ -5618,7 +5600,7 @@ static void def_cmp_invert(StructRNA *srna)
static void def_cmp_crop(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "use_crop_size", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1);
RNA_def_property_ui_text(prop, "Crop Image Size", "Whether to crop the size of the input image");
@@ -5636,19 +5618,19 @@ static void def_cmp_crop(StructRNA *srna)
RNA_def_property_range(prop, 0, 10000);
RNA_def_property_ui_text(prop, "X1", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "max_x", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "x2");
RNA_def_property_range(prop, 0, 10000);
RNA_def_property_ui_text(prop, "X2", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "min_y", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "y1");
RNA_def_property_range(prop, 0, 10000);
RNA_def_property_ui_text(prop, "Y1", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "max_y", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "y2");
RNA_def_property_range(prop, 0, 10000);
@@ -5683,50 +5665,50 @@ static void def_cmp_crop(StructRNA *srna)
static void def_cmp_dblur(StructRNA *srna)
{
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeDBlurData", "storage");
-
+
prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "iter");
RNA_def_property_range(prop, 1, 32);
RNA_def_property_ui_text(prop, "Iterations", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "use_wrap", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "wrap", 1);
RNA_def_property_ui_text(prop, "Wrap", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "center_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "center_x");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Center X", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "center_y", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "center_y");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Center Y", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "distance");
RNA_def_property_range(prop, -1.0f, 1.0f);
RNA_def_property_ui_text(prop, "Distance", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "angle");
RNA_def_property_range(prop, 0.0f, DEG2RADF(360.0f));
RNA_def_property_ui_text(prop, "Angle", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "spin", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "spin");
RNA_def_property_range(prop, DEG2RADF(-360.0f), DEG2RADF(360.0f));
RNA_def_property_ui_text(prop, "Spin", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "zoom", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "zoom");
RNA_def_property_range(prop, 0.0f, 100.0f);
@@ -5737,21 +5719,21 @@ static void def_cmp_dblur(StructRNA *srna)
static void def_cmp_bilateral_blur(StructRNA *srna)
{
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeBilateralBlurData", "storage");
-
+
prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "iter");
RNA_def_property_range(prop, 1, 128);
RNA_def_property_ui_text(prop, "Iterations", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "sigma_color", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "sigma_color");
RNA_def_property_range(prop, 0.01f, 3.0f);
RNA_def_property_ui_text(prop, "Color Sigma", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "sigma_space", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "sigma_space");
RNA_def_property_range(prop, 0.01f, 30.0f);
@@ -5762,25 +5744,25 @@ static void def_cmp_bilateral_blur(StructRNA *srna)
static void def_cmp_premul_key(StructRNA *srna)
{
PropertyRNA *prop;
-
+
static const EnumPropertyItem type_items[] = {
{0, "STRAIGHT_TO_PREMUL", 0, "Straight to Premul", ""},
{1, "PREMUL_TO_STRAIGHT", 0, "Premul to Straight", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, type_items);
RNA_def_property_ui_text(prop, "Mapping", "Conversion between premultiplied alpha and key alpha");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
}
static void def_cmp_glare(StructRNA *srna)
{
PropertyRNA *prop;
-
+
static const EnumPropertyItem type_items[] = {
{3, "GHOSTS", 0, "Ghosts", ""},
{2, "STREAKS", 0, "Streaks", ""},
@@ -5788,22 +5770,22 @@ static void def_cmp_glare(StructRNA *srna)
{0, "SIMPLE_STAR", 0, "Simple Star", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem quality_items[] = {
{0, "HIGH", 0, "High", ""},
{1, "MEDIUM", 0, "Medium", ""},
{2, "LOW", 0, "Low", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
RNA_def_struct_sdna_from(srna, "NodeGlare", "storage");
-
+
prop = RNA_def_property(srna, "glare_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, type_items);
RNA_def_property_ui_text(prop, "Glare Type", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "quality", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "quality");
RNA_def_property_enum_items(prop, quality_items);
@@ -5811,13 +5793,13 @@ static void def_cmp_glare(StructRNA *srna)
"If not set to high quality, the effect will be applied to a low-res copy "
"of the source image");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "iter");
RNA_def_property_range(prop, 2, 5);
RNA_def_property_ui_text(prop, "Iterations", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "color_modulation", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "colmod");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -5825,109 +5807,109 @@ static void def_cmp_glare(StructRNA *srna)
"Amount of Color Modulation, modulates colors of streaks and ghosts for "
"a spectral dispersion effect");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "mix", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "mix");
RNA_def_property_range(prop, -1.0f, 1.0f);
RNA_def_property_ui_text(prop, "Mix",
"-1 is original image only, 0 is exact 50/50 mix, 1 is processed image only");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "threshold");
RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Threshold",
"The glare filter will only be applied to pixels brighter than this value");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "streaks", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "streaks");
RNA_def_property_range(prop, 1, 16);
RNA_def_property_ui_text(prop, "Streaks", "Total number of streaks");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "angle_offset", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "angle_ofs");
RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
RNA_def_property_ui_text(prop, "Angle Offset", "Streak angle offset");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "fade", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "fade");
RNA_def_property_range(prop, 0.75f, 1.0f);
RNA_def_property_ui_text(prop, "Fade", "Streak fade-out factor");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "use_rotate_45", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "star_45", 0);
RNA_def_property_ui_text(prop, "Rotate 45", "Simple star filter: add 45 degree rotation offset");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "size");
RNA_def_property_range(prop, 6, 9);
RNA_def_property_ui_text(prop, "Size",
"Glow/glare size (not actual size; relative to initial size of bright area of pixels)");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
/* TODO */
}
static void def_cmp_tonemap(StructRNA *srna)
{
PropertyRNA *prop;
-
+
static const EnumPropertyItem type_items[] = {
{1, "RD_PHOTORECEPTOR", 0, "R/D Photoreceptor", ""},
{0, "RH_SIMPLE", 0, "Rh Simple", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
RNA_def_struct_sdna_from(srna, "NodeTonemap", "storage");
-
+
prop = RNA_def_property(srna, "tonemap_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, type_items);
RNA_def_property_ui_text(prop, "Tonemap Type", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "key", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "key");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Key", "The value the average luminance is mapped to");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "offset");
RNA_def_property_range(prop, 0.001f, 10.0f);
RNA_def_property_ui_text(prop, "Offset",
"Normally always 1, but can be used as an extra control to alter the brightness curve");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "gamma");
RNA_def_property_range(prop, 0.001f, 3.0f);
RNA_def_property_ui_text(prop, "Gamma", "If not used, set to 1");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "f");
RNA_def_property_range(prop, -8.0f, 8.0f);
RNA_def_property_ui_text(prop, "Intensity", "If less than zero, darkens image; otherwise, makes it brighter");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "contrast", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "m");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Contrast", "Set to 0 to use estimate from input image");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "adaptation", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "a");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Adaptation", "If 0, global; if 1, based on pixel intensity");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "correction", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "c");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -5938,20 +5920,20 @@ static void def_cmp_tonemap(StructRNA *srna)
static void def_cmp_lensdist(StructRNA *srna)
{
PropertyRNA *prop;
-
+
RNA_def_struct_sdna_from(srna, "NodeLensDist", "storage");
-
+
prop = RNA_def_property(srna, "use_projector", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "proj", 1);
RNA_def_property_ui_text(prop, "Projector",
"Enable/disable projector mode (the effect is applied in horizontal direction only)");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "use_jitter", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "jit", 1);
RNA_def_property_ui_text(prop, "Jitter", "Enable/disable jittering (faster, but also noisier)");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "use_fit", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "fit", 1);
RNA_def_property_ui_text(prop, "Fit",
@@ -5963,21 +5945,21 @@ static void def_cmp_colorbalance(StructRNA *srna)
{
PropertyRNA *prop;
static float default_1[3] = {1.f, 1.f, 1.f};
-
+
static const EnumPropertyItem type_items[] = {
{0, "LIFT_GAMMA_GAIN", 0, "Lift/Gamma/Gain", ""},
{1, "OFFSET_POWER_SLOPE", 0, "Offset/Power/Slope (ASC-CDL)", "ASC-CDL standard color correction"},
{0, NULL, 0, NULL, NULL}
};
-
+
prop = RNA_def_property(srna, "correction_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, type_items);
RNA_def_property_ui_text(prop, "Correction Formula", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
RNA_def_struct_sdna_from(srna, "NodeColorBalance", "storage");
-
+
prop = RNA_def_property(srna, "lift", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "lift");
RNA_def_property_array(prop, 3);
@@ -5985,7 +5967,7 @@ static void def_cmp_colorbalance(StructRNA *srna)
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Lift", "Correction for Shadows");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_lgg");
-
+
prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "gamma");
RNA_def_property_array(prop, 3);
@@ -5993,7 +5975,7 @@ static void def_cmp_colorbalance(StructRNA *srna)
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Gamma", "Correction for Midtones");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_lgg");
-
+
prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "gain");
RNA_def_property_array(prop, 3);
@@ -6001,15 +5983,15 @@ static void def_cmp_colorbalance(StructRNA *srna)
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Gain", "Correction for Highlights");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_lgg");
-
-
+
+
prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "offset");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
RNA_def_property_ui_text(prop, "Offset", "Correction for Shadows");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_cdl");
-
+
prop = RNA_def_property(srna, "power", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "power");
RNA_def_property_array(prop, 3);
@@ -6018,7 +6000,7 @@ static void def_cmp_colorbalance(StructRNA *srna)
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Power", "Correction for Midtones");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_cdl");
-
+
prop = RNA_def_property(srna, "slope", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "slope");
RNA_def_property_array(prop, 3);
@@ -6038,7 +6020,7 @@ static void def_cmp_colorbalance(StructRNA *srna)
static void def_cmp_huecorrect(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "mapping", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "storage");
RNA_def_property_struct_type(prop, "CurveMapping");
@@ -6049,7 +6031,7 @@ static void def_cmp_huecorrect(StructRNA *srna)
static void def_cmp_zcombine(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "custom1", 0);
RNA_def_property_ui_text(prop, "Use Alpha", "Take Alpha channel into account when doing the Z operation");
@@ -6064,7 +6046,7 @@ static void def_cmp_zcombine(StructRNA *srna)
static void def_cmp_ycc(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, node_ycc_items);
@@ -6219,7 +6201,7 @@ static const EnumPropertyItem node_masktype_items[] = {
{0, NULL, 0, NULL, NULL}
};
-static void def_cmp_boxmask(StructRNA *srna)
+static void def_cmp_boxmask(StructRNA *srna)
{
PropertyRNA *prop;
@@ -6345,7 +6327,7 @@ static void def_cmp_bokehblur(StructRNA *srna)
RNA_def_property_range(prop, 0.0f, 10000.0f);
RNA_def_property_ui_text(prop, "Max Blur", "Blur limit, maximum CoC radius");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
}
static void def_cmp_bokehimage(StructRNA *srna)
@@ -6413,21 +6395,21 @@ static void def_cmp_colorcorrection(StructRNA *srna)
RNA_def_property_boolean_default(prop, true);
RNA_def_property_ui_text(prop, "Red", "Red channel active");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "green", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "custom1", 2);
RNA_def_property_boolean_default(prop, true);
RNA_def_property_ui_text(prop, "Green", "Green channel active");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "blue", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "custom1", 4);
RNA_def_property_boolean_default(prop, true);
RNA_def_property_ui_text(prop, "Blue", "Blue channel active");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
RNA_def_struct_sdna_from(srna, "NodeColorCorrection", "storage");
-
+
prop = RNA_def_property(srna, "midtones_start", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "startmidtones");
RNA_def_property_float_default(prop, 0.2f);
@@ -6441,35 +6423,35 @@ static void def_cmp_colorcorrection(StructRNA *srna)
RNA_def_property_range(prop, 0, 1);
RNA_def_property_ui_text(prop, "Midtones End", "End of midtones");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "master_saturation", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "master.saturation");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Master Saturation", "Master saturation");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "master_contrast", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "master.contrast");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Master Contrast", "Master contrast");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "master_gamma", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "master.gamma");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Master Gamma", "Master gamma");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "master_gain", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "master.gain");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Master Gain", "Master gain");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "master_lift", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "master.lift");
RNA_def_property_float_default(prop, 0.0f);
@@ -6484,28 +6466,28 @@ static void def_cmp_colorcorrection(StructRNA *srna)
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Shadows Saturation", "Shadows saturation");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "shadows_contrast", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "shadows.contrast");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Shadows Contrast", "Shadows contrast");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "shadows_gamma", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "shadows.gamma");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Shadows Gamma", "Shadows gamma");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "shadows_gain", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "shadows.gain");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Shadows Gain", "Shadows gain");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "shadows_lift", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "shadows.lift");
RNA_def_property_float_default(prop, 0.0f);
@@ -6519,28 +6501,28 @@ static void def_cmp_colorcorrection(StructRNA *srna)
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Midtones Saturation", "Midtones saturation");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "midtones_contrast", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "midtones.contrast");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Midtones Contrast", "Midtones contrast");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "midtones_gamma", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "midtones.gamma");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Midtones Gamma", "Midtones gamma");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "midtones_gain", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "midtones.gain");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Midtones Gain", "Midtones gain");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "midtones_lift", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "midtones.lift");
RNA_def_property_float_default(prop, 0.0f);
@@ -6554,28 +6536,28 @@ static void def_cmp_colorcorrection(StructRNA *srna)
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Highlights Saturation", "Highlights saturation");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "highlights_contrast", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "highlights.contrast");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Highlights Contrast", "Highlights contrast");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "highlights_gamma", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "highlights.gamma");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Highlights Gamma", "Highlights gamma");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "highlights_gain", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "highlights.gain");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_range(prop, 0, 4);
RNA_def_property_ui_text(prop, "Highlights Gain", "Highlights gain");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "highlights_lift", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "highlights.lift");
RNA_def_property_float_default(prop, 0.0f);
@@ -6607,7 +6589,7 @@ static void def_cmp_viewer(StructRNA *srna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "X", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "center_y", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "custom4");
RNA_def_property_float_default(prop, 0.5f);
@@ -6871,7 +6853,7 @@ static void def_tex_output(StructRNA *srna)
PropertyRNA *prop;
RNA_def_struct_sdna_from(srna, "TexNodeOutput", "storage");
-
+
prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "name");
RNA_def_property_ui_text(prop, "Output Name", "");
@@ -6906,19 +6888,19 @@ static void def_tex_bricks(StructRNA *srna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Offset Amount", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "offset_frequency", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "custom1");
RNA_def_property_range(prop, 2, 99);
RNA_def_property_ui_text(prop, "Offset Frequency", "Offset every N rows");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "squash", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "custom4");
RNA_def_property_range(prop, 0.0f, 99.0f);
RNA_def_property_ui_text(prop, "Squash Amount", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "squash_frequency", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "custom2");
RNA_def_property_range(prop, 2, 99);
@@ -6931,7 +6913,7 @@ static void def_tex_bricks(StructRNA *srna)
static void rna_def_shader_node(BlenderRNA *brna)
{
StructRNA *srna;
-
+
srna = RNA_def_struct(brna, "ShaderNode", "NodeInternal");
RNA_def_struct_ui_text(srna, "Shader Node", "Material shader node");
RNA_def_struct_sdna(srna, "bNode");
@@ -6942,12 +6924,12 @@ static void rna_def_compositor_node(BlenderRNA *brna)
{
StructRNA *srna;
FunctionRNA *func;
-
+
srna = RNA_def_struct(brna, "CompositorNode", "NodeInternal");
RNA_def_struct_ui_text(srna, "Compositor Node", "");
RNA_def_struct_sdna(srna, "bNode");
RNA_def_struct_register_funcs(srna, "rna_CompositorNode_register", "rna_Node_unregister", NULL);
-
+
/* compositor node need_exec flag */
func = RNA_def_function(srna, "tag_need_exec", "rna_CompositorNode_tag_need_exec");
RNA_def_function_ui_description(func, "Tag the node for compositor update");
@@ -6956,7 +6938,7 @@ static void rna_def_compositor_node(BlenderRNA *brna)
static void rna_def_texture_node(BlenderRNA *brna)
{
StructRNA *srna;
-
+
srna = RNA_def_struct(brna, "TextureNode", "NodeInternal");
RNA_def_struct_ui_text(srna, "Texture Node", "");
RNA_def_struct_sdna(srna, "bNode");
@@ -6971,9 +6953,9 @@ static void rna_def_node_socket(BlenderRNA *brna)
PropertyRNA *prop;
PropertyRNA *parm;
FunctionRNA *func;
-
+
static float default_draw_color[] = { 0.0f, 0.0f, 0.0f, 1.0f };
-
+
srna = RNA_def_struct(brna, "NodeSocket", NULL);
RNA_def_struct_ui_text(srna, "Node Socket", "Input or output socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
@@ -7100,9 +7082,9 @@ static void rna_def_node_socket_interface(BlenderRNA *brna)
PropertyRNA *prop;
PropertyRNA *parm;
FunctionRNA *func;
-
+
static float default_draw_color[] = { 0.0f, 0.0f, 0.0f, 1.0f };
-
+
srna = RNA_def_struct(brna, "NodeSocketInterface", NULL);
RNA_def_struct_ui_text(srna, "Node Socket Template", "Parameters to define node sockets");
/* XXX Using bNodeSocket DNA for templates is a compatibility hack.
@@ -7184,7 +7166,7 @@ static void rna_def_node_socket_float(BlenderRNA *brna, const char *idname, cons
StructRNA *srna;
PropertyRNA *prop;
float value_default;
-
+
/* choose sensible common default based on subtype */
switch (subtype) {
case PROP_FACTOR:
@@ -7197,46 +7179,46 @@ static void rna_def_node_socket_float(BlenderRNA *brna, const char *idname, cons
value_default = 0.0f;
break;
}
-
+
srna = RNA_def_struct(brna, idname, "NodeSocketStandard");
RNA_def_struct_ui_text(srna, "Float Node Socket", "Floating point number socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocketValueFloat", "default_value");
-
+
prop = RNA_def_property(srna, "default_value", PROP_FLOAT, subtype);
RNA_def_property_float_sdna(prop, NULL, "value");
RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocketStandard_float_range");
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketStandard_value_update");
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
-
+
/* socket interface */
srna = RNA_def_struct(brna, interface_idname, "NodeSocketInterfaceStandard");
RNA_def_struct_ui_text(srna, "Float Node Socket Interface", "Floating point number socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocketValueFloat", "default_value");
-
+
prop = RNA_def_property(srna, "default_value", PROP_FLOAT, subtype);
RNA_def_property_float_sdna(prop, NULL, "value");
RNA_def_property_float_default(prop, value_default);
RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocketStandard_float_range");
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
-
+
prop = RNA_def_property(srna, "min_value", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "min");
RNA_def_property_ui_text(prop, "Minimum Value", "Minimum value");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
-
+
prop = RNA_def_property(srna, "max_value", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "max");
RNA_def_property_ui_text(prop, "Maximum Value", "Maximum value");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
}
@@ -7245,7 +7227,7 @@ static void rna_def_node_socket_int(BlenderRNA *brna, const char *identifier, co
StructRNA *srna;
PropertyRNA *prop;
int value_default;
-
+
/* choose sensible common default based on subtype */
switch (subtype) {
case PROP_FACTOR:
@@ -7258,13 +7240,13 @@ static void rna_def_node_socket_int(BlenderRNA *brna, const char *identifier, co
value_default = 0;
break;
}
-
+
srna = RNA_def_struct(brna, identifier, "NodeSocketStandard");
RNA_def_struct_ui_text(srna, "Integer Node Socket", "Integer number socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocketValueInt", "default_value");
-
+
prop = RNA_def_property(srna, "default_value", PROP_INT, subtype);
RNA_def_property_int_sdna(prop, NULL, "value");
RNA_def_property_int_default(prop, value_default);
@@ -7272,32 +7254,32 @@ static void rna_def_node_socket_int(BlenderRNA *brna, const char *identifier, co
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketStandard_value_update");
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
-
+
/* socket interface */
srna = RNA_def_struct(brna, interface_idname, "NodeSocketInterfaceStandard");
RNA_def_struct_ui_text(srna, "Integer Node Socket Interface", "Integer number socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
RNA_def_struct_sdna_from(srna, "bNodeSocketValueInt", "default_value");
-
+
prop = RNA_def_property(srna, "default_value", PROP_INT, subtype);
RNA_def_property_int_sdna(prop, NULL, "value");
RNA_def_property_int_funcs(prop, NULL, NULL, "rna_NodeSocketStandard_int_range");
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
-
+
prop = RNA_def_property(srna, "min_value", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "min");
RNA_def_property_ui_text(prop, "Minimum Value", "Minimum value");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
-
+
prop = RNA_def_property(srna, "max_value", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "max");
RNA_def_property_ui_text(prop, "Maximum Value", "Maximum value");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
}
@@ -7305,33 +7287,33 @@ static void rna_def_node_socket_bool(BlenderRNA *brna, const char *identifier, c
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, identifier, "NodeSocketStandard");
RNA_def_struct_ui_text(srna, "Boolean Node Socket", "Boolean value socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocketValueBoolean", "default_value");
-
+
prop = RNA_def_property(srna, "default_value", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "value", 1);
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketStandard_value_update");
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
-
+
/* socket interface */
srna = RNA_def_struct(brna, interface_idname, "NodeSocketInterfaceStandard");
RNA_def_struct_ui_text(srna, "Boolean Node Socket Interface", "Boolean value socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocketValueBoolean", "default_value");
-
+
prop = RNA_def_property(srna, "default_value", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "value", 1);
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
}
@@ -7340,7 +7322,7 @@ static void rna_def_node_socket_vector(BlenderRNA *brna, const char *identifier,
StructRNA *srna;
PropertyRNA *prop;
const float *value_default;
-
+
/* choose sensible common default based on subtype */
switch (subtype) {
case PROP_DIRECTION: {
@@ -7354,13 +7336,13 @@ static void rna_def_node_socket_vector(BlenderRNA *brna, const char *identifier,
break;
}
}
-
+
srna = RNA_def_struct(brna, identifier, "NodeSocketStandard");
RNA_def_struct_ui_text(srna, "Vector Node Socket", "3D vector socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocketValueVector", "default_value");
-
+
prop = RNA_def_property(srna, "default_value", PROP_FLOAT, subtype);
RNA_def_property_float_sdna(prop, NULL, "value");
RNA_def_property_float_array_default(prop, value_default);
@@ -7368,32 +7350,32 @@ static void rna_def_node_socket_vector(BlenderRNA *brna, const char *identifier,
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketStandard_value_update");
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
-
+
/* socket interface */
srna = RNA_def_struct(brna, interface_idname, "NodeSocketInterfaceStandard");
RNA_def_struct_ui_text(srna, "Vector Node Socket Interface", "3D vector socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocketValueVector", "default_value");
-
+
prop = RNA_def_property(srna, "default_value", PROP_FLOAT, subtype);
RNA_def_property_float_sdna(prop, NULL, "value");
RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocketStandard_vector_range");
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
-
+
prop = RNA_def_property(srna, "min_value", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "min");
RNA_def_property_ui_text(prop, "Minimum Value", "Minimum value");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
-
+
prop = RNA_def_property(srna, "max_value", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "max");
RNA_def_property_ui_text(prop, "Maximum Value", "Maximum value");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
}
@@ -7401,33 +7383,33 @@ static void rna_def_node_socket_color(BlenderRNA *brna, const char *identifier,
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, identifier, "NodeSocketStandard");
RNA_def_struct_ui_text(srna, "Color Node Socket", "RGBA color socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocketValueRGBA", "default_value");
-
+
prop = RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "value");
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketStandard_value_update");
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
-
+
/* socket interface */
srna = RNA_def_struct(brna, interface_idname, "NodeSocketInterfaceStandard");
RNA_def_struct_ui_text(srna, "Color Node Socket Interface", "RGBA color socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocketValueRGBA", "default_value");
-
+
prop = RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "value");
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
}
@@ -7435,44 +7417,44 @@ static void rna_def_node_socket_string(BlenderRNA *brna, const char *identifier,
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, identifier, "NodeSocketStandard");
RNA_def_struct_ui_text(srna, "String Node Socket", "String socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocketValueString", "default_value");
-
+
prop = RNA_def_property(srna, "default_value", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "value");
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketStandard_value_update");
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
-
+
/* socket interface */
srna = RNA_def_struct(brna, interface_idname, "NodeSocketInterfaceStandard");
RNA_def_struct_ui_text(srna, "String Node Socket Interface", "String socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocketValueString", "default_value");
-
+
prop = RNA_def_property(srna, "default_value", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "value");
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
-
+
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
}
static void rna_def_node_socket_shader(BlenderRNA *brna, const char *identifier, const char *interface_idname)
{
StructRNA *srna;
-
+
srna = RNA_def_struct(brna, identifier, "NodeSocketStandard");
RNA_def_struct_ui_text(srna, "Shader Node Socket", "Shader socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
-
+
/* socket interface */
srna = RNA_def_struct(brna, interface_idname, "NodeSocketInterfaceStandard");
RNA_def_struct_ui_text(srna, "Shader Node Socket Interface", "Shader socket of a node");
@@ -7482,7 +7464,7 @@ static void rna_def_node_socket_shader(BlenderRNA *brna, const char *identifier,
static void rna_def_node_socket_virtual(BlenderRNA *brna, const char *identifier)
{
StructRNA *srna;
-
+
srna = RNA_def_struct(brna, identifier, "NodeSocketStandard");
RNA_def_struct_ui_text(srna, "Virtual Node Socket", "Virtual socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
@@ -7496,16 +7478,16 @@ static void rna_def_node_socket_standard_types(BlenderRNA *brna)
* so in order to call them in py scripts we need to overload and replace them with plain C callbacks.
* These types provide a usable basis for socket types defined in C.
*/
-
+
StructRNA *srna;
PropertyRNA *parm, *prop;
FunctionRNA *func;
-
+
static float default_draw_color[] = { 0.0f, 0.0f, 0.0f, 1.0f };
-
+
srna = RNA_def_struct(brna, "NodeSocketStandard", "NodeSocket");
RNA_def_struct_sdna(srna, "bNodeSocket");
-
+
/* draw socket */
func = RNA_def_function(srna, "draw", "rna_NodeSocketStandard_draw");
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
@@ -7536,11 +7518,11 @@ static void rna_def_node_socket_standard_types(BlenderRNA *brna)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
parm = RNA_def_float_array(func, "color", 4, default_draw_color, 0.0f, 1.0f, "Color", "", 0.0f, 1.0f);
RNA_def_function_output(func, parm);
-
-
+
+
srna = RNA_def_struct(brna, "NodeSocketInterfaceStandard", "NodeSocketInterface");
RNA_def_struct_sdna(srna, "bNodeSocket");
-
+
/* for easier type comparison in python */
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "typeinfo->type");
@@ -7548,7 +7530,7 @@ static void rna_def_node_socket_standard_types(BlenderRNA *brna)
RNA_def_property_enum_default(prop, SOCK_FLOAT);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Type", "Data type");
-
+
func = RNA_def_function(srna, "draw", "rna_NodeSocketInterfaceStandard_draw");
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
RNA_def_function_ui_description(func, "Draw template settings");
@@ -7572,7 +7554,7 @@ static void rna_def_node_socket_standard_types(BlenderRNA *brna)
* Then use the nodeStaticSocketType and nodeStaticSocketInterfaceType functions
* to get the idname strings from int type and subtype (see node_socket.c, register_standard_node_socket_types).
*/
-
+
rna_def_node_socket_float(brna, "NodeSocketFloat", "NodeSocketInterfaceFloat", PROP_NONE);
rna_def_node_socket_float(brna, "NodeSocketFloatUnsigned", "NodeSocketInterfaceFloatUnsigned", PROP_UNSIGNED);
rna_def_node_socket_float(brna, "NodeSocketFloatPercentage", "NodeSocketInterfaceFloatPercentage", PROP_PERCENTAGE);
@@ -7609,36 +7591,36 @@ static void rna_def_internal_node(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop, *parm;
FunctionRNA *func;
-
+
srna = RNA_def_struct(brna, "NodeInternalSocketTemplate", NULL);
RNA_def_struct_ui_text(srna, "Socket Template", "Type and default value of a node socket");
-
+
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, "rna_NodeInternalSocketTemplate_name_get", "rna_NodeInternalSocketTemplate_name_length", NULL);
RNA_def_property_ui_text(prop, "Name", "Name of the socket");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
+
prop = RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, "rna_NodeInternalSocketTemplate_identifier_get", "rna_NodeInternalSocketTemplate_identifier_length", NULL);
RNA_def_property_ui_text(prop, "Identifier", "Identifier of the socket");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
+
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_funcs(prop, "rna_NodeInternalSocketTemplate_type_get", NULL, NULL);
RNA_def_property_enum_items(prop, node_socket_type_items);
RNA_def_property_ui_text(prop, "Type", "Data type of the socket");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
+
/* XXX Workaround: Registered functions are not exposed in python by bpy,
* it expects them to be registered from python and use the native implementation.
* However, the standard node types are not registering these functions from python,
* so in order to call them in py scripts we need to overload and replace them with plain C callbacks.
* This type provides a usable basis for node types defined in C.
*/
-
+
srna = RNA_def_struct(brna, "NodeInternal", "Node");
RNA_def_struct_sdna(srna, "bNode");
-
+
/* poll */
func = RNA_def_function(srna, "poll", "rna_NodeInternal_poll");
RNA_def_function_ui_description(func, "If non-null output is returned, the node type can be added to the tree");
@@ -7646,18 +7628,18 @@ static void rna_def_internal_node(BlenderRNA *brna)
RNA_def_function_return(func, RNA_def_boolean(func, "visible", false, "", ""));
parm = RNA_def_pointer(func, "node_tree", "NodeTree", "Node Tree", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
+
func = RNA_def_function(srna, "poll_instance", "rna_NodeInternal_poll_instance");
RNA_def_function_ui_description(func, "If non-null output is returned, the node can be added to the tree");
RNA_def_function_return(func, RNA_def_boolean(func, "visible", false, "", ""));
parm = RNA_def_pointer(func, "node_tree", "NodeTree", "Node Tree", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
+
/* update */
func = RNA_def_function(srna, "update", "rna_NodeInternal_update");
RNA_def_function_ui_description(func, "Update on editor changes");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_ALLOW_WRITE);
-
+
/* draw buttons */
func = RNA_def_function(srna, "draw_buttons", "rna_NodeInternal_draw_buttons");
RNA_def_function_ui_description(func, "Draw node buttons");
@@ -7734,7 +7716,7 @@ static void rna_def_node(BlenderRNA *brna)
PropertyRNA *prop;
FunctionRNA *func;
PropertyRNA *parm;
-
+
static const EnumPropertyItem dummy_static_type_items[] = {
{NODE_CUSTOM, "CUSTOM", 0, "Custom", "Custom Node"},
{0, NULL, 0, NULL, NULL}};
@@ -7753,7 +7735,7 @@ static void rna_def_node(BlenderRNA *brna)
RNA_def_struct_path_func(srna, "rna_Node_path");
RNA_def_struct_register_funcs(srna, "rna_Node_register", "rna_Node_unregister", NULL);
RNA_def_struct_idprops_func(srna, "rna_Node_idprops");
-
+
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, dummy_static_type_items);
@@ -7761,55 +7743,55 @@ static void rna_def_node(BlenderRNA *brna)
RNA_def_property_enum_default(prop, NODE_CUSTOM);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Type", "Node type (deprecated, use bl_static_type or bl_idname for the actual identifier string)");
-
+
prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "locx");
RNA_def_property_array(prop, 2);
RNA_def_property_range(prop, -100000.0f, 100000.0f);
RNA_def_property_ui_text(prop, "Location", "");
RNA_def_property_update(prop, NC_NODE, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "width", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "width");
RNA_def_property_float_funcs(prop, NULL, NULL, "rna_Node_width_range");
RNA_def_property_ui_text(prop, "Width", "Width of the node");
RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL);
-
+
prop = RNA_def_property(srna, "width_hidden", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "miniwidth");
RNA_def_property_float_funcs(prop, NULL, NULL, "rna_Node_width_range");
RNA_def_property_ui_text(prop, "Width Hidden", "Width of the node in hidden state");
RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL);
-
+
prop = RNA_def_property(srna, "height", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "height");
RNA_def_property_float_funcs(prop, NULL, NULL, "rna_Node_height_range");
RNA_def_property_ui_text(prop, "Height", "Height of the node");
RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL);
-
+
prop = RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ_LENGTH);
RNA_def_property_array(prop, 2);
RNA_def_property_float_funcs(prop, "rna_Node_dimensions_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Dimensions", "Absolute bounding box dimensions of the node");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
+
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "Unique node identifier");
RNA_def_struct_name_property(srna, prop);
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Node_name_set");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
prop = RNA_def_property(srna, "label", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "label");
RNA_def_property_ui_text(prop, "Label", "Optional custom node label");
RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL);
-
+
prop = RNA_def_property(srna, "inputs", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "inputs", NULL);
RNA_def_property_struct_type(prop, "NodeSocket");
RNA_def_property_ui_text(prop, "Inputs", "");
rna_def_node_sockets_api(brna, prop, SOCK_IN);
-
+
prop = RNA_def_property(srna, "outputs", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "outputs", NULL);
RNA_def_property_struct_type(prop, "NodeSocket");
@@ -7827,7 +7809,7 @@ static void rna_def_node(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "Node");
RNA_def_property_ui_text(prop, "Parent", "Parent this node is attached to");
-
+
prop = RNA_def_property(srna, "use_custom_color", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_CUSTOM_COLOR);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -7904,7 +7886,7 @@ static void rna_def_node(BlenderRNA *brna)
prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_TRANSLATION);
RNA_def_property_string_sdna(prop, NULL, "typeinfo->ui_description");
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
-
+
prop = RNA_def_property(srna, "bl_icon", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "typeinfo->ui_icon");
RNA_def_property_enum_items(prop, rna_enum_node_icon_items);
@@ -7952,26 +7934,26 @@ static void rna_def_node(BlenderRNA *brna)
RNA_def_function_return(func, RNA_def_boolean(func, "visible", false, "", ""));
parm = RNA_def_pointer(func, "node_tree", "NodeTree", "Node Tree", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
+
func = RNA_def_function(srna, "poll_instance", NULL);
RNA_def_function_ui_description(func, "If non-null output is returned, the node can be added to the tree");
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
RNA_def_function_return(func, RNA_def_boolean(func, "visible", false, "", ""));
parm = RNA_def_pointer(func, "node_tree", "NodeTree", "Node Tree", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
+
/* update */
func = RNA_def_function(srna, "update", NULL);
RNA_def_function_ui_description(func, "Update on editor changes");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
-
+
/* insert_link */
func = RNA_def_function(srna, "insert_link", NULL);
RNA_def_function_ui_description(func, "Handle creation of a link to or from the node");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
parm = RNA_def_pointer(func, "link", "NodeLink", "Link", "Node link that will be inserted");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
-
+
/* init */
func = RNA_def_function(srna, "init", NULL);
RNA_def_function_ui_description(func, "Initialize a new instance of this node");
@@ -8216,7 +8198,7 @@ static void rna_def_nodetree(BlenderRNA *brna)
RNA_def_property_array(prop, 2);
RNA_def_property_float_sdna(prop, NULL, "view_center");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
+
/* AnimData */
rna_def_animdata_common(srna);
@@ -8241,7 +8223,7 @@ static void rna_def_nodetree(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil data-block");
RNA_def_property_update(prop, NC_NODE, NULL);
-
+
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_enum_items(prop, static_type_items);
@@ -8291,7 +8273,7 @@ static void rna_def_nodetree(BlenderRNA *brna)
prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_TRANSLATION);
RNA_def_property_string_sdna(prop, NULL, "typeinfo->ui_description");
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
-
+
prop = RNA_def_property(srna, "bl_icon", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "typeinfo->ui_icon");
RNA_def_property_enum_items(prop, rna_enum_node_icon_items);
@@ -8398,11 +8380,11 @@ static StructRNA *define_specific_node(BlenderRNA *brna, const char *struct_name
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
-
+
/* XXX hack, want to avoid "NodeInternal" prefix, so use "Node" in NOD_static_types.h and replace here */
if (STREQ(base_name, "Node"))
base_name = "NodeInternal";
-
+
srna = RNA_def_struct(brna, struct_name, base_name);
RNA_def_struct_ui_text(srna, ui_name, ui_desc);
RNA_def_struct_sdna(srna, "bNode");
@@ -8460,26 +8442,26 @@ static void rna_def_node_instance_hash(BlenderRNA *brna)
void RNA_def_nodetree(BlenderRNA *brna)
{
StructRNA *srna;
-
+
rna_def_node_socket(brna);
rna_def_node_socket_interface(brna);
-
+
rna_def_node(brna);
rna_def_node_link(brna);
-
+
rna_def_internal_node(brna);
rna_def_shader_node(brna);
rna_def_compositor_node(brna);
rna_def_texture_node(brna);
-
+
rna_def_nodetree(brna);
-
+
rna_def_node_socket_standard_types(brna);
-
+
rna_def_composite_nodetree(brna);
rna_def_shader_nodetree(brna);
rna_def_texture_nodetree(brna);
-
+
#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
{ \
srna = define_specific_node(brna, #Category #StructName, #Category, UIName, UIDesc, DefFunc); \
@@ -8488,12 +8470,12 @@ void RNA_def_nodetree(BlenderRNA *brna)
def_cmp_output_file(brna, srna); \
} \
}
-
+
/* hack, don't want to add include path to RNA just for this, since in the future RNA types
* for nodes should be defined locally at runtime anyway ...
*/
#include "../../nodes/NOD_static_types.h"
-
+
/* Node group types need to be defined for shader, compositor, texture nodes individually.
* Cannot use the static types header for this, since they share the same int id.
*/
@@ -8501,11 +8483,11 @@ void RNA_def_nodetree(BlenderRNA *brna)
define_specific_node(brna, "CompositorNodeGroup", "CompositorNode", "Group", "", def_group);
define_specific_node(brna, "TextureNodeGroup", "TextureNode", "Group", "", def_group);
def_custom_group(brna);
-
+
/* special socket types */
rna_def_cmp_output_file_slot_file(brna);
rna_def_cmp_output_file_slot_layer(brna);
-
+
rna_def_node_instance_hash(brna);
}
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index d9074aed29e..28e13790d5c 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -224,18 +224,6 @@ static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA
DEG_id_type_tag(bmain, ID_OB);
}
-static int rna_Object_is_visible_get(PointerRNA *ptr)
-{
- Object *ob = ptr->id.data;
- /* The duplicators final visibility is not evaluated by depsgraph, so it's
- * in ob->base_flag & VISIBLED. Instead we need to take into account whether
- * we are rendering or not, and the ob->duplicator_visibility_flag.
- * However for this assessor we don't know if we are rendering, so we just
- * ignore the duplicator visibility
- */
- return BKE_object_is_visible(ob, OB_VISIBILITY_CHECK_UNKNOWN_RENDER_MODE);
-}
-
static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
{
Object *ob = ptr->id.data;
@@ -300,7 +288,7 @@ static void rna_Object_active_shape_update(bContext *C, PointerRNA *ptr)
break;
case OB_CURVE:
case OB_SURF:
- ED_curve_editnurb_load(ob);
+ ED_curve_editnurb_load(bmain, ob);
ED_curve_editnurb_make(ob);
break;
case OB_LATTICE:
@@ -346,7 +334,7 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
}
}
else if (ob->type == OB_MESH) {
- BKE_mesh_assign_object(ob, (Mesh *)id);
+ BKE_mesh_assign_object(G.main, ob, (Mesh *)id);
}
else {
if (ob->data) {
@@ -358,7 +346,7 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
id_us_plus(id);
ob->data = id;
- test_object_materials(ob, id);
+ test_object_materials(G.main, ob, id);
if (GS(id->name) == ID_CU)
BKE_curve_type_test(ob);
@@ -417,7 +405,7 @@ static const EnumPropertyItem *rna_Object_parent_type_itemf(bContext *UNUSED(C),
if (ob->parent) {
Object *par = ob->parent;
-
+
if (par->type == OB_LATTICE) {
/* special hack: prevents this overriding others */
RNA_enum_items_add_value(&item, &totitem, &parent_type_items[2], PARSKEL);
@@ -475,7 +463,7 @@ static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value)
{
Object *ob = (Object *)ptr->data;
Collection *grp = (Collection *)value.data;
-
+
/* must not let this be set if the object belongs in this group already,
* thus causing a cycle/infinite-recursion leading to crashes on load [#25298]
*/
@@ -735,7 +723,7 @@ static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
{
Object *ob = (Object *)ptr->id.data;
Material *ma;
-
+
ma = (ob->totcol) ? give_current_material(ob, ob->actcol) : NULL;
return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
}
@@ -745,7 +733,7 @@ static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value)
Object *ob = (Object *)ptr->id.data;
DEG_id_tag_update(value.data, 0);
- assign_material(ob, value.data, ob->actcol, BKE_MAT_ASSIGN_EXISTING);
+ assign_material(G.main, ob, value.data, ob->actcol, BKE_MAT_ASSIGN_EXISTING);
}
static int rna_Object_active_material_editable(PointerRNA *ptr, const char **UNUSED(r_info))
@@ -800,7 +788,7 @@ static void rna_Object_particle_update(Main *UNUSED(bmain), Scene *scene, Pointe
static void rna_Object_rotation_axis_angle_get(PointerRNA *ptr, float *value)
{
Object *ob = ptr->data;
-
+
/* for now, assume that rotation mode is axis-angle */
value[0] = ob->rotAngle;
copy_v3_v3(&value[1], ob->rotAxis);
@@ -810,21 +798,21 @@ static void rna_Object_rotation_axis_angle_get(PointerRNA *ptr, float *value)
static void rna_Object_rotation_axis_angle_set(PointerRNA *ptr, const float *value)
{
Object *ob = ptr->data;
-
+
/* for now, assume that rotation mode is axis-angle */
ob->rotAngle = value[0];
copy_v3_v3(ob->rotAxis, &value[1]);
-
+
/* TODO: validate axis? */
}
static void rna_Object_rotation_mode_set(PointerRNA *ptr, int value)
{
Object *ob = ptr->data;
-
+
/* use API Method for conversions... */
BKE_rotMode_change_values(ob->quat, ob->rot, ob->rotAxis, &ob->rotAngle, ob->rotmode, (short)value);
-
+
/* finally, set the new rotation type */
ob->rotmode = value;
}
@@ -844,7 +832,7 @@ static void rna_Object_dimensions_set(PointerRNA *ptr, const float *value)
static int rna_Object_location_editable(PointerRNA *ptr, int index)
{
Object *ob = (Object *)ptr->data;
-
+
/* only if the axis in question is locked, not editable... */
if ((index == 0) && (ob->protectflag & OB_LOCK_LOCX))
return 0;
@@ -859,7 +847,7 @@ static int rna_Object_location_editable(PointerRNA *ptr, int index)
static int rna_Object_scale_editable(PointerRNA *ptr, int index)
{
Object *ob = (Object *)ptr->data;
-
+
/* only if the axis in question is locked, not editable... */
if ((index == 0) && (ob->protectflag & OB_LOCK_SCALEX))
return 0;
@@ -874,7 +862,7 @@ static int rna_Object_scale_editable(PointerRNA *ptr, int index)
static int rna_Object_rotation_euler_editable(PointerRNA *ptr, int index)
{
Object *ob = (Object *)ptr->data;
-
+
/* only if the axis in question is locked, not editable... */
if ((index == 0) && (ob->protectflag & OB_LOCK_ROTX))
return 0;
@@ -889,7 +877,7 @@ static int rna_Object_rotation_euler_editable(PointerRNA *ptr, int index)
static int rna_Object_rotation_4d_editable(PointerRNA *ptr, int index)
{
Object *ob = (Object *)ptr->data;
-
+
/* only consider locks if locking components individually... */
if (ob->protectflag & OB_LOCK_ROT4D) {
/* only if the axis in question is locked, not editable... */
@@ -902,7 +890,7 @@ static int rna_Object_rotation_4d_editable(PointerRNA *ptr, int index)
else if ((index == 3) && (ob->protectflag & OB_LOCK_ROTZ))
return 0;
}
-
+
return PROP_EDITABLE;
}
@@ -922,7 +910,7 @@ static void rna_MaterialSlot_material_set(PointerRNA *ptr, PointerRNA value)
Object *ob = (Object *)ptr->id.data;
int index = (Material **)ptr->data - ob->mat;
- assign_material(ob, value.data, index + 1, BKE_MAT_ASSIGN_EXISTING);
+ assign_material(G.main, ob, value.data, index + 1, BKE_MAT_ASSIGN_EXISTING);
}
static int rna_MaterialSlot_link_get(PointerRNA *ptr)
@@ -937,7 +925,7 @@ static void rna_MaterialSlot_link_set(PointerRNA *ptr, int value)
{
Object *ob = (Object *)ptr->id.data;
int index = (Material **)ptr->data - ob->mat;
-
+
if (value) {
ob->matbits[index] = 1;
/* ob->colbits |= (1 << index); */ /* DEPRECATED */
@@ -958,7 +946,7 @@ static int rna_MaterialSlot_name_length(PointerRNA *ptr)
if (ma)
return strlen(ma->id.name + 2);
-
+
return 0;
}
@@ -1051,7 +1039,7 @@ static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr)
if (key == NULL)
return PointerRNA_NULL;
-
+
kb = BLI_findlink(&key->block, ob->shapenr - 1);
RNA_pointer_create((ID *)key, &RNA_ShapeKey, kb, &keyptr);
return keyptr;
@@ -1064,7 +1052,7 @@ static PointerRNA rna_Object_field_get(PointerRNA *ptr)
/* weak */
if (!ob->pd)
ob->pd = object_add_collision_fields(0);
-
+
return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, ob->pd);
}
@@ -1078,7 +1066,7 @@ static PointerRNA rna_Object_collision_get(PointerRNA *ptr)
/* weak */
if (!ob->pd)
ob->pd = object_add_collision_fields(0);
-
+
return rna_pointer_inherit_refine(ptr, &RNA_CollisionSettings, ob->pd);
}
@@ -1095,17 +1083,17 @@ static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value)
BKE_constraints_active_set(&ob->constraints, (bConstraint *)value.data);
}
-static bConstraint *rna_Object_constraints_new(Object *object, int type)
+static bConstraint *rna_Object_constraints_new(Object *object, Main *bmain, int type)
{
bConstraint *new_con = BKE_constraint_add_for_object(object, NULL, type);
- ED_object_constraint_tag_update(object, new_con);
+ ED_object_constraint_tag_update(bmain, object, new_con);
WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, object);
return new_con;
}
-static void rna_Object_constraints_remove(Object *object, ReportList *reports, PointerRNA *con_ptr)
+static void rna_Object_constraints_remove(Object *object, Main *bmain, ReportList *reports, PointerRNA *con_ptr)
{
bConstraint *con = con_ptr->data;
if (BLI_findindex(&object->constraints, con) == -1) {
@@ -1116,16 +1104,16 @@ static void rna_Object_constraints_remove(Object *object, ReportList *reports, P
BKE_constraint_remove(&object->constraints, con);
RNA_POINTER_INVALIDATE(con_ptr);
- ED_object_constraint_update(object);
+ ED_object_constraint_update(bmain, object);
ED_object_constraint_set_active(object, NULL);
WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
}
-static void rna_Object_constraints_clear(Object *object)
+static void rna_Object_constraints_clear(Object *object, Main *bmain)
{
BKE_constraints_free(&object->constraints);
- ED_object_constraint_update(object);
+ ED_object_constraint_update(bmain, object);
ED_object_constraint_set_active(object, NULL);
WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
@@ -1432,12 +1420,6 @@ int rna_Lamp_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
return ((Object *)value.id.data)->type == OB_LAMP;
}
-int rna_DupliObject_index_get(PointerRNA *ptr)
-{
- DupliObject *dob = (DupliObject *)ptr->data;
- return dob->persistent_id[0];
-}
-
int rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr)
{
SculptSession *ss = ((Object *)ptr->id.data)->sculpt;
@@ -1471,7 +1453,7 @@ static void rna_def_vertex_group(BlenderRNA *brna)
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_VertexGroup_name_set");
/* update data because modifiers may use [#24761] */
RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
-
+
prop = RNA_def_property(srna, "lock_weight", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "", "Maintain the relative weights for the group");
RNA_def_property_boolean_sdna(prop, NULL, "flag", 0);
@@ -1527,7 +1509,7 @@ static void rna_def_face_map(BlenderRNA *brna)
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_FaceMap_name_set");
/* update data because modifiers may use [#24761] */
RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
-
+
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
RNA_def_property_ui_text(prop, "Select", "Face-map selection state (for tools to use)");
@@ -1563,7 +1545,7 @@ static void rna_def_material_slot(BlenderRNA *brna)
{0, "DATA", 0, "Data", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
/* NOTE: there is no MaterialSlot equivalent in DNA, so the internal
* pointer data points to ob->mat + index, and we manually implement
* get/set for the properties. */
@@ -1572,19 +1554,23 @@ static void rna_def_material_slot(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Material Slot", "Material slot in an object");
RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
+ /* WARNING! Order is crucial for override to work properly here... :/
+ * 'link' must come before material pointer, since it defines where (in object or obdata) that one is set! */
+ prop = RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, link_items);
+ RNA_def_property_enum_funcs(prop, "rna_MaterialSlot_link_get", "rna_MaterialSlot_link_set", NULL);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
+ RNA_def_property_ui_text(prop, "Link", "Link material to object or the object's data");
+ RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
+
prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Material");
RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_pointer_funcs(prop, "rna_MaterialSlot_material_get", "rna_MaterialSlot_material_set", NULL, NULL);
RNA_def_property_ui_text(prop, "Material", "Material data-block used by this material slot");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
- prop = RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, link_items);
- RNA_def_property_enum_funcs(prop, "rna_MaterialSlot_link_get", "rna_MaterialSlot_link_set", NULL);
- RNA_def_property_ui_text(prop, "Link", "Link material to object or the object's data");
- RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
-
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, "rna_MaterialSlot_name_get", "rna_MaterialSlot_name_length", NULL);
RNA_def_property_ui_text(prop, "Name", "Material slot name");
@@ -1620,6 +1606,7 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
/* Constraint collection */
func = RNA_def_function(srna, "new", "rna_Object_constraints_new");
RNA_def_function_ui_description(func, "Add a new constraint to this object");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
/* object to add */
parm = RNA_def_enum(func, "type", rna_enum_constraint_type_items, 1, "", "Constraint type to add");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
@@ -1629,13 +1616,14 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "remove", "rna_Object_constraints_remove");
RNA_def_function_ui_description(func, "Remove a constraint from this object");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
/* constraint to remove */
parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
func = RNA_def_function(srna, "clear", "rna_Object_constraints_clear");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
RNA_def_function_ui_description(func, "Remove all constraint from this object");
}
@@ -1697,7 +1685,7 @@ static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
-
+
PropertyRNA *prop;
/* FunctionRNA *func; */
@@ -1713,7 +1701,7 @@ static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop
RNA_def_property_pointer_funcs(prop, "rna_Object_active_particle_system_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Active Particle System", "Active particle system being displayed");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
-
+
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_funcs(prop, "rna_Object_active_particle_system_index_get",
@@ -1728,7 +1716,7 @@ static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop
static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
-
+
PropertyRNA *prop;
FunctionRNA *func;
@@ -1754,7 +1742,7 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop)
"rna_Object_active_vertex_group_index_range");
RNA_def_property_ui_text(prop, "Active Vertex Group Index", "Active index in vertex group array");
RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
-
+
/* vertex groups */ /* add_vertex_group */
func = RNA_def_function(srna, "new", "rna_Object_vgroup_new");
RNA_def_function_ui_description(func, "Add vertex group to object");
@@ -1777,7 +1765,7 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop)
static void rna_def_object_face_maps(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
-
+
PropertyRNA *prop;
FunctionRNA *func;
@@ -1803,7 +1791,7 @@ static void rna_def_object_face_maps(BlenderRNA *brna, PropertyRNA *cprop)
"rna_Object_active_face_map_index_range");
RNA_def_property_ui_text(prop, "Active Face Map Index", "Active index in face map array");
RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
-
+
/* face maps */ /* add_face_map */
func = RNA_def_function(srna, "new", "rna_Object_fmap_new");
RNA_def_function_ui_description(func, "Add face map to object");
@@ -1869,7 +1857,7 @@ static void rna_def_object(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
-
+
/* XXX: this RNA enum define is currently duplicated for objects,
* since there is some text here which is not applicable */
static const EnumPropertyItem prop_rotmode_items[] = {
@@ -1884,7 +1872,7 @@ static void rna_def_object(BlenderRNA *brna)
"Axis Angle (W+XYZ), defines a rotation around some axis defined by 3D-Vector"},
{0, NULL, 0, NULL, NULL}
};
-
+
static float default_quat[4] = {1, 0, 0, 0}; /* default quaternion values */
static float default_axisAngle[4] = {0, 0, 1, 0}; /* default axis-angle rotation values */
static float default_scale[3] = {1, 1, 1}; /* default scale values */
@@ -1899,6 +1887,7 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "ID");
RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_data_set", "rna_Object_data_typef", NULL);
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Data", "Object data");
RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
@@ -1932,10 +1921,11 @@ static void rna_def_object(BlenderRNA *brna)
/* parent */
prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_parent_set", NULL, NULL);
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK | PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Parent", "Parent Object");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
-
+
prop = RNA_def_property(srna, "parent_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "partype");
RNA_def_property_enum_items(prop, parent_type_items);
@@ -1954,7 +1944,7 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Object_parent_bone_set");
RNA_def_property_ui_text(prop, "Parent Bone", "Name of parent bone in case of a bone parenting relation");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
-
+
/* Track and Up flags */
/* XXX: these have been saved here for a bit longer (after old track was removed),
* since some other tools still refer to this */
@@ -1973,7 +1963,7 @@ static void rna_def_object(BlenderRNA *brna)
"Axis that points in the upward direction (applies to DupliFrame when "
"parent 'Follow' is enabled)");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
-
+
/* proxy */
prop = RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Proxy", "Library object this proxy object controls");
@@ -1985,6 +1975,7 @@ static void rna_def_object(BlenderRNA *brna)
prop = RNA_def_property(srna, "material_slots", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
RNA_def_property_struct_type(prop, "MaterialSlot");
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC | PROPOVERRIDE_NO_PROP_NAME);
/* don't dereference pointer! */
RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", NULL, NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Material Slots", "Material slots in the object");
@@ -2001,28 +1992,29 @@ static void rna_def_object(BlenderRNA *brna)
prop = RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "actcol");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set",
"rna_Object_active_material_index_range");
RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, NULL);
-
+
/* transform */
prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "loc");
RNA_def_property_editable_array_func(prop, "rna_Object_location_editable");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Location", "Location of the object");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
-
+
prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
RNA_def_property_float_sdna(prop, NULL, "quat");
RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_float_array_default(prop, default_quat);
RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions");
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
-
+
/* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but
* having a single one is better for Keyframing and other property-management situations...
*/
@@ -2032,27 +2024,28 @@ static void rna_def_object(BlenderRNA *brna)
"rna_Object_rotation_axis_angle_set", NULL);
RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
RNA_def_property_float_array_default(prop, default_axisAngle);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation");
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
-
+
prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
RNA_def_property_float_sdna(prop, NULL, "rot");
RNA_def_property_editable_array_func(prop, "rna_Object_rotation_euler_editable");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers");
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
-
+
prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "rotmode");
RNA_def_property_enum_items(prop, prop_rotmode_items); /* XXX move to using a single define of this someday */
RNA_def_property_enum_funcs(prop, NULL, "rna_Object_rotation_mode_set", NULL);
RNA_def_property_ui_text(prop, "Rotation Mode", "");
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
-
+
prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "size");
- RNA_def_property_flag(prop, PROP_PROPORTIONAL | PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_flag(prop, PROP_PROPORTIONAL);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
RNA_def_property_float_array_default(prop, default_scale);
@@ -2067,7 +2060,7 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_ui_text(prop, "Dimensions", "Absolute bounding box dimensions of the object");
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
-
+
/* delta transforms */
prop = RNA_def_property(srna, "delta_location", PROP_FLOAT, PROP_TRANSLATION);
@@ -2075,20 +2068,20 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Delta Location", "Extra translation added to the location of the object");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
-
+
prop = RNA_def_property(srna, "delta_rotation_euler", PROP_FLOAT, PROP_EULER);
RNA_def_property_float_sdna(prop, NULL, "drot");
RNA_def_property_ui_text(prop, "Delta Rotation (Euler)",
"Extra rotation added to the rotation of the object (when using Euler rotations)");
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
-
+
prop = RNA_def_property(srna, "delta_rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
RNA_def_property_float_sdna(prop, NULL, "dquat");
RNA_def_property_float_array_default(prop, default_quat);
RNA_def_property_ui_text(prop, "Delta Rotation (Quaternion)",
"Extra rotation added to the rotation of the object (when using Quaternion rotations)");
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
-
+
#if 0 /* XXX not supported well yet... */
prop = RNA_def_property(srna, "delta_rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
/* FIXME: this is not a single field any more! (drotAxis and drotAngle) */
@@ -2106,7 +2099,7 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_float_array_default(prop, default_scale);
RNA_def_property_ui_text(prop, "Delta Scale", "Extra scaling added to the scale of the object");
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
-
+
/* transform locks */
prop = RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX);
@@ -2121,7 +2114,7 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface");
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
-
+
/* XXX this is sub-optimal - it really should be included above,
* but due to technical reasons we can't do this! */
prop = RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE);
@@ -2180,13 +2173,13 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "Modifier");
RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the geometric data of the object");
RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Object_modifiers_override_apply");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC | PROP_OVERRIDABLE_STATIC_INSERTION);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC | PROPOVERRIDE_STATIC_INSERTION);
rna_def_object_modifiers(brna, prop);
/* constraints */
prop = RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "Constraint");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC | PROP_OVERRIDABLE_STATIC_INSERTION);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC | PROPOVERRIDE_STATIC_INSERTION);
RNA_def_property_ui_text(prop, "Constraints", "Constraints affecting the transformation of the object");
RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Object_constraints_override_apply");
/* RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "constraints__add", "constraints__remove"); */
@@ -2199,14 +2192,14 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Vertex Groups", "Vertex groups of the object");
rna_def_object_vertex_groups(brna, prop);
-
+
/* face maps */
prop = RNA_def_property(srna, "face_maps", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fmaps", NULL);
RNA_def_property_struct_type(prop, "FaceMap");
RNA_def_property_ui_text(prop, "Face Maps", "Maps of faces of the object");
rna_def_object_face_maps(brna, prop);
-
+
/* empty */
prop = RNA_def_property(srna, "empty_draw_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "empty_drawtype");
@@ -2240,7 +2233,7 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "index");
RNA_def_property_ui_text(prop, "Pass Index", "Index number for the \"Object Index\" render pass");
RNA_def_property_update(prop, NC_OBJECT, "rna_Object_internal_update_draw");
-
+
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "col");
RNA_def_property_ui_text(prop, "Color", "Object color and alpha, used when faces have the ObColor mode enabled");
@@ -2271,7 +2264,7 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object");
rna_def_object_particle_systems(brna, prop);
-
+
prop = RNA_def_property(srna, "rigid_body", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "rigidbody_object");
RNA_def_property_struct_type(prop, "RigidBodyObject");
@@ -2281,7 +2274,7 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "rigidbody_constraint");
RNA_def_property_struct_type(prop, "RigidBodyConstraint");
RNA_def_property_ui_text(prop, "Rigid Body Constraint", "Constraint constraining rigid bodies");
-
+
/* restrict */
prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER);
@@ -2295,19 +2288,14 @@ static void rna_def_object(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_duplicator_for_viewport", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "duplicator_visibility_flag", OB_DUPLI_FLAG_VIEWPORT);
- RNA_def_property_ui_text(prop, "Show Duplicator", "Make duplicator visible in the viewport");
-
- prop = RNA_def_property(srna, "is_visible", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_Object_is_visible_get", NULL);
- RNA_def_property_ui_text(prop, "Visible", "Visible to camera rays, set only on objects evaluated by depsgraph");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Display Duplicator", "Make duplicator visible in the viewport");
/* anim */
rna_def_animdata_common(srna);
-
+
rna_def_animviz_common(srna);
rna_def_motionpath_common(srna);
-
+
/* slow parenting */
/* XXX: evil old crap */
prop = RNA_def_property(srna, "use_slow_parent", PROP_BOOLEAN, PROP_NONE);
@@ -2316,7 +2304,7 @@ static void rna_def_object(BlenderRNA *brna)
"Create a delay in the parent relationship (beware: this isn't renderfarm "
"safe and may be invalid after jumping around the timeline)");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
-
+
prop = RNA_def_property(srna, "slow_parent_offset", PROP_FLOAT, PROP_NONE | PROP_UNIT_TIME);
RNA_def_property_float_sdna(prop, NULL, "sf");
RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
@@ -2390,7 +2378,7 @@ static void rna_def_object(BlenderRNA *brna)
prop = RNA_def_property(srna, "is_duplicator", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLI);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
+
/* drawing */
prop = RNA_def_property(srna, "draw_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "dt");
@@ -2408,22 +2396,22 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_enum_items(prop, boundtype_items);
RNA_def_property_ui_text(prop, "Draw Bounds Type", "Object boundary display type");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
-
+
prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWNAME);
RNA_def_property_ui_text(prop, "Draw Name", "Display the object's name");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
-
+
prop = RNA_def_property(srna, "show_axis", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_AXIS);
RNA_def_property_ui_text(prop, "Draw Axes", "Display the object's origin and axes");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
-
+
prop = RNA_def_property(srna, "show_texture_space", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_TEXSPACE);
RNA_def_property_ui_text(prop, "Draw Texture Space", "Display the object's texture space");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
-
+
prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWWIRE);
RNA_def_property_ui_text(prop, "Draw Wire", "Add the object's wireframe over solid drawing");
@@ -2439,13 +2427,13 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Draw Transparent",
"Display material transparency in the object (unsupported for duplicator drawing)");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
-
+
prop = RNA_def_property(srna, "show_x_ray", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWXRAY);
RNA_def_property_ui_text(prop, "X-Ray",
"Make the object draw in front of others (unsupported for duplicator drawing)");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
-
+
/* Grease Pencil */
prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "gpd");
@@ -2453,7 +2441,7 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil data-block");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
-
+
/* pose */
prop = RNA_def_property(srna, "pose_library", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "poselib");
@@ -2464,7 +2452,7 @@ static void rna_def_object(BlenderRNA *brna)
prop = RNA_def_property(srna, "pose", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "pose");
RNA_def_property_struct_type(prop, "Pose");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Pose", "Current pose for armatures");
/* shape keys */
@@ -2520,64 +2508,6 @@ static void rna_def_object(BlenderRNA *brna)
RNA_api_object(srna);
}
-static void rna_def_dupli_object(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "DupliObject", NULL);
- RNA_def_struct_sdna(srna, "DupliObject");
- RNA_def_struct_ui_text(srna, "Object Duplicate", "An object duplicate");
- /* RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA); */
-
- prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "ob");
- /* RNA_def_property_pointer_funcs(prop, "rna_DupliObject_object_get", NULL, NULL, NULL); */
- RNA_def_property_ui_text(prop, "Object", "Object being duplicated");
-
- prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
- RNA_def_property_float_sdna(prop, NULL, "mat");
- RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Object Duplicate Matrix", "Object duplicate transformation matrix");
-
- prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "no_draw", 0);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Hide", "Don't show dupli object in viewport or render");
-
- prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
- RNA_def_property_int_funcs(prop, "rna_DupliObject_index_get", NULL, NULL);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Index", "Index in the lowest-level dupli list");
-
- prop = RNA_def_property(srna, "persistent_id", PROP_INT, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Persistent ID", "Persistent identifier for inter-frame matching of objects with motion blur");
-
- prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Particle System", "Particle system that this dupli object was instanced from");
-
- prop = RNA_def_property(srna, "orco", PROP_FLOAT, PROP_TRANSLATION);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Generated Coordinates", "Generated coordinates in parent object space");
-
- prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE);
- RNA_def_property_array(prop, 2);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space");
-
- prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, dupli_items);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Dupli Type", "Duplicator type that generated this dupli object");
-
- prop = RNA_def_property(srna, "random_id", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Dupli random id", "Random id for this dupli object");
-}
-
void RNA_def_object(BlenderRNA *brna)
{
rna_def_object(brna);
@@ -2586,7 +2516,6 @@ void RNA_def_object(BlenderRNA *brna)
rna_def_vertex_group(brna);
rna_def_face_map(brna);
rna_def_material_slot(brna);
- rna_def_dupli_object(brna);
rna_def_object_display(brna);
RNA_define_animate_sdna(true);
}
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index a01192dad68..fb27af7c464 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -218,7 +218,7 @@ static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList *
RNA_pointer_create((ID *)ob->data, &RNA_ShapeKey, kb, &keyptr);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
-
+
return keyptr;
}
else {
@@ -355,7 +355,7 @@ static void rna_Object_closest_point_on_mesh(
int *r_success, float r_location[3], float r_normal[3], int *r_index)
{
BVHTreeFromMesh treeData = {NULL};
-
+
if (ob->derivedFinal == NULL) {
BKE_reportf(reports, RPT_ERROR, "Object '%s' has no mesh data to be used for finding nearest point",
ob->id.name + 2);
@@ -445,10 +445,10 @@ void rna_Object_dm_info(struct Object *ob, int type, char *result)
}
#endif /* NDEBUG */
-static int rna_Object_update_from_editmode(Object *ob)
+static int rna_Object_update_from_editmode(Object *ob, Main *bmain)
{
/* fail gracefully if we aren't in edit-mode. */
- return ED_object_editmode_load(ob);
+ return ED_object_editmode_load(bmain, ob);
}
#else /* RNA_RUNTIME */
@@ -591,7 +591,7 @@ void RNA_api_object(StructRNA *srna)
func = RNA_def_function(srna, "ray_cast", "rna_Object_ray_cast");
RNA_def_function_ui_description(func, "Cast a ray onto in object space");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
-
+
/* ray start and end */
parm = RNA_def_float_vector(func, "origin", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
@@ -676,6 +676,7 @@ void RNA_api_object(StructRNA *srna)
func = RNA_def_function(srna, "update_from_editmode", "rna_Object_update_from_editmode");
RNA_def_function_ui_description(func, "Load the objects edit-mode data into the object data");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
parm = RNA_def_boolean(func, "result", 0, "", "Success");
RNA_def_function_return(func, parm);
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index 4c09f7cf4cf..b79dee63136 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -219,7 +219,7 @@ static void rna_Cache_active_point_cache_index_range(PointerRNA *ptr, int *min,
Object *ob = ptr->id.data;
PointCache *cache = ptr->data;
PTCacheID pid = BKE_ptcache_id_find(ob, NULL, cache);
-
+
*min = 0;
*max = 0;
@@ -247,7 +247,7 @@ static void rna_Cache_active_point_cache_index_set(struct PointerRNA *ptr, int v
Object *ob = ptr->id.data;
PointCache *cache = ptr->data;
PTCacheID pid = BKE_ptcache_id_find(ob, NULL, cache);
-
+
if (pid.cache) {
*(pid.cache_ptr) = BLI_findlink(pid.ptcaches, value);
}
@@ -527,13 +527,13 @@ static void rna_FieldSettings_dependency_update(Main *bmain, Scene *scene, Point
static char *rna_FieldSettings_path(PointerRNA *ptr)
{
PartDeflect *pd = (PartDeflect *)ptr->data;
-
+
/* Check through all possible places the settings can be to find the right one */
-
+
if (particle_id_check(ptr)) {
/* particle system force field */
ParticleSettings *part = (ParticleSettings *)ptr->id.data;
-
+
if (part->pd == pd)
return BLI_sprintfN("force_field_1");
else if (part->pd2 == pd)
@@ -542,7 +542,7 @@ static char *rna_FieldSettings_path(PointerRNA *ptr)
else {
/* object force field */
Object *ob = (Object *)ptr->id.data;
-
+
if (ob->pd == pd)
return BLI_sprintfN("field");
}
@@ -580,11 +580,11 @@ static char *rna_EffectorWeight_path(PointerRNA *ptr)
{
EffectorWeights *ew = (EffectorWeights *)ptr->data;
/* Check through all possible places the settings can be to find the right one */
-
+
if (particle_id_check(ptr)) {
/* particle effector weights */
ParticleSettings *part = (ParticleSettings *)ptr->id.data;
-
+
if (part->effector_weights == ew)
return BLI_sprintfN("effector_weights");
}
@@ -602,7 +602,7 @@ static char *rna_EffectorWeight_path(PointerRNA *ptr)
return BLI_sprintfN("modifiers[\"%s\"].settings.effector_weights", name_esc);
}
}
-
+
/* check cloth modifier */
md = (ModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
if (md) {
@@ -613,7 +613,7 @@ static char *rna_EffectorWeight_path(PointerRNA *ptr)
return BLI_sprintfN("modifiers[\"%s\"].settings.effector_weights", name_esc);
}
}
-
+
/* check smoke modifier */
md = (ModifierData *)modifiers_findByType(ob, eModifierType_Smoke);
if (md) {
@@ -693,9 +693,9 @@ static const EnumPropertyItem *rna_Effector_shape_itemf(bContext *UNUSED(C), Poi
if (particle_id_check(ptr))
return empty_shape_items;
-
+
ob = (Object *)ptr->id.data;
-
+
if (ob->type == OB_CURVE) {
if (ob->pd->forcefield == PFIELD_VORTEX)
return curve_vortex_shape_items;
@@ -880,44 +880,44 @@ static void rna_def_collision(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "PartDeflect");
RNA_def_struct_path_func(srna, "rna_CollisionSettings_path");
RNA_def_struct_ui_text(srna, "Collision Settings", "Collision settings for object in physics simulation");
-
+
prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "deflect", 1);
RNA_def_property_ui_text(prop, "Enabled", "Enable this objects as a collider for physics systems");
RNA_def_property_update(prop, 0, "rna_CollisionSettings_dependency_update");
-
+
/* Particle Interaction */
-
+
prop = RNA_def_property(srna, "damping_factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "pdef_damp");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Damping Factor", "Amount of damping during particle collision");
RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
-
+
prop = RNA_def_property(srna, "damping_random", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "pdef_rdamp");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Random Damping", "Random variation of damping");
RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
-
+
prop = RNA_def_property(srna, "friction_factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "pdef_frict");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Friction Factor", "Amount of friction during particle collision");
RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
-
+
prop = RNA_def_property(srna, "friction_random", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "pdef_rfrict");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Random Friction", "Random variation of friction");
RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
-
+
prop = RNA_def_property(srna, "permeability", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "pdef_perm");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Permeability", "Chance that the particle will pass through the mesh");
RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
-
+
prop = RNA_def_property(srna, "use_particle_kill", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PDEFLE_KILL_PART);
RNA_def_property_ui_text(prop, "Kill Particles", "Kill collided particles");
@@ -928,21 +928,21 @@ static void rna_def_collision(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(prop, "Stickiness", "Amount of stickiness to surface collision");
RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
-
+
/* Soft Body and Cloth Interaction */
-
+
prop = RNA_def_property(srna, "thickness_inner", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "pdef_sbift");
RNA_def_property_range(prop, 0.001f, 1.0f);
RNA_def_property_ui_text(prop, "Inner Thickness", "Inner face thickness (only used by softbodies)");
RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
-
+
prop = RNA_def_property(srna, "thickness_outer", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "pdef_sboft");
RNA_def_property_range(prop, 0.001f, 1.0f);
RNA_def_property_ui_text(prop, "Outer Thickness", "Outer face thickness");
RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
-
+
prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "pdef_sbdamp");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -973,7 +973,7 @@ static void rna_def_effector_weight(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", EFF_WEIGHT_DO_HAIR);
RNA_def_property_ui_text(prop, "Use For Growing Hair", "Use force fields when growing hair");
RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
-
+
/* General */
prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Collection");
@@ -1092,7 +1092,7 @@ static void rna_def_field(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem field_type_items[] = {
{0, "NONE", 0, "None", ""},
{PFIELD_FORCE, "FORCE", ICON_FORCE_FORCE, "Force", "Radial field toward the center of object"},
@@ -1122,7 +1122,7 @@ static void rna_def_field(BlenderRNA *brna)
{PFIELD_FALL_CONE, "CONE", 0, "Cone", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem texture_items[] = {
{PFIELD_TEX_RGB, "RGB", 0, "RGB", ""},
{PFIELD_TEX_GRAD, "GRADIENT", 0, "Gradient", ""},
@@ -1136,7 +1136,7 @@ static void rna_def_field(BlenderRNA *brna)
{PFIELD_Z_NEG, "NEGATIVE", 0, "-Z", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem guide_kink_items[] = {
{0, "NONE", 0, "Nothing", ""},
{1, "CURL", 0, "Curl", ""},
@@ -1153,9 +1153,9 @@ static void rna_def_field(BlenderRNA *brna)
RNA_def_struct_path_func(srna, "rna_FieldSettings_path");
RNA_def_struct_ui_text(srna, "Field Settings", "Field settings for an object in physics simulation");
RNA_def_struct_ui_icon(srna, ICON_PHYSICS);
-
+
/* Enums */
-
+
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "forcefield");
RNA_def_property_enum_items(prop, field_type_items);
@@ -1168,13 +1168,13 @@ static void rna_def_field(BlenderRNA *brna)
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Effector_shape_itemf");
RNA_def_property_ui_text(prop, "Shape", "Which direction is used to calculate the effector force");
RNA_def_property_update(prop, 0, "rna_FieldSettings_shape_update");
-
+
prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "falloff");
RNA_def_property_enum_items(prop, falloff_items);
RNA_def_property_ui_text(prop, "Fall-Off", "");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "texture_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "tex_mode");
RNA_def_property_enum_items(prop, texture_items);
@@ -1188,9 +1188,9 @@ static void rna_def_field(BlenderRNA *brna)
RNA_def_property_enum_items(prop, zdirection_items);
RNA_def_property_ui_text(prop, "Z Direction", "Effect in full or only positive/negative Z direction");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
/* Float */
-
+
prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "f_strength");
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
@@ -1242,38 +1242,38 @@ static void rna_def_field(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Rest Length", "Rest length of the harmonic force");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "falloff_power", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "f_power");
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(prop, "Falloff Power", "");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "distance_min", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "mindist");
RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Minimum Distance", "Minimum distance for the field's fall-off");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "distance_max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "maxdist");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0f, 1000.0f, 1.0f, 3);
RNA_def_property_ui_text(prop, "Maximum Distance", "Maximum distance for the field to work");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "radial_min", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "minrad");
RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Minimum Radial Distance", "Minimum radial distance for the field's fall-off");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "radial_max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "maxrad");
RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Maximum Radial Distance", "Maximum radial distance for the field to work");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "radial_falloff", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "f_power_r");
RNA_def_property_range(prop, 0.0f, 10.0f);
@@ -1286,7 +1286,7 @@ static void rna_def_field(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Nabla",
"Defines size of derivative offset used for calculating gradient and curl");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "noise", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "f_noise");
RNA_def_property_range(prop, 0.0f, 10.0f);
@@ -1299,23 +1299,23 @@ static void rna_def_field(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
/* Boolean */
-
+
prop = RNA_def_property(srna, "use_min_distance", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USEMIN);
RNA_def_property_ui_text(prop, "Use Min", "Use a minimum distance for the field's fall-off");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "use_max_distance", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USEMAX);
RNA_def_property_ui_text(prop, "Use Max", "Use a maximum distance for the field to work");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "use_radial_min", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USEMINR);
RNA_def_property_ui_text(prop, "Use Min", "Use a minimum radial distance for the field's fall-off");
/* "Use a minimum angle for the field's fall-off" */
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "use_radial_max", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USEMAXR);
RNA_def_property_ui_text(prop, "Use Max", "Use a maximum radial distance for the field to work");
@@ -1331,12 +1331,12 @@ static void rna_def_field(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_GLOBAL_CO);
RNA_def_property_ui_text(prop, "Use Global Coordinates", "Use effector/global coordinates for turbulence");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "use_2d_force", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_TEX_2D);
RNA_def_property_ui_text(prop, "2D", "Apply force only in 2D");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "use_root_coords", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_TEX_ROOTCO);
RNA_def_property_ui_text(prop, "Root Texture Coordinates", "Texture coordinates from root particle locations");
@@ -1371,9 +1371,9 @@ static void rna_def_field(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Gravity Falloff", "Multiply force by 1/distance²");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
/* Pointer */
-
+
prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "tex");
RNA_def_property_flag(prop, PROP_EDITABLE);
@@ -1385,9 +1385,9 @@ static void rna_def_field(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Domain Object", "Select domain object of the smoke simulation");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
/********** Curve Guide Field Settings **********/
-
+
prop = RNA_def_property(srna, "guide_minimum", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "f_strength");
RNA_def_property_range(prop, 0.0f, 1000.0f);
@@ -1409,29 +1409,29 @@ static void rna_def_field(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_GUIDE_PATH_WEIGHT);
RNA_def_property_ui_text(prop, "Weights", "Use curve weights to influence the particle influence along the curve");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
/* Clump Settings */
-
+
prop = RNA_def_property(srna, "guide_clump_amount", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "clump_fac");
RNA_def_property_range(prop, -1.0f, 1.0f);
RNA_def_property_ui_text(prop, "Amount", "Amount of clumping");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "guide_clump_shape", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "clump_pow");
RNA_def_property_range(prop, -0.999f, 0.999f);
RNA_def_property_ui_text(prop, "Shape", "Shape of clumping");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
/* Kink Settings */
-
+
prop = RNA_def_property(srna, "guide_kink_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "kink");
RNA_def_property_enum_items(prop, guide_kink_items);
RNA_def_property_ui_text(prop, "Kink", "Type of periodic offset on the curve");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "guide_kink_axis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "kink_axis");
RNA_def_property_enum_items(prop, rna_enum_axis_xyz_items);
@@ -1443,13 +1443,13 @@ static void rna_def_field(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(prop, "Frequency", "The frequency of the offset (1/total length)");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "guide_kink_shape", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kink_shape");
RNA_def_property_range(prop, -0.999f, 0.999f);
RNA_def_property_ui_text(prop, "Shape", "Adjust the offset to the beginning/end");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
-
+
prop = RNA_def_property(srna, "guide_kink_amplitude", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kink_amp");
RNA_def_property_range(prop, 0.0f, 10.0f);
@@ -1464,7 +1464,7 @@ static void rna_def_softbody(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem collision_type_items[] = {
{SBC_MODE_MANUAL, "MANUAL", 0, "Manual", "Manual adjust"},
{SBC_MODE_AVG, "AVERAGE", 0, "Average", "Average Spring length * Ball Size"},
@@ -1473,7 +1473,7 @@ static void rna_def_softbody(BlenderRNA *brna)
{SBC_MODE_AVGMINMAX, "MINMAX", 0, "AvMinMax", "(Min+Max)/2 * Ball Size"},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem aerodynamics_type[] = {
{0, "SIMPLE", 0, "Simple", "Edges receive a drag force from surrounding media"},
{1, "LIFT_FORCE", 0, "Lift Force", "Edges receive a lift force when passing through surrounding media"},
@@ -1484,42 +1484,42 @@ static void rna_def_softbody(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "SoftBody");
RNA_def_struct_path_func(srna, "rna_SoftBodySettings_path");
RNA_def_struct_ui_text(srna, "Soft Body Settings", "Soft body simulation settings for an object");
-
+
/* General Settings */
-
+
prop = RNA_def_property(srna, "friction", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "mediafrict");
RNA_def_property_range(prop, 0.0f, 50.0f);
RNA_def_property_ui_text(prop, "Friction", "General media friction for point movements");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "nodemass");
RNA_def_property_range(prop, 0.0f, 50000.0f);
RNA_def_property_ui_text(prop, "Mass", "General Mass value");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "vertex_group_mass", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "namedVG_Mass");
RNA_def_property_ui_text(prop, "Mass Vertex Group", "Control point mass values");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SoftBodySettings_mass_vgroup_set");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
/* no longer used */
prop = RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION);
RNA_def_property_float_sdna(prop, NULL, "grav");
RNA_def_property_range(prop, -10.0f, 10.0f);
RNA_def_property_ui_text(prop, "Gravitation", "Apply gravitation to point movement");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "speed", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "physics_speed");
RNA_def_property_range(prop, 0.01f, 100.0f);
RNA_def_property_ui_text(prop, "Speed", "Tweak timing for physics to control frequency and speed");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
/* Goal */
-
+
prop = RNA_def_property(srna, "vertex_group_goal", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "vertgroup");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* not impossible .. but not supported yet */
@@ -1527,7 +1527,7 @@ static void rna_def_softbody(BlenderRNA *brna)
"rna_SoftBodySettings_goal_vgroup_length",
"rna_SoftBodySettings_goal_vgroup_set");
RNA_def_property_ui_text(prop, "Goal Vertex Group", "Control point weight values");
-
+
prop = RNA_def_property(srna, "goal_min", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "mingoal");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -1547,104 +1547,104 @@ static void rna_def_softbody(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Goal Default",
"Default Goal (vertex target position) value");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "goal_spring", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "goalspring");
RNA_def_property_range(prop, 0.0f, 0.999f);
RNA_def_property_ui_text(prop, "Goal Stiffness", "Goal (vertex target position) spring stiffness");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "goal_friction", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "goalfrict");
RNA_def_property_range(prop, 0.0f, 50.0f);
RNA_def_property_ui_text(prop, "Goal Damping", "Goal (vertex target position) friction");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
/* Edge Spring Settings */
-
+
prop = RNA_def_property(srna, "pull", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "inspring");
RNA_def_property_range(prop, 0.0f, 0.999f);
RNA_def_property_ui_text(prop, "Pull", "Edge spring stiffness when longer than rest length");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "push", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "inpush");
RNA_def_property_range(prop, 0.0f, 0.999f);
RNA_def_property_ui_text(prop, "Push", "Edge spring stiffness when shorter than rest length");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "infrict");
RNA_def_property_range(prop, 0.0f, 50.0f);
RNA_def_property_ui_text(prop, "Damp", "Edge spring friction");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "spring_length", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "springpreload");
RNA_def_property_range(prop, 0.0f, 200.0f);
RNA_def_property_ui_text(prop, "view_layer", "Alter spring length to shrink/blow up (unit %) 0 to disable");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "aero", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "aeroedge");
RNA_def_property_range(prop, 0.0f, 30000.0f);
RNA_def_property_ui_text(prop, "Aero", "Make edges 'sail'");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "plastic", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "plastic");
RNA_def_property_range(prop, 0.0f, 100.0f);
RNA_def_property_ui_text(prop, "Plastic", "Permanent deform");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "bend", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "secondspring");
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(prop, "Bending", "Bending Stiffness");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "shear", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "shearstiff");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Shear", "Shear Stiffness");
-
+
prop = RNA_def_property(srna, "vertex_group_spring", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "namedVG_Spring_K");
RNA_def_property_ui_text(prop, "Spring Vertex Group", "Control point spring strength values");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SoftBodySettings_spring_vgroup_set");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
/* Collision */
-
+
prop = RNA_def_property(srna, "collision_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "sbc_mode");
RNA_def_property_enum_items(prop, collision_type_items);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Collision Type", "Choose Collision Type");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "ball_size", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "colball");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* code is not ready for that yet */
RNA_def_property_range(prop, -10.0f, 10.0f);
RNA_def_property_ui_text(prop, "Ball Size", "Absolute ball size or factor if not manually adjusted");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "ball_stiff", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ballstiff");
RNA_def_property_range(prop, 0.001f, 100.0f);
RNA_def_property_ui_text(prop, "Ball Size", "Ball inflating pressure");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "ball_damp", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "balldamp");
RNA_def_property_range(prop, 0.001f, 1.0f);
RNA_def_property_ui_text(prop, "Ball Size", "Blending to inelastic collision");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
/* Solver */
-
+
prop = RNA_def_property(srna, "error_threshold", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "rklimit");
RNA_def_property_range(prop, 0.001f, 10.0f);
@@ -1652,25 +1652,25 @@ static void rna_def_softbody(BlenderRNA *brna)
"The Runge-Kutta ODE solver error limit, low value gives more precision, "
"high values speed");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "step_min", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "minloops");
RNA_def_property_range(prop, 0, 30000);
RNA_def_property_ui_text(prop, "Min Step", "Minimal # solver steps/frame");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "step_max", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "maxloops");
RNA_def_property_range(prop, 0, 30000);
RNA_def_property_ui_text(prop, "Max Step", "Maximal # solver steps/frame");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "choke", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "choke");
RNA_def_property_range(prop, 0, 100);
RNA_def_property_ui_text(prop, "Choke", "'Viscosity' inside collision target");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "fuzzy", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "fuzzyness");
RNA_def_property_range(prop, 1, 100);
@@ -1678,16 +1678,16 @@ static void rna_def_softbody(BlenderRNA *brna)
"Fuzziness while on collision, high values make collision handling faster "
"but less stable");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "use_auto_step", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "solverflags", SBSO_OLDERR);
RNA_def_property_ui_text(prop, "V", "Use velocities for automagic step sizes");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "use_diagnose", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "solverflags", SBSO_MONITOR);
RNA_def_property_ui_text(prop, "Print Performance to Console", "Turn on SB diagnose console prints");
-
+
prop = RNA_def_property(srna, "use_estimate_matrix", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "solverflags", SBSO_ESTIMATEIPO);
RNA_def_property_ui_text(prop, "Estimate matrix", "Estimate matrix... split to COM, ROT, SCALE");
@@ -1717,44 +1717,44 @@ static void rna_def_softbody(BlenderRNA *brna)
/* Flags */
-
+
prop = RNA_def_property(srna, "use_goal", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_SoftBodySettings_use_goal_get", "rna_SoftBodySettings_use_goal_set");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Use Goal", "Define forces for vertices to stick to animated position");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "use_edges", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_SoftBodySettings_use_edges_get", "rna_SoftBodySettings_use_edges_set");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Use Edges", "Use Edges as springs");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "use_stiff_quads", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_SoftBodySettings_stiff_quads_get",
"rna_SoftBodySettings_stiff_quads_set");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Stiff Quads", "Add diagonal springs on 4-gons");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "use_edge_collision", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_SoftBodySettings_edge_collision_get",
"rna_SoftBodySettings_edge_collision_set");
RNA_def_property_ui_text(prop, "Edge Collision", "Edges collide too");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "use_face_collision", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_SoftBodySettings_face_collision_get",
"rna_SoftBodySettings_face_collision_set");
RNA_def_property_ui_text(prop, "Face Collision", "Faces collide too, can be very slow");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "aerodynamics_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, aerodynamics_type);
RNA_def_property_enum_funcs(prop, "rna_SoftBodySettings_new_aero_get", "rna_SoftBodySettings_new_aero_set", NULL);
RNA_def_property_ui_text(prop, "Aerodynamics Type", "Method of calculating aerodynamic interaction");
RNA_def_property_update(prop, 0, "rna_softbody_update");
-
+
prop = RNA_def_property(srna, "use_self_collision", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_SoftBodySettings_self_collision_get",
"rna_SoftBodySettings_self_collision_set");
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 17e9a6604fd..573bbb5345b 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -115,7 +115,7 @@ static const EnumPropertyItem part_ren_as_items[] = {
{PART_DRAW_LINE, "LINE", 0, "Line", ""},
{PART_DRAW_PATH, "PATH", 0, "Path", ""},
{PART_DRAW_OB, "OBJECT", 0, "Object", ""},
- {PART_DRAW_GR, "GROUP", 0, "Group", ""},
+ {PART_DRAW_GR, "COLLECTION", 0, "Collection", ""},
{PART_DRAW_BB, "BILLBOARD", 0, "Billboard", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -125,7 +125,7 @@ static const EnumPropertyItem part_hair_ren_as_items[] = {
{PART_DRAW_NOT, "NONE", 0, "None", ""},
{PART_DRAW_PATH, "PATH", 0, "Path", ""},
{PART_DRAW_OB, "OBJECT", 0, "Object", ""},
- {PART_DRAW_GR, "GROUP", 0, "Group", ""},
+ {PART_DRAW_GR, "COLLECTION", 0, "Collection", ""},
{0, NULL, 0, NULL, NULL}
};
#endif
@@ -134,6 +134,7 @@ static const EnumPropertyItem part_hair_ren_as_items[] = {
#include "BLI_math.h"
+#include "BKE_boids.h"
#include "BKE_context.h"
#include "BKE_cloth.h"
#include "BKE_colortools.h"
@@ -301,7 +302,7 @@ static void rna_Particle_uv_on_emitter(ParticleData *particle, ReportList *repor
/* get uvco */
if (r_uv && ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) {
-
+
if (num != DMCACHE_NOTFOUND) {
MFace *mface;
MTFace *mtface;
@@ -341,7 +342,7 @@ static void rna_ParticleSystem_co_hair(ParticleSystem *particlesystem, Object *o
if (part == NULL || pars == NULL)
return;
-
+
if (part->ren_as == PART_DRAW_OB || part->ren_as == PART_DRAW_GR || part->ren_as == PART_DRAW_NOT)
return;
@@ -638,9 +639,31 @@ static void rna_Particle_change_type(Main *bmain, Scene *UNUSED(scene), PointerR
DEG_relations_tag_update(bmain);
}
-static void rna_Particle_change_physics(Main *bmain, Scene *scene, PointerRNA *ptr)
+static void rna_Particle_change_physics_type(Main *bmain, Scene *scene, PointerRNA *ptr)
{
particle_recalc(bmain, scene, ptr, PSYS_RECALC_RESET | PSYS_RECALC_PHYS);
+
+ ParticleSettings *part = (ParticleSettings *)ptr->data;
+
+ if (part->phystype == PART_PHYS_BOIDS && part->boids == NULL) {
+ BoidState *state;
+
+ part->boids = MEM_callocN(sizeof(BoidSettings), "Boid Settings");
+ boid_default_settings(part->boids);
+
+ state = boid_new_state(part->boids);
+ BLI_addtail(&state->rules, boid_new_rule(eBoidRuleType_Separate));
+ BLI_addtail(&state->rules, boid_new_rule(eBoidRuleType_Flock));
+
+ ((BoidRule *)state->rules.first)->flag |= BOIDRULE_CURRENT;
+
+ state->flag |= BOIDSTATE_CURRENT;
+ BLI_addtail(&part->boids->states, state);
+ }
+ else if (part->phystype == PART_PHYS_FLUID && part->fluid == NULL) {
+ part->fluid = MEM_callocN(sizeof(SPHFluidSettings), "SPH Fluid Settings");
+ BKE_particlesettings_fluid_default_settings(part);
+ }
}
static void rna_Particle_redo_child(Main *bmain, Scene *scene, PointerRNA *ptr)
@@ -666,7 +689,7 @@ static ParticleSystem *rna_particle_system_for_target(Object *ob, ParticleTarget
for (pt = psys->targets.first; pt; pt = pt->next)
if (pt == target)
return psys;
-
+
return NULL;
}
@@ -694,7 +717,7 @@ static void rna_Particle_target_reset(Main *bmain, Scene *UNUSED(scene), Pointer
else
pt->flag &= ~PTARGET_VALID;
}
-
+
psys->recalc = PSYS_RECALC_RESET;
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -710,7 +733,7 @@ static void rna_Particle_target_redo(Main *UNUSED(bmain), Scene *UNUSED(scene),
Object *ob = (Object *)ptr->id.data;
ParticleTarget *pt = (ParticleTarget *)ptr->data;
ParticleSystem *psys = rna_particle_system_for_target(ob, pt);
-
+
psys->recalc = PSYS_RECALC_REDO;
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -722,7 +745,7 @@ static void rna_Particle_hair_dynamics_update(Main *bmain, Scene *scene, Pointer
{
Object *ob = (Object *)ptr->id.data;
ParticleSystem *psys = (ParticleSystem *)ptr->data;
-
+
if (psys && !psys->clmd) {
psys->clmd = (ClothModifierData *)modifier_new(eModifierType_Cloth);
psys->clmd->sim_parms->goalspring = 0.0f;
@@ -884,26 +907,26 @@ static int rna_PartSettings_is_fluid_get(PointerRNA *ptr)
static void rna_ParticleSettings_use_clump_curve_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
ParticleSettings *part = ptr->data;
-
+
if (part->child_flag & PART_CHILD_USE_CLUMP_CURVE) {
if (!part->clumpcurve) {
BKE_particlesettings_clump_curve_init(part);
}
}
-
+
rna_Particle_redo_child(bmain, scene, ptr);
}
static void rna_ParticleSettings_use_roughness_curve_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
ParticleSettings *part = ptr->data;
-
+
if (part->child_flag & PART_CHILD_USE_ROUGH_CURVE) {
if (!part->roughcurve) {
BKE_particlesettings_rough_curve_init(part);
}
}
-
+
rna_Particle_redo_child(bmain, scene, ptr);
}
@@ -991,7 +1014,7 @@ static void rna_ParticleTarget_name_get(PointerRNA *ptr, char *str)
Object *ob = (Object *) ptr->id.data;
psys = BLI_findlink(&ob->particlesystem, pt->psys - 1);
}
-
+
if (psys) {
if (pt->ob)
sprintf(str, "%s: %s", pt->ob->id.name + 2, psys->name);
@@ -1024,10 +1047,10 @@ static int particle_id_check(PointerRNA *ptr)
static char *rna_SPHFluidSettings_path(PointerRNA *ptr)
{
SPHFluidSettings *fluid = (SPHFluidSettings *)ptr->data;
-
+
if (particle_id_check(ptr)) {
ParticleSettings *part = (ParticleSettings *)ptr->id.data;
-
+
if (part->fluid == fluid)
return BLI_sprintfN("fluid");
}
@@ -1169,7 +1192,7 @@ static PointerRNA rna_Particle_field1_get(PointerRNA *ptr)
/* weak */
if (!part->pd)
part->pd = object_add_collision_fields(0);
-
+
return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, part->pd);
}
@@ -1180,7 +1203,7 @@ static PointerRNA rna_Particle_field2_get(PointerRNA *ptr)
/* weak */
if (!part->pd2)
part->pd2 = object_add_collision_fields(0);
-
+
return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, part->pd2);
}
@@ -1333,7 +1356,7 @@ static void rna_def_particle_hair_key(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Location (Object Space)", "Location of the hair key in object space");
RNA_def_property_float_funcs(prop, "rna_ParticleHairKey_location_object_get",
"rna_ParticleHairKey_location_object_set", NULL);
-
+
prop = RNA_def_property(srna, "co_local", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "co");
RNA_def_property_ui_text(prop, "Location",
@@ -1719,7 +1742,7 @@ static void rna_def_particle_settings_mtex(BlenderRNA *brna)
{MTEX_SPHERE, "SPHERE", 0, "Sphere", "Map with Z as central axis"},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem prop_x_mapping_items[] = {
{0, "NONE", 0, "None", ""},
{1, "X", 0, "X", ""},
@@ -1727,7 +1750,7 @@ static void rna_def_particle_settings_mtex(BlenderRNA *brna)
{3, "Z", 0, "Z", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem prop_y_mapping_items[] = {
{0, "NONE", 0, "None", ""},
{1, "X", 0, "X", ""},
@@ -1735,7 +1758,7 @@ static void rna_def_particle_settings_mtex(BlenderRNA *brna)
{3, "Z", 0, "Z", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem prop_z_mapping_items[] = {
{0, "NONE", 0, "None", ""},
{1, "X", 0, "X", ""},
@@ -1773,19 +1796,19 @@ static void rna_def_particle_settings_mtex(BlenderRNA *brna)
RNA_def_property_enum_items(prop, prop_x_mapping_items);
RNA_def_property_ui_text(prop, "X Mapping", "");
RNA_def_property_update(prop, 0, "rna_Particle_reset");
-
+
prop = RNA_def_property(srna, "mapping_y", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "projy");
RNA_def_property_enum_items(prop, prop_y_mapping_items);
RNA_def_property_ui_text(prop, "Y Mapping", "");
RNA_def_property_update(prop, 0, "rna_Particle_reset");
-
+
prop = RNA_def_property(srna, "mapping_z", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "projz");
RNA_def_property_enum_items(prop, prop_z_mapping_items);
RNA_def_property_ui_text(prop, "Z Mapping", "");
RNA_def_property_update(prop, 0, "rna_Particle_reset");
-
+
prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_mapping_items);
RNA_def_property_ui_text(prop, "Mapping", "");
@@ -2227,7 +2250,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_items(prop, phys_type_items);
RNA_def_property_ui_text(prop, "Physics Type", "Particle physics type");
- RNA_def_property_update(prop, 0, "rna_Particle_change_physics");
+ RNA_def_property_update(prop, 0, "rna_Particle_change_physics_type");
prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "rotmode");
@@ -3050,7 +3073,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 1.0f, 100.0f, 0.1, 3);
RNA_def_property_ui_text(prop, "Loop count", "Number of times the keys are looped");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
-
+
/* modified dm support */
prop = RNA_def_property(srna, "use_modifier_stack", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "use_modifier_stack", 0);
@@ -3101,7 +3124,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "BoidSettings");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Boid Settings", "");
-
+
/* Fluid particles */
prop = RNA_def_property(srna, "fluid", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "SPHFluidSettings");
@@ -3113,7 +3136,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "EffectorWeights");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Effector Weights", "");
-
+
/* animation here? */
rna_def_animdata_common(srna);
@@ -3147,6 +3170,38 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Twist Curve", "Curve defining twist");
RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
+
+ /* hair shape */
+ prop = RNA_def_property(srna, "use_close_tip", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "shape_flag", PART_SHAPE_CLOSE_TIP);
+ RNA_def_property_ui_text(prop, "Close Tip", "Set tip radius to zero");
+ RNA_def_property_update(prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */
+
+ prop = RNA_def_property(srna, "shape", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_range(prop, -1.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Shape", "Strand shape parameter");
+ RNA_def_property_update(prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */
+
+ prop = RNA_def_property(srna, "root_radius", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "rad_root");
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 2);
+ RNA_def_property_ui_text(prop, "Root", "Strand width at the root");
+ RNA_def_property_update(prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */
+
+ prop = RNA_def_property(srna, "tip_radius", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "rad_tip");
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 2);
+ RNA_def_property_ui_text(prop, "Tip", "Strand width at the tip");
+ RNA_def_property_update(prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */
+
+ prop = RNA_def_property(srna, "radius_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "rad_scale");
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 2);
+ RNA_def_property_ui_text(prop, "Scaling", "Multiplier of radius properties");
+ RNA_def_property_update(prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */
}
static void rna_def_particle_target(BlenderRNA *brna)
@@ -3240,13 +3295,13 @@ static void rna_def_particle_system(BlenderRNA *brna)
prop = RNA_def_property(srna, "particles", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "particles", "totpart");
RNA_def_property_struct_type(prop, "Particle");
- RNA_def_property_flag(prop, PROP_NO_COMPARISON);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
RNA_def_property_ui_text(prop, "Particles", "Particles generated by the particle system");
prop = RNA_def_property(srna, "child_particles", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "child", "totchild");
RNA_def_property_struct_type(prop, "ChildParticle");
- RNA_def_property_flag(prop, PROP_NO_COMPARISON);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
RNA_def_property_ui_text(prop, "Child Particles", "Child particles generated by the particle system");
prop = RNA_def_property(srna, "seed", PROP_INT, PROP_UNSIGNED);
@@ -3579,7 +3634,7 @@ void RNA_def_particle(BlenderRNA *brna)
rna_def_fluid_settings(brna);
rna_def_particle_hair_key(brna);
rna_def_particle_key(brna);
-
+
rna_def_child_particle(brna);
rna_def_particle(brna);
rna_def_particle_dupliweight(brna);
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 014ac426b54..6a5f6485029 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -106,6 +106,7 @@ const EnumPropertyItem rna_enum_color_sets_items[] = {
#include "BKE_context.h"
#include "BKE_constraint.h"
+#include "BKE_global.h"
#include "BKE_idprop.h"
#include "DEG_depsgraph.h"
@@ -175,11 +176,11 @@ static void rna_bone_group_remove(ID *id, bPose *pose, ReportList *reports, Poin
void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value)
{
bActionGroup *grp = ptr->data;
-
+
/* ensure only valid values get set */
if ((value >= -1) && (value < 21)) {
grp->customCol = value;
-
+
/* sync colors stored with theme colors based on the index specified */
action_group_colors_sync(grp, NULL);
}
@@ -188,7 +189,7 @@ void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value)
int rna_ActionGroup_is_custom_colorset_get(PointerRNA *ptr)
{
bActionGroup *grp = ptr->data;
-
+
return (grp->customCol < 0);
}
@@ -239,10 +240,10 @@ static void rna_Pose_ik_solver_update(Main *bmain, Scene *UNUSED(scene), Pointer
BKE_pose_tag_recalc(bmain, pose); /* checks & sorts pose channels */
DEG_relations_tag_update(bmain);
-
+
BKE_pose_update_constraint_flags(pose);
-
- object_test_constraints(ob);
+
+ object_test_constraints(bmain, ob);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
}
@@ -251,7 +252,7 @@ static void rna_Pose_ik_solver_update(Main *bmain, Scene *UNUSED(scene), Pointer
static void rna_PoseChannel_rotation_axis_angle_get(PointerRNA *ptr, float *value)
{
bPoseChannel *pchan = ptr->data;
-
+
/* for now, assume that rotation mode is axis-angle */
value[0] = pchan->rotAngle;
copy_v3_v3(&value[1], pchan->rotAxis);
@@ -261,22 +262,22 @@ static void rna_PoseChannel_rotation_axis_angle_get(PointerRNA *ptr, float *valu
static void rna_PoseChannel_rotation_axis_angle_set(PointerRNA *ptr, const float *value)
{
bPoseChannel *pchan = ptr->data;
-
+
/* for now, assume that rotation mode is axis-angle */
pchan->rotAngle = value[0];
copy_v3_v3(pchan->rotAxis, &value[1]);
-
+
/* TODO: validate axis? */
}
static void rna_PoseChannel_rotation_mode_set(PointerRNA *ptr, int value)
{
bPoseChannel *pchan = ptr->data;
-
+
/* use API Method for conversions... */
BKE_rotMode_change_values(pchan->quat, pchan->eul, pchan->rotAxis, &pchan->rotAngle,
pchan->rotmode, (short)value);
-
+
/* finally, set the new rotation type */
pchan->rotmode = value;
}
@@ -291,7 +292,7 @@ static void rna_PoseChannel_name_set(PointerRNA *ptr, const char *value)
BLI_strncpy_utf8(newname, value, sizeof(pchan->name));
BLI_strncpy(oldname, pchan->name, sizeof(pchan->name));
- ED_armature_bone_rename(ob->data, oldname, newname);
+ ED_armature_bone_rename(G.main, ob->data, oldname, newname);
}
static int rna_PoseChannel_has_ik_get(PointerRNA *ptr)
@@ -387,12 +388,12 @@ static PointerRNA rna_PoseChannel_bone_group_get(PointerRNA *ptr)
bPose *pose = (ob) ? ob->pose : NULL;
bPoseChannel *pchan = (bPoseChannel *)ptr->data;
bActionGroup *grp;
-
+
if (pose)
grp = BLI_findlink(&pose->agroups, pchan->agrp_index - 1);
else
grp = NULL;
-
+
return rna_pointer_inherit_refine(ptr, &RNA_BoneGroup, grp);
}
@@ -401,7 +402,7 @@ static void rna_PoseChannel_bone_group_set(PointerRNA *ptr, PointerRNA value)
Object *ob = (Object *)ptr->id.data;
bPose *pose = (ob) ? ob->pose : NULL;
bPoseChannel *pchan = (bPoseChannel *)ptr->data;
-
+
if (pose)
pchan->agrp_index = BLI_findindex(&pose->agroups, value.data) + 1;
else
@@ -425,7 +426,7 @@ static void rna_PoseChannel_bone_group_index_range(PointerRNA *ptr, int *min, in
{
Object *ob = (Object *)ptr->id.data;
bPose *pose = (ob) ? ob->pose : NULL;
-
+
*min = 0;
*max = pose ? max_ii(0, BLI_listbase_count(&pose->agroups) - 1) : 0;
}
@@ -489,14 +490,14 @@ static void rna_pose_bgroup_name_index_set(PointerRNA *ptr, const char *value, s
bPose *pose = (bPose *)ptr->data;
bActionGroup *grp;
int a;
-
+
for (a = 1, grp = pose->agroups.first; grp; grp = grp->next, a++) {
if (STREQ(grp->name, value)) {
*index = a;
return;
}
}
-
+
*index = 0;
}
@@ -504,14 +505,14 @@ static void rna_pose_pgroup_name_set(PointerRNA *ptr, const char *value, char *r
{
bPose *pose = (bPose *)ptr->data;
bActionGroup *grp;
-
+
for (grp = pose->agroups.first; grp; grp = grp->next) {
if (STREQ(grp->name, value)) {
BLI_strncpy(result, value, maxlen);
return;
}
}
-
+
result[0] = '\0';
}
#endif
@@ -540,7 +541,8 @@ static bConstraint *rna_PoseChannel_constraints_new(ID *id, bPoseChannel *pchan,
return new_con;
}
-static void rna_PoseChannel_constraints_remove(ID *id, bPoseChannel *pchan, ReportList *reports, PointerRNA *con_ptr)
+static void rna_PoseChannel_constraints_remove(
+ ID *id, bPoseChannel *pchan, Main *bmain, ReportList *reports, PointerRNA *con_ptr)
{
bConstraint *con = con_ptr->data;
const bool is_ik = ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK);
@@ -554,7 +556,7 @@ static void rna_PoseChannel_constraints_remove(ID *id, bPoseChannel *pchan, Repo
BKE_constraint_remove(&pchan->constraints, con);
RNA_POINTER_INVALIDATE(con_ptr);
- ED_object_constraint_update(ob);
+ ED_object_constraint_update(bmain, ob);
BKE_constraints_active_set(&pchan->constraints, NULL); /* XXX, is this really needed? - Campbell */
@@ -618,12 +620,12 @@ static int rna_PoseChannel_proxy_editable(PointerRNA *ptr, const char **r_info)
Object *ob = (Object *)ptr->id.data;
bArmature *arm = ob->data;
bPoseChannel *pchan = (bPoseChannel *)ptr->data;
-
+
if (ob->proxy && pchan->bone && (pchan->bone->layer & arm->layer_protected)) {
*r_info = "Can't edit property of a proxy on a protected layer";
return 0;
}
-
+
return PROP_EDITABLE;
}
@@ -645,7 +647,7 @@ static int rna_PoseChannel_location_editable(PointerRNA *ptr, int index)
static int rna_PoseChannel_scale_editable(PointerRNA *ptr, int index)
{
bPoseChannel *pchan = (bPoseChannel *)ptr->data;
-
+
/* only if the axis in question is locked, not editable... */
if ((index == 0) && (pchan->protectflag & OB_LOCK_SCALEX))
return 0;
@@ -660,7 +662,7 @@ static int rna_PoseChannel_scale_editable(PointerRNA *ptr, int index)
static int rna_PoseChannel_rotation_euler_editable(PointerRNA *ptr, int index)
{
bPoseChannel *pchan = (bPoseChannel *)ptr->data;
-
+
/* only if the axis in question is locked, not editable... */
if ((index == 0) && (pchan->protectflag & OB_LOCK_ROTX))
return 0;
@@ -675,7 +677,7 @@ static int rna_PoseChannel_rotation_euler_editable(PointerRNA *ptr, int index)
static int rna_PoseChannel_rotation_4d_editable(PointerRNA *ptr, int index)
{
bPoseChannel *pchan = (bPoseChannel *)ptr->data;
-
+
/* only consider locks if locking components individually... */
if (pchan->protectflag & OB_LOCK_ROT4D) {
/* only if the axis in question is locked, not editable... */
@@ -688,7 +690,7 @@ static int rna_PoseChannel_rotation_4d_editable(PointerRNA *ptr, int index)
else if ((index == 3) && (pchan->protectflag & OB_LOCK_ROTZ))
return 0;
}
-
+
return PROP_EDITABLE;
}
@@ -735,7 +737,7 @@ static void rna_PoseChannel_matrix_set(PointerRNA *ptr, const float *values)
void rna_def_actionbone_group_common(StructRNA *srna, int update_flag, const char *update_cb)
{
PropertyRNA *prop;
-
+
/* color set + colors */
prop = RNA_def_property(srna, "color_set", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "customCol");
@@ -743,12 +745,12 @@ void rna_def_actionbone_group_common(StructRNA *srna, int update_flag, const cha
RNA_def_property_enum_funcs(prop, NULL, "rna_ActionGroup_colorset_set", NULL);
RNA_def_property_ui_text(prop, "Color Set", "Custom color set to use");
RNA_def_property_update(prop, update_flag, update_cb);
-
+
prop = RNA_def_property(srna, "is_custom_color_set", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_ActionGroup_is_custom_colorset_get", NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Custom Color Set", "Color set is user-defined instead of a fixed theme color set");
-
+
/* TODO: editing the colors for this should result in changes to the color type... */
prop = RNA_def_property(srna, "colors", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
@@ -763,21 +765,21 @@ static void rna_def_bone_group(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
/* struct */
srna = RNA_def_struct(brna, "BoneGroup", NULL);
RNA_def_struct_sdna(srna, "bActionGroup");
RNA_def_struct_ui_text(srna, "Bone Group", "Groups of Pose Channels (Bones)");
RNA_def_struct_ui_icon(srna, ICON_GROUP_BONE);
-
+
/* name */
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_BoneGroup_name_set");
RNA_def_struct_name_property(srna, prop);
-
+
/* TODO: add some runtime-collections stuff to access grouped bones */
-
+
/* color set */
rna_def_actionbone_group_common(srna, NC_OBJECT | ND_POSE, "rna_Pose_update");
}
@@ -830,7 +832,7 @@ static void rna_def_pose_channel_constraints(BlenderRNA *brna, PropertyRNA *cpro
func = RNA_def_function(srna, "remove", "rna_PoseChannel_constraints_remove");
RNA_def_function_ui_description(func, "Remove a constraint from this object");
- RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); /* ID needed for refresh */
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS ); /* ID needed for refresh */
/* constraint to remove */
parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
@@ -852,11 +854,11 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_struct_path_func(srna, "rna_PoseBone_path");
RNA_def_struct_idprops_func(srna, "rna_PoseBone_idprops");
RNA_def_struct_ui_icon(srna, ICON_BONE_DATA);
-
+
/* Bone Constraints */
prop = RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "Constraint");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC | PROP_OVERRIDABLE_STATIC_INSERTION);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC | PROPOVERRIDE_STATIC_INSERTION);
RNA_def_property_ui_text(prop, "Constraints", "Constraints that act on this PoseChannel");
RNA_def_property_override_funcs(prop, NULL, NULL, "rna_PoseChannel_constraints_override_apply");
@@ -871,7 +873,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
/* Baked Bone Path cache data */
rna_def_motionpath_common(srna);
-
+
/* Relationships to other bones */
prop = RNA_def_property(srna, "bone", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
@@ -891,11 +893,11 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Child", "Child of this pose bone");
-
+
/* Transformation settings */
prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "loc");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_editable_array_func(prop, "rna_PoseChannel_location_editable");
RNA_def_property_ui_text(prop, "Location", "");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
@@ -903,7 +905,8 @@ static void rna_def_pose_channel(BlenderRNA *brna)
prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "size");
- RNA_def_property_flag(prop, PROP_PROPORTIONAL | PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_flag(prop, PROP_PROPORTIONAL);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_editable_array_func(prop, "rna_PoseChannel_scale_editable");
RNA_def_property_float_array_default(prop, default_scale);
RNA_def_property_ui_text(prop, "Scale", "");
@@ -911,17 +914,17 @@ static void rna_def_pose_channel(BlenderRNA *brna)
prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
RNA_def_property_float_sdna(prop, NULL, "quat");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable");
RNA_def_property_float_array_default(prop, default_quat);
RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
/* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but
* having a single one is better for Keyframing and other property-management situations...
*/
prop = RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_array(prop, 4);
RNA_def_property_float_funcs(prop, "rna_PoseChannel_rotation_axis_angle_get",
"rna_PoseChannel_rotation_axis_angle_set", NULL);
@@ -929,14 +932,14 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_float_array_default(prop, default_axisAngle);
RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
RNA_def_property_float_sdna(prop, NULL, "eul");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_euler_editable");
RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "rotmode");
RNA_def_property_enum_items(prop, rna_enum_posebone_rotmode_items); /* XXX move to using a single define of this someday */
@@ -945,19 +948,19 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_ui_text(prop, "Rotation Mode", "");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
/* Curved bones settings - Applied on top of restpose values */
rna_def_bone_curved_common(srna, true);
-
+
/* Custom BBone next/prev sources */
prop = RNA_def_property(srna, "use_bbone_custom_handles", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "bboneflag", PCHAN_BBONE_CUSTOM_HANDLES);
- RNA_def_property_ui_text(prop, "Use Custom Handle References",
+ RNA_def_property_ui_text(prop, "Use Custom Handle References",
"Use custom reference bones as handles for B-Bones instead of next/previous bones, "
"leave these blank to use only B-Bone offset properties to control the shape");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
prop = RNA_def_property(srna, "bbone_custom_handle_start", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "bbone_prev");
RNA_def_property_struct_type(prop, "PoseBone");
@@ -966,14 +969,14 @@ static void rna_def_pose_channel(BlenderRNA *brna)
"Bone that serves as the start handle for the B-Bone curve");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
prop = RNA_def_property(srna, "use_bbone_relative_start_handle", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "bboneflag", PCHAN_BBONE_CUSTOM_START_REL);
- RNA_def_property_ui_text(prop, "Relative B-Bone Start Handle",
+ RNA_def_property_ui_text(prop, "Relative B-Bone Start Handle",
"Treat custom start handle position as a relative value");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
prop = RNA_def_property(srna, "bbone_custom_handle_end", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "bbone_next");
RNA_def_property_struct_type(prop, "PoseBone");
@@ -982,14 +985,14 @@ static void rna_def_pose_channel(BlenderRNA *brna)
"Bone that serves as the end handle for the B-Bone curve");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
prop = RNA_def_property(srna, "use_bbone_relative_end_handle", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "bboneflag", PCHAN_BBONE_CUSTOM_END_REL);
- RNA_def_property_ui_text(prop, "Relative B-Bone End Handle",
+ RNA_def_property_ui_text(prop, "Relative B-Bone End Handle",
"Treat custom end handle position as a relative value");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
/* transform matrices - should be read-only since these are set directly by AnimSys evaluation */
prop = RNA_def_property(srna, "matrix_channel", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_float_sdna(prop, NULL, "chan_mat");
@@ -1027,7 +1030,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Pose Tail Position", "Location of tail of the channel's bone");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
-
+
/* IK Settings */
prop = RNA_def_property(srna, "is_in_ik_chain", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_PoseChannel_has_ik_get", NULL);
@@ -1073,19 +1076,19 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "IK Z Limit", "Limit movement around the Z axis");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
-
+
prop = RNA_def_property(srna, "use_ik_rotation_control", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_ROTCTL);
RNA_def_property_ui_text(prop, "IK rot control", "Apply channel rotation as IK constraint");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
-
+
prop = RNA_def_property(srna, "use_ik_linear_control", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_LINCTL);
RNA_def_property_ui_text(prop, "IK rot control", "Apply channel size as IK constraint if stretching is enabled");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
-
+
prop = RNA_def_property(srna, "ik_min_x", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "limitmin[0]");
RNA_def_property_range(prop, -M_PI, 0.0f);
@@ -1155,21 +1158,21 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "IK Stretch", "Allow scaling of the bone for IK");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
-
+
prop = RNA_def_property(srna, "ik_rotation_weight", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ikrotweight");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "IK Rot Weight", "Weight of rotation constraint for IK");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
prop = RNA_def_property(srna, "ik_linear_weight", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "iklinweight");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "IK Lin Weight", "Weight of scale constraint for IK");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
/* custom bone shapes */
prop = RNA_def_property(srna, "custom_shape", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "custom");
@@ -1179,7 +1182,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Custom Object", "Object that defines custom draw type for this bone");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
prop = RNA_def_property(srna, "custom_shape_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "custom_scale");
RNA_def_property_range(prop, 0.0f, 1000.0f);
@@ -1199,7 +1202,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
"Bone that defines the display transform of this custom shape");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
/* bone groups */
prop = RNA_def_property(srna, "bone_group_index", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "agrp_index");
@@ -1210,7 +1213,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Bone Group Index", "Bone Group this pose channel belongs to (0=no group)");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
prop = RNA_def_property(srna, "bone_group", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "BoneGroup");
RNA_def_property_flag(prop, PROP_EDITABLE);
@@ -1219,7 +1222,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Bone Group", "Bone Group this pose channel belongs to");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
/* transform locks */
prop = RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX);
@@ -1236,7 +1239,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
/* XXX this is sub-optimal - it really should be included above, but due to technical reasons
* we can't do this! */
prop = RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE);
@@ -1436,7 +1439,7 @@ static void rna_def_bone_groups(BlenderRNA *brna, PropertyRNA *cprop)
"rna_Pose_active_bone_group_set", NULL, NULL);
RNA_def_property_ui_text(prop, "Active Bone Group", "Active bone group for this pose");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
-
+
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "active_group");
RNA_def_property_int_funcs(prop, "rna_Pose_active_bone_group_index_get", "rna_Pose_active_bone_group_index_set",
@@ -1449,7 +1452,7 @@ static void rna_def_pose(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
/* struct definition */
srna = RNA_def_struct(brna, "Pose", NULL);
RNA_def_struct_sdna(srna, "bPose");
@@ -1459,7 +1462,7 @@ static void rna_def_pose(BlenderRNA *brna)
prop = RNA_def_property(srna, "bones", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "chanbase", NULL);
RNA_def_property_struct_type(prop, "PoseBone");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Pose Bones", "Individual pose bones for the armature");
/* can be removed, only for fast lookup */
RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, "rna_PoseBones_lookup_string", NULL);
@@ -1470,7 +1473,7 @@ static void rna_def_pose(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "BoneGroup");
RNA_def_property_ui_text(prop, "Bone Groups", "Groups of the bones");
rna_def_bone_groups(brna, prop);
-
+
/* ik solvers */
prop = RNA_def_property(srna, "ik_solver", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "iksolver");
@@ -1484,10 +1487,10 @@ static void rna_def_pose(BlenderRNA *brna)
RNA_def_property_pointer_funcs(prop, "rna_Pose_ikparam_get", NULL, "rna_Pose_ikparam_typef", NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "IK Param", "Parameters for IK solver");
-
+
/* animviz */
rna_def_animviz_common(srna);
-
+
RNA_api_pose(srna);
}
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c
index 18e29a2de3f..0dd33944dda 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -168,15 +168,15 @@ static void engine_update(RenderEngine *engine, Main *bmain, Depsgraph *depsgrap
RNA_parameter_list_free(&list);
}
-static void engine_render_to_image(RenderEngine *engine, Depsgraph *depsgraph)
+static void engine_render(RenderEngine *engine, Depsgraph *depsgraph)
{
- extern FunctionRNA rna_RenderEngine_render_to_image_func;
+ extern FunctionRNA rna_RenderEngine_render_func;
PointerRNA ptr;
ParameterList list;
FunctionRNA *func;
RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
- func = &rna_RenderEngine_render_to_image_func;
+ func = &rna_RenderEngine_render_func;
RNA_parameter_list_create(&list, &ptr, func);
RNA_parameter_set_lookup(&list, "depsgraph", &depsgraph);
@@ -230,15 +230,15 @@ static void engine_view_update(RenderEngine *engine, const struct bContext *cont
RNA_parameter_list_free(&list);
}
-static void engine_render_to_view(RenderEngine *engine, const struct bContext *context)
+static void engine_view_draw(RenderEngine *engine, const struct bContext *context)
{
- extern FunctionRNA rna_RenderEngine_render_to_view_func;
+ extern FunctionRNA rna_RenderEngine_view_draw_func;
PointerRNA ptr;
ParameterList list;
FunctionRNA *func;
RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
- func = &rna_RenderEngine_render_to_view_func;
+ func = &rna_RenderEngine_view_draw_func;
RNA_parameter_list_create(&list, &ptr, func);
RNA_parameter_set_lookup(&list, "context", &context);
@@ -291,7 +291,7 @@ static void rna_RenderEngine_unregister(Main *bmain, StructRNA *type)
if (!et)
return;
-
+
RNA_struct_free_extension(type, &et->ext);
RNA_struct_free(&BLENDER_RNA, type);
BLI_freelinkN(&R_engines, et);
@@ -332,7 +332,7 @@ static StructRNA *rna_RenderEngine_register(
break;
}
}
-
+
/* create a new engine type */
et = MEM_callocN(sizeof(RenderEngineType), "python render engine");
memcpy(et, &dummyet, sizeof(dummyet));
@@ -344,10 +344,10 @@ static StructRNA *rna_RenderEngine_register(
RNA_struct_blender_type_set(et->ext.srna, et);
et->update = (have_function[0]) ? engine_update : NULL;
- et->render_to_image = (have_function[1]) ? engine_render_to_image : NULL;
+ et->render = (have_function[1]) ? engine_render : NULL;
et->bake = (have_function[2]) ? engine_bake : NULL;
et->view_update = (have_function[3]) ? engine_view_update : NULL;
- et->render_to_view = (have_function[4]) ? engine_render_to_view : NULL;
+ et->view_draw = (have_function[4]) ? engine_view_draw : NULL;
et->update_script_node = (have_function[5]) ? engine_update_script_node : NULL;
et->update_render_passes = (have_function[6]) ? engine_update_render_passes : NULL;
@@ -489,7 +489,7 @@ static void rna_def_render_engine(BlenderRNA *brna)
RNA_def_pointer(func, "data", "BlendData", "", "");
RNA_def_pointer(func, "depsgraph", "Depsgraph", "", "");
- func = RNA_def_function(srna, "render_to_image", NULL);
+ func = RNA_def_function(srna, "render", NULL);
RNA_def_function_ui_description(func, "Render scene into an image");
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "", "");
@@ -524,7 +524,7 @@ static void rna_def_render_engine(BlenderRNA *brna)
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
RNA_def_pointer(func, "context", "Context", "", "");
- func = RNA_def_function(srna, "render_to_view", NULL);
+ func = RNA_def_function(srna, "view_draw", NULL);
RNA_def_function_ui_description(func, "Draw viewport render");
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
RNA_def_pointer(func, "context", "Context", "", "");
@@ -790,7 +790,7 @@ static void rna_def_render_result(BlenderRNA *brna)
FunctionRNA *func;
PropertyRNA *parm;
-
+
srna = RNA_def_struct(brna, "RenderResult", NULL);
RNA_def_struct_ui_text(srna, "Render Result", "Result of rendering, including all layers and passes");
@@ -890,7 +890,7 @@ static void rna_def_render_layer(BlenderRNA *brna)
FunctionRNA *func;
PropertyRNA *parm;
-
+
srna = RNA_def_struct(brna, "RenderLayer", NULL);
RNA_def_struct_ui_text(srna, "Render Layer", "");
diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c
index 0a8a99d779a..60a1783f118 100644
--- a/source/blender/makesrna/intern/rna_rigidbody.c
+++ b/source/blender/makesrna/intern/rna_rigidbody.c
@@ -108,19 +108,19 @@ static const EnumPropertyItem rigidbody_mesh_source_items[] = {
static void rna_RigidBodyWorld_reset(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data;
-
+
BKE_rigidbody_cache_reset(rbw);
}
static char *rna_RigidBodyWorld_path(PointerRNA *UNUSED(ptr))
-{
+{
return BLI_sprintfN("rigidbody_world");
}
static void rna_RigidBodyWorld_num_solver_iterations_set(PointerRNA *ptr, int value)
{
RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data;
-
+
rbw->num_solver_iterations = value;
#ifdef WITH_BULLET
@@ -133,7 +133,7 @@ static void rna_RigidBodyWorld_num_solver_iterations_set(PointerRNA *ptr, int va
static void rna_RigidBodyWorld_split_impulse_set(PointerRNA *ptr, int value)
{
RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data;
-
+
RB_FLAG_SET(rbw->flag, value, RBW_FLAG_USE_SPLIT_IMPULSE);
#ifdef WITH_BULLET
@@ -148,16 +148,16 @@ static void rna_RigidBodyWorld_split_impulse_set(PointerRNA *ptr, int value)
static void rna_RigidBodyOb_reset(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
{
RigidBodyWorld *rbw = scene->rigidbody_world;
-
+
BKE_rigidbody_cache_reset(rbw);
}
static void rna_RigidBodyOb_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Object *ob = ptr->id.data;
-
+
rna_RigidBodyOb_reset(bmain, scene, ptr);
-
+
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
}
@@ -165,7 +165,7 @@ static void rna_RigidBodyOb_shape_reset(Main *UNUSED(bmain), Scene *scene, Point
{
RigidBodyWorld *rbw = scene->rigidbody_world;
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
-
+
BKE_rigidbody_cache_reset(rbw);
if (rbo->physics_shape)
rbo->flag |= RBO_FLAG_NEEDS_RESHAPE;
@@ -180,7 +180,7 @@ static char *rna_RigidBodyOb_path(PointerRNA *UNUSED(ptr))
static void rna_RigidBodyOb_type_set(PointerRNA *ptr, int value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
-
+
rbo->type = value;
rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
}
@@ -196,7 +196,7 @@ static void rna_RigidBodyOb_shape_set(PointerRNA *ptr, int value)
static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, int value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
-
+
RB_FLAG_SET(rbo->flag, !value, RBO_FLAG_DISABLED);
#ifdef WITH_BULLET
@@ -212,7 +212,7 @@ static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, int value)
static void rna_RigidBodyOb_mass_set(PointerRNA *ptr, float value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
-
+
rbo->mass = value;
#ifdef WITH_BULLET
@@ -226,7 +226,7 @@ static void rna_RigidBodyOb_mass_set(PointerRNA *ptr, float value)
static void rna_RigidBodyOb_friction_set(PointerRNA *ptr, float value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
-
+
rbo->friction = value;
#ifdef WITH_BULLET
@@ -239,7 +239,7 @@ static void rna_RigidBodyOb_friction_set(PointerRNA *ptr, float value)
static void rna_RigidBodyOb_restitution_set(PointerRNA *ptr, float value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
-
+
rbo->restitution = value;
#ifdef WITH_BULLET
if (rbo->physics_object) {
@@ -251,7 +251,7 @@ static void rna_RigidBodyOb_restitution_set(PointerRNA *ptr, float value)
static void rna_RigidBodyOb_collision_margin_set(PointerRNA *ptr, float value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
-
+
rbo->margin = value;
#ifdef WITH_BULLET
@@ -278,7 +278,7 @@ static void rna_RigidBodyOb_collision_groups_set(PointerRNA *ptr, const int *val
static void rna_RigidBodyOb_kinematic_state_set(PointerRNA *ptr, int value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
-
+
RB_FLAG_SET(rbo->flag, value, RBO_FLAG_KINEMATIC);
#ifdef WITH_BULLET
@@ -294,7 +294,7 @@ static void rna_RigidBodyOb_kinematic_state_set(PointerRNA *ptr, int value)
static void rna_RigidBodyOb_activation_state_set(PointerRNA *ptr, int value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
-
+
RB_FLAG_SET(rbo->flag, value, RBO_FLAG_USE_DEACTIVATION);
#ifdef WITH_BULLET
@@ -308,7 +308,7 @@ static void rna_RigidBodyOb_activation_state_set(PointerRNA *ptr, int value)
static void rna_RigidBodyOb_linear_sleepThresh_set(PointerRNA *ptr, float value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
-
+
rbo->lin_sleep_thresh = value;
#ifdef WITH_BULLET
@@ -322,7 +322,7 @@ static void rna_RigidBodyOb_linear_sleepThresh_set(PointerRNA *ptr, float value)
static void rna_RigidBodyOb_angular_sleepThresh_set(PointerRNA *ptr, float value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
-
+
rbo->ang_sleep_thresh = value;
#ifdef WITH_BULLET
@@ -336,7 +336,7 @@ static void rna_RigidBodyOb_angular_sleepThresh_set(PointerRNA *ptr, float value
static void rna_RigidBodyOb_linear_damping_set(PointerRNA *ptr, float value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
-
+
rbo->lin_damping = value;
#ifdef WITH_BULLET
@@ -350,7 +350,7 @@ static void rna_RigidBodyOb_linear_damping_set(PointerRNA *ptr, float value)
static void rna_RigidBodyOb_angular_damping_set(PointerRNA *ptr, float value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
-
+
rbo->ang_damping = value;
#ifdef WITH_BULLET
@@ -737,7 +737,7 @@ static void rna_def_rigidbody_world(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "RigidBodyWorld");
RNA_def_struct_ui_text(srna, "Rigid Body World", "Self-contained rigid body simulation environment and settings");
RNA_def_struct_path_func(srna, "rna_RigidBodyWorld_path");
-
+
/* groups */
prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Collection");
@@ -750,13 +750,13 @@ static void rna_def_rigidbody_world(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
RNA_def_property_ui_text(prop, "Constraints", "Collection containing rigid body constraint objects");
RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
-
+
/* booleans */
prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", RBW_FLAG_MUTED);
RNA_def_property_ui_text(prop, "Enabled", "Simulation will be evaluated");
RNA_def_property_update(prop, NC_SCENE, NULL);
-
+
/* time scale */
prop = RNA_def_property(srna, "time_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "time_scale");
@@ -765,7 +765,7 @@ static void rna_def_rigidbody_world(BlenderRNA *brna)
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Time Scale", "Change the speed of the simulation");
RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
-
+
/* timestep */
prop = RNA_def_property(srna, "steps_per_second", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "steps_per_second");
@@ -776,7 +776,7 @@ static void rna_def_rigidbody_world(BlenderRNA *brna)
"Number of simulation steps taken per second (higher values are more accurate "
"but slower)");
RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
-
+
/* constraint solver iterations */
prop = RNA_def_property(srna, "solver_iterations", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "num_solver_iterations");
@@ -788,7 +788,7 @@ static void rna_def_rigidbody_world(BlenderRNA *brna)
"Number of constraint solver iterations made per simulation step (higher values are more "
"accurate but slower)");
RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
-
+
/* split impulse */
prop = RNA_def_property(srna, "use_split_impulse", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", RBW_FLAG_USE_SPLIT_IMPULSE);
@@ -843,13 +843,13 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
-
+
+
srna = RNA_def_struct(brna, "RigidBodyObject", NULL);
RNA_def_struct_sdna(srna, "RigidBodyOb");
RNA_def_struct_ui_text(srna, "Rigid Body Object", "Settings for object participating in Rigid Body Simulation");
RNA_def_struct_path_func(srna, "rna_RigidBodyOb_path");
-
+
/* Enums */
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
@@ -858,21 +858,21 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Type", "Role of object in Rigid Body Simulations");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
-
+
prop = RNA_def_property(srna, "mesh_source", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "mesh_source");
RNA_def_property_enum_items(prop, rigidbody_mesh_source_items);
RNA_def_property_ui_text(prop, "Mesh Source", "Source of the mesh used to create collision shape");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
-
+
/* booleans */
prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", RBO_FLAG_DISABLED);
RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyOb_disabled_set");
RNA_def_property_ui_text(prop, "Enabled", "Rigid Body actively participates to the simulation");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
-
+
prop = RNA_def_property(srna, "collision_shape", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "shape");
RNA_def_property_enum_items(prop, rna_enum_rigidbody_object_shape_items);
@@ -880,18 +880,18 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Collision Shape", "Collision Shape of object in Rigid Body Simulations");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_shape_update");
-
+
prop = RNA_def_property(srna, "kinematic", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_KINEMATIC);
RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyOb_kinematic_state_set");
RNA_def_property_ui_text(prop, "Kinematic", "Allow rigid body to be controlled by the animation system");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
-
+
prop = RNA_def_property(srna, "use_deform", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_USE_DEFORM);
RNA_def_property_ui_text(prop, "Deforming", "Rigid body deforms during simulation");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
-
+
/* Physics Parameters */
prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_UNIT_MASS);
RNA_def_property_float_sdna(prop, NULL, "mass");
@@ -900,10 +900,10 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_mass_set", NULL);
RNA_def_property_ui_text(prop, "Mass", "How much the object 'weighs' irrespective of gravity");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
-
+
/* Dynamics Parameters - Activation */
// TODO: define and figure out how to implement these
-
+
/* Dynamics Parameters - Deactivation */
prop = RNA_def_property(srna, "use_deactivation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_USE_DEACTIVATION);
@@ -913,13 +913,13 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
"Enable deactivation of resting rigid bodies (increases performance and stability "
"but can cause glitches)");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
-
+
prop = RNA_def_property(srna, "use_start_deactivated", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_START_DEACTIVATED);
RNA_def_property_ui_text(prop, "Start Deactivated", "Deactivate rigid body at the start of the simulation");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
-
+
prop = RNA_def_property(srna, "deactivate_linear_velocity", PROP_FLOAT, PROP_UNIT_VELOCITY);
RNA_def_property_float_sdna(prop, NULL, "lin_sleep_thresh");
RNA_def_property_range(prop, FLT_MIN, FLT_MAX); // range must always be positive (and non-zero)
@@ -928,7 +928,7 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Linear Velocity Deactivation Threshold",
"Linear Velocity below which simulation stops simulating object");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
-
+
prop = RNA_def_property(srna, "deactivate_angular_velocity", PROP_FLOAT, PROP_UNIT_VELOCITY);
RNA_def_property_float_sdna(prop, NULL, "ang_sleep_thresh");
RNA_def_property_range(prop, FLT_MIN, FLT_MAX); // range must always be positive (and non-zero)
@@ -937,7 +937,7 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Angular Velocity Deactivation Threshold",
"Angular Velocity below which simulation stops simulating object");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
-
+
/* Dynamics Parameters - Damping Parameters */
prop = RNA_def_property(srna, "linear_damping", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "lin_damping");
@@ -946,7 +946,7 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_linear_damping_set", NULL);
RNA_def_property_ui_text(prop, "Linear Damping", "Amount of linear velocity that is lost over time");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
-
+
prop = RNA_def_property(srna, "angular_damping", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "ang_damping");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -954,7 +954,7 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_angular_damping_set", NULL);
RNA_def_property_ui_text(prop, "Angular Damping", "Amount of angular velocity that is lost over time");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
-
+
/* Collision Parameters - Surface Parameters */
prop = RNA_def_property(srna, "friction", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "friction");
@@ -964,7 +964,7 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_friction_set", NULL);
RNA_def_property_ui_text(prop, "Friction", "Resistance of object to movement");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
-
+
prop = RNA_def_property(srna, "restitution", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "restitution");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
@@ -975,7 +975,7 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
"Tendency of object to bounce after colliding with another "
"(0 = stays still, 1 = perfectly elastic)");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
-
+
/* Collision Parameters - Sensitivity */
prop = RNA_def_property(srna, "use_margin", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_USE_MARGIN);
@@ -983,7 +983,7 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Collision Margin",
"Use custom collision margin (some shapes will have a visible gap around them)");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_shape_reset");
-
+
prop = RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_UNIT_LENGTH);
RNA_def_property_float_sdna(prop, NULL, "margin");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -994,7 +994,7 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
"Threshold of distance near surface where collisions are still considered "
"(best results when non-zero)");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_shape_reset");
-
+
prop = RNA_def_property(srna, "collision_groups", PROP_BOOLEAN, PROP_LAYER_MEMBER);
RNA_def_property_boolean_sdna(prop, NULL, "col_groups", 1);
RNA_def_property_array(prop, 20);
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index f42bc1e1923..53b98928c31 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -595,7 +595,7 @@ static int rna_Property_overridable_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
- return (prop->flag & PROP_OVERRIDABLE_STATIC) != 0;
+ return (prop->flag_override & PROPOVERRIDE_OVERRIDABLE_STATIC) != 0;
}
static int rna_Property_use_output_get(PointerRNA *ptr)
@@ -945,10 +945,10 @@ static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, Point
const EnumPropertyItem *item = NULL;
int totitem;
bool free;
-
+
rna_idproperty_check(&prop, ptr);
/* eprop = (EnumPropertyRNA *)prop; */
-
+
RNA_property_enum_items_ex(
NULL, ptr, prop, STREQ(iter->prop->identifier, "enum_items_static"), &item, &totitem, &free);
rna_iterator_array_begin(iter, (void *)item, sizeof(EnumPropertyItem), totitem, free, rna_enum_check_separator);
@@ -1121,7 +1121,7 @@ static int rna_BlenderRNA_structs_lookup_string(PointerRNA *ptr, const char *key
/* Ensures it makes sense to go inside the pointers to compare their content
* (if they are IDs, or have different names or RNA type, then this would be meaningless). */
static bool rna_property_override_diff_propptr_validate_diffing(
- PointerRNA *propptr_a, PointerRNA *propptr_b,
+ PointerRNA *propptr_a, PointerRNA *propptr_b, const bool no_prop_name,
bool *r_is_id, bool *r_is_null, bool *r_is_type_diff,
char **r_propname_a, char *propname_a_buff, size_t propname_a_buff_size,
char **r_propname_b, char *propname_b_buff, size_t propname_b_buff_size)
@@ -1129,7 +1129,7 @@ static bool rna_property_override_diff_propptr_validate_diffing(
BLI_assert(propptr_a != NULL);
bool is_valid_for_diffing = true;
- const bool do_force_name = r_propname_a != NULL;
+ const bool do_force_name = !no_prop_name && r_propname_a != NULL;
if (do_force_name) {
BLI_assert(r_propname_a != NULL);
@@ -1165,7 +1165,7 @@ static bool rna_property_override_diff_propptr_validate_diffing(
/* We do a generic quick first comparison checking for "name" and/or "type" properties.
* We assume that is any of those are false, then we are not handling the same data.
* This helps a lot in static override case, especially to detect inserted items in collections. */
- if (is_valid_for_diffing || do_force_name) {
+ if (!no_prop_name && (is_valid_for_diffing || do_force_name)) {
PropertyRNA *nameprop_a = RNA_struct_name_property(propptr_a->type);
PropertyRNA *nameprop_b = (propptr_b != NULL) ? RNA_struct_name_property(propptr_b->type) : NULL;
@@ -1222,7 +1222,8 @@ static bool rna_property_override_diff_propptr_validate_diffing(
/* Used for both Pointer and Collection properties. */
static int rna_property_override_diff_propptr(
- PointerRNA *propptr_a, PointerRNA *propptr_b, eRNACompareMode mode, const bool no_ownership,
+ PointerRNA *propptr_a, PointerRNA *propptr_b,
+ eRNACompareMode mode, const bool no_ownership, const bool no_prop_name,
IDOverrideStatic *override, const char *rna_path, const int flags, bool *r_override_changed)
{
const bool do_create = override != NULL && (flags & RNA_OVERRIDE_COMPARE_CREATE) != 0 && rna_path != NULL;
@@ -1232,7 +1233,7 @@ static int rna_property_override_diff_propptr(
bool is_type_diff = false;
/* If false, it means that the whole data itself is different, so no point in going inside of it at all! */
bool is_valid_for_diffing = rna_property_override_diff_propptr_validate_diffing(
- propptr_a, propptr_b, &is_id, &is_null, &is_type_diff,
+ propptr_a, propptr_b, no_prop_name, &is_id, &is_null, &is_type_diff,
NULL, NULL, 0, NULL, NULL, 0);
if (is_id) {
@@ -1538,8 +1539,9 @@ int rna_property_override_diff_default(PointerRNA *ptr_a, PointerRNA *ptr_b,
PointerRNA propptr_a = RNA_property_pointer_get(ptr_a, prop_a);
PointerRNA propptr_b = RNA_property_pointer_get(ptr_b, prop_b);
const bool no_ownership = (RNA_property_flag(prop_a) & PROP_PTR_NO_OWNERSHIP) != 0;
+ const bool no_prop_name = (RNA_property_override_flag(prop_a) & PROPOVERRIDE_NO_PROP_NAME) != 0;
return rna_property_override_diff_propptr(
- &propptr_a, &propptr_b, mode, no_ownership,
+ &propptr_a, &propptr_b, mode, no_ownership, no_prop_name,
override, rna_path, flags, r_override_changed);
}
break;
@@ -1549,7 +1551,8 @@ int rna_property_override_diff_default(PointerRNA *ptr_a, PointerRNA *ptr_b,
{
/* Note: we assume we only insert in ptr_a (i.e. we can only get new items in ptr_a),
* and that we never remove anything. */
- const bool use_insertion = (RNA_property_flag(prop_a) & PROP_OVERRIDABLE_STATIC_INSERTION) && do_create;
+ const bool use_insertion = (RNA_property_override_flag(prop_a) & PROPOVERRIDE_STATIC_INSERTION) && do_create;
+ const bool no_prop_name = (RNA_property_override_flag(prop_a) & PROPOVERRIDE_NO_PROP_NAME) != 0;
bool equals = true;
bool abort = false;
bool is_first_insert = true;
@@ -1590,16 +1593,18 @@ int rna_property_override_diff_default(PointerRNA *ptr_a, PointerRNA *ptr_b,
/* If false, it means that the whole data itself is different, so no point in going inside of it at all! */
if (iter_b.valid) {
is_valid_for_diffing = rna_property_override_diff_propptr_validate_diffing(
- &iter_a.ptr, &iter_b.ptr, &is_id, &is_null, &is_type_diff,
- &propname_a, buff_a, sizeof(buff_a),
- &propname_b, buff_b, sizeof(buff_b));
+ &iter_a.ptr, &iter_b.ptr, no_prop_name,
+ &is_id, &is_null, &is_type_diff,
+ &propname_a, buff_a, sizeof(buff_a),
+ &propname_b, buff_b, sizeof(buff_b));
}
else {
is_valid_for_diffing = false;
if (is_valid_for_insertion) {
/* We still need propname from 'a' item... */
rna_property_override_diff_propptr_validate_diffing(
- &iter_a.ptr, NULL, &is_id, &is_null, &is_type_diff,
+ &iter_a.ptr, NULL, no_prop_name,
+ &is_id, &is_null, &is_type_diff,
&propname_a, buff_a, sizeof(buff_a),
&propname_b, buff_b, sizeof(buff_b));
}
@@ -1615,7 +1620,7 @@ int rna_property_override_diff_default(PointerRNA *ptr_a, PointerRNA *ptr_b,
printf("Checking %s, %s [%d] vs %s [%d]; diffing: %d; insert: %d (could be used: %d, do_create: %d)\n",
rna_path, propname_a ? propname_a : "", idx_a, propname_b ? propname_b : "", idx_b,
is_valid_for_diffing, is_valid_for_insertion,
- (RNA_property_flag(prop_a) & PROP_OVERRIDABLE_STATIC_INSERTION) != 0, do_create);
+ (RNA_property_override_flag(prop_a) & PROPOVERRIDE_STATIC_INSERTION) != 0, do_create);
}
#endif
@@ -1685,7 +1690,7 @@ int rna_property_override_diff_default(PointerRNA *ptr_a, PointerRNA *ptr_b,
if (equals || do_create) {
const bool no_ownership = (RNA_property_flag(prop_a) & PROP_PTR_NO_OWNERSHIP) != 0;
const int eq = rna_property_override_diff_propptr(
- &iter_a.ptr, &iter_b.ptr, mode, no_ownership,
+ &iter_a.ptr, &iter_b.ptr, mode, no_ownership, no_prop_name,
override, extended_rna_path, flags, r_override_changed);
equals = equals && eq;
}
@@ -2248,18 +2253,18 @@ static void rna_def_struct(BlenderRNA *brna)
RNA_def_property_string_funcs(prop, "rna_Struct_identifier_get", "rna_Struct_identifier_length", NULL);
RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting");
RNA_def_struct_name_property(srna, prop);
-
+
prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_string_funcs(prop, "rna_Struct_description_get", "rna_Struct_description_length", NULL);
RNA_def_property_ui_text(prop, "Description", "Description of the Struct's purpose");
-
+
prop = RNA_def_property(srna, "translation_context", PROP_STRING, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_string_funcs(prop, "rna_Struct_translation_context_get",
"rna_Struct_translation_context_length", NULL);
RNA_def_property_ui_text(prop, "Translation Context", "Translation context of the struct's name");
-
+
prop = RNA_def_property(srna, "base", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "Struct");
@@ -2351,7 +2356,7 @@ static void rna_def_property(BlenderRNA *brna)
RNA_def_property_string_funcs(prop, "rna_Property_identifier_get", "rna_Property_identifier_length", NULL);
RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting");
RNA_def_struct_name_property(srna, prop);
-
+
prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_string_funcs(prop, "rna_Property_description_get", "rna_Property_description_length", NULL);
@@ -2449,7 +2454,7 @@ static void rna_def_property(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, "rna_Property_is_registered_optional_get", NULL);
RNA_def_property_ui_text(prop, "Registered Optionally",
"Property is optionally registered as part of type registration");
-
+
prop = RNA_def_property(srna, "is_runtime", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_boolean_funcs(prop, "rna_Property_is_runtime_get", NULL);
@@ -2517,7 +2522,7 @@ static void rna_def_function(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, "rna_Function_no_self_get", NULL);
RNA_def_property_ui_text(prop, "No Self",
"Function does not pass its self as an argument (becomes a static method in python)");
-
+
prop = RNA_def_property(srna, "use_self_type", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_boolean_funcs(prop, "rna_Function_use_self_type_get", NULL);
@@ -2776,7 +2781,7 @@ void RNA_def_rna(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Collection Definition",
"RNA collection property to define lists, arrays and mappings");
rna_def_pointer_property(srna, PROP_COLLECTION);
-
+
/* Function */
rna_def_function(brna);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 4599ec0f9c5..ae1b60c7d27 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -122,7 +122,7 @@ const EnumPropertyItem rna_enum_snap_target_items[] = {
{SCE_SNAP_TARGET_ACTIVE, "ACTIVE", 0, "Active", "Snap active onto target"},
{0, NULL, 0, NULL, NULL}
};
-
+
const EnumPropertyItem rna_enum_proportional_falloff_items[] = {
{PROP_SMOOTH, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", "Smooth falloff"},
{PROP_SPHERE, "SPHERE", ICON_SPHERECURVE, "Sphere", "Spherical falloff"},
@@ -419,7 +419,7 @@ static const EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = {
{0, "", 0, N_("Interpolation"), "Standard transitions between keyframes"},
{GP_IPO_LINEAR, "LINEAR", ICON_IPO_LINEAR, "Linear", "Straight-line interpolation between A and B (i.e. no ease in/out)"},
{GP_IPO_CURVEMAP, "CUSTOM", ICON_IPO_BEZIER, "Custom", "Custom interpolation defined using a curve map"},
-
+
/* easing */
{0, "", 0, N_("Easing (by strength)"), "Predefined inertial transitions, useful for motion graphics (from least to most ''dramatic'')"},
{GP_IPO_SINE, "SINE", ICON_IPO_SINE, "Sinusoidal", "Sinusoidal easing (weakest, almost linear but with a slight curvature)"},
@@ -429,12 +429,12 @@ static const EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = {
{GP_IPO_QUINT, "QUINT", ICON_IPO_QUINT, "Quintic", "Quintic easing"},
{GP_IPO_EXPO, "EXPO", ICON_IPO_EXPO, "Exponential", "Exponential easing (dramatic)"},
{GP_IPO_CIRC, "CIRC", ICON_IPO_CIRC, "Circular", "Circular easing (strongest and most dynamic)"},
-
+
{0, "", 0, N_("Dynamic Effects"), "Simple physics-inspired easing effects"},
{GP_IPO_BACK, "BACK", ICON_IPO_BACK, "Back", "Cubic easing with overshoot and settle"},
{GP_IPO_BOUNCE, "BOUNCE", ICON_IPO_BOUNCE, "Bounce", "Exponentially decaying parabolic bounce, like when objects collide"},
{GP_IPO_ELASTIC, "ELASTIC", ICON_IPO_ELASTIC, "Elastic", "Exponentially decaying sine wave, like an elastic band"},
-
+
{0, NULL, 0, NULL, NULL}
};
@@ -524,12 +524,12 @@ static char *rna_GPencilInterpolateSettings_path(PointerRNA *UNUSED(ptr))
static void rna_GPencilInterpolateSettings_type_set(PointerRNA *ptr, int value)
{
GP_Interpolate_Settings *settings = (GP_Interpolate_Settings *)ptr->data;
-
+
/* NOTE: This cast should be fine, as we have a small + finite set of values (eGP_Interpolate_Type)
* that should fit well within a char
*/
settings->type = (char)value;
-
+
/* init custom interpolation curve here now the first time it's used */
if ((settings->type == GP_IPO_CURVEMAP) &&
(settings->custom_ipo == NULL))
@@ -642,7 +642,7 @@ static void rna_GPencilBrush_name_set(PointerRNA *ptr, const char *value)
static void rna_SpaceImageEditor_uv_sculpt_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
{
- ED_space_image_uv_sculpt_update(bmain->wm.first, scene);
+ ED_space_image_uv_sculpt_update(bmain, bmain->wm.first, scene);
}
@@ -772,7 +772,7 @@ static void rna_Scene_framelen_update(Main *UNUSED(bmain), Scene *scene, Pointer
static void rna_Scene_frame_current_set(PointerRNA *ptr, int value)
{
Scene *data = (Scene *)ptr->data;
-
+
/* if negative frames aren't allowed, then we can't use them */
FRAMENUMBER_MIN_CLAMP(value);
data->r.cfra = value;
@@ -826,14 +826,14 @@ static void rna_Scene_end_frame_set(PointerRNA *ptr, int value)
static void rna_Scene_use_preview_range_set(PointerRNA *ptr, int value)
{
Scene *data = (Scene *)ptr->data;
-
+
if (value) {
/* copy range from scene if not set before */
if ((data->r.psfra == data->r.pefra) && (data->r.psfra == 0)) {
data->r.psfra = data->r.sfra;
data->r.pefra = data->r.efra;
}
-
+
data->r.flag |= SCER_PRV_RANGE;
}
else
@@ -844,14 +844,14 @@ static void rna_Scene_use_preview_range_set(PointerRNA *ptr, int value)
static void rna_Scene_preview_range_start_frame_set(PointerRNA *ptr, int value)
{
Scene *data = (Scene *)ptr->data;
-
+
/* check if enabled already */
if ((data->r.flag & SCER_PRV_RANGE) == 0) {
/* set end of preview range to end frame, then clamp as per normal */
/* TODO: or just refuse to set instead? */
data->r.pefra = data->r.efra;
}
-
+
/* now set normally */
CLAMP(value, MINAFRAME, data->r.pefra);
data->r.psfra = value;
@@ -860,14 +860,14 @@ static void rna_Scene_preview_range_start_frame_set(PointerRNA *ptr, int value)
static void rna_Scene_preview_range_end_frame_set(PointerRNA *ptr, int value)
{
Scene *data = (Scene *)ptr->data;
-
+
/* check if enabled already */
if ((data->r.flag & SCER_PRV_RANGE) == 0) {
/* set start of preview range to start frame, then clamp as per normal */
/* TODO: or just refuse to set instead? */
data->r.psfra = data->r.sfra;
}
-
+
/* now set normally */
CLAMP(value, data->r.psfra, MAXFRAME);
data->r.pefra = value;
@@ -896,7 +896,7 @@ static void rna_Scene_active_keying_set_set(PointerRNA *ptr, PointerRNA value)
{
Scene *scene = (Scene *)ptr->data;
KeyingSet *ks = (KeyingSet *)value.data;
-
+
scene->active_keyingset = ANIM_scene_get_keyingset_index(scene, ks);
}
@@ -926,7 +926,7 @@ extern ListBase builtin_keyingsets;
static void rna_Scene_all_keyingsets_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Scene *scene = (Scene *)ptr->data;
-
+
/* start going over the scene KeyingSets first, while we still have pointer to it
* but only if we have any Keying Sets to use...
*/
@@ -940,13 +940,13 @@ static void rna_Scene_all_keyingsets_next(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal = &iter->internal.listbase;
KeyingSet *ks = (KeyingSet *)internal->link;
-
+
/* if we've run out of links in Scene list, jump over to the builtins list unless we're there already */
if ((ks->next == NULL) && (ks != builtin_keyingsets.last))
internal->link = (Link *)builtin_keyingsets.first;
else
internal->link = (Link *)ks->next;
-
+
iter->valid = (internal->link != NULL);
}
@@ -1416,7 +1416,7 @@ static const EnumPropertyItem *rna_RenderSettings_engine_itemf(
tmp.name = type->name;
RNA_enum_item_add(&item, &totitem, &tmp);
}
-
+
RNA_enum_item_end(&item, &totitem);
*r_free = true;
@@ -1432,7 +1432,7 @@ static int rna_RenderSettings_engine_get(PointerRNA *ptr)
for (type = R_engines.first; type; type = type->next, a++)
if (STREQ(type->idname, rd->engine))
return a;
-
+
return 0;
}
@@ -1592,7 +1592,7 @@ static void object_simplify_update(Object *ob)
for (psys = ob->particlesystem.first; psys; psys = psys->next)
psys->recalc |= PSYS_RECALC_CHILD;
-
+
if (ob->dup_group) {
CollectionObject *cob;
@@ -1617,7 +1617,7 @@ static void rna_Scene_use_simplify_update(Main *bmain, Scene *UNUSED(scene), Poi
for (SETLOOPER_SET_ONLY(sce, sce_iter, base)) {
object_simplify_update(base->object);
}
-
+
WM_main_add_notifier(NC_GEOM | ND_DATA, NULL);
DEG_id_tag_update(&sce->id, 0);
}
@@ -1727,7 +1727,7 @@ static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, cons
/* call the API func, and set the active keyingset index */
ks = BKE_keyingset_add(&sce->keyingsets, idname, name, KEYINGSET_ABSOLUTE, 0);
-
+
if (ks) {
sce->active_keyingset = BLI_listbase_count(&sce->keyingsets);
return ks;
@@ -1981,7 +1981,7 @@ static void rna_GPUDOFSettings_update(Main *UNUSED(bmain), Scene *scene, Pointer
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene);
}
-static void rna_Stereo3dFormat_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_Stereo3dFormat_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
ID *id = ptr->id.data;
@@ -1996,7 +1996,7 @@ static void rna_Stereo3dFormat_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf) {
- BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
+ BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_FREE);
}
BKE_image_release_ibuf(ima, ibuf, lock);
}
@@ -2103,13 +2103,13 @@ static void rna_def_gpencil_interpolate(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "GPencilInterpolateSettings", NULL);
RNA_def_struct_sdna(srna, "GP_Interpolate_Settings");
RNA_def_struct_path_func(srna, "rna_GPencilInterpolateSettings_path");
RNA_def_struct_ui_text(srna, "Grease Pencil Interpolate Settings",
"Settings for Grease Pencil interpolation tools");
-
+
/* flags */
prop = RNA_def_property(srna, "interpolate_all_layers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS);
@@ -2120,7 +2120,7 @@ static void rna_def_gpencil_interpolate(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED);
RNA_def_property_ui_text(prop, "Interpolate Selected Strokes", "Interpolate only selected strokes in the original frame");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
/* interpolation type */
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
@@ -2129,38 +2129,38 @@ static void rna_def_gpencil_interpolate(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Type",
"Interpolation method to use the next time 'Interpolate Sequence' is run");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
/* easing */
prop = RNA_def_property(srna, "easing", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "easing");
RNA_def_property_enum_items(prop, rna_enum_beztriple_interpolation_easing_items);
- RNA_def_property_ui_text(prop, "Easing",
+ RNA_def_property_ui_text(prop, "Easing",
"Which ends of the segment between the preceding and following grease pencil frames "
"easing interpolation is applied to");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
/* easing options */
prop = RNA_def_property(srna, "back", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "back");
RNA_def_property_ui_text(prop, "Back", "Amount of overshoot for 'back' easing");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "amplitude");
RNA_def_property_range(prop, 0.0f, FLT_MAX); /* only positive values... */
RNA_def_property_ui_text(prop, "Amplitude", "Amount to boost elastic bounces for 'elastic' easing");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
prop = RNA_def_property(srna, "period", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "period");
RNA_def_property_ui_text(prop, "Period", "Time between bounces for elastic easing");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
/* custom curvemap */
prop = RNA_def_property(srna, "interpolation_curve", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "custom_ipo");
RNA_def_property_struct_type(prop, "CurveMapping");
- RNA_def_property_ui_text(prop, "Interpolation Curve",
+ RNA_def_property_ui_text(prop, "Interpolation Curve",
"Custom curve to control 'sequence' interpolation between Grease Pencil frames");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
}
@@ -2368,14 +2368,14 @@ static void rna_def_transform_orientation(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "TransformOrientation", NULL);
-
+
prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_float_sdna(prop, NULL, "mat");
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_3x3);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
+
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_struct_name_property(srna, prop);
RNA_def_property_ui_text(prop, "Name", "Name of the custom transform orientation");
@@ -2394,7 +2394,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
{UV_SELECT_ISLAND, "ISLAND", ICON_UV_ISLANDSEL, "Island", "Island selection mode"},
{0, NULL, 0, NULL, NULL}
};
-
+
/* the construction of this enum is quite special - everything is stored as bitflags,
* with 1st position only for for on/off (and exposed as boolean), while others are mutually
* exclusive options but which will only have any effect when autokey is enabled
@@ -2435,7 +2435,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
{WT_VGROUP_BONE_DEFORM_OFF, "OTHER_DEFORM", 0, "Other", "Vertex Groups assigned to non Deform Bones"},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem gpencil_source_3d_items[] = {
{GP_TOOL_SOURCE_SCENE, "SCENE", 0, "Scene",
"Grease Pencil data attached to the current scene is used, "
@@ -2445,7 +2445,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
"(required when using pre 2.73 add-ons, e.g. BSurfaces)"},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem gpencil_stroke_placement_items[] = {
{GP_PROJECT_VIEWSPACE, "CURSOR", 0, "Cursor", "Draw stroke at the 3D cursor"},
{0, "VIEW", 0, "View", "Stick stroke to the view "}, /* weird, GP_PROJECT_VIEWALIGN is inverted */
@@ -2453,16 +2453,16 @@ static void rna_def_tool_settings(BlenderRNA *brna)
{GP_PROJECT_VIEWSPACE | GP_PROJECT_DEPTH_STROKE, "STROKE", 0, "Stroke", "Stick stroke to other strokes"},
{0, NULL, 0, NULL, NULL}
};
-
-
+
+
srna = RNA_def_struct(brna, "ToolSettings", NULL);
RNA_def_struct_path_func(srna, "rna_ToolSettings_path");
RNA_def_struct_ui_text(srna, "Tool Settings", "");
-
+
prop = RNA_def_property(srna, "sculpt", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Sculpt");
RNA_def_property_ui_text(prop, "Sculpt", "");
-
+
prop = RNA_def_property(srna, "use_auto_normalize", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_boolean_sdna(prop, NULL, "auto_normalize", 1);
@@ -2582,7 +2582,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "proportional_size");
RNA_def_property_ui_text(prop, "Proportional Size", "Display size for proportional editing circle");
RNA_def_property_range(prop, 0.00001, 5000.0);
-
+
prop = RNA_def_property(srna, "double_threshold", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "doublimit");
RNA_def_property_ui_text(prop, "Double Threshold", "Limit for removing duplicates and 'Auto Merge'");
@@ -2632,14 +2632,14 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_ui_text(prop, "Snap Element", "Type of element to snap to");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
-
+
/* node editor uses own set of snap modes */
prop = RNA_def_property(srna, "snap_node_element", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "snap_node_mode");
RNA_def_property_enum_items(prop, rna_enum_snap_node_element_items);
RNA_def_property_ui_text(prop, "Snap Node Element", "Type of element to snap to");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
-
+
/* image editor uses own set of snap modes */
prop = RNA_def_property(srna, "snap_uv_element", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "snap_uv_mode");
@@ -2658,7 +2658,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Snap Peel Object", "Consider objects as whole when finding volume center");
RNA_def_property_ui_icon(prop, ICON_SNAP_PEEL_OBJECT, 0);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
-
+
prop = RNA_def_property(srna, "use_snap_project", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_PROJECT);
RNA_def_property_ui_text(prop, "Project Individual Elements",
@@ -2678,14 +2678,14 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Use Continuous Drawing",
"Allow drawing multiple strokes at a time with Grease Pencil");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* xxx: need toolbar to be redrawn... */
-
+
prop = RNA_def_property(srna, "use_gpencil_additive_drawing", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_RETAIN_LAST);
RNA_def_property_ui_text(prop, "Use Additive Drawing",
"When creating new frames, the strokes from the previous/active frame "
"are included as the basis for the new one");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
prop = RNA_def_property(srna, "use_gpencil_draw_onback", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_PAINT_ONBACK);
RNA_def_property_ui_text(prop, "Draw Strokes on Back",
@@ -2698,17 +2698,17 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Grease Pencil Source",
"Data-block where active Grease Pencil data is found from");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
-
+
prop = RNA_def_property(srna, "gpencil_sculpt", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "gp_sculpt");
RNA_def_property_struct_type(prop, "GPencilSculptSettings");
RNA_def_property_ui_text(prop, "Grease Pencil Sculpt",
"Settings for stroke sculpting tools and brushes");
-
+
prop = RNA_def_property(srna, "gpencil_interpolate", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "gp_interpolate");
RNA_def_property_struct_type(prop, "GPencilInterpolateSettings");
- RNA_def_property_ui_text(prop, "Grease Pencil Interpolate",
+ RNA_def_property_ui_text(prop, "Grease Pencil Interpolate",
"Settings for Grease Pencil Interpolation tools");
/* Grease Pencil - Drawing brushes */
@@ -2724,12 +2724,12 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_enum_items(prop, gpencil_stroke_placement_items);
RNA_def_property_ui_text(prop, "Stroke Placement (3D View)", "");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
-
+
prop = RNA_def_property(srna, "use_gpencil_stroke_endpoints", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gpencil_v3d_align", GP_PROJECT_DEPTH_STROKE_ENDPOINTS);
RNA_def_property_ui_text(prop, "Only Endpoints", "Only use the first and last parts of the stroke for snapping");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
-
+
/* Grease Pencil - 2D Views Stroke Placement */
prop = RNA_def_property(srna, "gpencil_stroke_placement_view2d", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_v2d_align");
@@ -2743,7 +2743,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_enum_items(prop, gpencil_stroke_placement_items);
RNA_def_property_ui_text(prop, "Stroke Placement (Sequencer Preview)", "");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
-
+
/* Grease Pencil - Image Editor Stroke Placement */
prop = RNA_def_property(srna, "gpencil_stroke_placement_image_editor", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_ima_align");
@@ -2751,36 +2751,36 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Stroke Placement (Image Editor)", "");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
-
+
/* Auto Keying */
prop = RNA_def_property(srna, "use_keyframe_insert_auto", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "autokey_mode", AUTOKEY_ON);
RNA_def_property_ui_text(prop, "Auto Keying", "Automatic keyframe insertion for Objects and Bones");
RNA_def_property_ui_icon(prop, ICON_REC, 0);
-
+
prop = RNA_def_property(srna, "auto_keying_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "autokey_mode");
RNA_def_property_enum_items(prop, auto_key_items);
RNA_def_property_ui_text(prop, "Auto-Keying Mode", "Mode of automatic keyframe insertion for Objects and Bones");
-
+
prop = RNA_def_property(srna, "use_record_with_nla", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", ANIMRECORD_FLAG_WITHNLA);
RNA_def_property_ui_text(prop, "Layered",
"Add a new NLA Track + Strip for every loop/pass made over the animation "
"to allow non-destructive tweaking");
-
+
prop = RNA_def_property(srna, "use_keyframe_insert_keyingset", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_ONLYKEYINGSET);
RNA_def_property_ui_text(prop, "Auto Keyframe Insert Keying Set",
"Automatic keyframe insertion using active Keying Set only");
RNA_def_property_ui_icon(prop, ICON_KEYINGSET, 0);
-
+
/* Keyframing */
prop = RNA_def_property(srna, "keyframe_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "keyframe_type");
RNA_def_property_enum_items(prop, rna_enum_beztriple_keyframe_type_items);
RNA_def_property_ui_text(prop, "New Keyframe Type", "Type of keyframes to create when inserting keyframes");
-
+
/* UV */
prop = RNA_def_property(srna, "uv_select_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "uv_selectmode");
@@ -3172,7 +3172,7 @@ static void rna_def_unit_settings(BlenderRNA *brna)
{USER_UNIT_IMPERIAL, "IMPERIAL", 0, "Imperial", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem rotation_units[] = {
{0, "DEGREES", 0, "Degrees", "Use degrees for measuring angles and rotations"},
{USER_UNIT_ROT_RADIANS, "RADIANS", 0, "Radians", ""},
@@ -3187,7 +3187,7 @@ static void rna_def_unit_settings(BlenderRNA *brna)
RNA_def_property_enum_items(prop, unit_systems);
RNA_def_property_ui_text(prop, "Unit System", "The unit system to use for button display");
RNA_def_property_update(prop, NC_WINDOW, NULL);
-
+
prop = RNA_def_property(srna, "system_rotation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rotation_units);
RNA_def_property_ui_text(prop, "Rotation Units", "Unit to use for displaying/editing rotation values");
@@ -3299,7 +3299,7 @@ void rna_def_view_layer_common(StructRNA *srna, int scene)
RNA_def_property_ui_text(prop, "Z", "Deliver Z values pass");
if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
+
prop = RNA_def_property(srna, "use_pass_vector", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_VECTOR);
RNA_def_property_ui_text(prop, "Vector", "Deliver speed vector pass");
@@ -3353,7 +3353,7 @@ void rna_def_view_layer_common(StructRNA *srna, int scene)
RNA_def_property_ui_text(prop, "AO", "Deliver AO pass");
if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
+
prop = RNA_def_property(srna, "use_pass_emit", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_EMIT);
RNA_def_property_ui_text(prop, "Emit", "Deliver emission pass");
@@ -3425,7 +3425,7 @@ void rna_def_view_layer_common(StructRNA *srna, int scene)
RNA_def_property_ui_text(prop, "Transmission Color", "Deliver transmission color pass");
if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
+
prop = RNA_def_property(srna, "use_pass_subsurface_direct", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SUBSURFACE_DIRECT);
RNA_def_property_ui_text(prop, "Subsurface Direct", "Deliver subsurface direct pass");
@@ -4766,7 +4766,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem alpha_mode_items[] = {
{R_ADDSKY, "SKY", 0, "Sky", "Transparent pixels are filled with sky color"},
{R_ALPHAPREMUL, "TRANSPARENT", 0, "Transparent", "World background is transparent with premultiplied alpha"},
@@ -4832,7 +4832,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
-
+ static const EnumPropertyItem hair_shape_type_items[] = {
+ {SCE_HAIR_SHAPE_STRAND, "STRAND", 0, "Strand", ""},
+ {SCE_HAIR_SHAPE_STRIP, "STRIP", 0, "Strip", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
rna_def_scene_ffmpeg_settings(brna);
@@ -4856,7 +4860,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_range(prop, 4, 65536);
RNA_def_property_ui_text(prop, "Resolution X", "Number of horizontal pixels in the rendered image");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneCamera_update");
-
+
prop = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "ysch");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
@@ -4864,7 +4868,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_range(prop, 4, 65536);
RNA_def_property_ui_text(prop, "Resolution Y", "Number of vertical pixels in the rendered image");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneCamera_update");
-
+
prop = RNA_def_property(srna, "resolution_percentage", PROP_INT, PROP_PERCENTAGE);
RNA_def_property_int_sdna(prop, NULL, "size");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -4872,14 +4876,14 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 1, 100, 10, 1);
RNA_def_property_ui_text(prop, "Resolution %", "Percentage scale for render resolution");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "tile_x", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "tilex");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 8, 65536);
RNA_def_property_ui_text(prop, "Tile X", "Horizontal tile size to use while rendering");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "tile_y", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "tiley");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -4909,7 +4913,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Pixel Aspect X",
"Horizontal aspect ratio - for anamorphic or non-square pixel output");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneCamera_update");
-
+
prop = RNA_def_property(srna, "pixel_aspect_y", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "yasp");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
@@ -4932,7 +4936,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 1, 120, 1, -1);
RNA_def_property_ui_text(prop, "FPS", "Framerate, expressed in frames per second");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_fps_update");
-
+
prop = RNA_def_property(srna, "fps_base", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "frs_sec_base");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -4940,7 +4944,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.1f, 120.0f, 2, -1);
RNA_def_property_ui_text(prop, "FPS Base", "Framerate base");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_fps_update");
-
+
/* frame mapping */
prop = RNA_def_property(srna, "frame_map_old", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "framapto");
@@ -4948,7 +4952,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_range(prop, 1, 900);
RNA_def_property_ui_text(prop, "Frame Map Old", "Old mapping value in frames");
RNA_def_property_update(prop, NC_SCENE | ND_FRAME, "rna_Scene_framelen_update");
-
+
prop = RNA_def_property(srna, "frame_map_new", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "images");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -4956,7 +4960,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Frame Map New", "How many frames the Map Old will last");
RNA_def_property_update(prop, NC_SCENE | ND_FRAME, "rna_Scene_framelen_update");
-
+
prop = RNA_def_property(srna, "dither_intensity", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "dither_intensity");
RNA_def_property_range(prop, 0.0f, 2.0f);
@@ -4982,14 +4986,14 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Anti-Aliasing",
"Render and combine multiple samples per pixel to prevent jagged edges");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "antialiasing_samples", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "osa");
RNA_def_property_enum_items(prop, fixed_oversample_items);
RNA_def_property_ui_text(prop, "Anti-Aliasing Samples", "Amount of anti-aliasing samples per pixel");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_EDGE_FRS);
@@ -5005,21 +5009,21 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
"Number of CPU threads to use simultaneously while rendering "
"(for multi-core/CPU systems)");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "threads_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
RNA_def_property_enum_items(prop, threads_mode_items);
RNA_def_property_enum_funcs(prop, "rna_RenderSettings_threads_mode_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Threads Mode", "Determine the amount of render threads used");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
/* motion blur */
prop = RNA_def_property(srna, "use_motion_blur", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_MBLUR);
RNA_def_property_ui_text(prop, "Motion Blur", "Use multi-sampled 3D scene motion blur");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
-
+
prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_sdna(prop, NULL, "blurfac");
RNA_def_property_ui_range(prop, 0.01f, 2.0f, 1, 2);
@@ -5031,14 +5035,25 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "mblur_shutter_curve");
RNA_def_property_struct_type(prop, "CurveMapping");
RNA_def_property_ui_text(prop, "Shutter Curve", "Curve defining the shutter's openness over time");
-
+
+ /* Hairs */
+ prop = RNA_def_property(srna, "hair_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, hair_shape_type_items);
+ RNA_def_property_ui_text(prop, "Hair Shape Type", "Hair shape type");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
+
+ prop = RNA_def_property(srna, "hair_subdiv", PROP_INT, PROP_NONE);
+ RNA_def_property_range(prop, 0, 3);
+ RNA_def_property_ui_text(prop, "Additional Subdiv", "Additional subdivision along the hair");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
+
/* border */
prop = RNA_def_property(srna, "use_border", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_BORDER);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Border", "Render a user-defined border region, within the frame size ");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "border_min_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "border.xmin");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -5066,24 +5081,24 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Border Maximum Y", "Maximum Y value for the render border");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_crop_to_border", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_CROP);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Crop to Border", "Crop the rendered frame to the defined border size");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_placeholder", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_TOUCH);
RNA_def_property_ui_text(prop, "Placeholders",
"Create empty placeholder files while rendering frames (similar to Unix 'touch')");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_overwrite", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", R_NO_OVERWRITE);
RNA_def_property_ui_text(prop, "Overwrite", "Overwrite existing files while rendering");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_compositing", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_DOCOMP);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -5091,7 +5106,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
"Process the render result through the compositing pipeline, "
"if compositing nodes are enabled");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_sequencer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_DOSEQ);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -5099,7 +5114,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
"Process the render (and composited) result through the video sequence "
"editor pipeline, if sequencer strips exist");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_file_extension", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_EXTENSION);
RNA_def_property_ui_text(prop, "File Extensions",
@@ -5131,7 +5146,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
"Save tiles for all RenderLayers and SceneNodes to files in the temp directory "
"(saves memory, required for Full Sample)");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_full_sample", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FULL_SAMPLE);
RNA_def_property_ui_text(prop, "Full Sample",
@@ -5167,7 +5182,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
/* Bake */
-
+
prop = RNA_def_property(srna, "bake_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "bake_mode");
RNA_def_property_enum_items(prop, bake_mode_items);
@@ -5228,23 +5243,23 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
"apply a user scale to the derivative map");
/* stamp */
-
+
prop = RNA_def_property(srna, "use_stamp_time", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_TIME);
RNA_def_property_ui_text(prop, "Stamp Time",
"Include the rendered frame timecode as HH:MM:SS.FF in image metadata");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_stamp_date", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_DATE);
RNA_def_property_ui_text(prop, "Stamp Date", "Include the current date in image/video metadata");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_stamp_frame", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_FRAME);
RNA_def_property_ui_text(prop, "Stamp Frame", "Include the frame number in image metadata");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_stamp_frame_range", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_FRAME_RANGE);
RNA_def_property_ui_text(prop, "Stamp Frame", "Include the rendered frame range in image/video metadata");
@@ -5259,27 +5274,27 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_CAMERALENS);
RNA_def_property_ui_text(prop, "Stamp Lens", "Include the active camera's lens in image metadata");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_stamp_scene", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_SCENE);
RNA_def_property_ui_text(prop, "Stamp Scene", "Include the name of the active scene in image/video metadata");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_stamp_note", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_NOTE);
RNA_def_property_ui_text(prop, "Stamp Note", "Include a custom note in image/video metadata");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_stamp_marker", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_MARKER);
RNA_def_property_ui_text(prop, "Stamp Marker", "Include the name of the last marker in image metadata");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_stamp_filename", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_FILENAME);
RNA_def_property_ui_text(prop, "Stamp Filename", "Include the .blend filename in image/video metadata");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "use_stamp_sequencer_strip", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_SEQSTRIP);
RNA_def_property_ui_text(prop, "Stamp Sequence Strip",
@@ -5290,7 +5305,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_RENDERTIME);
RNA_def_property_ui_text(prop, "Stamp Render Time", "Include the render time in image metadata");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "stamp_note_text", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "stamp_udata");
RNA_def_property_ui_text(prop, "Stamp Note Text", "Custom text to appear in the stamp note");
@@ -5328,7 +5343,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_text(prop, "Text Color", "Color to use for stamp text");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
prop = RNA_def_property(srna, "stamp_background", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "bg_stamp");
RNA_def_property_array(prop, 4);
@@ -5560,7 +5575,7 @@ static void rna_def_scene_keying_sets(BlenderRNA *brna, PropertyRNA *cprop)
"rna_Scene_active_keying_set_set", NULL, NULL);
RNA_def_property_ui_text(prop, "Active Keying Set", "Active Keying Set used to insert/delete keyframes");
RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET, NULL);
-
+
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "active_keyingset");
RNA_def_property_int_funcs(prop, "rna_Scene_active_keying_set_index_get",
@@ -5574,14 +5589,14 @@ static void rna_def_scene_keying_sets_all(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
RNA_def_property_srna(cprop, "KeyingSetsAll");
srna = RNA_def_struct(brna, "KeyingSetsAll", NULL);
RNA_def_struct_sdna(srna, "Scene");
RNA_def_struct_ui_text(srna, "Keying Sets All", "All available keying sets");
-
+
/* NOTE: no add/remove available here, without screwing up this amalgamated list... */
-
+
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "KeyingSet");
RNA_def_property_flag(prop, PROP_EDITABLE);
@@ -5589,7 +5604,7 @@ static void rna_def_scene_keying_sets_all(BlenderRNA *brna, PropertyRNA *cprop)
"rna_Scene_active_keying_set_set", NULL, NULL);
RNA_def_property_ui_text(prop, "Active Keying Set", "Active Keying Set used to insert/delete keyframes");
RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET, NULL);
-
+
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "active_keyingset");
RNA_def_property_int_funcs(prop, "rna_Scene_active_keying_set_index_get",
@@ -5759,7 +5774,7 @@ static void rna_def_scene_display(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 250.0f);
prop = RNA_def_property(srna, "matcap_ssao_factor_edge", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Edge Strength", "Strength of the Edge effect");
RNA_def_property_range(prop, 0.0f, 250.0f);
@@ -5837,337 +5852,337 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Diffuse Bounces", "Number of time the light is reinjected inside light grids, "
"0 disable indirect diffuse light");
RNA_def_property_range(prop, 0, INT_MAX);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "gi_cubemap_resolution", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, eevee_shadow_size_items);
RNA_def_property_enum_default(prop, 512);
RNA_def_property_ui_text(prop, "Cubemap Size", "Size of every cubemaps");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "gi_visibility_resolution", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, eevee_gi_visibility_size_items);
RNA_def_property_enum_default(prop, 32);
RNA_def_property_ui_text(prop, "Irradiance Visibility Size",
"Size of the shadow map applied to each irradiance sample");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
/* Temporal Anti-Aliasing (super sampling) */
prop = RNA_def_property(srna, "taa_samples", PROP_INT, PROP_NONE);
RNA_def_property_int_default(prop, 16);
RNA_def_property_ui_text(prop, "Viewport Samples", "Number of samples, unlimited if 0");
RNA_def_property_range(prop, 0, INT_MAX);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "taa_render_samples", PROP_INT, PROP_NONE);
RNA_def_property_int_default(prop, 64);
RNA_def_property_ui_text(prop, "Render Samples", "Number of samples per pixels for rendering");
RNA_def_property_range(prop, 1, INT_MAX);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "use_taa_reprojection", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_TAA_REPROJECTION);
RNA_def_property_boolean_default(prop, 1);
RNA_def_property_ui_text(prop, "Viewport Denoising", "Denoise image using temporal reprojection "
"(can leave some ghosting)");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
/* Screen Space Subsurface Scattering */
prop = RNA_def_property(srna, "use_sss", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SSS_ENABLED);
RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "Subsurface Scattering", "Enable screen space subsurface scattering");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "sss_samples", PROP_INT, PROP_NONE);
RNA_def_property_int_default(prop, 7);
RNA_def_property_ui_text(prop, "Samples", "Number of samples to compute the scattering effect");
RNA_def_property_range(prop, 1, 32);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "sss_jitter_threshold", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 0.3f);
RNA_def_property_ui_text(prop, "Jitter Threshold", "Rotate samples that are below this threshold");
RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "use_sss_separate_albedo", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SSS_SEPARATE_ALBEDO);
RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "Separate Albedo", "Avoid albedo being blured by the subsurface scattering "
"but uses more video memory");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
/* Screen Space Reflection */
prop = RNA_def_property(srna, "use_ssr", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SSR_ENABLED);
RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "Screen Space Reflections", "Enable screen space reflection");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "use_ssr_refraction", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SSR_REFRACTION);
RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "Screen Space Refractions", "Enable screen space Refractions");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "use_ssr_halfres", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SSR_HALF_RESOLUTION);
RNA_def_property_boolean_default(prop, 1);
RNA_def_property_ui_text(prop, "Half Res Trace", "Raytrace at a lower resolution");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "ssr_quality", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 0.25f);
RNA_def_property_ui_text(prop, "Trace Quality", "Quality of the screen space raytracing");
RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "ssr_max_roughness", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(prop, "Max Roughness", "Do not raytrace reflections for roughness above this value");
RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "ssr_thickness", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_default(prop, 0.2f);
RNA_def_property_ui_text(prop, "Thickness", "Pixel thickness used to detect intersection");
RNA_def_property_range(prop, 1e-6f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 5, 3);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "ssr_border_fade", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 0.075f);
RNA_def_property_ui_text(prop, "Edge Fading", "Screen percentage used to fade the SSR");
RNA_def_property_range(prop, 0.0f, 0.5f);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "ssr_firefly_fac", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, 10.0f);
RNA_def_property_ui_text(prop, "Clamp", "Clamp pixel intensity to remove noise (0 to disabled)");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
/* Volumetrics */
prop = RNA_def_property(srna, "use_volumetric", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_VOLUMETRIC_ENABLED);
RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "Volumetrics", "Enable scattering and absorbance of volumetric material");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "volumetric_start", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_default(prop, 0.1f);
RNA_def_property_ui_text(prop, "Start", "Start distance of the volumetric effect");
RNA_def_property_range(prop, 1e-6f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "volumetric_end", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_default(prop, 100.0f);
RNA_def_property_ui_text(prop, "End", "End distance of the volumetric effect");
RNA_def_property_range(prop, 1e-6f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "volumetric_tile_size", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_default(prop, 8);
RNA_def_property_enum_items(prop, eevee_volumetric_tile_size_items);
RNA_def_property_ui_text(prop, "Tile Size", "Control the quality of the volumetric effects "
"(lower size increase vram usage and quality)");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "volumetric_samples", PROP_INT, PROP_NONE);
RNA_def_property_int_default(prop, 64);
RNA_def_property_ui_text(prop, "Samples", "Number of samples to compute volumetric effects");
RNA_def_property_range(prop, 1, 256);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "volumetric_sample_distribution", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 0.8f);
RNA_def_property_ui_text(prop, "Exponential Sampling", "Distribute more samples closer to the camera");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "use_volumetric_lights", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_VOLUMETRIC_LIGHTS);
RNA_def_property_boolean_default(prop, 1);
RNA_def_property_ui_text(prop, "Volumetric Lighting", "Enable scene lamps interactions with volumetrics");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "volumetric_light_clamp", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, 0.0f);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_text(prop, "Clamp", "Maximum light contribution, reducing noise");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "use_volumetric_shadows", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_VOLUMETRIC_SHADOWS);
RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "Volumetric Shadows", "Generate shadows from volumetric material (Very expensive)");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "volumetric_shadow_samples", PROP_INT, PROP_NONE);
RNA_def_property_int_default(prop, 16);
RNA_def_property_range(prop, 1, 128);
RNA_def_property_ui_text(prop, "Volumetric Shadow Samples", "Number of samples to compute volumetric shadowing");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "use_volumetric_colored_transmittance", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_VOLUMETRIC_COLORED);
RNA_def_property_boolean_default(prop, 1);
RNA_def_property_ui_text(prop, "Colored Transmittance", "Enable wavelength dependent volumetric transmittance");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
/* Ambient Occlusion */
prop = RNA_def_property(srna, "use_gtao", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_GTAO_ENABLED);
RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "Ambient Occlusion", "Enable ambient occlusion to simulate medium scale indirect shadowing");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "use_gtao_bent_normals", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_GTAO_BENT_NORMALS);
RNA_def_property_boolean_default(prop, 1);
RNA_def_property_ui_text(prop, "Bent Normals", "Compute main non occluded direction to sample the environment");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "use_gtao_bounce", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_GTAO_BOUNCE);
RNA_def_property_boolean_default(prop, 1);
RNA_def_property_ui_text(prop, "Bounces Approximation", "An approximation to simulate light bounces "
"giving less occlusion on brighter objects");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "gtao_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Factor", "Factor for ambient occlusion blending");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1f, 2);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "gtao_quality", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 0.25f);
RNA_def_property_ui_text(prop, "Trace Quality", "Quality of the horizon search");
RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "gtao_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_default(prop, 0.2f);
RNA_def_property_ui_text(prop, "Distance", "Distance of object that contribute to the ambient occlusion effect");
RNA_def_property_range(prop, 0.0f, 100000.0f);
RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
/* Depth of Field */
prop = RNA_def_property(srna, "use_dof", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_DOF_ENABLED);
RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "Depth of Field", "Enable depth of field using the values from the active camera");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "bokeh_max_size", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 100.0f);
RNA_def_property_ui_text(prop, "Max Size", "Max size of the bokeh shape for the depth of field (lower is faster)");
RNA_def_property_range(prop, 0.0f, 2000.0f);
RNA_def_property_ui_range(prop, 2.0f, 200.0f, 1, 3);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "bokeh_threshold", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Sprite Threshold", "Brightness threshold for using sprite base depth of field");
RNA_def_property_range(prop, 0.0f, 100000.0f);
RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
/* Bloom */
prop = RNA_def_property(srna, "use_bloom", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_BLOOM_ENABLED);
RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "Bloom", "High brighness pixels generate a glowing effect");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "bloom_threshold", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 0.8f);
RNA_def_property_ui_text(prop, "Threshold", "Filters out pixels under this level of brightness");
RNA_def_property_range(prop, 0.0f, 100000.0f);
RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "bloom_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_array_default(prop, default_bloom_color);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Color", "Color applied to the bloom effect");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "bloom_knee", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(prop, "Knee", "Makes transition between under/over-threshold gradual");
RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "bloom_radius", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 6.5f);
RNA_def_property_ui_text(prop, "Radius", "Bloom spread distance");
RNA_def_property_range(prop, 0.0f, 100.0f);
RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "bloom_clamp", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Clamp", "Maximum intensity a bloom pixel can have");
RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "bloom_intensity", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_default(prop, 0.8f);
RNA_def_property_ui_text(prop, "Intensity", "Blend factor");
RNA_def_property_range(prop, 0.0f, 10000.0f);
RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
/* Motion blur */
prop = RNA_def_property(srna, "use_motion_blur", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_MOTION_BLUR_ENABLED);
RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "Motion Blur", "Enable motion blur effect (only in camera view)");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "motion_blur_samples", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_default(prop, 8);
RNA_def_property_ui_text(prop, "Samples", "Number of samples to take with motion blur");
RNA_def_property_range(prop, 1, 64);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close");
RNA_def_property_ui_range(prop, 0.01f, 2.0f, 1, 2);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
/* Shadows */
prop = RNA_def_property(srna, "shadow_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_default(prop, SHADOW_ESM);
RNA_def_property_enum_items(prop, eevee_shadow_method_items);
RNA_def_property_ui_text(prop, "Method", "Technique use to compute the shadows");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "shadow_cube_size", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_default(prop, 512);
RNA_def_property_enum_items(prop, eevee_shadow_size_items);
RNA_def_property_ui_text(prop, "Cube Shadows Resolution", "Size of point and area lamps shadow maps");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "shadow_cascade_size", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_default(prop, 1024);
RNA_def_property_enum_items(prop, eevee_shadow_size_items);
RNA_def_property_ui_text(prop, "Directional Shadows Resolution", "Size of sun lamps shadow maps");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
prop = RNA_def_property(srna, "use_shadow_high_bitdepth", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SHADOW_HIGH_BITDEPTH);
RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "High Bitdepth", "Use 32bit shadows");
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
}
void RNA_def_scene(BlenderRNA *brna)
@@ -6177,7 +6192,7 @@ void RNA_def_scene(BlenderRNA *brna)
FunctionRNA *func;
PropertyRNA *parm;
-
+
static const EnumPropertyItem audio_distance_model_items[] = {
{0, "NONE", 0, "None", "No distance attenuation"},
{1, "INVERSE", 0, "Inverse", "Inverse distance model"},
@@ -6202,7 +6217,7 @@ void RNA_def_scene(BlenderRNA *brna)
"defining time and render related settings");
RNA_def_struct_ui_icon(srna, ICON_SCENE_DATA);
RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
-
+
/* Global Settings */
prop = RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE);
@@ -6270,7 +6285,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Current Frame",
"Current Frame, to update animation data from python frame_set() instead");
RNA_def_property_update(prop, NC_SCENE | ND_FRAME, "rna_Scene_frame_update");
-
+
prop = RNA_def_property(srna, "frame_subframe", PROP_FLOAT, PROP_TIME);
RNA_def_property_float_sdna(prop, NULL, "r.subframe");
RNA_def_property_ui_text(prop, "Current Sub-Frame", "");
@@ -6295,7 +6310,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_int_default(prop, 1);
RNA_def_property_ui_text(prop, "Start Frame", "First frame of the playback/rendering range");
RNA_def_property_update(prop, NC_SCENE | ND_FRAME_RANGE, NULL);
-
+
prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_sdna(prop, NULL, "r.efra");
@@ -6304,7 +6319,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_int_default(prop, 250);
RNA_def_property_ui_text(prop, "End Frame", "Final frame of the playback/rendering range");
RNA_def_property_update(prop, NC_SCENE | ND_FRAME_RANGE, NULL);
-
+
prop = RNA_def_property(srna, "frame_step", PROP_INT, PROP_TIME);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_sdna(prop, NULL, "r.frame_step");
@@ -6313,7 +6328,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Frame Step",
"Number of frames to skip forward while rendering/playing back each frame");
RNA_def_property_update(prop, NC_SCENE | ND_FRAME, NULL);
-
+
prop = RNA_def_property(srna, "frame_current_final", PROP_FLOAT, PROP_TIME);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
@@ -6338,14 +6353,14 @@ void RNA_def_scene(BlenderRNA *brna)
"OpenGL renders instead of the Render properties start/end frame range");
RNA_def_property_update(prop, NC_SCENE | ND_FRAME, NULL);
RNA_def_property_ui_icon(prop, ICON_PREVIEW_RANGE, 0);
-
+
prop = RNA_def_property(srna, "frame_preview_start", PROP_INT, PROP_TIME);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_sdna(prop, NULL, "r.psfra");
RNA_def_property_int_funcs(prop, NULL, "rna_Scene_preview_range_start_frame_set", NULL);
RNA_def_property_ui_text(prop, "Preview Range Start Frame", "Alternative start frame for UI playback");
RNA_def_property_update(prop, NC_SCENE | ND_FRAME, NULL);
-
+
prop = RNA_def_property(srna, "frame_preview_end", PROP_INT, PROP_TIME);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_sdna(prop, NULL, "r.pefra");
@@ -6368,16 +6383,16 @@ void RNA_def_scene(BlenderRNA *brna)
"Consider keyframes for active Object and/or its selected bones only "
"(in timeline and when jumping between keyframes)");
RNA_def_property_update(prop, NC_SCENE | ND_FRAME, NULL);
-
+
/* Stamp */
prop = RNA_def_property(srna, "use_stamp_note", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "r.stamp_udata");
RNA_def_property_ui_text(prop, "Stamp Note", "User defined note for the render stamping");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
+
/* Animation Data (for Scene) */
rna_def_animdata_common(srna);
-
+
/* Readonly Properties */
prop = RNA_def_property(srna, "is_nla_tweakmode", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_NLA_EDIT_ON);
@@ -6385,7 +6400,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "NLA TweakMode",
"Whether there is any action referenced by NLA being edited (strictly read-only)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
-
+
/* Frame dropping flag for playback and sync enum */
#if 0 /* XXX: Is this actually needed? */
prop = RNA_def_property(srna, "use_frame_drop", PROP_BOOLEAN, PROP_NONE);
@@ -6412,13 +6427,13 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_ui_text(prop, "Use Nodes", "Enable the compositing node tree");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_use_nodes_update");
-
+
/* Sequencer */
prop = RNA_def_property(srna, "sequence_editor", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "ed");
RNA_def_property_struct_type(prop, "SequenceEditor");
RNA_def_property_ui_text(prop, "Sequence Editor", "");
-
+
/* Keying Sets */
prop = RNA_def_property(srna, "keying_sets", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "keyingsets", NULL);
@@ -6426,7 +6441,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Absolute Keying Sets", "Absolute Keying Sets for this Scene");
RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET, NULL);
rna_def_scene_keying_sets(brna, prop);
-
+
prop = RNA_def_property(srna, "keying_sets_all", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_funcs(prop, "rna_Scene_all_keyingsets_begin", "rna_Scene_all_keyingsets_next",
"rna_iterator_listbase_end", "rna_iterator_listbase_get",
@@ -6436,14 +6451,14 @@ void RNA_def_scene(BlenderRNA *brna)
"All Keying Sets available for use (Builtins and Absolute Keying Sets for this Scene)");
RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET, NULL);
rna_def_scene_keying_sets_all(brna, prop);
-
+
/* Rigid Body Simulation */
prop = RNA_def_property(srna, "rigidbody_world", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "rigidbody_world");
RNA_def_property_struct_type(prop, "RigidBodyWorld");
RNA_def_property_ui_text(prop, "Rigid Body World", "");
RNA_def_property_update(prop, NC_SCENE, NULL);
-
+
/* Tool Settings */
prop = RNA_def_property(srna, "tool_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
@@ -6470,7 +6485,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "physics_settings.flag", PHYS_GLOBAL_GRAVITY);
RNA_def_property_ui_text(prop, "Global Gravity", "Use global gravity for all dynamics");
RNA_def_property_update(prop, 0, "rna_Physics_update");
-
+
/* Render Data */
prop = RNA_def_property(srna, "render", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
@@ -6505,7 +6520,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "TransformOrientation");
RNA_def_property_pointer_funcs(prop, "rna_Scene_current_orientation_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Current Transform Orientation", "Current transformation orientation");
-
+
/* Audio Settings */
prop = RNA_def_property(srna, "use_audio", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Scene_use_audio_get", "rna_Scene_use_audio_set");
@@ -6560,7 +6575,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
parm = RNA_def_string(func, "statistics", NULL, 0, "Statistics", "");
RNA_def_function_return(func, parm);
-
+
/* Grease Pencil */
prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "gpd");
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index a307aff6e96..003e2561a22 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -105,7 +105,7 @@ static void rna_Scene_frame_set(Scene *scene, Main *bmain, int frame, float subf
/* cant use NC_SCENE|ND_FRAME because this causes wm_event_do_notifiers to call
* BKE_scene_graph_update_for_newframe which will loose any un-keyed changes [#24690] */
/* WM_main_add_notifier(NC_SCENE|ND_FRAME, scene); */
-
+
/* instead just redraw the views */
WM_main_add_notifier(NC_WINDOW, NULL);
}
@@ -158,13 +158,13 @@ static void rna_SceneRender_get_frame_path(
}
else {
BKE_image_path_from_imformat(
- name, rd->pic, bmain->name, (frame == INT_MIN) ? rd->cfra : frame,
+ name, rd->pic, BKE_main_blendfile_path(bmain), (frame == INT_MIN) ? rd->cfra : frame,
&rd->im_format, (rd->scemode & R_EXTENSION) != 0, true, suffix);
}
}
static void rna_Scene_ray_cast(
- Scene *scene, ViewLayer *view_layer,
+ Scene *scene, Main *bmain, ViewLayer *view_layer,
float origin[3], float direction[3], float ray_dist,
int *r_success, float r_location[3], float r_normal[3], int *r_index,
Object **r_ob, float r_obmat[16])
@@ -172,8 +172,7 @@ static void rna_Scene_ray_cast(
normalize_v3(direction);
Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
- SnapObjectContext *sctx = ED_transform_snap_object_context_create(
- scene, depsgraph, 0);
+ SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, depsgraph, 0);
bool ret = ED_transform_snap_object_project_ray_ex(
sctx,
@@ -306,9 +305,10 @@ void RNA_api_scene(StructRNA *srna)
parm = RNA_def_float_vector(func, "result", 2, NULL, 0.0f, FLT_MAX, "", "aspect", 0.0f, FLT_MAX);
RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_function_output(func, parm);
-
+
/* Ray Cast */
func = RNA_def_function(srna, "ray_cast", "rna_Scene_ray_cast");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
RNA_def_function_ui_description(func, "Cast a ray onto in object space");
parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Scene Layer");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index b8c7eff6241..e30b75b27bd 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -58,6 +58,7 @@ const EnumPropertyItem rna_enum_region_type_items[] = {
#include "BKE_global.h"
#include "BKE_workspace.h"
+#include "BKE_screen.h"
#include "DEG_depsgraph.h"
@@ -145,7 +146,7 @@ static const EnumPropertyItem *rna_Area_type_itemf(bContext *UNUSED(C), PointerR
/* +1 to skip SPACE_EMPTY */
for (const EnumPropertyItem *item_from = rna_enum_space_type_items + 1; item_from->identifier; item_from++) {
- if (ELEM(item_from->value, SPACE_TOPBAR, SPACE_STATUSBAR)) {
+ if (ELEM(item_from->value, SPACE_TOPBAR, SPACE_STATUSBAR, SPACE_USERPREF)) {
continue;
}
RNA_enum_item_add(&item, &totitem, item_from);
@@ -166,7 +167,7 @@ static int rna_Area_type_get(PointerRNA *ptr)
static void rna_Area_type_set(PointerRNA *ptr, int value)
{
- if (ELEM(value, SPACE_TOPBAR, SPACE_STATUSBAR)) {
+ if (ELEM(value, SPACE_TOPBAR, SPACE_STATUSBAR, SPACE_USERPREF)) {
/* Special case: An area can not be set to show the top-bar editor (or
* other global areas). However it should still be possible to identify
* its type from Python. */
@@ -214,6 +215,75 @@ static void rna_Area_type_update(bContext *C, PointerRNA *ptr)
}
}
+
+static const EnumPropertyItem *rna_Area_ui_type_itemf(
+ bContext *C, PointerRNA *UNUSED(ptr),
+ PropertyRNA *UNUSED(prop), bool *r_free)
+{
+ EnumPropertyItem *item = NULL;
+ int totitem = 0;
+
+ /* +1 to skip SPACE_EMPTY */
+ for (const EnumPropertyItem *item_from = rna_enum_space_type_items + 1; item_from->identifier; item_from++) {
+ if (ELEM(item_from->value, SPACE_TOPBAR, SPACE_STATUSBAR, SPACE_USERPREF)) {
+ continue;
+ }
+
+ SpaceType *st = item_from->identifier[0] ? BKE_spacetype_from_id(item_from->value) : NULL;
+ int totitem_prev = totitem;
+ if (st && st->space_subtype_item_extend != NULL) {
+ st->space_subtype_item_extend(C, &item, &totitem);
+ while (totitem_prev < totitem) {
+ item[totitem_prev++].value |= item_from->value << 16;
+ }
+ }
+ else {
+ RNA_enum_item_add(&item, &totitem, item_from);
+ item[totitem_prev++].value = item_from->value << 16;
+ }
+ }
+ RNA_enum_item_end(&item, &totitem);
+ *r_free = true;
+
+ return item;
+}
+
+static int rna_Area_ui_type_get(PointerRNA *ptr)
+{
+ int value = rna_Area_type_get(ptr) << 16;
+ ScrArea *sa = ptr->data;
+ if (sa->type->space_subtype_item_extend != NULL) {
+ value |= sa->type->space_subtype_get(sa);
+ }
+ return value;
+}
+
+static void rna_Area_ui_type_set(PointerRNA *ptr, int value)
+{
+ ScrArea *sa = ptr->data;
+ const int space_type = value >> 16;
+ SpaceType *st = BKE_spacetype_from_id(space_type);
+
+ rna_Area_type_set(ptr, space_type);
+
+ if (st && st->space_subtype_item_extend != NULL) {
+ sa->butspacetype_subtype = value & 0xffff;
+ }
+}
+
+static void rna_Area_ui_type_update(bContext *C, PointerRNA *ptr)
+{
+ ScrArea *sa = ptr->data;
+ SpaceType *st = BKE_spacetype_from_id(sa->butspacetype);
+
+ rna_Area_type_update(C, ptr);
+
+ if ((sa->type == st) && (st->space_subtype_item_extend != NULL)) {
+ st->space_subtype_set(sa, sa->butspacetype_subtype);
+ }
+ sa->butspacetype_subtype = 0;
+}
+
static void rna_View2D_region_to_view(struct View2D *v2d, int x, int y, float result[2])
{
UI_view2d_region_to_view(v2d, x, y, &result[0], &result[1]);
@@ -284,6 +354,15 @@ static void rna_def_area(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, 0, "rna_Area_type_update");
+ prop = RNA_def_property(srna, "ui_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, DummyRNA_DEFAULT_items); /* infact dummy */
+ RNA_def_property_enum_default(prop, 0);
+ RNA_def_property_enum_funcs(prop, "rna_Area_ui_type_get", "rna_Area_ui_type_set", "rna_Area_ui_type_itemf");
+ RNA_def_property_ui_text(prop, "Editor Type", "Current editor type for this area");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, 0, "rna_Area_ui_type_update");
+
prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "totrct.xmin");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -315,10 +394,10 @@ static void rna_def_view2d_api(StructRNA *srna)
{
FunctionRNA *func;
PropertyRNA *parm;
-
+
static const float view_default[2] = {0.0f, 0.0f};
static const int region_default[2] = {0.0f, 0.0f};
-
+
func = RNA_def_function(srna, "region_to_view", "rna_View2D_region_to_view");
RNA_def_function_ui_description(func, "Transform region coordinates to 2D view");
parm = RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "x", "Region x coordinate", -10000, 10000);
@@ -349,9 +428,9 @@ static void rna_def_view2d(BlenderRNA *brna)
srna = RNA_def_struct(brna, "View2D", NULL);
RNA_def_struct_ui_text(srna, "View2D", "Scroll and zoom for a 2D region");
RNA_def_struct_sdna(srna, "View2D");
-
+
/* TODO more View2D properties could be exposed here (read-only) */
-
+
rna_def_view2d_api(srna);
}
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 12b080a9284..be52a3ffca7 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -162,6 +162,8 @@ static void rna_ParticleEdit_redo(bContext *C, PointerRNA *UNUSED(ptr))
if (!edit)
return;
+ if (ob) DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+
BKE_particle_batch_cache_dirty(edit->psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
psys_free_path_cache(edit->psys, edit);
DEG_id_tag_update(&CTX_data_scene(C)->id, DEG_TAG_COPY_ON_WRITE);
@@ -181,7 +183,7 @@ static void rna_ParticleEdit_update(bContext *C, PointerRNA *UNUSED(ptr))
static void rna_ParticleEdit_tool_set(PointerRNA *ptr, int value)
{
ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data;
-
+
/* redraw hair completely if weight brush is/was used */
if ((pset->brushtype == PE_BRUSH_WEIGHT || value == PE_BRUSH_WEIGHT) && pset->object) {
Object *ob = pset->object;
@@ -236,7 +238,7 @@ static int rna_ParticleEdit_hair_get(PointerRNA *ptr)
return (edit && edit->psys);
}
-
+
return 0;
}
@@ -400,7 +402,7 @@ static void rna_ImaPaint_canvas_update(bContext *C, PointerRNA *UNUSED(ptr))
Object *obedit = OBEDIT_FROM_OBACT(ob);
bScreen *sc;
Image *ima = scene->toolsettings->imapaint.canvas;
-
+
for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
@@ -408,14 +410,14 @@ static void rna_ImaPaint_canvas_update(bContext *C, PointerRNA *UNUSED(ptr))
for (slink = sa->spacedata.first; slink; slink = slink->next) {
if (slink->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)slink;
-
+
if (!sima->pin)
- ED_space_image_set(sima, scene, obedit, ima);
+ ED_space_image_set(bmain, sima, scene, obedit, ima);
}
}
}
}
-
+
if (ob && ob->type == OB_MESH) {
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
@@ -432,7 +434,7 @@ static PointerRNA rna_GPencilSculptSettings_brush_get(PointerRNA *ptr)
{
GP_BrushEdit_Settings *gset = (GP_BrushEdit_Settings *)ptr->data;
GP_EditBrush_Data *brush = NULL;
-
+
if ((gset->brushtype >= 0) && (gset->brushtype < TOT_GP_EDITBRUSH_TYPES))
brush = &gset->brush[gset->brushtype];
@@ -745,35 +747,35 @@ static void rna_def_image_paint(BlenderRNA *brna)
"Image", "Set image for texture painting directly"},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "ImagePaint", "Paint");
RNA_def_struct_sdna(srna, "ImagePaintSettings");
RNA_def_struct_path_func(srna, "rna_ImagePaintSettings_path");
RNA_def_struct_ui_text(srna, "Image Paint", "Properties of image and texture painting mode");
- /* functions */
+ /* functions */
func = RNA_def_function(srna, "detect_data", "rna_ImaPaint_detect_data");
RNA_def_function_ui_description(func, "Check if required texpaint data exist");
/* return type */
RNA_def_function_return(func, RNA_def_boolean(func, "ok", 1, "", ""));
-
- /* booleans */
+
+ /* booleans */
prop = RNA_def_property(srna, "use_occlude", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_XRAY);
RNA_def_property_ui_text(prop, "Occlude", "Only paint onto the faces directly under the brush (slower)");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
prop = RNA_def_property(srna, "use_backface_culling", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_BACKFACE);
RNA_def_property_ui_text(prop, "Cull", "Ignore faces pointing away from the view (faster)");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
prop = RNA_def_property(srna, "use_normal_falloff", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_FLAT);
RNA_def_property_ui_text(prop, "Normal", "Paint most on faces pointing towards the view");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
prop = RNA_def_property(srna, "use_stencil_layer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_STENCIL);
RNA_def_property_ui_text(prop, "Stencil Layer", "Set the mask layer from the UV map buttons");
@@ -794,13 +796,13 @@ static void rna_def_image_paint(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE);
RNA_def_property_ui_text(prop, "Canvas", "Image used as canvas");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_canvas_update");
-
+
prop = RNA_def_property(srna, "clone_image", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "clone");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Clone Image", "Image used as clone source");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
prop = RNA_def_property(srna, "stencil_color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_float_sdna(prop, NULL, "stencil_col");
@@ -811,15 +813,15 @@ static void rna_def_image_paint(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0, 2.0);
RNA_def_property_ui_text(prop, "Dither", "Amount of dithering when painting on byte images");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
prop = RNA_def_property(srna, "use_clone_layer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_CLONE);
RNA_def_property_ui_text(prop, "Clone Map",
"Use another UV map as clone source, otherwise use the 3D cursor as the source");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_viewport_update");
-
+
/* integers */
-
+
prop = RNA_def_property(srna, "seam_bleed", PROP_INT, PROP_PIXEL);
RNA_def_property_ui_range(prop, 0, 8, 0, -1);
RNA_def_property_ui_text(prop, "Bleed", "Extend paint beyond the faces UVs to reduce seams (in pixels, slower)");
@@ -831,37 +833,37 @@ static void rna_def_image_paint(BlenderRNA *brna)
prop = RNA_def_int_array(srna, "screen_grab_size", 2, NULL, 0, 0, "screen_grab_size",
"Size to capture the image for re-projecting", 0, 0);
RNA_def_property_range(prop, 512, 16384);
-
+
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_enum_items(prop, paint_type_items);
RNA_def_property_ui_text(prop, "Mode", "Mode of operation for projection painting");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_mode_update");
-
+
/* Missing data */
prop = RNA_def_property(srna, "missing_uvs", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "missing_data", IMAGEPAINT_MISSING_UVS);
RNA_def_property_ui_text(prop, "Missing UVs",
"A UV layer is missing on the mesh");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
prop = RNA_def_property(srna, "missing_materials", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "missing_data", IMAGEPAINT_MISSING_MATERIAL);
RNA_def_property_ui_text(prop, "Missing Materials",
"The mesh is missing materials");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
prop = RNA_def_property(srna, "missing_stencil", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "missing_data", IMAGEPAINT_MISSING_STENCIL);
RNA_def_property_ui_text(prop, "Missing Stencil",
"Image Painting does not have a stencil");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
prop = RNA_def_property(srna, "missing_texture", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "missing_data", IMAGEPAINT_MISSING_TEX);
RNA_def_property_ui_text(prop, "Missing Texture",
"Image Painting does not have a texture to paint on");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
}
static void rna_def_particle_edit(BlenderRNA *brna)
@@ -1058,10 +1060,10 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
{0, "ADD", 0, "Add", "Add effect of brush"},
{GP_EDITBRUSH_FLAG_INVERT, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"},
{0, NULL, 0, NULL, NULL}};
-
+
StructRNA *srna;
PropertyRNA *prop;
-
+
/* == Settings == */
srna = RNA_def_struct(brna, "GPencilSculptSettings", NULL);
RNA_def_struct_sdna(srna, "GP_BrushEdit_Settings");
@@ -1073,18 +1075,18 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
RNA_def_property_enum_items(prop, rna_enum_gpencil_sculpt_brush_items);
RNA_def_property_ui_text(prop, "Tool", "");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
prop = RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "GPencilSculptBrush");
RNA_def_property_pointer_funcs(prop, "rna_GPencilSculptSettings_brush_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Brush", "");
-
+
prop = RNA_def_property(srna, "use_select_mask", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_SELECT_MASK);
RNA_def_property_ui_text(prop, "Selection Mask", "Only sculpt selected stroke points");
RNA_def_property_ui_icon(prop, ICON_VERTEXSEL, 0); // FIXME: this needs a custom icon
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
prop = RNA_def_property(srna, "affect_position", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_APPLY_POSITION);
RNA_def_property_ui_text(prop, "Affect Position", "The brush affects the position of the point");
@@ -1130,23 +1132,23 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
RNA_def_property_range(prop, 0.001, 1.0);
RNA_def_property_ui_text(prop, "Strength", "Brush strength");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
prop = RNA_def_property(srna, "use_pressure_strength", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_EDITBRUSH_FLAG_USE_PRESSURE);
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
RNA_def_property_ui_text(prop, "Strength Pressure", "Enable tablet pressure sensitivity for strength");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
prop = RNA_def_property(srna, "use_falloff", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_EDITBRUSH_FLAG_USE_FALLOFF);
RNA_def_property_ui_text(prop, "Use Falloff", "Strength of brush decays with distance from cursor");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
prop = RNA_def_property(srna, "affect_pressure", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE);
RNA_def_property_ui_text(prop, "Affect Pressure", "Affect pressure values as well when smoothing strokes");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
+
prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, prop_direction_items);
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index 33621af69af..fb6953904b3 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -177,7 +177,7 @@ static int rna_SequenceEditor_elements_length(PointerRNA *ptr)
/* Hack? copied from sequencer.c::reload_sequence_new_file() */
size_t olen = MEM_allocN_len(seq->strip->stripdata) / sizeof(struct StripElem);
-
+
/* the problem with seq->strip->len and seq->len is that it's discounted from the offset (hard cut trim) */
return (int) olen;
}
@@ -232,7 +232,7 @@ static void rna_Sequence_start_frame_set(PointerRNA *ptr, int value)
{
Sequence *seq = (Sequence *)ptr->data;
Scene *scene = (Scene *)ptr->id.data;
-
+
BKE_sequence_translate(scene, seq, value - seq->start);
do_sequence_frame_change_update(scene, seq);
}
@@ -283,7 +283,7 @@ static void rna_Sequence_frame_length_set(PointerRNA *ptr, int value)
{
Sequence *seq = (Sequence *)ptr->data;
Scene *scene = (Scene *)ptr->id.data;
-
+
BKE_sequence_tx_set_final_right(seq, BKE_sequence_tx_get_final_left(seq, false) + value);
do_sequence_frame_change_update(scene, seq);
}
@@ -307,7 +307,7 @@ static void rna_Sequence_channel_set(PointerRNA *ptr, int value)
Scene *scene = (Scene *)ptr->id.data;
Editing *ed = BKE_sequencer_editing_get(scene, false);
ListBase *seqbase = BKE_sequence_seqbase(&ed->seqbase, seq);
-
+
/* check channel increment or decrement */
const int channel_delta = (value >= seq->machine) ? 1 : -1;
seq->machine = value;
@@ -480,16 +480,16 @@ static void rna_Sequence_name_set(PointerRNA *ptr, const char *value)
Sequence *seq = (Sequence *)ptr->data;
char oldname[sizeof(seq->name)];
AnimData *adt;
-
+
/* make a copy of the old name first */
BLI_strncpy(oldname, seq->name + 2, sizeof(seq->name) - 2);
-
+
/* copy the new name into the name slot */
BLI_strncpy_utf8(seq->name + 2, value, sizeof(seq->name) - 2);
-
+
/* make sure the name is unique */
BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
-
+
/* fix all the animation data which may link to this */
/* don't rename everywhere because these are per scene */
@@ -562,7 +562,7 @@ static StructRNA *rna_Sequence_refine(struct PointerRNA *ptr)
static char *rna_Sequence_path(PointerRNA *ptr)
{
Sequence *seq = (Sequence *)ptr->data;
-
+
/* sequencer data comes from scene...
* TODO: would be nice to make SequenceEditor data a data-block of its own (for shorter paths)
*/
@@ -1121,11 +1121,11 @@ static void rna_def_strip_element(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "SequenceElement", NULL);
RNA_def_struct_ui_text(srna, "Sequence Element", "Sequence strip data for a single frame");
RNA_def_struct_sdna(srna, "StripElem");
-
+
prop = RNA_def_property(srna, "filename", PROP_STRING, PROP_FILENAME);
RNA_def_property_string_sdna(prop, NULL, "name");
RNA_def_property_ui_text(prop, "Filename", "Name of the source file");
@@ -1146,7 +1146,7 @@ static void rna_def_strip_crop(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "SequenceCrop", NULL);
RNA_def_struct_ui_text(srna, "Sequence Crop", "Cropping parameters for a sequence strip");
RNA_def_struct_sdna(srna, "StripCrop");
@@ -1156,13 +1156,13 @@ static void rna_def_strip_crop(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Top", "Number of pixels to crop from the top");
RNA_def_property_ui_range(prop, 0, 4096, 1, -1);
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceCrop_update");
-
+
prop = RNA_def_property(srna, "min_y", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "bottom");
RNA_def_property_ui_text(prop, "Bottom", "Number of pixels to crop from the bottom");
RNA_def_property_ui_range(prop, 0, 4096, 1, -1);
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceCrop_update");
-
+
prop = RNA_def_property(srna, "min_x", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "left");
RNA_def_property_ui_text(prop, "Left", "Number of pixels to crop from the left side");
@@ -1182,7 +1182,7 @@ static void rna_def_strip_transform(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "SequenceTransform", NULL);
RNA_def_struct_ui_text(srna, "Sequence Transform", "Transform parameters for a sequence strip");
RNA_def_struct_sdna(srna, "StripTransform");
@@ -1222,16 +1222,16 @@ static void rna_def_strip_proxy(BlenderRNA *brna)
"changes in framerate or dropouts"},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "SequenceProxy", NULL);
RNA_def_struct_ui_text(srna, "Sequence Proxy", "Proxy parameters for a sequence strip");
RNA_def_struct_sdna(srna, "StripProxy");
-
+
prop = RNA_def_property(srna, "directory", PROP_STRING, PROP_DIRPATH);
RNA_def_property_string_sdna(prop, NULL, "dir");
RNA_def_property_ui_text(prop, "Directory", "Location to store the proxy files");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceProxy_update");
-
+
prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
RNA_def_property_ui_text(prop, "Path", "Location of custom proxy file");
RNA_def_property_string_funcs(prop, "rna_Sequence_proxy_filepath_get", "rna_Sequence_proxy_filepath_length",
@@ -1464,7 +1464,7 @@ static void rna_def_sequence(BlenderRNA *brna)
{SEQ_TYPE_COLORMIX, "COLORMIX", 0, "Color Mix", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "Sequence", NULL);
RNA_def_struct_ui_text(srna, "Sequence", "Sequence strip in the sequence editor");
RNA_def_struct_refine_func(srna, "rna_Sequence_refine");
@@ -1529,7 +1529,7 @@ static void rna_def_sequence(BlenderRNA *brna)
RNA_def_property_range(prop, 1, MAXFRAME);
RNA_def_property_ui_text(prop, "Length",
"The length of the contents of this strip before the handles are applied");
-
+
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "start");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -1537,7 +1537,7 @@ static void rna_def_sequence(BlenderRNA *brna)
RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_start_frame_set", NULL); /* overlap tests and calc_seq_disp */
RNA_def_property_editable_func(prop, "rna_Sequence_frame_editable");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "frame_final_start", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "startdisp");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -1579,14 +1579,14 @@ static void rna_def_sequence(BlenderRNA *brna)
RNA_def_property_range(prop, 0, MAXFRAME);
RNA_def_property_ui_text(prop, "Start Still", "");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_frame_change_update");
-
+
prop = RNA_def_property(srna, "frame_still_end", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "endstill");
// RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* overlap tests */
RNA_def_property_range(prop, 0, MAXFRAME);
RNA_def_property_ui_text(prop, "End Still", "");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_frame_change_update");
-
+
prop = RNA_def_property(srna, "channel", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "machine");
RNA_def_property_range(prop, 1, MAXSEQ);
@@ -1606,14 +1606,14 @@ static void rna_def_sequence(BlenderRNA *brna)
RNA_def_property_enum_items(prop, blend_mode_items);
RNA_def_property_ui_text(prop, "Blend Mode", "Method for controlling how the strip combines with other strips");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "blend_alpha", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Blend Opacity", "Percentage of how much the strip's colors affect other strips");
/* stupid 0-100 -> 0-1 */
RNA_def_property_float_funcs(prop, "rna_Sequence_opacity_get", "rna_Sequence_opacity_set", NULL);
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "effect_fader", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
@@ -1627,7 +1627,7 @@ static void rna_def_sequence(BlenderRNA *brna)
"Fade effect using the built-in default (usually make transition as long as "
"effect strip)");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "speed_factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "speed_fader");
@@ -1679,7 +1679,7 @@ static void rna_def_editor(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Meta Stack", "Meta strip stack, last is currently edited meta strip");
RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_SequenceEditor_meta_stack_get",
NULL, NULL, NULL, NULL);
-
+
prop = RNA_def_property(srna, "active_strip", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "act_seq");
RNA_def_property_flag(prop, PROP_EDITABLE);
@@ -1884,7 +1884,7 @@ static void rna_def_image(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "ImageSequence", "Sequence");
RNA_def_struct_ui_text(srna, "Image Sequence", "Sequence strip to load one or more images");
RNA_def_struct_sdna(srna, "Sequence");
@@ -1931,7 +1931,7 @@ static void rna_def_meta(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "MetaSequence", "Sequence");
RNA_def_struct_ui_text(srna, "Meta Sequence", "Sequence strip to group other strips as a single sequence strip");
RNA_def_struct_sdna(srna, "Sequence");
@@ -1950,7 +1950,7 @@ static void rna_def_scene(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "SceneSequence", "Sequence");
RNA_def_struct_ui_text(srna, "Scene Sequence", "Sequence strip to used the rendered image of a scene");
RNA_def_struct_sdna(srna, "Sequence");
@@ -2057,7 +2057,7 @@ static void rna_def_movieclip(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "MovieClipSequence", "Sequence");
RNA_def_struct_ui_text(srna, "MovieClip Sequence", "Sequence strip to load a video from the clip editor");
RNA_def_struct_sdna(srna, "Sequence");
@@ -2101,7 +2101,7 @@ static void rna_def_sound(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "SoundSequence", "Sequence");
RNA_def_struct_ui_text(srna, "Sound Sequence",
"Sequence strip defining a sound to be played over a period of time");
@@ -2140,7 +2140,7 @@ static void rna_def_sound(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_AUDIO_DRAW_WAVEFORM);
RNA_def_property_ui_text(prop, "Draw Waveform", "Whether to draw the sound's waveform");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
-
+
rna_def_input(srna);
}
@@ -2160,7 +2160,7 @@ static void rna_def_effect(BlenderRNA *brna)
static void rna_def_multicam(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "multicam_source", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "multicam_source");
RNA_def_property_range(prop, 0, MAXSEQ - 1);
@@ -2173,7 +2173,7 @@ static void rna_def_multicam(StructRNA *srna)
static void rna_def_wipe(StructRNA *srna)
{
PropertyRNA *prop;
-
+
static const EnumPropertyItem wipe_type_items[] = {
{0, "SINGLE", 0, "Single", ""},
{1, "DOUBLE", 0, "Double", ""},
@@ -2209,7 +2209,7 @@ static void rna_def_wipe(StructRNA *srna)
RNA_def_property_enum_items(prop, wipe_direction_items);
RNA_def_property_ui_text(prop, "Direction", "Wipe direction");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "transition_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "wipetype");
RNA_def_property_enum_items(prop, wipe_type_items);
@@ -2223,37 +2223,37 @@ static void rna_def_glow(StructRNA *srna)
PropertyRNA *prop;
RNA_def_struct_sdna_from(srna, "GlowVars", "effectdata");
-
+
prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "fMini");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Threshold", "Minimum intensity to trigger a glow");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "clamp", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "fClamp");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Clamp", "Brightness limit of intensity");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "boost_factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "fBoost");
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(prop, "Boost Factor", "Brightness multiplier");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "blur_radius", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "dDist");
RNA_def_property_range(prop, 0.5f, 20.0f);
RNA_def_property_ui_text(prop, "Blur Distance", "Radius of glow effect");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "quality", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "dQuality");
RNA_def_property_range(prop, 1, 5);
RNA_def_property_ui_text(prop, "Quality", "Accuracy of the blur effect");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "use_only_boost", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "bNoComp", 0);
RNA_def_property_ui_text(prop, "Only Boost", "Show the glow buffer only");
@@ -2284,43 +2284,43 @@ static void rna_def_transform(StructRNA *srna)
RNA_def_property_ui_text(prop, "Scale X", "Amount to scale the input in the X axis");
RNA_def_property_ui_range(prop, 0, 10, 3, 6);
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "scale_start_y", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_sdna(prop, NULL, "ScaleyIni");
RNA_def_property_ui_text(prop, "Scale Y", "Amount to scale the input in the Y axis");
RNA_def_property_ui_range(prop, 0, 10, 3, 6);
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "use_uniform_scale", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uniform_scale", 0);
RNA_def_property_ui_text(prop, "Uniform Scale", "Scale uniformly, preserving aspect ratio");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "translate_start_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "xIni");
RNA_def_property_ui_text(prop, "Translate X", "Amount to move the input on the X axis");
RNA_def_property_ui_range(prop, -4000.0f, 4000.0f, 3, 6);
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "translate_start_y", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "yIni");
RNA_def_property_ui_text(prop, "Translate Y", "Amount to move the input on the Y axis");
RNA_def_property_ui_range(prop, -4000.0f, 4000.0f, 3, 6);
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "rotation_start", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "rotIni");
RNA_def_property_range(prop, -360.0f, 360.0f);
RNA_def_property_ui_text(prop, "Rotation", "Degrees to rotate the input");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "translation_unit", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "percent");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* not meant to be animated */
RNA_def_property_enum_items(prop, translation_unit_items);
RNA_def_property_ui_text(prop, "Translation Unit", "Unit of measure to translate the input");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, interpolation_items);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* not meant to be animated */
@@ -2352,7 +2352,7 @@ static void rna_def_speed_control(StructRNA *srna)
RNA_def_property_ui_text(prop, "Multiply Speed", "Multiply the resulting speed after the speed factor");
RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, -1);
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
+
prop = RNA_def_property(srna, "use_as_speed", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", SEQ_SPEED_INTEGRATE);
RNA_def_property_ui_text(prop, "Use as speed", "Interpret the value as speed instead of a frame number");
diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c
index d447d2972f6..da8b19a1ff6 100644
--- a/source/blender/makesrna/intern/rna_sequencer_api.c
+++ b/source/blender/makesrna/intern/rna_sequencer_api.c
@@ -74,7 +74,7 @@ static void rna_Sequence_update_rnafunc(ID *id, Sequence *self, int do_data)
static void rna_Sequence_swap_internal(Sequence *seq_self, ReportList *reports, Sequence *seq_other)
{
const char *error_msg;
-
+
if (BKE_sequence_swap(seq_self, seq_other, &error_msg) == 0)
BKE_report(reports, RPT_ERROR, error_msg);
}
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index 832d5b28bd1..b4c9e7ba3a2 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -243,7 +243,7 @@ static void rna_SmokeModifier_density_grid_get(PointerRNA *ptr, float *values)
float *density;
BLI_rw_mutex_lock(sds->fluid_mutex, THREAD_LOCK_READ);
-
+
if (sds->flags & MOD_SMOKE_HIGHRES && sds->wt)
density = smoke_turbulence_get_density(sds->wt);
else
@@ -326,12 +326,12 @@ static void rna_SmokeModifier_flame_grid_get(PointerRNA *ptr, float *values)
float *flame;
BLI_rw_mutex_lock(sds->fluid_mutex, THREAD_LOCK_READ);
-
+
if (sds->flags & MOD_SMOKE_HIGHRES && sds->wt)
flame = smoke_turbulence_get_flame(sds->wt);
else
flame = smoke_get_flame(sds->fluid);
-
+
if (flame)
memcpy(values, flame, size * sizeof(float));
else
@@ -973,7 +973,7 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna)
RNA_def_property_ui_range(prop, -10, 10, 1, 1);
RNA_def_property_ui_text(prop, "Temp. Diff.", "Temperature difference to ambient temperature");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
-
+
prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "psys");
RNA_def_property_struct_type(prop, "ParticleSystem");
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 65edc619ced..8de651f822d 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -114,7 +114,6 @@ const EnumPropertyItem rna_enum_space_image_mode_items[] = {
{0, NULL, 0, NULL, NULL}
};
-
#define V3D_S3D_CAMERA_LEFT {STEREO_LEFT_ID, "LEFT", ICON_RESTRICT_RENDER_OFF, "Left", ""},
#define V3D_S3D_CAMERA_RIGHT {STEREO_RIGHT_ID, "RIGHT", ICON_RESTRICT_RENDER_OFF, "Right", ""},
#define V3D_S3D_CAMERA_S3D {STEREO_3D_ID, "S3D", ICON_CAMERA_STEREO, "3D", ""},
@@ -188,46 +187,16 @@ const EnumPropertyItem rna_enum_shading_type_items[] = {
};
const EnumPropertyItem rna_enum_viewport_lighting_items[] = {
- {V3D_LIGHTING_FLAT, "FLAT", 0, "Flat Lighting", "Display using flat lighting"},
- {V3D_LIGHTING_STUDIO, "STUDIO", 0, "Studio Lighting", "Display using studio lighting"},
- /* {V3D_LIGHTING_SCENE, "SCENE", 0, "Scene Lighting", "Display using scene lighting"}, */
+ {V3D_LIGHTING_FLAT, "FLAT", 0, "Flat", "Display using flat lighting"},
+ {V3D_LIGHTING_STUDIO, "STUDIO", 0, "Studio", "Display using studio lighting"},
+ {V3D_LIGHTING_MATCAP, "MATCAP", 0, "MatCap", "Display using matcap material and lighting"},
{0, NULL, 0, NULL, NULL}
};
static const EnumPropertyItem rna_enum_studio_light_items[] = {
- {0, "STUDIOLIGHT_00", 0, "", ""},
- {1, "STUDIOLIGHT_01", 0, "", ""},
- {2, "STUDIOLIGHT_02", 0, "", ""},
- {3, "STUDIOLIGHT_03", 0, "", ""},
- {4, "STUDIOLIGHT_04", 0, "", ""},
- {5, "STUDIOLIGHT_05", 0, "", ""},
- {6, "STUDIOLIGHT_06", 0, "", ""},
- {7, "STUDIOLIGHT_07", 0, "", ""},
- {8, "STUDIOLIGHT_08", 0, "", ""},
- {9, "STUDIOLIGHT_09", 0, "", ""},
- {10, "STUDIOLIGHT_10", 0, "", ""},
- {11, "STUDIOLIGHT_11", 0, "", ""},
- {12, "STUDIOLIGHT_12", 0, "", ""},
- {13, "STUDIOLIGHT_13", 0, "", ""},
- {14, "STUDIOLIGHT_14", 0, "", ""},
- {15, "STUDIOLIGHT_15", 0, "", ""},
- {16, "STUDIOLIGHT_16", 0, "", ""},
- {17, "STUDIOLIGHT_17", 0, "", ""},
- {18, "STUDIOLIGHT_18", 0, "", ""},
- {19, "STUDIOLIGHT_19", 0, "", ""},
- {20, "STUDIOLIGHT_20", 0, "", ""},
- {21, "STUDIOLIGHT_21", 0, "", ""},
- {22, "STUDIOLIGHT_22", 0, "", ""},
- {23, "STUDIOLIGHT_23", 0, "", ""},
- {24, "STUDIOLIGHT_24", 0, "", ""},
- {25, "STUDIOLIGHT_25", 0, "", ""},
- {26, "STUDIOLIGHT_26", 0, "", ""},
- {27, "STUDIOLIGHT_27", 0, "", ""},
- {28, "STUDIOLIGHT_28", 0, "", ""},
- {29, "STUDIOLIGHT_29", 0, "", ""},
+ {0, "DEFAULT", 0, "Default", ""},
{0, NULL, 0, NULL, NULL}
};
-#define NUM_STUDIOLIGHT_ITEMS 30
const EnumPropertyItem rna_enum_clip_editor_mode_items[] = {
{SC_MODE_TRACKING, "TRACKING", ICON_ANIM_DATA, "Tracking", "Show tracking and solving tools"},
@@ -237,6 +206,7 @@ const EnumPropertyItem rna_enum_clip_editor_mode_items[] = {
/* Actually populated dynamically trough a function, but helps for context-less access (e.g. doc, i18n...). */
static const EnumPropertyItem buttons_context_items[] = {
+ {BCONTEXT_TOOL, "TOOL", ICON_PREFERENCES, "Tool", "Tool settings"},
{BCONTEXT_SCENE, "SCENE", ICON_SCENE_DATA, "Scene", "Scene"},
{BCONTEXT_RENDER, "RENDER", ICON_SCENE, "Render", "Render"},
{BCONTEXT_VIEW_LAYER, "VIEW_LAYER", ICON_RENDER_RESULT, "View Layer", "View layer"},
@@ -541,17 +511,6 @@ static void rna_3DViewShading_type_update(Main *bmain, Scene *UNUSED(scene), Poi
ED_view3d_shade_update(bmain, v3d, sa);
}
-static void rna_SpaceView3D_matcap_enable(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
- View3D *v3d = (View3D *)(ptr->data);
-
- if (v3d->matcap_icon < ICON_MATCAP_01 ||
- v3d->matcap_icon > ICON_MATCAP_24)
- {
- v3d->matcap_icon = ICON_MATCAP_01;
- }
-}
-
static PointerRNA rna_SpaceView3D_region_3d_get(PointerRNA *ptr)
{
View3D *v3d = (View3D *)(ptr->data);
@@ -656,7 +615,7 @@ static int rna_3DViewShading_type_get(PointerRNA *ptr)
View3D *v3d = (View3D *)ptr->data;
if (!BKE_scene_uses_blender_eevee(scene) && v3d->drawtype == OB_RENDER) {
- if (!(type && type->render_to_view)) {
+ if (!(type && type->view_draw)) {
return OB_MATERIAL;
}
}
@@ -670,6 +629,9 @@ static void rna_3DViewShading_type_set(PointerRNA *ptr, int value)
if (value != v3d->drawtype && value == OB_RENDER) {
v3d->prev_drawtype = v3d->drawtype;
}
+ if (value == OB_TEXTURE && v3d->shading.light == V3D_LIGHTING_MATCAP) {
+ v3d->shading.light = V3D_LIGHTING_STUDIO;
+ }
v3d->drawtype = value;
}
@@ -693,7 +655,7 @@ static const EnumPropertyItem *rna_3DViewShading_type_itemf(
}
else {
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_MATERIAL);
- if (type && type->render_to_view) {
+ if (type && type->view_draw) {
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_RENDER);
}
}
@@ -704,30 +666,89 @@ static const EnumPropertyItem *rna_3DViewShading_type_itemf(
return item;
}
-static int rna_View3DShading_studio_light_orientation_get(PointerRNA *ptr)
+/* Shading.selected_studio_light */
+static PointerRNA rna_View3DShading_selected_studio_light_get(PointerRNA *ptr)
{
View3D *v3d = (View3D *)ptr->data;
- StudioLight *sl = BKE_studiolight_find(v3d->shading.studio_light, 0);
- return sl->flag & (STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_ORIENTATION_CAMERA);
+ StudioLight *sl;
+ if (v3d->shading.light == V3D_LIGHTING_MATCAP) {
+ sl = BKE_studiolight_find(v3d->shading.matcap, STUDIOLIGHT_FLAG_ALL);
+ }
+ else {
+ sl = BKE_studiolight_find(v3d->shading.studio_light, STUDIOLIGHT_FLAG_ALL);
+ }
+ return rna_pointer_inherit_refine(ptr, &RNA_StudioLight, sl);
+}
+
+/* shading.light */
+static int rna_View3DShading_light_get(PointerRNA *ptr)
+{
+ View3D *v3d = (View3D *)ptr->data;
+ return v3d->shading.light;
}
-static void rna_View3DShading_studio_light_orientation_set(PointerRNA *UNUSED(ptr), int UNUSED(value))
+
+static void rna_View3DShading_light_set(PointerRNA *ptr, int value)
{
+ View3D *v3d = (View3D *)ptr->data;
+ v3d->shading.light = value;
}
+static const EnumPropertyItem *rna_View3DShading_light_itemf(
+ bContext *UNUSED(C), PointerRNA *ptr,
+ PropertyRNA *UNUSED(prop), bool *r_free)
+{
+ View3D *v3d = (View3D *)ptr->data;
+
+ int totitem = 0;
+ EnumPropertyItem *item = NULL;
+
+ if (v3d->drawtype == OB_SOLID || v3d->drawtype == OB_TEXTURE) {
+ RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_lighting_items, V3D_LIGHTING_FLAT);
+ RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_lighting_items, V3D_LIGHTING_STUDIO);
+ }
+
+ if (v3d->drawtype == OB_SOLID) {
+ RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_lighting_items, V3D_LIGHTING_MATCAP);
+ }
+ RNA_enum_item_end(&item, &totitem);
+ *r_free = true;
+ return item;
+}
+
+/* Studio light */
static int rna_View3DShading_studio_light_get(PointerRNA *ptr)
{
View3D *v3d = (View3D *)ptr->data;
- const int flag = v3d->drawtype == OB_MATERIAL? STUDIOLIGHT_ORIENTATION_WORLD: 0;
- StudioLight *sl = BKE_studiolight_find(v3d->shading.studio_light, flag);
- BLI_strncpy(v3d->shading.studio_light, sl->name, FILE_MAXFILE);
+ char* dna_storage = v3d->shading.studio_light;
+
+ int flag = STUDIOLIGHT_ORIENTATIONS_SOLID;
+ if (v3d->drawtype == OB_SOLID && v3d->shading.light == V3D_LIGHTING_MATCAP) {
+ flag = STUDIOLIGHT_ORIENTATION_VIEWNORMAL;
+ dna_storage = v3d->shading.matcap;
+ }
+ else if (v3d->drawtype == OB_MATERIAL) {
+ flag = STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE;
+ }
+ StudioLight *sl = BKE_studiolight_find(dna_storage, flag);
+ BLI_strncpy(dna_storage, sl->name, FILE_MAXFILE);
return sl->index;
}
static void rna_View3DShading_studio_light_set(PointerRNA *ptr, int value)
{
View3D *v3d = (View3D *)ptr->data;
- StudioLight *sl = BKE_studiolight_findindex(value);
- BLI_strncpy(v3d->shading.studio_light, sl->name, FILE_MAXFILE);
+ char* dna_storage = v3d->shading.studio_light;
+
+ int flag = STUDIOLIGHT_ORIENTATIONS_SOLID;
+ if (v3d->drawtype == OB_SOLID && v3d->shading.light == V3D_LIGHTING_MATCAP) {
+ flag = STUDIOLIGHT_ORIENTATION_VIEWNORMAL;
+ dna_storage = v3d->shading.matcap;
+ }
+ else if (v3d->drawtype == OB_MATERIAL) {
+ flag = STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE;
+ }
+ StudioLight *sl = BKE_studiolight_findindex(value, flag);
+ BLI_strncpy(dna_storage, sl->name, FILE_MAXFILE);
}
static const EnumPropertyItem *rna_View3DShading_studio_light_itemf(
@@ -736,36 +757,46 @@ static const EnumPropertyItem *rna_View3DShading_studio_light_itemf(
{
View3D *v3d = (View3D *)ptr->data;
EnumPropertyItem *item = NULL;
- EnumPropertyItem *lastitem;
int totitem = 0;
- bool show_studiolight;
-
- LISTBASE_FOREACH(StudioLight *, sl, BKE_studiolight_listbase()) {
- show_studiolight = false;
- int icon_id = sl->irradiance_icon_id;
-
- if ((sl->flag & STUDIOLIGHT_EXTERNAL_FILE) == 0) {
- /* always show internal lights */
- show_studiolight = true;
- } else {
- switch (v3d->drawtype) {
- case OB_SOLID:
- case OB_TEXTURE:
- show_studiolight = true;
- break;
- case OB_MATERIAL:
- show_studiolight = (sl->flag & STUDIOLIGHT_ORIENTATION_WORLD) > 0;
- icon_id = sl->radiance_icon_id;
- break;
+
+ if (v3d->drawtype == OB_SOLID && v3d->shading.light == V3D_LIGHTING_MATCAP) {
+ const int flags = (STUDIOLIGHT_EXTERNAL_FILE | STUDIOLIGHT_ORIENTATION_VIEWNORMAL);
+
+ LISTBASE_FOREACH(StudioLight *, sl, BKE_studiolight_listbase()) {
+ int icon_id = sl->irradiance_icon_id;
+ if ((sl->flag & flags) == flags) {
+ EnumPropertyItem tmp = {sl->index, sl->name, icon_id, sl->name, ""};
+ RNA_enum_item_add(&item, &totitem, &tmp);
}
}
+ }
+ else {
+ LISTBASE_FOREACH(StudioLight *, sl, BKE_studiolight_listbase()) {
+ int icon_id = sl->irradiance_icon_id;
+ bool show_studiolight = false;
+
+ if ((sl->flag & STUDIOLIGHT_INTERNAL)) {
+ /* always show internal lights */
+ show_studiolight = true;
+ }
+ else {
+ switch (v3d->drawtype) {
+ case OB_SOLID:
+ case OB_TEXTURE:
+ show_studiolight = (sl->flag & (STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_ORIENTATION_CAMERA)) > 0;
+ break;
+
+ case OB_MATERIAL:
+ show_studiolight = (sl->flag & STUDIOLIGHT_ORIENTATION_WORLD) > 0;
+ icon_id = sl->radiance_icon_id;
+ break;
+ }
+ }
- if (show_studiolight && totitem < NUM_STUDIOLIGHT_ITEMS) {
- RNA_enum_items_add_value(&item, &totitem, rna_enum_studio_light_items, sl->index);
- lastitem = &item[totitem - 1];
- lastitem->value = sl->index;
- lastitem->icon = icon_id;
- lastitem->name = sl->name;
+ if (show_studiolight) {
+ EnumPropertyItem tmp = {sl->index, sl->name, icon_id, sl->name, ""};
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
}
}
@@ -815,7 +846,7 @@ static PointerRNA rna_SpaceImageEditor_uvedit_get(PointerRNA *ptr)
static void rna_SpaceImageEditor_mode_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
{
- ED_space_image_paint_update(bmain->wm.first, scene);
+ ED_space_image_paint_update(bmain, bmain->wm.first, scene);
}
@@ -889,7 +920,7 @@ static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value)
Scene *scene = ED_screen_scene_find_with_window(sc, G.main->wm.first, &win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
- ED_space_image_set(sima, scene, obedit, (Image *)value.data);
+ ED_space_image_set(G.main, sima, scene, obedit, (Image *)value.data);
}
static void rna_SpaceImageEditor_mask_set(PointerRNA *ptr, PointerRNA value)
@@ -1134,6 +1165,10 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf(
EnumPropertyItem *item = NULL;
int totitem = 0;
+ if (sbuts->pathflag & (1 << BCONTEXT_TOOL)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_TOOL);
+ }
+
if (sbuts->pathflag & (1 << BCONTEXT_RENDER)) {
RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_RENDER);
}
@@ -1401,12 +1436,12 @@ static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr)
else
saction->action = NULL;
}
-
+
/* Collapse summary channel and hide channel list for timeline */
if (saction->mode == SACTCONT_TIMELINE) {
saction->ads.flag |= ADS_FLAG_SUMMARY_COLLAPSED;
}
-
+
if (sa && sa->spacedata.first == saction) {
ARegion *channels_region = BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS);
if (channels_region) {
@@ -1419,7 +1454,7 @@ static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr)
ED_region_visibility_change_update(C, channels_region);
}
}
-
+
/* recalculate extents of channel list */
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
}
@@ -1494,11 +1529,17 @@ static int rna_SpaceNodeEditor_tree_type_poll(void *Cv, bNodeTreeType *type)
else
return true;
}
+
+const EnumPropertyItem *RNA_enum_node_tree_types_itemf_impl(bContext *C, bool *r_free)
+{
+ return rna_node_tree_type_itemf(C, rna_SpaceNodeEditor_tree_type_poll, r_free);
+}
+
static const EnumPropertyItem *rna_SpaceNodeEditor_tree_type_itemf(
bContext *C, PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop), bool *r_free)
{
- return rna_node_tree_type_itemf(C, rna_SpaceNodeEditor_tree_type_poll, r_free);
+ return RNA_enum_node_tree_types_itemf_impl(C, r_free);
}
static void rna_SpaceNodeEditor_path_get(PointerRNA *ptr, char *value)
@@ -2242,19 +2283,11 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
static const EnumPropertyItem color_type_items[] = {
{V3D_SHADING_SINGLE_COLOR, "SINGLE", 0, "Single", "Show scene in a single color"},
- {V3D_SHADING_OBJECT_COLOR, "OBJECT", 0, "Object", "Show Object color"},
- {V3D_SHADING_MATERIAL_COLOR, "MATERIAL", 0, "Material", "Show Material color"},
+ {V3D_SHADING_MATERIAL_COLOR, "MATERIAL", 0, "Material", "Show material color"},
{V3D_SHADING_RANDOM_COLOR, "RANDOM", 0, "Random", "Show random object color"},
{0, NULL, 0, NULL, NULL}
};
- static const EnumPropertyItem studio_light_orientation_items[] = {
- {0, "UNKNOWN", 0, "Unknown", "Studio light has no orientation"},
- {STUDIOLIGHT_ORIENTATION_CAMERA, "CAMERA", 0, "Camera", "Studio light is camera based"},
- {STUDIOLIGHT_ORIENTATION_WORLD, "WORLD", 0, "World", "Studio light is world based"},
- {0, NULL, 0, NULL, NULL}
- };
-
srna = RNA_def_struct(brna, "View3DShading", NULL);
RNA_def_struct_sdna(srna, "View3D");
RNA_def_struct_nested(brna, srna, "SpaceView3D");
@@ -2272,6 +2305,7 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
prop = RNA_def_property(srna, "light", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "shading.light");
RNA_def_property_enum_items(prop, rna_enum_viewport_lighting_items);
+ RNA_def_property_enum_funcs(prop, "rna_View3DShading_light_get", "rna_View3DShading_light_set", "rna_View3DShading_light_itemf");
RNA_def_property_ui_text(prop, "Lighting", "Lighting Method for Solid/Texture Viewport Shading");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
@@ -2288,13 +2322,36 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Studiolight", "Studio lighting setup");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- prop = RNA_def_property(srna, "studio_light_orientation", PROP_ENUM, PROP_NONE);
- RNA_define_verify_sdna(0);
- RNA_def_property_enum_sdna(prop, NULL, "shading.flag");
- RNA_def_property_ui_text(prop, "Studio Light Orientation", "Orientation of the studio light");
- RNA_def_property_enum_items(prop, studio_light_orientation_items);
- RNA_def_property_enum_funcs(prop, "rna_View3DShading_studio_light_orientation_get", "rna_View3DShading_studio_light_orientation_set", NULL);
+ prop = RNA_def_property(srna, "show_cavity", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_CAVITY);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Cavity", "Show Cavity");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "cavity_ridge_factor", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "shading.cavity_ridge_factor");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_ui_text(prop, "Ridge", "Factor for the ridges");
+ RNA_def_property_range(prop, 0.0f, 250.0f);
+ RNA_def_property_ui_range(prop, 0.00f, 2.5f, 1, 3);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "cavity_valley_factor", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "shading.cavity_valley_factor");
+ RNA_def_property_float_default(prop, 1.0);
+ RNA_def_property_ui_text(prop, "Valley", "Factor for the valleys");
+ RNA_def_property_range(prop, 0.0f, 250.0f);
+ RNA_def_property_ui_range(prop, 0.00f, 2.5f, 1, 3);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "selected_studio_light", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "StudioLight");
+ RNA_define_verify_sdna(0);
+ RNA_def_property_ui_text(prop, "Studio Light", "Selected StudioLight");
+ RNA_def_property_pointer_funcs(prop, "rna_View3DShading_selected_studio_light_get", NULL, NULL, NULL);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
RNA_define_verify_sdna(1);
prop = RNA_def_property(srna, "studiolight_rot_z", PROP_FLOAT, PROP_ANGLE);
@@ -2330,6 +2387,26 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "X-Ray", "Show whole scene transparent");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ prop = RNA_def_property(srna, "xray_alpha", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "shading.xray_alpha");
+ RNA_def_property_float_default(prop, 0.5);
+ RNA_def_property_ui_text(prop, "X-Ray Alpha", "Amount of alpha to use");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "use_scene_light", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_SCENE_LIGHT);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Scene Light", "Render lamps and light probes of the scene");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "show_specular_highlight", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_SPECULAR_HIGHLIGHT);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Specular Highlights", "Render specular highlights");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
prop = RNA_def_property(srna, "object_outline_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "shading.object_outline_color");
RNA_def_property_array(prop, 3);
@@ -2345,6 +2422,15 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.00f, 1.0f, 1, 3);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "studiolight_background", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "shading.studiolight_background");
+ RNA_def_property_float_default(prop, 0.0);
+ RNA_def_property_ui_text(prop, "Show Background", "Show the studiolight in the background");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_range(prop, 0.00f, 1.0f, 1, 3);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
}
static void rna_def_space_view3d_overlay(BlenderRNA *brna)
@@ -2439,6 +2525,11 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show 3D Cursor", "Display 3D Cursor Overlay");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ prop = RNA_def_property(srna, "show_text", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_TEXT);
+ RNA_def_property_ui_text(prop, "Show Text", "Display overlay text");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
prop = RNA_def_property(srna, "show_face_orientation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_FACE_ORIENTATION);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -2451,6 +2542,46 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Bone Selection", "Show the Bone Selection Overlay");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ prop = RNA_def_property(srna, "bone_selection_alpha", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "overlay.bone_selection_alpha");
+ RNA_def_property_float_default(prop, 0.5f);
+ RNA_def_property_ui_text(prop, "Opacity", "Opacity to use for bone selection");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "show_motion_paths", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_MOTION_PATHS);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Motion Paths", "Show the Motion Paths Overlay");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "show_onion_skins", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_ONION_SKINS);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Onion Skins", "Show the Onion Skinning Overlay");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "show_look_dev", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_LOOK_DEV);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Look Dev", "Show Look Development Balls and Palette");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "show_wireframes", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_WIREFRAMES);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Wireframes", "Show face edges wires");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "wireframe_threshold", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "overlay.wireframe_threshold");
+ RNA_def_property_float_default(prop, 0.5f);
+ RNA_def_property_ui_text(prop, "Wireframe Threshold", "Adjust the number of wires displayed (1 for all wires)");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
prop = RNA_def_property(srna, "show_paint_wire", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "overlay.paint_flag", V3D_OVERLAY_PAINT_WIRE);
RNA_def_property_ui_text(prop, "Show Wire", "Use wireframe display in painting modes");
@@ -2523,34 +2654,6 @@ static void rna_def_space_view3d(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
- static const EnumPropertyItem view3d_matcap_items[] = {
- {ICON_MATCAP_01, "01", ICON_MATCAP_01, "", ""},
- {ICON_MATCAP_02, "02", ICON_MATCAP_02, "", ""},
- {ICON_MATCAP_03, "03", ICON_MATCAP_03, "", ""},
- {ICON_MATCAP_04, "04", ICON_MATCAP_04, "", ""},
- {ICON_MATCAP_05, "05", ICON_MATCAP_05, "", ""},
- {ICON_MATCAP_06, "06", ICON_MATCAP_06, "", ""},
- {ICON_MATCAP_07, "07", ICON_MATCAP_07, "", ""},
- {ICON_MATCAP_08, "08", ICON_MATCAP_08, "", ""},
- {ICON_MATCAP_09, "09", ICON_MATCAP_09, "", ""},
- {ICON_MATCAP_10, "10", ICON_MATCAP_10, "", ""},
- {ICON_MATCAP_11, "11", ICON_MATCAP_11, "", ""},
- {ICON_MATCAP_12, "12", ICON_MATCAP_12, "", ""},
- {ICON_MATCAP_13, "13", ICON_MATCAP_13, "", ""},
- {ICON_MATCAP_14, "14", ICON_MATCAP_14, "", ""},
- {ICON_MATCAP_15, "15", ICON_MATCAP_15, "", ""},
- {ICON_MATCAP_16, "16", ICON_MATCAP_16, "", ""},
- {ICON_MATCAP_17, "17", ICON_MATCAP_17, "", ""},
- {ICON_MATCAP_18, "18", ICON_MATCAP_18, "", ""},
- {ICON_MATCAP_19, "19", ICON_MATCAP_19, "", ""},
- {ICON_MATCAP_20, "20", ICON_MATCAP_20, "", ""},
- {ICON_MATCAP_21, "21", ICON_MATCAP_21, "", ""},
- {ICON_MATCAP_22, "22", ICON_MATCAP_22, "", ""},
- {ICON_MATCAP_23, "23", ICON_MATCAP_23, "", ""},
- {ICON_MATCAP_24, "24", ICON_MATCAP_24, "", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
srna = RNA_def_struct(brna, "SpaceView3D", "Space");
RNA_def_struct_sdna(srna, "View3D");
RNA_def_struct_ui_text(srna, "3D View Space", "3D View space data");
@@ -2767,17 +2870,6 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show 3D Marker Names", "Show names for reconstructed tracks objects");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- prop = RNA_def_property(srna, "use_matcap", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SOLID_MATCAP);
- RNA_def_property_ui_text(prop, "Matcap", "Active Objects draw images mapped on normals, enhancing Solid Draw Mode");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_matcap_enable");
-
- prop = RNA_def_property(srna, "matcap_icon", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "matcap_icon");
- RNA_def_property_enum_items(prop, view3d_matcap_items);
- RNA_def_property_ui_text(prop, "Matcap", "Image to use for Material Capture, active objects only");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
prop = RNA_def_property(srna, "fx_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "FX Options", "Options used for real time compositing");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
@@ -3524,7 +3616,7 @@ static void rna_def_space_dopesheet(BlenderRNA *brna)
RNA_def_property_enum_items(prop, autosnap_items);
RNA_def_property_ui_text(prop, "Auto Snap", "Automatic time snapping settings for transformations");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL);
-
+
/* displaying cache status */
prop = RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DISPLAY);
diff --git a/source/blender/makesrna/intern/rna_test.c b/source/blender/makesrna/intern/rna_test.c
index 46299799966..f6d38c309f3 100644
--- a/source/blender/makesrna/intern/rna_test.c
+++ b/source/blender/makesrna/intern/rna_test.c
@@ -150,7 +150,7 @@ void RNA_def_test(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_DYNAMIC);
RNA_def_property_dynamic_array_funcs(prop, "rna_Test_idarr_get_length", "rna_Test_idarr_set_length");
RNA_def_property_int_funcs(prop, "rna_Test_idarr_get", "rna_Test_idarr_set", NULL);
-
+
prop = RNA_def_boolean_array(srna, "bdarr", DYNAMIC_ARRAY_SIZE, NULL, "bdarr", "boolean array");
RNA_def_property_flag(prop, PROP_DYNAMIC);
RNA_def_property_dynamic_array_funcs(prop, "rna_Test_bdarr_get_length", "rna_Test_bdarr_set_length");
diff --git a/source/blender/makesrna/intern/rna_text.c b/source/blender/makesrna/intern/rna_text.c
index 474fc3e5dc7..1035a3f7f55 100644
--- a/source/blender/makesrna/intern/rna_text.c
+++ b/source/blender/makesrna/intern/rna_text.c
@@ -131,10 +131,10 @@ static void rna_def_text_line(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "TextLine", NULL);
RNA_def_struct_ui_text(srna, "Text Line", "Line of text in a Text data-block");
-
+
prop = RNA_def_property(srna, "body", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, "rna_TextLine_body_get", "rna_TextLine_body_length", "rna_TextLine_body_set");
RNA_def_property_ui_text(prop, "Line", "Text in the line");
@@ -146,12 +146,12 @@ static void rna_def_text(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "Text", "ID");
RNA_def_struct_ui_text(srna, "Text", "Text data-block referencing an external or packed text file");
RNA_def_struct_ui_icon(srna, ICON_TEXT);
RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
-
+
prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, "rna_Text_filename_get", "rna_Text_filename_length", "rna_Text_filename_set");
RNA_def_property_ui_text(prop, "File Path", "Filename of the text file");
@@ -170,7 +170,7 @@ static void rna_def_text(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flags", TXT_ISMEM);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Memory", "Text file is in memory, without a corresponding file on disk");
-
+
prop = RNA_def_property(srna, "use_module", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", TXT_ISSCRIPT);
RNA_def_property_ui_text(prop, "Register",
@@ -183,7 +183,7 @@ static void rna_def_text(BlenderRNA *brna)
prop = RNA_def_property(srna, "lines", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "TextLine");
RNA_def_property_ui_text(prop, "Lines", "Lines of text");
-
+
prop = RNA_def_property(srna, "current_line", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, NULL, "curl");
@@ -197,7 +197,7 @@ static void rna_def_text(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Current Character",
"Index of current character in current line, and also start index of "
"character in selection if one exists");
-
+
prop = RNA_def_property(srna, "current_line_index", PROP_INT, PROP_NONE);
RNA_def_property_int_funcs(prop, "rna_Text_current_line_index_get", "rna_Text_current_line_index_set", NULL);
RNA_def_property_ui_text(prop, "Current Line Index", "Index of current TextLine in TextLine collection");
@@ -209,13 +209,13 @@ static void rna_def_text(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "TextLine");
RNA_def_property_ui_text(prop, "Selection End Line", "End line of selection");
-
+
prop = RNA_def_property(srna, "select_end_character", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "selc");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Selection End Character",
"Index of character after end of selection in the selection end line");
-
+
RNA_api_text(srna);
}
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index 5449b67c040..b848bb96392 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -191,7 +191,7 @@ static void rna_Texture_nodes_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
static void rna_Texture_type_set(PointerRNA *ptr, int value)
{
Tex *tex = (Tex *)ptr->data;
-
+
BKE_texture_type_set(tex, value);
}
@@ -247,7 +247,7 @@ void rna_TextureSlot_update(bContext *C, PointerRNA *ptr)
char *rna_TextureSlot_path(PointerRNA *ptr)
{
MTex *mtex = ptr->data;
-
+
/* if there is ID-data, resolve the path using the index instead of by name,
* since the name used is the name of the texture assigned, but the texture
* may be used multiple times in the same stack
@@ -274,7 +274,7 @@ char *rna_TextureSlot_path(PointerRNA *ptr)
}
}
}
-
+
/* this is a compromise for the remaining cases... */
if (mtex->tex) {
char name_esc[(sizeof(mtex->tex->id.name) - 2) * 2];
@@ -293,7 +293,7 @@ static int rna_TextureSlot_name_length(PointerRNA *ptr)
if (mtex->tex)
return strlen(mtex->tex->id.name + 2);
-
+
return 0;
}
@@ -312,7 +312,7 @@ static int rna_TextureSlot_output_node_get(PointerRNA *ptr)
MTex *mtex = ptr->data;
Tex *tex = mtex->tex;
int cur = mtex->which_output;
-
+
if (tex) {
bNodeTree *ntree = tex->nodetree;
bNode *node;
@@ -325,7 +325,7 @@ static int rna_TextureSlot_output_node_get(PointerRNA *ptr)
}
}
}
-
+
mtex->which_output = 0;
return 0;
}
@@ -339,18 +339,18 @@ static const EnumPropertyItem *rna_TextureSlot_output_node_itemf(
Tex *tex = mtex->tex;
EnumPropertyItem *item = NULL;
int totitem = 0;
-
+
if (tex) {
bNodeTree *ntree = tex->nodetree;
if (ntree) {
EnumPropertyItem tmp = {0, "", 0, "", ""};
bNode *node;
-
+
tmp.value = 0;
tmp.name = "Not Specified";
tmp.identifier = "NOT_SPECIFIED";
RNA_enum_item_add(&item, &totitem, &tmp);
-
+
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == TEX_NODE_OUTPUT) {
tmp.value = node->custom1;
@@ -361,7 +361,7 @@ static const EnumPropertyItem *rna_TextureSlot_output_node_itemf(
}
}
}
-
+
RNA_enum_item_end(&item, &totitem);
*r_free = true;
@@ -382,14 +382,14 @@ static void rna_Texture_use_color_ramp_set(PointerRNA *ptr, int value)
static void rna_Texture_use_nodes_update(bContext *C, PointerRNA *ptr)
{
Tex *tex = (Tex *)ptr->data;
-
+
if (tex->use_nodes) {
tex->type = 0;
-
+
if (tex->nodetree == NULL)
ED_node_texture_default(C, tex);
}
-
+
rna_Texture_nodes_update(CTX_data_main(C), CTX_data_scene(C), ptr);
}
@@ -412,7 +412,7 @@ static void rna_def_texmapping(BlenderRNA *brna)
{MTEX_SPHERE, "SPHERE", 0, "Sphere", "Map with Z as central axis"},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem prop_vect_type_items[] = {
{TEXMAP_TYPE_TEXTURE, "TEXTURE", 0, "Texture", "Transform a texture by inverse mapping the texture coordinate"},
{TEXMAP_TYPE_POINT, "POINT", 0, "Point", "Transform a point"},
@@ -431,7 +431,7 @@ static void rna_def_texmapping(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "TexMapping", NULL);
RNA_def_struct_ui_text(srna, "Texture Mapping", "Texture coordinate mapping settings");
@@ -446,34 +446,34 @@ static void rna_def_texmapping(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Location", "");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
-
+
/* Not PROP_XYZ, this is now in radians, no more degrees */
prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER);
RNA_def_property_float_sdna(prop, NULL, "rot");
RNA_def_property_ui_text(prop, "Rotation", "");
RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
-
+
prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "size");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
RNA_def_property_ui_text(prop, "Scale", "");
RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
-
+
prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "min");
RNA_def_property_ui_text(prop, "Minimum", "Minimum value for clipping");
RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
-
+
prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "max");
RNA_def_property_ui_text(prop, "Maximum", "Maximum value for clipping");
RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
-
+
prop = RNA_def_property(srna, "use_min", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MIN);
RNA_def_property_ui_text(prop, "Has Minimum", "Whether to use minimum clipping value");
RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
-
+
prop = RNA_def_property(srna, "use_max", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MAX);
RNA_def_property_ui_text(prop, "Has Maximum", "Whether to use maximum clipping value");
@@ -484,13 +484,13 @@ static void rna_def_texmapping(BlenderRNA *brna)
RNA_def_property_enum_items(prop, prop_xyz_mapping_items);
RNA_def_property_ui_text(prop, "X Mapping", "");
RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
-
+
prop = RNA_def_property(srna, "mapping_y", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "projy");
RNA_def_property_enum_items(prop, prop_xyz_mapping_items);
RNA_def_property_ui_text(prop, "Y Mapping", "");
RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
-
+
prop = RNA_def_property(srna, "mapping_z", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "projz");
RNA_def_property_enum_items(prop, prop_xyz_mapping_items);
@@ -507,7 +507,7 @@ static void rna_def_colormapping(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "ColorMapping", NULL);
RNA_def_struct_ui_text(srna, "Color Mapping", "Color mapping settings");
@@ -562,7 +562,7 @@ static void rna_def_mtex(BlenderRNA *brna)
{0, "DUMMY", 0, "Dummy", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "TextureSlot", NULL);
RNA_def_struct_sdna(srna, "MTex");
RNA_def_struct_ui_text(srna, "Texture Slot", "Texture slot defining the mapping and influence of a texture");
@@ -639,7 +639,7 @@ static void rna_def_mtex(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Default Value",
"Value to use for Ref, Spec, Amb, Emit, Alpha, RayMir, TransLu and Hard");
RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
-
+
prop = RNA_def_property(srna, "output_node", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "which_output");
RNA_def_property_enum_items(prop, output_node_items);
@@ -652,24 +652,24 @@ static void rna_def_mtex(BlenderRNA *brna)
static void rna_def_filter_common(StructRNA *srna)
{
PropertyRNA *prop;
-
+
prop = RNA_def_property(srna, "use_mipmap", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_MIPMAP);
RNA_def_property_boolean_funcs(prop, NULL, "rna_ImageTexture_mipmap_set");
RNA_def_property_ui_text(prop, "MIP Map", "Use auto-generated MIP maps for the image");
RNA_def_property_update(prop, 0, "rna_Texture_update");
-
+
prop = RNA_def_property(srna, "use_mipmap_gauss", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_GAUSS_MIP);
RNA_def_property_ui_text(prop, "MIP Map Gaussian filter", "Use Gauss filter to sample down MIP maps");
RNA_def_property_update(prop, 0, "rna_Texture_update");
-
+
prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "texfilter");
RNA_def_property_enum_items(prop, texture_filter_items);
RNA_def_property_ui_text(prop, "Filter", "Texture filter to use for sampling image");
RNA_def_property_update(prop, 0, "rna_Texture_update");
-
+
prop = RNA_def_property(srna, "filter_lightprobes", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "afmax");
RNA_def_property_range(prop, 1, 256);
@@ -677,7 +677,7 @@ static void rna_def_filter_common(StructRNA *srna)
"Maximum number of samples (higher gives less blur at distant/oblique angles, "
"but is also slower)");
RNA_def_property_update(prop, 0, "rna_Texture_update");
-
+
prop = RNA_def_property(srna, "filter_eccentricity", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "afmax");
RNA_def_property_range(prop, 1, 256);
@@ -908,7 +908,7 @@ static void rna_def_texture_marble(BlenderRNA *brna)
RNA_def_property_enum_items(prop, prop_marble_stype);
RNA_def_property_ui_text(prop, "Pattern", "");
RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
-
+
prop = RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "noisebasis");
RNA_def_property_enum_items(prop, prop_noise_basis_items);
@@ -1016,7 +1016,7 @@ static void rna_def_texture_stucci(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.0001, 200, 10, 2);
RNA_def_property_ui_text(prop, "Turbulence", "Turbulence of the noise");
RNA_def_property_update(prop, 0, "rna_Texture_update");
-
+
prop = RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "noisebasis");
RNA_def_property_enum_items(prop, prop_noise_basis_items);
@@ -1329,19 +1329,19 @@ static void rna_def_texture_voronoi(BlenderRNA *brna)
RNA_def_property_range(prop, -2, 2);
RNA_def_property_ui_text(prop, "Weight 1", "Voronoi feature weight 1");
RNA_def_property_update(prop, 0, "rna_Texture_update");
-
+
prop = RNA_def_property(srna, "weight_2", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "vn_w2");
RNA_def_property_range(prop, -2, 2);
RNA_def_property_ui_text(prop, "Weight 2", "Voronoi feature weight 2");
RNA_def_property_update(prop, 0, "rna_Texture_update");
-
+
prop = RNA_def_property(srna, "weight_3", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "vn_w3");
RNA_def_property_range(prop, -2, 2);
RNA_def_property_ui_text(prop, "Weight 3", "Voronoi feature weight 3");
RNA_def_property_update(prop, 0, "rna_Texture_update");
-
+
prop = RNA_def_property(srna, "weight_4", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "vn_w4");
RNA_def_property_range(prop, -2, 2);
@@ -1451,7 +1451,7 @@ static void rna_def_texture(BlenderRNA *brna)
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TEX_NO_CLAMP);
RNA_def_property_ui_text(prop, "Clamp", "Set negative texture RGB and intensity values to zero, for some uses like displacement this option can be disabled to get the full range");
RNA_def_property_update(prop, 0, "rna_Texture_update");
-
+
prop = RNA_def_property(srna, "use_color_ramp", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_COLORBAND);
RNA_def_property_boolean_funcs(prop, NULL, "rna_Texture_use_color_ramp_set");
@@ -1479,44 +1479,44 @@ static void rna_def_texture(BlenderRNA *brna)
RNA_def_property_range(prop, 0, 2);
RNA_def_property_ui_text(prop, "Saturation", "Adjust the saturation of colors in the texture");
RNA_def_property_update(prop, 0, "rna_Texture_update");
-
+
/* RGB Factor */
prop = RNA_def_property(srna, "factor_red", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "rfac");
RNA_def_property_range(prop, 0, 2);
RNA_def_property_ui_text(prop, "Factor Red", "");
RNA_def_property_update(prop, 0, "rna_Texture_update");
-
+
prop = RNA_def_property(srna, "factor_green", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "gfac");
RNA_def_property_range(prop, 0, 2);
RNA_def_property_ui_text(prop, "Factor Green", "");
RNA_def_property_update(prop, 0, "rna_Texture_update");
-
+
prop = RNA_def_property(srna, "factor_blue", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "bfac");
RNA_def_property_range(prop, 0, 2);
RNA_def_property_ui_text(prop, "Factor Blue", "");
RNA_def_property_update(prop, 0, "rna_Texture_update");
-
+
/* Alpha for preview render */
prop = RNA_def_property(srna, "use_preview_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_PRV_ALPHA);
RNA_def_property_ui_text(prop, "Show Alpha", "Show Alpha in Preview Render");
RNA_def_property_update(prop, 0, "rna_Texture_update");
-
+
/* nodetree */
prop = RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1);
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_ui_text(prop, "Use Nodes", "Make this a node-based texture");
RNA_def_property_update(prop, 0, "rna_Texture_use_nodes_update");
-
+
prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node-based textures");
RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
-
+
rna_def_animdata_common(srna);
/* specific types */
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index 173eaf56f0c..ebee502515f 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -93,7 +93,7 @@ static ARegionType *region_type_find(ReportList *reports, int space_type, int re
if (art->regionid == region_type)
break;
}
-
+
/* region type not found? abort */
if (art == NULL) {
BKE_report(reports, RPT_ERROR, "Region not found in space type");
@@ -175,10 +175,16 @@ static void rna_Panel_unregister(Main *UNUSED(bmain), StructRNA *type)
return;
if (!(art = region_type_find(NULL, pt->space_type, pt->region_type)))
return;
-
+
RNA_struct_free_extension(type, &pt->ext);
RNA_struct_free(&BLENDER_RNA, type);
+ if (pt->parent) {
+ LinkData *link = BLI_findptr(&pt->parent->children, pt, offsetof(LinkData, data));
+ BLI_freelinkN(&pt->parent->children, link);
+ }
+
+ BLI_freelistN(&pt->children);
BLI_freelinkN(&art->paneltypes, pt);
/* update while blender is running */
@@ -190,7 +196,7 @@ static StructRNA *rna_Panel_register(
StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
ARegionType *art;
- PanelType *pt, dummypt = {NULL};
+ PanelType *pt, *parent = NULL, dummypt = {NULL};
Panel dummypanel = {NULL};
PointerRNA dummyptr;
int have_function[3];
@@ -205,7 +211,7 @@ static StructRNA *rna_Panel_register(
/* validate the python class */
if (validate(&dummyptr, data, have_function) != 0)
return NULL;
-
+
if (strlen(identifier) >= sizeof(dummypt.idname)) {
BKE_reportf(reports, RPT_ERROR, "Registering panel class: '%s' is too long, maximum length is %d",
identifier, (int)sizeof(dummypt.idname));
@@ -229,6 +235,10 @@ static StructRNA *rna_Panel_register(
BLI_freelinkN(&art->paneltypes, pt);
break;
}
+
+ if (dummypt.parent_id[0] && STREQ(pt->idname, dummypt.parent_id)) {
+ parent = pt;
+ }
}
if (!RNA_struct_available_or_report(reports, dummypt.idname)) {
return NULL;
@@ -236,7 +246,12 @@ static StructRNA *rna_Panel_register(
if (!RNA_struct_bl_idname_ok_or_report(reports, dummypt.idname, "_PT_")) {
return NULL;
}
-
+ if (dummypt.parent_id[0] && !parent) {
+ BKE_reportf(reports, RPT_ERROR, "Registering panel class: parent '%s' for '%s' not found",
+ dummypt.parent_id, dummypt.idname);
+ return NULL;
+ }
+
/* create a new panel type */
pt = MEM_callocN(sizeof(PanelType), "python buttons panel");
memcpy(pt, &dummypt, sizeof(dummypt));
@@ -267,6 +282,11 @@ static StructRNA *rna_Panel_register(
else
BLI_addtail(&art->paneltypes, pt);
+ if (parent) {
+ pt->parent = parent;
+ BLI_addtail(&parent->children, BLI_genericNodeN(pt));
+ }
+
{
const char *owner_id = RNA_struct_state_owner_get();
if (owner_id) {
@@ -276,14 +296,14 @@ static StructRNA *rna_Panel_register(
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
-
+
return pt->ext.srna;
}
static StructRNA *rna_Panel_refine(PointerRNA *ptr)
{
- Panel *hdr = (Panel *)ptr->data;
- return (hdr->type && hdr->type->ext.srna) ? hdr->type->ext.srna : &RNA_Panel;
+ Panel *menu = (Panel *)ptr->data;
+ return (menu->type && menu->type->ext.srna) ? menu->type->ext.srna : &RNA_Panel;
}
/* UIList */
@@ -570,7 +590,7 @@ static void rna_Header_unregister(Main *UNUSED(bmain), StructRNA *type)
return;
if (!(art = region_type_find(NULL, ht->space_type, ht->region_type)))
return;
-
+
RNA_struct_free_extension(type, &ht->ext);
RNA_struct_free(&BLENDER_RNA, type);
@@ -622,7 +642,7 @@ static StructRNA *rna_Header_register(
if (!RNA_struct_bl_idname_ok_or_report(reports, dummyht.idname, "_HT_")) {
return NULL;
}
-
+
/* create a new header type */
ht = MEM_callocN(sizeof(HeaderType), "python buttons header");
memcpy(ht, &dummyht, sizeof(dummyht));
@@ -639,7 +659,7 @@ static StructRNA *rna_Header_register(
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
-
+
return ht->ext.srna;
}
@@ -676,7 +696,7 @@ static int menu_poll(const bContext *C, MenuType *pt)
return visible;
}
-static void menu_draw(const bContext *C, Menu *hdr)
+static void menu_draw(const bContext *C, Menu *menu)
{
extern FunctionRNA rna_Menu_draw_func;
@@ -684,12 +704,12 @@ static void menu_draw(const bContext *C, Menu *hdr)
ParameterList list;
FunctionRNA *func;
- RNA_pointer_create(&CTX_wm_screen(C)->id, hdr->type->ext.srna, hdr, &mtr);
+ RNA_pointer_create(&CTX_wm_screen(C)->id, menu->type->ext.srna, menu, &mtr);
func = &rna_Menu_draw_func; /* RNA_struct_find_function(&mtr, "draw"); */
RNA_parameter_list_create(&list, &mtr, func);
RNA_parameter_set_lookup(&list, "context", &C);
- hdr->type->ext.call((bContext *)C, &mtr, func, &list);
+ menu->type->ext.call((bContext *)C, &mtr, func, &list);
RNA_parameter_list_free(&list);
}
@@ -700,7 +720,7 @@ static void rna_Menu_unregister(Main *UNUSED(bmain), StructRNA *type)
if (!mt)
return;
-
+
RNA_struct_free_extension(type, &mt->ext);
RNA_struct_free(&BLENDER_RNA, type);
@@ -734,7 +754,7 @@ static StructRNA *rna_Menu_register(
/* validate the python class */
if (validate(&dummymtr, data, have_function) != 0)
return NULL;
-
+
if (strlen(identifier) >= sizeof(dummymt.idname)) {
BKE_reportf(reports, RPT_ERROR, "Registering menu class: '%s' is too long, maximum length is %d",
identifier, (int)sizeof(dummymt.idname));
@@ -752,7 +772,7 @@ static StructRNA *rna_Menu_register(
if (!RNA_struct_bl_idname_ok_or_report(reports, dummymt.idname, "_MT_")) {
return NULL;
}
-
+
/* create a new menu type */
if (_menu_descr[0]) {
description_size = strlen(_menu_descr) + 1;
@@ -792,14 +812,14 @@ static StructRNA *rna_Menu_register(
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
-
+
return mt->ext.srna;
}
static StructRNA *rna_Menu_refine(PointerRNA *mtr)
{
- Menu *hdr = (Menu *)mtr->data;
- return (hdr->type && hdr->type->ext.srna) ? hdr->type->ext.srna : &RNA_Menu;
+ Menu *menu = (Menu *)mtr->data;
+ return (menu->type && menu->type->ext.srna) ? menu->type->ext.srna : &RNA_Menu;
}
static void rna_Menu_bl_description_set(PointerRNA *ptr, const char *value)
@@ -938,7 +958,7 @@ static void rna_def_ui_layout(BlenderRNA *brna)
{UI_LAYOUT_ALIGN_RIGHT, "RIGHT", 0, "Right", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem emboss_items[] = {
{UI_EMBOSS, "NORMAL", 0, "Normal", "Draw standard button emboss style"},
{UI_EMBOSS_NONE, "NONE", 0, "None", "Draw only text and icons"},
@@ -955,15 +975,15 @@ static void rna_def_ui_layout(BlenderRNA *brna)
prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_UILayout_active_get", "rna_UILayout_active_set");
-
+
prop = RNA_def_property(srna, "operator_context", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_operator_context_items);
RNA_def_property_enum_funcs(prop, "rna_UILayout_op_context_get", "rna_UILayout_op_context_set", NULL);
-
+
prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_UILayout_enabled_get", "rna_UILayout_enabled_set");
RNA_def_property_ui_text(prop, "Enabled", "When false, this (sub)layout is grayed out");
-
+
prop = RNA_def_property(srna, "alert", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_UILayout_alert_get", "rna_UILayout_alert_set");
@@ -979,7 +999,7 @@ static void rna_def_ui_layout(BlenderRNA *brna)
prop = RNA_def_property(srna, "scale_x", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_funcs(prop, "rna_UILayout_scale_x_get", "rna_UILayout_scale_x_set", NULL);
RNA_def_property_ui_text(prop, "Scale X", "Scale factor along the X for items in this (sub)layout");
-
+
prop = RNA_def_property(srna, "scale_y", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_funcs(prop, "rna_UILayout_scale_y_get", "rna_UILayout_scale_y_set", NULL);
RNA_def_property_ui_text(prop, "Scale Y", "Scale factor along the Y for items in this (sub)layout");
@@ -988,7 +1008,7 @@ static void rna_def_ui_layout(BlenderRNA *brna)
prop = RNA_def_property(srna, "emboss", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, emboss_items);
RNA_def_property_enum_funcs(prop, "rna_UILayout_emboss_get", "rna_UILayout_emboss_set", NULL);
-
+
prop = RNA_def_property(srna, "use_property_split", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_UILayout_property_split_get", "rna_UILayout_property_split_set");
}
@@ -999,7 +1019,7 @@ static void rna_def_panel(BlenderRNA *brna)
PropertyRNA *prop;
PropertyRNA *parm;
FunctionRNA *func;
-
+
static const EnumPropertyItem panel_flag_items[] = {
{PNL_DEFAULT_CLOSED, "DEFAULT_CLOSED", 0, "Default Closed",
"Defines if the panel has to be open or collapsed at the time of its creation"},
@@ -1008,7 +1028,7 @@ static void rna_def_panel(BlenderRNA *brna)
"arrow to collapse the panel and the label (see bl_label)"},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "Panel", NULL);
RNA_def_struct_ui_text(srna, "Panel", "Panel containing UI elements");
RNA_def_struct_sdna(srna, "Panel");
@@ -1041,11 +1061,11 @@ static void rna_def_panel(BlenderRNA *brna)
prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "UILayout");
RNA_def_property_ui_text(prop, "Layout", "Defines the structure of the panel in the UI");
-
+
prop = RNA_def_property(srna, "text", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "drawname");
RNA_def_property_ui_text(prop, "Text", "XXX todo");
-
+
/* registration */
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "type->idname");
@@ -1082,7 +1102,7 @@ static void rna_def_panel(BlenderRNA *brna)
RNA_def_property_enum_items(prop, rna_enum_space_type_items);
RNA_def_property_flag(prop, PROP_REGISTER);
RNA_def_property_ui_text(prop, "Space type", "The space where the panel is going to be used in");
-
+
prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type->region_type");
RNA_def_property_enum_items(prop, rna_enum_region_type_items);
@@ -1095,18 +1115,28 @@ static void rna_def_panel(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Context",
"The context in which the panel belongs to. (TODO: explain the "
"possible combinations bl_context/bl_region_type/bl_space_type)");
-
+
prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type->flag");
RNA_def_property_enum_items(prop, panel_flag_items);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
RNA_def_property_ui_text(prop, "Options", "Options for this panel type");
+ prop = RNA_def_property(srna, "bl_parent_id", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "type->parent_id");
+ RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+ RNA_def_property_ui_text(prop, "Parent ID Name", "If this is set, the panel becomes a subpanel");
+
prop = RNA_def_property(srna, "use_pin", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PNL_PIN);
RNA_def_property_ui_text(prop, "Pin", "");
/* XXX, should only tag region for redraw */
RNA_def_property_update(prop, NC_WINDOW, NULL);
+
+ prop = RNA_def_property(srna, "is_popover", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PNL_POPOVER);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Popover", "");
}
static void rna_def_uilist(BlenderRNA *brna)
@@ -1238,7 +1268,7 @@ static void rna_def_header(BlenderRNA *brna)
PropertyRNA *prop;
PropertyRNA *parm;
FunctionRNA *func;
-
+
srna = RNA_def_struct(brna, "Header", NULL);
RNA_def_struct_ui_text(srna, "Header", "Editor header containing UI elements");
RNA_def_struct_sdna(srna, "Header");
@@ -1293,7 +1323,7 @@ static void rna_def_menu(BlenderRNA *brna)
PropertyRNA *prop;
PropertyRNA *parm;
FunctionRNA *func;
-
+
srna = RNA_def_struct(brna, "Menu", NULL);
RNA_def_struct_ui_text(srna, "Menu", "Editor menu containing buttons");
RNA_def_struct_sdna(srna, "Menu");
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index d61f6166889..3940f13c64a 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -95,9 +95,10 @@ const char *rna_translate_ui_text(
return BLT_pgettext(BLT_I18NCONTEXT_DEFAULT, text);
}
-static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name, const char *text_ctxt,
- int translate, int icon, int expand, int slider, int toggle, int icon_only, int event,
- int full_event, int emboss, int index, int icon_value)
+static void rna_uiItemR(
+ uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name, const char *text_ctxt,
+ int translate, int icon, int expand, int slider, int toggle, int icon_only, int event,
+ int full_event, int emboss, int index, int icon_value)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
int flag = 0;
@@ -125,8 +126,9 @@ static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname,
uiItemFullR(layout, ptr, prop, index, 0, flag, name, icon);
}
-static void rna_uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name,
- const char *text_ctxt, int translate, int icon)
+static void rna_uiItemMenuEnumR(
+ uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name,
+ const char *text_ctxt, int translate, int icon)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
@@ -140,8 +142,9 @@ static void rna_uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const
uiItemMenuEnumR_prop(layout, ptr, prop, name, icon);
}
-static void rna_uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value,
- const char *name, const char *text_ctxt, int translate, int icon)
+static void rna_uiItemEnumR_string(
+ uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value,
+ const char *name, const char *text_ctxt, int translate, int icon)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
@@ -157,9 +160,10 @@ static void rna_uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, con
uiItemEnumR_string(layout, ptr, propname, value, name, icon);
}
-static void rna_uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
- struct PointerRNA *searchptr, const char *searchpropname,
- const char *name, const char *text_ctxt, int translate, int icon)
+static void rna_uiItemPointerR(
+ uiLayout *layout, struct PointerRNA *ptr, const char *propname,
+ struct PointerRNA *searchptr, const char *searchpropname,
+ const char *name, const char *text_ctxt, int translate, int icon)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
@@ -226,8 +230,9 @@ static PointerRNA rna_uiItemOMenuHold(
}
-static void rna_uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, const char *propname, const char *name,
- const char *text_ctxt, int translate, int icon)
+static void rna_uiItemMenuEnumO(
+ uiLayout *layout, bContext *C, const char *opname, const char *propname, const char *name,
+ const char *text_ctxt, int translate, int icon)
{
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
@@ -242,8 +247,9 @@ static void rna_uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opnam
uiItemMenuEnumO_ptr(layout, C, ot, propname, name, icon);
}
-static void rna_uiItemL(uiLayout *layout, const char *name, const char *text_ctxt, int translate,
- int icon, int icon_value)
+static void rna_uiItemL(
+ uiLayout *layout, const char *name, const char *text_ctxt, int translate,
+ int icon, int icon_value)
{
/* Get translated name (label). */
name = rna_translate_ui_text(name, text_ctxt, NULL, NULL, translate);
@@ -255,8 +261,9 @@ static void rna_uiItemL(uiLayout *layout, const char *name, const char *text_ctx
uiItemL(layout, name, icon);
}
-static void rna_uiItemM(uiLayout *layout, bContext *C, const char *menuname, const char *name, const char *text_ctxt,
- int translate, int icon, int icon_value)
+static void rna_uiItemM(
+ uiLayout *layout, bContext *C, const char *menuname, const char *name, const char *text_ctxt,
+ int translate, int icon, int icon_value)
{
/* Get translated name (label). */
name = rna_translate_ui_text(name, text_ctxt, NULL, NULL, translate);
@@ -291,8 +298,9 @@ static void rna_uiItemPopoverPanelFromGroup(
uiItemPopoverPanelFromGroup(layout, C, space_id, region_id, context, category);
}
-static void rna_uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *proptypename,
- const char *name, const char *text_ctxt, int translate)
+static void rna_uiTemplateAnyID(
+ uiLayout *layout, PointerRNA *ptr, const char *propname, const char *proptypename,
+ const char *name, const char *text_ctxt, int translate)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
@@ -308,8 +316,9 @@ static void rna_uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *p
uiTemplateAnyID(layout, ptr, propname, proptypename, name);
}
-static void rna_uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *root_ptr,
- const char *name, const char *text_ctxt, int translate)
+static void rna_uiTemplatePathBuilder(
+ uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *root_ptr,
+ const char *name, const char *text_ctxt, int translate)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
@@ -360,8 +369,9 @@ static const char *rna_ui_get_enum_name(bContext *C, PointerRNA *ptr, const char
return name;
}
-static const char *rna_ui_get_enum_description(bContext *C, PointerRNA *ptr, const char *propname,
- const char *identifier)
+static const char *rna_ui_get_enum_description(
+ bContext *C, PointerRNA *ptr, const char *propname,
+ const char *identifier)
{
PropertyRNA *prop = NULL;
const EnumPropertyItem *items = NULL, *item;
@@ -493,7 +503,7 @@ void RNA_api_ui_layout(StructRNA *srna)
"Sub-layout. Items placed in this sublayout are placed next to each other "
"in a row");
RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
-
+
func = RNA_def_function(srna, "column", "uiLayoutColumn");
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
RNA_def_function_return(func, parm);
@@ -508,13 +518,26 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_function_return(func, parm);
RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
+ func = RNA_def_function(srna, "grid_flow", "uiLayoutGridFlow");
+ RNA_def_boolean(func, "row_major", false, "", "Fill row by row, instead of column by column");
+ RNA_def_int(func, "num_columns", 0, INT_MIN, INT_MAX, "",
+ "Number of columns, positive are absolute fixed numbers, 0 is automatic, negative are "
+ "automatic multiple numbers along major axis (e.g. -2 will only produce 2, 4, 6 etc. "
+ "columns for row major layout, and 2, 4, 6 etc. rows for column major layout)",
+ INT_MIN, INT_MAX);
+ RNA_def_boolean(func, "even_columns", false, "", "All columns will have the same width");
+ RNA_def_boolean(func, "even_rows", false, "", "All rows will have the same height");
+ RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
+ parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
+ RNA_def_function_return(func, parm);
+
/* box layout */
func = RNA_def_function(srna, "box", "uiLayoutBox");
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
RNA_def_function_return(func, parm);
RNA_def_function_ui_description(func, "Sublayout (items placed in this sublayout are placed "
"under each other in a column and are surrounded by a box)");
-
+
/* split layout */
func = RNA_def_function(srna, "split", "uiLayoutSplit");
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
@@ -719,13 +742,16 @@ void RNA_api_ui_layout(StructRNA *srna)
func = RNA_def_function(srna, "separator", "uiItemS");
RNA_def_function_ui_description(func, "Item. Inserts empty space into the layout between items");
+ func = RNA_def_function(srna, "separator_spacer", "uiItemSpacer");
+ RNA_def_function_ui_description(func, "Item. Inserts horizontal spacing empty space into the layout between items");
+
/* context */
func = RNA_def_function(srna, "context_pointer_set", "uiLayoutSetContextPointer");
parm = RNA_def_string(func, "name", NULL, 0, "Name", "Name of entry in the context");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_pointer(func, "data", "AnyType", "", "Pointer to put in context");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR);
-
+
/* templates */
func = RNA_def_function(srna, "template_header", "uiTemplateHeader");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
@@ -802,7 +828,7 @@ void RNA_api_ui_layout(StructRNA *srna)
parm = RNA_def_pointer(func, "root", "ID", "", "ID-block from which path is evaluated from");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR);
api_ui_item_common_text(func);
-
+
func = RNA_def_function(srna, "template_modifier", "uiTemplateModifier");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Generates the UI layout for modifiers");
@@ -852,15 +878,15 @@ void RNA_api_ui_layout(StructRNA *srna)
func = RNA_def_function(srna, "template_histogram", "uiTemplateHistogram");
RNA_def_function_ui_description(func, "Item. A histogramm widget to analyze imaga data");
api_ui_item_rna_common(func);
-
+
func = RNA_def_function(srna, "template_waveform", "uiTemplateWaveform");
RNA_def_function_ui_description(func, "Item. A waveform widget to analyze imaga data");
api_ui_item_rna_common(func);
-
+
func = RNA_def_function(srna, "template_vectorscope", "uiTemplateVectorscope");
RNA_def_function_ui_description(func, "Item. A vectorscope widget to analyze imaga data");
api_ui_item_rna_common(func);
-
+
func = RNA_def_function(srna, "template_layers", "uiTemplateLayers");
api_ui_item_rna_common(func);
parm = RNA_def_pointer(func, "used_layers_data", "AnyType", "", "Data from which to take property");
@@ -869,7 +895,7 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_int(func, "active_layer", 0, 0, INT_MAX, "Active Layer", "", 0, INT_MAX);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
+
func = RNA_def_function(srna, "template_color_picker", "uiTemplateColorPicker");
RNA_def_function_ui_description(func, "Item. A color wheel widget to pick colors");
api_ui_item_rna_common(func);
@@ -985,7 +1011,7 @@ void RNA_api_ui_layout(StructRNA *srna)
func = RNA_def_function(srna, "template_edit_mode_selection", "uiTemplateEditModeSelection");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Inserts common 3DView Edit modes header UI (selector for selection mode)");
-
+
func = RNA_def_function(srna, "template_reports_banner", "uiTemplateReportsBanner");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
@@ -1021,10 +1047,6 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_string(func, "name", NULL, 0, "", "");
- func = RNA_def_function(srna, "introspect", "uiLayoutIntrospect");
- parm = RNA_def_string(func, "string", NULL, 1024 * 1024, "Descr", "DESCR");
- RNA_def_function_return(func, parm);
-
/* color management templates */
func = RNA_def_function(srna, "template_colorspace_settings", "uiTemplateColorspaceSettings");
RNA_def_function_ui_description(func, "Item. A widget to control input color space settings.");
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index fef4cc3ed8e..0d05d03e3a9 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -41,6 +41,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_sound.h"
#include "BKE_addon.h"
+#include "BKE_studiolight.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -77,6 +78,12 @@ const EnumPropertyItem rna_enum_navigation_mode_items[] = {
{0, NULL, 0, NULL, NULL}
};
+static const EnumPropertyItem rna_enum_studio_light_icons_id_items[] = {
+ {0, "DEFAULT", 0, "Default", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
+
#if defined(WITH_INTERNATIONAL) || !defined(RNA_RUNTIME)
static const EnumPropertyItem rna_enum_language_default_items[] = {
{0, "DEFAULT", 0, "Default (Default)", ""},
@@ -184,7 +191,7 @@ static void rna_userdef_show_manipulator_update(Main *bmain, Scene *scene, Point
}
}
}
-
+
rna_userdef_update(bmain, scene, ptr);
}
@@ -251,7 +258,7 @@ static int rna_userdef_autokeymode_get(PointerRNA *ptr)
{
UserDef *userdef = (UserDef *)ptr->data;
short retval = userdef->autokey_mode;
-
+
if (!(userdef->autokey_mode & AUTOKEY_ON))
retval |= AUTOKEY_ON;
@@ -284,10 +291,10 @@ static void rna_userdef_timecode_style_set(PointerRNA *ptr, int value)
{
UserDef *userdef = (UserDef *)ptr->data;
int required_size = userdef->v2d_min_gridsize;
-
+
/* set the timecode style */
userdef->timecode_style = value;
-
+
/* adjust the v2d gridsize if needed so that timecodes don't overlap
* NOTE: most of these have been hand-picked to avoid overlaps while still keeping
* things from getting too blown out
@@ -309,7 +316,7 @@ static void rna_userdef_timecode_style_set(PointerRNA *ptr, int value)
required_size = 45;
break;
}
-
+
if (U.v2d_min_gridsize < required_size)
U.v2d_min_gridsize = required_size;
}
@@ -653,6 +660,117 @@ static void rna_ThemeUI_roundness_set(PointerRNA *ptr, float value)
tui->roundness = value * 0.5f;
}
+/* Studio Light */
+static void rna_UserDef_studiolight_begin(CollectionPropertyIterator *iter, PointerRNA *UNUSED(ptr))
+{
+ rna_iterator_listbase_begin(iter, BKE_studiolight_listbase(), NULL);
+}
+
+static void rna_UserDef_studiolight_refresh(UserDef *UNUSED(userdef))
+{
+ BKE_studiolight_refresh();
+}
+
+/* StudioLight.name */
+static void rna_UserDef_studiolight_name_get(PointerRNA *ptr, char *value)
+{
+ StudioLight *sl = (StudioLight *)ptr->data;
+ BLI_strncpy(value, sl->name, FILE_MAXFILE);
+}
+
+static int rna_UserDef_studiolight_name_length(PointerRNA *ptr)
+{
+ StudioLight *sl = (StudioLight *)ptr->data;
+ return strlen(sl->name);
+}
+
+/* StudioLight.path */
+static void rna_UserDef_studiolight_path_get(PointerRNA *ptr, char *value)
+{
+ StudioLight *sl = (StudioLight *)ptr->data;
+ BLI_strncpy(value, sl->path, FILE_MAX);
+}
+
+static int rna_UserDef_studiolight_path_length(PointerRNA *ptr)
+{
+ StudioLight *sl = (StudioLight *)ptr->data;
+ return strlen(sl->path);
+}
+
+/* StudioLight.index */
+static int rna_UserDef_studiolight_index_get(PointerRNA *ptr)
+{
+ StudioLight *sl = (StudioLight *)ptr->data;
+ return sl->index;
+}
+
+/* StudioLight.icon_id */
+static int rna_UserDef_studiolight_icon_id_get(PointerRNA *ptr)
+{
+ StudioLight *sl = (StudioLight *)ptr->data;
+ if (sl->flag & (STUDIOLIGHT_ORIENTATION_VIEWNORMAL | STUDIOLIGHT_ORIENTATION_CAMERA)) {
+ return 1;
+ }
+ return 0;
+}
+
+static const EnumPropertyItem *rna_UserDef_studiolight_icon_id_itemf(
+ bContext *UNUSED(C), PointerRNA *ptr,
+ PropertyRNA *UNUSED(prop), bool *r_free)
+{
+ EnumPropertyItem *item = NULL;
+ int totitem = 0;
+ StudioLight *sl = (StudioLight *)ptr->data;
+
+ if ((sl->flag & (STUDIOLIGHT_ORIENTATION_VIEWNORMAL | STUDIOLIGHT_ORIENTATION_CAMERA)) == 0) {
+ EnumPropertyItem tmp = {0, sl->name, sl->radiance_icon_id, sl->name, ""};
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
+
+ {
+ EnumPropertyItem tmp = {1, sl->name, sl->irradiance_icon_id, sl->name, ""};
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
+ RNA_enum_item_end(&item, &totitem);
+ *r_free = true;
+ return item;
+}
+
+/* StudioLight.is_user_defined */
+static int rna_UserDef_studiolight_is_user_defined_get(PointerRNA *ptr)
+{
+ StudioLight *sl = (StudioLight *)ptr->data;
+ return (sl->flag & STUDIOLIGHT_USER_DEFINED) > 0;
+}
+
+/* StudioLight.show_expanded */
+static int rna_UserDef_studiolight_show_expanded_get(PointerRNA *ptr)
+{
+ StudioLight *sl = (StudioLight *)ptr->data;
+ return (sl->flag & STUDIOLIGHT_UI_EXPANDED) > 0;
+}
+
+static void rna_UserDef_studiolight_show_expanded_set(PointerRNA *ptr, const bool value)
+{
+ StudioLight *sl = (StudioLight *)ptr->data;
+ sl->flag ^= STUDIOLIGHT_UI_EXPANDED;
+ sl->flag |= value ? STUDIOLIGHT_UI_EXPANDED : 0;
+}
+
+
+/* StudioLight.orientation */
+
+static int rna_UserDef_studiolight_orientation_get(PointerRNA *ptr)
+{
+ StudioLight *sl = (StudioLight *)ptr->data;
+ return sl->flag & STUDIOLIGHT_FLAG_ORIENTATIONS;
+}
+
+static void rna_UserDef_studiolight_orientation_set(PointerRNA *UNUSED(ptr), const int UNUSED(value))
+{
+}
+
+
#else
/* TODO(sergey): This technically belongs to blenlib, but we don't link
@@ -680,7 +798,7 @@ static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem font_kerning_style[] = {
{0, "UNFITTED", 0, "Unfitted", "Use scaled but un-grid-fitted kerning distances"},
{1, "FITTED", 0, "Fitted", "Use scaled and grid-fitted kerning distances"},
@@ -691,7 +809,7 @@ static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "uiFontStyle");
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
RNA_def_struct_ui_text(srna, "Font Style", "Theme settings for Font");
-
+
prop = RNA_def_property(srna, "points", PROP_INT, PROP_NONE);
RNA_def_property_range(prop, 6, 48);
RNA_def_property_ui_text(prop, "Points", "");
@@ -707,13 +825,13 @@ static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna)
RNA_def_property_range(prop, 0, 5);
RNA_def_property_ui_text(prop, "Shadow Size", "Shadow size (0, 3 and 5 supported)");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "shadow_offset_x", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "shadx");
RNA_def_property_range(prop, -10, 10);
RNA_def_property_ui_text(prop, "Shadow X Offset", "Shadow offset in pixels");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "shadow_offset_y", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "shady");
RNA_def_property_range(prop, -10, 10);
@@ -737,14 +855,14 @@ static void rna_def_userdef_theme_ui_style(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
rna_def_userdef_theme_ui_font_style(brna);
-
+
srna = RNA_def_struct(brna, "ThemeStyle", NULL);
RNA_def_struct_sdna(srna, "uiStyle");
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
RNA_def_struct_ui_text(srna, "Style", "Theme settings for style sets");
-
+
prop = RNA_def_property(srna, "panel_title", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
@@ -759,66 +877,66 @@ static void rna_def_userdef_theme_ui_style(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "ThemeFontStyle");
RNA_def_property_ui_text(prop, "Widget Label Style", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "widget", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, NULL, "widget");
RNA_def_property_struct_type(prop, "ThemeFontStyle");
RNA_def_property_ui_text(prop, "Widget Style", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
}
static void rna_def_userdef_theme_ui_wcol(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "ThemeWidgetColors", NULL);
RNA_def_struct_sdna(srna, "uiWidgetColors");
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
RNA_def_struct_ui_text(srna, "Theme Widget Color Set", "Theme settings for widget color sets");
-
+
prop = RNA_def_property(srna, "outline", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Outline", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "inner", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Inner", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "inner_sel", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Inner Selected", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "item", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Item", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "text", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Text", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "text_sel", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Text Selected", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "show_shaded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "shaded", 1);
RNA_def_property_ui_text(prop, "Shaded", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "shadetop", PROP_INT, PROP_NONE);
RNA_def_property_range(prop, -100, 100);
RNA_def_property_ui_text(prop, "Shade Top", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "shadedown", PROP_INT, PROP_NONE);
RNA_def_property_range(prop, -100, 100);
RNA_def_property_ui_text(prop, "Shade Down", "");
@@ -834,12 +952,12 @@ static void rna_def_userdef_theme_ui_wcol_state(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "ThemeWidgetStateColors", NULL);
RNA_def_struct_sdna(srna, "uiWidgetStateColors");
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
RNA_def_struct_ui_text(srna, "Theme Widget State Color", "Theme settings for widget state colors");
-
+
prop = RNA_def_property(srna, "inner_anim", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Animated", "");
@@ -849,7 +967,7 @@ static void rna_def_userdef_theme_ui_wcol_state(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Animated Selected", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "inner_key", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Keyframe", "");
@@ -889,20 +1007,24 @@ static void rna_def_userdef_theme_ui_panel(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "ThemePanelColors", NULL);
RNA_def_struct_sdna(srna, "uiPanelColors");
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
RNA_def_struct_ui_text(srna, "Theme Panel Color", "Theme settings for panel colors");
-
+
prop = RNA_def_property(srna, "header", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_ui_text(prop, "Header", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "back", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_ui_text(prop, "Background", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
+ prop = RNA_def_property(srna, "sub_back", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_ui_text(prop, "Sub Background", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
+
prop = RNA_def_property(srna, "show_header", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "Show Header", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
@@ -957,7 +1079,7 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Regular Widget Colors", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "wcol_tool", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Tool Widget Colors", "");
@@ -967,17 +1089,17 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Toolbar Item Widget Colors", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "wcol_radio", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Radio Widget Colors", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "wcol_text", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Text Widget Colors", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "wcol_option", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Option Widget Colors", "");
@@ -987,32 +1109,32 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Toggle Widget Colors", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "wcol_num", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Number Widget Colors", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "wcol_numslider", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Slider Widget Colors", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "wcol_box", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Box Backdrop Colors", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "wcol_menu", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Menu Widget Colors", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "wcol_pulldown", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Pulldown Widget Colors", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "wcol_menu_back", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Menu Backdrop Colors", "");
@@ -1027,7 +1149,7 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Tooltip Colors", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "wcol_menu_item", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Menu Item Colors", "");
@@ -1037,7 +1159,7 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Scroll Widget Colors", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "wcol_progress", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Progress Bar Widget Colors", "");
@@ -1062,12 +1184,12 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Menu Shadow Strength", "Blending factor for menu shadows");
RNA_def_property_range(prop, 0.01f, 1.0f);
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "menu_shadow_width", PROP_INT, PROP_PIXEL);
RNA_def_property_ui_text(prop, "Menu Shadow Width", "Width of menu shadows, set to zero to disable");
RNA_def_property_range(prop, 0.0f, 24.0f);
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "icon_file", PROP_STRING, PROP_FILEPATH);
RNA_def_property_string_sdna(prop, NULL, "iconfile");
RNA_def_property_ui_text(prop, "Icon File", "");
@@ -1080,7 +1202,7 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
prop = RNA_def_property(srna, "icon_saturation", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_ui_text(prop, "Icon Saturation", "Saturation of icons in the interface");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "widget_emboss", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "widget_emboss");
RNA_def_property_array(prop, 4);
@@ -1099,13 +1221,13 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "X Axis", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "yaxis");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Y Axis", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "axis_z", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "zaxis");
RNA_def_property_array(prop, 3);
@@ -1378,7 +1500,7 @@ static void rna_def_userdef_theme_spaces_edge(StructRNA *srna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Edge Sharp", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "edge_crease", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Edge Crease", "");
@@ -1449,7 +1571,7 @@ static void rna_def_userdef_theme_spaces_curves(StructRNA *srna, bool incl_nurbs
bool incl_vector, bool incl_verthandle)
{
PropertyRNA *prop;
-
+
if (incl_nurbs) {
prop = RNA_def_property(srna, "nurb_uline", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "nurb_uline");
@@ -1539,7 +1661,7 @@ static void rna_def_userdef_theme_spaces_curves(StructRNA *srna, bool incl_nurbs
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Auto-Clamped handle color", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "handle_sel_auto_clamped", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "handle_sel_auto_clamped");
RNA_def_property_array(prop, 3);
@@ -1628,7 +1750,7 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Wire Edit", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
/* Grease Pencil */
@@ -1819,7 +1941,7 @@ static void rna_def_userdef_theme_space_graph(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Current Frame", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "window_sliders", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "shade1");
RNA_def_property_array(prop, 3);
@@ -1831,19 +1953,19 @@ static void rna_def_userdef_theme_space_graph(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Channels Region", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "dopesheet_channel", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "ds_channel");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Dope Sheet Channel", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "dopesheet_subchannel", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "ds_subchannel");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Dope Sheet Sub-Channel", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "channel_group", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "group");
RNA_def_property_array(prop, 3);
@@ -1855,7 +1977,7 @@ static void rna_def_userdef_theme_space_graph(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Active Channel Group", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
rna_def_userdef_theme_spaces_vertex(srna);
rna_def_userdef_theme_spaces_curves(srna, false, true, true, true);
}
@@ -1931,33 +2053,33 @@ static void rna_def_userdef_theme_space_console(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "ThemeSpace");
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
RNA_def_struct_ui_text(srna, "Theme Console", "Theme settings for the Console");
-
+
rna_def_userdef_theme_spaces_main(srna);
-
+
prop = RNA_def_property(srna, "line_output", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "console_output");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Line Output", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "line_input", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "console_input");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Line Input", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "line_info", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "console_info");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Line Info", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "line_error", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "console_error");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Line Error", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "cursor", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "console_cursor");
RNA_def_property_array(prop, 3);
@@ -2088,13 +2210,13 @@ static void rna_def_userdef_theme_space_text(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Cursor", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "syntax_builtin", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "syntaxb");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Syntax Built-in", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "syntax_symbols", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "syntaxs");
RNA_def_property_array(prop, 3);
@@ -2124,7 +2246,7 @@ static void rna_def_userdef_theme_space_text(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Syntax Comment", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "syntax_string", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "syntaxl");
RNA_def_property_array(prop, 3);
@@ -2152,7 +2274,7 @@ static void rna_def_userdef_theme_space_node(BlenderRNA *brna)
rna_def_userdef_theme_spaces_main(srna);
rna_def_userdef_theme_spaces_list_main(srna);
-
+
rna_def_userdef_theme_spaces_gpencil(srna);
prop = RNA_def_property(srna, "node_selected", PROP_FLOAT, PROP_COLOR_GAMMA);
@@ -2196,13 +2318,13 @@ static void rna_def_userdef_theme_space_node(BlenderRNA *brna)
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Node Backdrop", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "converter_node", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "syntaxv");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Converter Node", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "color_node", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "syntaxb");
RNA_def_property_array(prop, 3);
@@ -2226,7 +2348,7 @@ static void rna_def_userdef_theme_space_node(BlenderRNA *brna)
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Frame Node", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "matte_node", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "syntaxs");
RNA_def_property_array(prop, 3);
@@ -2333,7 +2455,7 @@ static void rna_def_userdef_theme_space_image(BlenderRNA *brna)
rna_def_userdef_theme_spaces_gpencil(srna);
rna_def_userdef_theme_spaces_vertex(srna);
rna_def_userdef_theme_spaces_face(srna);
-
+
prop = RNA_def_property(srna, "editmesh_active", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 4);
@@ -2523,7 +2645,7 @@ static void rna_def_userdef_theme_space_seq(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Draw Action", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "preview_back", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "preview_back");
RNA_def_property_array(prop, 3);
@@ -2562,13 +2684,13 @@ static void rna_def_userdef_theme_space_action(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Grid", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "frame_current", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "cframe");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Current Frame", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "value_sliders", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "face");
RNA_def_property_array(prop, 3);
@@ -2580,21 +2702,21 @@ static void rna_def_userdef_theme_space_action(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "View Sliders", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
-
+
+
prop = RNA_def_property(srna, "dopesheet_channel", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "ds_channel");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Dope Sheet Channel", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "dopesheet_subchannel", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "ds_subchannel");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Dope Sheet Sub-Channel", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
-
+
+
prop = RNA_def_property(srna, "channels", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "shade2");
RNA_def_property_array(prop, 3);
@@ -2618,8 +2740,8 @@ static void rna_def_userdef_theme_space_action(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Active Channel Group", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
-
+
+
prop = RNA_def_property(srna, "long_key", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "strip");
RNA_def_property_array(prop, 3);
@@ -2632,76 +2754,76 @@ static void rna_def_userdef_theme_space_action(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Long Key Selected", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
-
+
+
prop = RNA_def_property(srna, "keyframe", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "keytype_keyframe");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Keyframe", "Color of Keyframe");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "keyframe_selected", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "keytype_keyframe_select");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Keyframe Selected", "Color of selected keyframe");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "keyframe_extreme", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "keytype_extreme");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Extreme Keyframe", "Color of extreme keyframe");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "keyframe_extreme_selected", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "keytype_extreme_select");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Extreme Keyframe Selected", "Color of selected extreme keyframe");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "keyframe_breakdown", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "keytype_breakdown");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Breakdown Keyframe", "Color of breakdown keyframe");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "keyframe_breakdown_selected", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "keytype_breakdown_select");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Breakdown Keyframe Selected", "Color of selected breakdown keyframe");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "keyframe_jitter", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "keytype_jitter");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Jitter Keyframe", "Color of jitter keyframe");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "keyframe_jitter_selected", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "keytype_jitter_select");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Jitter Keyframe Selected", "Color of selected jitter keyframe");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "keyframe_border", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "keyborder");
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Keyframe Border", "Color of keyframe border");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "keyframe_border_selected", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "keyborder_select");
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Keyframe Border Selected", "Color of selected keyframe border");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "keyframe_scale_factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "keyframe_scale_fac");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Keyframe Scale Factor", "Scale factor for adjusting the height of keyframes");
RNA_def_property_range(prop, 0.8f, 5.0f); /* Note: These limits prevent buttons overlapping (min), and excessive size... (max) */
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, "rna_userdef_update");
-
-
+
+
prop = RNA_def_property(srna, "summary", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "anim_active");
RNA_def_property_array(prop, 4);
@@ -2733,94 +2855,94 @@ static void rna_def_userdef_theme_space_nla(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "View Sliders", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "active_action", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "anim_active");
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Active Action", "Animation data-block has active action");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "active_action_unset", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "anim_non_active");
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "No Active Action", "Animation data-block doesn't have active action");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "strips", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "strip");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Strips", "Action-Clip Strip - Unselected");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "strips_selected", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "strip_select");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Strips Selected", "Action-Clip Strip - Selected");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "transition_strips", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "nla_transition");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Transitions", "Transition Strip - Unselected");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "transition_strips_selected", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "nla_transition_sel");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Transitions Selected", "Transition Strip - Selected");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "meta_strips", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "nla_meta");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Meta Strips", "Meta Strip - Unselected (for grouping related strips)");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "meta_strips_selected", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "nla_meta_sel");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Meta Strips Selected", "Meta Strip - Selected (for grouping related strips)");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "sound_strips", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "nla_sound");
RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Sound Strips",
+ RNA_def_property_ui_text(prop, "Sound Strips",
"Sound Strip - Unselected (for timing speaker sounds)");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "sound_strips_selected", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "nla_sound_sel");
RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Sound Strips Selected",
+ RNA_def_property_ui_text(prop, "Sound Strips Selected",
"Sound Strip - Selected (for timing speaker sounds)");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "tweak", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "nla_tweaking");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Tweak", "Color for strip/action being 'tweaked' or edited");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "tweak_duplicate", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "nla_tweakdupli");
RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Tweak Duplicate Flag",
+ RNA_def_property_ui_text(prop, "Tweak Duplicate Flag",
"Warning/error indicator color for strips referencing the strip being tweaked");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "keyframe_border", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "keyborder");
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Keyframe Border", "Color of keyframe border");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "keyframe_border_selected", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "keyborder_select");
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Keyframe Border Selected", "Color of selected keyframe border");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "frame_current", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "cframe");
RNA_def_property_array(prop, 3);
@@ -2876,7 +2998,7 @@ static void rna_def_userdef_theme_space_clip(BlenderRNA *brna)
rna_def_userdef_theme_spaces_main(srna);
rna_def_userdef_theme_spaces_list_main(srna);
-
+
rna_def_userdef_theme_spaces_gpencil(srna);
prop = RNA_def_property(srna, "marker_outline", PROP_FLOAT, PROP_COLOR_GAMMA);
@@ -2980,7 +3102,7 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem active_theme_area[] = {
{0, "USER_INTERFACE", ICON_UI, "User Interface", ""},
{19, "STYLE", ICON_FONTPREVIEW, "Text Style", ""},
@@ -3105,7 +3227,7 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "tuserpref");
RNA_def_property_struct_type(prop, "ThemeUserPreferences");
RNA_def_property_ui_text(prop, "User Preferences", "");
-
+
prop = RNA_def_property(srna, "console", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, NULL, "tconsole");
@@ -3157,6 +3279,63 @@ static void rna_def_userdef_addon(BlenderRNA *brna)
RNA_def_property_pointer_funcs(prop, "rna_Addon_preferences_get", NULL, NULL, NULL);
}
+static void rna_def_userdef_studiolight(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ static const EnumPropertyItem rna_enum_studio_light_orientation_items[] = {
+ {STUDIOLIGHT_ORIENTATION_CAMERA, "CAMERA", 0, "Camera", ""},
+ {STUDIOLIGHT_ORIENTATION_WORLD, "WORLD", 0, "World", ""},
+ {STUDIOLIGHT_ORIENTATION_VIEWNORMAL, "MATCAP", 0, "MatCap", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ RNA_define_verify_sdna(false);
+ srna = RNA_def_struct(brna, "StudioLight", NULL);
+ RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
+ RNA_def_struct_ui_text(srna, "Studio Light", "Studio light");
+
+ prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
+ RNA_def_property_int_funcs(prop, "rna_UserDef_studiolight_index_get", NULL, NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Index", "");
+
+ prop = RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_UserDef_studiolight_is_user_defined_get", NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "User Defined", "");
+
+ prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_UserDef_studiolight_show_expanded_get", "rna_UserDef_studiolight_show_expanded_set");
+ RNA_def_property_ui_text(prop, "Show Expanded", "");
+
+ prop = RNA_def_property(srna, "orientation", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, rna_enum_studio_light_orientation_items);
+ RNA_def_property_enum_funcs(prop, "rna_UserDef_studiolight_orientation_get", "rna_UserDef_studiolight_orientation_set", NULL);
+ RNA_def_property_ui_text(prop, "Orientation", "");
+
+ prop = RNA_def_property(srna, "icon_id", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_funcs(prop, "rna_UserDef_studiolight_icon_id_get", NULL, "rna_UserDef_studiolight_icon_id_itemf");
+ RNA_def_property_enum_items(prop, rna_enum_studio_light_icons_id_items);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Preview", "Preview of the studiolight");
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_funcs(prop, "rna_UserDef_studiolight_name_get", "rna_UserDef_studiolight_name_length", NULL);
+ RNA_def_property_ui_text(prop, "Name", "");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_struct_name_property(srna, prop);
+
+ prop = RNA_def_property(srna, "path", PROP_STRING, PROP_DIRPATH);
+ RNA_def_property_string_funcs(prop, "rna_UserDef_studiolight_path_get", "rna_UserDef_studiolight_path_length", NULL);
+ RNA_def_property_ui_text(prop, "Path", "");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ RNA_define_verify_sdna(true);
+
+}
+
static void rna_def_userdef_pathcompare(BlenderRNA *brna)
{
StructRNA *srna;
@@ -3201,14 +3380,14 @@ static void rna_def_userdef_addon_pref(BlenderRNA *brna)
static void rna_def_userdef_dothemes(BlenderRNA *brna)
{
-
+
rna_def_userdef_theme_ui_style(brna);
rna_def_userdef_theme_ui(brna);
rna_def_userdef_theme_space_generic(brna);
rna_def_userdef_theme_space_gradient(brna);
rna_def_userdef_theme_space_list_generic(brna);
-
+
rna_def_userdef_theme_space_view3d(brna);
rna_def_userdef_theme_space_graph(brna);
rna_def_userdef_theme_space_file(brna);
@@ -3240,7 +3419,7 @@ static void rna_def_userdef_solidlight(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "SolidLight");
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
RNA_def_struct_ui_text(srna, "Solid Light", "Light used for OpenGL lighting in solid draw mode");
-
+
prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", 1);
RNA_def_property_ui_text(prop, "Enabled", "Enable this OpenGL light in solid draw mode");
@@ -3345,7 +3524,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
PropertyRNA *prop;
StructRNA *srna;
-
+
srna = RNA_def_struct(brna, "UserPreferencesView", NULL);
RNA_def_struct_sdna(srna, "UserDef");
RNA_def_struct_nested(brna, srna, "UserPreferences");
@@ -3417,7 +3596,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_MENUOPENAUTO);
RNA_def_property_ui_text(prop, "Open On Mouse Over",
"Open menu buttons and pulldowns automatically when the mouse is hovering");
-
+
prop = RNA_def_property(srna, "open_toplevel_delay", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "menuthreshold1");
RNA_def_property_range(prop, 1, 40);
@@ -3521,7 +3700,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_rotate_around_active", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ORBIT_SELECTION);
RNA_def_property_ui_text(prop, "Rotate Around Selection", "Use selection as the pivot point");
-
+
/* mini axis */
prop = RNA_def_property(srna, "show_mini_axis", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_SHOW_ROTVIEWICON);
@@ -3561,7 +3740,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "manipulator_flag", USER_MANIPULATOR_DRAW_NAVIGATE);
RNA_def_property_ui_text(prop, "Navigate Manipulator", "Use 3D navigation manipulator");
RNA_def_property_update(prop, 0, "rna_userdef_show_manipulator_update");
-
+
/* TODO, expose once it's working. */
#if 0
prop = RNA_def_property(srna, "show_manipulator_shaded", PROP_BOOLEAN, PROP_NONE);
@@ -3582,7 +3761,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
RNA_def_property_range(prop, 4, 10);
RNA_def_property_ui_text(prop, "Object Origin Size", "Diameter in Pixels for Object/Lamp origin display");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
/* View2D Grid Displays */
prop = RNA_def_property(srna, "view2d_grid_spacing_min", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "v2d_min_gridsize");
@@ -3590,7 +3769,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "2D View Minimum Grid Spacing",
"Minimum number of pixels between each gridline in 2D Viewports");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
/* TODO: add a setter for this, so that we can bump up the minimum size as necessary... */
prop = RNA_def_property(srna, "timecode_style", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, timecode_styles);
@@ -3627,14 +3806,14 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
{AUTOKEY_MODE_EDITKEYS, "REPLACE_KEYS", 0, "Replace", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem material_link_items[] = {
{0, "OBDATA", 0, "ObData", "Toggle whether the material is linked to object data or the object block"},
{USER_MAT_ON_OB, "OBJECT", 0, "Object",
"Toggle whether the material is linked to object data or the object block"},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem object_align_items[] = {
{0, "WORLD", 0, "World", "Align newly added objects to the world coordinate system"},
{USER_ADD_VIEWALIGNED, "VIEW", 0, "View", "Align newly added objects facing the active 3D View direction"},
@@ -3646,15 +3825,15 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
RNA_def_struct_nested(brna, srna, "UserPreferences");
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
RNA_def_struct_ui_text(srna, "Edit Methods", "Settings for interacting with Blender data");
-
+
/* Edit Methods */
-
+
prop = RNA_def_property(srna, "material_link", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, material_link_items);
RNA_def_property_ui_text(prop, "Material Link To",
"Toggle whether the material is linked to object data or the object block");
-
+
prop = RNA_def_property(srna, "object_align", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, object_align_items);
@@ -3670,7 +3849,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_RELEASECONFIRM);
RNA_def_property_ui_text(prop, "Release confirms",
"Moving things with a mouse drag confirms when releasing the button");
-
+
/* Undo */
prop = RNA_def_property(srna, "undo_steps", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "undosteps");
@@ -3713,7 +3892,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
RNA_def_property_boolean_negative_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_NOWARNING);
RNA_def_property_ui_text(prop, "Show Auto Keying Warning",
"Show warning indicators when transforming objects and bones if auto keying is enabled");
-
+
/* keyframing settings */
prop = RNA_def_property(srna, "use_keyframe_insert_needed", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_INSERTNEEDED);
@@ -3722,13 +3901,13 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_visual_keying", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_AUTOMATKEY);
RNA_def_property_ui_text(prop, "Visual Keying", "Use Visual keying automatically for constrained objects");
-
+
prop = RNA_def_property(srna, "use_insertkey_xyz_to_rgb", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_XYZ2RGB);
RNA_def_property_ui_text(prop, "New F-Curve Colors - XYZ to RGB",
"Color for newly added transformation F-Curves (Location, Rotation, Scale) "
"and also Color is based on the transform axis");
-
+
prop = RNA_def_property(srna, "keyframe_new_interpolation_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_beztriple_interpolation_mode_items);
RNA_def_property_enum_sdna(prop, NULL, "ipo_new");
@@ -3740,7 +3919,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
RNA_def_property_enum_items(prop, rna_enum_keyframe_handle_type_items);
RNA_def_property_enum_sdna(prop, NULL, "keyhandles_new");
RNA_def_property_ui_text(prop, "New Handles Type", "Handle type for handles of new keyframes");
-
+
/* frame numbers */
prop = RNA_def_property(srna, "use_negative_frames", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_NONEGFRAMES);
@@ -3754,7 +3933,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Unselected F-Curve Visibility",
"Amount that unselected F-Curves stand out from the background (Graph Editor)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
-
+
/* grease pencil */
prop = RNA_def_property(srna, "grease_pencil_manhattan_distance", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "gp_manhattendist");
@@ -3776,13 +3955,13 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "gp_eraser");
RNA_def_property_range(prop, 1, 500);
RNA_def_property_ui_text(prop, "Grease Pencil Eraser Radius", "Radius of eraser 'brush'");
-
-
+
+
prop = RNA_def_property(srna, "grease_pencil_default_color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "gpencil_new_layer_col");
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Grease Pencil Default Color", "Color of new Grease Pencil layers");
-
+
/* sculpt and paint */
prop = RNA_def_property(srna, "sculpt_paint_overlay_color", PROP_FLOAT, PROP_COLOR_GAMMA);
@@ -3798,7 +3977,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_duplicate_surface", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_SURF);
RNA_def_property_ui_text(prop, "Duplicate Surface", "Causes surface data to be duplicated with the object");
-
+
prop = RNA_def_property(srna, "use_duplicate_curve", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_CURVE);
RNA_def_property_ui_text(prop, "Duplicate Curve", "Causes curve data to be duplicated with the object");
@@ -3810,7 +3989,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_duplicate_metaball", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_MBALL);
RNA_def_property_ui_text(prop, "Duplicate Metaball", "Causes metaball data to be duplicated with the object");
-
+
prop = RNA_def_property(srna, "use_duplicate_armature", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_ARM);
RNA_def_property_ui_text(prop, "Duplicate Armature", "Causes armature data to be duplicated with the object");
@@ -3826,7 +4005,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_duplicate_texture", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_TEX);
RNA_def_property_ui_text(prop, "Duplicate Texture", "Causes texture data to be duplicated with the object");
-
+
/* xxx */
prop = RNA_def_property(srna, "use_duplicate_fcurve", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_IPO);
@@ -3835,7 +4014,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_duplicate_action", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_ACT);
RNA_def_property_ui_text(prop, "Duplicate Action", "Causes actions to be duplicated with the object");
-
+
prop = RNA_def_property(srna, "use_duplicate_particle", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_PSYS);
RNA_def_property_ui_text(prop, "Duplicate Particle", "Causes particle systems to be duplicated with the object");
@@ -3926,7 +4105,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
{USER_CP_SQUARE_HV, "SQUARE_HV", 0, "Square (HV + S)", "A square showing Hue/Value, with Saturation slider"},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem multi_sample_levels[] = {
{USER_MULTISAMPLE_NONE, "NONE", 0, "No MultiSample", "Do not use OpenGL MultiSample"},
{USER_MULTISAMPLE_2, "2", 0, "MultiSample: 2", "Use 2x OpenGL MultiSample (requires restart)"},
@@ -3957,7 +4136,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "System & OpenGL", "Graphics driver and operating system settings");
/* Language */
-
+
prop = RNA_def_property(srna, "use_international_fonts", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "transopts", USER_DOTRANSLATE);
RNA_def_property_ui_text(prop, "International Fonts", "Use international fonts");
@@ -4057,7 +4236,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "color_picker_type");
RNA_def_property_ui_text(prop, "Color Picker Type", "Different styles of displaying the color picker widget");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
+
prop = RNA_def_property(srna, "use_preview_images", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ALLWINCODECS);
RNA_def_property_ui_text(prop, "Enable All Codecs",
@@ -4117,7 +4296,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
"Quality of the anisotropic filtering (values greater than 1.0 enable anisotropic "
"filtering)");
RNA_def_property_update(prop, 0, "rna_userdef_anisotropic_update");
-
+
prop = RNA_def_property(srna, "gl_texture_limit", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "glreslimit");
RNA_def_property_enum_items(prop, gl_texture_clamp_items);
@@ -4206,7 +4385,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "uiflag2", USER_REGION_OVERLAP);
RNA_def_property_ui_text(prop, "Region Overlap",
"Draw tool/property regions over the main region, when using Triple Buffer");
- RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
+ RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
#ifdef WITH_OPENSUBDIV
prop = RNA_def_property(srna, "opensubdiv_compute_type", PROP_ENUM, PROP_NONE);
@@ -4265,44 +4444,44 @@ static void rna_def_userdef_input(BlenderRNA *brna)
"Zoom in and out like scaling the view, mouse movements relative to center"},
{0, NULL, 0, NULL, NULL}
};
-
+
static const EnumPropertyItem view_zoom_axes[] = {
{0, "VERTICAL", 0, "Vertical", "Zoom in and out based on vertical mouse movement"},
{USER_ZOOM_HORIZ, "HORIZONTAL", 0, "Horizontal", "Zoom in and out based on horizontal mouse movement"},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "UserPreferencesInput", NULL);
RNA_def_struct_sdna(srna, "UserDef");
RNA_def_struct_nested(brna, srna, "UserPreferences");
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
RNA_def_struct_ui_text(srna, "Input", "Settings for input devices");
-
+
prop = RNA_def_property(srna, "select_mouse", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, select_mouse_items);
RNA_def_property_enum_funcs(prop, NULL, "rna_userdef_select_mouse_set", NULL);
RNA_def_property_ui_text(prop, "Select Mouse", "Mouse button used for selection");
-
+
prop = RNA_def_property(srna, "view_zoom_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "viewzoom");
RNA_def_property_enum_items(prop, view_zoom_styles);
RNA_def_property_ui_text(prop, "Zoom Style", "Which style to use for viewport scaling");
-
+
prop = RNA_def_property(srna, "view_zoom_axis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "uiflag");
RNA_def_property_enum_items(prop, view_zoom_axes);
RNA_def_property_ui_text(prop, "Zoom Axis", "Axis of mouse movement to zoom in or out on");
-
+
prop = RNA_def_property(srna, "invert_mouse_zoom", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ZOOM_INVERT);
RNA_def_property_ui_text(prop, "Invert Zoom Direction", "Invert the axis of mouse movement for zooming");
-
+
prop = RNA_def_property(srna, "view_rotate_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, view_rotation_items);
RNA_def_property_ui_text(prop, "View Rotation", "Rotation style in the viewport");
-
+
prop = RNA_def_property(srna, "use_mouse_continuous", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_CONTINUOUS_MOUSE);
RNA_def_property_ui_text(prop, "Continuous Grab",
@@ -4340,7 +4519,7 @@ static void rna_def_userdef_input(BlenderRNA *brna)
prop = RNA_def_property(srna, "ndof_sensitivity", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.01f, 40.0f);
RNA_def_property_ui_text(prop, "Sensitivity", "Overall sensitivity of the 3D Mouse for panning");
-
+
prop = RNA_def_property(srna, "ndof_orbit_sensitivity", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.01f, 40.0f);
RNA_def_property_ui_text(prop, "Orbit Sensitivity", "Overall sensitivity of the 3D Mouse for orbiting");
@@ -4364,7 +4543,7 @@ static void rna_def_userdef_input(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_SHOW_GUIDE);
RNA_def_property_ui_text(prop, "Show Navigation Guide", "Display the center and axis during rotation");
/* TODO: update description when fly-mode visuals are in place ("projected position in fly mode")*/
-
+
/* 3D view */
prop = RNA_def_property(srna, "ndof_view_navigate_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "ndof_flag");
@@ -4436,13 +4615,13 @@ static void rna_def_userdef_input(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_emulate_numpad", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_NONUMPAD);
RNA_def_property_ui_text(prop, "Emulate Numpad", "Main 1 to 0 keys act as the numpad ones (useful for laptops)");
-
+
/* middle mouse button */
prop = RNA_def_property(srna, "use_mouse_mmb_paste", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_MMB_PASTE);
RNA_def_property_ui_text(prop, "Middle Mouse Paste",
"In text window, paste with middle mouse button instead of panning");
-
+
prop = RNA_def_property(srna, "invert_zoom_wheel", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_WHEELZOOMDIR);
RNA_def_property_ui_text(prop, "Wheel Invert Zoom", "Swap the Mouse Wheel zoom direction");
@@ -4451,7 +4630,7 @@ static void rna_def_userdef_input(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "wheellinescroll");
RNA_def_property_range(prop, 0, 32);
RNA_def_property_ui_text(prop, "Wheel Scroll Lines", "Number of lines scrolled at a time with the mouse wheel");
-
+
prop = RNA_def_property(srna, "use_trackpad_natural", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag2", USER_TRACKPAD_NATURAL);
RNA_def_property_ui_text(prop, "Trackpad Natural",
@@ -4466,7 +4645,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
{
PropertyRNA *prop;
StructRNA *srna;
-
+
static const EnumPropertyItem anim_player_presets[] = {
{0, "INTERNAL", 0, "Internal", "Built-in animation player"},
{2, "DJV", 0, "Djv", "Open source frame player: http://djv.sourceforge.net"},
@@ -4476,22 +4655,22 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
{50, "CUSTOM", 0, "Custom", "Custom animation player executable path"},
{0, NULL, 0, NULL, NULL}
};
-
+
srna = RNA_def_struct(brna, "UserPreferencesFilePaths", NULL);
RNA_def_struct_sdna(srna, "UserDef");
RNA_def_struct_nested(brna, srna, "UserPreferences");
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
RNA_def_struct_ui_text(srna, "File Paths", "Default paths for external files");
-
+
prop = RNA_def_property(srna, "show_hidden_files_datablocks", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_HIDE_DOT);
RNA_def_property_ui_text(prop, "Hide Dot Files/Data-Blocks", "Hide files/data-blocks that start with a dot (.*)");
-
+
prop = RNA_def_property(srna, "use_filter_files", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_FILTERFILEEXTS);
RNA_def_property_ui_text(prop, "Filter File Extensions",
"Display only files with extensions in the image select window");
-
+
prop = RNA_def_property(srna, "hide_recent_locations", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_HIDE_RECENT);
RNA_def_property_ui_text(prop, "Hide Recent Locations", "Hide recent locations in the file selector");
@@ -4507,7 +4686,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_relative_paths", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_RELPATHS);
RNA_def_property_ui_text(prop, "Relative Paths", "Default relative path option for the file selector");
-
+
prop = RNA_def_property(srna, "use_file_compression", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_FILECOMPRESS);
RNA_def_property_ui_text(prop, "Compress File", "Enable file compression when saving .blend files");
@@ -4559,7 +4738,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
prop = RNA_def_property(srna, "image_editor", PROP_STRING, PROP_FILEPATH);
RNA_def_property_string_sdna(prop, NULL, "image_editor");
RNA_def_property_ui_text(prop, "Image Editor", "Path to an image editor");
-
+
prop = RNA_def_property(srna, "animation_player", PROP_STRING, PROP_FILEPATH);
RNA_def_property_string_sdna(prop, NULL, "anim_player");
RNA_def_property_ui_text(prop, "Animation Player", "Path to a custom animation/frame sequence player");
@@ -4568,7 +4747,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "anim_player_preset");
RNA_def_property_enum_items(prop, anim_player_presets);
RNA_def_property_ui_text(prop, "Animation Player Preset", "Preset configs for external animation players");
-
+
/* Autosave */
prop = RNA_def_property(srna, "save_version", PROP_INT, PROP_NONE);
@@ -4594,7 +4773,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "uiflag2", USER_KEEP_SESSION);
RNA_def_property_ui_text(prop, "Keep Session",
"Always load session recovery and save it after quitting Blender");
-
+
prop = RNA_def_property(srna, "recent_files", PROP_INT, PROP_NONE);
RNA_def_property_range(prop, 0, 30);
RNA_def_property_ui_text(prop, "Recent Files", "Maximum number of recently opened files to remember");
@@ -4661,6 +4840,7 @@ void RNA_def_userdef(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
+ FunctionRNA *func;
static const EnumPropertyItem user_pref_sections[] = {
{USER_SECTION_INTERFACE, "INTERFACE", 0, "Interface", ""},
@@ -4668,6 +4848,7 @@ void RNA_def_userdef(BlenderRNA *brna)
{USER_SECTION_INPUT, "INPUT", 0, "Input", ""},
{USER_SECTION_ADDONS, "ADDONS", 0, "Add-ons", ""},
{USER_SECTION_THEME, "THEMES", 0, "Themes", ""},
+ {USER_SECTION_LIGHT, "LIGHTS", 0, "Lights", ""},
{USER_SECTION_FILE, "FILES", 0, "File", ""},
{USER_SECTION_SYSTEM, "SYSTEM", 0, "System", ""},
{0, NULL, 0, NULL, NULL}
@@ -4703,7 +4884,7 @@ void RNA_def_userdef(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "uistyles", NULL);
RNA_def_property_struct_type(prop, "ThemeStyle");
RNA_def_property_ui_text(prop, "Styles", "");
-
+
prop = RNA_def_property(srna, "addons", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "addons", NULL);
RNA_def_property_struct_type(prop, "Addon");
@@ -4728,31 +4909,43 @@ void RNA_def_userdef(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "UserPreferencesEdit");
RNA_def_property_pointer_funcs(prop, "rna_UserDef_edit_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Edit Methods", "Settings for interacting with Blender data");
-
+
prop = RNA_def_property(srna, "inputs", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "UserPreferencesInput");
RNA_def_property_pointer_funcs(prop, "rna_UserDef_input_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Inputs", "Settings for input devices");
-
+
prop = RNA_def_property(srna, "filepaths", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "UserPreferencesFilePaths");
RNA_def_property_pointer_funcs(prop, "rna_UserDef_filepaths_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "File Paths", "Default paths for external files");
-
+
prop = RNA_def_property(srna, "system", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "UserPreferencesSystem");
RNA_def_property_pointer_funcs(prop, "rna_UserDef_system_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "System & OpenGL", "Graphics driver and operating system settings");
-
+
prop = RNA_def_int_vector(srna, "version", 3, NULL, 0, INT_MAX,
"Version", "Version of Blender the userpref.blend was saved with", 0, INT_MAX);
RNA_def_property_int_funcs(prop, "rna_userdef_version_get", NULL, NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_THICK_WRAP);
+ prop = RNA_def_property(srna, "studio_lights", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_struct_type(prop, "StudioLight");
+ RNA_def_property_collection_funcs(
+ prop, "rna_UserDef_studiolight_begin", "rna_iterator_listbase_next",
+ "rna_iterator_listbase_end", "rna_iterator_listbase_get",
+ NULL, NULL, NULL, NULL);
+
+ func = RNA_def_function(srna, "studio_lights_refresh", "rna_UserDef_studiolight_refresh");
+ RNA_def_function_ui_description(func, "Refresh Studio Lights");
+
+ RNA_def_property_ui_text(prop, "Studio Lights", "");
+
rna_def_userdef_view(brna);
rna_def_userdef_edit(brna);
rna_def_userdef_input(brna);
@@ -4760,8 +4953,9 @@ void RNA_def_userdef(BlenderRNA *brna)
rna_def_userdef_system(brna);
rna_def_userdef_addon(brna);
rna_def_userdef_addon_pref(brna);
+ rna_def_userdef_studiolight(brna);
rna_def_userdef_pathcompare(brna);
-
+
}
#endif
diff --git a/source/blender/makesrna/intern/rna_vfont.c b/source/blender/makesrna/intern/rna_vfont.c
index 78d46d35246..487b5220c86 100644
--- a/source/blender/makesrna/intern/rna_vfont.c
+++ b/source/blender/makesrna/intern/rna_vfont.c
@@ -70,7 +70,7 @@ void RNA_def_vfont(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "VectorFont", "ID");
RNA_def_struct_ui_text(srna, "Vector Font", "Vector font for Text objects");
RNA_def_struct_sdna(srna, "VFont");
diff --git a/source/blender/makesrna/intern/rna_vfont_api.c b/source/blender/makesrna/intern/rna_vfont_api.c
index 6a2a7f3ffad..b93fc1a0053 100644
--- a/source/blender/makesrna/intern/rna_vfont_api.c
+++ b/source/blender/makesrna/intern/rna_vfont_api.c
@@ -43,14 +43,14 @@ static void rna_VectorFont_pack(VFont *vfont, Main *bmain, ReportList *reports)
vfont->packedfile = newPackedFile(reports, vfont->name, ID_BLEND_PATH(bmain, &vfont->id));
}
-static void rna_VectorFont_unpack(VFont *vfont, ReportList *reports, int method)
+static void rna_VectorFont_unpack(VFont *vfont, Main *bmain, ReportList *reports, int method)
{
if (!vfont->packedfile) {
BKE_report(reports, RPT_ERROR, "Font not packed");
}
else {
/* reports its own error on failure */
- unpackVFont(reports, vfont, method);
+ unpackVFont(bmain, reports, vfont, method);
}
}
@@ -62,11 +62,11 @@ void RNA_api_vfont(StructRNA *srna)
func = RNA_def_function(srna, "pack", "rna_VectorFont_pack");
RNA_def_function_ui_description(func, "Pack the font into the current blend file");
- RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_MAIN);
+ RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
func = RNA_def_function(srna, "unpack", "rna_VectorFont_unpack");
RNA_def_function_ui_description(func, "Unpack the font to the samples filename");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
RNA_def_enum(func, "method", rna_enum_unpack_method_items, PF_USE_LOCAL, "method", "How to unpack");
}
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 0fa7f53da9b..c4e15174c88 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -53,6 +53,7 @@ static const EnumPropertyItem event_keymouse_value_items[] = {
{KM_RELEASE, "RELEASE", 0, "Release", ""},
{KM_CLICK, "CLICK", 0, "Click", ""},
{KM_DBL_CLICK, "DOUBLE_CLICK", 0, "Double Click", ""},
+ {KM_CLICK_DRAG, "CLICK_DRAG", 0, "Click Drag", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -391,6 +392,7 @@ const EnumPropertyItem rna_enum_event_value_items[] = {
{KM_RELEASE, "RELEASE", 0, "Release", ""},
{KM_CLICK, "CLICK", 0, "Click", ""},
{KM_DBL_CLICK, "DOUBLE_CLICK", 0, "Double Click", ""},
+ {KM_CLICK_DRAG, "CLICK_DRAG", 0, "Click Drag", ""},
{EVT_GESTURE_N, "NORTH", 0, "North", ""},
{EVT_GESTURE_NE, "NORTH_EAST", 0, "North-East", ""},
{EVT_GESTURE_E, "EAST", 0, "East", ""},
@@ -498,7 +500,7 @@ static wmOperator *rna_OperatorProperties_find_operator(PointerRNA *ptr)
}
}
}
-
+
return NULL;
}
@@ -794,7 +796,7 @@ static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr)
if (kmi->ptr)
return *(kmi->ptr);
-
+
/*return rna_pointer_inherit_refine(ptr, &RNA_OperatorProperties, op->properties); */
return PointerRNA_NULL;
}
@@ -846,7 +848,7 @@ static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value)
static void rna_wmKeyMapItem_keymodifier_set(PointerRNA *ptr, int value)
{
wmKeyMapItem *kmi = ptr->data;
-
+
/* XXX, this should really be managed in an _itemf function,
* giving a list of valid enums, then silently changing them when they are set is not
* a good precedent, don't do this unless you have a good reason! */
@@ -974,7 +976,7 @@ static PointerRNA rna_WindowManager_active_keyconfig_get(PointerRNA *ptr)
if (!kc)
kc = wm->defaultconf;
-
+
return rna_pointer_inherit_refine(ptr, &RNA_KeyConfig, kc);
}
@@ -1609,13 +1611,13 @@ static void rna_def_operator(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "OperatorProperties");
RNA_def_property_ui_text(prop, "Properties", "");
RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL, NULL);
-
+
prop = RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */
RNA_def_property_boolean_funcs(prop, "rna_Operator_has_reports_get", NULL);
RNA_def_property_ui_text(prop, "Has Reports",
"Operator has a set of reports (warnings and errors) from last execution");
-
+
prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "UILayout");
@@ -1817,12 +1819,12 @@ static void rna_def_operator_filelist_element(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_IDPROPERTY);
RNA_def_property_ui_text(prop, "Name", "Name of a file or directory within a file list");
}
-
+
static void rna_def_event(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
srna = RNA_def_struct(brna, "Event", NULL);
RNA_def_struct_ui_text(srna, "Event", "Window Manager Event");
RNA_def_struct_sdna(srna, "wmEvent");
@@ -1847,7 +1849,7 @@ static void rna_def_event(BlenderRNA *brna)
RNA_def_property_enum_items(prop, rna_enum_event_value_items);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Value", "The type of event, only applies to some");
-
+
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, rna_enum_event_type_items);
@@ -1861,7 +1863,7 @@ static void rna_def_event(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "x");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Mouse X Position", "The window relative horizontal location of the mouse");
-
+
prop = RNA_def_property(srna, "mouse_y", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "y");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -1876,12 +1878,12 @@ static void rna_def_event(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "mval[1]");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Mouse Y Position", "The region relative vertical location of the mouse");
-
+
prop = RNA_def_property(srna, "mouse_prev_x", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "prevx");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Mouse Previous X Position", "The window relative horizontal location of the mouse");
-
+
prop = RNA_def_property(srna, "mouse_prev_y", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "prevy");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -1913,17 +1915,17 @@ static void rna_def_event(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "shift", 1);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Shift", "True when the Shift key is held");
-
+
prop = RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 1);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Ctrl", "True when the Ctrl key is held");
-
+
prop = RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "alt", 1);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Alt", "True when the Alt/Option key is held");
-
+
prop = RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "oskey", 1);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -2117,7 +2119,7 @@ static void rna_def_wm_keyconfigs(BlenderRNA *brna, PropertyRNA *cprop)
"rna_WindowManager_active_keyconfig_set", NULL, NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Active KeyConfig", "Active key configuration (preset)");
-
+
prop = RNA_def_property(srna, "default", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, NULL, "defaultconf");
RNA_def_property_struct_type(prop, "KeyConfig");
@@ -2136,7 +2138,7 @@ static void rna_def_wm_keyconfigs(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_ui_text(prop, "User Key Configuration",
"Final key configuration that combines keymaps from the active and add-on configurations, "
"and can be edited by the user");
-
+
RNA_api_keyconfigs(srna);
}
@@ -2175,7 +2177,7 @@ static void rna_def_windowmanager(BlenderRNA *brna)
static void rna_def_keymap_items(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
-
+
RNA_def_property_srna(cprop, "KeyMapItems");
srna = RNA_def_struct(brna, "KeyMapItems", NULL);
RNA_def_struct_sdna(srna, "wmKeyMap");
@@ -2280,7 +2282,7 @@ static void rna_def_keyconfig(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_EXPANDED);
RNA_def_property_ui_text(prop, "Items Expanded", "Expanded in the user interface");
RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
-
+
prop = RNA_def_property(srna, "show_expanded_children", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_CHILDREN_EXPANDED);
RNA_def_property_ui_text(prop, "Children Expanded", "Children expanded in the user interface");
@@ -2308,7 +2310,7 @@ static void rna_def_keyconfig(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Name", "Name of operator (translated) to call on input event");
RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_name_get", "rna_wmKeyMapItem_name_length", NULL);
-
+
prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "OperatorProperties");
RNA_def_property_pointer_funcs(prop, "rna_KeyMapItem_properties_get", NULL, NULL, NULL);
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index ab534159a9e..aff696696af 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -98,7 +98,7 @@ static int rna_Operator_is_repeat(wmOperator *op, bContext *C)
static void rna_Operator_enum_search_invoke(bContext *C, wmOperator *op)
{
WM_enum_search_invoke(C, op, NULL);
-
+
}
static int rna_event_modal_handler_add(struct bContext *C, struct wmOperator *operator)
@@ -202,8 +202,9 @@ static int rna_Operator_props_popup(bContext *C, wmOperator *op, wmEvent *event)
return WM_operator_props_popup(C, op, event);
}
-static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km, ReportList *reports, const char *idname, int type, int value,
- int any, int shift, int ctrl, int alt, int oskey, int keymodifier, int head)
+static wmKeyMapItem *rna_KeyMap_item_new(
+ wmKeyMap *km, ReportList *reports, const char *idname, int type, int value,
+ int any, int shift, int ctrl, int alt, int oskey, int keymodifier, int head)
{
/* wmWindowManager *wm = CTX_wm_manager(C); */
wmKeyMapItem *kmi = NULL;
@@ -224,24 +225,25 @@ static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km, ReportList *reports, cons
if (oskey) modifier |= KM_OSKEY;
if (any) modifier = KM_ANY;
-
+
/* create keymap item */
kmi = WM_keymap_add_item(km, idname_bl, type, value, modifier, keymodifier);
-
- /* [#32437] allow scripts to define hotkeys that get added to start of keymap
+
+ /* [#32437] allow scripts to define hotkeys that get added to start of keymap
* so that they stand a chance against catch-all defines later on
*/
if (head) {
BLI_remlink(&km->items, kmi);
BLI_addhead(&km->items, kmi);
}
-
+
return kmi;
}
-static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km, ReportList *reports, const char *propvalue_str,
- int type, int value, int any, int shift, int ctrl, int alt,
- int oskey, int keymodifier)
+static wmKeyMapItem *rna_KeyMap_item_new_modal(
+ wmKeyMap *km, ReportList *reports, const char *propvalue_str,
+ int type, int value, int any, int shift, int ctrl, int alt,
+ int oskey, int keymodifier)
{
int modifier = 0;
int propvalue = 0;
@@ -694,7 +696,7 @@ void RNA_api_operator(StructRNA *srna)
parm = RNA_def_boolean(func, "result", 0, "result", ""); /* better name? */
RNA_def_function_return(func, parm);
-
+
/* invoke */
func = RNA_def_function(srna, "invoke", NULL);
RNA_def_function_ui_description(func, "Invoke the operator");
@@ -822,7 +824,7 @@ void RNA_api_keymapitems(StructRNA *srna)
RNA_def_boolean(func, "alt", 0, "Alt", "");
RNA_def_boolean(func, "oskey", 0, "OS Key", "");
RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
- RNA_def_boolean(func, "head", 0, "At Head",
+ RNA_def_boolean(func, "head", 0, "At Head",
"Force item to be added at start (not end) of key map so that "
"it doesn't get blocked by an existing key map item");
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item");
@@ -844,7 +846,7 @@ void RNA_api_keymapitems(StructRNA *srna)
RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item");
RNA_def_function_return(func, parm);
-
+
func = RNA_def_function(srna, "remove", "rna_KeyMap_item_remove");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c
index bb40a12f5d5..4ae1e107e28 100644
--- a/source/blender/makesrna/intern/rna_wm_manipulator.c
+++ b/source/blender/makesrna/intern/rna_wm_manipulator.c
@@ -74,6 +74,7 @@
/** \name Manipulator API
* \{ */
+#ifdef WITH_PYTHON
static void rna_manipulator_draw_cb(
const struct bContext *C, struct wmManipulator *mpr)
{
@@ -238,6 +239,8 @@ static void rna_manipulator_select_refresh_cb(
RNA_parameter_list_free(&list);
}
+#endif /* WITH_PYTHON */
+
/* just to work around 'const char *' warning and to ensure this is a python op */
static void rna_Manipulator_bl_idname_set(PointerRNA *ptr, const char *value)
{
diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index af9a200c3b9..041b2b9157f 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -146,6 +146,12 @@ const EnumPropertyItem *rna_WorkSpace_tools_mode_itemf(
return DummyRNA_DEFAULT_items;
}
+static int rna_WorkspaceTool_index_get(PointerRNA *ptr)
+{
+ bToolRef *tref = ptr->data;
+ return (tref->runtime) ? tref->runtime->index : 0;
+}
+
#else /* RNA_RUNTIME */
static void rna_def_workspace_owner(BlenderRNA *brna)
@@ -213,6 +219,11 @@ static void rna_def_workspace_tool(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Name", "");
RNA_def_struct_name_property(srna, prop);
+ prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Index", "");
+ RNA_def_property_int_funcs(prop, "rna_WorkspaceTool_index_get", NULL, NULL);
+
RNA_api_workspace_tool(srna);
}
diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c
index 92fbbd61898..ead67814f01 100644
--- a/source/blender/makesrna/intern/rna_world.c
+++ b/source/blender/makesrna/intern/rna_world.c
@@ -143,7 +143,7 @@ static void rna_def_world_mist(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+
static const EnumPropertyItem falloff_items[] = {
{WO_MIST_QUADRATIC, "QUADRATIC", 0, "Quadratic", "Use quadratic progression"},
{WO_MIST_LINEAR, "LINEAR", 0, "Linear", "Use linear progression"},
@@ -186,7 +186,7 @@ static void rna_def_world_mist(BlenderRNA *brna)
RNA_def_property_range(prop, 0, 100);
RNA_def_property_ui_text(prop, "Height", "Control how much mist density decreases with height");
RNA_def_property_update(prop, 0, "rna_World_update");
-
+
prop = RNA_def_property(srna, "falloff", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "mistype");
RNA_def_property_enum_items(prop, falloff_items);
@@ -214,7 +214,7 @@ void RNA_def_world(BlenderRNA *brna)
/* RNA_def_property_update(prop, 0, "rna_World_update"); */
/* render-only uses this */
RNA_def_property_update(prop, 0, "rna_World_draw_update");
-
+
/* nested structs */
prop = RNA_def_property(srna, "light_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
diff --git a/source/blender/makesrna/rna_cleanup/rna_cleaner.py b/source/blender/makesrna/rna_cleanup/rna_cleaner.py
index 8b4b10c490e..0b80a711c3b 100755
--- a/source/blender/makesrna/rna_cleanup/rna_cleaner.py
+++ b/source/blender/makesrna/rna_cleanup/rna_cleaner.py
@@ -19,7 +19,7 @@ def font_bold(mystring):
font_bold = "\033[1m"
font_reset = "\033[0;0m"
return font_bold + mystring + font_reset
-
+
def usage():
"""
@@ -102,30 +102,30 @@ def get_props_from_txt(input_filename):
"""
If the file is *.txt, the script assumes it is formatted as outlined in this script docstring
"""
-
+
file=open(input_filename,'r')
file_lines=file.readlines()
file.close()
props_list=[]
props_length_max=[0,0,0,0,0,0,0,0]
-
+
done_text = "+"
done = 0
tot = 0
-
+
for iii, line in enumerate(file_lines):
-
+
# debug
#print(line)
line_strip = line.strip()
# empty line or comment
if not line_strip:
continue
-
+
if line_strip == "EOF":
break
-
+
if line.startswith("#"):
line = line[1:]
@@ -162,18 +162,18 @@ def get_props_from_txt(input_filename):
# changed
changed = check_if_changed(bfrom, bto)
-
+
# lists formatting
props=[comment, changed, bclass, bfrom, bto, kwcheck, btype, description]
props_list.append(props)
props_length_max=list(map(max,zip(props_length_max,list(map(len,props)))))
-
+
if done_text in comment:
done += 1
tot += 1
-
+
print("Total done %.2f" % (done / tot * 100.0) )
-
+
return (props_list,props_length_max)
@@ -181,7 +181,7 @@ def get_props_from_py(input_filename):
"""
If the file is *.py, the script assumes it contains a python list (as "rna_api=[...]")
This means that this script executes the text in the py file with an exec(text).
- """
+ """
# adds the list "rna_api" to this function's scope
rna_api = __import__(input_filename[:-3]).rna_api
@@ -205,7 +205,7 @@ def get_props(input_filename):
props_list,props_length_max = get_props_from_py(input_filename)
return (props_list,props_length_max)
-
+
def sort(props_list, sort_priority):
"""
reminder
@@ -221,7 +221,7 @@ def sort(props_list, sort_priority):
props_list = sorted(props_list, key=lambda p: p[i], reverse=True)
else:
props_list = sorted(props_list, key=lambda p: p[i])
-
+
print ('\nSorted by %s.' % font_bold(sort_priority))
return props_list
@@ -260,11 +260,11 @@ def write_files(basename, props_list, props_length_max):
props_list = [['NOTE', 'CHANGED', 'CLASS', 'FROM', 'TO', 'KEYWORD-CHECK', 'TYPE', 'DESCRIPTION']] + props_list
for props in props_list:
#txt
-
+
# quick way we can tell if it changed
if props[3] == props[4]: txt += "#"
else: txt += " "
-
+
if props[0] != '': txt += '%s * ' % props[0] # comment
txt += '%s.%s -> %s: %s "%s"\n' % tuple(props[2:5] + props[6:]) # skipping keyword-check
# rna_api
@@ -279,7 +279,7 @@ def write_files(basename, props_list, props_length_max):
f_txt.write(txt)
f_py.write("rna_api = [\n%s]\n" % py)
f_rna.write("rna_api = [\n%s]\n" % rna)
-
+
# write useful py script, wont hurt
f_py.write("\n'''\n")
f_py.write("for p_note, p_changed, p_class, p_from, p_to, p_check, p_type, p_desc in rna_api:\n")
diff --git a/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py b/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py
index 17ea5f9b0bd..a5d5cebcbb7 100755
--- a/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py
+++ b/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py
@@ -7,38 +7,38 @@ Example usage:
python3 rna_cleaner_merge.py out_work.py rna_booleans_work.py
'''
def main():
-
+
def work_line_id(line):
return line[2].split("|")[-1], line[3] # class/from
-
-
+
+
if not (sys.argv[-1].endswith(".py") and sys.argv[-2].endswith(".py")):
print("Only accepts 2 py files as arguments.")
-
+
sys.path.insert(0, ".")
mod_from = __import__(sys.argv[-1][:-3])
mod_to = __import__(sys.argv[-2][:-3])
-
+
mod_to_dict = dict([(work_line_id(line), line) for line in mod_to.rna_api])
mod_from_dict = dict([(work_line_id(line), line) for line in mod_from.rna_api])
-
+
rna_api_new = []
-
+
for key, val_orig in mod_to_dict.items():
try:
val_new = mod_from_dict.pop(key)
except:
# print("not found", key)
val_new = val_orig
-
+
# always take the class from the base
val = list(val_orig)
val[0] = val_new[0] # comment
val[4] = val_new[4] # -> to
val = tuple(val)
rna_api_new.append(val)
-
+
def write_work_file(file_path, rna_api):
rna_api = list(rna_api)
rna_api.sort(key=work_line_id)
@@ -51,7 +51,7 @@ def main():
file_path = sys.argv[-2][:-3] + "_merged.py"
write_work_file(file_path, rna_api_new)
-
+
if mod_from_dict:
file_path = sys.argv[-2][:-3] + "_lost.py"
write_work_file(file_path, list(mod_from_dict.values()))
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index e74d9087427..c1268157d58 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -49,6 +49,7 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_displist.h"
#include "BKE_curve.h"
+#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_modifier.h"
#include "BKE_mesh.h"
@@ -373,6 +374,7 @@ static Mesh *arrayModifier_doArray(
int first_chunk_start, first_chunk_nverts, last_chunk_start, last_chunk_nverts;
Mesh *result, *start_cap_mesh = NULL, *end_cap_mesh = NULL;
+ bool start_cap_mesh_free, end_cap_mesh_free;
int *vgroup_start_cap_remap = NULL;
int vgroup_start_cap_remap_len = 0;
@@ -390,7 +392,7 @@ static Mesh *arrayModifier_doArray(
vgroup_start_cap_remap = BKE_object_defgroup_index_map_create(
amd->start_cap, ctx->object, &vgroup_start_cap_remap_len);
- start_cap_mesh = BKE_modifier_get_evaluated_mesh_from_object(ctx, amd->start_cap);
+ start_cap_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(amd->start_cap, &start_cap_mesh_free);
if (start_cap_mesh) {
start_cap_nverts = start_cap_mesh->totvert;
start_cap_nedges = start_cap_mesh->totedge;
@@ -402,7 +404,7 @@ static Mesh *arrayModifier_doArray(
vgroup_end_cap_remap = BKE_object_defgroup_index_map_create(
amd->end_cap, ctx->object, &vgroup_end_cap_remap_len);
- end_cap_mesh = BKE_modifier_get_evaluated_mesh_from_object(ctx, amd->end_cap);
+ end_cap_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(amd->end_cap, &end_cap_mesh_free);
if (end_cap_mesh) {
end_cap_nverts = end_cap_mesh->totvert;
end_cap_nedges = end_cap_mesh->totedge;
@@ -737,6 +739,12 @@ static Mesh *arrayModifier_doArray(
if (vgroup_end_cap_remap) {
MEM_freeN(vgroup_end_cap_remap);
}
+ if (start_cap_mesh != NULL && start_cap_mesh_free) {
+ BKE_id_free(NULL, start_cap_mesh);
+ }
+ if (end_cap_mesh != NULL && end_cap_mesh_free) {
+ BKE_id_free(NULL, end_cap_mesh);
+ }
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index 73d1388d88f..f2c0baedc01 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -170,24 +170,27 @@ static int bm_face_isect_pair(BMFace *f, void *UNUSED(user_data))
static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
{
BooleanModifierData *bmd = (BooleanModifierData *) md;
+ Mesh *result;
+
Mesh *mesh_other;
+ bool mesh_other_free;
if (!bmd->object)
return mesh;
- mesh_other = BKE_modifier_get_evaluated_mesh_from_object(ctx, bmd->object);
+ Object *ob_eval = DEG_get_evaluated_object(ctx->depsgraph, bmd->object);
+ mesh_other = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_eval, &mesh_other_free);
if (mesh_other) {
- Mesh *result;
- Object *object_eval = DEG_get_evaluated_object(ctx->depsgraph, ctx->object);
- Object *other_eval = DEG_get_evaluated_object(ctx->depsgraph, bmd->object);
+ Object *object = ctx->object;
+ Object *other = bmd->object;
/* when one of objects is empty (has got no faces) we could speed up
* calculation a bit returning one of objects' derived meshes (or empty one)
* Returning mesh is depended on modifiers operation (sergey) */
- result = get_quick_mesh(object_eval, mesh, other_eval, mesh_other, bmd->operation);
+ result = get_quick_mesh(object, mesh, other, mesh_other, bmd->operation);
if (result == NULL) {
- const bool is_flip = (is_negative_m4(object_eval->obmat) != is_negative_m4(other_eval->obmat));
+ const bool is_flip = (is_negative_m4(object->obmat) != is_negative_m4(other->obmat));
BMesh *bm;
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh, mesh_other);
@@ -234,8 +237,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
float imat[4][4];
float omat[4][4];
- invert_m4_m4(imat, object_eval->obmat);
- mul_m4_m4m4(omat, imat, other_eval->obmat);
+ invert_m4_m4(imat, object->obmat);
+ mul_m4_m4m4(omat, imat, other->obmat);
BMVert *eve;
i = 0;
@@ -257,11 +260,11 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
negate_m3(nmat);
}
- const short ob_src_totcol = other_eval->totcol;
+ const short ob_src_totcol = other->totcol;
short *material_remap = BLI_array_alloca(material_remap, ob_src_totcol ? ob_src_totcol : 1);
/* Using original (not evaluated) object here since we are writing to it. */
- BKE_material_remap_object_calc(ctx->object, other_eval, material_remap);
+ BKE_material_remap_object_calc(ctx->object, other, material_remap);
BMFace *efa;
i = 0;
@@ -321,19 +324,19 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
#ifdef DEBUG_TIME
TIMEIT_END(boolean_bmesh);
#endif
-
- return result;
}
/* if new mesh returned, return it; otherwise there was
* an error, so delete the modifier object */
- if (result)
- return result;
- else
+ if (result == NULL)
modifier_setError(md, "Cannot execute boolean operation");
}
- return mesh;
+ if (mesh_other != NULL && mesh_other_free) {
+ BKE_id_free(NULL, mesh_other);
+ }
+
+ return result;
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md))
diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c
index 036954a2774..71022f8a4ab 100644
--- a/source/blender/modifiers/intern/MOD_collision.c
+++ b/source/blender/modifiers/intern/MOD_collision.c
@@ -45,6 +45,7 @@
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_pointcache.h"
#include "BKE_scene.h"
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index d6b96b34273..ef15b5fbf7a 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -271,7 +271,6 @@ static void displaceModifier_do_task(
}
}
-/* dm must be a CDDerivedMesh */
static void displaceModifier_do(
DisplaceModifierData *dmd, const ModifierEvalContext *ctx,
Mesh *mesh, float (*vertexCos)[3], const int numVerts)
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index 5f7cd1e0d60..4bcc14236a0 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -48,6 +48,7 @@
#include "BKE_fluidsim.h" /* ensure definitions here match */
#include "BKE_cdderivedmesh.h"
+#include "BKE_main.h"
#ifdef WITH_MOD_FLUID
# include "BKE_global.h"
#endif
@@ -465,7 +466,7 @@ static DerivedMesh *fluidsim_read_cache(
/* offset baked frame */
curFrame += fss->frameOffset;
- BLI_path_abs(targetFile, modifier_path_relbase(ob));
+ BLI_path_abs(targetFile, modifier_path_relbase_from_global(ob));
BLI_path_frame(targetFile, curFrame, 0); // fixed #frame-no
/* assign material + flags to new dm
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index ae4eb042444..63b4e950697 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -38,8 +38,8 @@
#include "BKE_deform.h"
#include "BKE_editmesh.h"
#include "BKE_library.h"
-#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_particle.h"
#include "DNA_mesh_types.h"
diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c
index 5d8ac9e5638..50765079785 100644
--- a/source/blender/modifiers/intern/MOD_meshcache.c
+++ b/source/blender/modifiers/intern/MOD_meshcache.c
@@ -152,7 +152,7 @@ static void meshcache_do(
/* would be nice if we could avoid doing this _every_ frame */
BLI_strncpy(filepath, mcmd->filepath, sizeof(filepath));
- BLI_path_abs(filepath, ID_BLEND_PATH(G.main, (ID *)ob));
+ BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL((ID *)ob));
switch (mcmd->type) {
case MOD_MESHCACHE_TYPE_MDD:
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index 48653856178..4fe8942a194 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -225,8 +225,8 @@ static void meshdeform_vert_task(
const MDeformVert *dvert = data->dvert;
const int defgrp_index = data->defgrp_index;
const int *offsets = mmd->bindoffsets;
- const MDefInfluence *influences = mmd->bindinfluences;
- /*const*/ float (*dco)[3] = data->dco;
+ const MDefInfluence *__restrict influences = mmd->bindinfluences;
+ /*const*/ float (*__restrict dco)[3] = data->dco;
float (*vertexCos)[3] = data->vertexCos;
float co[3];
float weight, totweight, fac = 1.0f;
@@ -253,11 +253,12 @@ static void meshdeform_vert_task(
totweight = meshdeform_dynamic_bind(mmd, dco, co);
}
else {
- int a;
totweight = 0.0f;
zero_v3(co);
+ int start = offsets[iter];
+ int end = offsets[iter + 1];
- for (a = offsets[iter]; a < offsets[iter + 1]; a++) {
+ for (int a = start; a < end; a++) {
weight = influences[a].weight;
madd_v3_v3fl(co, dco[influences[a].vertex], weight);
totweight += weight;
@@ -275,10 +276,12 @@ static void meshdeform_vert_task(
}
static void meshdeformModifier_do(
- ModifierData *md, Depsgraph *depsgraph, Object *ob, Mesh *mesh,
+ ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
MeshDeformModifierData *mmd = (MeshDeformModifierData *) md;
+ Object *ob = ctx->object;
+
Mesh *cagemesh;
MDeformVert *dvert = NULL;
float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4];
@@ -301,29 +304,9 @@ static void meshdeformModifier_do(
*
* We'll support this case once granular dependency graph is landed.
*/
- if (mmd->object->mode & OB_MODE_EDIT) {
- BMEditMesh *em = BKE_editmesh_from_object(mmd->object);
- cagemesh = BKE_bmesh_to_mesh_nomain(em->bm, &(struct BMeshToMeshParams){0});
- free_cagemesh = true;
- }
- else {
- ModifierEvalContext ctx = {
- .depsgraph = depsgraph,
- .flag = md->mode & eModifierMode_Render ? MOD_APPLY_RENDER : 0,
- };
- cagemesh = BKE_modifier_get_evaluated_mesh_from_object(&ctx, ob);
- }
-
- /* if we don't have one computed, use derivedmesh from data
- * without any modifiers */
- if (!cagemesh) {
- cagemesh = get_mesh(mmd->object, NULL, NULL, NULL, false, false);
- if (cagemesh) {
- free_cagemesh = true;
- }
- }
+ cagemesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(mmd->object, &free_cagemesh);
- if (!cagemesh) {
+ if (cagemesh == NULL) {
modifier_setError(md, "Cannot get mesh from cage object");
return;
}
@@ -412,7 +395,9 @@ static void meshdeformModifier_do(
/* release cage derivedmesh */
MEM_freeN(dco);
MEM_freeN(cagecos);
- if (free_cagemesh) BKE_id_free(NULL, cagemesh);
+ if (cagemesh != NULL && free_cagemesh) {
+ BKE_id_free(NULL, cagemesh);
+ }
}
static void deformVerts(
@@ -425,7 +410,7 @@ static void deformVerts(
modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
- meshdeformModifier_do(md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, numVerts);
+ meshdeformModifier_do(md, ctx, mesh_src, vertexCos, numVerts);
if (mesh_src && mesh_src != mesh) {
BKE_id_free(NULL, mesh_src);
@@ -441,7 +426,7 @@ static void deformVertsEM(
{
Mesh *mesh_src = get_mesh(ctx->object, NULL, mesh, NULL, false, false);
- meshdeformModifier_do(md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, numVerts);
+ meshdeformModifier_do(md, ctx, mesh_src, vertexCos, numVerts);
if (mesh_src && mesh_src != mesh) {
BKE_id_free(NULL, mesh_src);
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index 595b91f25a2..abd84799457 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -31,13 +31,13 @@
#include "DNA_scene_types.h"
#include "BKE_cachefile.h"
-#include "BKE_DerivedMesh.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_scene.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "MOD_modifiertypes.h"
@@ -87,23 +87,23 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
return (mcmd->cache_file == NULL) || (mcmd->object_path[0] == '\0');
}
-static DerivedMesh *applyModifier(
+static Mesh *applyModifier(
ModifierData *md, const ModifierEvalContext *ctx,
- DerivedMesh *dm)
+ Mesh *mesh)
{
#ifdef WITH_ALEMBIC
MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *) md;
/* Only used to check whether we are operating on org data or not... */
Mesh *me = (ctx->object->type == OB_MESH) ? ctx->object->data : NULL;
- DerivedMesh *org_dm = dm;
+ Mesh *org_mesh = mesh;
- Scene *scene = md->scene;
- const float frame = BKE_scene_frame_get(scene);
+ Scene *scene = md->scene; /* for FPS macro */
+ const float frame = DEG_get_ctime(ctx->depsgraph);
const float time = BKE_cachefile_time_offset(mcmd->cache_file, frame, FPS);
const char *err_str = NULL;
- CacheFile *cache_file = mcmd->cache_file;
+ CacheFile *cache_file = (CacheFile *)DEG_get_original_id(&mcmd->cache_file->id);
BKE_cachefile_ensure_handle(G.main, cache_file);
@@ -114,39 +114,44 @@ static DerivedMesh *applyModifier(
mcmd->object_path);
if (!mcmd->reader) {
modifier_setError(md, "Could not create Alembic reader for file %s", cache_file->filepath);
- return dm;
+ return mesh;
}
}
if (me != NULL) {
- MVert *mvert = dm->getVertArray(dm);
- MEdge *medge = dm->getEdgeArray(dm);
- MPoly *mpoly = dm->getPolyArray(dm);
+ MVert *mvert = mesh->mvert;
+ MEdge *medge = mesh->medge;
+ MPoly *mpoly = mesh->mpoly;
if ((me->mvert == mvert) || (me->medge == medge) || (me->mpoly == mpoly)) {
/* We need to duplicate data here, otherwise we'll modify org mesh, see T51701. */
- dm = CDDM_copy(dm);
+ BKE_id_copy_ex(NULL, &mesh->id, (ID **)&mesh,
+ LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG |
+ LIB_ID_COPY_NO_PREVIEW,
+ false);
}
}
- DerivedMesh *result = ABC_read_mesh(mcmd->reader,
- ctx->object,
- dm,
- time,
- &err_str,
- mcmd->read_flag);
+ Mesh *result = ABC_read_mesh(mcmd->reader,
+ ctx->object,
+ mesh,
+ time,
+ &err_str,
+ mcmd->read_flag);
if (err_str) {
modifier_setError(md, "%s", err_str);
}
- if (!ELEM(result, NULL, dm) && (dm != org_dm)) {
- dm->release(dm);
- dm = org_dm;
+ if (!ELEM(result, NULL, mesh) && (mesh != org_mesh)) {
+ BKE_id_free(NULL, mesh);
+ mesh = org_mesh;
}
- return result ? result : dm;
+ return result ? result : mesh;
#else
- return dm;
+ return mesh;
UNUSED_VARS(ctx, md);
#endif
}
@@ -190,14 +195,14 @@ ModifierTypeInfo modifierType_MeshSequenceCache = {
/* deformMatrices_DM */ NULL,
/* deformVertsEM_DM */ NULL,
/* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ applyModifier,
+ /* applyModifier_DM */ NULL,
/* applyModifierEM_DM */NULL,
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
- /* applyModifier */ NULL,
+ /* applyModifier */ applyModifier,
/* applyModifierEM */ NULL,
/* initData */ initData,
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index 67d20e1a52f..08dbcf81256 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -405,13 +405,20 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, Object *ob, Mes
}
Mesh *result;
- BKE_id_copy_ex(
- NULL, &mesh->id, (ID **)&result,
- LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
- false);
+ if (mesh->medge == ((Mesh *)ob->data)->medge) {
+ /* We need to duplicate data here, otherwise setting custom normals (which may also affect sharp edges) could
+ * modify org mesh, see T43671. */
+ BKE_id_copy_ex(
+ NULL, &mesh->id, (ID **)&result,
+ LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG |
+ LIB_ID_COPY_NO_PREVIEW,
+ false);
+ }
+ else {
+ result = mesh;
+ }
const int num_verts = result->totvert;
const int num_edges = result->totedge;
@@ -450,7 +457,7 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, Object *ob, Mes
result->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL;
if (use_current_clnors) {
- clnors = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL);
+ clnors = CustomData_duplicate_referenced_layer(ldata, CD_CUSTOMLOOPNORMAL, num_loops);
BKE_mesh_normals_loop_split(mvert, num_verts, medge, num_edges, mloop, loopnors, num_loops,
mpoly, (const float (*)[3])polynors, num_polys,
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index 728802882a9..af5b537ca52 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -41,6 +41,8 @@
#include "BLI_utildefines.h"
#include "BKE_cdderivedmesh.h"
+#include "BKE_global.h"
+#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_ocean.h"
@@ -49,7 +51,7 @@
#ifdef WITH_OCEANSIM
static void init_cache_data(Object *ob, struct OceanModifierData *omd)
{
- const char *relbase = modifier_path_relbase(ob);
+ const char *relbase = modifier_path_relbase_from_global(ob);
omd->oceancache = BKE_ocean_init_cache(omd->cachepath, relbase,
omd->bakestart, omd->bakeend, omd->wave_scale,
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index eee7f0c5561..0aafcf33202 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -149,7 +149,7 @@ static bool particle_skip(ParticleInstanceModifierData *pimd, ParticleSystem *ps
if (p >= psys->totpart) {
ChildParticle *cpa = psys->child + (p - psys->totpart);
- pa = psys->particles + (between? cpa->pa[0]: cpa->parent);
+ pa = psys->particles + (between ? cpa->pa[0] : cpa->parent);
}
else {
pa = psys->particles + p;
@@ -173,8 +173,8 @@ static bool particle_skip(ParticleInstanceModifierData *pimd, ParticleSystem *ps
/* TODO make randomization optional? */
randp = (int)(psys_frand(psys, 3578 + p) * totpart) % totpart;
- minp = (int)(totpart * pimd->particle_offset) % (totpart+1);
- maxp = (int)(totpart * (pimd->particle_offset + pimd->particle_amount)) % (totpart+1);
+ minp = (int)(totpart * pimd->particle_offset) % (totpart + 1);
+ maxp = (int)(totpart * (pimd->particle_offset + pimd->particle_amount)) % (totpart + 1);
if (maxp > minp) {
return randp < minp || randp >= maxp;
@@ -340,7 +340,7 @@ static Mesh *applyModifier(
for (p = part_start, p_skip = 0; p < part_end; p++) {
float prev_dir[3];
float frame[4]; /* frame orientation quaternion */
- float p_random = psys_frand(psys, 77091 + 283*p);
+ float p_random = psys_frand(psys, 77091 + 283 * p);
/* skip particle? */
if (particle_skip(pimd, psys, p))
@@ -404,7 +404,7 @@ static Mesh *applyModifier(
pa = psys->particles + p;
else {
ChildParticle *cpa = psys->child + (p - psys->totpart);
- pa = psys->particles + (between? cpa->pa[0]: cpa->parent);
+ pa = psys->particles + (between ? cpa->pa[0] : cpa->parent);
}
psys_mat_hair_to_global(sim.ob, sim.psmd->mesh_final, sim.psys->part->from, pa, hairmat);
copy_m3_m4(mat, hairmat);
@@ -412,7 +412,7 @@ static Mesh *applyModifier(
mat3_to_quat(frame, mat);
if (pimd->rotation > 0.0f || pimd->random_rotation > 0.0f) {
- float angle = 2.0f*M_PI * (pimd->rotation + pimd->random_rotation * (psys_frand(psys, 19957323 + p) - 0.5f));
+ float angle = 2.0f * M_PI * (pimd->rotation + pimd->random_rotation * (psys_frand(psys, 19957323 + p) - 0.5f));
float eul[3] = { 0.0f, 0.0f, angle };
float rot[4];
diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c
index eff343a4906..df607c04164 100644
--- a/source/blender/modifiers/intern/MOD_remesh.c
+++ b/source/blender/modifiers/intern/MOD_remesh.c
@@ -38,6 +38,7 @@
#include "MOD_modifiertypes.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include <assert.h>
#include <stdlib.h>
diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c
index 1e503f41310..29f5815c733 100644
--- a/source/blender/modifiers/intern/MOD_shrinkwrap.c
+++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c
@@ -111,7 +111,7 @@ static void deformVerts(
BLI_assert(mesh_src->totvert == numVerts);
- shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts, ctx);
+ shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts);
}
static void deformVertsEM(
@@ -127,7 +127,7 @@ static void deformVertsEM(
BLI_assert(mesh_src->totvert == numVerts);
- shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts, ctx);
+ shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts);
if (!mesh) {
BKE_id_free(NULL, mesh_src);
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 5e2cdd71a10..26fd16ef167 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -28,7 +28,7 @@
/* Implementation based in part off the paper "B-Mesh: A Fast Modeling
* System for Base Meshes of 3D Articulated Shapes" (Zhongping Ji,
* Ligang Liu, Yigang Wang)
- *
+ *
* Note that to avoid confusion with Blender's BMesh data structure,
* this tool is renamed as the Skin modifier.
*
@@ -36,7 +36,7 @@
* http://www.math.zju.edu.cn/ligangliu/CAGD/Projects/BMesh/
*
* The main missing features in this code compared to the paper are:
- *
+ *
* + No mesh evolution. The paper suggests iteratively subsurfing the
* skin output and adapting the output to better conform with the
* spheres of influence surrounding each vertex.
diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c
index 6e57ad53c2b..30f9829ae20 100644
--- a/source/blender/modifiers/intern/MOD_softbody.c
+++ b/source/blender/modifiers/intern/MOD_softbody.c
@@ -35,11 +35,11 @@
#include <stdio.h>
#include "DNA_scene_types.h"
+#include "DNA_mesh_types.h"
#include "DNA_object_force_types.h"
#include "BLI_utildefines.h"
-#include "BKE_cdderivedmesh.h"
#include "BKE_layer.h"
#include "BKE_particle.h"
#include "BKE_softbody.h"
@@ -52,7 +52,7 @@
static void deformVerts(
ModifierData *md, const ModifierEvalContext *ctx,
- DerivedMesh *UNUSED(derivedData),
+ Mesh *UNUSED(derivedData),
float (*vertexCos)[3],
int numVerts)
{
@@ -86,14 +86,14 @@ ModifierTypeInfo modifierType_Softbody = {
/* copyData */ NULL,
- /* deformVerts_DM */ deformVerts,
+ /* deformVerts_DM */ NULL,
/* deformMatrices_DM */ NULL,
/* deformVertsEM_DM */ NULL,
/* deformMatricesEM_DM*/NULL,
/* applyModifier_DM */ NULL,
/* applyModifierEM_DM */NULL,
- /* deformVerts */ NULL,
+ /* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index f03ae73e2bb..e964da0a8d1 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -9,7 +9,7 @@
#include "BLI_task.h"
#include "BKE_bvhutils.h"
-#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_editmesh.h"
#include "BKE_library.h"
#include "BKE_library_query.h"
@@ -1041,33 +1041,6 @@ static bool surfacedeformBind(
return data.success == 1;
}
-static Mesh *surfacedeform_get_mesh(Depsgraph *depsgraph, SurfaceDeformModifierData *smd, bool *r_needsfree)
-{
- Mesh *mesh;
-
- /* Handle target mesh both in and out of edit mode */
- if (smd->target->mode & OB_MODE_EDIT) {
- BMEditMesh *em = BKE_editmesh_from_object(smd->target);
- mesh = BKE_bmesh_to_mesh_nomain(em->bm, &(struct BMeshToMeshParams){0});
- *r_needsfree = true;
- }
- else {
- ModifierEvalContext ctx = {
- .depsgraph = depsgraph,
- .flag = smd->modifier.mode & eModifierMode_Render ? MOD_APPLY_RENDER : 0,
- };
- mesh = BKE_modifier_get_evaluated_mesh_from_object(&ctx, smd->target);
- *r_needsfree = false;
- }
-
- if (!mesh) {
- mesh = get_mesh(smd->target, NULL, NULL, NULL, false, false);
- *r_needsfree = true;
- }
-
- return mesh;
-}
-
static void deformVert(
void *__restrict userdata,
const int index,
@@ -1127,7 +1100,7 @@ static void deformVert(
static void surfacedeformModifier_do(
ModifierData *md,
- const ModifierEvalContext *ctx,
+ const ModifierEvalContext *UNUSED(ctx),
float (*vertexCos)[3], unsigned int numverts, Object *ob)
{
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
@@ -1141,7 +1114,7 @@ static void surfacedeformModifier_do(
return;
}
- target = surfacedeform_get_mesh(ctx->depsgraph, smd, &free_target);
+ target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(smd->target, &free_target);
if (!target) {
modifier_setError(md, "No valid target mesh");
return;
@@ -1200,7 +1173,9 @@ static void surfacedeformModifier_do(
MEM_freeN(data.targetCos);
}
- if (free_target) BKE_id_free(NULL, target);
+ if (target != NULL && free_target) {
+ BKE_id_free(NULL, target);
+ }
}
static void deformVerts(
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 5d740ae9e20..d4f035915d0 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -311,10 +311,11 @@ Mesh *get_mesh(
* we really need a copy here. Maybe the CoW ob->data can be directly used. */
BKE_id_copy_ex(
NULL, ob->data, (ID **)&mesh,
- LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
+ (LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG |
+ LIB_ID_COPY_NO_PREVIEW |
+ LIB_ID_COPY_CD_REFERENCE),
false);
mesh->runtime.deformed_only = 1;
}
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index b491496caa4..394255ddb18 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -113,7 +113,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
typedef struct Projector {
- Object *ob_eval; /* object this projector is derived from */
+ Object *ob; /* object this projector is derived from */
float projmat[4][4]; /* projection matrix */
float normal[3]; /* projector normal in world space */
void *uci; /* optional uv-project info (panorama projection) */
@@ -121,7 +121,6 @@ typedef struct Projector {
static Mesh *uvprojectModifier_do(
UVProjectModifierData *umd,
- Depsgraph *depsgraph,
Object *ob, Mesh *mesh)
{
float (*coords)[3], (*co)[3];
@@ -140,7 +139,7 @@ static Mesh *uvprojectModifier_do(
for (i = 0; i < umd->num_projectors; ++i)
if (umd->projectors[i])
- projectors[num_projectors++].ob_eval = DEG_get_evaluated_object(depsgraph, umd->projectors[i]);
+ projectors[num_projectors++].ob = umd->projectors[i];
if (num_projectors == 0) return mesh;
@@ -157,14 +156,14 @@ static Mesh *uvprojectModifier_do(
float offsetmat[4][4];
Camera *cam = NULL;
/* calculate projection matrix */
- invert_m4_m4(projectors[i].projmat, projectors[i].ob_eval->obmat);
+ invert_m4_m4(projectors[i].projmat, projectors[i].ob->obmat);
projectors[i].uci = NULL;
- if (projectors[i].ob_eval->type == OB_CAMERA) {
- cam = (Camera *)projectors[i].ob_eval->data;
+ if (projectors[i].ob->type == OB_CAMERA) {
+ cam = (Camera *)projectors[i].ob->data;
if (cam->type == CAM_PANO) {
- projectors[i].uci = BLI_uvproject_camera_info(projectors[i].ob_eval, NULL, aspx, aspy);
+ projectors[i].uci = BLI_uvproject_camera_info(projectors[i].ob, NULL, aspx, aspy);
BLI_uvproject_camera_info_scale(projectors[i].uci, scax, scay);
free_uci = 1;
}
@@ -173,7 +172,7 @@ static Mesh *uvprojectModifier_do(
/* setup parameters */
BKE_camera_params_init(&params);
- BKE_camera_params_from_object(&params, projectors[i].ob_eval);
+ BKE_camera_params_from_object(&params, projectors[i].ob);
/* compute matrix, viewplane, .. */
BKE_camera_params_compute_viewplane(&params, 1, 1, aspx, aspy);
@@ -202,7 +201,7 @@ static Mesh *uvprojectModifier_do(
projectors[i].normal[0] = 0;
projectors[i].normal[1] = 0;
projectors[i].normal[2] = 1;
- mul_mat3_m4_v3(projectors[i].ob_eval->obmat, projectors[i].normal);
+ mul_mat3_m4_v3(projectors[i].ob->obmat, projectors[i].normal);
}
numPolys = mesh->totpoly;
@@ -314,7 +313,7 @@ static Mesh *applyModifier(
Mesh *result;
UVProjectModifierData *umd = (UVProjectModifierData *) md;
- result = uvprojectModifier_do(umd, ctx->depsgraph, ctx->object, mesh);
+ result = uvprojectModifier_do(umd, ctx->object, mesh);
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index 7c71dd5159e..00bc8a05cee 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -202,17 +202,10 @@ static Mesh *applyModifier(
}
}
- Mesh *result;
- BKE_id_copy_ex(
- NULL, &mesh->id, (ID **)&result,
- LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
- false);
+ Mesh *result = mesh;
if (has_mdef) {
- dvert = CustomData_get_layer(&result->vdata, CD_MDEFORMVERT);
+ dvert = CustomData_duplicate_referenced_layer(&result->vdata, CD_MDEFORMVERT, numVerts);
}
else {
/* Add a valid data layer! */
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index 1736bb01951..2b0f90008cf 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -243,17 +243,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
}
}
- Mesh *result;
- BKE_id_copy_ex(
- NULL, &mesh->id, (ID **)&result,
- LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
- false);
+ Mesh *result = mesh;
if (has_mdef) {
- dvert = CustomData_get_layer(&result->vdata, CD_MDEFORMVERT);
+ dvert = CustomData_duplicate_referenced_layer(&result->vdata, CD_MDEFORMVERT, numVerts);
}
else {
/* Add a valid data layer! */
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 9e77e0d3794..070d4ad80e6 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -421,17 +421,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
return mesh;
}
- Mesh *result;
- BKE_id_copy_ex(
- NULL, &mesh->id, (ID **)&result,
- LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
- false);
+ Mesh *result = mesh;
if (has_mdef) {
- dvert = CustomData_get_layer(&result->vdata, CD_MDEFORMVERT);
+ dvert = CustomData_duplicate_referenced_layer(&result->vdata, CD_MDEFORMVERT, numVerts);
}
else {
/* Add a valid data layer! */
@@ -506,7 +499,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
const bool use_trgt_faces = (wmd->proximity_flags & MOD_WVG_PROXIMITY_GEOM_FACES) != 0;
if (use_trgt_verts || use_trgt_edges || use_trgt_faces) {
- Mesh *target_mesh = BKE_modifier_get_evaluated_mesh_from_object(ctx, obr);
+ bool target_mesh_free;
+ Mesh *target_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(obr, &target_mesh_free);
/* We must check that we do have a valid target_mesh! */
if (target_mesh != NULL) {
@@ -529,6 +523,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
MEM_SAFE_FREE(dists_v);
MEM_SAFE_FREE(dists_e);
MEM_SAFE_FREE(dists_f);
+
+ if (target_mesh_free) {
+ BKE_id_free(NULL, target_mesh);
+ }
}
/* Else, fall back to default obj2vert behavior. */
else {
diff --git a/source/blender/nodes/NOD_socket.h b/source/blender/nodes/NOD_socket.h
index e311adc45eb..3ff65ce4fd9 100644
--- a/source/blender/nodes/NOD_socket.h
+++ b/source/blender/nodes/NOD_socket.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index 8994a2741f8..43beb1656a2 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -59,7 +59,7 @@
static void composite_get_from_context(const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from)
{
Scene *scene = CTX_data_scene(C);
-
+
*r_from = NULL;
*r_id = &scene->id;
*r_ntree = scene->nodetree;
@@ -83,7 +83,7 @@ static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCa
static void free_node_cache(bNodeTree *UNUSED(ntree), bNode *node)
{
bNodeSocket *sock;
-
+
for (sock = node->outputs.first; sock; sock = sock->next) {
if (sock->cache) {
sock->cache = NULL;
@@ -103,15 +103,15 @@ static void localize(bNodeTree *UNUSED(localtree), bNodeTree *ntree)
{
bNode *node;
bNodeSocket *sock;
-
+
for (node = ntree->nodes.first; node; node = node->next) {
/* ensure new user input gets handled ok */
node->need_exec = 0;
node->new_node->original = node;
-
+
/* move over the compbufs */
/* right after ntreeCopyTree() oldsock pointers are valid */
-
+
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
if (node->id) {
if (node->flag & NODE_DO_OUTPUT)
@@ -120,7 +120,7 @@ static void localize(bNodeTree *UNUSED(localtree), bNodeTree *ntree)
node->new_node->id = NULL;
}
}
-
+
for (sock = node->outputs.first; sock; sock = sock->next) {
sock->new_sock->cache = sock->cache;
sock->cache = NULL;
@@ -134,20 +134,20 @@ static void local_sync(bNodeTree *localtree, bNodeTree *ntree)
BKE_node_preview_sync_tree(ntree, localtree);
}
-static void local_merge(bNodeTree *localtree, bNodeTree *ntree)
+static void local_merge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree)
{
bNode *lnode;
bNodeSocket *lsock;
-
+
/* move over the compbufs and previews */
BKE_node_preview_merge_tree(ntree, localtree, true);
-
+
for (lnode = localtree->nodes.first; lnode; lnode = lnode->next) {
if (ntreeNodeExists(ntree, lnode->new_node)) {
if (ELEM(lnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
if (lnode->id && (lnode->flag & NODE_DO_OUTPUT)) {
/* image_merge does sanity check for pointers */
- BKE_image_merge((Image *)lnode->new_node->id, (Image *)lnode->id);
+ BKE_image_merge(bmain, (Image *)lnode->new_node->id, (Image *)lnode->id);
}
}
else if (lnode->type == CMP_NODE_MOVIEDISTORTION) {
@@ -161,7 +161,7 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree)
lnode->new_node->storage = BKE_tracking_distortion_copy(lnode->storage);
}
}
-
+
for (lsock = lnode->outputs.first; lsock; lsock = lsock->next) {
if (ntreeOutputExists(lnode->new_node, lsock->new_sock)) {
lsock->new_sock->cache = lsock->cache;
@@ -176,9 +176,9 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree)
static void update(bNodeTree *ntree)
{
ntreeSetOutput(ntree);
-
+
ntree_update_reroute_nodes(ntree);
-
+
if (ntree->update & NTREE_UPDATE_NODES) {
/* clean up preview cache, in case nodes have been removed */
BKE_node_preview_remove_unused(ntree);
@@ -187,12 +187,12 @@ static void update(bNodeTree *ntree)
static void composite_node_add_init(bNodeTree *UNUSED(bnodetree), bNode *bnode)
{
- /* Composite node will only show previews for input classes
- * by default, other will be hidden
+ /* Composite node will only show previews for input classes
+ * by default, other will be hidden
* but can be made visible with the show_preview option */
if (bnode->typeinfo->nclass != NODE_CLASS_INPUT) {
bnode->flag &= ~NODE_PREVIEW;
- }
+ }
}
bNodeTreeType *ntreeType_Composite;
@@ -200,13 +200,13 @@ bNodeTreeType *ntreeType_Composite;
void register_node_tree_type_cmp(void)
{
bNodeTreeType *tt = ntreeType_Composite = MEM_callocN(sizeof(bNodeTreeType), "compositor node tree type");
-
+
tt->type = NTREE_COMPOSIT;
strcpy(tt->idname, "CompositorNodeTree");
strcpy(tt->ui_name, "Compositing");
tt->ui_icon = 0; /* defined in drawnode.c */
strcpy(tt->ui_description, "Compositing nodes");
-
+
tt->free_cache = free_cache;
tt->free_node_cache = free_node_cache;
tt->foreach_nodeclass = foreach_nodeclass;
@@ -216,9 +216,9 @@ void register_node_tree_type_cmp(void)
tt->update = update;
tt->get_from_context = composite_get_from_context;
tt->node_add_init = composite_node_add_init;
-
+
tt->ext.srna = &RNA_CompositorNodeTree;
-
+
ntreeTypeAdd(tt);
}
diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c
index c6b1d37f8b4..022794e8d42 100644
--- a/source/blender/nodes/composite/node_composite_util.c
+++ b/source/blender/nodes/composite/node_composite_util.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -52,7 +52,7 @@ void cmp_node_update_default(bNodeTree *UNUSED(ntree), bNode *node)
void cmp_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
{
node_type_base(ntype, type, name, nclass, flag);
-
+
ntype->poll = cmp_node_poll_default;
ntype->updatefunc = cmp_node_update_default;
ntype->insert_link = node_insert_link_default;
diff --git a/source/blender/nodes/composite/node_composite_util.h b/source/blender/nodes/composite/node_composite_util.h
index 22c5e6f9507..25827d914f4 100644
--- a/source/blender/nodes/composite/node_composite_util.h
+++ b/source/blender/nodes/composite/node_composite_util.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c
index dda0ec0c897..da26a337add 100644
--- a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c
+++ b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
index fde7dccb4ac..68937262bf5 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.c b/source/blender/nodes/composite/nodes/node_composite_blur.c
index e5d3fd14df6..09e1ce654ce 100644
--- a/source/blender/nodes/composite/nodes/node_composite_blur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_blur.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehblur.c b/source/blender/nodes/composite/nodes/node_composite_bokehblur.c
index 58a00559192..acb5d100b0a 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bokehblur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_bokehblur.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -60,6 +60,6 @@ void register_node_type_cmp_bokehblur(void)
cmp_node_type_base(&ntype, CMP_NODE_BOKEHBLUR, "Bokeh Blur", NODE_CLASS_OP_FILTER, 0);
node_type_socket_templates(&ntype, cmp_node_bokehblur_in, cmp_node_bokehblur_out);
node_type_init(&ntype, node_composit_init_bokehblur);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehimage.c b/source/blender/nodes/composite/nodes/node_composite_bokehimage.c
index 1473212f8e1..04cdd3367e6 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bokehimage.c
+++ b/source/blender/nodes/composite/nodes/node_composite_bokehimage.c
@@ -54,7 +54,7 @@ static void node_composit_init_bokehimage(bNodeTree *UNUSED(ntree), bNode *node)
void register_node_type_cmp_bokehimage(void)
{
static bNodeType ntype;
-
+
cmp_node_type_base(&ntype, CMP_NODE_BOKEHIMAGE, "Bokeh Image", NODE_CLASS_INPUT, NODE_PREVIEW);
node_type_socket_templates(&ntype, NULL, cmp_node_bokehimage_out);
node_type_init(&ntype, node_composit_init_bokehimage);
diff --git a/source/blender/nodes/composite/nodes/node_composite_boxmask.c b/source/blender/nodes/composite/nodes/node_composite_boxmask.c
index 0390eb43da0..611cf323873 100644
--- a/source/blender/nodes/composite/nodes/node_composite_boxmask.c
+++ b/source/blender/nodes/composite/nodes/node_composite_boxmask.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -32,7 +32,7 @@
#include "../node_composite_util.h"
-/* **************** SCALAR MATH ******************** */
+/* **************** SCALAR MATH ******************** */
static bNodeSocketTemplate cmp_node_boxmask_in[] = {
{ SOCK_FLOAT, 1, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
diff --git a/source/blender/nodes/composite/nodes/node_composite_brightness.c b/source/blender/nodes/composite/nodes/node_composite_brightness.c
index 26e4d3a52c9..d44b8cd63cb 100644
--- a/source/blender/nodes/composite/nodes/node_composite_brightness.c
+++ b/source/blender/nodes/composite/nodes/node_composite_brightness.c
@@ -4,24 +4,24 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
+ *
* The Original Code is Copyright (C) 2006 Blender Foundation.
* All rights reserved.
- *
+ *
* The Original Code is: all of this file.
- *
+ *
* Contributor(s): none yet.
- *
+ *
* ***** END GPL LICENSE BLOCK *****
*/
@@ -54,7 +54,7 @@ static void node_composit_init_brightcontrast(bNodeTree *UNUSED(ntree), bNode *n
void register_node_type_cmp_brightcontrast(void)
{
static bNodeType ntype;
-
+
cmp_node_type_base(&ntype, CMP_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, cmp_node_brightcontrast_in, cmp_node_brightcontrast_out);
node_type_init(&ntype, node_composit_init_brightcontrast);
diff --git a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c
index 984967ac167..52afeabb969 100644
--- a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c
index 7ebdefc0164..eeccd80a01c 100644
--- a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c
index 0d608758eaa..641026c3aad 100644
--- a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c
+++ b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -57,7 +57,7 @@ static void node_composit_init_color_spill(bNodeTree *UNUSED(ntree), bNode *node
void register_node_type_cmp_color_spill(void)
{
static bNodeType ntype;
-
+
cmp_node_type_base(&ntype, CMP_NODE_COLOR_SPILL, "Color Spill", NODE_CLASS_MATTE, 0);
node_type_socket_templates(&ntype, cmp_node_color_spill_in, cmp_node_color_spill_out);
node_type_init(&ntype, node_composit_init_color_spill);
diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
index 70e52d432cd..f9ad8c0ea5f 100644
--- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
+++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -52,7 +52,7 @@ void ntreeCompositColorBalanceSyncFromLGG(bNodeTree *UNUSED(ntree), bNode *node)
{
NodeColorBalance *n = node->storage;
int c;
-
+
for (c = 0; c < 3; ++c) {
n->slope[c] = (2.0f - n->lift[c]) * n->gain[c];
n->offset[c] = (n->lift[c] - 1.0f) * n->gain[c];
@@ -64,7 +64,7 @@ void ntreeCompositColorBalanceSyncFromCDL(bNodeTree *UNUSED(ntree), bNode *node)
{
NodeColorBalance *n = node->storage;
int c;
-
+
for (c = 0; c < 3; ++c) {
float d = n->slope[c] + n->offset[c];
n->lift[c] = (d != 0.0f ? n->slope[c] + 2.0f * n->offset[c] / d : 0.0f);
diff --git a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c
index ad1e70423a5..2f7d163a7bf 100644
--- a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c
+++ b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_common.c b/source/blender/nodes/composite/nodes/node_composite_common.c
index 0fbbb54ee7a..de97a5beac3 100644
--- a/source/blender/nodes/composite/nodes/node_composite_common.c
+++ b/source/blender/nodes/composite/nodes/node_composite_common.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -43,7 +43,7 @@
void register_node_type_cmp_group(void)
{
static bNodeType ntype;
-
+
/* NB: cannot use sh_node_type_base for node group, because it would map the node type
* to the shared NODE_GROUP integer type id.
*/
@@ -56,7 +56,7 @@ void register_node_type_cmp_group(void)
ntype.ext.srna = RNA_struct_find("CompositorNodeGroup");
BLI_assert(ntype.ext.srna != NULL);
RNA_struct_blender_type_set(ntype.ext.srna, &ntype);
-
+
node_type_socket_templates(&ntype, NULL, NULL);
node_type_size(&ntype, 140, 60, 400);
node_type_label(&ntype, node_group_label);
diff --git a/source/blender/nodes/composite/nodes/node_composite_composite.c b/source/blender/nodes/composite/nodes/node_composite_composite.c
index be9ed457150..13dc8387504 100644
--- a/source/blender/nodes/composite/nodes/node_composite_composite.c
+++ b/source/blender/nodes/composite/nodes/node_composite_composite.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_crop.c b/source/blender/nodes/composite/nodes/node_composite_crop.c
index 5d89581a1bf..0ac400cd8dc 100644
--- a/source/blender/nodes/composite/nodes/node_composite_crop.c
+++ b/source/blender/nodes/composite/nodes/node_composite_crop.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.c b/source/blender/nodes/composite/nodes/node_composite_curves.c
index cd2e1f9a2d5..927d319a90d 100644
--- a/source/blender/nodes/composite/nodes/node_composite_curves.c
+++ b/source/blender/nodes/composite/nodes/node_composite_curves.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.c b/source/blender/nodes/composite/nodes/node_composite_defocus.c
index a3311755717..00b73bae5fa 100644
--- a/source/blender/nodes/composite/nodes/node_composite_defocus.c
+++ b/source/blender/nodes/composite/nodes/node_composite_defocus.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.c b/source/blender/nodes/composite/nodes/node_composite_dilate.c
index 37b0b549006..72d12e0a643 100644
--- a/source/blender/nodes/composite/nodes/node_composite_dilate.c
+++ b/source/blender/nodes/composite/nodes/node_composite_dilate.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -54,7 +54,7 @@ static void node_composit_init_dilateerode(bNodeTree *UNUSED(ntree), bNode *node
void register_node_type_cmp_dilateerode(void)
{
static bNodeType ntype;
-
+
cmp_node_type_base(&ntype, CMP_NODE_DILATEERODE, "Dilate/Erode", NODE_CLASS_OP_FILTER, 0);
node_type_socket_templates(&ntype, cmp_node_dilateerode_in, cmp_node_dilateerode_out);
node_type_init(&ntype, node_composit_init_dilateerode);
diff --git a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c
index 336eb3409ff..1bd81fa8390 100644
--- a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_displace.c b/source/blender/nodes/composite/nodes/node_composite_displace.c
index d205600211a..da3031a7320 100644
--- a/source/blender/nodes/composite/nodes/node_composite_displace.c
+++ b/source/blender/nodes/composite/nodes/node_composite_displace.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c
index 21041062e2d..b72a0fb82ae 100644
--- a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c
+++ b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -32,7 +32,7 @@
#include "../node_composite_util.h"
-/* **************** SCALAR MATH ******************** */
+/* **************** SCALAR MATH ******************** */
static bNodeSocketTemplate cmp_node_ellipsemask_in[] = {
{ SOCK_FLOAT, 1, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
diff --git a/source/blender/nodes/composite/nodes/node_composite_filter.c b/source/blender/nodes/composite/nodes/node_composite_filter.c
index f1c18612e1c..ef8c80cecb4 100644
--- a/source/blender/nodes/composite/nodes/node_composite_filter.c
+++ b/source/blender/nodes/composite/nodes/node_composite_filter.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_flip.c b/source/blender/nodes/composite/nodes/node_composite_flip.c
index 81e49bf902d..71c377b9a66 100644
--- a/source/blender/nodes/composite/nodes/node_composite_flip.c
+++ b/source/blender/nodes/composite/nodes/node_composite_flip.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_gamma.c b/source/blender/nodes/composite/nodes/node_composite_gamma.c
index ab292c630a0..30d399d3f73 100644
--- a/source/blender/nodes/composite/nodes/node_composite_gamma.c
+++ b/source/blender/nodes/composite/nodes/node_composite_gamma.c
@@ -4,24 +4,24 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
+ *
* The Original Code is Copyright (C) 2006 Blender Foundation.
* All rights reserved.
- *
+ *
* The Original Code is: all of this file.
- *
+ *
* Contributor(s): none yet.
- *
+ *
* ***** END GPL LICENSE BLOCK *****
*/
@@ -47,9 +47,9 @@ static bNodeSocketTemplate cmp_node_gamma_out[] = {
void register_node_type_cmp_gamma(void)
{
static bNodeType ntype;
-
+
cmp_node_type_base(&ntype, CMP_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, cmp_node_gamma_in, cmp_node_gamma_out);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_glare.c b/source/blender/nodes/composite/nodes/node_composite_glare.c
index 76020e55463..33534ad84c6 100644
--- a/source/blender/nodes/composite/nodes/node_composite_glare.c
+++ b/source/blender/nodes/composite/nodes/node_composite_glare.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c
index 124e33d186f..372d62470b4 100644
--- a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c
+++ b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c
index 2ed58262b3b..70c73bcb46a 100644
--- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c
+++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -47,14 +47,14 @@ static void node_composit_init_huecorrect(bNodeTree *UNUSED(ntree), bNode *node)
{
CurveMapping *cumapping = node->storage = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
int c;
-
+
cumapping->preset = CURVE_PRESET_MID9;
-
+
for (c = 0; c < 3; c++) {
CurveMap *cuma = &cumapping->cm[c];
curvemap_reset(cuma, &cumapping->clipr, cumapping->preset, CURVEMAP_SLOPE_POSITIVE);
}
-
+
/* default to showing Saturation */
cumapping->cur = 1;
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_idMask.c b/source/blender/nodes/composite/nodes/node_composite_idMask.c
index 379c52cf29e..707b68bb06b 100644
--- a/source/blender/nodes/composite/nodes/node_composite_idMask.c
+++ b/source/blender/nodes/composite/nodes/node_composite_idMask.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index a1beadbdc03..124b2fa72b9 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -150,10 +150,10 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree, bNode *node, LinkNod
/* make sure ima->type is correct */
ibuf = BKE_image_acquire_ibuf(ima, &load_iuser, NULL);
-
+
if (ima->rr) {
RenderLayer *rl = BLI_findlink(&ima->rr->layers, iuser->layer);
-
+
if (rl) {
RenderPass *rpass;
for (rpass = rl->passes.first; rpass; rpass = rpass->next) {
@@ -251,7 +251,7 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rl
bNodeSocket *sock, *sock_next;
LinkNodePair available_sockets = {NULL, NULL};
int sock_index;
-
+
/* XXX make callback */
if (rlayer)
cmp_node_rlayer_create_outputs(ntree, node, &available_sockets);
@@ -307,7 +307,7 @@ static void node_composit_init_image(bNodeTree *ntree, bNode *node)
iuser->fie_ima = 2;
iuser->ok = 1;
iuser->flag |= IMA_ANIM_ALWAYS;
-
+
/* setup initial outputs */
cmp_node_image_verify_outputs(ntree, node, false);
}
@@ -315,20 +315,20 @@ static void node_composit_init_image(bNodeTree *ntree, bNode *node)
static void node_composit_free_image(bNode *node)
{
bNodeSocket *sock;
-
+
/* free extra socket info */
for (sock = node->outputs.first; sock; sock = sock->next)
MEM_freeN(sock->storage);
-
+
MEM_freeN(node->storage);
}
static void node_composit_copy_image(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, bNode *src_node)
{
bNodeSocket *sock;
-
+
dest_node->storage = MEM_dupallocN(src_node->storage);
-
+
/* copy extra socket info */
for (sock = src_node->outputs.first; sock; sock = sock->next)
sock->new_sock->storage = MEM_dupallocN(sock->storage);
@@ -394,7 +394,7 @@ static int node_composit_poll_rlayers(bNodeType *UNUSED(ntype), bNodeTree *ntree
{
if (STREQ(ntree->idname, "CompositorNodeTree")) {
Scene *scene;
-
+
/* XXX ugly: check if ntree is a local scene node tree.
* Render layers node can only be used in local scene->nodetree,
* since it directly links to the scene.
@@ -402,7 +402,7 @@ static int node_composit_poll_rlayers(bNodeType *UNUSED(ntype), bNodeTree *ntree
for (scene = G.main->scene.first; scene; scene = scene->id.next)
if (scene->nodetree == ntree)
break;
-
+
return (scene != NULL);
}
return false;
diff --git a/source/blender/nodes/composite/nodes/node_composite_inpaint.c b/source/blender/nodes/composite/nodes/node_composite_inpaint.c
index 7c52d9330c2..f97f366d0c4 100644
--- a/source/blender/nodes/composite/nodes/node_composite_inpaint.c
+++ b/source/blender/nodes/composite/nodes/node_composite_inpaint.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -47,7 +47,7 @@ static bNodeSocketTemplate cmp_node_inpaint_out[] = {
void register_node_type_cmp_inpaint(void)
{
static bNodeType ntype;
-
+
cmp_node_type_base(&ntype, CMP_NODE_INPAINT, "Inpaint", NODE_CLASS_OP_FILTER, 0);
node_type_socket_templates(&ntype, cmp_node_inpaint_in, cmp_node_inpaint_out);
diff --git a/source/blender/nodes/composite/nodes/node_composite_invert.c b/source/blender/nodes/composite/nodes/node_composite_invert.c
index 946b69821f9..c3f1fdbf867 100644
--- a/source/blender/nodes/composite/nodes/node_composite_invert.c
+++ b/source/blender/nodes/composite/nodes/node_composite_invert.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_lensdist.c b/source/blender/nodes/composite/nodes/node_composite_lensdist.c
index 34176ca5919..3cc0c5ca73e 100644
--- a/source/blender/nodes/composite/nodes/node_composite_lensdist.c
+++ b/source/blender/nodes/composite/nodes/node_composite_lensdist.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_levels.c b/source/blender/nodes/composite/nodes/node_composite_levels.c
index 65e5b2fedf1..be9259752d2 100644
--- a/source/blender/nodes/composite/nodes/node_composite_levels.c
+++ b/source/blender/nodes/composite/nodes/node_composite_levels.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c
index 7574f0ef0fa..e848c680003 100644
--- a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_mapRange.c b/source/blender/nodes/composite/nodes/node_composite_mapRange.c
index c255b0faea4..2e86dc1d247 100644
--- a/source/blender/nodes/composite/nodes/node_composite_mapRange.c
+++ b/source/blender/nodes/composite/nodes/node_composite_mapRange.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_mapUV.c b/source/blender/nodes/composite/nodes/node_composite_mapUV.c
index d4aff97ef74..dd7cf12420f 100644
--- a/source/blender/nodes/composite/nodes/node_composite_mapUV.c
+++ b/source/blender/nodes/composite/nodes/node_composite_mapUV.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_mapValue.c b/source/blender/nodes/composite/nodes/node_composite_mapValue.c
index 35096d57a4e..d9e8a80a569 100644
--- a/source/blender/nodes/composite/nodes/node_composite_mapValue.c
+++ b/source/blender/nodes/composite/nodes/node_composite_mapValue.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.c b/source/blender/nodes/composite/nodes/node_composite_mask.c
index 39c7a750ea1..f61fc343433 100644
--- a/source/blender/nodes/composite/nodes/node_composite_mask.c
+++ b/source/blender/nodes/composite/nodes/node_composite_mask.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_math.c b/source/blender/nodes/composite/nodes/node_composite_math.c
index d93c5d53fd3..e40621d3210 100644
--- a/source/blender/nodes/composite/nodes/node_composite_math.c
+++ b/source/blender/nodes/composite/nodes/node_composite_math.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -32,7 +32,7 @@
#include "node_composite_util.h"
-/* **************** SCALAR MATH ******************** */
+/* **************** SCALAR MATH ******************** */
static bNodeSocketTemplate cmp_node_math_in[] = {
{ SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
diff --git a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c
index d7559ece476..765b19b8d9c 100644
--- a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c
+++ b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
index 9c54009d2f1..4149a0eec9d 100644
--- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
+++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
@@ -58,7 +58,7 @@ static void init(const bContext *C, PointerRNA *ptr)
{
bNode *node = ptr->data;
Scene *scene = CTX_data_scene(C);
-
+
node->id = (ID *)scene->clip;
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_normal.c b/source/blender/nodes/composite/nodes/node_composite_normal.c
index 8d016e7e438..7ba1be1017e 100644
--- a/source/blender/nodes/composite/nodes/node_composite_normal.c
+++ b/source/blender/nodes/composite/nodes/node_composite_normal.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_normalize.c b/source/blender/nodes/composite/nodes/node_composite_normalize.c
index c76b2ef8f26..9a5cc84797e 100644
--- a/source/blender/nodes/composite/nodes/node_composite_normalize.c
+++ b/source/blender/nodes/composite/nodes/node_composite_normalize.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,7 +20,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): gsr b3d, and a very minor edit from Robert Holcomb
+ * Contributor(s): gsr b3d, and a very minor edit from Robert Holcomb
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -46,9 +46,9 @@ static bNodeSocketTemplate cmp_node_normalize_out[] = {
void register_node_type_cmp_normalize(void)
{
static bNodeType ntype;
-
+
cmp_node_type_base(&ntype, CMP_NODE_NORMALIZE, "Normalize", NODE_CLASS_OP_VECTOR, 0);
node_type_socket_templates(&ntype, cmp_node_normalize_in, cmp_node_normalize_out);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c
index 6a96f1b30d8..a2a25d5c515 100644
--- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c
+++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -107,16 +107,16 @@ bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree, bNode *node, con
{
NodeImageMultiFile *nimf = node->storage;
bNodeSocket *sock = nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, NULL, name);
-
+
/* create format data for the input socket */
NodeImageMultiFileSocket *sockdata = MEM_callocN(sizeof(NodeImageMultiFileSocket), "socket image format");
sock->storage = sockdata;
-
+
BLI_strncpy_utf8(sockdata->path, name, sizeof(sockdata->path));
ntreeCompositOutputFileUniquePath(&node->inputs, sock, name, '_');
BLI_strncpy_utf8(sockdata->layer, name, sizeof(sockdata->layer));
ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, name, '_');
-
+
if (im_format) {
sockdata->format = *im_format;
if (BKE_imtype_is_movie(sockdata->format.imtype)) {
@@ -129,7 +129,7 @@ bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree, bNode *node, con
sockdata->use_node_format = true;
nimf->active_input = BLI_findindex(&node->inputs, sock);
-
+
return sock;
}
@@ -138,16 +138,16 @@ int ntreeCompositOutputFileRemoveActiveSocket(bNodeTree *ntree, bNode *node)
NodeImageMultiFile *nimf = node->storage;
bNodeSocket *sock = BLI_findlink(&node->inputs, nimf->active_input);
int totinputs = BLI_listbase_count(&node->inputs);
-
+
if (!sock)
return 0;
-
+
if (nimf->active_input == totinputs - 1)
--nimf->active_input;
-
+
/* free format data */
MEM_freeN(sock->storage);
-
+
nodeRemoveSocket(ntree, node, sock);
return 1;
}
@@ -175,7 +175,7 @@ static void init_output_file(const bContext *C, PointerRNA *ptr)
NodeImageMultiFile *nimf = MEM_callocN(sizeof(NodeImageMultiFile), "node image multi file");
ImageFormatData *format = NULL;
node->storage = nimf;
-
+
if (scene) {
RenderData *rd = &scene->r;
@@ -184,7 +184,7 @@ static void init_output_file(const bContext *C, PointerRNA *ptr)
if (BKE_imtype_is_movie(nimf->format.imtype)) {
nimf->format.imtype = R_IMF_IMTYPE_OPENEXR;
}
-
+
format = &nimf->format;
}
else
@@ -197,21 +197,21 @@ static void init_output_file(const bContext *C, PointerRNA *ptr)
static void free_output_file(bNode *node)
{
bNodeSocket *sock;
-
+
/* free storage data in sockets */
for (sock = node->inputs.first; sock; sock = sock->next) {
MEM_freeN(sock->storage);
}
-
+
MEM_freeN(node->storage);
}
static void copy_output_file(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, bNode *src_node)
{
bNodeSocket *src_sock, *dest_sock;
-
+
dest_node->storage = MEM_dupallocN(src_node->storage);
-
+
/* duplicate storage data in sockets */
for (src_sock = src_node->inputs.first, dest_sock = dest_node->inputs.first; src_sock && dest_sock; src_sock = src_sock->next, dest_sock = dest_sock->next) {
dest_sock->storage = MEM_dupallocN(src_sock->storage);
@@ -222,7 +222,7 @@ static void update_output_file(bNodeTree *ntree, bNode *node)
{
bNodeSocket *sock, *sock_next;
PointerRNA ptr;
-
+
/* XXX fix for #36706: remove invalid sockets added with bpy API.
* This is not ideal, but prevents crashes from missing storage.
* FileOutput node needs a redesign to support this properly.
@@ -237,9 +237,9 @@ static void update_output_file(bNodeTree *ntree, bNode *node)
sock_next = sock->next;
nodeRemoveSocket(ntree, node, sock);
}
-
+
cmp_node_update_default(ntree, node);
-
+
/* automatically update the socket type based on linked input */
for (sock = node->inputs.first; sock; sock = sock->next) {
if (sock->link) {
diff --git a/source/blender/nodes/composite/nodes/node_composite_premulkey.c b/source/blender/nodes/composite/nodes/node_composite_premulkey.c
index b786728de53..60f3b2bbf63 100644
--- a/source/blender/nodes/composite/nodes/node_composite_premulkey.c
+++ b/source/blender/nodes/composite/nodes/node_composite_premulkey.c
@@ -4,24 +4,24 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
+ *
* The Original Code is Copyright (C) 2006 Blender Foundation.
* All rights reserved.
- *
+ *
* The Original Code is: all of this file.
- *
+ *
* Contributor(s): none yet.
- *
+ *
* ***** END GPL LICENSE BLOCK *****
*/
diff --git a/source/blender/nodes/composite/nodes/node_composite_rgb.c b/source/blender/nodes/composite/nodes/node_composite_rgb.c
index 8a0618eccf4..2c397d21f7b 100644
--- a/source/blender/nodes/composite/nodes/node_composite_rgb.c
+++ b/source/blender/nodes/composite/nodes/node_composite_rgb.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_rotate.c b/source/blender/nodes/composite/nodes/node_composite_rotate.c
index 31f3fff200f..0d268766aae 100644
--- a/source/blender/nodes/composite/nodes/node_composite_rotate.c
+++ b/source/blender/nodes/composite/nodes/node_composite_rotate.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c
index 58ffaf0b103..3c0ab9bf4b1 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c
index 92ea6c4871a..7269cef0754 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c
index 27b1fff321e..3f7bea5b837 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c
index c7226d0261d..076378e49c0 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_setalpha.c b/source/blender/nodes/composite/nodes/node_composite_setalpha.c
index 71ece989e82..2c4568cb623 100644
--- a/source/blender/nodes/composite/nodes/node_composite_setalpha.c
+++ b/source/blender/nodes/composite/nodes/node_composite_setalpha.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c
index c3eb44281f5..f7008bc9ae4 100644
--- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c
+++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -33,6 +33,7 @@
#include "node_composite_util.h"
#include "BKE_image.h"
+#include "BKE_global.h"
/* **************** SPLIT VIEWER ******************** */
static bNodeSocketTemplate cmp_node_splitviewer_in[] = {
@@ -49,8 +50,8 @@ static void node_composit_init_splitviewer(bNodeTree *UNUSED(ntree), bNode *node
iuser->fie_ima = 2;
iuser->ok = 1;
node->custom1 = 50; /* default 50% split */
-
- node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+
+ node->id = (ID *)BKE_image_verify_viewer(G.main, IMA_TYPE_COMPOSITE, "Viewer Node");
}
void register_node_type_cmp_splitviewer(void)
diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c
index 00791c278ae..16f5d340ddd 100644
--- a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c
+++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -50,9 +50,9 @@ static void init(const bContext *C, PointerRNA *ptr)
{
bNode *node = ptr->data;
Scene *scene = CTX_data_scene(C);
-
+
node->id = (ID *)scene->clip;
-
+
/* default to bilinear, see node_sampler_type_items in rna_nodetree.c */
node->custom1 = 1;
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_sunbeams.c b/source/blender/nodes/composite/nodes/node_composite_sunbeams.c
index 4d937d63b75..4761228f724 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sunbeams.c
+++ b/source/blender/nodes/composite/nodes/node_composite_sunbeams.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_texture.c b/source/blender/nodes/composite/nodes/node_composite_texture.c
index d2ab2af1347..8198717a870 100644
--- a/source/blender/nodes/composite/nodes/node_composite_texture.c
+++ b/source/blender/nodes/composite/nodes/node_composite_texture.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_tonemap.c b/source/blender/nodes/composite/nodes/node_composite_tonemap.c
index b622418d519..3f116efc8cc 100644
--- a/source/blender/nodes/composite/nodes/node_composite_tonemap.c
+++ b/source/blender/nodes/composite/nodes/node_composite_tonemap.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_translate.c b/source/blender/nodes/composite/nodes/node_composite_translate.c
index c03a0f1cc89..bfcfa955512 100644
--- a/source/blender/nodes/composite/nodes/node_composite_translate.c
+++ b/source/blender/nodes/composite/nodes/node_composite_translate.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c
index 707f1d22efd..16fc98a5e85 100644
--- a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c
+++ b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -77,10 +77,10 @@ static bNodeSocketTemplate cmp_node_rgbtobw_out[] = {
void register_node_type_cmp_rgbtobw(void)
{
static bNodeType ntype;
-
+
cmp_node_type_base(&ntype, CMP_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, cmp_node_rgbtobw_in, cmp_node_rgbtobw_out);
node_type_size_preset(&ntype, NODE_SIZE_SMALL);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_value.c b/source/blender/nodes/composite/nodes/node_composite_value.c
index daec4c3fbca..33fddbe4471 100644
--- a/source/blender/nodes/composite/nodes/node_composite_value.c
+++ b/source/blender/nodes/composite/nodes/node_composite_value.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c
index 38b360c97cf..a4a56d95a48 100644
--- a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c
index 4b96270d36c..f82b0d7206a 100644
--- a/source/blender/nodes/composite/nodes/node_composite_viewer.c
+++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -33,6 +33,7 @@
#include "node_composite_util.h"
#include "BKE_image.h"
+#include "BKE_global.h"
/* **************** VIEWER ******************** */
@@ -52,8 +53,8 @@ static void node_composit_init_viewer(bNodeTree *UNUSED(ntree), bNode *node)
iuser->ok = 1;
node->custom3 = 0.5f;
node->custom4 = 0.5f;
-
- node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+
+ node->id = (ID *)BKE_image_verify_viewer(G.main, IMA_TYPE_COMPOSITE, "Viewer Node");
}
void register_node_type_cmp_viewer(void)
diff --git a/source/blender/nodes/composite/nodes/node_composite_zcombine.c b/source/blender/nodes/composite/nodes/node_composite_zcombine.c
index edfc6822aaf..dd8f555fcd9 100644
--- a/source/blender/nodes/composite/nodes/node_composite_zcombine.c
+++ b/source/blender/nodes/composite/nodes/node_composite_zcombine.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index 736f17f1d70..4a47bf7035c 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -98,16 +98,16 @@ int nodeGroupPoll(bNodeTree *nodetree, bNodeTree *grouptree)
{
bNode *node;
int valid = 1;
-
+
/* unspecified node group, generally allowed
* (if anything, should be avoided on operator level)
*/
if (grouptree == NULL)
return 1;
-
+
if (nodetree == grouptree)
return 0;
-
+
for (node = grouptree->nodes.first; node; node = node->next) {
if (node->typeinfo->poll_instance && !node->typeinfo->poll_instance(node, nodetree)) {
valid = 0;
@@ -121,27 +121,27 @@ int nodeGroupPoll(bNodeTree *nodetree, bNodeTree *grouptree)
static bNodeSocket *group_verify_socket(bNodeTree *ntree, bNode *gnode, bNodeSocket *iosock, ListBase *verify_lb, int in_out)
{
bNodeSocket *sock;
-
+
for (sock = verify_lb->first; sock; sock = sock->next) {
if (STREQ(sock->identifier, iosock->identifier))
break;
}
if (sock) {
strcpy(sock->name, iosock->name);
-
+
if (iosock->typeinfo->interface_verify_socket)
iosock->typeinfo->interface_verify_socket(ntree, iosock, gnode, sock, "interface");
}
else {
sock = nodeAddSocket(ntree, gnode, in_out, iosock->idname, iosock->identifier, iosock->name);
-
+
if (iosock->typeinfo->interface_init_socket)
iosock->typeinfo->interface_init_socket(ntree, iosock, gnode, sock, "interface");
}
-
+
/* remove from list temporarily, to distinguish from orphaned sockets */
BLI_remlink(verify_lb, sock);
-
+
return sock;
}
@@ -150,9 +150,9 @@ static void group_verify_socket_list(bNodeTree *ntree, bNode *gnode,
ListBase *iosock_lb, ListBase *verify_lb, int in_out)
{
bNodeSocket *iosock, *sock, *nextsock;
-
+
/* step by step compare */
-
+
iosock = iosock_lb->first;
for (; iosock; iosock = iosock->next) {
/* abusing new_sock pointer for verification here! only used inside this function */
@@ -195,9 +195,9 @@ static void node_frame_init(bNodeTree *UNUSED(ntree), bNode *node)
{
NodeFrame *data = (NodeFrame *)MEM_callocN(sizeof(NodeFrame), "frame node storage");
node->storage = data;
-
+
data->flag |= NODE_FRAME_SHRINK;
-
+
data->label_size = 20;
}
@@ -211,7 +211,7 @@ void register_node_type_frame(void)
node_type_storage(ntype, "NodeFrame", node_free_standard_storage, node_copy_standard_storage);
node_type_size(ntype, 150, 100, 0);
node_type_compatibility(ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
-
+
ntype->needs_free = 1;
nodeRegisterType(ntype);
}
@@ -251,11 +251,11 @@ void register_node_type_reroute(void)
{
/* frame type is used for all tree types, needs dynamic allocation */
bNodeType *ntype = MEM_callocN(sizeof(bNodeType), "frame node type");
-
+
node_type_base(ntype, NODE_REROUTE, "Reroute", NODE_CLASS_LAYOUT, 0);
node_type_init(ntype, node_reroute_init);
node_type_internal_links(ntype, node_reroute_update_internal_links);
-
+
ntype->needs_free = 1;
nodeRegisterType(ntype);
}
@@ -267,14 +267,14 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
bNodeLink *link;
int type = SOCK_FLOAT;
const char *type_idname = nodeStaticSocketType(type, PROP_NONE);
-
+
/* XXX it would be a little bit more efficient to restrict actual updates
* to rerout nodes connected to an updated node, but there's no reliable flag
* to indicate updated nodes (node->update is not set on linking).
*/
-
+
node->done = 1;
-
+
/* recursive update */
for (link = ntree->links.first; link; link = link->next) {
bNode *fromnode = link->fromnode;
@@ -283,7 +283,7 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
continue;
if (nodeLinkIsHidden(link))
continue;
-
+
if (flag & REFINE_FORWARD) {
if (tonode == node && fromnode->type == NODE_REROUTE && !fromnode->done)
node_reroute_inherit_type_recursive(ntree, fromnode, REFINE_FORWARD);
@@ -293,7 +293,7 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
node_reroute_inherit_type_recursive(ntree, tonode, REFINE_BACKWARD);
}
}
-
+
/* determine socket type from unambiguous input/output connection if possible */
if (input->limit == 1 && input->link) {
type = input->link->fromsock->type;
@@ -303,7 +303,7 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
type = output->link->tosock->type;
type_idname = nodeStaticSocketType(type, PROP_NONE);
}
-
+
if (input->type != type) {
bNodeSocket *ninput = nodeAddSocket(ntree, node, SOCK_IN, type_idname, "input", "Input");
for (link = ntree->links.first; link; link = link->next) {
@@ -314,7 +314,7 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
}
nodeRemoveSocket(ntree, node, input);
}
-
+
if (output->type != type) {
bNodeSocket *noutput = nodeAddSocket(ntree, node, SOCK_OUT, type_idname, "output", "Output");
for (link = ntree->links.first; link; link = link->next) {
@@ -324,7 +324,7 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
}
nodeRemoveSocket(ntree, node, output);
}
-
+
nodeUpdateInternalLinks(ntree, node);
}
@@ -334,11 +334,11 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
void ntree_update_reroute_nodes(bNodeTree *ntree)
{
bNode *node;
-
+
/* clear tags */
for (node = ntree->nodes.first; node; node = node->next)
node->done = 0;
-
+
for (node = ntree->nodes.first; node; node = node->next)
if (node->type == NODE_REROUTE && !node->done)
node_reroute_inherit_type_recursive(ntree, node, REFINE_FORWARD | REFINE_BACKWARD);
@@ -411,7 +411,7 @@ void node_group_input_verify(bNodeTree *ntree, bNode *node, ID *id)
if (id == (ID *)ntree) {
/* value_in_out inverted for interface nodes to get correct socket value_property */
group_verify_socket_list(ntree, node, &ntree->inputs, &node->outputs, SOCK_OUT);
-
+
/* add virtual extension socket */
nodeAddSocket(ntree, node, SOCK_OUT, "NodeSocketVirtual", "__extend__", "");
}
@@ -426,23 +426,23 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node)
* so they can be recreated after verification.
*/
ListBase tmplinks;
-
+
/* find links from the extension socket and store them */
BLI_listbase_clear(&tmplinks);
for (link = ntree->links.first; link; link = linknext) {
linknext = link->next;
if (nodeLinkIsHidden(link))
continue;
-
+
if (link->fromsock == extsock) {
bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "temporary link");
*tlink = *link;
BLI_addtail(&tmplinks, tlink);
-
+
nodeRemLink(ntree, link);
}
}
-
+
/* find valid link to expose */
exposelink = NULL;
for (link = tmplinks.first; link; link = link->next) {
@@ -456,22 +456,22 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node)
break;
}
}
-
+
if (exposelink) {
bNodeSocket *gsock, *newsock;
-
+
gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->tonode, exposelink->tosock);
-
+
node_group_input_verify(ntree, node, (ID *)ntree);
newsock = node_group_input_find_socket(node, gsock->identifier);
-
+
/* redirect links from the extension socket */
for (link = tmplinks.first; link; link = link->next) {
nodeAddLink(ntree, node, newsock, link->tonode, link->tosock);
}
-
+
}
-
+
BLI_freelistN(&tmplinks);
}
@@ -479,13 +479,13 @@ void register_node_type_group_input(void)
{
/* used for all tree types, needs dynamic allocation */
bNodeType *ntype = MEM_callocN(sizeof(bNodeType), "node type");
-
+
node_type_base(ntype, NODE_GROUP_INPUT, "Group Input", NODE_CLASS_INTERFACE, 0);
node_type_size(ntype, 140, 80, 400);
node_type_init(ntype, node_group_input_init);
node_type_update(ntype, node_group_input_update, node_group_input_verify);
node_type_compatibility(ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
-
+
ntype->needs_free = 1;
nodeRegisterType(ntype);
}
@@ -510,7 +510,7 @@ void node_group_output_verify(bNodeTree *ntree, bNode *node, ID *id)
if (id == (ID *)ntree) {
/* value_in_out inverted for interface nodes to get correct socket value_property */
group_verify_socket_list(ntree, node, &ntree->outputs, &node->inputs, SOCK_IN);
-
+
/* add virtual extension socket */
nodeAddSocket(ntree, node, SOCK_IN, "NodeSocketVirtual", "__extend__", "");
}
@@ -525,23 +525,23 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node)
* so they can be recreated after verification.
*/
ListBase tmplinks;
-
+
/* find links to the extension socket and store them */
BLI_listbase_clear(&tmplinks);
for (link = ntree->links.first; link; link = linknext) {
linknext = link->next;
if (nodeLinkIsHidden(link))
continue;
-
+
if (link->tosock == extsock) {
bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "temporary link");
*tlink = *link;
BLI_addtail(&tmplinks, tlink);
-
+
nodeRemLink(ntree, link);
}
}
-
+
/* find valid link to expose */
exposelink = NULL;
for (link = tmplinks.first; link; link = link->next) {
@@ -555,22 +555,22 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node)
break;
}
}
-
+
if (exposelink) {
bNodeSocket *gsock, *newsock;
-
+
/* XXX what if connecting virtual to virtual socket?? */
gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->fromnode, exposelink->fromsock);
-
+
node_group_output_verify(ntree, node, (ID *)ntree);
newsock = node_group_output_find_socket(node, gsock->identifier);
-
+
/* redirect links to the extension socket */
for (link = tmplinks.first; link; link = link->next) {
nodeAddLink(ntree, link->fromnode, link->fromsock, node, newsock);
}
}
-
+
BLI_freelistN(&tmplinks);
}
@@ -578,13 +578,13 @@ void register_node_type_group_output(void)
{
/* used for all tree types, needs dynamic allocation */
bNodeType *ntype = MEM_callocN(sizeof(bNodeType), "node type");
-
+
node_type_base(ntype, NODE_GROUP_OUTPUT, "Group Output", NODE_CLASS_INTERFACE, 0);
node_type_size(ntype, 140, 80, 400);
node_type_init(ntype, node_group_output_init);
node_type_update(ntype, node_group_output_update, node_group_output_verify);
node_type_compatibility(ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
-
+
ntype->needs_free = 1;
nodeRegisterType(ntype);
}
diff --git a/source/blender/nodes/intern/node_common.h b/source/blender/nodes/intern/node_common.h
index df3937f5a3e..edc1f19f554 100644
--- a/source/blender/nodes/intern/node_common.h
+++ b/source/blender/nodes/intern/node_common.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c
index ac4031f4932..3708a7663ed 100644
--- a/source/blender/nodes/intern/node_exec.c
+++ b/source/blender/nodes/intern/node_exec.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -61,14 +61,14 @@ bNodeStack *node_get_socket_stack(bNodeStack *stack, bNodeSocket *sock)
void node_get_stack(bNode *node, bNodeStack *stack, bNodeStack **in, bNodeStack **out)
{
bNodeSocket *sock;
-
+
/* build pointer stack */
if (in) {
for (sock = node->inputs.first; sock; sock = sock->next) {
*(in++) = node_get_socket_stack(stack, sock);
}
}
-
+
if (out) {
for (sock = node->outputs.first; sock; sock = sock->next) {
*(out++) = node_get_socket_stack(stack, sock);
@@ -127,13 +127,13 @@ static struct bNodeStack *setup_stack(bNodeStack *stack, bNodeTree *ntree, bNode
bNodeStack *ns = node_get_socket_stack(stack, sock);
if (!ns)
return NULL;
-
+
/* don't mess with remote socket stacks, these are initialized by other nodes! */
if (sock->link)
return ns;
-
+
ns->sockettype = sock->type;
-
+
switch (sock->type) {
case SOCK_FLOAT:
ns->vec[0] = node_socket_get_float(ntree, node, sock);
@@ -145,7 +145,7 @@ static struct bNodeStack *setup_stack(bNodeStack *stack, bNodeTree *ntree, bNode
node_socket_get_color(ntree, node, sock, ns->vec);
break;
}
-
+
return ns;
}
@@ -161,29 +161,29 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context, bNodeTree *ntree, bNo
bNode **nodelist;
int totnodes, n;
/* XXX texnodes have threading issues with muting, have to disable it there ... */
-
+
/* ensure all sock->link pointers and node levels are correct */
ntreeUpdateTree(G.main, ntree);
-
+
/* get a dependency-sorted list of nodes */
ntreeGetDependencyList(ntree, &nodelist, &totnodes);
-
+
/* XXX could let callbacks do this for specialized data */
exec = MEM_callocN(sizeof(bNodeTreeExec), "node tree execution data");
/* backpointer to node tree */
exec->nodetree = ntree;
-
+
/* set stack indices */
index = 0;
for (n = 0; n < totnodes; ++n) {
node = nodelist[n];
-
+
node->stack_index = index;
-
+
/* init node socket stack indexes */
for (sock = node->inputs.first; sock; sock = sock->next)
node_init_input_index(sock, &index);
-
+
if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) {
for (sock = node->outputs.first; sock; sock = sock->next)
node_init_output_index(sock, &index, &node->internal_links);
@@ -193,48 +193,48 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context, bNodeTree *ntree, bNo
node_init_output_index(sock, &index, NULL);
}
}
-
+
/* allocated exec data pointers for nodes */
exec->totnodes = totnodes;
exec->nodeexec = MEM_callocN(exec->totnodes * sizeof(bNodeExec), "node execution data");
/* allocate data pointer for node stack */
exec->stacksize = index;
exec->stack = MEM_callocN(exec->stacksize * sizeof(bNodeStack), "bNodeStack");
-
+
/* all non-const results are considered inputs */
for (n = 0; n < exec->stacksize; ++n)
exec->stack[n].hasinput = 1;
-
+
/* prepare all nodes for execution */
for (n = 0, nodeexec = exec->nodeexec; n < totnodes; ++n, ++nodeexec) {
node = nodeexec->node = nodelist[n];
nodeexec->freeexecfunc = node->typeinfo->freeexecfunc;
-
+
/* tag inputs */
for (sock = node->inputs.first; sock; sock = sock->next) {
/* disable the node if an input link is invalid */
if (sock->link && !(sock->link->flag & NODE_LINK_VALID))
node->need_exec = 0;
-
+
ns = setup_stack(exec->stack, ntree, node, sock);
if (ns)
ns->hasoutput = 1;
}
-
+
/* tag all outputs */
for (sock = node->outputs.first; sock; sock = sock->next) {
/* ns = */ setup_stack(exec->stack, ntree, node, sock);
}
-
+
nodekey = BKE_node_instance_key(parent_key, ntree, node);
nodeexec->data.preview = context->previews ? BKE_node_instance_hash_lookup(context->previews, nodekey) : NULL;
if (node->typeinfo->initexecfunc)
nodeexec->data.data = node->typeinfo->initexecfunc(context, node, nodekey);
}
-
+
if (nodelist)
MEM_freeN(nodelist);
-
+
return exec;
}
@@ -242,18 +242,18 @@ void ntree_exec_end(bNodeTreeExec *exec)
{
bNodeExec *nodeexec;
int n;
-
+
if (exec->stack)
MEM_freeN(exec->stack);
-
+
for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) {
if (nodeexec->freeexecfunc)
nodeexec->freeexecfunc(nodeexec->data.data);
}
-
+
if (exec->nodeexec)
MEM_freeN(exec->nodeexec);
-
+
MEM_freeN(exec);
}
@@ -263,14 +263,14 @@ bNodeThreadStack *ntreeGetThreadStack(bNodeTreeExec *exec, int thread)
{
ListBase *lb = &exec->threadstack[thread];
bNodeThreadStack *nts;
-
+
for (nts = lb->first; nts; nts = nts->next) {
if (!nts->used) {
nts->used = true;
break;
}
}
-
+
if (!nts) {
nts = MEM_callocN(sizeof(bNodeThreadStack), "bNodeThreadStack");
nts->stack = MEM_dupallocN(exec->stack);
@@ -293,9 +293,9 @@ bool ntreeExecThreadNodes(bNodeTreeExec *exec, bNodeThreadStack *nts, void *call
bNodeExec *nodeexec;
bNode *node;
int n;
-
+
/* nodes are presorted, so exec is in order of list */
-
+
for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) {
node = nodeexec->node;
if (node->need_exec) {
@@ -308,7 +308,7 @@ bool ntreeExecThreadNodes(bNodeTreeExec *exec, bNodeThreadStack *nts, void *call
node->typeinfo->execfunc(callerdata, thread, node, &nodeexec->data, nsin, nsout);
}
}
-
+
/* signal to that all went OK, for render */
return true;
}
diff --git a/source/blender/nodes/intern/node_exec.h b/source/blender/nodes/intern/node_exec.h
index a0023d02295..6771df76bf9 100644
--- a/source/blender/nodes/intern/node_exec.h
+++ b/source/blender/nodes/intern/node_exec.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -51,17 +51,17 @@ struct bNodeStack;
typedef struct bNodeExec {
struct bNode *node; /* backpointer to node */
bNodeExecData data;
-
+
NodeFreeExecFunction freeexecfunc; /* free function, stored in exec itself to avoid dangling node pointer access */
} bNodeExec;
/* Execution Data for each instance of node tree execution */
typedef struct bNodeTreeExec {
struct bNodeTree *nodetree; /* backpointer to node tree */
-
+
int totnodes; /* total node count */
struct bNodeExec *nodeexec; /* per-node execution data */
-
+
int stacksize;
struct bNodeStack *stack; /* socket data stack */
/* only used by material and texture trees to keep one stack for each thread */
diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c
index e1d17003ba4..23ba51bbe10 100644
--- a/source/blender/nodes/intern/node_socket.c
+++ b/source/blender/nodes/intern/node_socket.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -52,9 +52,9 @@ struct Main;
struct bNodeSocket *node_add_socket_from_template(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocketTemplate *stemp, int in_out)
{
bNodeSocket *sock = nodeAddStaticSocket(ntree, node, in_out, stemp->type, stemp->subtype, stemp->identifier, stemp->name);
-
+
sock->flag |= stemp->flag;
-
+
/* initialize default_value */
switch (stemp->type) {
case SOCK_FLOAT:
@@ -99,14 +99,14 @@ struct bNodeSocket *node_add_socket_from_template(struct bNodeTree *ntree, struc
break;
}
}
-
+
return sock;
}
static bNodeSocket *verify_socket_template(bNodeTree *ntree, bNode *node, int in_out, ListBase *socklist, bNodeSocketTemplate *stemp)
{
bNodeSocket *sock;
-
+
for (sock = socklist->first; sock; sock = sock->next) {
if (STREQLEN(sock->name, stemp->name, NODE_MAXSTR))
break;
@@ -127,7 +127,7 @@ static bNodeSocket *verify_socket_template(bNodeTree *ntree, bNode *node, int in
/* remove the new socket from the node socket list first,
* will be added back after verification. */
BLI_remlink(socklist, sock);
-
+
return sock;
}
@@ -135,7 +135,7 @@ static void verify_socket_template_list(bNodeTree *ntree, bNode *node, int in_ou
{
bNodeSocket *sock, *nextsock;
bNodeSocketTemplate *stemp;
-
+
/* no inputs anymore? */
if (stemp_first == NULL) {
for (sock = (bNodeSocket *)socklist->first; sock; sock = nextsock) {
@@ -155,7 +155,7 @@ static void verify_socket_template_list(bNodeTree *ntree, bNode *node, int in_ou
nextsock = sock->next;
nodeRemoveSocket(ntree, node, sock);
}
-
+
/* and we put back the verified sockets */
stemp = stemp_first;
if (socklist->first) {
@@ -199,10 +199,10 @@ void node_socket_init_default_value(bNodeSocket *sock)
{
int type = sock->typeinfo->type;
int subtype = sock->typeinfo->subtype;
-
+
if (sock->default_value)
return; /* already initialized */
-
+
switch (type) {
case SOCK_FLOAT:
{
@@ -211,7 +211,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
dval->value = 0.0f;
dval->min = -FLT_MAX;
dval->max = FLT_MAX;
-
+
sock->default_value = dval;
break;
}
@@ -222,7 +222,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
dval->value = 0;
dval->min = INT_MIN;
dval->max = INT_MAX;
-
+
sock->default_value = dval;
break;
}
@@ -230,7 +230,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
{
bNodeSocketValueBoolean *dval = MEM_callocN(sizeof(bNodeSocketValueBoolean), "node socket value bool");
dval->value = false;
-
+
sock->default_value = dval;
break;
}
@@ -242,7 +242,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
copy_v3_v3(dval->value, default_value);
dval->min = -FLT_MAX;
dval->max = FLT_MAX;
-
+
sock->default_value = dval;
break;
}
@@ -251,7 +251,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
static float default_value[] = { 0.0f, 0.0f, 0.0f, 1.0f };
bNodeSocketValueRGBA *dval = MEM_callocN(sizeof(bNodeSocketValueRGBA), "node socket value color");
copy_v4_v4(dval->value, default_value);
-
+
sock->default_value = dval;
break;
}
@@ -260,7 +260,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
bNodeSocketValueString *dval = MEM_callocN(sizeof(bNodeSocketValueString), "node socket value string");
dval->subtype = subtype;
dval->value[0] = '\0';
-
+
sock->default_value = dval;
break;
}
@@ -272,12 +272,12 @@ void node_socket_copy_default_value(bNodeSocket *to, const bNodeSocket *from)
/* sanity check */
if (to->type != from->type)
return;
-
+
/* make sure both exist */
if (!from->default_value)
return;
node_socket_init_default_value(to);
-
+
switch (from->typeinfo->type) {
case SOCK_FLOAT:
{
@@ -330,7 +330,7 @@ static void standard_node_socket_interface_init_socket(bNodeTree *UNUSED(ntree),
{
/* initialize the type value */
sock->type = sock->typeinfo->type;
-
+
/* XXX socket interface 'type' value is not used really,
* but has to match or the copy function will bail out
*/
@@ -345,12 +345,12 @@ static void standard_node_socket_interface_verify_socket(bNodeTree *UNUSED(ntree
/* sanity check */
if (sock->type != stemp->typeinfo->type)
return;
-
+
/* make sure both exist */
if (!stemp->default_value)
return;
node_socket_init_default_value(sock);
-
+
switch (stemp->typeinfo->type) {
case SOCK_FLOAT:
{
@@ -389,65 +389,65 @@ static void standard_node_socket_interface_from_socket(bNodeTree *UNUSED(ntree),
static bNodeSocketType *make_standard_socket_type(int type, int subtype)
{
extern void ED_init_standard_node_socket_type(bNodeSocketType *);
-
+
const char *socket_idname = nodeStaticSocketType(type, subtype);
const char *interface_idname = nodeStaticSocketInterfaceType(type, subtype);
bNodeSocketType *stype;
StructRNA *srna;
-
+
stype = MEM_callocN(sizeof(bNodeSocketType), "node socket C type");
BLI_strncpy(stype->idname, socket_idname, sizeof(stype->idname));
-
+
/* set the RNA type
* uses the exact same identifier as the socket type idname */
srna = stype->ext_socket.srna = RNA_struct_find(socket_idname);
BLI_assert(srna != NULL);
/* associate the RNA type with the socket type */
RNA_struct_blender_type_set(srna, stype);
-
+
/* set the interface RNA type */
srna = stype->ext_interface.srna = RNA_struct_find(interface_idname);
BLI_assert(srna != NULL);
/* associate the RNA type with the socket type */
RNA_struct_blender_type_set(srna, stype);
-
+
/* extra type info for standard socket types */
stype->type = type;
stype->subtype = subtype;
-
+
/* XXX bad-level call! needed for setting draw callbacks */
ED_init_standard_node_socket_type(stype);
-
+
stype->interface_init_socket = standard_node_socket_interface_init_socket;
stype->interface_from_socket = standard_node_socket_interface_from_socket;
stype->interface_verify_socket = standard_node_socket_interface_verify_socket;
-
+
return stype;
}
static bNodeSocketType *make_socket_type_virtual(void)
{
extern void ED_init_node_socket_type_virtual(bNodeSocketType *);
-
+
const char *socket_idname = "NodeSocketVirtual";
bNodeSocketType *stype;
StructRNA *srna;
-
+
stype = MEM_callocN(sizeof(bNodeSocketType), "node socket C type");
BLI_strncpy(stype->idname, socket_idname, sizeof(stype->idname));
-
+
/* set the RNA type
* uses the exact same identifier as the socket type idname */
srna = stype->ext_socket.srna = RNA_struct_find(socket_idname);
BLI_assert(srna != NULL);
/* associate the RNA type with the socket type */
RNA_struct_blender_type_set(srna, stype);
-
+
/* extra type info for standard socket types */
stype->type = SOCK_CUSTOM;
-
+
ED_init_node_socket_type_virtual(stype);
-
+
return stype;
}
@@ -455,21 +455,21 @@ static bNodeSocketType *make_socket_type_virtual(void)
void register_standard_node_socket_types(void)
{
/* draw callbacks are set in drawnode.c to avoid bad-level calls */
-
+
nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_NONE));
nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_UNSIGNED));
nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_PERCENTAGE));
nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_FACTOR));
nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_ANGLE));
nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_TIME));
-
+
nodeRegisterSocketType(make_standard_socket_type(SOCK_INT, PROP_NONE));
nodeRegisterSocketType(make_standard_socket_type(SOCK_INT, PROP_UNSIGNED));
nodeRegisterSocketType(make_standard_socket_type(SOCK_INT, PROP_PERCENTAGE));
nodeRegisterSocketType(make_standard_socket_type(SOCK_INT, PROP_FACTOR));
-
+
nodeRegisterSocketType(make_standard_socket_type(SOCK_BOOLEAN, PROP_NONE));
-
+
nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_NONE));
nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_TRANSLATION));
nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_DIRECTION));
@@ -477,12 +477,12 @@ void register_standard_node_socket_types(void)
nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_ACCELERATION));
nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_EULER));
nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_XYZ));
-
+
nodeRegisterSocketType(make_standard_socket_type(SOCK_RGBA, PROP_NONE));
-
+
nodeRegisterSocketType(make_standard_socket_type(SOCK_STRING, PROP_NONE));
-
+
nodeRegisterSocketType(make_standard_socket_type(SOCK_SHADER, PROP_NONE));
-
+
nodeRegisterSocketType(make_socket_type_virtual());
}
diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c
index 9f04c12fb5e..19529794c7c 100644
--- a/source/blender/nodes/intern/node_util.c
+++ b/source/blender/nodes/intern/node_util.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -165,10 +165,10 @@ static int node_count_links(bNodeTree *ntree, bNodeSocket *sock)
static bNodeSocket *node_find_linkable_socket(bNodeTree *ntree, bNode *node, bNodeSocket *cur)
{
/* link swapping: try to find a free slot with a matching name */
-
+
bNodeSocket *first = cur->in_out == SOCK_IN ? node->inputs.first : node->outputs.first;
bNodeSocket *sock;
-
+
sock = cur->next ? cur->next : first; /* wrap around the list end */
while (sock != cur) {
if (!nodeSocketIsHidden(sock) && node_link_socket_match(sock, cur)) {
@@ -177,7 +177,7 @@ static bNodeSocket *node_find_linkable_socket(bNodeTree *ntree, bNode *node, bNo
if (link_count + 1 <= sock->limit)
return sock; /* found a valid free socket we can swap to */
}
-
+
sock = sock->next ? sock->next : first; /* wrap around the list end */
}
return NULL;
@@ -187,18 +187,18 @@ void node_insert_link_default(bNodeTree *ntree, bNode *node, bNodeLink *link)
{
bNodeSocket *sock = link->tosock;
bNodeLink *tlink, *tlink_next;
-
+
/* inputs can have one link only, outputs can have unlimited links */
if (node != link->tonode)
return;
-
+
for (tlink = ntree->links.first; tlink; tlink = tlink_next) {
bNodeSocket *new_sock;
tlink_next = tlink->next;
-
+
if (sock != tlink->tosock)
continue;
-
+
new_sock = node_find_linkable_socket(ntree, node, sock);
if (new_sock && new_sock != sock) {
/* redirect existing link */
@@ -287,12 +287,12 @@ static bNodeSocket *select_internal_link_input(bNode *node, bNodeSocket *output)
int i;
int sel_priority = -1;
bool sel_is_linked = false;
-
+
for (input = node->inputs.first, i = 0; input; input = input->next, ++i) {
int priority = node_datatype_priority(input->type, output->type);
bool is_linked = (input->link != NULL);
bool preferred;
-
+
if (nodeSocketIsHidden(input) || /* ignore hidden sockets */
input->flag & SOCK_NO_INTERNAL_LINK || /* ignore if input is not allowed for internal connections */
priority < 0 || /* ignore incompatible types */
@@ -300,18 +300,18 @@ static bNodeSocket *select_internal_link_input(bNode *node, bNodeSocket *output)
{
continue;
}
-
+
/* determine if this input is preferred over the currently selected */
preferred = (priority > sel_priority) || /* prefer higher datatype priority */
(is_linked && !sel_is_linked); /* prefer linked over unlinked */
-
+
if (preferred) {
selected = input;
sel_is_linked = is_linked;
sel_priority = priority;
}
}
-
+
return selected;
}
@@ -319,29 +319,29 @@ void node_update_internal_links_default(bNodeTree *ntree, bNode *node)
{
bNodeLink *link;
bNodeSocket *output, *input;
-
+
/* sanity check */
if (!ntree)
return;
-
+
/* use link pointer as a tag for handled sockets (for outputs is unused anyway) */
for (output = node->outputs.first; output; output = output->next)
output->link = NULL;
-
+
for (link = ntree->links.first; link; link = link->next) {
if (nodeLinkIsHidden(link))
continue;
-
+
output = link->fromsock;
if (link->fromnode != node || output->link)
continue;
if (nodeSocketIsHidden(output) || output->flag & SOCK_NO_INTERNAL_LINK)
continue;
output->link = link; /* not really used, just for tagging handled sockets */
-
+
/* look for suitable input */
input = select_internal_link_input(node, output);
-
+
if (input) {
bNodeLink *ilink = MEM_callocN(sizeof(bNodeLink), "internal node link");
ilink->fromnode = node;
@@ -353,7 +353,7 @@ void node_update_internal_links_default(bNodeTree *ntree, bNode *node)
BLI_addtail(&node->internal_links, ilink);
}
}
-
+
/* clean up */
for (output = node->outputs.first; output; output = output->next)
output->link = NULL;
diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h
index b4437dfcb78..5c0e53c2399 100644
--- a/source/blender/nodes/intern/node_util.h
+++ b/source/blender/nodes/intern/node_util.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index bad80450f80..9d77d45dedf 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -82,7 +82,7 @@ static void shader_get_from_context(const bContext *C, bNodeTreeType *UNUSED(tre
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
-
+
if (snode->shaderfrom == SNODE_SHADER_OBJECT) {
if (ob) {
*r_from = &ob->id;
@@ -136,11 +136,11 @@ static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCa
static void localize(bNodeTree *localtree, bNodeTree *UNUSED(ntree))
{
bNode *node, *node_next;
-
+
/* replace muted nodes and reroute nodes by internal links */
for (node = localtree->nodes.first; node; node = node_next) {
node_next = node->next;
-
+
if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) {
nodeInternalRelink(localtree, node);
nodeFreeNode(localtree, node);
@@ -153,7 +153,7 @@ static void local_sync(bNodeTree *localtree, bNodeTree *ntree)
BKE_node_preview_sync_tree(ntree, localtree);
}
-static void local_merge(bNodeTree *localtree, bNodeTree *ntree)
+static void local_merge(Main *UNUSED(bmain), bNodeTree *localtree, bNodeTree *ntree)
{
BKE_node_preview_merge_tree(ntree, localtree, true);
}
@@ -161,9 +161,9 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree)
static void update(bNodeTree *ntree)
{
ntreeSetOutput(ntree);
-
+
ntree_update_reroute_nodes(ntree);
-
+
if (ntree->update & NTREE_UPDATE_NODES) {
/* clean up preview cache, in case nodes have been removed */
BKE_node_preview_remove_unused(ntree);
@@ -175,13 +175,13 @@ bNodeTreeType *ntreeType_Shader;
void register_node_tree_type_sh(void)
{
bNodeTreeType *tt = ntreeType_Shader = MEM_callocN(sizeof(bNodeTreeType), "shader node tree type");
-
+
tt->type = NTREE_SHADER;
strcpy(tt->idname, "ShaderNodeTree");
- strcpy(tt->ui_name, "Shader");
+ strcpy(tt->ui_name, "Shader Editor");
tt->ui_icon = 0; /* defined in drawnode.c */
strcpy(tt->ui_description, "Shader nodes");
-
+
tt->foreach_nodeclass = foreach_nodeclass;
tt->localize = localize;
tt->local_sync = local_sync;
@@ -189,9 +189,9 @@ void register_node_tree_type_sh(void)
tt->update = update;
tt->poll = shader_tree_poll;
tt->get_from_context = shader_get_from_context;
-
+
tt->ext.srna = &RNA_ShaderNodeTree;
-
+
ntreeTypeAdd(tt);
}
@@ -622,19 +622,19 @@ bNodeTreeExec *ntreeShaderBeginExecTree_internal(bNodeExecContext *context, bNod
{
bNodeTreeExec *exec;
bNode *node;
-
+
/* ensures only a single output node is enabled */
ntreeSetOutput(ntree);
-
+
/* common base initialization */
exec = ntree_exec_begin(context, ntree, parent_key);
-
+
/* allocate the thread stack listbase array */
exec->threadstack = MEM_callocN(BLENDER_MAX_THREADS * sizeof(ListBase), "thread stack array");
-
+
for (node = exec->nodetree->nodes.first; node; node = node->next)
node->need_exec = 1;
-
+
return exec;
}
@@ -642,22 +642,22 @@ bNodeTreeExec *ntreeShaderBeginExecTree(bNodeTree *ntree)
{
bNodeExecContext context;
bNodeTreeExec *exec;
-
+
/* XXX hack: prevent exec data from being generated twice.
* this should be handled by the renderer!
*/
if (ntree->execdata)
return ntree->execdata;
-
+
context.previews = ntree->previews;
-
+
exec = ntreeShaderBeginExecTree_internal(&context, ntree, NODE_INSTANCE_KEY_BASE);
-
+
/* XXX this should not be necessary, but is still used for cmp/sha/tex nodes,
* which only store the ntree pointer. Should be fixed at some point!
*/
ntree->execdata = exec;
-
+
return exec;
}
@@ -665,18 +665,18 @@ void ntreeShaderEndExecTree_internal(bNodeTreeExec *exec)
{
bNodeThreadStack *nts;
int a;
-
+
if (exec->threadstack) {
for (a = 0; a < BLENDER_MAX_THREADS; a++) {
for (nts = exec->threadstack[a].first; nts; nts = nts->next)
if (nts->stack) MEM_freeN(nts->stack);
BLI_freelistN(&exec->threadstack[a]);
}
-
+
MEM_freeN(exec->threadstack);
exec->threadstack = NULL;
}
-
+
ntree_exec_end(exec);
}
@@ -686,7 +686,7 @@ void ntreeShaderEndExecTree(bNodeTreeExec *exec)
/* exec may get freed, so assign ntree */
bNodeTree *ntree = exec->nodetree;
ntreeShaderEndExecTree_internal(exec);
-
+
/* XXX clear nodetree backpointer to exec data, same problem as noted in ntreeBeginExecTree */
ntree->execdata = NULL;
}
@@ -699,7 +699,7 @@ bool ntreeShaderExecTree(bNodeTree *ntree, int thread)
bNodeThreadStack *nts = NULL;
bNodeTreeExec *exec = ntree->execdata;
int compat;
-
+
/* ensure execdata is only initialized once */
if (!exec) {
BLI_thread_lock(LOCK_NODES);
@@ -709,11 +709,11 @@ bool ntreeShaderExecTree(bNodeTree *ntree, int thread)
exec = ntree->execdata;
}
-
+
nts = ntreeGetThreadStack(exec, thread);
compat = ntreeExecThreadNodes(exec, nts, &scd, thread);
ntreeReleaseThreadStack(nts);
-
+
/* if compat is zero, it has been using non-compatible nodes */
return compat;
}
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c
index 69a69c156e3..a4b2c155675 100644
--- a/source/blender/nodes/shader/node_shader_util.c
+++ b/source/blender/nodes/shader/node_shader_util.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -45,7 +45,7 @@ int sh_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass, short flag)
{
node_type_base(ntype, type, name, nclass, flag);
-
+
ntype->poll = sh_node_poll_default;
ntype->insert_link = node_insert_link_default;
ntype->update_internal_links = node_update_internal_links_default;
@@ -56,11 +56,11 @@ void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, shor
void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)
{
const float *from = ns->vec;
-
+
if (type_in == SOCK_FLOAT) {
if (ns->sockettype == SOCK_FLOAT)
*in = *from;
- else
+ else
*in = (from[0] + from[1] + from[2]) / 3.0f;
}
else if (type_in == SOCK_VECTOR) {
@@ -94,7 +94,7 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)
void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
{
memset(gs, 0, sizeof(*gs));
-
+
if (ns == NULL) {
/* node_get_stack() will generate NULL bNodeStack pointers for unknown/unsuported types of sockets... */
zero_v4(gs->vec);
@@ -107,7 +107,7 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
else {
nodestack_get_vec(gs->vec, type, ns);
gs->link = ns->data;
-
+
if (type == SOCK_FLOAT)
gs->type = GPU_FLOAT;
else if (type == SOCK_VECTOR)
@@ -140,10 +140,10 @@ static void gpu_stack_from_data_list(GPUNodeStack *gs, ListBase *sockets, bNodeS
{
bNodeSocket *sock;
int i;
-
+
for (sock = sockets->first, i = 0; sock; sock = sock->next, i++)
node_gpu_stack_from_data(&gs[i], sock->type, ns[i]);
-
+
gs[i].end = true;
}
@@ -192,7 +192,7 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree)
if (activetexnode)
return activetexnode;
-
+
if (hasgroup) {
/* node active texture node in this tree, look inside groups */
for (node = ntree->nodes.first; node; node = node->next) {
@@ -203,7 +203,7 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree)
}
}
}
-
+
return inactivenode;
}
@@ -222,7 +222,7 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs, sh
for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) {
node = nodeexec->node;
-
+
do_it = false;
/* for groups, only execute outputs for edited group */
if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) {
diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h
index 44c1ab7ca95..46f99d98026 100644
--- a/source/blender/nodes/shader/node_shader_util.h
+++ b/source/blender/nodes/shader/node_shader_util.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
index cb4335ca9a7..f835822469c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
+++ b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_blackbody.c b/source/blender/nodes/shader/nodes/node_shader_blackbody.c
index 28019651926..7bdce077977 100644
--- a/source/blender/nodes/shader/nodes/node_shader_blackbody.c
+++ b/source/blender/nodes/shader/nodes/node_shader_blackbody.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_brightness.c b/source/blender/nodes/shader/nodes/node_shader_brightness.c
index 457708405af..bb95ed2d32c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_brightness.c
+++ b/source/blender/nodes/shader/nodes/node_shader_brightness.c
@@ -4,24 +4,24 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
+ *
* The Original Code is Copyright (C) 2006 Blender Foundation.
* All rights reserved.
- *
+ *
* The Original Code is: all of this file.
- *
+ *
* Contributor(s): none yet.
- *
+ *
* ***** END GPL LICENSE BLOCK *****
*/
@@ -50,13 +50,13 @@ static int gpu_shader_brightcontrast(GPUMaterial *mat, bNode *node, bNodeExecDat
void register_node_type_sh_brightcontrast(void)
{
static bNodeType ntype;
-
+
sh_node_type_base(&ntype, SH_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, 0);
node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_brightcontrast_in, sh_node_brightcontrast_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
node_type_gpu(&ntype, gpu_shader_brightcontrast);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
index 1537e07ca16..3d3173f6862 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
index ad9e7730ad1..eb5bd7b57d8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c
index b8078ac60ac..9db0e3284b9 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
index 9dbe3361e8b..949f6a90de5 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
index 28941fbd662..0470795930b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
index f6f6da524d5..7757ae38efd 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c
index 76afe935433..441a7c50305 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
index 6d61f3f7473..fec106a131a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_bump.c b/source/blender/nodes/shader/nodes/node_shader_bump.c
index 84481a50993..6274d132bc7 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bump.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bump.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -31,7 +31,7 @@
#include "node_shader_util.h"
-/* **************** BUMP ******************** */
+/* **************** BUMP ******************** */
static bNodeSocketTemplate sh_node_bump_in[] = {
{ SOCK_FLOAT, 1, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{ SOCK_FLOAT, 1, N_("Distance"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
diff --git a/source/blender/nodes/shader/nodes/node_shader_camera.c b/source/blender/nodes/shader/nodes/node_shader_camera.c
index 245360e789f..dfd712afb29 100644
--- a/source/blender/nodes/shader/nodes/node_shader_camera.c
+++ b/source/blender/nodes/shader/nodes/node_shader_camera.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c
index 796193a564e..24de03dbda4 100644
--- a/source/blender/nodes/shader/nodes/node_shader_common.c
+++ b/source/blender/nodes/shader/nodes/node_shader_common.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -50,7 +50,7 @@ static void copy_stack(bNodeStack *to, bNodeStack *from)
copy_v4_v4(to->vec, from->vec);
to->data = from->data;
to->datatype = from->datatype;
-
+
/* tag as copy to prevent freeing */
to->is_copy = 1;
}
@@ -63,7 +63,7 @@ static void move_stack(bNodeStack *to, bNodeStack *from)
to->data = from->data;
to->datatype = from->datatype;
to->is_copy = from->is_copy;
-
+
from->data = NULL;
from->is_copy = 0;
}
@@ -75,20 +75,20 @@ static void *group_initexec(bNodeExecContext *context, bNode *node, bNodeInstanc
{
bNodeTree *ngroup = (bNodeTree *)node->id;
bNodeTreeExec *exec;
-
+
if (!ngroup)
return NULL;
-
+
/* initialize the internal node tree execution */
exec = ntreeShaderBeginExecTree_internal(context, ngroup, key);
-
+
return exec;
}
static void group_freeexec(void *nodedata)
{
bNodeTreeExec *gexec = (bNodeTreeExec *)nodedata;
-
+
if (gexec)
ntreeShaderEndExecTree_internal(gexec);
}
@@ -102,7 +102,7 @@ static void group_copy_inputs(bNode *gnode, bNodeStack **in, bNodeStack *gstack)
bNodeSocket *sock;
bNodeStack *ns;
int a;
-
+
for (node = ngroup->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP_INPUT) {
for (sock = node->outputs.first, a = 0; sock; sock = sock->next, ++a) {
@@ -123,7 +123,7 @@ static void group_move_outputs(bNode *gnode, bNodeStack **out, bNodeStack *gstac
bNodeSocket *sock;
bNodeStack *ns;
int a;
-
+
for (node = ngroup->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP_OUTPUT && (node->flag & NODE_DO_OUTPUT)) {
for (sock = node->inputs.first, a = 0; sock; sock = sock->next, ++a) {
@@ -140,10 +140,10 @@ static void group_execute(void *data, int thread, struct bNode *node, bNodeExecD
{
bNodeTreeExec *exec = execdata->data;
bNodeThreadStack *nts;
-
+
if (!exec)
return;
-
+
/* XXX same behavior as trunk: all nodes inside group are executed.
* it's stupid, but just makes it work. compo redesign will do this better.
*/
@@ -152,13 +152,13 @@ static void group_execute(void *data, int thread, struct bNode *node, bNodeExecD
for (inode = exec->nodetree->nodes.first; inode; inode = inode->next)
inode->need_exec = 1;
}
-
+
nts = ntreeGetThreadStack(exec, thread);
-
+
group_copy_inputs(node, in, nts->stack);
ntreeExecThreadNodes(exec, nts, data, thread);
group_move_outputs(node, out, nts->stack);
-
+
ntreeReleaseThreadStack(nts);
}
@@ -169,7 +169,7 @@ static void group_gpu_copy_inputs(bNode *gnode, GPUNodeStack *in, bNodeStack *gs
bNodeSocket *sock;
bNodeStack *ns;
int a;
-
+
for (node = ngroup->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP_INPUT) {
for (sock = node->outputs.first, a = 0; sock; sock = sock->next, ++a) {
@@ -192,7 +192,7 @@ static void group_gpu_move_outputs(bNode *gnode, GPUNodeStack *out, bNodeStack *
bNodeSocket *sock;
bNodeStack *ns;
int a;
-
+
for (node = ngroup->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP_OUTPUT && (node->flag & NODE_DO_OUTPUT)) {
for (sock = node->inputs.first, a = 0; sock; sock = sock->next, ++a) {
@@ -210,10 +210,10 @@ static void group_gpu_move_outputs(bNode *gnode, GPUNodeStack *out, bNodeStack *
static int gpu_group_execute(GPUMaterial *mat, bNode *node, bNodeExecData *execdata, GPUNodeStack *in, GPUNodeStack *out)
{
bNodeTreeExec *exec = execdata->data;
-
+
if (!node->id)
return 0;
-
+
group_gpu_copy_inputs(node, in, exec->stack);
#if 0 /* XXX NODE_GROUP_EDIT is deprecated, depends on node space */
ntreeExecGPUNodes(exec, mat, (node->flag & NODE_GROUP_EDIT));
@@ -221,14 +221,14 @@ static int gpu_group_execute(GPUMaterial *mat, bNode *node, bNodeExecData *execd
ntreeExecGPUNodes(exec, mat, 0, NODE_NEW_SHADING | NODE_OLD_SHADING);
#endif
group_gpu_move_outputs(node, out, exec->stack);
-
+
return 1;
}
void register_node_type_sh_group(void)
{
static bNodeType ntype;
-
+
/* NB: cannot use sh_node_type_base for node group, because it would map the node type
* to the shared NODE_GROUP integer type id.
*/
@@ -241,7 +241,7 @@ void register_node_type_sh_group(void)
ntype.ext.srna = RNA_struct_find("ShaderNodeGroup");
BLI_assert(ntype.ext.srna != NULL);
RNA_struct_blender_type_set(ntype.ext.srna, &ntype);
-
+
node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, NULL);
node_type_size(&ntype, 140, 60, 400);
@@ -249,6 +249,6 @@ void register_node_type_sh_group(void)
node_type_update(&ntype, NULL, node_group_verify);
node_type_exec(&ntype, group_initexec, group_freeexec, group_execute);
node_type_gpu(&ntype, gpu_group_execute);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c
index ceba8fd1248..4f3dc92ad02 100644
--- a/source/blender/nodes/shader/nodes/node_shader_curves.c
+++ b/source/blender/nodes/shader/nodes/node_shader_curves.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -48,7 +48,7 @@ static bNodeSocketTemplate sh_node_curve_vec_out[] = {
static void node_shader_exec_curve_vec(void *UNUSED(data), int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
{
float vec[3];
-
+
/* stack order input: vec */
/* stack order output: vec */
nodestack_get_vec(vec, SOCK_VECTOR, in[1]);
@@ -102,7 +102,7 @@ static void node_shader_exec_curve_rgb(void *UNUSED(data), int UNUSED(thread), b
{
float vec[3];
float fac;
-
+
/* stack order input: vec */
/* stack order output: vec */
nodestack_get_vec(&fac, SOCK_FLOAT, in[0]);
diff --git a/source/blender/nodes/shader/nodes/node_shader_emission.c b/source/blender/nodes/shader/nodes/node_shader_emission.c
index 0901e8204f8..f2ab4a119da 100644
--- a/source/blender/nodes/shader/nodes/node_shader_emission.c
+++ b/source/blender/nodes/shader/nodes/node_shader_emission.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_fresnel.c b/source/blender/nodes/shader/nodes/node_shader_fresnel.c
index 30bdf0b0f42..072abed6c16 100644
--- a/source/blender/nodes/shader/nodes/node_shader_fresnel.c
+++ b/source/blender/nodes/shader/nodes/node_shader_fresnel.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -47,7 +47,7 @@ static int node_shader_gpu_fresnel(GPUMaterial *mat, bNode *node, bNodeExecData
else {
GPU_link(mat, "direction_transform_m4v3", in[1].link, GPU_builtin(GPU_VIEW_MATRIX), &in[1].link);
}
-
+
return GPU_stack_link(mat, node, "node_fresnel", in, out, GPU_builtin(GPU_VIEW_POSITION));
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_gamma.c b/source/blender/nodes/shader/nodes/node_shader_gamma.c
index 1aebfbe5888..e536d198ed0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_gamma.c
+++ b/source/blender/nodes/shader/nodes/node_shader_gamma.c
@@ -4,24 +4,24 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
+ *
* The Original Code is Copyright (C) 2006 Blender Foundation.
* All rights reserved.
- *
+ *
* The Original Code is: all of this file.
- *
+ *
* Contributor(s): none yet.
- *
+ *
* ***** END GPL LICENSE BLOCK *****
*/
@@ -60,7 +60,7 @@ static int node_shader_gpu_gamma(GPUMaterial *mat, bNode *node, bNodeExecData *U
void register_node_type_sh_gamma(void)
{
static bNodeType ntype;
-
+
sh_node_type_base(&ntype, SH_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR, 0);
node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_gamma_in, sh_node_gamma_out);
@@ -68,6 +68,6 @@ void register_node_type_sh_gamma(void)
node_type_storage(&ntype, "", NULL, NULL);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_gamma);
node_type_gpu(&ntype, node_shader_gpu_gamma);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_geometry.c b/source/blender/nodes/shader/nodes/node_shader_geometry.c
index 6647f27e5c9..2af3e3e259a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_geometry.c
+++ b/source/blender/nodes/shader/nodes/node_shader_geometry.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_hair_info.c b/source/blender/nodes/shader/nodes/node_shader_hair_info.c
index 6a15c59aa5b..13259dce9d1 100644
--- a/source/blender/nodes/shader/nodes/node_shader_hair_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_hair_info.c
@@ -37,6 +37,11 @@ static bNodeSocketTemplate outputs[] = {
{ -1, 0, "" }
};
+static int node_shader_gpu_hair_info(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+{
+ return GPU_stack_link(mat, node, "node_hair_info", in, out);
+}
+
/* node type definition */
void register_node_type_sh_hair_info(void)
{
@@ -47,6 +52,7 @@ void register_node_type_sh_hair_info(void)
node_type_socket_templates(&ntype, NULL, outputs);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
+ node_type_gpu(&ntype, node_shader_gpu_hair_info);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_holdout.c b/source/blender/nodes/shader/nodes/node_shader_holdout.c
index ac28a2fa11b..42563f2bfa8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_holdout.c
+++ b/source/blender/nodes/shader/nodes/node_shader_holdout.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
index 9eaa0c9f91c..07f1e9e3233 100644
--- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
+++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -52,7 +52,7 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat
{
if (fac != 0.0f && (hue != 0.5f || sat != 1.0f || val != 1.0f)) {
float col[3], hsv[3], mfac = 1.0f - fac;
-
+
rgb_to_hsv(in[0], in[1], in[2], hsv, hsv + 1, hsv + 2);
hsv[0] += (hue - 0.5f);
if (hsv[0] > 1.0f) hsv[0] -= 1.0f; else if (hsv[0] < 0.0f) hsv[0] += 1.0f;
diff --git a/source/blender/nodes/shader/nodes/node_shader_invert.c b/source/blender/nodes/shader/nodes/node_shader_invert.c
index 6a54733006d..b1805946f65 100644
--- a/source/blender/nodes/shader/nodes/node_shader_invert.c
+++ b/source/blender/nodes/shader/nodes/node_shader_invert.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -34,7 +34,7 @@
-/* **************** INVERT ******************** */
+/* **************** INVERT ******************** */
static bNodeSocketTemplate sh_node_invert_in[] = {
{ SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{ SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
@@ -46,18 +46,18 @@ static bNodeSocketTemplate sh_node_invert_out[] = {
{ -1, 0, "" }
};
-static void node_shader_exec_invert(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in,
+static void node_shader_exec_invert(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in,
bNodeStack **out)
{
float col[3], icol[3], fac;
nodestack_get_vec(&fac, SOCK_FLOAT, in[0]);
nodestack_get_vec(col, SOCK_VECTOR, in[1]);
-
+
icol[0] = 1.0f - col[0];
icol[1] = 1.0f - col[1];
icol[2] = 1.0f - col[2];
-
+
/* if fac, blend result against original input */
if (fac < 1.0f)
interp_v3_v3v3(out[0]->vec, col, icol, fac);
diff --git a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
index 87ed85ffa99..53bfad833eb 100644
--- a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
+++ b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c
index a51e4dc720f..56b790b3835 100644
--- a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c
+++ b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_light_path.c b/source/blender/nodes/shader/nodes/node_shader_light_path.c
index be6db9c8269..0e87da2215b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_light_path.c
+++ b/source/blender/nodes/shader/nodes/node_shader_light_path.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c
index 7f25b298cb2..fdbf23618ef 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mapping.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -56,7 +56,7 @@ static void node_shader_exec_mapping(void *UNUSED(data), int UNUSED(thread), bNo
{
TexMapping *texmap = node->storage;
float *vec = out[0]->vec;
-
+
/* stack order input: vector */
/* stack order output: vector */
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
@@ -105,7 +105,7 @@ static int gpu_shader_mapping(GPUMaterial *mat, bNode *node, bNodeExecData *UNUS
void register_node_type_sh_mapping(void)
{
static bNodeType ntype;
-
+
sh_node_type_base(&ntype, SH_NODE_MAPPING, "Mapping", NODE_CLASS_OP_VECTOR, 0);
node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_mapping_in, sh_node_mapping_out);
@@ -114,6 +114,6 @@ void register_node_type_sh_mapping(void)
node_type_storage(&ntype, "TexMapping", node_free_standard_storage, node_copy_standard_storage);
node_type_exec(&ntype, node_shader_initexec_mapping, NULL, node_shader_exec_mapping);
node_type_gpu(&ntype, gpu_shader_mapping);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c
index f36310f4d00..bf594325119 100644
--- a/source/blender/nodes/shader/nodes/node_shader_math.c
+++ b/source/blender/nodes/shader/nodes/node_shader_math.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -33,7 +33,7 @@
#include "node_shader_util.h"
-/* **************** SCALAR MATH ******************** */
+/* **************** SCALAR MATH ******************** */
static bNodeSocketTemplate sh_node_math_in[] = {
{ SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
@@ -45,15 +45,15 @@ static bNodeSocketTemplate sh_node_math_out[] = {
{ -1, 0, "" }
};
-static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
+static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
{
float a, b, r = 0.0f;
-
+
nodestack_get_vec(&a, SOCK_FLOAT, in[0]);
nodestack_get_vec(&b, SOCK_FLOAT, in[1]);
-
+
switch (node->custom1) {
-
+
case NODE_MATH_ADD:
r = a + b;
break;
@@ -147,7 +147,7 @@ static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode
}
else {
float y_mod_1 = fabsf(fmodf(b, 1.0f));
-
+
/* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */
if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) {
r = powf(a, floorf(b + 0.5f));
diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
index cca0a1e0561..054b02b220d 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -54,7 +54,7 @@ static void node_shader_exec_mix_rgb(void *UNUSED(data), int UNUSED(thread), bNo
nodestack_get_vec(&fac, SOCK_FLOAT, in[0]);
CLAMP(fac, 0.0f, 1.0f);
-
+
nodestack_get_vec(col, SOCK_VECTOR, in[1]);
nodestack_get_vec(vec, SOCK_VECTOR, in[2]);
diff --git a/source/blender/nodes/shader/nodes/node_shader_mix_shader.c b/source/blender/nodes/shader/nodes/node_shader_mix_shader.c
index 5ac576004be..892b41ab058 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mix_shader.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mix_shader.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.c b/source/blender/nodes/shader/nodes/node_shader_normal.c
index 7033eeaead0..265f6ac6fab 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal.c
+++ b/source/blender/nodes/shader/nodes/node_shader_normal.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -48,12 +48,12 @@ static bNodeSocketTemplate sh_node_normal_out[] = {
static void node_shader_exec_normal(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
{
float vec[3];
-
+
/* stack order input: normal */
/* stack order output: normal, value */
-
+
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
-
+
/* render normals point inside... the widget points outside */
out[1]->vec[0] = -dot_v3v3(vec, out[0]->vec);
}
@@ -67,12 +67,12 @@ static int gpu_shader_normal(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSE
void register_node_type_sh_normal(void)
{
static bNodeType ntype;
-
+
sh_node_type_base(&ntype, SH_NODE_NORMAL, "Normal", NODE_CLASS_OP_VECTOR, 0);
node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_normal_in, sh_node_normal_out);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_normal);
node_type_gpu(&ntype, gpu_shader_normal);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_object_info.c b/source/blender/nodes/shader/nodes/node_shader_object_info.c
index 25c9bd77250..cba4f2854f8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_object_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_object_info.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
index c1903facb8c..b08a4b4ff57 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.c b/source/blender/nodes/shader/nodes/node_shader_output_material.c
index e901e7c4590..05837e79f82 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_material.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_material.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_world.c b/source/blender/nodes/shader/nodes/node_shader_output_world.c
index abab4fc351a..2c115bdda20 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_world.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_world.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -56,7 +56,7 @@ void register_node_type_sh_output_world(void)
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
node_type_gpu(&ntype, node_shader_gpu_output_world);
-
+
/* Do not allow muting output node. */
node_type_internal_links(&ntype, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb.c b/source/blender/nodes/shader/nodes/node_shader_rgb.c
index b9c051c0441..dce7e5354e1 100644
--- a/source/blender/nodes/shader/nodes/node_shader_rgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_rgb.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_script.c b/source/blender/nodes/shader/nodes/node_shader_script.c
index f640dd5ea13..888e502a7f6 100644
--- a/source/blender/nodes/shader/nodes/node_shader_script.c
+++ b/source/blender/nodes/shader/nodes/node_shader_script.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c
index d031a2e412f..148f8e99c8f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -48,7 +48,7 @@ static void node_shader_exec_sephsv(void *UNUSED(data), int UNUSED(thread), bNod
{
float col[3];
nodestack_get_vec(col, SOCK_VECTOR, in[0]);
-
+
rgb_to_hsv(col[0], col[1], col[2],
&out[0]->vec[0], &out[1]->vec[0], &out[2]->vec[0]);
}
@@ -90,7 +90,7 @@ static void node_shader_exec_combhsv(void *UNUSED(data), int UNUSED(thread), bNo
nodestack_get_vec(&h, SOCK_FLOAT, in[0]);
nodestack_get_vec(&s, SOCK_FLOAT, in[1]);
nodestack_get_vec(&v, SOCK_FLOAT, in[2]);
-
+
hsv_to_rgb(h, s, v, &out[0]->vec[0], &out[0]->vec[1], &out[0]->vec[2]);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
index 682909edb0e..bd914399a28 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -48,7 +48,7 @@ static void node_shader_exec_seprgb(void *UNUSED(data), int UNUSED(thread), bNod
{
float col[3];
nodestack_get_vec(col, SOCK_VECTOR, in[0]);
-
+
out[0]->vec[0] = col[0];
out[1]->vec[0] = col[1];
out[2]->vec[0] = col[2];
@@ -92,7 +92,7 @@ static void node_shader_exec_combrgb(void *UNUSED(data), int UNUSED(thread), bNo
nodestack_get_vec(&r, SOCK_FLOAT, in[0]);
nodestack_get_vec(&g, SOCK_FLOAT, in[1]);
nodestack_get_vec(&b, SOCK_FLOAT, in[2]);
-
+
out[0]->vec[0] = r;
out[0]->vec[1] = g;
out[0]->vec[2] = b;
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c b/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c
index fce62f730b9..ba8bf565ca8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_squeeze.c b/source/blender/nodes/shader/nodes/node_shader_squeeze.c
index 2a1fbc2d02d..e46494efd34 100644
--- a/source/blender/nodes/shader/nodes/node_shader_squeeze.c
+++ b/source/blender/nodes/shader/nodes/node_shader_squeeze.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -32,7 +32,7 @@
#include "node_shader_util.h"
-/* **************** VALUE SQUEEZE ******************** */
+/* **************** VALUE SQUEEZE ******************** */
static bNodeSocketTemplate sh_node_squeeze_in[] = {
{ SOCK_FLOAT, 1, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("Width"), 1.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
@@ -48,7 +48,7 @@ static bNodeSocketTemplate sh_node_squeeze_out[] = {
static void node_shader_exec_squeeze(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
{
float vec[3];
-
+
nodestack_get_vec(vec, SOCK_FLOAT, in[0]);
nodestack_get_vec(vec + 1, SOCK_FLOAT, in[1]);
nodestack_get_vec(vec + 2, SOCK_FLOAT, in[2]);
diff --git a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
index 4b4f08a8b56..7bf44792e7f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
+++ b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c
index 20ea162d98f..67fe6d08ffd 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -54,7 +54,7 @@ static void node_shader_init_tex_brick(bNodeTree *UNUSED(ntree), bNode *node)
NodeTexBrick *tex = MEM_callocN(sizeof(NodeTexBrick), "NodeTexBrick");
BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT);
BKE_texture_colormapping_default(&tex->base.color_mapping);
-
+
tex->offset = 0.5f;
tex->squash = 1.0f;
tex->offset_freq = 2;
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c
index 3dbf98a929c..633cc9a1d0e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
index 0cab9379364..360b28d768a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -49,7 +49,7 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat, bNode *node, bNodeExecDat
GPUMatType type = GPU_Material_get_type(mat);
GPU_link(mat, "generated_from_orco", orco, &orco);
-
+
if (type == GPU_MATERIAL_TYPE_WORLD) {
return GPU_stack_link(mat, node, "node_tex_coord_background", in, out,
GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
@@ -59,7 +59,7 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat, bNode *node, bNodeExecDat
else {
return GPU_stack_link(mat, node, "node_tex_coord", in, out,
GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
- GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
+ GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
GPU_builtin(GPU_CAMERA_TEXCO_FACTORS), orco, mtface);
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
index 8a65ee89ffc..d441a674838 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -66,20 +66,20 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, bNodeE
if (!in[0].link) {
GPUMatType type = GPU_Material_get_type(mat);
-
+
if (type == GPU_MATERIAL_TYPE_MESH)
in[0].link = GPU_builtin(GPU_VIEW_POSITION);
else
GPU_link(mat, "background_transform_to_world", GPU_builtin(GPU_VIEW_POSITION), &in[0].link);
}
-
+
node_shader_gpu_tex_mapping(mat, node, in, out);
if (tex->projection == SHD_PROJ_EQUIRECTANGULAR)
GPU_stack_link(mat, node, "node_tex_environment_equirectangular", in, out, GPU_image(ima, iuser, isdata));
else
GPU_stack_link(mat, node, "node_tex_environment_mirror_ball", in, out, GPU_image(ima, iuser, isdata));
-
+
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 &&
GPU_material_do_color_management(mat))
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c
index 13d3438587c..0721a24688f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
index 22f302a9c59..2c958c6478d 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c
index 7cd79067693..14e6cbf337e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
index e36b2d5b95b..48ab45895bc 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c
index 38b208fc876..2f6994c6533 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
index 7df6d34b756..8a17ee1e0d2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
index 30deb422e58..7f30d244da6 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c
index 356d2a78139..a9071fdbdd4 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
index 39598eb8675..a1879df3a18 100644
--- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -48,7 +48,7 @@ static void node_shader_exec_valtorgb(void *UNUSED(data), int UNUSED(thread), bN
{
/* stack order in: fac */
/* stack order out: col, alpha */
-
+
if (node->storage) {
float fac;
nodestack_get_vec(&fac, SOCK_FLOAT, in[0]);
diff --git a/source/blender/nodes/shader/nodes/node_shader_value.c b/source/blender/nodes/shader/nodes/node_shader_value.c
index 1e5bd8c5bff..a1b8717cebc 100644
--- a/source/blender/nodes/shader/nodes/node_shader_value.c
+++ b/source/blender/nodes/shader/nodes/node_shader_value.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_vectMath.c b/source/blender/nodes/shader/nodes/node_shader_vectMath.c
index f117adde98c..ca5291e6041 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vectMath.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vectMath.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -31,7 +31,7 @@
#include "node_shader_util.h"
-/* **************** VECTOR MATH ******************** */
+/* **************** VECTOR MATH ******************** */
static bNodeSocketTemplate sh_node_vect_math_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
{ SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
@@ -44,32 +44,32 @@ static bNodeSocketTemplate sh_node_vect_math_out[] = {
{ -1, 0, "" }
};
-static void node_shader_exec_vect_math(void *UNUSED(data), int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
-{
+static void node_shader_exec_vect_math(void *UNUSED(data), int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
+{
float vec1[3], vec2[3];
-
+
nodestack_get_vec(vec1, SOCK_VECTOR, in[0]);
nodestack_get_vec(vec2, SOCK_VECTOR, in[1]);
-
+
if (node->custom1 == 0) { /* Add */
out[0]->vec[0] = vec1[0] + vec2[0];
out[0]->vec[1] = vec1[1] + vec2[1];
out[0]->vec[2] = vec1[2] + vec2[2];
-
+
out[1]->vec[0] = (fabsf(out[0]->vec[0]) + fabsf(out[0]->vec[1]) + fabsf(out[0]->vec[2])) / 3.0f;
}
else if (node->custom1 == 1) { /* Subtract */
out[0]->vec[0] = vec1[0] - vec2[0];
out[0]->vec[1] = vec1[1] - vec2[1];
out[0]->vec[2] = vec1[2] - vec2[2];
-
+
out[1]->vec[0] = (fabsf(out[0]->vec[0]) + fabsf(out[0]->vec[1]) + fabsf(out[0]->vec[2])) / 3.0f;
}
else if (node->custom1 == 2) { /* Average */
out[0]->vec[0] = vec1[0] + vec2[0];
out[0]->vec[1] = vec1[1] + vec2[1];
out[0]->vec[2] = vec1[2] + vec2[2];
-
+
out[1]->vec[0] = normalize_v3(out[0]->vec);
}
else if (node->custom1 == 3) { /* Dot product */
@@ -79,7 +79,7 @@ static void node_shader_exec_vect_math(void *UNUSED(data), int UNUSED(thread), b
out[0]->vec[0] = (vec1[1] * vec2[2]) - (vec1[2] * vec2[1]);
out[0]->vec[1] = (vec1[2] * vec2[0]) - (vec1[0] * vec2[2]);
out[0]->vec[2] = (vec1[0] * vec2[1]) - (vec1[1] * vec2[0]);
-
+
out[1]->vec[0] = normalize_v3(out[0]->vec);
}
else if (node->custom1 == 5) { /* Normalize */
@@ -93,10 +93,10 @@ static void node_shader_exec_vect_math(void *UNUSED(data), int UNUSED(thread), b
out[0]->vec[1] = vec2[1];
out[0]->vec[2] = vec2[2];
}
-
+
out[1]->vec[0] = normalize_v3(out[0]->vec);
}
-
+
}
static int gpu_shader_vect_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
@@ -132,7 +132,7 @@ static int gpu_shader_vect_math(GPUMaterial *mat, bNode *node, bNodeExecData *UN
default:
return false;
}
-
+
return true;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
index 71bb88f892f..d0b16dd5886 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -28,10 +28,10 @@
/** \file blender/nodes/shader/nodes/node_shader_vectTransform.c
* \ingroup shdnodes
*/
-
+
#include "../node_shader_util.h"
-/* **************** Vector Transform ******************** */
+/* **************** Vector Transform ******************** */
static bNodeSocketTemplate sh_node_vect_transform_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
{ -1, 0, "" }
@@ -45,10 +45,10 @@ static bNodeSocketTemplate sh_node_vect_transform_out[] = {
static void node_shader_init_vect_transform(bNodeTree *UNUSED(ntree), bNode *node)
{
NodeShaderVectTransform *vect = MEM_callocN(sizeof(NodeShaderVectTransform), "NodeShaderVectTransform");
-
+
/* Convert World into Object Space per default */
vect->convert_to = 1;
-
+
node->storage = vect;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c b/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c
index dfd7154e6b8..80cc5a467a1 100644
--- a/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c
+++ b/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_wavelength.c b/source/blender/nodes/shader/nodes/node_shader_wavelength.c
index 182769e2b32..f903e314edf 100644
--- a/source/blender/nodes/shader/nodes/node_shader_wavelength.c
+++ b/source/blender/nodes/shader/nodes/node_shader_wavelength.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/shader/nodes/node_shader_wireframe.c b/source/blender/nodes/shader/nodes/node_shader_wireframe.c
index db15dd09f35..0b9f3ac347a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_wireframe.c
+++ b/source/blender/nodes/shader/nodes/node_shader_wireframe.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index cd7a3f6d9c2..551d955c70f 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -70,7 +70,7 @@ static void texture_get_from_context(
if (snode->texfrom == SNODE_TEX_BRUSH) {
struct Brush *brush = NULL;
-
+
if (ob && (ob->mode & OB_MODE_SCULPT))
brush = BKE_paint_brush(&scene->toolsettings->sculpt->paint);
else
@@ -119,11 +119,11 @@ static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCa
static void localize(bNodeTree *localtree, bNodeTree *UNUSED(ntree))
{
bNode *node, *node_next;
-
+
/* replace muted nodes and reroute nodes by internal links */
for (node = localtree->nodes.first; node; node = node_next) {
node_next = node->next;
-
+
if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) {
nodeInternalRelink(localtree, node);
nodeFreeNode(localtree, node);
@@ -141,7 +141,7 @@ static void local_sync(bNodeTree *localtree, bNodeTree *ntree)
BKE_node_preview_sync_tree(ntree, localtree);
}
-static void local_merge(bNodeTree *localtree, bNodeTree *ntree)
+static void local_merge(Main *UNUSED(bmain), bNodeTree *localtree, bNodeTree *ntree)
{
BKE_node_preview_merge_tree(ntree, localtree, true);
}
@@ -149,7 +149,7 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree)
static void update(bNodeTree *ntree)
{
ntree_update_reroute_nodes(ntree);
-
+
if (ntree->update & NTREE_UPDATE_NODES) {
/* clean up preview cache, in case nodes have been removed */
BKE_node_preview_remove_unused(ntree);
@@ -161,31 +161,31 @@ bNodeTreeType *ntreeType_Texture;
void register_node_tree_type_tex(void)
{
bNodeTreeType *tt = ntreeType_Texture = MEM_callocN(sizeof(bNodeTreeType), "texture node tree type");
-
+
tt->type = NTREE_TEXTURE;
strcpy(tt->idname, "TextureNodeTree");
- strcpy(tt->ui_name, "Texture");
+ strcpy(tt->ui_name, "Texture Editor");
tt->ui_icon = 0; /* defined in drawnode.c */
strcpy(tt->ui_description, "Texture nodes");
-
+
tt->foreach_nodeclass = foreach_nodeclass;
tt->update = update;
tt->localize = localize;
tt->local_sync = local_sync;
tt->local_merge = local_merge;
tt->get_from_context = texture_get_from_context;
-
+
tt->ext.srna = &RNA_TextureNodeTree;
-
+
ntreeTypeAdd(tt);
}
int ntreeTexTagAnimated(bNodeTree *ntree)
{
bNode *node;
-
+
if (ntree == NULL) return 0;
-
+
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == TEX_NODE_CURVE_TIME) {
nodeUpdate(ntree, node);
@@ -197,7 +197,7 @@ int ntreeTexTagAnimated(bNodeTree *ntree)
}
}
}
-
+
return 0;
}
@@ -205,16 +205,16 @@ bNodeTreeExec *ntreeTexBeginExecTree_internal(bNodeExecContext *context, bNodeTr
{
bNodeTreeExec *exec;
bNode *node;
-
+
/* common base initialization */
exec = ntree_exec_begin(context, ntree, parent_key);
-
+
/* allocate the thread stack listbase array */
exec->threadstack = MEM_callocN(BLENDER_MAX_THREADS * sizeof(ListBase), "thread stack array");
-
+
for (node = exec->nodetree->nodes.first; node; node = node->next)
node->need_exec = 1;
-
+
return exec;
}
@@ -222,22 +222,22 @@ bNodeTreeExec *ntreeTexBeginExecTree(bNodeTree *ntree)
{
bNodeExecContext context;
bNodeTreeExec *exec;
-
+
/* XXX hack: prevent exec data from being generated twice.
* this should be handled by the renderer!
*/
if (ntree->execdata)
return ntree->execdata;
-
+
context.previews = ntree->previews;
-
+
exec = ntreeTexBeginExecTree_internal(&context, ntree, NODE_INSTANCE_KEY_BASE);
-
+
/* XXX this should not be necessary, but is still used for cmp/sha/tex nodes,
* which only store the ntree pointer. Should be fixed at some point!
*/
ntree->execdata = exec;
-
+
return exec;
}
@@ -247,7 +247,7 @@ static void tex_free_delegates(bNodeTreeExec *exec)
bNodeThreadStack *nts;
bNodeStack *ns;
int th, a;
-
+
for (th = 0; th < BLENDER_MAX_THREADS; th++)
for (nts = exec->threadstack[th].first; nts; nts = nts->next)
for (ns = nts->stack, a = 0; a < exec->stacksize; a++, ns++)
@@ -259,20 +259,20 @@ void ntreeTexEndExecTree_internal(bNodeTreeExec *exec)
{
bNodeThreadStack *nts;
int a;
-
+
if (exec->threadstack) {
tex_free_delegates(exec);
-
+
for (a = 0; a < BLENDER_MAX_THREADS; a++) {
for (nts = exec->threadstack[a].first; nts; nts = nts->next)
if (nts->stack) MEM_freeN(nts->stack);
BLI_freelistN(&exec->threadstack[a]);
}
-
+
MEM_freeN(exec->threadstack);
exec->threadstack = NULL;
}
-
+
ntree_exec_end(exec);
}
@@ -282,7 +282,7 @@ void ntreeTexEndExecTree(bNodeTreeExec *exec)
/* exec may get freed, so assign ntree */
bNodeTree *ntree = exec->nodetree;
ntreeTexEndExecTree_internal(exec);
-
+
/* XXX clear nodetree backpointer to exec data, same problem as noted in ntreeBeginExecTree */
ntree->execdata = NULL;
}
@@ -318,7 +318,7 @@ int ntreeTexExecTree(
data.which_output = which_output;
data.cfra = cfra;
data.mtex = mtex;
-
+
/* ensure execdata is only initialized once */
if (!exec) {
BLI_thread_lock(LOCK_NODES);
@@ -328,7 +328,7 @@ int ntreeTexExecTree(
exec = nodes->execdata;
}
-
+
nts = ntreeGetThreadStack(exec, thread);
ntreeExecThreadNodes(exec, nts, &data, thread);
ntreeReleaseThreadStack(nts);
diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c
index 8cb61478c41..a6b0d060d93 100644
--- a/source/blender/nodes/texture/node_texture_util.c
+++ b/source/blender/nodes/texture/node_texture_util.c
@@ -58,7 +58,7 @@ int tex_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
void tex_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass, short flag)
{
node_type_base(ntype, type, name, nclass, flag);
-
+
ntype->poll = tex_node_poll_default;
ntype->insert_link = node_insert_link_default;
ntype->update_internal_links = node_update_internal_links_default;
@@ -80,7 +80,7 @@ static void tex_input(float *out, int sz, bNodeStack *in, TexParams *params, sho
TexDelegate *dg = in->data;
if (dg) {
tex_call_delegate(dg, in->vec, params, thread);
-
+
if (in->hasoutput && in->sockettype == SOCK_FLOAT)
in->vec[1] = in->vec[2] = in->vec[0];
}
@@ -95,12 +95,12 @@ void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread)
void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
{
tex_input(out, 4, in, params, thread);
-
+
if (in->hasoutput && in->sockettype == SOCK_FLOAT) {
out[1] = out[2] = out[0];
out[3] = 1;
}
-
+
if (in->hasoutput && in->sockettype == SOCK_VECTOR) {
out[0] = out[0] * 0.5f + 0.5f;
out[1] = out[1] * 0.5f + 0.5f;
@@ -132,7 +132,7 @@ void tex_do_preview(bNodePreview *preview, const float coord[2], const float col
if (preview) {
int xs = ((coord[0] + 1.0f) * 0.5f) * preview->xsize;
int ys = ((coord[1] + 1.0f) * 0.5f) * preview->ysize;
-
+
BKE_node_preview_set_pixel(preview, col, xs, ys, do_manage);
}
}
@@ -140,7 +140,7 @@ void tex_do_preview(bNodePreview *preview, const float coord[2], const float col
void tex_output(bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
{
TexDelegate *dg;
-
+
if (node->flag & NODE_MUTED) {
/* do not add a delegate if the node is muted */
return;
@@ -175,9 +175,9 @@ void ntreeTexCheckCyclics(struct bNodeTree *ntree)
}
else {
Tex *tex = (Tex *)node->id;
-
+
node->custom2 = 0;
-
+
node->custom1 = 1;
if (tex->use_nodes && tex->nodetree) {
ntreeTexCheckCyclics(tex->nodetree);
diff --git a/source/blender/nodes/texture/node_texture_util.h b/source/blender/nodes/texture/node_texture_util.h
index 82ba573425a..8662a8a0e82 100644
--- a/source/blender/nodes/texture/node_texture_util.h
+++ b/source/blender/nodes/texture/node_texture_util.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/nodes/texture/nodes/node_texture_at.c b/source/blender/nodes/texture/nodes/node_texture_at.c
index aafb9793d2c..690d87b42a9 100644
--- a/source/blender/nodes/texture/nodes/node_texture_at.c
+++ b/source/blender/nodes/texture/nodes/node_texture_at.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -48,7 +48,7 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **
TexParams np = *p;
float new_co[3];
np.co = new_co;
-
+
tex_input_vec(new_co, in[1], p, thread);
tex_input_rgba(out, in[0], &np, thread);
}
@@ -61,11 +61,11 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
void register_node_type_tex_at(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_AT, "At", NODE_CLASS_DISTORT, 0);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_size(&ntype, 140, 100, 320);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.c b/source/blender/nodes/texture/nodes/node_texture_bricks.c
index 02d4ddda47c..43af02acdf2 100644
--- a/source/blender/nodes/texture/nodes/node_texture_bricks.c
+++ b/source/blender/nodes/texture/nodes/node_texture_bricks.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -67,43 +67,43 @@ static float noise(int n) /* fast integer noise */
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
const float *co = p->co;
-
+
float x = co[0];
float y = co[1];
-
+
int bricknum, rownum;
float offset = 0;
float ins_x, ins_y;
float tint;
-
+
float bricks1[4];
float bricks2[4];
float mortar[4];
-
+
float mortar_thickness = tex_input_value(in[3], p, thread);
float bias = tex_input_value(in[4], p, thread);
float brick_width = tex_input_value(in[5], p, thread);
float row_height = tex_input_value(in[6], p, thread);
-
+
tex_input_rgba(bricks1, in[0], p, thread);
tex_input_rgba(bricks2, in[1], p, thread);
tex_input_rgba(mortar, in[2], p, thread);
-
+
rownum = (int)floor(y / row_height);
-
+
if (node->custom1 && node->custom2) {
brick_width *= ((int)(rownum) % node->custom2) ? 1.0f : node->custom4; /* squash */
offset = ((int)(rownum) % node->custom1) ? 0 : (brick_width * node->custom3); /* offset */
}
-
+
bricknum = (int)floor((x + offset) / brick_width);
-
+
ins_x = (x + offset) - brick_width * bricknum;
ins_y = y - row_height * rownum;
-
+
tint = noise((rownum << 16) + (bricknum & 0xFFFF)) + bias;
CLAMP(tint, 0.0f, 1.0f);
-
+
if (ins_x < mortar_thickness || ins_y < mortar_thickness ||
ins_x > (brick_width - mortar_thickness) ||
ins_y > (row_height - mortar_thickness))
@@ -124,12 +124,12 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
void register_node_type_tex_bricks(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_BRICKS, "Bricks", NODE_CLASS_PATTERN, NODE_PREVIEW);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, init);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_checker.c b/source/blender/nodes/texture/nodes/node_texture_checker.c
index c26a96c6a47..d7ad642d474 100644
--- a/source/blender/nodes/texture/nodes/node_texture_checker.c
+++ b/source/blender/nodes/texture/nodes/node_texture_checker.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -51,12 +51,12 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **
float y = p->co[1];
float z = p->co[2];
float sz = tex_input_value(in[2], p, thread);
-
+
/* 0.00001 because of unit sized stuff */
int xi = (int)fabs(floor(0.00001f + x / sz));
int yi = (int)fabs(floor(0.00001f + y / sz));
int zi = (int)fabs(floor(0.00001f + z / sz));
-
+
if ( (xi % 2 == yi % 2) == (zi % 2) ) {
tex_input_rgba(out, in[0], p, thread);
}
@@ -73,10 +73,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
void register_node_type_tex_checker(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_CHECKER, "Checker", NODE_CLASS_PATTERN, NODE_PREVIEW);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c
index 79a4c4e3a6b..20b1815e436 100644
--- a/source/blender/nodes/texture/nodes/node_texture_common.c
+++ b/source/blender/nodes/texture/nodes/node_texture_common.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -50,7 +50,7 @@ static void copy_stack(bNodeStack *to, bNodeStack *from)
copy_v4_v4(to->vec, from->vec);
to->data = from->data;
to->datatype = from->datatype;
-
+
/* tag as copy to prevent freeing */
to->is_copy = 1;
}
@@ -62,20 +62,20 @@ static void *group_initexec(bNodeExecContext *context, bNode *node, bNodeInstanc
{
bNodeTree *ngroup = (bNodeTree *)node->id;
void *exec;
-
+
if (!ngroup)
return NULL;
-
+
/* initialize the internal node tree execution */
exec = ntreeTexBeginExecTree_internal(context, ngroup, key);
-
+
return exec;
}
static void group_freeexec(void *nodedata)
{
bNodeTreeExec *gexec = (bNodeTreeExec *)nodedata;
-
+
ntreeTexEndExecTree_internal(gexec);
}
@@ -89,7 +89,7 @@ static void group_copy_inputs(bNode *gnode, bNodeStack **in, bNodeStack *gstack)
bNodeSocket *sock;
bNodeStack *ns;
int a;
-
+
for (node = ngroup->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP_INPUT) {
for (sock = node->outputs.first, a = 0; sock; sock = sock->next, ++a) {
@@ -113,7 +113,7 @@ static void group_copy_outputs(bNode *gnode, bNodeStack **out, bNodeStack *gstac
bNodeSocket *sock;
bNodeStack *ns;
int a;
-
+
for (node = ngroup->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP_OUTPUT && (node->flag & NODE_DO_OUTPUT)) {
for (sock = node->inputs.first, a = 0; sock; sock = sock->next, ++a) {
@@ -133,10 +133,10 @@ static void group_execute(void *data, int thread, struct bNode *node, bNodeExecD
{
bNodeTreeExec *exec = execdata->data;
bNodeThreadStack *nts;
-
+
if (!exec)
return;
-
+
/* XXX same behavior as trunk: all nodes inside group are executed.
* it's stupid, but just makes it work. compo redesign will do this better.
*/
@@ -145,13 +145,13 @@ static void group_execute(void *data, int thread, struct bNode *node, bNodeExecD
for (inode = exec->nodetree->nodes.first; inode; inode = inode->next)
inode->need_exec = 1;
}
-
+
nts = ntreeGetThreadStack(exec, thread);
-
+
group_copy_inputs(node, in, nts->stack);
ntreeExecThreadNodes(exec, nts, data, thread);
group_copy_outputs(node, out, nts->stack);
-
+
ntreeReleaseThreadStack(nts);
}
@@ -171,12 +171,12 @@ void register_node_type_tex_group(void)
ntype.ext.srna = RNA_struct_find("TextureNodeGroup");
BLI_assert(ntype.ext.srna != NULL);
RNA_struct_blender_type_set(ntype.ext.srna, &ntype);
-
+
node_type_socket_templates(&ntype, NULL, NULL);
node_type_size(&ntype, 140, 60, 400);
node_type_label(&ntype, node_group_label);
node_type_update(&ntype, NULL, node_group_verify);
node_type_exec(&ntype, group_initexec, group_freeexec, group_execute);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_compose.c b/source/blender/nodes/texture/nodes/node_texture_compose.c
index 08813667ab4..002da4428cc 100644
--- a/source/blender/nodes/texture/nodes/node_texture_compose.c
+++ b/source/blender/nodes/texture/nodes/node_texture_compose.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -30,7 +30,7 @@
*/
-#include "node_texture_util.h"
+#include "node_texture_util.h"
#include "NOD_texture.h"
static bNodeSocketTemplate inputs[] = {
@@ -60,10 +60,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
void register_node_type_tex_compose(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_COMPOSE, "Combine RGBA", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_coord.c b/source/blender/nodes/texture/nodes/node_texture_coord.c
index 5221d456b88..e698ffd0a54 100644
--- a/source/blender/nodes/texture/nodes/node_texture_coord.c
+++ b/source/blender/nodes/texture/nodes/node_texture_coord.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -51,11 +51,11 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
void register_node_type_tex_coord(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_COORD, "Coordinates", NODE_CLASS_INPUT, 0);
node_type_socket_templates(&ntype, NULL, outputs);
node_type_storage(&ntype, "", NULL, NULL);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c
index 897157e3f61..cc734df9586 100644
--- a/source/blender/nodes/texture/nodes/node_texture_curves.c
+++ b/source/blender/nodes/texture/nodes/node_texture_curves.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -45,10 +45,10 @@ static void time_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNU
{
/* stack order output: fac */
float fac = 0.0f;
-
+
if (node->custom1 < node->custom2)
fac = (p->cfra - node->custom1) / (float)(node->custom2 - node->custom1);
-
+
curvemapping_initialize(node->storage);
fac = curvemapping_evaluateF(node->storage, 0, fac);
out[0] = CLAMPIS(fac, 0.0f, 1.0f);
@@ -70,14 +70,14 @@ static void time_init(bNodeTree *UNUSED(ntree), bNode *node)
void register_node_type_tex_curve_time(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_CURVE_TIME, "Time", NODE_CLASS_INPUT, 0);
node_type_socket_templates(&ntype, NULL, time_outputs);
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
node_type_init(&ntype, time_init);
node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
node_type_exec(&ntype, node_initexec_curves, NULL, time_exec);
-
+
nodeRegisterType(&ntype);
}
@@ -96,7 +96,7 @@ static void rgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in,
{
float cin[4];
tex_input_rgba(cin, in[0], p, thread);
-
+
curvemapping_evaluateRGBF(node->storage, out, cin);
out[3] = cin[3];
}
@@ -114,13 +114,13 @@ static void rgb_init(bNodeTree *UNUSED(ntree), bNode *node)
void register_node_type_tex_curve_rgb(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, rgb_inputs, rgb_outputs);
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
node_type_init(&ntype, rgb_init);
node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
node_type_exec(&ntype, node_initexec_curves, NULL, rgb_exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_decompose.c b/source/blender/nodes/texture/nodes/node_texture_decompose.c
index 4bdc66bdb38..392cff970e7 100644
--- a/source/blender/nodes/texture/nodes/node_texture_decompose.c
+++ b/source/blender/nodes/texture/nodes/node_texture_decompose.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -30,7 +30,7 @@
*/
-#include "node_texture_util.h"
+#include "node_texture_util.h"
#include "NOD_texture.h"
#include <math.h>
@@ -81,10 +81,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
void register_node_type_tex_decompose(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_DECOMPOSE, "Separate RGBA", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_distance.c b/source/blender/nodes/texture/nodes/node_texture_distance.c
index 76a5b79c7a9..7cd032f7d59 100644
--- a/source/blender/nodes/texture/nodes/node_texture_distance.c
+++ b/source/blender/nodes/texture/nodes/node_texture_distance.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -64,11 +64,11 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
void register_node_type_tex_distance(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_DISTANCE, "Distance", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_storage(&ntype, "", NULL, NULL);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
index 154246495f0..8316579af93 100644
--- a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
+++ b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -51,7 +51,7 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat
{
if (fac != 0 && (hue != 0.5f || sat != 1 || val != 1)) {
float col[3], hsv[3], mfac = 1.0f - fac;
-
+
rgb_to_hsv(in[0], in[1], in[2], hsv, hsv + 1, hsv + 2);
hsv[0] += (hue - 0.5f);
if (hsv[0] > 1.0f) hsv[0] -= 1.0f; else if (hsv[0] < 0.0f) hsv[0] += 1.0f;
@@ -71,19 +71,19 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat
}
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
-{
+{
float hue = tex_input_value(in[0], p, thread);
float sat = tex_input_value(in[1], p, thread);
float val = tex_input_value(in[2], p, thread);
float fac = tex_input_value(in[3], p, thread);
-
+
float col[4];
tex_input_rgba(col, in[4], p, thread);
-
+
hue += 0.5f; /* [-0.5, 0.5] -> [0, 1] */
-
+
do_hue_sat_fac(node, out, hue, sat, val, col, fac);
-
+
out[3] = col[3];
}
@@ -95,11 +95,11 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
void register_node_type_tex_hue_sat(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c
index fd1e818b63b..0d70eff15e3 100644
--- a/source/blender/nodes/texture/nodes/node_texture_image.c
+++ b/source/blender/nodes/texture/nodes/node_texture_image.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -44,37 +44,37 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(i
float y = p->co[1];
Image *ima = (Image *)node->id;
ImageUser *iuser = (ImageUser *)node->storage;
-
+
if (ima) {
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
if (ibuf) {
float xsize, ysize;
float xoff, yoff;
int px, py;
-
+
const float *result;
xsize = ibuf->x / 2;
ysize = ibuf->y / 2;
xoff = yoff = -1;
-
+
px = (int)( (x - xoff) * xsize);
py = (int)( (y - yoff) * ysize);
-
+
if ( (!xsize) || (!ysize) ) return;
-
+
if (!ibuf->rect_float) {
BLI_thread_lock(LOCK_IMAGE);
if (!ibuf->rect_float)
IMB_float_from_rect(ibuf);
BLI_thread_unlock(LOCK_IMAGE);
}
-
+
while (px < 0) px += ibuf->x;
while (py < 0) py += ibuf->y;
while (px >= ibuf->x) px -= ibuf->x;
while (py >= ibuf->y) py -= ibuf->y;
-
+
result = ibuf->rect_float + py * ibuf->x * 4 + px * 4;
copy_v4_v4(out, result);
@@ -101,7 +101,7 @@ static void init(bNodeTree *UNUSED(ntree), bNode *node)
void register_node_type_tex_image(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_IMAGE, "Image", NODE_CLASS_INPUT, NODE_PREVIEW);
node_type_socket_templates(&ntype, NULL, outputs);
node_type_init(&ntype, init);
diff --git a/source/blender/nodes/texture/nodes/node_texture_invert.c b/source/blender/nodes/texture/nodes/node_texture_invert.c
index 82b3d40d686..8ef7a7a6ad2 100644
--- a/source/blender/nodes/texture/nodes/node_texture_invert.c
+++ b/source/blender/nodes/texture/nodes/node_texture_invert.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -33,7 +33,7 @@
#include "node_texture_util.h"
#include "NOD_texture.h"
-/* **************** INVERT ******************** */
+/* **************** INVERT ******************** */
static bNodeSocketTemplate inputs[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
@@ -47,13 +47,13 @@ static bNodeSocketTemplate outputs[] = {
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
float col[4];
-
+
tex_input_rgba(col, in[0], p, thread);
col[0] = 1.0f - col[0];
col[1] = 1.0f - col[1];
col[2] = 1.0f - col[2];
-
+
copy_v3_v3(out, col);
out[3] = col[3];
}
@@ -66,10 +66,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
void register_node_type_tex_invert(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c
index f3f3dd87b0e..9fb8332c61a 100644
--- a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c
+++ b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -49,16 +49,16 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
{
float fac = tex_input_value(in[0], p, thread);
float col1[4], col2[4];
-
+
tex_input_rgba(col1, in[1], p, thread);
tex_input_rgba(col2, in[2], p, thread);
/* use alpha */
if (node->custom2 & 1)
fac *= col2[3];
-
+
CLAMP(fac, 0.0f, 1.0f);
-
+
copy_v4_v4(out, col1);
ramp_blend(node->custom1, out, fac, col2);
}
@@ -71,11 +71,11 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
void register_node_type_tex_mix_rgb(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_label(&ntype, node_blend_label);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c
index 57165a8cb09..412e3ffb56c 100644
--- a/source/blender/nodes/texture/nodes/node_texture_output.c
+++ b/source/blender/nodes/texture/nodes/node_texture_output.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -45,7 +45,7 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
{
TexCallData *cdata = (TexCallData *)data;
TexResult *target = cdata->target;
-
+
if (cdata->do_preview) {
TexParams params;
params_from_cdata(&params, cdata);
@@ -61,12 +61,12 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
if (cdata->which_output == node->custom1 || (cdata->which_output == 0 && node->custom1 == 1)) {
TexParams params;
params_from_cdata(&params, cdata);
-
+
tex_input_rgba(&target->tr, in[0], &params, cdata->thread);
-
+
target->tin = (target->tr + target->tg + target->tb) / 3.0f;
target->talpha = true;
-
+
if (target->nor) {
if (in[1] && in[1]->hasinput)
tex_input_vec(target->nor, in[1], &params, cdata->thread);
@@ -85,7 +85,7 @@ static void unique_name(bNode *node)
int suffix;
bNode *i;
const char *name = tno->name;
-
+
new_name[0] = '\0';
i = node;
while (i->prev) i = i->prev;
@@ -114,7 +114,7 @@ static void unique_name(bNode *node)
}
sprintf(new_name + new_len - 4, ".%03d", ++suffix);
}
-
+
if (new_name[0] != '\0') {
BLI_strncpy(tno->name, new_name, sizeof(tno->name));
}
@@ -124,11 +124,11 @@ static void assign_index(struct bNode *node)
{
bNode *tnode;
int index = 1;
-
+
tnode = node;
while (tnode->prev)
tnode = tnode->prev;
-
+
check_index:
for (; tnode; tnode = tnode->next)
if (tnode->type == TEX_NODE_OUTPUT && tnode != node)
@@ -136,7 +136,7 @@ check_index:
index++;
goto check_index;
}
-
+
node->custom1 = index;
}
@@ -144,7 +144,7 @@ static void init(bNodeTree *UNUSED(ntree), bNode *node)
{
TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output");
node->storage = tno;
-
+
strcpy(tno->name, "Default");
unique_name(node);
assign_index(node);
@@ -160,16 +160,16 @@ static void copy(bNodeTree *dest_ntree, bNode *dest_node, bNode *src_node)
void register_node_type_tex_output(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_OUTPUT, "Output", NODE_CLASS_OUTPUT, NODE_PREVIEW);
node_type_socket_templates(&ntype, inputs, NULL);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, init);
node_type_storage(&ntype, "TexNodeOutput", node_free_standard_storage, copy);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
/* Do not allow muting output. */
node_type_internal_links(&ntype, NULL);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c
index c16d723e1e1..47f4683549f 100644
--- a/source/blender/nodes/texture/nodes/node_texture_proc.c
+++ b/source/blender/nodes/texture/nodes/node_texture_proc.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -35,7 +35,7 @@
#include "RE_shader_ext.h"
-/*
+/*
* In this file: wrappers to use procedural textures as nodes
*/
@@ -61,19 +61,19 @@ static void do_proc(float *result, TexParams *p, const float col1[4], const floa
{
TexResult texres;
int textype;
-
+
if (is_normal) {
texres.nor = result;
}
else
texres.nor = NULL;
-
+
textype = multitex_nodes(tex, p->co, p->dxt, p->dyt, p->osatex,
&texres, thread, 0, p->mtex, NULL);
-
+
if (is_normal)
return;
-
+
if (textype & TEX_RGB) {
copy_v4_v4(result, &texres.tr);
}
@@ -86,11 +86,11 @@ static void do_proc(float *result, TexParams *p, const float col1[4], const floa
typedef void (*MapFn) (Tex *tex, bNodeStack **in, TexParams *p, const short thread);
static void texfn(
- float *result,
+ float *result,
TexParams *p,
- bNode *node,
+ bNode *node,
bNodeStack **in,
- char is_normal,
+ char is_normal,
MapFn map_inputs,
short thread)
{
@@ -98,9 +98,9 @@ static void texfn(
float col1[4], col2[4];
tex_input_rgba(col1, in[0], p, thread);
tex_input_rgba(col2, in[1], p, thread);
-
+
map_inputs(&tex, in, p, thread);
-
+
do_proc(result, p, col1, col2, is_normal, &tex, thread);
}
@@ -144,10 +144,10 @@ static bNodeSocketTemplate voronoi_inputs[] = {
{ SOCK_FLOAT, 1, N_("W2"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE },
{ SOCK_FLOAT, 1, N_("W3"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE },
{ SOCK_FLOAT, 1, N_("W4"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE },
-
+
{ SOCK_FLOAT, 1, N_("iScale"), 1.0f, 0.0f, 0.0f, 0.0f, 0.01f, 10.0f, PROP_UNSIGNED },
{ SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 4.0f, PROP_UNSIGNED },
-
+
{ -1, 0, "" }
};
static void voronoi_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread)
@@ -156,7 +156,7 @@ static void voronoi_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short th
tex->vn_w2 = tex_input_value(in[I + 1], p, thread);
tex->vn_w3 = tex_input_value(in[I + 2], p, thread);
tex->vn_w4 = tex_input_value(in[I + 3], p, thread);
-
+
tex->ns_outscale = tex_input_value(in[I + 4], p, thread);
tex->noisesize = tex_input_value(in[I + 5], p, thread);
}
@@ -242,7 +242,7 @@ static bNodeSocketTemplate musgrave_inputs[] = {
{ SOCK_FLOAT, 1, N_("H"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED },
{ SOCK_FLOAT, 1, N_("Lacunarity"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 6.0f, PROP_UNSIGNED },
{ SOCK_FLOAT, 1, N_("Octaves"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 8.0f, PROP_UNSIGNED },
-
+
{ SOCK_FLOAT, 1, N_("iScale"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f, PROP_UNSIGNED },
{ SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED },
{ -1, 0, "" }
@@ -285,13 +285,13 @@ static void init(bNodeTree *UNUSED(ntree), bNode *node)
{
Tex *tex = MEM_callocN(sizeof(Tex), "Tex");
node->storage = tex;
-
+
BKE_texture_default(tex);
tex->type = node->type - TEX_NODE_PROC;
-
+
if (tex->type == TEX_WOOD)
tex->stype = TEX_BANDNOISE;
-
+
}
/* Node type definitions */
@@ -309,10 +309,10 @@ void register_node_type_tex_proc_##name(void) \
\
nodeRegisterType(&ntype); \
}
-
+
#define C outputs_color_only
#define CV outputs_both
-
+
TexDef(TEX_VORONOI, CV, voronoi, "Voronoi" )
TexDef(TEX_BLEND, C, blend, "Blend" )
TexDef(TEX_MAGIC, C, magic, "Magic" )
diff --git a/source/blender/nodes/texture/nodes/node_texture_rotate.c b/source/blender/nodes/texture/nodes/node_texture_rotate.c
index ff1bd464316..bc4e56ea81d 100644
--- a/source/blender/nodes/texture/nodes/node_texture_rotate.c
+++ b/source/blender/nodes/texture/nodes/node_texture_rotate.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -52,18 +52,18 @@ static void rotate(float new_co[3], float a, float ax[3], const float co[3])
float para[3];
float perp[3];
float cp[3];
-
+
float cos_a = cosf(a * (float)(2 * M_PI));
float sin_a = sinf(a * (float)(2 * M_PI));
-
+
// x' = xcosa + n(n.x)(1-cosa) + (x*n)sina
-
+
mul_v3_v3fl(perp, co, cos_a);
mul_v3_v3fl(para, ax, dot_v3v3(co, ax) * (1 - cos_a));
-
+
cross_v3_v3v3(cp, ax, co);
mul_v3_fl(cp, sin_a);
-
+
new_co[0] = para[0] + perp[0] + cp[0];
new_co[1] = para[1] + perp[1] + cp[1];
new_co[2] = para[2] + perp[2] + cp[2];
@@ -72,7 +72,7 @@ static void rotate(float new_co[3], float a, float ax[3], const float co[3])
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
float new_co[3], new_dxt[3], new_dyt[3], a, ax[3];
-
+
a = tex_input_value(in[1], p, thread);
tex_input_vec(ax, in[2], p, thread);
@@ -81,7 +81,7 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **
rotate(new_dxt, a, ax, p->dxt);
rotate(new_dyt, a, ax, p->dyt);
}
-
+
{
TexParams np = *p;
np.co = new_co;
@@ -90,7 +90,7 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **
tex_input_rgba(out, in[0], &np, thread);
}
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
{
tex_output(node, execdata, in, out[0], &colorfn, data);
}
@@ -98,10 +98,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
void register_node_type_tex_rotate(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_ROTATE, "Rotate", NODE_CLASS_DISTORT, 0);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_scale.c b/source/blender/nodes/texture/nodes/node_texture_scale.c
index 4643ba224c4..94ccfd01357 100644
--- a/source/blender/nodes/texture/nodes/node_texture_scale.c
+++ b/source/blender/nodes/texture/nodes/node_texture_scale.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -52,7 +52,7 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **
np.co = new_co;
np.dxt = new_dxt;
np.dyt = new_dyt;
-
+
tex_input_vec(scale, in[1], p, thread);
mul_v3_v3v3(new_co, p->co, scale);
@@ -60,10 +60,10 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **
mul_v3_v3v3(new_dxt, p->dxt, scale);
mul_v3_v3v3(new_dyt, p->dyt, scale);
}
-
+
tex_input_rgba(out, in[0], &np, thread);
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
{
tex_output(node, execdata, in, out[0], &colorfn, data);
}
@@ -71,10 +71,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
void register_node_type_tex_scale(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_SCALE, "Scale", NODE_CLASS_DISTORT, 0);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c
index 7e035d522f7..ff405cc9f3e 100644
--- a/source/blender/nodes/texture/nodes/node_texture_texture.c
+++ b/source/blender/nodes/texture/nodes/node_texture_texture.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -52,7 +52,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static float red[] = {1, 0, 0, 1};
static float white[] = {1, 1, 1, 1};
float co[3], dxt[3], dyt[3];
-
+
copy_v3_v3(co, p->co);
if (p->osatex) {
copy_v3_v3(dxt, p->dxt);
@@ -62,7 +62,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
zero_v3(dxt);
zero_v3(dyt);
}
-
+
if (node->custom2 || node->need_exec == 0) {
/* this node refers to its own texture tree! */
copy_v4_v4(out, (fabsf(co[0] - co[1]) < 0.01f) ? white : red);
@@ -72,14 +72,14 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
int textype;
float nor[] = {0, 0, 0};
float col1[4], col2[4];
-
+
tex_input_rgba(col1, in[0], p, thread);
tex_input_rgba(col2, in[1], p, thread);
-
+
texres.nor = nor;
textype = multitex_nodes(nodetex, co, dxt, dyt, p->osatex,
&texres, thread, 0, p->mtex, NULL);
-
+
if (textype & TEX_RGB) {
copy_v4_v4(out, &texres.tr);
}
@@ -98,10 +98,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
void register_node_type_tex_texture(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT, NODE_PREVIEW);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_translate.c b/source/blender/nodes/texture/nodes/node_texture_translate.c
index 4ee1b5b2f44..fa8319d077b 100644
--- a/source/blender/nodes/texture/nodes/node_texture_translate.c
+++ b/source/blender/nodes/texture/nodes/node_texture_translate.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -50,16 +50,16 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **
float offset[3], new_co[3];
TexParams np = *p;
np.co = new_co;
-
+
tex_input_vec(offset, in[1], p, thread);
-
+
new_co[0] = p->co[0] + offset[0];
new_co[1] = p->co[1] + offset[1];
new_co[2] = p->co[2] + offset[2];
-
+
tex_input_rgba(out, in[0], &np, thread);
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
{
tex_output(node, execdata, in, out[0], &colorfn, data);
}
@@ -67,10 +67,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
void register_node_type_tex_translate(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_TRANSLATE, "Translate", NODE_CLASS_DISTORT, 0);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_valToNor.c b/source/blender/nodes/texture/nodes/node_texture_valToNor.c
index aeca75c8b6e..b7d57b4d4cf 100644
--- a/source/blender/nodes/texture/nodes/node_texture_valToNor.c
+++ b/source/blender/nodes/texture/nodes/node_texture_valToNor.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -52,7 +52,7 @@ static void normalfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack *
float nabla = tex_input_value(in[1], p, thread);
float val;
float nor[3];
-
+
TexParams np = *p;
np.co = new_co;
@@ -66,7 +66,7 @@ static void normalfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack *
new_co[0] = co[0];
new_co[1] = co[1] + nabla;
nor[1] = tex_input_value(in[0], &np, thread);
-
+
new_co[1] = co[1];
new_co[2] = co[2] + nabla;
nor[2] = tex_input_value(in[0], &np, thread);
@@ -75,7 +75,7 @@ static void normalfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack *
out[1] = val - nor[1];
out[2] = val - nor[2];
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
{
tex_output(node, execdata, in, out[0], &normalfn, data);
}
@@ -83,10 +83,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
void register_node_type_tex_valtonor(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_VALTONOR, "Value to Normal", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c
index 8b016c5aa50..ad3c4344f34 100644
--- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c
+++ b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -53,7 +53,7 @@ static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack *
}
}
-static void valtorgb_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+static void valtorgb_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
{
tex_output(node, execdata, in, out[0], &valtorgb_colorfn, data);
}
@@ -66,14 +66,14 @@ static void valtorgb_init(bNodeTree *UNUSED(ntree), bNode *node)
void register_node_type_tex_valtorgb(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, valtorgb_in, valtorgb_out);
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
node_type_init(&ntype, valtorgb_init);
node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage);
node_type_exec(&ntype, NULL, NULL, valtorgb_exec);
-
+
nodeRegisterType(&ntype);
}
@@ -103,10 +103,10 @@ static void rgbtobw_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecD
void register_node_type_tex_rgbtobw(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, rgbtobw_in, rgbtobw_out);
node_type_exec(&ntype, NULL, NULL, rgbtobw_exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_viewer.c b/source/blender/nodes/texture/nodes/node_texture_viewer.c
index 4168e7a16e7..69f4d3ca086 100644
--- a/source/blender/nodes/texture/nodes/node_texture_viewer.c
+++ b/source/blender/nodes/texture/nodes/node_texture_viewer.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -59,13 +59,13 @@ static void exec(void *data, int UNUSED(thread), bNode *UNUSED(node), bNodeExecD
void register_node_type_tex_viewer(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_VIEWER, "Viewer", NODE_CLASS_OUTPUT, NODE_PREVIEW);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
/* Do not allow muting viewer node. */
node_type_internal_links(&ntype, NULL);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index e5724c97bbc..c8932045c52 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -60,7 +60,7 @@ static int cloth_count_nondiag_blocks(Cloth *cloth)
{
LinkNode *link;
int nondiag = 0;
-
+
for (link = cloth->springs; link; link = link->next) {
ClothSpring *spring = (ClothSpring *)link->link;
switch (spring->type) {
@@ -68,14 +68,14 @@ static int cloth_count_nondiag_blocks(Cloth *cloth)
/* angular bending combines 3 vertices */
nondiag += 3;
break;
-
+
default:
/* all other springs depend on 2 vertices only */
nondiag += 1;
break;
}
}
-
+
return nondiag;
}
@@ -86,25 +86,25 @@ int BPH_cloth_solver_init(Object *UNUSED(ob), ClothModifierData *clmd)
const float ZERO[3] = {0.0f, 0.0f, 0.0f};
Implicit_Data *id;
unsigned int i, nondiag;
-
+
nondiag = cloth_count_nondiag_blocks(cloth);
cloth->implicit = id = BPH_mass_spring_solver_create(cloth->mvert_num, nondiag);
-
+
for (i = 0; i < cloth->mvert_num; i++) {
BPH_mass_spring_set_vertex_mass(id, i, verts[i].mass);
}
-
+
for (i = 0; i < cloth->mvert_num; i++) {
BPH_mass_spring_set_motion_state(id, i, verts[i].x, ZERO);
}
-
+
return 1;
}
void BPH_cloth_solver_free(ClothModifierData *clmd)
{
Cloth *cloth = clmd->clothObject;
-
+
if (cloth->implicit) {
BPH_mass_spring_solver_free(cloth->implicit);
cloth->implicit = NULL;
@@ -118,7 +118,7 @@ void BKE_cloth_solver_set_positions(ClothModifierData *clmd)
unsigned int mvert_num = cloth->mvert_num, i;
ClothHairData *cloth_hairdata = clmd->hairdata;
Implicit_Data *id = cloth->implicit;
-
+
for (i = 0; i < mvert_num; i++) {
if (cloth_hairdata) {
ClothHairData *root = &cloth_hairdata[i];
@@ -126,7 +126,7 @@ void BKE_cloth_solver_set_positions(ClothModifierData *clmd)
}
else
BPH_mass_spring_set_rest_transform(id, i, I3);
-
+
BPH_mass_spring_set_motion_state(id, i, verts[i].x, verts[i].v);
}
}
@@ -136,22 +136,22 @@ static bool collision_response(ClothModifierData *clmd, CollisionModifierData *c
Cloth *cloth = clmd->clothObject;
int index = collpair->ap1;
bool result = false;
-
+
float v1[3], v2_old[3], v2_new[3], v_rel_old[3], v_rel_new[3];
float epsilon2 = BLI_bvhtree_get_epsilon(collmd->bvhtree);
float margin_distance = (float)collpair->distance - epsilon2;
float mag_v_rel;
-
+
zero_v3(r_impulse);
-
+
if (margin_distance > 0.0f)
return false; /* XXX tested before already? */
-
+
/* only handle static collisions here */
if ( collpair->flag & COLLISION_IN_FUTURE )
return false;
-
+
/* velocity */
copy_v3_v3(v1, cloth->verts[index].v);
collision_get_collider_velocity(v2_old, v2_new, collmd, collpair);
@@ -160,32 +160,32 @@ static bool collision_response(ClothModifierData *clmd, CollisionModifierData *c
sub_v3_v3v3(v_rel_new, v1, v2_new);
/* normal component of the relative velocity */
mag_v_rel = dot_v3v3(v_rel_old, collpair->normal);
-
+
/* only valid when moving toward the collider */
if (mag_v_rel < -ALMOST_ZERO) {
float v_nor_old, v_nor_new;
float v_tan_old[3], v_tan_new[3];
float bounce, repulse;
-
+
/* Collision response based on
* "Simulating Complex Hair with Robust Collision Handling" (Choe, Choi, Ko, ACM SIGGRAPH 2005)
* http://graphics.snu.ac.kr/publications/2005-choe-HairSim/Choe_2005_SCA.pdf
*/
-
+
v_nor_old = mag_v_rel;
v_nor_new = dot_v3v3(v_rel_new, collpair->normal);
-
+
madd_v3_v3v3fl(v_tan_old, v_rel_old, collpair->normal, -v_nor_old);
madd_v3_v3v3fl(v_tan_new, v_rel_new, collpair->normal, -v_nor_new);
-
+
bounce = -v_nor_old * restitution;
-
+
repulse = -margin_distance / dt; /* base repulsion velocity in normal direction */
/* XXX this clamping factor is quite arbitrary ...
* not sure if there is a more scientific approach, but seems to give good results
*/
CLAMP(repulse, 0.0f, 4.0f * bounce);
-
+
if (margin_distance < -epsilon2) {
mul_v3_v3fl(r_impulse, collpair->normal, max_ff(repulse, bounce) - v_nor_new);
}
@@ -193,10 +193,10 @@ static bool collision_response(ClothModifierData *clmd, CollisionModifierData *c
bounce = 0.0f;
mul_v3_v3fl(r_impulse, collpair->normal, repulse - v_nor_new);
}
-
+
result = true;
}
-
+
return result;
}
@@ -211,17 +211,17 @@ static void cloth_setup_constraints(ClothModifierData *clmd, ColliderContacts *c
ClothVertex *verts = cloth->verts;
int mvert_num = cloth->mvert_num;
int i, j, v;
-
+
const float ZERO[3] = {0.0f, 0.0f, 0.0f};
-
+
BPH_mass_spring_clear_constraints(data);
-
+
for (v = 0; v < mvert_num; v++) {
if (verts[v].flags & CLOTH_VERT_FLAG_PINNED) {
/* pinned vertex constraints */
BPH_mass_spring_add_constraint_ndof0(data, v, ZERO); /* velocity is defined externally */
}
-
+
verts[v].impulse_count = 0;
}
@@ -233,21 +233,21 @@ static void cloth_setup_constraints(ClothModifierData *clmd, ColliderContacts *c
float restitution = 0.0f;
int v = collpair->face1;
float impulse[3];
-
+
/* pinned verts handled separately */
if (verts[v].flags & CLOTH_VERT_FLAG_PINNED)
continue;
-
+
/* XXX cheap way of avoiding instability from multiple collisions in the same step
* this should eventually be supported ...
*/
if (verts[v].impulse_count > 0)
continue;
-
+
/* calculate collision response */
if (!collision_response(clmd, ct->collmd, collpair, dt, restitution, impulse))
continue;
-
+
BPH_mass_spring_add_constraint_ndof2(data, v, collpair->normal, impulse);
++verts[v].impulse_count;
}
@@ -267,11 +267,11 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothMo
ClothSpring *spring;
ClothVertex *cv;
int i, steps;
-
+
cv = cloth->verts;
for (i = 0; i < cloth->mvert_num; i++, cv++) {
copy_v3_v3(cos[i], cv->tx);
-
+
if (cv->goal == 1.0f || len_squared_v3v3(initial_cos[i], cv->tx) != 0.0f) {
masses[i] = 1e+10;
}
@@ -279,57 +279,57 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothMo
masses[i] = cv->mass;
}
}
-
+
steps = 55;
for (i=0; i<steps; i++) {
for (node=cloth->springs; node; node=node->next) {
/* ClothVertex *cv1, *cv2; */ /* UNUSED */
int v1, v2;
float len, c, l, vec[3];
-
+
spring = (ClothSpring *)node->link;
- if (spring->type != CLOTH_SPRING_TYPE_STRUCTURAL && spring->type != CLOTH_SPRING_TYPE_SHEAR)
+ if (spring->type != CLOTH_SPRING_TYPE_STRUCTURAL && spring->type != CLOTH_SPRING_TYPE_SHEAR)
continue;
-
+
v1 = spring->ij; v2 = spring->kl;
/* cv1 = cloth->verts + v1; */ /* UNUSED */
/* cv2 = cloth->verts + v2; */ /* UNUSED */
len = len_v3v3(cos[v1], cos[v2]);
-
+
sub_v3_v3v3(vec, cos[v1], cos[v2]);
normalize_v3(vec);
-
+
c = (len - spring->restlen);
if (c == 0.0f)
continue;
-
+
l = c / ((1.0f / masses[v1]) + (1.0f / masses[v2]));
-
+
mul_v3_fl(vec, -(1.0f / masses[v1]) * l);
add_v3_v3(cos[v1], vec);
-
+
sub_v3_v3v3(vec, cos[v2], cos[v1]);
normalize_v3(vec);
-
+
mul_v3_fl(vec, -(1.0f / masses[v2]) * l);
add_v3_v3(cos[v2], vec);
}
}
-
+
cv = cloth->verts;
for (i = 0; i < cloth->mvert_num; i++, cv++) {
float vec[3];
-
+
/*compute forces*/
sub_v3_v3v3(vec, cos[i], cv->tx);
mul_v3_fl(vec, cv->mass*dt*20.0f);
add_v3_v3(cv->tv, vec);
//copy_v3_v3(cv->tx, cos[i]);
}
-
+
MEM_freeN(cos);
MEM_freeN(masses);
-
+
return 1;
}
@@ -338,21 +338,21 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
Cloth *cloth = clmd->clothObject;
ClothSimSettings *parms = clmd->sim_parms;
Implicit_Data *data = cloth->implicit;
-
+
bool no_compress = parms->flags & CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS;
-
+
s->flags &= ~CLOTH_SPRING_FLAG_NEEDED;
-
+
// calculate force of structural + shear springs
if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR) || (s->type & CLOTH_SPRING_TYPE_SEWING) ) {
#ifdef CLOTH_FORCE_SPRING_STRUCTURAL
float k, scaling;
-
+
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
-
+
scaling = parms->structural + s->stiffness * fabsf(parms->max_struct - parms->structural);
k = scaling / (parms->avg_spring_len + FLT_EPSILON);
-
+
if (s->type & CLOTH_SPRING_TYPE_SEWING) {
// TODO: verify, half verified (couldn't see error)
// sewing springs usually have a large distance at first so clamp the force so we don't get tunnelling through colission objects
@@ -366,50 +366,50 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
else if (s->type & CLOTH_SPRING_TYPE_BENDING) { /* calculate force of bending springs */
#ifdef CLOTH_FORCE_SPRING_BEND
float kb, cb, scaling;
-
+
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
-
+
scaling = parms->bending + s->stiffness * fabsf(parms->max_bend - parms->bending);
kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));
-
+
// Fix for [#45084] for cloth stiffness must have cb proportional to kb
cb = kb * parms->bending_damping;
-
+
BPH_mass_spring_force_spring_bending(data, s->ij, s->kl, s->restlen, kb, cb);
#endif
}
else if (s->type & CLOTH_SPRING_TYPE_BENDING_ANG) {
#ifdef CLOTH_FORCE_SPRING_BEND
float kb, cb, scaling;
-
+
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
-
+
/* XXX WARNING: angular bending springs for hair apply stiffness factor as an overall factor, unlike cloth springs!
* this is crap, but needed due to cloth/hair mixing ...
* max_bend factor is not even used for hair, so ...
*/
scaling = s->stiffness * parms->bending;
kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));
-
+
// Fix for [#45084] for cloth stiffness must have cb proportional to kb
cb = kb * parms->bending_damping;
-
+
/* XXX assuming same restlen for ij and jk segments here, this can be done correctly for hair later */
BPH_mass_spring_force_spring_bending_angular(data, s->ij, s->kl, s->mn, s->target, kb, cb);
-
+
#if 0
{
float x_kl[3], x_mn[3], v[3], d[3];
-
+
BPH_mass_spring_get_motion_state(data, s->kl, x_kl, v);
BPH_mass_spring_get_motion_state(data, s->mn, x_mn, v);
-
+
BKE_sim_debug_data_add_dot(clmd->debug_data, x_kl, 0.9, 0.9, 0.9, "target", 7980, s->kl);
BKE_sim_debug_data_add_line(clmd->debug_data, x_kl, x_mn, 0.8, 0.8, 0.8, "target", 7981, s->kl);
-
+
copy_v3_v3(d, s->target);
BKE_sim_debug_data_add_vector(clmd->debug_data, x_kl, d, 0.8, 0.8, 0.2, "target", 7982, s->kl);
-
+
// copy_v3_v3(d, s->target_ij);
// BKE_sim_debug_data_add_vector(clmd->debug_data, x, d, 1, 0.4, 0.4, "target", 7983, s->kl);
}
@@ -424,7 +424,7 @@ static void hair_get_boundbox(ClothModifierData *clmd, float gmin[3], float gmax
Implicit_Data *data = cloth->implicit;
unsigned int mvert_num = cloth->mvert_num;
int i;
-
+
INIT_MINMAX(gmin, gmax);
for (i = 0; i < mvert_num; i++) {
float x[3];
@@ -444,7 +444,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), ListB
const MVertTri *tri = cloth->tri;
unsigned int mvert_num = cloth->mvert_num;
ClothVertex *vert;
-
+
#ifdef CLOTH_FORCE_GRAVITY
/* global acceleration (gravitation) */
if (clmd->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
@@ -477,7 +477,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), ListB
#ifdef CLOTH_FORCE_DRAG
BPH_mass_spring_force_drag(data, drag);
#endif
-
+
/* handle external forces like wind */
if (effectors) {
/* cache per-vertex forces to avoid redundant calculation */
@@ -485,12 +485,12 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), ListB
for (i = 0; i < cloth->mvert_num; i++) {
float x[3], v[3];
EffectedPoint epoint;
-
+
BPH_mass_spring_get_motion_state(data, i, x, v);
pd_point_from_loc(clmd->scene, x, v, i, &epoint);
pdDoEffectors(effectors, NULL, clmd->sim_parms->effector_weights, &epoint, winvec[i], NULL);
}
-
+
for (i = 0; i < cloth->tri_num; i++) {
const MVertTri *vt = &tri[i];
BPH_mass_spring_force_face_wind(data, vt->tri[0], vt->tri[1], vt->tri[2], winvec);
@@ -501,7 +501,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), ListB
#if 0
ClothHairData *hairdata = clmd->hairdata;
ClothHairData *hair_ij, *hair_kl;
-
+
for (LinkNode *link = cloth->springs; link; link = link->next) {
ClothSpring *spring = (ClothSpring *)link->link;
if (spring->type == CLOTH_SPRING_TYPE_STRUCTURAL) {
@@ -516,7 +516,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), ListB
}
#else
ClothHairData *hairdata = clmd->hairdata;
-
+
vert = cloth->verts;
for (i = 0; i < cloth->mvert_num; i++, vert++) {
if (hairdata) {
@@ -531,7 +531,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), ListB
MEM_freeN(winvec);
}
-
+
// calculate spring forces
for (LinkNode *link = cloth->springs; link; link = link->next) {
ClothSpring *spring = (ClothSpring *)link->link;
@@ -548,7 +548,7 @@ BLI_INLINE void cloth_get_grid_location(Implicit_Data *data, float cell_scale, c
{
BPH_mass_spring_get_position(data, index, x);
BPH_mass_spring_get_new_velocity(data, index, v);
-
+
mul_v3_fl(x, cell_scale);
add_v3_v3(x, cell_offset);
}
@@ -582,41 +582,41 @@ static LinkNode *cloth_continuum_add_hair_segments(HairGrid *grid, const float c
// ClothVertex *vert3, *vert4;
float x1[3], v1[3], x2[3], v2[3], x3[3], v3[3], x4[3], v4[3];
float dir1[3], dir2[3], dir3[3];
-
+
spring1 = NULL;
spring2 = NULL;
spring3 = (ClothSpring *)spring_link->link;
-
+
zero_v3(x1); zero_v3(v1);
zero_v3(dir1);
zero_v3(x2); zero_v3(v2);
zero_v3(dir2);
-
+
// vert3 = &verts[spring3->kl];
cloth_get_grid_location(data, cell_scale, cell_offset, spring3->kl, x3, v3);
// vert4 = &verts[spring3->ij];
cloth_get_grid_location(data, cell_scale, cell_offset, spring3->ij, x4, v4);
sub_v3_v3v3(dir3, x4, x3);
normalize_v3(dir3);
-
+
while (spring_link) {
/* move on */
spring1 = spring2;
spring2 = spring3;
-
+
// vert3 = vert4;
-
+
copy_v3_v3(x1, x2); copy_v3_v3(v1, v2);
copy_v3_v3(x2, x3); copy_v3_v3(v2, v3);
copy_v3_v3(x3, x4); copy_v3_v3(v3, v4);
-
+
copy_v3_v3(dir1, dir2);
copy_v3_v3(dir2, dir3);
-
+
/* read next segment */
next_spring_link = spring_link->next;
spring_link = hair_spring_next(spring_link);
-
+
if (spring_link) {
spring3 = (ClothSpring *)spring_link->link;
// vert4 = &verts[spring3->ij];
@@ -630,13 +630,13 @@ static LinkNode *cloth_continuum_add_hair_segments(HairGrid *grid, const float c
zero_v3(x4); zero_v3(v4);
zero_v3(dir3);
}
-
+
BPH_hair_volume_add_segment(grid, x1, v1, x2, v2, x3, v3, x4, v4,
spring1 ? dir1 : NULL,
dir2,
spring3 ? dir3 : NULL);
}
-
+
return next_spring_link;
}
@@ -647,17 +647,17 @@ static void cloth_continuum_fill_grid(HairGrid *grid, Cloth *cloth)
int mvert_num = cloth->mvert_num;
ClothVertex *vert;
int i;
-
+
for (i = 0, vert = cloth->verts; i < mvert_num; i++, vert++) {
float x[3], v[3];
-
+
cloth_get_vertex_motion_state(data, vert, x, v);
BPH_hair_volume_add_vertex(grid, x, v);
}
#else
LinkNode *link;
float cellsize, gmin[3], cell_scale, cell_offset[3];
-
+
/* scale and offset for transforming vertex locations into grid space
* (cell size is 0..1, gmin becomes origin)
*/
@@ -665,7 +665,7 @@ static void cloth_continuum_fill_grid(HairGrid *grid, Cloth *cloth)
cell_scale = cellsize > 0.0f ? 1.0f / cellsize : 0.0f;
mul_v3_v3fl(cell_offset, gmin, cell_scale);
negate_v3(cell_offset);
-
+
link = cloth->springs;
while (link) {
ClothSpring *spring = (ClothSpring *)link->link;
@@ -685,7 +685,7 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
Implicit_Data *data = cloth->implicit;
int mvert_num = cloth->mvert_num;
ClothVertex *vert;
-
+
const float fluid_factor = 0.95f; /* blend between PIC and FLIP methods */
float smoothfac = parms->velocity_smooth;
/* XXX FIXME arbitrary factor!!! this should be based on some intuitive value instead,
@@ -695,42 +695,42 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
float density_strength = parms->density_strength;
float gmin[3], gmax[3];
int i;
-
+
/* clear grid info */
zero_v3_int(clmd->hair_grid_res);
zero_v3(clmd->hair_grid_min);
zero_v3(clmd->hair_grid_max);
clmd->hair_grid_cellsize = 0.0f;
-
+
hair_get_boundbox(clmd, gmin, gmax);
-
+
/* gather velocities & density */
if (smoothfac > 0.0f || density_strength > 0.0f) {
HairGrid *grid = BPH_hair_volume_create_vertex_grid(clmd->sim_parms->voxel_cell_size, gmin, gmax);
-
+
cloth_continuum_fill_grid(grid, cloth);
-
+
/* main hair continuum solver */
BPH_hair_volume_solve_divergence(grid, dt, density_target, density_strength);
-
+
for (i = 0, vert = cloth->verts; i < mvert_num; i++, vert++) {
float x[3], v[3], nv[3];
-
+
/* calculate volumetric velocity influence */
BPH_mass_spring_get_position(data, i, x);
BPH_mass_spring_get_new_velocity(data, i, v);
-
+
BPH_hair_volume_grid_velocity(grid, x, v, fluid_factor, nv);
-
+
interp_v3_v3v3(nv, v, nv, smoothfac);
-
+
/* apply on hair data */
BPH_mass_spring_set_new_velocity(data, i, nv);
}
-
+
/* store basic grid info in the modifier data */
BPH_hair_volume_grid_geometry(grid, &clmd->hair_grid_cellsize, clmd->hair_grid_res, clmd->hair_grid_min, clmd->hair_grid_max);
-
+
#if 0 /* DEBUG hair velocity vector field */
{
const int size = 64;
@@ -738,26 +738,26 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
float offset[3], a[3], b[3];
const int axis = 0;
const float shift = 0.0f;
-
+
copy_v3_v3(offset, clmd->hair_grid_min);
zero_v3(a);
zero_v3(b);
-
+
offset[axis] = shift * clmd->hair_grid_cellsize;
a[(axis+1) % 3] = clmd->hair_grid_max[(axis+1) % 3] - clmd->hair_grid_min[(axis+1) % 3];
b[(axis+2) % 3] = clmd->hair_grid_max[(axis+2) % 3] - clmd->hair_grid_min[(axis+2) % 3];
-
+
BKE_sim_debug_data_clear_category(clmd->debug_data, "grid velocity");
for (j = 0; j < size; ++j) {
for (i = 0; i < size; ++i) {
float x[3], v[3], gvel[3], gvel_smooth[3], gdensity;
-
+
madd_v3_v3v3fl(x, offset, a, (float)i / (float)(size-1));
madd_v3_v3fl(x, b, (float)j / (float)(size-1));
zero_v3(v);
-
+
BPH_hair_volume_grid_interpolate(grid, x, &gdensity, gvel, gvel_smooth, NULL, NULL);
-
+
// BKE_sim_debug_data_add_circle(clmd->debug_data, x, gdensity, 0.7, 0.3, 1, "grid density", i, j, 3111);
if (!is_zero_v3(gvel) || !is_zero_v3(gvel_smooth)) {
float dvel[3];
@@ -770,7 +770,7 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
float col0[3] = {0.0, 0.0, 0.0};
float col1[3] = {0.0, 1.0, 0.0};
float col[3];
-
+
interp_v3_v3v3(col, col0, col1, CLAMPIS(gdensity * clmd->sim_parms->density_strength, 0.0, 1.0));
// BKE_sim_debug_data_add_circle(clmd->debug_data, x, gdensity * clmd->sim_parms->density_strength, 0, 1, 0.4, "grid velocity", i, j, 3115);
// BKE_sim_debug_data_add_dot(clmd->debug_data, x, col[0], col[1], col[2], "grid velocity", i, j, 3115);
@@ -782,7 +782,7 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
}
}
#endif
-
+
BPH_hair_volume_free_vertex_grid(grid);
}
}
@@ -795,7 +795,7 @@ static void cloth_calc_volume_force(ClothModifierData *clmd)
Implicit_Data *data = cloth->implicit;
int mvert_num = cloth->mvert_num;
ClothVertex *vert;
-
+
/* 2.0f is an experimental value that seems to give good results */
float smoothfac = 2.0f * parms->velocity_smooth;
float collfac = 2.0f * parms->collider_friction;
@@ -803,17 +803,17 @@ static void cloth_calc_volume_force(ClothModifierData *clmd)
float minpress = parms->pressure_threshold;
float gmin[3], gmax[3];
int i;
-
+
hair_get_boundbox(clmd, gmin, gmax);
-
+
/* gather velocities & density */
if (smoothfac > 0.0f || pressfac > 0.0f) {
HairVertexGrid *vertex_grid = BPH_hair_volume_create_vertex_grid(clmd->sim_parms->voxel_res, gmin, gmax);
-
+
vert = cloth->verts;
for (i = 0; i < mvert_num; i++, vert++) {
float x[3], v[3];
-
+
if (vert->solver_index < 0) {
copy_v3_v3(x, vert->x);
copy_v3_v3(v, vert->v);
@@ -824,21 +824,21 @@ static void cloth_calc_volume_force(ClothModifierData *clmd)
BPH_hair_volume_add_vertex(vertex_grid, x, v);
}
BPH_hair_volume_normalize_vertex_grid(vertex_grid);
-
+
vert = cloth->verts;
for (i = 0; i < mvert_num; i++, vert++) {
float x[3], v[3], f[3], dfdx[3][3], dfdv[3][3];
-
+
if (vert->solver_index < 0)
continue;
-
+
/* calculate volumetric forces */
BPH_mass_spring_get_motion_state(data, vert->solver_index, x, v);
BPH_hair_volume_vertex_grid_forces(vertex_grid, x, v, smoothfac, pressfac, minpress, f, dfdx, dfdv);
/* apply on hair data */
BPH_mass_spring_force_extern(data, vert->solver_index, f, dfdx, dfdv);
}
-
+
BPH_hair_volume_free_vertex_grid(vertex_grid);
}
}
@@ -854,33 +854,33 @@ static void cloth_collision_solve_extra(Object *ob, ClothModifierData *clmd, Lis
ClothVertex *verts = cloth->verts;
int mvert_num = cloth->mvert_num;
const float spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
-
+
bool do_extra_solve;
int i;
-
+
if (!(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED))
return;
if (!clmd->clothObject->bvhtree)
return;
-
+
// update verts to current positions
for (i = 0; i < mvert_num; i++) {
BPH_mass_spring_get_new_position(id, i, verts[i].tx);
-
+
sub_v3_v3v3(verts[i].tv, verts[i].tx, verts[i].txold);
copy_v3_v3(verts[i].v, verts[i].tv);
}
-
+
#if 0 /* unused */
for (i=0, cv=cloth->verts; i<cloth->mvert_num; i++, cv++) {
copy_v3_v3(initial_cos[i], cv->tx);
}
#endif
-
+
// call collision function
// TODO: check if "step" or "step+dt" is correct - dg
do_extra_solve = cloth_bvh_objcollision(ob, clmd, step / clmd->sim_parms->timescale, dt / clmd->sim_parms->timescale);
-
+
// copy corrected positions back to simulation
for (i = 0; i < mvert_num; i++) {
float curx[3];
@@ -888,41 +888,41 @@ static void cloth_collision_solve_extra(Object *ob, ClothModifierData *clmd, Lis
// correct velocity again, just to be sure we had to change it due to adaptive collisions
sub_v3_v3v3(verts[i].tv, verts[i].tx, curx);
}
-
+
if (do_extra_solve) {
// cloth_calc_helper_forces(ob, clmd, initial_cos, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale);
-
+
for (i = 0; i < mvert_num; i++) {
-
+
float newv[3];
-
+
if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED))
continue;
-
+
BPH_mass_spring_set_new_position(id, i, verts[i].tx);
mul_v3_v3fl(newv, verts[i].tv, spf);
BPH_mass_spring_set_new_velocity(id, i, newv);
}
}
-
+
// X = Xnew;
BPH_mass_spring_apply_result(id);
-
+
if (do_extra_solve) {
ImplicitSolverResult result;
-
+
/* initialize forces to zero */
BPH_mass_spring_clear_forces(id);
-
+
// calculate forces
cloth_calc_force(clmd, frame, effectors, step);
-
+
// calculate new velocity and position
BPH_mass_spring_solve_velocities(id, dt, &result);
// cloth_record_result(clmd, &result, clmd->sim_parms->stepsPerFrame);
-
+
/* note: positions are advanced only once in the main solver step! */
-
+
BPH_mass_spring_apply_result(id);
}
}
@@ -930,7 +930,7 @@ static void cloth_collision_solve_extra(Object *ob, ClothModifierData *clmd, Lis
static void cloth_clear_result(ClothModifierData *clmd)
{
ClothSolverResult *sres = clmd->solver_result;
-
+
sres->status = 0;
sres->max_error = sres->min_error = sres->avg_error = 0.0f;
sres->max_iterations = sres->min_iterations = 0;
@@ -940,7 +940,7 @@ static void cloth_clear_result(ClothModifierData *clmd)
static void cloth_record_result(ClothModifierData *clmd, ImplicitSolverResult *result, int steps)
{
ClothSolverResult *sres = clmd->solver_result;
-
+
if (sres->status) { /* already initialized ? */
/* error only makes sense for successful iterations */
if (result->status == BPH_SOLVER_SUCCESS) {
@@ -948,7 +948,7 @@ static void cloth_record_result(ClothModifierData *clmd, ImplicitSolverResult *r
sres->max_error = max_ff(sres->max_error, result->error);
sres->avg_error += result->error / (float)steps;
}
-
+
sres->min_iterations = min_ii(sres->min_iterations, result->iterations);
sres->max_iterations = max_ii(sres->max_iterations, result->iterations);
sres->avg_iterations += (float)result->iterations / (float)steps;
@@ -959,11 +959,11 @@ static void cloth_record_result(ClothModifierData *clmd, ImplicitSolverResult *r
sres->min_error = sres->max_error = result->error;
sres->avg_error += result->error / (float)steps;
}
-
+
sres->min_iterations = sres->max_iterations = result->iterations;
sres->avg_iterations += (float)result->iterations / (float)steps;
}
-
+
sres->status |= result->status;
}
@@ -974,7 +974,7 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *
* Bad design, TODO
*/
const bool is_hair = (clmd->hairdata != NULL);
-
+
unsigned int i=0;
float step=0.0f, tf=clmd->sim_parms->timescale;
Cloth *cloth = clmd->clothObject;
@@ -984,13 +984,13 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *
Implicit_Data *id = cloth->implicit;
ColliderContacts *contacts = NULL;
int totcolliders = 0;
-
+
BKE_sim_debug_data_clear_category("collision");
-
+
if (!clmd->solver_result)
clmd->solver_result = (ClothSolverResult *)MEM_callocN(sizeof(ClothSolverResult), "cloth solver result");
cloth_clear_result(clmd);
-
+
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) { /* do goal stuff */
for (i = 0; i < mvert_num; i++) {
// update velocities with constrained velocities from pinned verts
@@ -1004,22 +1004,22 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *
}
}
}
-
+
while (step < tf) {
ImplicitSolverResult result;
-
+
/* copy velocities for collision */
for (i = 0; i < mvert_num; i++) {
BPH_mass_spring_get_motion_state(id, i, NULL, verts[i].tv);
copy_v3_v3(verts[i].v, verts[i].tv);
}
-
+
if (is_hair) {
/* determine contact points */
if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED) {
cloth_find_point_contacts(ob, clmd, 0.0f, tf, &contacts, &totcolliders);
}
-
+
/* setup vertex constraints for pinned vertices and contacts */
cloth_setup_constraints(clmd, contacts, totcolliders, dt);
}
@@ -1027,10 +1027,10 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *
/* setup vertex constraints for pinned vertices */
cloth_setup_constraints(clmd, NULL, 0, dt);
}
-
+
/* initialize forces to zero */
BPH_mass_spring_clear_forces(id);
-
+
// damping velocity for artistic reasons
// this is a bad way to do it, should be removed imo - lukas_t
if (clmd->sim_parms->vel_damping != 1.0f) {
@@ -1041,26 +1041,26 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *
BPH_mass_spring_set_velocity(id, i, v);
}
}
-
+
// calculate forces
cloth_calc_force(clmd, frame, effectors, step);
-
+
// calculate new velocity and position
BPH_mass_spring_solve_velocities(id, dt, &result);
cloth_record_result(clmd, &result, clmd->sim_parms->stepsPerFrame);
-
+
if (is_hair) {
cloth_continuum_step(clmd, dt);
}
-
+
BPH_mass_spring_solve_positions(id, dt);
-
+
if (!is_hair) {
cloth_collision_solve_extra(ob, clmd, effectors, frame, step, dt);
}
-
+
BPH_mass_spring_apply_result(id);
-
+
/* move pinned verts to correct position */
for (i = 0; i < mvert_num; i++) {
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) {
@@ -1071,23 +1071,23 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *
BPH_mass_spring_set_position(id, i, x);
}
}
-
+
BPH_mass_spring_get_motion_state(id, i, verts[i].txold, NULL);
}
-
+
/* free contact points */
if (contacts) {
cloth_free_contacts(contacts, totcolliders);
}
-
+
step += dt;
}
-
+
/* copy results back to cloth data */
for (i = 0; i < mvert_num; i++) {
BPH_mass_spring_get_motion_state(id, i, verts[i].x, verts[i].v);
copy_v3_v3(verts[i].txold, verts[i].x);
}
-
+
return 1;
}
diff --git a/source/blender/physics/intern/ConstrainedConjugateGradient.h b/source/blender/physics/intern/ConstrainedConjugateGradient.h
index f9c6931fe8c..2d5fb41cc73 100644
--- a/source/blender/physics/intern/ConstrainedConjugateGradient.h
+++ b/source/blender/physics/intern/ConstrainedConjugateGradient.h
@@ -4,7 +4,7 @@
#include <Eigen/Core>
-namespace Eigen {
+namespace Eigen {
namespace internal {
@@ -29,16 +29,16 @@ void constrained_conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest&
typedef typename Dest::RealScalar RealScalar;
typedef typename Dest::Scalar Scalar;
typedef Matrix<Scalar,Dynamic,1> VectorType;
-
+
RealScalar tol = tol_error;
int maxIters = iters;
-
+
int n = mat.cols();
VectorType residual = filter * (rhs - mat * x); //initial residual
RealScalar rhsNorm2 = (filter * rhs).squaredNorm();
- if(rhsNorm2 == 0)
+ if(rhsNorm2 == 0)
{
/* XXX TODO set constrained result here */
x.setZero();
@@ -54,7 +54,7 @@ void constrained_conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest&
tol_error = sqrt(residualNorm2 / rhsNorm2);
return;
}
-
+
VectorType p(n);
p = filter * precond.solve(residual); //initial search direction
@@ -68,11 +68,11 @@ void constrained_conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest&
Scalar alpha = absNew / p.dot(tmp); // the amount we travel on dir
x += alpha * p; // update solution
residual -= alpha * tmp; // update residue
-
+
residualNorm2 = residual.squaredNorm();
if(residualNorm2 < threshold)
break;
-
+
z = precond.solve(residual); // approximately solve for "A z = residual"
RealScalar absOld = absNew;
@@ -95,20 +95,20 @@ struct MatrixFilter
m_cmat(NULL)
{
}
-
+
MatrixFilter(const MatrixType &cmat) :
m_cmat(&cmat)
{
}
-
+
void setMatrix(const MatrixType &cmat) { m_cmat = &cmat; }
-
+
template <typename VectorType>
void apply(VectorType v) const
{
v = (*m_cmat) * v;
}
-
+
protected:
const MatrixType *m_cmat;
};
@@ -145,7 +145,7 @@ struct traits<ConstrainedConjugateGradient<_MatrixType,_UpLo,_FilterMatrixType,_
* The maximal number of iterations and tolerance value can be controlled via the setMaxIterations()
* and setTolerance() methods. The defaults are the size of the problem for the maximal number of iterations
* and NumTraits<Scalar>::epsilon() for the tolerance.
- *
+ *
* This class can be used as the direct solver classes. Here is a typical usage example:
* \code
* int n = 10000;
@@ -160,7 +160,7 @@ struct traits<ConstrainedConjugateGradient<_MatrixType,_UpLo,_FilterMatrixType,_
* // update b, and solve again
* x = cg.solve(b);
* \endcode
- *
+ *
* By default the iterations start with x=0 as an initial guess of the solution.
* One can control the start using the solveWithGuess() method. Here is a step by
* step execution example starting with a random guess and printing the evolution
@@ -176,7 +176,7 @@ struct traits<ConstrainedConjugateGradient<_MatrixType,_UpLo,_FilterMatrixType,_
* } while (cg.info()!=Success && i<100);
* \endcode
* Note that such a step by step excution is slightly slower.
- *
+ *
* \sa class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner
*/
template< typename _MatrixType, int _UpLo, typename _FilterMatrixType, typename _Preconditioner>
@@ -206,10 +206,10 @@ public:
ConstrainedConjugateGradient() : Base() {}
/** Initialize the solver with matrix \a A for further \c Ax=b solving.
- *
+ *
* This constructor is a shortcut for the default constructor followed
* by a call to compute().
- *
+ *
* \warning this class stores a reference to the matrix A as well as some
* precomputed values that depend on it. Therefore, if \a A is changed
* this class becomes invalid. Call compute() to update it with the new
@@ -258,7 +258,7 @@ public:
m_isInitialized = true;
m_info = m_error <= Base::m_tolerance ? Success : NoConvergence;
}
-
+
/** \internal */
template<typename Rhs,typename Dest>
void _solve(const Rhs& b, Dest& x) const
diff --git a/source/blender/physics/intern/eigen_utils.h b/source/blender/physics/intern/eigen_utils.h
index 8a5a9dbf5e9..4598d3ad3a7 100644
--- a/source/blender/physics/intern/eigen_utils.h
+++ b/source/blender/physics/intern/eigen_utils.h
@@ -56,24 +56,24 @@ typedef float Scalar;
class Vector3 : public Eigen::Vector3f {
public:
typedef float *ctype;
-
+
Vector3()
{
}
-
+
Vector3(const ctype &v)
{
for (int k = 0; k < 3; ++k)
coeffRef(k) = v[k];
}
-
+
Vector3& operator = (const ctype &v)
{
for (int k = 0; k < 3; ++k)
coeffRef(k) = v[k];
return *this;
}
-
+
operator ctype()
{
return data();
@@ -86,18 +86,18 @@ public:
class Matrix3 : public Eigen::Matrix3f {
public:
typedef float (*ctype)[3];
-
+
Matrix3()
{
}
-
+
Matrix3(const ctype &v)
{
for (int k = 0; k < 3; ++k)
for (int l = 0; l < 3; ++l)
coeffRef(l, k) = v[k][l];
}
-
+
Matrix3& operator = (const ctype &v)
{
for (int k = 0; k < 3; ++k)
@@ -105,7 +105,7 @@ public:
coeffRef(l, k) = v[k][l];
return *this;
}
-
+
operator ctype()
{
return (ctype)data();
@@ -120,23 +120,23 @@ typedef Eigen::VectorXf lVector;
class lVector3f : public Eigen::VectorXf {
public:
typedef Eigen::VectorXf base_t;
-
+
lVector3f()
{
}
-
+
template <typename T>
lVector3f& operator = (T rhs)
{
base_t::operator=(rhs);
return *this;
}
-
+
float* v3(int vertex)
{
return &coeffRef(3 * vertex);
}
-
+
const float* v3(int vertex) const
{
return &coeffRef(3 * vertex);
@@ -157,18 +157,18 @@ struct lMatrix3fCtor {
lMatrix3fCtor()
{
}
-
+
void reset()
{
m_trips.clear();
}
-
+
void reserve(int numverts)
{
/* reserve for diagonal entries */
m_trips.reserve(numverts * 9);
}
-
+
void add(int i, int j, const Matrix3 &m)
{
i *= 3;
@@ -177,7 +177,7 @@ struct lMatrix3fCtor {
for (int l = 0; l < 3; ++l)
m_trips.push_back(Triplet(i + k, j + l, m.coeff(l, k)));
}
-
+
void sub(int i, int j, const Matrix3 &m)
{
i *= 3;
@@ -186,13 +186,13 @@ struct lMatrix3fCtor {
for (int l = 0; l < 3; ++l)
m_trips.push_back(Triplet(i + k, j + l, -m.coeff(l, k)));
}
-
+
inline void construct(lMatrix &m)
{
m.setFromTriplets(m_trips.begin(), m_trips.end());
m_trips.clear();
}
-
+
private:
TripletList m_trips;
};
@@ -206,7 +206,7 @@ BLI_INLINE void print_lvector(const lVector3f &v)
for (int i = 0; i < v.rows(); ++i) {
if (i > 0 && i % 3 == 0)
printf("\n");
-
+
printf("%f,\n", v[i]);
}
}
@@ -216,11 +216,11 @@ BLI_INLINE void print_lmatrix(const lMatrix &m)
for (int j = 0; j < m.rows(); ++j) {
if (j > 0 && j % 3 == 0)
printf("\n");
-
+
for (int i = 0; i < m.cols(); ++i) {
if (i > 0 && i % 3 == 0)
printf(" ");
-
+
implicit_print_matrix_elem(m.coeff(j, i));
}
printf("\n");
diff --git a/source/blender/physics/intern/hair_volume.cpp b/source/blender/physics/intern/hair_volume.cpp
index 05d30657af8..b59ac46abbc 100644
--- a/source/blender/physics/intern/hair_volume.cpp
+++ b/source/blender/physics/intern/hair_volume.cpp
@@ -45,12 +45,12 @@ extern "C" {
/* ================ Volumetric Hair Interaction ================
* adapted from
- *
+ *
* Volumetric Methods for Simulation and Rendering of Hair
* (Petrovic, Henne, Anderson, Pixar Technical Memo #06-08, Pixar Animation Studios)
- *
+ *
* as well as
- *
+ *
* "Detail Preserving Continuum Simulation of Straight Hair"
* (McAdams, Selle 2009)
*/
@@ -82,7 +82,7 @@ typedef struct HairGridVert {
int samples;
float velocity[3];
float density;
-
+
float velocity_smooth[3];
} HairGridVert;
@@ -107,20 +107,20 @@ BLI_INLINE int hair_grid_offset(const float vec[3], const int res[3], const floa
BLI_INLINE int hair_grid_interp_weights(const int res[3], const float gmin[3], float scale, const float vec[3], float uvw[3])
{
int i, j, k, offset;
-
+
i = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 0);
j = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 1);
k = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 2);
offset = i + (j + k*res[1])*res[0];
-
+
uvw[0] = (vec[0] - gmin[0]) * scale - (float)i;
uvw[1] = (vec[1] - gmin[1]) * scale - (float)j;
uvw[2] = (vec[2] - gmin[2]) * scale - (float)k;
-
+
// BLI_assert(0.0f <= uvw[0] && uvw[0] <= 1.0001f);
// BLI_assert(0.0f <= uvw[1] && uvw[1] <= 1.0001f);
// BLI_assert(0.0f <= uvw[2] && uvw[2] <= 1.0001f);
-
+
return offset;
}
@@ -131,12 +131,12 @@ BLI_INLINE void hair_grid_interpolate(const HairGridVert *grid, const int res[3]
float uvw[3], muvw[3];
int res2 = res[1] * res[0];
int offset;
-
+
offset = hair_grid_interp_weights(res, gmin, scale, vec, uvw);
muvw[0] = 1.0f - uvw[0];
muvw[1] = 1.0f - uvw[1];
muvw[2] = 1.0f - uvw[2];
-
+
data[0] = grid[offset ];
data[1] = grid[offset +1];
data[2] = grid[offset +res[0] ];
@@ -145,14 +145,14 @@ BLI_INLINE void hair_grid_interpolate(const HairGridVert *grid, const int res[3]
data[5] = grid[offset+res2 +1];
data[6] = grid[offset+res2+res[0] ];
data[7] = grid[offset+res2+res[0]+1];
-
+
if (density) {
*density = muvw[2]*( muvw[1]*( muvw[0]*data[0].density + uvw[0]*data[1].density ) +
uvw[1]*( muvw[0]*data[2].density + uvw[0]*data[3].density ) ) +
uvw[2]*( muvw[1]*( muvw[0]*data[4].density + uvw[0]*data[5].density ) +
uvw[1]*( muvw[0]*data[6].density + uvw[0]*data[7].density ) );
}
-
+
if (velocity) {
int k;
for (k = 0; k < 3; ++k) {
@@ -162,7 +162,7 @@ BLI_INLINE void hair_grid_interpolate(const HairGridVert *grid, const int res[3]
uvw[1]*( muvw[0]*data[6].velocity[k] + uvw[0]*data[7].velocity[k] ) );
}
}
-
+
if (vel_smooth) {
int k;
for (k = 0; k < 3; ++k) {
@@ -172,24 +172,24 @@ BLI_INLINE void hair_grid_interpolate(const HairGridVert *grid, const int res[3]
uvw[1]*( muvw[0]*data[6].velocity_smooth[k] + uvw[0]*data[7].velocity_smooth[k] ) );
}
}
-
+
if (density_gradient) {
density_gradient[0] = muvw[1] * muvw[2] * ( data[0].density - data[1].density ) +
uvw[1] * muvw[2] * ( data[2].density - data[3].density ) +
muvw[1] * uvw[2] * ( data[4].density - data[5].density ) +
uvw[1] * uvw[2] * ( data[6].density - data[7].density );
-
+
density_gradient[1] = muvw[2] * muvw[0] * ( data[0].density - data[2].density ) +
uvw[2] * muvw[0] * ( data[4].density - data[6].density ) +
muvw[2] * uvw[0] * ( data[1].density - data[3].density ) +
uvw[2] * uvw[0] * ( data[5].density - data[7].density );
-
+
density_gradient[2] = muvw[2] * muvw[0] * ( data[0].density - data[4].density ) +
uvw[2] * muvw[0] * ( data[1].density - data[5].density ) +
muvw[2] * uvw[0] * ( data[2].density - data[6].density ) +
uvw[2] * uvw[0] * ( data[3].density - data[7].density );
}
-
+
if (velocity_gradient) {
/* XXX TODO */
zero_m3(velocity_gradient);
@@ -201,21 +201,21 @@ void BPH_hair_volume_vertex_grid_forces(HairGrid *grid, const float x[3], const
float f[3], float dfdx[3][3], float dfdv[3][3])
{
float gdensity, gvelocity[3], ggrad[3], gvelgrad[3][3], gradlen;
-
+
hair_grid_interpolate(grid->verts, grid->res, grid->gmin, grid->inv_cellsize, x, &gdensity, gvelocity, NULL, ggrad, gvelgrad);
-
+
zero_v3(f);
sub_v3_v3(gvelocity, v);
mul_v3_v3fl(f, gvelocity, smoothfac);
-
+
gradlen = normalize_v3(ggrad) - minpressure;
if (gradlen > 0.0f) {
mul_v3_fl(ggrad, gradlen);
madd_v3_v3fl(f, ggrad, pressurefac);
}
-
+
zero_m3(dfdx);
-
+
sub_m3_m3m3(dfdv, gvelgrad, I);
mul_m3_fl(dfdv, smoothfac);
}
@@ -232,16 +232,16 @@ void BPH_hair_volume_grid_velocity(HairGrid *grid, const float x[3], const float
{
float gdensity, gvelocity[3], gvel_smooth[3], ggrad[3], gvelgrad[3][3];
float v_pic[3], v_flip[3];
-
+
hair_grid_interpolate(grid->verts, grid->res, grid->gmin, grid->inv_cellsize, x, &gdensity, gvelocity, gvel_smooth, ggrad, gvelgrad);
-
+
/* velocity according to PIC method (Particle-in-Cell) */
copy_v3_v3(v_pic, gvel_smooth);
-
+
/* velocity according to FLIP method (Fluid-Implicit-Particle) */
sub_v3_v3v3(v_flip, gvel_smooth, gvelocity);
add_v3_v3(v_flip, v);
-
+
interp_v3_v3v3(r_v, v_pic, v_flip, fluid_factor);
}
@@ -283,16 +283,16 @@ BLI_INLINE int hair_grid_weights(const int res[3], const float gmin[3], float sc
{
int i, j, k, offset;
float uvw[3];
-
+
i = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 0);
j = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 1);
k = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 2);
offset = i + (j + k*res[1])*res[0];
-
+
uvw[0] = (vec[0] - gmin[0]) * scale;
uvw[1] = (vec[1] - gmin[1]) * scale;
uvw[2] = (vec[2] - gmin[2]) * scale;
-
+
weights[0] = dist_tent_v3f3(uvw, (float)i , (float)j , (float)k );
weights[1] = dist_tent_v3f3(uvw, (float)(i+1), (float)j , (float)k );
weights[2] = dist_tent_v3f3(uvw, (float)i , (float)(j+1), (float)k );
@@ -301,9 +301,9 @@ BLI_INLINE int hair_grid_weights(const int res[3], const float gmin[3], float sc
weights[5] = dist_tent_v3f3(uvw, (float)(i+1), (float)j , (float)(k+1));
weights[6] = dist_tent_v3f3(uvw, (float)i , (float)(j+1), (float)(k+1));
weights[7] = dist_tent_v3f3(uvw, (float)(i+1), (float)(j+1), (float)(k+1));
-
+
// BLI_assert(fabsf(weights_sum(weights) - 1.0f) < 0.0001f);
-
+
return offset;
}
@@ -320,18 +320,18 @@ void BPH_hair_volume_add_vertex(HairGrid *grid, const float x[3], const float v[
float weights[8];
int di, dj, dk;
int offset;
-
+
if (!hair_grid_point_valid(x, grid->gmin, grid->gmax))
return;
-
+
offset = hair_grid_weights(res, grid->gmin, grid->inv_cellsize, x, weights);
-
+
for (di = 0; di < 2; ++di) {
for (dj = 0; dj < 2; ++dj) {
for (dk = 0; dk < 2; ++dk) {
int voffset = offset + di + (dj + dk*res[1])*res[0];
int iw = di + dj*2 + dk*4;
-
+
grid->verts[voffset].density += weights[iw];
madd_v3_v3fl(grid->verts[voffset].velocity, v, weights[iw]);
}
@@ -344,15 +344,15 @@ BLI_INLINE void hair_volume_eval_grid_vertex(HairGridVert *vert, const float loc
const float x2[3], const float v2[3], const float x3[3], const float v3[3])
{
float closest[3], lambda, dist, weight;
-
+
lambda = closest_to_line_v3(closest, loc, x2, x3);
dist = len_v3v3(closest, loc);
-
+
weight = (radius - dist) * dist_scale;
-
+
if (weight > 0.0f) {
float vel[3];
-
+
interp_v3_v3v3(vel, v2, v3, lambda);
madd_v3_v3fl(vert->velocity, vel, weight);
vert->density += weight;
@@ -378,37 +378,37 @@ BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
{
const float radius = 1.5f;
const float dist_scale = grid->inv_cellsize;
-
+
int j, k;
-
+
/* boundary checks to be safe */
CLAMP_MIN(jmin, 0);
CLAMP_MAX(jmax, resj-1);
CLAMP_MIN(kmin, 0);
CLAMP_MAX(kmax, resk-1);
-
+
HairGridVert *vert_j = vert + jmin * stride_j;
float loc_j[3] = { loc[0], loc[1], loc[2] };
loc_j[axis_j] += (float)jmin;
for (j = jmin; j <= jmax; ++j, vert_j += stride_j, loc_j[axis_j] += 1.0f) {
-
+
HairGridVert *vert_k = vert_j + kmin * stride_k;
float loc_k[3] = { loc_j[0], loc_j[1], loc_j[2] };
loc_k[axis_k] += (float)kmin;
for (k = kmin; k <= kmax; ++k, vert_k += stride_k, loc_k[axis_k] += 1.0f) {
-
+
hair_volume_eval_grid_vertex(vert_k, loc_k, radius, dist_scale, x2, v2, x3, v3);
-
+
#if 0
{
float wloc[3], x2w[3], x3w[3];
grid_to_world(grid, wloc, loc_k);
grid_to_world(grid, x2w, x2);
grid_to_world(grid, x3w, x3);
-
+
if (vert_k->samples > 0)
BKE_sim_debug_data_add_circle(wloc, 0.01f, 1.0, 1.0, 0.3, "grid", 2525, debug_i, j, k);
-
+
if (grid->debug_value) {
BKE_sim_debug_data_add_dot(wloc, 1, 0, 0, "grid", 93, debug_i, j, k);
BKE_sim_debug_data_add_dot(x2w, 0.1, 0.1, 0.7, "grid", 649, debug_i, j, k);
@@ -423,11 +423,11 @@ BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
}
/* Uses a variation of Bresenham's algorithm for rasterizing a 3D grid with a line segment.
- *
+ *
* The radius of influence around a segment is assumed to be at most 2*cellsize,
* i.e. only cells containing the segment and their direct neighbors are examined.
- *
- *
+ *
+ *
*/
void BPH_hair_volume_add_segment(HairGrid *grid,
const float x1[3], const float v1[3], const float x2[3], const float v2[3],
@@ -435,55 +435,55 @@ void BPH_hair_volume_add_segment(HairGrid *grid,
const float dir1[3], const float dir2[3], const float dir3[3])
{
const int res[3] = { grid->res[0], grid->res[1], grid->res[2] };
-
+
/* find the primary direction from the major axis of the direction vector */
const int axis0 = major_axis_v3(dir2);
const int axis1 = (axis0 + 1) % 3;
const int axis2 = (axis0 + 2) % 3;
-
+
/* vertex buffer offset factors along cardinal axes */
const int strides[3] = { 1, res[0], res[0] * res[1] };
const int stride0 = strides[axis0];
const int stride1 = strides[axis1];
const int stride2 = strides[axis2];
-
+
/* increment of secondary directions per step in the primary direction
* note: we always go in the positive direction along axis0, so the sign can be inverted
*/
const float inc1 = dir2[axis1] / dir2[axis0];
const float inc2 = dir2[axis2] / dir2[axis0];
-
+
/* start/end points, so increment along axis0 is always positive */
const float *start = x2[axis0] < x3[axis0] ? x2 : x3;
const float *end = x2[axis0] < x3[axis0] ? x3 : x2;
const float start0 = start[axis0], start1 = start[axis1], start2 = start[axis2];
const float end0 = end[axis0];
-
+
/* range along primary direction */
const int imin = max_ii(floor_int(start[axis0]) - 1, 0);
const int imax = min_ii(floor_int(end[axis0]) + 2, res[axis0]-1);
-
+
float h = 0.0f;
HairGridVert *vert0;
float loc0[3];
int j0, k0, j0_prev, k0_prev;
int i;
-
+
for (i = imin; i <= imax; ++i) {
float shift1, shift2; /* fraction of a full cell shift [0.0, 1.0) */
int jmin, jmax, kmin, kmax;
-
+
h = CLAMPIS((float)i, start0, end0);
-
+
shift1 = start1 + (h - start0) * inc1;
shift2 = start2 + (h - start0) * inc2;
-
+
j0_prev = j0;
j0 = floor_int(shift1);
-
+
k0_prev = k0;
k0 = floor_int(shift2);
-
+
if (i > imin) {
jmin = min_ii(j0, j0_prev);
jmax = max_ii(j0, j0_prev);
@@ -494,12 +494,12 @@ void BPH_hair_volume_add_segment(HairGrid *grid,
jmin = jmax = j0;
kmin = kmax = k0;
}
-
+
vert0 = grid->verts + i * stride0;
loc0[axis0] = (float)i;
loc0[axis1] = 0.0f;
loc0[axis2] = 0.0f;
-
+
hair_volume_add_segment_2D(grid, x1, v1, x2, v2, x3, v3, x4, v4, dir1, dir2, dir3,
res[axis1], res[axis2], jmin-1, jmax+2, kmin-1, kmax+2,
vert0, stride1, stride2, loc0, axis1, axis2,
@@ -511,11 +511,11 @@ BLI_INLINE void hair_volume_eval_grid_vertex_sample(HairGridVert *vert, const fl
const float x[3], const float v[3])
{
float dist, weight;
-
+
dist = len_v3v3(x, loc);
-
+
weight = (radius - dist) * dist_scale;
-
+
if (weight > 0.0f) {
madd_v3_v3fl(vert->velocity, v, weight);
vert->density += weight;
@@ -533,34 +533,34 @@ void BPH_hair_volume_add_segment(HairGrid *grid,
{
const float radius = 1.5f;
const float dist_scale = grid->inv_cellsize;
-
+
const int res[3] = { grid->res[0], grid->res[1], grid->res[2] };
const int stride[3] = { 1, res[0], res[0] * res[1] };
const int num_samples = 10;
-
+
int s;
-
+
for (s = 0; s < num_samples; ++s) {
float x[3], v[3];
int i, j, k;
-
+
float f = (float)s / (float)(num_samples-1);
interp_v3_v3v3(x, x2, x3, f);
interp_v3_v3v3(v, v2, v3, f);
-
+
int imin = max_ii(floor_int(x[0]) - 2, 0);
int imax = min_ii(floor_int(x[0]) + 2, res[0]-1);
int jmin = max_ii(floor_int(x[1]) - 2, 0);
int jmax = min_ii(floor_int(x[1]) + 2, res[1]-1);
int kmin = max_ii(floor_int(x[2]) - 2, 0);
int kmax = min_ii(floor_int(x[2]) + 2, res[2]-1);
-
+
for (k = kmin; k <= kmax; ++k) {
for (j = jmin; j <= jmax; ++j) {
for (i = imin; i <= imax; ++i) {
float loc[3] = { (float)i, (float)j, (float)k };
HairGridVert *vert = grid->verts + i * stride[0] + j * stride[1] + k * stride[2];
-
+
hair_volume_eval_grid_vertex_sample(vert, loc, radius, dist_scale, x, v);
}
}
@@ -598,25 +598,25 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
{
const float flowfac = grid->cellsize;
const float inv_flowfac = 1.0f / grid->cellsize;
-
+
/*const int num_cells = hair_grid_size(grid->res);*/
const int res[3] = { grid->res[0], grid->res[1], grid->res[2] };
const int resA[3] = { grid->res[0] + 2, grid->res[1] + 2, grid->res[2] + 2 };
-
+
const int stride0 = 1;
const int stride1 = grid->res[0];
const int stride2 = grid->res[1] * grid->res[0];
const int strideA0 = 1;
const int strideA1 = grid->res[0] + 2;
const int strideA2 = (grid->res[1] + 2) * (grid->res[0] + 2);
-
+
const int num_cells = res[0] * res[1] * res[2];
const int num_cellsA = (res[0] + 2) * (res[1] + 2) * (res[2] + 2);
-
+
HairGridVert *vert_start = grid->verts - (stride0 + stride1 + stride2);
HairGridVert *vert;
int i, j, k;
-
+
#define MARGIN_i0 (i < 1)
#define MARGIN_j0 (j < 1)
#define MARGIN_k0 (k < 1)
@@ -630,9 +630,9 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
#define NEIGHBOR_MARGIN_i1 (i >= resA[0]-2)
#define NEIGHBOR_MARGIN_j1 (j >= resA[1]-2)
#define NEIGHBOR_MARGIN_k1 (k >= resA[2]-2)
-
+
BLI_assert(num_cells >= 1);
-
+
/* Calculate divergence */
lVector B(num_cellsA);
for (k = 0; k < resA[2]; ++k) {
@@ -640,14 +640,14 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
for (i = 0; i < resA[0]; ++i) {
int u = i * strideA0 + j * strideA1 + k * strideA2;
bool is_margin = MARGIN_i0 || MARGIN_i1 || MARGIN_j0 || MARGIN_j1 || MARGIN_k0 || MARGIN_k1;
-
+
if (is_margin) {
B[u] = 0.0f;
continue;
}
-
+
vert = vert_start + i * stride0 + j * stride1 + k * stride2;
-
+
const float *v0 = vert->velocity;
float dx = 0.0f, dy = 0.0f, dz = 0.0f;
if (!NEIGHBOR_MARGIN_i0)
@@ -662,19 +662,19 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
dz += v0[2] - (vert - stride2)->velocity[2];
if (!NEIGHBOR_MARGIN_k1)
dz += (vert + stride2)->velocity[2] - v0[2];
-
+
float divergence = -0.5f * flowfac * (dx + dy + dz);
-
+
/* adjustment term for target density */
float target = hair_volume_density_divergence(vert->density, target_density, target_strength);
-
+
/* B vector contains the finite difference approximation of the velocity divergence.
* Note: according to the discretized Navier-Stokes equation the rhs vector
* and resulting pressure gradient should be multiplied by the (inverse) density;
* however, this is already included in the weighting of hair velocities on the grid!
*/
B[u] = divergence - target;
-
+
#if 0
{
float wloc[3], loc[3];
@@ -683,12 +683,12 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
float coln[3] = {1.0, 0.0, 1.0};
float col[3];
float fac;
-
+
loc[0] = (float)(i - 1);
loc[1] = (float)(j - 1);
loc[2] = (float)(k - 1);
grid_to_world(grid, wloc, loc);
-
+
if (divergence > 0.0f) {
fac = CLAMPIS(divergence * target_strength, 0.0, 1.0);
interp_v3_v3v3(col, col0, colp, fac);
@@ -704,11 +704,11 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
}
}
}
-
+
/* Main Poisson equation system:
* This is derived from the discretezation of the Poisson equation
* div(grad(p)) = div(v)
- *
+ *
* The finite difference approximation yields the linear equation system described here:
* https://en.wikipedia.org/wiki/Discrete_Poisson_equation
*/
@@ -718,13 +718,13 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
* and up to 6 factors -1 on other places.
*/
A.reserve(Eigen::VectorXi::Constant(num_cellsA, 7));
-
+
for (k = 0; k < resA[2]; ++k) {
for (j = 0; j < resA[1]; ++j) {
for (i = 0; i < resA[0]; ++i) {
int u = i * strideA0 + j * strideA1 + k * strideA2;
bool is_margin = MARGIN_i0 || MARGIN_i1 || MARGIN_j0 || MARGIN_j1 || MARGIN_k0 || MARGIN_k1;
-
+
vert = vert_start + i * stride0 + j * stride1 + k * stride2;
if (!is_margin && vert->density > density_threshold) {
int neighbors_lo = 0;
@@ -733,7 +733,7 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
int neighbor_lo_index[3];
int neighbor_hi_index[3];
int n;
-
+
/* check for upper bounds in advance
* to get the correct number of neighbors,
* needed for the diagonal element
@@ -750,10 +750,10 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
neighbor_hi_index[neighbors_hi++] = u + strideA1;
if (!NEIGHBOR_MARGIN_k1 && (vert + stride2)->density > density_threshold)
neighbor_hi_index[neighbors_hi++] = u + strideA2;
-
+
/*int liquid_neighbors = neighbors_lo + neighbors_hi;*/
non_solid_neighbors = 6;
-
+
for (n = 0; n < neighbors_lo; ++n)
A.insert(neighbor_lo_index[n], u) = -1.0f;
A.insert(u, u) = (float)non_solid_neighbors;
@@ -766,15 +766,15 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
}
}
}
-
+
ConjugateGradient cg;
cg.setMaxIterations(100);
cg.setTolerance(0.01f);
-
+
cg.compute(A);
-
+
lVector p = cg.solve(B);
-
+
if (cg.info() == Eigen::Success) {
/* Calculate velocity = grad(p) */
for (k = 0; k < resA[2]; ++k) {
@@ -784,7 +784,7 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
bool is_margin = MARGIN_i0 || MARGIN_i1 || MARGIN_j0 || MARGIN_j1 || MARGIN_k0 || MARGIN_k1;
if (is_margin)
continue;
-
+
vert = vert_start + i * stride0 + j * stride1 + k * stride2;
if (vert->density > density_threshold) {
float p_left = p[u - strideA0];
@@ -793,14 +793,14 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
float p_up = p[u + strideA1];
float p_bottom = p[u - strideA2];
float p_top = p[u + strideA2];
-
+
/* finite difference estimate of pressure gradient */
float dvel[3];
dvel[0] = p_right - p_left;
dvel[1] = p_up - p_down;
dvel[2] = p_top - p_bottom;
mul_v3_fl(dvel, -0.5f * inv_flowfac);
-
+
/* pressure gradient describes velocity delta */
add_v3_v3v3(vert->velocity_smooth, vert->velocity, dvel);
}
@@ -810,14 +810,14 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
}
}
}
-
+
#if 0
{
int axis = 0;
float offset = 0.0f;
-
+
int slice = (offset - grid->gmin[axis]) / grid->cellsize;
-
+
for (k = 0; k < resA[2]; ++k) {
for (j = 0; j < resA[1]; ++j) {
for (i = 0; i < resA[0]; ++i) {
@@ -825,21 +825,21 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
bool is_margin = MARGIN_i0 || MARGIN_i1 || MARGIN_j0 || MARGIN_j1 || MARGIN_k0 || MARGIN_k1;
if (i != slice)
continue;
-
+
vert = vert_start + i * stride0 + j * stride1 + k * stride2;
-
+
float wloc[3], loc[3];
float col0[3] = {0.0, 0.0, 0.0};
float colp[3] = {0.0, 1.0, 1.0};
float coln[3] = {1.0, 0.0, 1.0};
float col[3];
float fac;
-
+
loc[0] = (float)(i - 1);
loc[1] = (float)(j - 1);
loc[2] = (float)(k - 1);
grid_to_world(grid, wloc, loc);
-
+
float pressure = p[u];
if (pressure > 0.0f) {
fac = CLAMPIS(pressure * grid->debug1, 0.0, 1.0);
@@ -851,19 +851,19 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
}
if (fac > 0.05f)
BKE_sim_debug_data_add_circle(grid->debug_data, wloc, 0.01f, col[0], col[1], col[2], "grid", 5533, i, j, k);
-
+
if (!is_margin) {
float dvel[3];
sub_v3_v3v3(dvel, vert->velocity_smooth, vert->velocity);
// BKE_sim_debug_data_add_vector(grid->debug_data, wloc, dvel, 1, 1, 1, "grid", 5566, i, j, k);
}
-
+
if (!is_margin) {
float d = CLAMPIS(vert->density * grid->debug2, 0.0f, 1.0f);
float col0[3] = {0.3, 0.3, 0.3};
float colp[3] = {0.0, 0.0, 1.0};
float col[3];
-
+
interp_v3_v3v3(col, col0, colp, d);
// if (d > 0.05f)
// BKE_sim_debug_data_add_dot(grid->debug_data, wloc, col[0], col[1], col[2], "grid", 5544, i, j, k);
@@ -873,7 +873,7 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
}
}
#endif
-
+
return true;
}
else {
@@ -881,7 +881,7 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
for (i = 0, vert = grid->verts; i < num_cells; ++i, ++vert) {
zero_v3(vert->velocity_smooth);
}
-
+
return false;
}
}
@@ -901,20 +901,20 @@ BLI_INLINE void hair_volume_filter_box_convolute(HairVertexGrid *grid, float inv
int offset, kernel_offset, kernel_dq, kernel_dr;
HairGridVert *verts;
float *vel_smooth;
-
+
offset = i + (j + k*res)*res;
verts = grid->verts;
vel_smooth = verts[offset].velocity_smooth;
-
+
kernel_offset = minp + (minq + minr*res)*res;
kernel_dq = res;
kernel_dr = res * res;
for (r = minr; r <= maxr; ++r) {
for (q = minq; q <= maxq; ++q) {
for (p = minp; p <= maxp; ++p) {
-
+
madd_v3_v3fl(vel_smooth, verts[kernel_offset].velocity, invD);
-
+
kernel_offset += 1;
}
kernel_offset += kernel_dq;
@@ -930,18 +930,18 @@ void BPH_hair_volume_vertex_grid_filter_box(HairVertexGrid *grid, int kernel_siz
int tot;
float invD;
int i, j, k;
-
+
if (kernel_size <= 0)
return;
-
+
tot = kernel_size * 2 + 1;
invD = 1.0f / (float)(tot*tot*tot);
-
+
/* clear values for convolution */
for (i = 0; i < size; ++i) {
zero_v3(grid->verts[i].velocity_smooth);
}
-
+
for (i = 0; i < grid->res; ++i) {
for (j = 0; j < grid->res; ++j) {
for (k = 0; k < grid->res; ++k) {
@@ -949,7 +949,7 @@ void BPH_hair_volume_vertex_grid_filter_box(HairVertexGrid *grid, int kernel_siz
}
}
}
-
+
/* apply as new velocity */
for (i = 0; i < size; ++i) {
copy_v3_v3(grid->verts[i].velocity, grid->verts[i].velocity_smooth);
@@ -966,21 +966,21 @@ HairGrid *BPH_hair_volume_create_vertex_grid(float cellsize, const float gmin[3]
int size;
HairGrid *grid;
int i;
-
+
/* sanity check */
if (cellsize <= 0.0f)
cellsize = 1.0f;
scale = 1.0f / cellsize;
-
+
sub_v3_v3v3(extent, gmax, gmin);
for (i = 0; i < 3; ++i) {
resmin[i] = floor_int(gmin[i] * scale);
resmax[i] = floor_int(gmax[i] * scale) + 1;
-
+
/* add margin of 1 cell */
resmin[i] -= 1;
resmax[i] += 1;
-
+
res[i] = resmax[i] - resmin[i] + 1;
/* sanity check: avoid null-sized grid */
if (res[i] < 4) {
@@ -992,12 +992,12 @@ HairGrid *BPH_hair_volume_create_vertex_grid(float cellsize, const float gmin[3]
res[i] = MAX_HAIR_GRID_RES;
resmax[i] = resmin[i] + MAX_HAIR_GRID_RES;
}
-
+
gmin_margin[i] = (float)resmin[i] * cellsize;
gmax_margin[i] = (float)resmax[i] * cellsize;
}
size = hair_grid_size(res);
-
+
grid = (HairGrid *)MEM_callocN(sizeof(HairGrid), "hair grid");
grid->res[0] = res[0];
grid->res[1] = res[1];
@@ -1062,23 +1062,23 @@ static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd,
float vel[3];
float weights[8];
int di, dj, dk;
-
+
for (v=0; v < col->collmd->numverts; v++, loc0++, loc1++) {
int offset;
-
+
if (!hair_grid_point_valid(loc1->co, gmin, gmax))
continue;
-
+
offset = hair_grid_weights(res, gmin, scale, lX[v], weights);
-
+
sub_v3_v3v3(vel, loc1->co, loc0->co);
-
+
for (di = 0; di < 2; ++di) {
for (dj = 0; dj < 2; ++dj) {
for (dk = 0; dk < 2; ++dk) {
int voffset = offset + di + (dj + dk*res)*res;
int iw = di + dj*2 + dk*4;
-
+
collgrid[voffset].density += weights[iw];
madd_v3_v3fl(collgrid[voffset].velocity, vel, weights[iw]);
}
@@ -1095,7 +1095,7 @@ static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd,
if (density > 0.0f)
mul_v3_fl(collgrid[i].velocity, 1.0f/density);
}
-
+
return collgrid;
}
#endif
diff --git a/source/blender/physics/intern/implicit.h b/source/blender/physics/intern/implicit.h
index d6bf5c6b7bf..2eadd3171b0 100644
--- a/source/blender/physics/intern/implicit.h
+++ b/source/blender/physics/intern/implicit.h
@@ -62,7 +62,7 @@ struct Implicit_Data;
typedef struct ImplicitSolverResult {
int status;
-
+
int iterations;
float error;
} ImplicitSolverResult;
diff --git a/source/blender/physics/intern/implicit_blender.c b/source/blender/physics/intern/implicit_blender.c
index 0fdc1d86d5c..5fd9c6b50de 100644
--- a/source/blender/physics/intern/implicit_blender.c
+++ b/source/blender/physics/intern/implicit_blender.c
@@ -71,9 +71,9 @@ static float ZERO[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
/*
#define C99
#ifdef C99
-#defineDO_INLINE inline
-#else
-#defineDO_INLINE static
+#defineDO_INLINE inline
+#else
+#defineDO_INLINE static
#endif
*/
struct Cloth;
@@ -90,7 +90,7 @@ typedef struct fmatrix3x3 {
/* int pinned; // is this vertex allowed to move? */
float n1, n2, n3; /* three normal vectors for collision constrains */
unsigned int vcount; /* vertex count */
- unsigned int scount; /* spring count */
+ unsigned int scount; /* spring count */
} fmatrix3x3;
///////////////////////////
@@ -115,9 +115,9 @@ DO_INLINE void mul_fvectorT_fvector(float to[3][3], float vectorA[3], float vect
/* simple v^T * v product with scalar ("outer product") */
/* STATUS: HAS TO BE verified (*should* work) */
DO_INLINE void mul_fvectorT_fvectorS(float to[3][3], float vectorA[3], float vectorB[3], float aS)
-{
+{
mul_fvectorT_fvector(to, vectorA, vectorB);
-
+
mul_fvector_S(to[0], to[0], aS);
mul_fvector_S(to[1], to[1], aS);
mul_fvector_S(to[2], to[2], aS);
@@ -288,7 +288,7 @@ static void print_lvector(lfVector *v, int numverts)
for (i = 0; i < numverts; ++i) {
if (i > 0)
printf("\n");
-
+
printf("%f,\n", v[i][0]);
printf("%f,\n", v[i][1]);
printf("%f,\n", v[i][2]);
@@ -303,11 +303,11 @@ static void print_bfmatrix(fmatrix3x3 *m)
int size = m[0].vcount * 3;
float *t = MEM_callocN(sizeof(float) * size*size, "bfmatrix");
int q, i, j;
-
+
for (q = 0; q < tot; ++q) {
int k = 3 * m[q].r;
int l = 3 * m[q].c;
-
+
for (j = 0; j < 3; ++j) {
for (i = 0; i < 3; ++i) {
// if (t[k + i + (l + j) * size] != 0.0f) {
@@ -323,20 +323,20 @@ static void print_bfmatrix(fmatrix3x3 *m)
}
}
}
-
+
for (j = 0; j < size; ++j) {
if (j > 0 && j % 3 == 0)
printf("\n");
-
+
for (i = 0; i < size; ++i) {
if (i > 0 && i % 3 == 0)
printf(" ");
-
+
implicit_print_matrix_elem(t[i + j * size]);
}
printf("\n");
}
-
+
MEM_freeN(t);
}
#endif
@@ -354,7 +354,7 @@ DO_INLINE void cp_fmatrix(float to[3][3], float from[3][3])
DO_INLINE void initdiag_fmatrixS(float to[3][3], float aS)
{
cp_fmatrix(to, ZERO);
-
+
to[0][0] = aS;
to[1][1] = aS;
to[2][2] = aS;
@@ -532,15 +532,15 @@ DO_INLINE fmatrix3x3 *create_bfmatrix(unsigned int verts, unsigned int springs)
// TODO: check if memory allocation was successful */
fmatrix3x3 *temp = (fmatrix3x3 *)MEM_callocN(sizeof(fmatrix3x3) * (verts + springs), "cloth_implicit_alloc_matrix");
int i;
-
+
temp[0].vcount = verts;
temp[0].scount = springs;
-
+
/* vertex part of the matrix is diagonal blocks */
for (i = 0; i < verts; ++i) {
init_fmatrix(temp + i, i, i);
}
-
+
return temp;
}
/* delete big matrix */
@@ -565,7 +565,7 @@ DO_INLINE void init_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
unsigned int i;
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
- cp_fmatrix(matrix[i].m, m3);
+ cp_fmatrix(matrix[i].m, m3);
}
}
@@ -577,10 +577,10 @@ DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
float tmatrix[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
for (i = 0; i < matrix[0].vcount; i++) {
- cp_fmatrix(matrix[i].m, m3);
+ cp_fmatrix(matrix[i].m, m3);
}
for (j = matrix[0].vcount; j < matrix[0].vcount+matrix[0].scount; j++) {
- cp_fmatrix(matrix[j].m, tmatrix);
+ cp_fmatrix(matrix[j].m, tmatrix);
}
}
@@ -591,7 +591,7 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector
unsigned int i = 0;
unsigned int vcount = from[0].vcount;
lfVector *temp = create_lfvector(vcount);
-
+
zero_lfvector(to, vcount);
#pragma omp parallel sections private(i) if (vcount > CLOTH_OPENMP_LIMIT)
@@ -610,10 +610,10 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector
}
}
add_lfvector_lfvector(to, to, temp, from[0].vcount);
-
+
del_lfvector(temp);
-
-
+
+
}
/* SPARSE SYMMETRIC sub big matrix with big matrix*/
@@ -642,15 +642,15 @@ typedef struct Implicit_Data {
lfVector *F; /* forces */
fmatrix3x3 *dFdV, *dFdX; /* force jacobians */
int num_blocks; /* number of off-diagonal blocks (springs) */
-
+
/* motion state data */
lfVector *X, *Xnew; /* positions */
lfVector *V, *Vnew; /* velocities */
-
+
/* internal solver data */
lfVector *B; /* B for A*dV = B */
fmatrix3x3 *A; /* A for A*dV = B */
-
+
lfVector *dV; /* velocity change (solution of A*dV = B) */
lfVector *z; /* target velocity in constrained directions */
fmatrix3x3 *S; /* filtering matrix for constraints */
@@ -660,7 +660,7 @@ typedef struct Implicit_Data {
Implicit_Data *BPH_mass_spring_solver_create(int numverts, int numsprings)
{
Implicit_Data *id = (Implicit_Data *)MEM_callocN(sizeof(Implicit_Data), "implicit vecmat");
-
+
/* process diagonal elements */
id->tfm = create_bfmatrix(numverts, 0);
id->A = create_bfmatrix(numverts, numsprings);
@@ -696,7 +696,7 @@ void BPH_mass_spring_solver_free(Implicit_Data *id)
del_bfmatrix(id->Pinv);
del_bfmatrix(id->bigI);
del_bfmatrix(id->M);
-
+
del_lfvector(id->X);
del_lfvector(id->Xnew);
del_lfvector(id->V);
@@ -705,7 +705,7 @@ void BPH_mass_spring_solver_free(Implicit_Data *id)
del_lfvector(id->B);
del_lfvector(id->dV);
del_lfvector(id->z);
-
+
MEM_freeN(id);
}
@@ -752,7 +752,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z
// Solves for unknown X in equation AX=B
unsigned int conjgrad_loopcount=0, conjgrad_looplimit=100;
float conjgrad_epsilon=0.0001f /* , conjgrad_lasterror=0 */ /* UNUSED */;
- lfVector *q, *d, *tmp, *r;
+ lfVector *q, *d, *tmp, *r;
float s, starget, a, s_prev;
unsigned int numverts = lA[0].vcount;
q = create_lfvector(numverts);
@@ -818,7 +818,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z,
// Solves for unknown X in equation AX=B
unsigned int conjgrad_loopcount=0, conjgrad_looplimit=100;
float conjgrad_epsilon=0.01f;
-
+
unsigned int numverts = lA[0].vcount;
lfVector *fB = create_lfvector(numverts);
lfVector *AdV = create_lfvector(numverts);
@@ -827,27 +827,27 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z,
lfVector *q = create_lfvector(numverts);
lfVector *s = create_lfvector(numverts);
float bnorm2, delta_new, delta_old, delta_target, alpha;
-
+
cp_lfvector(ldV, z, numverts);
-
+
/* d0 = filter(B)^T * P * filter(B) */
cp_lfvector(fB, lB, numverts);
filter(fB, S);
bnorm2 = dot_lfvector(fB, fB, numverts);
delta_target = conjgrad_epsilon*conjgrad_epsilon * bnorm2;
-
+
/* r = filter(B - A * dV) */
mul_bfmatrix_lfvector(AdV, lA, ldV);
sub_lfvector_lfvector(r, lB, AdV, numverts);
filter(r, S);
-
+
/* c = filter(P^-1 * r) */
cp_lfvector(c, r, numverts);
filter(c, S);
-
+
/* delta = r^T * c */
delta_new = dot_lfvector(r, c, numverts);
-
+
#ifdef IMPLICIT_PRINT_SOLVER_INPUT_OUTPUT
printf("==== A ====\n");
print_bfmatrix(lA);
@@ -858,25 +858,25 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z,
printf("==== S ====\n");
print_bfmatrix(S);
#endif
-
+
while (delta_new > delta_target && conjgrad_loopcount < conjgrad_looplimit) {
mul_bfmatrix_lfvector(q, lA, c);
filter(q, S);
-
+
alpha = delta_new / dot_lfvector(c, q, numverts);
-
+
add_lfvector_lfvectorS(ldV, ldV, c, alpha, numverts);
-
+
add_lfvector_lfvectorS(r, r, q, -alpha, numverts);
-
+
/* s = P^-1 * r */
cp_lfvector(s, r, numverts);
delta_old = delta_new;
delta_new = dot_lfvector(r, s, numverts);
-
+
add_lfvector_lfvectorS(c, s, c, delta_new / delta_old, numverts);
filter(c, S);
-
+
conjgrad_loopcount++;
}
@@ -885,7 +885,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z,
print_lvector(ldV, numverts);
printf("========\n");
#endif
-
+
del_lfvector(fB);
del_lfvector(AdV);
del_lfvector(r);
@@ -906,14 +906,14 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z,
DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv)
{
unsigned int i = 0;
-
+
// Take only the diagonal blocks of A
// #pragma omp parallel for private(i) if (lA[0].vcount > CLOTH_OPENMP_LIMIT)
for (i = 0; i<lA[0].vcount; i++) {
// block diagonalizer
cp_fmatrix(P[i].m, lA[i].m);
inverse_fmatrix(Pinv[i].m, P[i].m);
-
+
}
}
/*
@@ -927,65 +927,65 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
lfVector *p = create_lfvector(numverts);
lfVector *s = create_lfvector(numverts);
lfVector *h = create_lfvector(numverts);
-
+
BuildPPinv(lA, P, Pinv);
-
+
filter(dv, S);
add_lfvector_lfvector(dv, dv, z, numverts);
-
+
mul_bfmatrix_lfvector(r, lA, dv);
sub_lfvector_lfvector(r, lB, r, numverts);
filter(r, S);
-
+
mul_prevfmatrix_lfvector(p, Pinv, r);
filter(p, S);
-
+
deltaNew = dot_lfvector(r, p, numverts);
-
+
delta0 = deltaNew * sqrt(conjgrad_epsilon);
-
+
#ifdef DEBUG_TIME
double start = PIL_check_seconds_timer();
#endif
-
+
while ((deltaNew > delta0) && (iterations < conjgrad_looplimit))
{
iterations++;
-
+
mul_bfmatrix_lfvector(s, lA, p);
filter(s, S);
-
+
alpha = deltaNew / dot_lfvector(p, s, numverts);
-
+
add_lfvector_lfvectorS(dv, dv, p, alpha, numverts);
-
+
add_lfvector_lfvectorS(r, r, s, -alpha, numverts);
-
+
mul_prevfmatrix_lfvector(h, Pinv, r);
filter(h, S);
-
+
deltaOld = deltaNew;
-
+
deltaNew = dot_lfvector(r, h, numverts);
-
+
add_lfvector_lfvectorS(p, h, p, deltaNew / deltaOld, numverts);
-
+
filter(p, S);
-
+
}
#ifdef DEBUG_TIME
double end = PIL_check_seconds_timer();
printf("cg_filtered_pre time: %f\n", (float)(end - start));
#endif
-
+
del_lfvector(h);
del_lfvector(s);
del_lfvector(p);
del_lfvector(r);
-
+
printf("iterations: %d\n", iterations);
-
+
return iterations<conjgrad_looplimit;
}
*/
@@ -1000,83 +1000,83 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
lfVector *h = create_lfvector(numverts);
lfVector *bhat = create_lfvector(numverts);
lfVector *btemp = create_lfvector(numverts);
-
+
BuildPPinv(lA, P, Pinv);
-
+
initdiag_bfmatrix(bigI, I);
sub_bfmatrix_Smatrix(bigI, bigI, S);
-
+
// x = Sx_0+(I-S)z
filter(dv, S);
add_lfvector_lfvector(dv, dv, z, numverts);
-
+
// b_hat = S(b-A(I-S)z)
mul_bfmatrix_lfvector(r, lA, z);
mul_bfmatrix_lfvector(bhat, bigI, r);
sub_lfvector_lfvector(bhat, lB, bhat, numverts);
-
+
// r = S(b-Ax)
mul_bfmatrix_lfvector(r, lA, dv);
sub_lfvector_lfvector(r, lB, r, numverts);
filter(r, S);
-
+
// p = SP^-1r
mul_prevfmatrix_lfvector(p, Pinv, r);
filter(p, S);
-
+
// delta0 = bhat^TP^-1bhat
mul_prevfmatrix_lfvector(btemp, Pinv, bhat);
delta0 = dot_lfvector(bhat, btemp, numverts);
-
+
// deltaNew = r^TP
deltaNew = dot_lfvector(r, p, numverts);
-
+
/*
filter(dv, S);
add_lfvector_lfvector(dv, dv, z, numverts);
-
+
mul_bfmatrix_lfvector(r, lA, dv);
sub_lfvector_lfvector(r, lB, r, numverts);
filter(r, S);
-
+
mul_prevfmatrix_lfvector(p, Pinv, r);
filter(p, S);
-
+
deltaNew = dot_lfvector(r, p, numverts);
-
+
delta0 = deltaNew * sqrt(conjgrad_epsilon);
*/
#ifdef DEBUG_TIME
double start = PIL_check_seconds_timer();
#endif
-
+
tol = (0.01*0.2);
-
+
while ((deltaNew > delta0*tol*tol) && (iterations < conjgrad_looplimit))
{
iterations++;
-
+
mul_bfmatrix_lfvector(s, lA, p);
filter(s, S);
-
+
alpha = deltaNew / dot_lfvector(p, s, numverts);
-
+
add_lfvector_lfvectorS(dv, dv, p, alpha, numverts);
-
+
add_lfvector_lfvectorS(r, r, s, -alpha, numverts);
-
+
mul_prevfmatrix_lfvector(h, Pinv, r);
filter(h, S);
-
+
deltaOld = deltaNew;
-
+
deltaNew = dot_lfvector(r, h, numverts);
-
+
add_lfvector_lfvectorS(p, h, p, deltaNew / deltaOld, numverts);
-
+
filter(p, S);
-
+
}
#ifdef DEBUG_TIME
@@ -1090,9 +1090,9 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
del_lfvector(s);
del_lfvector(p);
del_lfvector(r);
-
+
// printf("iterations: %d\n", iterations);
-
+
return iterations<conjgrad_looplimit;
}
#endif
@@ -1128,17 +1128,17 @@ bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol
add_lfvector_lfvector(data->Vnew, data->V, data->dV, numverts);
del_lfvector(dFdXmV);
-
+
return result->status == BPH_SOLVER_SUCCESS;
}
bool BPH_mass_spring_solve_positions(Implicit_Data *data, float dt)
{
int numverts = data->M[0].vcount;
-
+
// advance positions
add_lfvector_lfvectorS(data->Xnew, data->X, data->Vnew, dt, numverts);
-
+
return true;
}
@@ -1219,7 +1219,7 @@ static int BPH_mass_spring_add_block(Implicit_Data *data, int v1, int v2)
int s = data->M[0].vcount + data->num_blocks; /* index from array start */
BLI_assert(s < data->M[0].vcount + data->M[0].scount);
++data->num_blocks;
-
+
/* tfm and S don't have spring entries (diagonal blocks only) */
init_fmatrix(data->bigI + s, v1, v2);
init_fmatrix(data->M + s, v1, v2);
@@ -1228,7 +1228,7 @@ static int BPH_mass_spring_add_block(Implicit_Data *data, int v1, int v2)
init_fmatrix(data->A + s, v1, v2);
init_fmatrix(data->P + s, v1, v2);
init_fmatrix(data->Pinv + s, v1, v2);
-
+
return s;
}
@@ -1244,26 +1244,26 @@ void BPH_mass_spring_clear_constraints(Implicit_Data *data)
void BPH_mass_spring_add_constraint_ndof0(Implicit_Data *data, int index, const float dV[3])
{
zero_m3(data->S[index].m);
-
+
world_to_root_v3(data, index, data->z[index], dV);
}
void BPH_mass_spring_add_constraint_ndof1(Implicit_Data *data, int index, const float c1[3], const float c2[3], const float dV[3])
{
float m[3][3], p[3], q[3], u[3], cmat[3][3];
-
+
world_to_root_v3(data, index, p, c1);
mul_fvectorT_fvector(cmat, p, p);
sub_m3_m3m3(m, I, cmat);
-
+
world_to_root_v3(data, index, q, c2);
mul_fvectorT_fvector(cmat, q, q);
sub_m3_m3m3(m, m, cmat);
-
+
/* XXX not sure but multiplication should work here */
copy_m3_m3(data->S[index].m, m);
// mul_m3_m3m3(data->S[index].m, data->S[index].m, m);
-
+
world_to_root_v3(data, index, u, dV);
add_v3_v3(data->z[index], u);
}
@@ -1271,14 +1271,14 @@ void BPH_mass_spring_add_constraint_ndof1(Implicit_Data *data, int index, const
void BPH_mass_spring_add_constraint_ndof2(Implicit_Data *data, int index, const float c1[3], const float dV[3])
{
float m[3][3], p[3], u[3], cmat[3][3];
-
+
world_to_root_v3(data, index, p, c1);
mul_fvectorT_fvector(cmat, p, p);
sub_m3_m3m3(m, I, cmat);
-
+
copy_m3_m3(data->S[index].m, m);
// mul_m3_m3m3(data->S[index].m, data->S[index].m, m);
-
+
world_to_root_v3(data, index, u, dV);
add_v3_v3(data->z[index], u);
}
@@ -1289,7 +1289,7 @@ void BPH_mass_spring_clear_forces(Implicit_Data *data)
zero_lfvector(data->F, numverts);
init_bfmatrix(data->dFdX, ZERO);
init_bfmatrix(data->dFdV, ZERO);
-
+
data->num_blocks = 0;
}
@@ -1300,37 +1300,37 @@ void BPH_mass_spring_force_reference_frame(Implicit_Data *data, int index, const
float f[3], dfdx[3][3], dfdv[3][3];
float euler[3], coriolis[3], centrifugal[3], rotvel[3];
float deuler[3][3], dcoriolis[3][3], dcentrifugal[3][3], drotvel[3][3];
-
+
world_to_root_v3(data, index, acc, acceleration);
world_to_root_v3(data, index, w, omega);
world_to_root_v3(data, index, dwdt, domega_dt);
-
+
cross_v3_v3v3(euler, dwdt, data->X[index]);
cross_v3_v3v3(coriolis, w, data->V[index]);
mul_v3_fl(coriolis, 2.0f);
cross_v3_v3v3(rotvel, w, data->X[index]);
cross_v3_v3v3(centrifugal, w, rotvel);
-
+
sub_v3_v3v3(f, acc, euler);
sub_v3_v3(f, coriolis);
sub_v3_v3(f, centrifugal);
-
+
mul_v3_fl(f, mass); /* F = m * a */
-
+
cross_v3_identity(deuler, dwdt);
cross_v3_identity(dcoriolis, w);
mul_m3_fl(dcoriolis, 2.0f);
cross_v3_identity(drotvel, w);
cross_m3_v3m3(dcentrifugal, w, drotvel);
-
+
add_m3_m3m3(dfdx, deuler, dcentrifugal);
negate_m3(dfdx);
mul_m3_fl(dfdx, mass);
-
+
copy_m3_m3(dfdv, dcoriolis);
negate_m3(dfdv);
mul_m3_fl(dfdv, mass);
-
+
add_v3_v3(data->F[index], f);
add_m3_m3m3(data->dFdX[index].m, data->dFdX[index].m, dfdx);
add_m3_m3m3(data->dFdV[index].m, data->dFdV[index].m, dfdv);
@@ -1349,7 +1349,7 @@ void BPH_mass_spring_force_gravity(Implicit_Data *data, int index, float mass, c
float f[3];
world_to_root_v3(data, index, f, g);
mul_v3_fl(f, mass);
-
+
add_v3_v3(data->F[index], f);
}
@@ -1358,10 +1358,10 @@ void BPH_mass_spring_force_drag(Implicit_Data *data, float drag)
int i, numverts = data->M[0].vcount;
for (i = 0; i < numverts; i++) {
float tmp[3][3];
-
+
/* NB: uses root space velocity, no need to transform */
madd_v3_v3fl(data->F[i], data->V[i], -drag);
-
+
copy_m3_m3(tmp, I);
mul_m3_fl(tmp, -drag);
add_m3_m3m3(data->dFdV[i].m, data->dFdV[i].m, tmp);
@@ -1374,7 +1374,7 @@ void BPH_mass_spring_force_extern(struct Implicit_Data *data, int i, const float
world_to_root_v3(data, i, tf, f);
world_to_root_m3(data, i, tdfdx, dfdx);
world_to_root_m3(data, i, tdfdv, dfdv);
-
+
add_v3_v3(data->F[i], tf);
add_m3_m3m3(data->dFdX[i].m, data->dFdX[i].m, tdfdx);
add_m3_m3m3(data->dFdV[i].m, data->dFdV[i].m, tdfdv);
@@ -1383,10 +1383,10 @@ void BPH_mass_spring_force_extern(struct Implicit_Data *data, int i, const float
static float calc_nor_area_tri(float nor[3], const float v1[3], const float v2[3], const float v3[3])
{
float n1[3], n2[3];
-
+
sub_v3_v3v3(n1, v1, v2);
sub_v3_v3v3(n2, v2, v3);
-
+
cross_v3_v3v3(nor, n1, n2);
return normalize_v3(nor);
}
@@ -1397,17 +1397,17 @@ void BPH_mass_spring_force_face_wind(Implicit_Data *data, int v1, int v2, int v3
const float effector_scale = 0.02f;
float win[3], nor[3], area;
float factor;
-
+
/* calculate face normal and area */
area = calc_nor_area_tri(nor, data->X[v1], data->X[v2], data->X[v3]);
factor = effector_scale * area / 3.0f;
-
+
world_to_root_v3(data, v1, win, winvec[v1]);
madd_v3_v3fl(data->F[v1], nor, factor * dot_v3v3(win, nor));
-
+
world_to_root_v3(data, v2, win, winvec[v2]);
madd_v3_v3fl(data->F[v2], nor, factor * dot_v3v3(win, nor));
-
+
world_to_root_v3(data, v3, win, winvec[v3]);
madd_v3_v3fl(data->F[v3], nor, factor * dot_v3v3(win, nor));
}
@@ -1417,17 +1417,17 @@ static void edge_wind_vertex(const float dir[3], float length, float radius, con
const float density = 0.01f; /* XXX arbitrary value, corresponds to effect of air density */
float cos_alpha, sin_alpha, cross_section;
float windlen = len_v3(wind);
-
+
if (windlen == 0.0f) {
zero_v3(f);
return;
}
-
+
/* angle of wind direction to edge */
cos_alpha = dot_v3v3(wind, dir) / windlen;
sin_alpha = sqrtf(1.0f - cos_alpha * cos_alpha);
cross_section = radius * ((float)M_PI * radius * sin_alpha + length * cos_alpha);
-
+
mul_v3_v3fl(f, wind, density * cross_section);
}
@@ -1435,14 +1435,14 @@ void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, float
{
float win[3], dir[3], length;
float f[3], dfdx[3][3], dfdv[3][3];
-
+
sub_v3_v3v3(dir, data->X[v1], data->X[v2]);
length = normalize_v3(dir);
-
+
world_to_root_v3(data, v1, win, winvec[v1]);
edge_wind_vertex(dir, length, radius1, win, f, dfdx, dfdv);
add_v3_v3(data->F[v1], f);
-
+
world_to_root_v3(data, v2, win, winvec[v2]);
edge_wind_vertex(dir, length, radius2, win, f, dfdx, dfdv);
add_v3_v3(data->F[v2], f);
@@ -1451,10 +1451,10 @@ void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, float
void BPH_mass_spring_force_vertex_wind(Implicit_Data *data, int v, float UNUSED(radius), const float (*winvec)[3])
{
const float density = 0.01f; /* XXX arbitrary value, corresponds to effect of air density */
-
+
float wind[3];
float f[3];
-
+
world_to_root_v3(data, v, wind, winvec[v]);
mul_v3_v3fl(f, wind, density);
add_v3_v3(data->F[v], f);
@@ -1466,8 +1466,8 @@ BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, fl
//return ( (I-outerprod(dir, dir))*Min(1.0f, rest/length) - I) * -k;
outerproduct(to, dir, dir);
sub_m3_m3m3(to, I, to);
-
- mul_m3_fl(to, (L/length));
+
+ mul_m3_fl(to, (L/length));
sub_m3_m3m3(to, to, I);
mul_m3_fl(to, k);
}
@@ -1476,7 +1476,7 @@ BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, fl
#if 0
BLI_INLINE void dfdx_damp(float to[3][3], const float dir[3], float length, const float vel[3], float rest, float damping)
{
- // inner spring damping vel is the relative velocity of the endpoints.
+ // inner spring damping vel is the relative velocity of the endpoints.
// return (I-outerprod(dir, dir)) * (-damping * -(dot(dir, vel)/Max(length, rest)));
mul_fvectorT_fvector(to, dir, dir);
sub_fmatrix_fmatrix(to, I, to);
@@ -1512,7 +1512,7 @@ BLI_INLINE float fbstar(float length, float L, float kb, float cb)
{
float tempfb_fl = kb * fb(length, L);
float fbstar_fl = cb * (length - L);
-
+
if (tempfb_fl < fbstar_fl)
return fbstar_fl;
else
@@ -1539,7 +1539,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data, int i, int j, float r_extent[
sub_v3_v3v3(r_extent, data->X[j], data->X[i]);
sub_v3_v3v3(r_vel, data->V[j], data->V[i]);
*r_length = len_v3(r_extent);
-
+
if (*r_length > ALMOST_ZERO) {
/*
if (length>L) {
@@ -1557,21 +1557,21 @@ BLI_INLINE bool spring_length(Implicit_Data *data, int i, int j, float r_extent[
else {
zero_v3(r_dir);
}
-
+
return true;
}
BLI_INLINE void apply_spring(Implicit_Data *data, int i, int j, const float f[3], float dfdx[3][3], float dfdv[3][3])
{
int block_ij = BPH_mass_spring_add_block(data, i, j);
-
+
add_v3_v3(data->F[i], f);
sub_v3_v3(data->F[j], f);
-
+
add_m3_m3m3(data->dFdX[i].m, data->dFdX[i].m, dfdx);
add_m3_m3m3(data->dFdX[j].m, data->dFdX[j].m, dfdx);
sub_m3_m3m3(data->dFdX[block_ij].m, data->dFdX[block_ij].m, dfdx);
-
+
add_m3_m3m3(data->dFdV[i].m, data->dFdV[i].m, dfdv);
add_m3_m3m3(data->dFdV[j].m, data->dFdV[j].m, dfdv);
sub_m3_m3m3(data->dFdV[block_ij].m, data->dFdV[block_ij].m, dfdv);
@@ -1581,7 +1581,7 @@ bool BPH_mass_spring_force_spring_linear(Implicit_Data *data, int i, int j, floa
float stiffness, float damping, bool no_compress, float clamp_force)
{
float extent[3], length, dir[3], vel[3];
-
+
// calculate elonglation
spring_length(data, i, j, extent, dir, &length, vel);
@@ -1590,22 +1590,22 @@ bool BPH_mass_spring_force_spring_linear(Implicit_Data *data, int i, int j, floa
Thus length > restlen makes cloth unconstrained at the start of simulation. */
if ((length >= restlen && length > 0) || no_compress) {
float stretch_force, f[3], dfdx[3][3], dfdv[3][3];
-
+
stretch_force = stiffness * (length - restlen);
if (clamp_force > 0.0f && stretch_force > clamp_force) {
stretch_force = clamp_force;
}
mul_v3_v3fl(f, dir, stretch_force);
-
+
// Ascher & Boxman, p.21: Damping only during elonglation
// something wrong with it...
madd_v3_v3fl(f, dir, damping * dot_v3v3(vel, dir));
-
+
dfdx_spring(dfdx, dir, length, restlen, stiffness);
dfdv_damp(dfdv, dir, damping);
-
+
apply_spring(data, i, j, f, dfdx, dfdv);
-
+
return true;
}
else {
@@ -1617,23 +1617,23 @@ bool BPH_mass_spring_force_spring_linear(Implicit_Data *data, int i, int j, floa
bool BPH_mass_spring_force_spring_bending(Implicit_Data *data, int i, int j, float restlen, float kb, float cb)
{
float extent[3], length, dir[3], vel[3];
-
+
// calculate elonglation
spring_length(data, i, j, extent, dir, &length, vel);
-
+
if (length < restlen) {
float f[3], dfdx[3][3], dfdv[3][3];
-
+
mul_v3_v3fl(f, dir, fbstar(length, restlen, kb, cb));
-
+
outerproduct(dfdx, dir, dir);
mul_m3_fl(dfdx, fbstar_jacobi(length, restlen, kb, cb));
-
+
/* XXX damping not supported */
zero_m3(dfdv);
-
+
apply_spring(data, i, j, f, dfdx, dfdv);
-
+
return true;
}
else {
@@ -1644,16 +1644,16 @@ bool BPH_mass_spring_force_spring_bending(Implicit_Data *data, int i, int j, flo
/* Jacobian of a direction vector.
* Basically the part of the differential orthogonal to the direction,
* inversely proportional to the length of the edge.
- *
+ *
* dD_ij/dx_i = -dD_ij/dx_j = (D_ij * D_ij^T - I) / len_ij
*/
BLI_INLINE void spring_grad_dir(Implicit_Data *data, int i, int j, float edge[3], float dir[3], float grad_dir[3][3])
{
float length;
-
+
sub_v3_v3v3(edge, data->X[j], data->X[i]);
length = normalize_v3_v3(dir, edge);
-
+
if (length > ALMOST_ZERO) {
outerproduct(grad_dir, dir, dir);
sub_m3_m3m3(grad_dir, I, grad_dir);
@@ -1676,39 +1676,39 @@ BLI_INLINE void spring_angbend_forces(Implicit_Data *data, int i, int j, int k,
float f_bend[3], f_damp[3];
float fk[3];
float dist[3];
-
+
zero_v3(fk);
-
+
sub_v3_v3v3(edge_ij, data->X[j], data->X[i]);
if (q == i) sub_v3_v3(edge_ij, dx);
if (q == j) add_v3_v3(edge_ij, dx);
normalize_v3_v3(dir_ij, edge_ij);
-
+
sub_v3_v3v3(edge_jk, data->X[k], data->X[j]);
if (q == j) sub_v3_v3(edge_jk, dx);
if (q == k) add_v3_v3(edge_jk, dx);
normalize_v3_v3(dir_jk, edge_jk);
-
+
sub_v3_v3v3(vel_ij, data->V[j], data->V[i]);
if (q == i) sub_v3_v3(vel_ij, dv);
if (q == j) add_v3_v3(vel_ij, dv);
-
+
sub_v3_v3v3(vel_jk, data->V[k], data->V[j]);
if (q == j) sub_v3_v3(vel_jk, dv);
if (q == k) add_v3_v3(vel_jk, dv);
-
+
/* bending force */
sub_v3_v3v3(dist, goal, edge_jk);
mul_v3_v3fl(f_bend, dist, stiffness);
-
+
add_v3_v3(fk, f_bend);
-
+
/* damping force */
madd_v3_v3v3fl(vel_ortho, vel_jk, dir_jk, -dot_v3v3(vel_jk, dir_jk));
mul_v3_v3fl(f_damp, vel_ortho, damping);
-
+
sub_v3_v3(fk, f_damp);
-
+
copy_v3_v3(r_f, fk);
}
@@ -1722,24 +1722,24 @@ BLI_INLINE void spring_angbend_estimate_dfdx(Implicit_Data *data, int i, int j,
float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
float f[3];
int a, b;
-
+
zero_m3(dvec_null);
unit_m3(dvec_pos);
mul_m3_fl(dvec_pos, delta * 0.5f);
copy_m3_m3(dvec_neg, dvec_pos);
negate_m3(dvec_neg);
-
+
/* XXX TODO offset targets to account for position dependency */
-
+
for (a = 0; a < 3; ++a) {
spring_angbend_forces(data, i, j, k, goal, stiffness, damping,
q, dvec_pos[a], dvec_null[a], f);
copy_v3_v3(dfdx[a], f);
-
+
spring_angbend_forces(data, i, j, k, goal, stiffness, damping,
q, dvec_neg[a], dvec_null[a], f);
sub_v3_v3(dfdx[a], f);
-
+
for (b = 0; b < 3; ++b) {
dfdx[a][b] /= delta;
}
@@ -1756,24 +1756,24 @@ BLI_INLINE void spring_angbend_estimate_dfdv(Implicit_Data *data, int i, int j,
float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
float f[3];
int a, b;
-
+
zero_m3(dvec_null);
unit_m3(dvec_pos);
mul_m3_fl(dvec_pos, delta * 0.5f);
copy_m3_m3(dvec_neg, dvec_pos);
negate_m3(dvec_neg);
-
+
/* XXX TODO offset targets to account for position dependency */
-
+
for (a = 0; a < 3; ++a) {
spring_angbend_forces(data, i, j, k, goal, stiffness, damping,
q, dvec_null[a], dvec_pos[a], f);
copy_v3_v3(dfdv[a], f);
-
+
spring_angbend_forces(data, i, j, k, goal, stiffness, damping,
q, dvec_null[a], dvec_neg[a], f);
sub_v3_v3(dfdv[a], f);
-
+
for (b = 0; b < 3; ++b) {
dfdv[a][b] /= delta;
}
@@ -1790,45 +1790,45 @@ bool BPH_mass_spring_force_spring_bending_angular(Implicit_Data *data, int i, in
float fj[3], fk[3];
float dfj_dxi[3][3], dfj_dxj[3][3], dfk_dxi[3][3], dfk_dxj[3][3], dfk_dxk[3][3];
float dfj_dvi[3][3], dfj_dvj[3][3], dfk_dvi[3][3], dfk_dvj[3][3], dfk_dvk[3][3];
-
+
const float vecnull[3] = {0.0f, 0.0f, 0.0f};
-
+
int block_ij = BPH_mass_spring_add_block(data, i, j);
int block_jk = BPH_mass_spring_add_block(data, j, k);
int block_ik = BPH_mass_spring_add_block(data, i, k);
-
+
world_to_root_v3(data, j, goal, target);
-
+
spring_angbend_forces(data, i, j, k, goal, stiffness, damping, k, vecnull, vecnull, fk);
negate_v3_v3(fj, fk); /* counterforce */
-
+
spring_angbend_estimate_dfdx(data, i, j, k, goal, stiffness, damping, i, dfk_dxi);
spring_angbend_estimate_dfdx(data, i, j, k, goal, stiffness, damping, j, dfk_dxj);
spring_angbend_estimate_dfdx(data, i, j, k, goal, stiffness, damping, k, dfk_dxk);
copy_m3_m3(dfj_dxi, dfk_dxi); negate_m3(dfj_dxi);
copy_m3_m3(dfj_dxj, dfk_dxj); negate_m3(dfj_dxj);
-
+
spring_angbend_estimate_dfdv(data, i, j, k, goal, stiffness, damping, i, dfk_dvi);
spring_angbend_estimate_dfdv(data, i, j, k, goal, stiffness, damping, j, dfk_dvj);
spring_angbend_estimate_dfdv(data, i, j, k, goal, stiffness, damping, k, dfk_dvk);
copy_m3_m3(dfj_dvi, dfk_dvi); negate_m3(dfj_dvi);
copy_m3_m3(dfj_dvj, dfk_dvj); negate_m3(dfj_dvj);
-
+
/* add forces and jacobians to the solver data */
-
+
add_v3_v3(data->F[j], fj);
add_v3_v3(data->F[k], fk);
-
+
add_m3_m3m3(data->dFdX[j].m, data->dFdX[j].m, dfj_dxj);
add_m3_m3m3(data->dFdX[k].m, data->dFdX[k].m, dfk_dxk);
-
+
add_m3_m3m3(data->dFdX[block_ij].m, data->dFdX[block_ij].m, dfj_dxi);
add_m3_m3m3(data->dFdX[block_jk].m, data->dFdX[block_jk].m, dfk_dxj);
add_m3_m3m3(data->dFdX[block_ik].m, data->dFdX[block_ik].m, dfk_dxi);
-
+
add_m3_m3m3(data->dFdV[j].m, data->dFdV[j].m, dfj_dvj);
add_m3_m3m3(data->dFdV[k].m, data->dFdV[k].m, dfk_dvk);
-
+
add_m3_m3m3(data->dFdV[block_ij].m, data->dFdV[block_ij].m, dfj_dvi);
add_m3_m3m3(data->dFdV[block_jk].m, data->dFdV[block_jk].m, dfk_dvj);
add_m3_m3m3(data->dFdV[block_ik].m, data->dFdV[block_ik].m, dfk_dvi);
@@ -1847,10 +1847,10 @@ bool BPH_mass_spring_force_spring_bending_angular(Implicit_Data *data, int i, in
float fi[3], fj[3], fk[3];
float dfi_dxi[3][3], dfj_dxi[3][3], dfj_dxj[3][3], dfk_dxi[3][3], dfk_dxj[3][3], dfk_dxk[3][3];
float dfdvi[3][3];
-
+
// TESTING
damping = 0.0f;
-
+
zero_v3(fi);
zero_v3(fj);
zero_v3(fk);
@@ -1859,68 +1859,68 @@ bool BPH_mass_spring_force_spring_bending_angular(Implicit_Data *data, int i, in
zero_m3(dfk_dxi);
zero_m3(dfk_dxj);
zero_m3(dfk_dxk);
-
+
/* jacobian of direction vectors */
spring_grad_dir(data, i, j, edge_ij, dir_ij, grad_dir_ij);
spring_grad_dir(data, j, k, edge_jk, dir_jk, grad_dir_jk);
-
+
sub_v3_v3v3(vel_jk, data->V[k], data->V[j]);
-
+
/* bending force */
mul_v3_v3fl(target, dir_ij, restlen);
sub_v3_v3v3(dist, target, edge_jk);
mul_v3_v3fl(fk, dist, stiffness);
-
+
/* damping force */
madd_v3_v3v3fl(vel_jk_ortho, vel_jk, dir_jk, -dot_v3v3(vel_jk, dir_jk));
madd_v3_v3fl(fk, vel_jk_ortho, damping);
-
+
/* XXX this only holds true as long as we assume straight rest shape!
* eventually will become a bit more involved since the opposite segment
* gets its own target, under condition of having equal torque on both sides.
*/
copy_v3_v3(fi, fk);
-
+
/* counterforce on the middle point */
sub_v3_v3(fj, fi);
sub_v3_v3(fj, fk);
-
+
/* === derivatives === */
-
+
madd_m3_m3fl(dfk_dxi, grad_dir_ij, stiffness * restlen);
-
+
madd_m3_m3fl(dfk_dxj, grad_dir_ij, -stiffness * restlen);
madd_m3_m3fl(dfk_dxj, I, stiffness);
-
+
madd_m3_m3fl(dfk_dxk, I, -stiffness);
-
+
copy_m3_m3(dfi_dxi, dfk_dxk);
negate_m3(dfi_dxi);
-
+
/* dfj_dfi == dfi_dfj due to symmetry,
* dfi_dfj == dfk_dfj due to fi == fk
* XXX see comment above on future bent rest shapes
*/
copy_m3_m3(dfj_dxi, dfk_dxj);
-
+
/* dfj_dxj == -(dfi_dxj + dfk_dxj) due to fj == -(fi + fk) */
sub_m3_m3m3(dfj_dxj, dfj_dxj, dfj_dxi);
sub_m3_m3m3(dfj_dxj, dfj_dxj, dfk_dxj);
-
+
/* add forces and jacobians to the solver data */
add_v3_v3(data->F[i], fi);
add_v3_v3(data->F[j], fj);
add_v3_v3(data->F[k], fk);
-
+
add_m3_m3m3(data->dFdX[i].m, data->dFdX[i].m, dfi_dxi);
add_m3_m3m3(data->dFdX[j].m, data->dFdX[j].m, dfj_dxj);
add_m3_m3m3(data->dFdX[k].m, data->dFdX[k].m, dfk_dxk);
-
+
add_m3_m3m3(data->dFdX[block_ij].m, data->dFdX[block_ij].m, dfj_dxi);
add_m3_m3m3(data->dFdX[block_jk].m, data->dFdX[block_jk].m, dfk_dxj);
add_m3_m3m3(data->dFdX[block_ik].m, data->dFdX[block_ik].m, dfk_dxi);
#endif
-
+
return true;
}
@@ -1929,29 +1929,29 @@ bool BPH_mass_spring_force_spring_goal(Implicit_Data *data, int i, const float g
{
float root_goal_x[3], root_goal_v[3], extent[3], length, dir[3], vel[3];
float f[3], dfdx[3][3], dfdv[3][3];
-
+
/* goal is in world space */
world_to_root_v3(data, i, root_goal_x, goal_x);
world_to_root_v3(data, i, root_goal_v, goal_v);
-
+
sub_v3_v3v3(extent, root_goal_x, data->X[i]);
sub_v3_v3v3(vel, root_goal_v, data->V[i]);
length = normalize_v3_v3(dir, extent);
-
+
if (length > ALMOST_ZERO) {
mul_v3_v3fl(f, dir, stiffness * length);
-
+
// Ascher & Boxman, p.21: Damping only during elonglation
// something wrong with it...
madd_v3_v3fl(f, dir, damping * dot_v3v3(vel, dir));
-
+
dfdx_spring(dfdx, dir, length, 0.0f, stiffness);
dfdv_damp(dfdv, dir, damping);
-
+
add_v3_v3(data->F[i], f);
add_m3_m3m3(data->dFdX[i].m, data->dFdX[i].m, dfdx);
add_m3_m3m3(data->dFdV[i].m, data->dFdV[i].m, dfdv);
-
+
return true;
}
else {
diff --git a/source/blender/physics/intern/implicit_eigen.cpp b/source/blender/physics/intern/implicit_eigen.cpp
index c36fabcffb0..eaac63893a6 100644
--- a/source/blender/physics/intern/implicit_eigen.cpp
+++ b/source/blender/physics/intern/implicit_eigen.cpp
@@ -99,24 +99,24 @@ static float I[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
class fVector : public Eigen::Vector3f {
public:
typedef float *ctype;
-
+
fVector()
{
}
-
+
fVector(const ctype &v)
{
for (int k = 0; k < 3; ++k)
coeffRef(k) = v[k];
}
-
+
fVector& operator = (const ctype &v)
{
for (int k = 0; k < 3; ++k)
coeffRef(k) = v[k];
return *this;
}
-
+
operator ctype()
{
return data();
@@ -129,18 +129,18 @@ public:
class fMatrix : public Eigen::Matrix3f {
public:
typedef float (*ctype)[3];
-
+
fMatrix()
{
}
-
+
fMatrix(const ctype &v)
{
for (int k = 0; k < 3; ++k)
for (int l = 0; l < 3; ++l)
coeffRef(l, k) = v[k][l];
}
-
+
fMatrix& operator = (const ctype &v)
{
for (int k = 0; k < 3; ++k)
@@ -148,7 +148,7 @@ public:
coeffRef(l, k) = v[k][l];
return *this;
}
-
+
operator ctype()
{
return (ctype)data();
@@ -161,23 +161,23 @@ public:
class lVector : public Eigen::VectorXf {
public:
typedef Eigen::VectorXf base_t;
-
+
lVector()
{
}
-
+
template <typename T>
lVector& operator = (T rhs)
{
base_t::operator=(rhs);
return *this;
}
-
+
float* v3(int vertex)
{
return &coeffRef(3 * vertex);
}
-
+
const float* v3(int vertex) const
{
return &coeffRef(3 * vertex);
@@ -198,18 +198,18 @@ struct lMatrixCtor {
lMatrixCtor()
{
}
-
+
void reset()
{
m_trips.clear();
}
-
+
void reserve(int numverts)
{
/* reserve for diagonal entries */
m_trips.reserve(numverts * 9);
}
-
+
void add(int i, int j, const fMatrix &m)
{
i *= 3;
@@ -218,7 +218,7 @@ struct lMatrixCtor {
for (int l = 0; l < 3; ++l)
m_trips.push_back(Triplet(i + k, j + l, m.coeff(l, k)));
}
-
+
void sub(int i, int j, const fMatrix &m)
{
i *= 3;
@@ -227,13 +227,13 @@ struct lMatrixCtor {
for (int l = 0; l < 3; ++l)
m_trips.push_back(Triplet(i + k, j + l, -m.coeff(l, k)));
}
-
+
inline void construct(lMatrix &m)
{
m.setFromTriplets(m_trips.begin(), m_trips.end());
m_trips.clear();
}
-
+
private:
TripletList m_trips;
};
@@ -253,7 +253,7 @@ static void print_lvector(const lVector &v)
for (int i = 0; i < v.rows(); ++i) {
if (i > 0 && i % 3 == 0)
printf("\n");
-
+
printf("%f,\n", v[i]);
}
}
@@ -263,11 +263,11 @@ static void print_lmatrix(const lMatrix &m)
for (int j = 0; j < m.rows(); ++j) {
if (j > 0 && j % 3 == 0)
printf("\n");
-
+
for (int i = 0; i < m.cols(); ++i) {
if (i > 0 && i % 3 == 0)
printf(" ");
-
+
implicit_print_matrix_elem(m.coeff(j, i));
}
printf("\n");
@@ -383,63 +383,63 @@ BLI_INLINE void madd_m3_m3m3fl(float r[3][3], float a[3][3], float b[3][3], floa
struct Implicit_Data {
typedef std::vector<fMatrix> fMatrixVector;
-
+
Implicit_Data(int numverts)
{
resize(numverts);
}
-
+
void resize(int numverts)
{
this->numverts = numverts;
int tot = 3 * numverts;
-
+
M.resize(tot, tot);
F.resize(tot);
dFdX.resize(tot, tot);
dFdV.resize(tot, tot);
-
+
tfm.resize(numverts, I);
-
+
X.resize(tot);
Xnew.resize(tot);
V.resize(tot);
Vnew.resize(tot);
-
+
A.resize(tot, tot);
B.resize(tot);
-
+
dV.resize(tot);
z.resize(tot);
S.resize(tot, tot);
-
+
iM.reserve(numverts);
idFdX.reserve(numverts);
idFdV.reserve(numverts);
iS.reserve(numverts);
}
-
+
int numverts;
-
+
/* inputs */
lMatrix M; /* masses */
lVector F; /* forces */
lMatrix dFdX, dFdV; /* force jacobians */
-
+
fMatrixVector tfm; /* local coordinate transform */
-
+
/* motion state data */
lVector X, Xnew; /* positions */
lVector V, Vnew; /* velocities */
-
+
/* internal solver data */
lVector B; /* B for A*dV = B */
lMatrix A; /* A for A*dV = B */
-
+
lVector dV; /* velocity change (solution of A*dV = B) */
lVector z; /* target velocity in constrained directions */
lMatrix S; /* filtering matrix for constraints */
-
+
/* temporary constructors */
lMatrixCtor iM; /* masses */
lMatrixCtor idFdX, idFdV; /* force jacobians */
@@ -502,25 +502,25 @@ bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol
#ifdef USE_EIGEN_CONSTRAINED_CG
typedef ConstraintConjGrad solver_t;
#endif
-
+
data->iM.construct(data->M);
data->idFdX.construct(data->dFdX);
data->idFdV.construct(data->dFdV);
data->iS.construct(data->S);
-
+
solver_t cg;
cg.setMaxIterations(100);
cg.setTolerance(0.01f);
-
+
#ifdef USE_EIGEN_CONSTRAINED_CG
cg.filter() = data->S;
#endif
-
+
data->A = data->M - dt * data->dFdV - dt*dt * data->dFdX;
cg.compute(data->A);
-
+
data->B = dt * data->F + dt*dt * data->dFdX * data->V;
-
+
#ifdef IMPLICIT_PRINT_SOLVER_INPUT_OUTPUT
printf("==== A ====\n");
print_lmatrix(id->A);
@@ -531,22 +531,22 @@ bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol
printf("==== S ====\n");
print_lmatrix(id->S);
#endif
-
+
#ifdef USE_EIGEN_CORE
data->dV = cg.solve(data->B);
#endif
#ifdef USE_EIGEN_CONSTRAINED_CG
data->dV = cg.solveWithGuess(data->B, data->z);
#endif
-
+
#ifdef IMPLICIT_PRINT_SOLVER_INPUT_OUTPUT
printf("==== dV ====\n");
print_lvector(id->dV);
printf("========\n");
#endif
-
+
data->Vnew = data->V + data->dV;
-
+
switch (cg.info()) {
case Eigen::Success: result->status = BPH_SOLVER_SUCCESS; break;
case Eigen::NoConvergence: result->status = BPH_SOLVER_NO_CONVERGENCE; break;
@@ -556,7 +556,7 @@ bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol
result->iterations = cg.iterations();
result->error = cg.error();
-
+
return cg.info() == Eigen::Success;
}
@@ -641,26 +641,26 @@ void BPH_mass_spring_clear_constraints(Implicit_Data *data)
void BPH_mass_spring_add_constraint_ndof0(Implicit_Data *data, int index, const float dV[3])
{
data->iS.sub(index, index, I);
-
+
world_to_root_v3(data, index, data->z.v3(index), dV);
}
void BPH_mass_spring_add_constraint_ndof1(Implicit_Data *data, int index, const float c1[3], const float c2[3], const float dV[3])
{
float m[3][3], p[3], q[3], u[3], cmat[3][3];
-
+
world_to_root_v3(data, index, p, c1);
outerproduct(cmat, p, p);
copy_m3_m3(m, cmat);
-
+
world_to_root_v3(data, index, q, c2);
outerproduct(cmat, q, q);
add_m3_m3m3(m, m, cmat);
-
+
/* XXX not sure but multiplication should work here */
data->iS.sub(index, index, m);
// mul_m3_m3m3(data->S[index].m, data->S[index].m, m);
-
+
world_to_root_v3(data, index, u, dV);
add_v3_v3(data->z.v3(index), u);
}
@@ -668,14 +668,14 @@ void BPH_mass_spring_add_constraint_ndof1(Implicit_Data *data, int index, const
void BPH_mass_spring_add_constraint_ndof2(Implicit_Data *data, int index, const float c1[3], const float dV[3])
{
float m[3][3], p[3], u[3], cmat[3][3];
-
+
world_to_root_v3(data, index, p, c1);
outerproduct(cmat, p, p);
copy_m3_m3(m, cmat);
-
+
data->iS.sub(index, index, m);
// mul_m3_m3m3(data->S[index].m, data->S[index].m, m);
-
+
world_to_root_v3(data, index, u, dV);
add_v3_v3(data->z.v3(index), u);
}
@@ -694,37 +694,37 @@ void BPH_mass_spring_force_reference_frame(Implicit_Data *data, int index, const
float f[3], dfdx[3][3], dfdv[3][3];
float euler[3], coriolis[3], centrifugal[3], rotvel[3];
float deuler[3][3], dcoriolis[3][3], dcentrifugal[3][3], drotvel[3][3];
-
+
world_to_root_v3(data, index, acc, acceleration);
world_to_root_v3(data, index, w, omega);
world_to_root_v3(data, index, dwdt, domega_dt);
-
+
cross_v3_v3v3(euler, dwdt, data->X.v3(index));
cross_v3_v3v3(coriolis, w, data->V.v3(index));
mul_v3_fl(coriolis, 2.0f);
cross_v3_v3v3(rotvel, w, data->X.v3(index));
cross_v3_v3v3(centrifugal, w, rotvel);
-
+
sub_v3_v3v3(f, acc, euler);
sub_v3_v3(f, coriolis);
sub_v3_v3(f, centrifugal);
-
+
mul_v3_fl(f, mass); /* F = m * a */
-
+
cross_v3_identity(deuler, dwdt);
cross_v3_identity(dcoriolis, w);
mul_m3_fl(dcoriolis, 2.0f);
cross_v3_identity(drotvel, w);
cross_m3_v3m3(dcentrifugal, w, drotvel);
-
+
add_m3_m3m3(dfdx, deuler, dcentrifugal);
negate_m3(dfdx);
mul_m3_fl(dfdx, mass);
-
+
copy_m3_m3(dfdv, dcoriolis);
negate_m3(dfdv);
mul_m3_fl(dfdv, mass);
-
+
add_v3_v3(data->F.v3(index), f);
data->idFdX.add(index, index, dfdx);
data->idFdV.add(index, index, dfdv);
@@ -743,7 +743,7 @@ void BPH_mass_spring_force_gravity(Implicit_Data *data, int index, float mass, c
float f[3];
world_to_root_v3(data, index, f, g);
mul_v3_fl(f, mass);
-
+
add_v3_v3(data->F.v3(index), f);
}
@@ -752,10 +752,10 @@ void BPH_mass_spring_force_drag(Implicit_Data *data, float drag)
int numverts = data->numverts;
for (int i = 0; i < numverts; i++) {
float tmp[3][3];
-
+
/* NB: uses root space velocity, no need to transform */
madd_v3_v3fl(data->F.v3(i), data->V.v3(i), -drag);
-
+
copy_m3_m3(tmp, I);
mul_m3_fl(tmp, -drag);
data->idFdV.add(i, i, tmp);
@@ -768,7 +768,7 @@ void BPH_mass_spring_force_extern(struct Implicit_Data *data, int i, const float
world_to_root_v3(data, i, tf, f);
world_to_root_m3(data, i, tdfdx, dfdx);
world_to_root_m3(data, i, tdfdv, dfdv);
-
+
add_v3_v3(data->F.v3(i), tf);
data->idFdX.add(i, i, tdfdx);
data->idFdV.add(i, i, tdfdv);
@@ -777,10 +777,10 @@ void BPH_mass_spring_force_extern(struct Implicit_Data *data, int i, const float
static float calc_nor_area_tri(float nor[3], const float v1[3], const float v2[3], const float v3[3])
{
float n1[3], n2[3];
-
+
sub_v3_v3v3(n1, v1, v2);
sub_v3_v3v3(n2, v2, v3);
-
+
cross_v3_v3v3(nor, n1, n2);
return normalize_v3(nor);
}
@@ -791,17 +791,17 @@ void BPH_mass_spring_force_face_wind(Implicit_Data *data, int v1, int v2, int v3
const float effector_scale = 0.02f;
float win[3], nor[3], area;
float factor;
-
+
// calculate face normal and area
area = calc_nor_area_tri(nor, data->X.v3(v1), data->X.v3(v2), data->X.v3(v3));
factor = effector_scale * area / 3.0f;
-
+
world_to_root_v3(data, v1, win, winvec[v1]);
madd_v3_v3fl(data->F.v3(v1), nor, factor * dot_v3v3(win, nor));
-
+
world_to_root_v3(data, v2, win, winvec[v2]);
madd_v3_v3fl(data->F.v3(v2), nor, factor * dot_v3v3(win, nor));
-
+
world_to_root_v3(data, v3, win, winvec[v3]);
madd_v3_v3fl(data->F.v3(v3), nor, factor * dot_v3v3(win, nor));
}
@@ -810,14 +810,14 @@ void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, const
{
const float effector_scale = 0.01;
float win[3], dir[3], nor[3], length;
-
+
sub_v3_v3v3(dir, data->X.v3(v1), data->X.v3(v2));
length = normalize_v3(dir);
-
+
world_to_root_v3(data, v1, win, winvec[v1]);
madd_v3_v3v3fl(nor, win, dir, -dot_v3v3(win, dir));
madd_v3_v3fl(data->F.v3(v1), nor, effector_scale * length);
-
+
world_to_root_v3(data, v2, win, winvec[v2]);
madd_v3_v3v3fl(nor, win, dir, -dot_v3v3(win, dir));
madd_v3_v3fl(data->F.v3(v2), nor, effector_scale * length);
@@ -829,8 +829,8 @@ BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, fl
//return ( (I-outerprod(dir, dir))*Min(1.0f, rest/length) - I) * -k;
outerproduct(to, dir, dir);
sub_m3_m3m3(to, I, to);
-
- mul_m3_fl(to, (L/length));
+
+ mul_m3_fl(to, (L/length));
sub_m3_m3m3(to, to, I);
mul_m3_fl(to, k);
}
@@ -839,7 +839,7 @@ BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, fl
#if 0
BLI_INLINE void dfdx_damp(float to[3][3], const float dir[3], float length, const float vel[3], float rest, float damping)
{
- // inner spring damping vel is the relative velocity of the endpoints.
+ // inner spring damping vel is the relative velocity of the endpoints.
// return (I-outerprod(dir, dir)) * (-damping * -(dot(dir, vel)/Max(length, rest)));
mul_fvectorT_fvector(to, dir, dir);
sub_fmatrix_fmatrix(to, I, to);
@@ -871,7 +871,7 @@ BLI_INLINE float fbstar(float length, float L, float kb, float cb)
{
float tempfb_fl = kb * fb(length, L);
float fbstar_fl = cb * (length - L);
-
+
if (tempfb_fl < fbstar_fl)
return fbstar_fl;
else
@@ -898,7 +898,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data, int i, int j, float r_extent[
sub_v3_v3v3(r_extent, data->X.v3(j), data->X.v3(i));
sub_v3_v3v3(r_vel, data->V.v3(j), data->V.v3(i));
*r_length = len_v3(r_extent);
-
+
if (*r_length > ALMOST_ZERO) {
/*
if (length>L) {
@@ -916,7 +916,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data, int i, int j, float r_extent[
else {
zero_v3(r_dir);
}
-
+
return true;
}
@@ -924,12 +924,12 @@ BLI_INLINE void apply_spring(Implicit_Data *data, int i, int j, const float f[3]
{
add_v3_v3(data->F.v3(i), f);
sub_v3_v3(data->F.v3(j), f);
-
+
data->idFdX.add(i, i, dfdx);
data->idFdX.add(j, j, dfdx);
data->idFdX.sub(i, j, dfdx);
data->idFdX.sub(j, i, dfdx);
-
+
data->idFdV.add(i, i, dfdv);
data->idFdV.add(j, j, dfdv);
data->idFdV.sub(i, j, dfdv);
@@ -941,39 +941,39 @@ bool BPH_mass_spring_force_spring_linear(Implicit_Data *data, int i, int j, floa
float r_f[3], float r_dfdx[3][3], float r_dfdv[3][3])
{
float extent[3], length, dir[3], vel[3];
-
+
// calculate elonglation
spring_length(data, i, j, extent, dir, &length, vel);
-
+
if (length > restlen || no_compress) {
float stretch_force, f[3], dfdx[3][3], dfdv[3][3];
-
+
stretch_force = stiffness * (length - restlen);
if (clamp_force > 0.0f && stretch_force > clamp_force) {
stretch_force = clamp_force;
}
mul_v3_v3fl(f, dir, stretch_force);
-
+
// Ascher & Boxman, p.21: Damping only during elonglation
// something wrong with it...
madd_v3_v3fl(f, dir, damping * dot_v3v3(vel, dir));
-
+
dfdx_spring(dfdx, dir, length, restlen, stiffness);
dfdv_damp(dfdv, dir, damping);
-
+
apply_spring(data, i, j, f, dfdx, dfdv);
-
+
if (r_f) copy_v3_v3(r_f, f);
if (r_dfdx) copy_m3_m3(r_dfdx, dfdx);
if (r_dfdv) copy_m3_m3(r_dfdv, dfdv);
-
+
return true;
}
else {
if (r_f) zero_v3(r_f);
if (r_dfdx) zero_m3(r_dfdx);
if (r_dfdv) zero_m3(r_dfdv);
-
+
return false;
}
}
@@ -984,34 +984,34 @@ bool BPH_mass_spring_force_spring_bending(Implicit_Data *data, int i, int j, flo
float r_f[3], float r_dfdx[3][3], float r_dfdv[3][3])
{
float extent[3], length, dir[3], vel[3];
-
+
// calculate elonglation
spring_length(data, i, j, extent, dir, &length, vel);
-
+
if (length < restlen) {
float f[3], dfdx[3][3], dfdv[3][3];
-
+
mul_v3_v3fl(f, dir, fbstar(length, restlen, kb, cb));
-
+
outerproduct(dfdx, dir, dir);
mul_m3_fl(dfdx, fbstar_jacobi(length, restlen, kb, cb));
-
+
/* XXX damping not supported */
zero_m3(dfdv);
-
+
apply_spring(data, i, j, f, dfdx, dfdv);
-
+
if (r_f) copy_v3_v3(r_f, f);
if (r_dfdx) copy_m3_m3(r_dfdx, dfdx);
if (r_dfdv) copy_m3_m3(r_dfdv, dfdv);
-
+
return true;
}
else {
if (r_f) zero_v3(r_f);
if (r_dfdx) zero_m3(r_dfdx);
if (r_dfdv) zero_m3(r_dfdv);
-
+
return false;
}
}
@@ -1019,16 +1019,16 @@ bool BPH_mass_spring_force_spring_bending(Implicit_Data *data, int i, int j, flo
/* Jacobian of a direction vector.
* Basically the part of the differential orthogonal to the direction,
* inversely proportional to the length of the edge.
- *
+ *
* dD_ij/dx_i = -dD_ij/dx_j = (D_ij * D_ij^T - I) / len_ij
*/
BLI_INLINE void spring_grad_dir(Implicit_Data *data, int i, int j, float edge[3], float dir[3], float grad_dir[3][3])
{
float length;
-
+
sub_v3_v3v3(edge, data->X.v3(j), data->X.v3(i));
length = normalize_v3_v3(dir, edge);
-
+
if (length > ALMOST_ZERO) {
outerproduct(grad_dir, dir, dir);
sub_m3_m3m3(grad_dir, I, grad_dir);
@@ -1051,39 +1051,39 @@ BLI_INLINE void spring_angbend_forces(Implicit_Data *data, int i, int j, int k,
float f_bend[3], f_damp[3];
float fk[3];
float dist[3];
-
+
zero_v3(fk);
-
+
sub_v3_v3v3(edge_ij, data->X.v3(j), data->X.v3(i));
if (q == i) sub_v3_v3(edge_ij, dx);
if (q == j) add_v3_v3(edge_ij, dx);
normalize_v3_v3(dir_ij, edge_ij);
-
+
sub_v3_v3v3(edge_jk, data->X.v3(k), data->X.v3(j));
if (q == j) sub_v3_v3(edge_jk, dx);
if (q == k) add_v3_v3(edge_jk, dx);
normalize_v3_v3(dir_jk, edge_jk);
-
+
sub_v3_v3v3(vel_ij, data->V.v3(j), data->V.v3(i));
if (q == i) sub_v3_v3(vel_ij, dv);
if (q == j) add_v3_v3(vel_ij, dv);
-
+
sub_v3_v3v3(vel_jk, data->V.v3(k), data->V.v3(j));
if (q == j) sub_v3_v3(vel_jk, dv);
if (q == k) add_v3_v3(vel_jk, dv);
-
+
/* bending force */
sub_v3_v3v3(dist, goal, edge_jk);
mul_v3_v3fl(f_bend, dist, stiffness);
-
+
add_v3_v3(fk, f_bend);
-
+
/* damping force */
madd_v3_v3v3fl(vel_ortho, vel_jk, dir_jk, -dot_v3v3(vel_jk, dir_jk));
mul_v3_v3fl(f_damp, vel_ortho, damping);
-
+
sub_v3_v3(fk, f_damp);
-
+
copy_v3_v3(r_f, fk);
}
@@ -1097,24 +1097,24 @@ BLI_INLINE void spring_angbend_estimate_dfdx(Implicit_Data *data, int i, int j,
float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
float f[3];
int a, b;
-
+
zero_m3(dvec_null);
unit_m3(dvec_pos);
mul_m3_fl(dvec_pos, delta * 0.5f);
copy_m3_m3(dvec_neg, dvec_pos);
negate_m3(dvec_neg);
-
+
/* XXX TODO offset targets to account for position dependency */
-
+
for (a = 0; a < 3; ++a) {
spring_angbend_forces(data, i, j, k, goal, stiffness, damping,
q, dvec_pos[a], dvec_null[a], f);
copy_v3_v3(dfdx[a], f);
-
+
spring_angbend_forces(data, i, j, k, goal, stiffness, damping,
q, dvec_neg[a], dvec_null[a], f);
sub_v3_v3(dfdx[a], f);
-
+
for (b = 0; b < 3; ++b) {
dfdx[a][b] /= delta;
}
@@ -1131,24 +1131,24 @@ BLI_INLINE void spring_angbend_estimate_dfdv(Implicit_Data *data, int i, int j,
float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
float f[3];
int a, b;
-
+
zero_m3(dvec_null);
unit_m3(dvec_pos);
mul_m3_fl(dvec_pos, delta * 0.5f);
copy_m3_m3(dvec_neg, dvec_pos);
negate_m3(dvec_neg);
-
+
/* XXX TODO offset targets to account for position dependency */
-
+
for (a = 0; a < 3; ++a) {
spring_angbend_forces(data, i, j, k, goal, stiffness, damping,
q, dvec_null[a], dvec_pos[a], f);
copy_v3_v3(dfdv[a], f);
-
+
spring_angbend_forces(data, i, j, k, goal, stiffness, damping,
q, dvec_null[a], dvec_neg[a], f);
sub_v3_v3(dfdv[a], f);
-
+
for (b = 0; b < 3; ++b) {
dfdv[a][b] /= delta;
}
@@ -1165,44 +1165,44 @@ bool BPH_mass_spring_force_spring_bending_angular(Implicit_Data *data, int i, in
float fj[3], fk[3];
float dfj_dxi[3][3], dfj_dxj[3][3], dfk_dxi[3][3], dfk_dxj[3][3], dfk_dxk[3][3];
float dfj_dvi[3][3], dfj_dvj[3][3], dfk_dvi[3][3], dfk_dvj[3][3], dfk_dvk[3][3];
-
+
const float vecnull[3] = {0.0f, 0.0f, 0.0f};
-
+
world_to_root_v3(data, j, goal, target);
-
+
spring_angbend_forces(data, i, j, k, goal, stiffness, damping, k, vecnull, vecnull, fk);
negate_v3_v3(fj, fk); /* counterforce */
-
+
spring_angbend_estimate_dfdx(data, i, j, k, goal, stiffness, damping, i, dfk_dxi);
spring_angbend_estimate_dfdx(data, i, j, k, goal, stiffness, damping, j, dfk_dxj);
spring_angbend_estimate_dfdx(data, i, j, k, goal, stiffness, damping, k, dfk_dxk);
copy_m3_m3(dfj_dxi, dfk_dxi); negate_m3(dfj_dxi);
copy_m3_m3(dfj_dxj, dfk_dxj); negate_m3(dfj_dxj);
-
+
spring_angbend_estimate_dfdv(data, i, j, k, goal, stiffness, damping, i, dfk_dvi);
spring_angbend_estimate_dfdv(data, i, j, k, goal, stiffness, damping, j, dfk_dvj);
spring_angbend_estimate_dfdv(data, i, j, k, goal, stiffness, damping, k, dfk_dvk);
copy_m3_m3(dfj_dvi, dfk_dvi); negate_m3(dfj_dvi);
copy_m3_m3(dfj_dvj, dfk_dvj); negate_m3(dfj_dvj);
-
+
/* add forces and jacobians to the solver data */
-
+
add_v3_v3(data->F.v3(j), fj);
add_v3_v3(data->F.v3(k), fk);
-
+
data->idFdX.add(j, j, dfj_dxj);
data->idFdX.add(k, k, dfk_dxk);
-
+
data->idFdX.add(i, j, dfj_dxi);
data->idFdX.add(j, i, dfj_dxi);
data->idFdX.add(j, k, dfk_dxj);
data->idFdX.add(k, j, dfk_dxj);
data->idFdX.add(i, k, dfk_dxi);
data->idFdX.add(k, i, dfk_dxi);
-
+
data->idFdV.add(j, j, dfj_dvj);
data->idFdV.add(k, k, dfk_dvk);
-
+
data->idFdV.add(i, j, dfj_dvi);
data->idFdV.add(j, i, dfj_dvi);
data->idFdV.add(j, k, dfk_dvj);
@@ -1223,10 +1223,10 @@ bool BPH_mass_spring_force_spring_bending_angular(Implicit_Data *data, int i, in
float fi[3], fj[3], fk[3];
float dfi_dxi[3][3], dfj_dxi[3][3], dfj_dxj[3][3], dfk_dxi[3][3], dfk_dxj[3][3], dfk_dxk[3][3];
float dfdvi[3][3];
-
+
// TESTING
damping = 0.0f;
-
+
zero_v3(fi);
zero_v3(fj);
zero_v3(fk);
@@ -1235,68 +1235,68 @@ bool BPH_mass_spring_force_spring_bending_angular(Implicit_Data *data, int i, in
zero_m3(dfk_dxi);
zero_m3(dfk_dxj);
zero_m3(dfk_dxk);
-
+
/* jacobian of direction vectors */
spring_grad_dir(data, i, j, edge_ij, dir_ij, grad_dir_ij);
spring_grad_dir(data, j, k, edge_jk, dir_jk, grad_dir_jk);
-
+
sub_v3_v3v3(vel_jk, data->V[k], data->V[j]);
-
+
/* bending force */
mul_v3_v3fl(target, dir_ij, restlen);
sub_v3_v3v3(dist, target, edge_jk);
mul_v3_v3fl(fk, dist, stiffness);
-
+
/* damping force */
madd_v3_v3v3fl(vel_jk_ortho, vel_jk, dir_jk, -dot_v3v3(vel_jk, dir_jk));
madd_v3_v3fl(fk, vel_jk_ortho, damping);
-
+
/* XXX this only holds true as long as we assume straight rest shape!
* eventually will become a bit more involved since the opposite segment
* gets its own target, under condition of having equal torque on both sides.
*/
copy_v3_v3(fi, fk);
-
+
/* counterforce on the middle point */
sub_v3_v3(fj, fi);
sub_v3_v3(fj, fk);
-
+
/* === derivatives === */
-
+
madd_m3_m3fl(dfk_dxi, grad_dir_ij, stiffness * restlen);
-
+
madd_m3_m3fl(dfk_dxj, grad_dir_ij, -stiffness * restlen);
madd_m3_m3fl(dfk_dxj, I, stiffness);
-
+
madd_m3_m3fl(dfk_dxk, I, -stiffness);
-
+
copy_m3_m3(dfi_dxi, dfk_dxk);
negate_m3(dfi_dxi);
-
+
/* dfj_dfi == dfi_dfj due to symmetry,
* dfi_dfj == dfk_dfj due to fi == fk
* XXX see comment above on future bent rest shapes
*/
copy_m3_m3(dfj_dxi, dfk_dxj);
-
+
/* dfj_dxj == -(dfi_dxj + dfk_dxj) due to fj == -(fi + fk) */
sub_m3_m3m3(dfj_dxj, dfj_dxj, dfj_dxi);
sub_m3_m3m3(dfj_dxj, dfj_dxj, dfk_dxj);
-
+
/* add forces and jacobians to the solver data */
add_v3_v3(data->F[i], fi);
add_v3_v3(data->F[j], fj);
add_v3_v3(data->F[k], fk);
-
+
add_m3_m3m3(data->dFdX[i].m, data->dFdX[i].m, dfi_dxi);
add_m3_m3m3(data->dFdX[j].m, data->dFdX[j].m, dfj_dxj);
add_m3_m3m3(data->dFdX[k].m, data->dFdX[k].m, dfk_dxk);
-
+
add_m3_m3m3(data->dFdX[block_ij].m, data->dFdX[block_ij].m, dfj_dxi);
add_m3_m3m3(data->dFdX[block_jk].m, data->dFdX[block_jk].m, dfk_dxj);
add_m3_m3m3(data->dFdX[block_ik].m, data->dFdX[block_ik].m, dfk_dxi);
#endif
-
+
return true;
}
@@ -1306,40 +1306,40 @@ bool BPH_mass_spring_force_spring_goal(Implicit_Data *data, int i, const float g
{
float root_goal_x[3], root_goal_v[3], extent[3], length, dir[3], vel[3];
float f[3], dfdx[3][3], dfdv[3][3];
-
+
/* goal is in world space */
world_to_root_v3(data, i, root_goal_x, goal_x);
world_to_root_v3(data, i, root_goal_v, goal_v);
-
+
sub_v3_v3v3(extent, root_goal_x, data->X.v3(i));
sub_v3_v3v3(vel, root_goal_v, data->V.v3(i));
length = normalize_v3_v3(dir, extent);
-
+
if (length > ALMOST_ZERO) {
mul_v3_v3fl(f, dir, stiffness * length);
-
+
// Ascher & Boxman, p.21: Damping only during elonglation
// something wrong with it...
madd_v3_v3fl(f, dir, damping * dot_v3v3(vel, dir));
-
+
dfdx_spring(dfdx, dir, length, 0.0f, stiffness);
dfdv_damp(dfdv, dir, damping);
-
+
add_v3_v3(data->F.v3(i), f);
data->idFdX.add(i, i, dfdx);
data->idFdV.add(i, i, dfdv);
-
+
if (r_f) copy_v3_v3(r_f, f);
if (r_dfdx) copy_m3_m3(r_dfdx, dfdx);
if (r_dfdv) copy_m3_m3(r_dfdv, dfdv);
-
+
return true;
}
else {
if (r_f) zero_v3(r_f);
if (r_dfdx) zero_m3(r_dfdx);
if (r_dfdv) zero_m3(r_dfdv);
-
+
return false;
}
}
diff --git a/source/blender/python/bmesh/CMakeLists.txt b/source/blender/python/bmesh/CMakeLists.txt
index 4d3230fa3e9..48213b7eed5 100644
--- a/source/blender/python/bmesh/CMakeLists.txt
+++ b/source/blender/python/bmesh/CMakeLists.txt
@@ -18,7 +18,7 @@
#
# ***** END GPL LICENSE BLOCK *****
-set(INC
+set(INC
.
../../bmesh
../../blenkernel
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index a6ed92d139c..c6a67a1b2dd 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -2153,7 +2153,7 @@ static PyObject *bpy_bmedgeseq_new(BPy_BMElemSeq *self, PyObject *args)
if (vert_array == NULL) {
return NULL;
}
-
+
if (BM_edge_exists(vert_array[0], vert_array[1])) {
PyErr_SetString(PyExc_ValueError,
"edges.new(): this edge exists");
diff --git a/source/blender/python/generic/CMakeLists.txt b/source/blender/python/generic/CMakeLists.txt
index df611e00d00..9a5a3fddff0 100644
--- a/source/blender/python/generic/CMakeLists.txt
+++ b/source/blender/python/generic/CMakeLists.txt
@@ -18,7 +18,7 @@
#
# ***** END GPL LICENSE BLOCK *****
-set(INC
+set(INC
.
../../blenkernel
../../blenlib
@@ -39,12 +39,14 @@ set(SRC
bpy_internal_import.c
bpy_threads.c
idprop_py_api.c
+ imbuf_py_api.c
py_capi_utils.c
bgl.h
blf_py_api.h
bpy_internal_import.h
idprop_py_api.h
+ imbuf_py_api.h
py_capi_utils.h
# header-only
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index 1e2837799e3..8f9475822bf 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -866,7 +866,7 @@ static PyObject *Buffer_slice(Buffer *self, int begin, int end)
{
PyObject *list;
int count;
-
+
if (begin < 0) begin = 0;
if (end > self->dimensions[0]) end = self->dimensions[0];
if (begin > end) begin = end;
@@ -914,11 +914,11 @@ static int Buffer_ass_slice(Buffer *self, int begin, int end, PyObject *seq)
{
PyObject *item;
int count, err = 0;
-
+
if (begin < 0) begin = 0;
if (end > self->dimensions[0]) end = self->dimensions[0];
if (begin > end) begin = end;
-
+
if (!PySequence_Check(seq)) {
PyErr_Format(PyExc_TypeError,
"buffer[:] = value, invalid assignment. "
@@ -934,7 +934,7 @@ static int Buffer_ass_slice(Buffer *self, int begin, int end, PyObject *seq)
"Expected: %d (given: %d)", count, end - begin);
return -1;
}
-
+
for (count = begin; count < end; count++) {
item = PySequence_GetItem(seq, count - begin);
if (item) {
diff --git a/source/blender/python/generic/bgl.h b/source/blender/python/generic/bgl.h
index b27a4d6a0a4..1373c81046b 100644
--- a/source/blender/python/generic/bgl.h
+++ b/source/blender/python/generic/bgl.h
@@ -39,7 +39,7 @@ int BGL_typeSize(int type);
* For Python access to OpenGL functions requiring a pointer.
*/
typedef struct _Buffer {
- PyObject_VAR_HEAD
+ PyObject_VAR_HEAD
PyObject *parent;
int type; /* GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT */
diff --git a/source/blender/python/generic/blf_py_api.c b/source/blender/python/generic/blf_py_api.c
index 02bd1fdbe39..2305d448e04 100644
--- a/source/blender/python/generic/blf_py_api.c
+++ b/source/blender/python/generic/blf_py_api.c
@@ -307,7 +307,7 @@ static PyObject *py_blf_rotation(PyObject *UNUSED(self), PyObject *args)
if (!PyArg_ParseTuple(args, "if:blf.rotation", &fontid, &angle))
return NULL;
-
+
BLF_rotation(fontid, angle);
Py_RETURN_NONE;
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
index 750d0c20301..0211e7bd880 100644
--- a/source/blender/python/generic/bpy_internal_import.c
+++ b/source/blender/python/generic/bpy_internal_import.c
@@ -177,7 +177,7 @@ PyObject *bpy_text_import_name(const char *name, int *found)
int namelen = strlen(name);
//XXX Main *maggie = bpy_import_main ? bpy_import_main:G.main;
Main *maggie = bpy_import_main;
-
+
*found = 0;
if (!maggie) {
@@ -210,7 +210,7 @@ PyObject *bpy_text_import_name(const char *name, int *found)
return NULL;
else
*found = 1;
-
+
return bpy_text_import(text);
}
@@ -226,14 +226,14 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
const char *filepath;
//XXX Main *maggie = bpy_import_main ? bpy_import_main:G.main;
Main *maggie = bpy_import_main;
-
+
if (!maggie) {
printf("ERROR: bpy_import_main_set() was not called before running python. this is a bug.\n");
return NULL;
}
-
+
*found = 0;
-
+
/* get name, filename from the module itself */
if ((name = PyModule_GetName(module)) == NULL)
return NULL;
@@ -288,15 +288,15 @@ static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject
/* import existing builtin modules or modules that have been imported already */
newmodule = PyImport_ImportModuleLevel(name, globals, locals, fromlist, level);
-
+
if (newmodule)
return newmodule;
-
+
PyErr_Fetch(&exception, &err, &tb); /* get the python error in case we cant import as blender text either */
-
+
/* importing from existing modules failed, see if we have this module as blender text */
newmodule = bpy_text_import_name(name, &found);
-
+
if (newmodule) { /* found module as blender text, ignore above exception */
PyErr_Clear();
Py_XDECREF(exception);
diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h
index f11571fb933..8de1436ed48 100644
--- a/source/blender/python/generic/bpy_internal_import.h
+++ b/source/blender/python/generic/bpy_internal_import.h
@@ -1,4 +1,4 @@
-/*
+/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -47,7 +47,7 @@ bool bpy_text_compile(struct Text *text);
PyObject *bpy_text_import(struct Text *text);
PyObject *bpy_text_import_name(const char *name, int *found);
PyObject *bpy_text_reimport(PyObject *module, int *found);
-/* void bpy_text_clear_modules(int clear_all);*/ /* Clear user modules */
+/* void bpy_text_clear_modules(int clear_all);*/ /* Clear user modules */
void bpy_text_filename_get(char *fn, size_t fn_len, struct Text *text);
diff --git a/source/blender/python/generic/imbuf_py_api.c b/source/blender/python/generic/imbuf_py_api.c
new file mode 100644
index 00000000000..2e32829bf6c
--- /dev/null
+++ b/source/blender/python/generic/imbuf_py_api.c
@@ -0,0 +1,447 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/python/generic/imbuf_py_api.c
+ * \ingroup pygen
+ *
+ * This file defines the 'imbuf' image manipulation module.
+ */
+
+#include <Python.h>
+
+#include "BLI_utildefines.h"
+#include "BLI_string.h"
+
+#include "py_capi_utils.h"
+
+#include "python_utildefines.h"
+
+#include "imbuf_py_api.h" /* own include */
+
+#include "../../imbuf/IMB_imbuf.h"
+#include "../../imbuf/IMB_imbuf_types.h"
+
+/* File IO */
+#include <fcntl.h>
+#include <errno.h>
+#include "BLI_fileops.h"
+
+/* -------------------------------------------------------------------- */
+/** \name Type & Utilities
+ * \{ */
+
+typedef struct Py_ImBuf {
+ PyObject_VAR_HEAD
+ /* can be NULL */
+ ImBuf *ibuf;
+} Py_ImBuf;
+
+static int py_imbuf_valid_check(Py_ImBuf *self)
+{
+ if (LIKELY(self->ibuf)) {
+ return 0;
+ }
+ else {
+ PyErr_Format(PyExc_ReferenceError,
+ "ImBuf data of type %.200s has been freed",
+ Py_TYPE(self)->tp_name);
+ return -1;
+ }
+}
+
+#define PY_IMBUF_CHECK_OBJ(obj) \
+ if (UNLIKELY(py_imbuf_valid_check(obj) == -1)) { return NULL; } ((void)0)
+#define PY_IMBUF_CHECK_INT(obj) \
+ if (UNLIKELY(py_imbuf_valid_check(obj) == -1)) { return -1; } ((void)0)
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Methods
+ * \{ */
+
+PyDoc_STRVAR(py_imbuf_resize_doc,
+".. method:: resize(size, method='FAST')\n"
+"\n"
+" Resize the image.\n"
+"\n"
+" :arg size: New size.\n"
+" :type size: pair of ints\n"
+" :arg method: Method of resizing (TODO)\n"
+" :type method: str\n"
+);
+static PyObject *py_imbuf_resize(Py_ImBuf *self, PyObject *args, PyObject *kw)
+{
+ PY_IMBUF_CHECK_OBJ(self);
+
+ uint size[2];
+ char *method = NULL;
+
+ static const char *_keywords[] = {"size", "method", NULL};
+ static _PyArg_Parser _parser = {"(II)|s:resize", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &size[0], &size[1],
+ &method))
+ {
+ return NULL;
+ }
+ IMB_scaleImBuf(self->ibuf, UNPACK2(size));
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(py_imbuf_free_doc,
+".. method:: free()\n"
+"\n"
+" Clear image data immediately (causing an error on re-use).\n"
+);
+static PyObject *py_imbuf_free(Py_ImBuf *self)
+{
+ if (self->ibuf) {
+ IMB_freeImBuf(self->ibuf);
+ self->ibuf = NULL;
+ }
+ Py_RETURN_NONE;
+}
+
+static struct PyMethodDef Py_ImBuf_methods[] = {
+ {"resize", (PyCFunction)py_imbuf_resize, METH_VARARGS | METH_KEYWORDS, (char *)py_imbuf_resize_doc},
+ {"free", (PyCFunction)py_imbuf_free, METH_NOARGS, (char *)py_imbuf_free_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Attributes
+ * \{ */
+
+PyDoc_STRVAR(py_imbuf_size_doc,
+"size of the image in pixels.\n\n:type: pair of ints"
+);
+static PyObject *py_imbuf_size_get(Py_ImBuf *self, void *UNUSED(closure))
+{
+ PY_IMBUF_CHECK_OBJ(self);
+ ImBuf *ibuf = self->ibuf;
+ return PyC_Tuple_Pack_I32(ibuf->x, ibuf->y);
+}
+
+PyDoc_STRVAR(py_imbuf_ppm_doc,
+"pixels per meter.\n\n:type: pair of floats"
+);
+static PyObject *py_imbuf_ppm_get(Py_ImBuf *self, void *UNUSED(closure))
+{
+ PY_IMBUF_CHECK_OBJ(self);
+ ImBuf *ibuf = self->ibuf;
+ return PyC_Tuple_Pack_F64(ibuf->ppm[0], ibuf->ppm[1]);
+}
+
+static int py_imbuf_ppm_set(Py_ImBuf *self, PyObject *value, void *UNUSED(closure))
+{
+ PY_IMBUF_CHECK_INT(self);
+ double ppm[2];
+
+ if (PyC_AsArray(ppm, value, 2, &PyFloat_Type, true, "ppm") == -1) {
+ return -1;
+ }
+
+ if (ppm[0] <= 0.0 || ppm[1] <= 0.0) {
+ PyErr_SetString(PyExc_ValueError, "invalid ppm value");
+ return -1;
+ }
+
+ ImBuf *ibuf = self->ibuf;
+ ibuf->ppm[0] = ppm[0];
+ ibuf->ppm[1] = ppm[1];
+ return 0;
+}
+
+static PyGetSetDef Py_ImBuf_getseters[] = {
+ {(char *)"size", (getter)py_imbuf_size_get, (setter)NULL, (char *)py_imbuf_size_doc, NULL},
+ {(char *)"ppm", (getter)py_imbuf_ppm_get, (setter)py_imbuf_ppm_set, (char *)py_imbuf_ppm_doc, NULL},
+ {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+};
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Type & Implementation
+ * \{ */
+
+static void py_imbuf_dealloc(Py_ImBuf *self)
+{
+ ImBuf *ibuf = self->ibuf;
+ if (ibuf != NULL) {
+ IMB_freeImBuf(self->ibuf);
+ self->ibuf = NULL;
+ }
+ PyObject_DEL(self);
+}
+
+static PyObject *py_imbuf_repr(Py_ImBuf *self)
+{
+ const ImBuf *ibuf = self->ibuf;
+ if (ibuf != NULL) {
+ return PyUnicode_FromFormat(
+ "<imbuf: address=%p, filename='%s', size=(%d, %d)>",
+ ibuf, ibuf->name, ibuf->x, ibuf->y);
+ }
+ else {
+ return PyUnicode_FromString(
+ "<imbuf: address=0x0>");
+ }
+}
+
+static Py_hash_t py_imbuf_hash(Py_ImBuf *self)
+{
+ return _Py_HashPointer(self->ibuf);
+}
+
+PyTypeObject Py_ImBuf_Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ /* For printing, in format "<module>.<name>" */
+ "ImBuf", /* tp_name */
+ sizeof(Py_ImBuf), /* int tp_basicsize; */
+ 0, /* tp_itemsize; For allocation */
+
+ /* Methods to implement standard operations */
+
+ (destructor)py_imbuf_dealloc, /* destructor tp_dealloc; */
+ NULL, /* printfunc tp_print; */
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
+ NULL, /* cmpfunc tp_compare; */
+ (reprfunc)py_imbuf_repr, /* reprfunc tp_repr; */
+
+ /* Method suites for standard classes */
+
+ NULL, /* PyNumberMethods *tp_as_number; */
+ NULL, /* PySequenceMethods *tp_as_sequence; */
+ NULL, /* PyMappingMethods *tp_as_mapping; */
+
+ /* More standard operations (here for binary compatibility) */
+
+ (hashfunc)py_imbuf_hash, /* hashfunc tp_hash; */
+ NULL, /* ternaryfunc tp_call; */
+ NULL, /* reprfunc tp_str; */
+ NULL, /* getattrofunc tp_getattro; */
+ NULL, /* setattrofunc tp_setattro; */
+
+ /* Functions to access object as input/output buffer */
+ NULL, /* PyBufferProcs *tp_as_buffer; */
+
+ /*** Flags to define presence of optional/expanded features ***/
+ Py_TPFLAGS_DEFAULT, /* long tp_flags; */
+
+ NULL, /* char *tp_doc; Documentation string */
+ /*** Assigned meaning in release 2.0 ***/
+ /* call function for all accessible objects */
+ NULL, /* traverseproc tp_traverse; */
+
+ /* delete references to contained objects */
+ NULL, /* inquiry tp_clear; */
+
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
+ NULL, /* richcmpfunc tp_richcompare; */
+
+ /*** weak reference enabler ***/
+ 0, /* long tp_weaklistoffset; */
+
+ /*** Added in release 2.2 ***/
+ /* Iterators */
+ NULL, /* getiterfunc tp_iter; */
+ NULL, /* iternextfunc tp_iternext; */
+ /*** Attribute descriptor and subclassing stuff ***/
+ Py_ImBuf_methods, /* struct PyMethodDef *tp_methods; */
+ NULL, /* struct PyMemberDef *tp_members; */
+ Py_ImBuf_getseters, /* struct PyGetSetDef *tp_getset; */
+};
+
+static PyObject *Py_ImBuf_CreatePyObject(ImBuf *ibuf)
+{
+ Py_ImBuf *self = PyObject_New(Py_ImBuf, &Py_ImBuf_Type);
+ self->ibuf = ibuf;
+ return (PyObject *)self;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Module Functions
+ * \{ */
+
+PyDoc_STRVAR(M_imbuf_new_doc,
+".. function:: new(size)\n"
+"\n"
+" Load a new image.\n"
+"\n"
+" :arg size: The size of the image in pixels.\n"
+" :type size: pair of ints\n"
+" :return: the newly loaded image.\n"
+" :rtype: :class:`ImBuf`\n"
+);
+static PyObject *M_imbuf_new(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
+{
+ int size[2];
+ static const char *_keywords[] = {"size", NULL};
+ static _PyArg_Parser _parser = {"(ii)|i:new", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &size[0], &size[1]))
+ {
+ return NULL;
+ }
+
+ /* TODO, make options */
+ uchar planes = 4;
+ uint flags = IB_rect;
+
+ ImBuf *ibuf = IMB_allocImBuf(UNPACK2(size), planes, flags);
+ if (ibuf == NULL) {
+ PyErr_Format(PyExc_ValueError, "new: Unable to create image (%d, %d)", UNPACK2(size));
+ return NULL;
+ }
+ return Py_ImBuf_CreatePyObject(ibuf);
+}
+
+PyDoc_STRVAR(M_imbuf_load_doc,
+".. function:: load(filename)\n"
+"\n"
+" Load an image from a file.\n"
+"\n"
+" :arg filename: the filename of the image.\n"
+" :type filename: string\n"
+" :return: the newly loaded image.\n"
+" :rtype: :class:`ImBuf`\n"
+);
+static PyObject *M_imbuf_load(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
+{
+ const char *filename;
+
+ static const char *_keywords[] = {"filename", NULL};
+ static _PyArg_Parser _parser = {"s:load", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &filename))
+ {
+ return NULL;
+ }
+
+ const int file = BLI_open(filename, O_BINARY | O_RDONLY, 0);
+ if (file == -1) {
+ PyErr_Format(PyExc_IOError, "load: %s, failed to open file '%s'", strerror(errno));
+ return NULL;
+ }
+
+ ImBuf *ibuf = IMB_loadifffile(file, filename, IB_rect, NULL, filename);
+
+ close(file);
+
+ if (ibuf == NULL) {
+ PyErr_Format(PyExc_ValueError, "load: Unable to recognize image format for file '%s'", filename);
+ return NULL;
+ }
+
+ BLI_strncpy(ibuf->name, filename, sizeof(ibuf->name));
+
+ return Py_ImBuf_CreatePyObject(ibuf);
+}
+
+PyDoc_STRVAR(M_imbuf_write_doc,
+".. function:: write(image, filename)\n"
+"\n"
+" Write an image.\n"
+"\n"
+" :arg image: the image to write.\n"
+" :type image: :class:`ImBuf`\n"
+" :arg filename: the filename of the image.\n"
+" :type filename: string\n"
+);
+static PyObject *M_imbuf_write(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
+{
+ Py_ImBuf *py_imb;
+ const char *filename = NULL;
+
+ static const char *_keywords[] = {"image", "filename", NULL};
+ static _PyArg_Parser _parser = {"O!|s:write", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &Py_ImBuf_Type, &py_imb,
+ &filename))
+ {
+ return NULL;
+ }
+
+ if (filename == NULL) {
+ filename = py_imb->ibuf->name;
+ }
+
+ bool ok = IMB_saveiff(py_imb->ibuf, filename, IB_rect);
+ if (ok == false) {
+ PyErr_Format(PyExc_IOError, "write: Unable to write image file (%s) '%s'", strerror(errno), filename);
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Module Definition
+ * \{ */
+
+static PyMethodDef IMB_methods[] = {
+ {"new", (PyCFunction) M_imbuf_new, METH_VARARGS | METH_KEYWORDS, M_imbuf_new_doc},
+ {"load", (PyCFunction) M_imbuf_load, METH_VARARGS | METH_KEYWORDS, M_imbuf_load_doc},
+ {"write", (PyCFunction) M_imbuf_write, METH_VARARGS | METH_KEYWORDS, M_imbuf_write_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+PyDoc_STRVAR(IMB_doc,
+"This module provides access to Blender's image manipulation API."
+);
+static struct PyModuleDef IMB_module_def = {
+ PyModuleDef_HEAD_INIT,
+ "imbuf", /* m_name */
+ IMB_doc, /* m_doc */
+ 0, /* m_size */
+ IMB_methods, /* m_methods */
+ NULL, /* m_reload */
+ NULL, /* m_traverse */
+ NULL, /* m_clear */
+ NULL, /* m_free */
+};
+
+PyObject *BPyInit_imbuf(void)
+{
+ PyObject *submodule;
+
+ submodule = PyModule_Create(&IMB_module_def);
+
+ PyType_Ready(&Py_ImBuf_Type);
+
+ return submodule;
+}
+
+/** \} */
diff --git a/source/blender/python/generic/imbuf_py_api.h b/source/blender/python/generic/imbuf_py_api.h
new file mode 100644
index 00000000000..92c1732a9c9
--- /dev/null
+++ b/source/blender/python/generic/imbuf_py_api.h
@@ -0,0 +1,30 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __IMBUF_PY_API_H__
+#define __IMBUF_PY_API_H__
+
+/** \file blender/python/generic/imbuf_py_api.h
+ * \ingroup pygen
+ */
+
+PyObject *BPyInit_imbuf(void);
+
+#endif /* __IMBUF_PY_API_H__ */
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 6f265b2ae87..22646462163 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -295,7 +295,7 @@ void PyC_LineSpit(void)
PyErr_Clear();
PyC_FileAndNum(&filename, &lineno);
-
+
fprintf(stderr, "%s:%d\n", filename, lineno);
}
@@ -317,7 +317,7 @@ void PyC_StackSpit(void)
void PyC_FileAndNum(const char **filename, int *lineno)
{
PyFrameObject *frame;
-
+
if (filename) *filename = NULL;
if (lineno) *lineno = -1;
@@ -375,22 +375,22 @@ PyObject *PyC_Object_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...)
Py_ssize_t i;
PyObject *item = o;
const char *attr;
-
+
va_list vargs;
va_start(vargs, n);
for (i = 0; i < n; i++) {
attr = va_arg(vargs, char *);
item = PyObject_GetAttrString(item, attr);
-
- if (item)
+
+ if (item)
Py_DECREF(item);
else /* python will set the error value here */
break;
-
+
}
va_end(vargs);
-
+
Py_XINCREF(item); /* final value has is increfed, to match PyObject_GetAttrString */
return item;
}
@@ -839,7 +839,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
}
}
va_end(vargs);
-
+
/* set the value so we can access it */
PyDict_SetItemString(py_dict, "values", values);
Py_DECREF(values);
@@ -865,7 +865,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
for (i = 0; i * 2 < n; i++) {
const char *format = va_arg(vargs, char *);
void *ptr = va_arg(vargs, void *);
-
+
PyObject *item;
PyObject *item_new;
/* prepend the string formatting and remake the tuple */
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index e07fa46424c..a0461ed945d 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -171,7 +171,7 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
PyErr_SetString(PyExc_ValueError, "invalid resource argument");
return NULL;
}
-
+
/* same logic as BKE_appdir_folder_id_create(), but best leave it up to the script author to create */
path = BKE_appdir_folder_id(folder_id, subdir);
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index f6e89ef38a5..03662102bbc 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -253,10 +253,10 @@ static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *clos
PyErr_SetString(PyExc_TypeError, "bpy.app.debug can only be True/False");
return -1;
}
-
+
if (param) G.debug |= flag;
else G.debug &= ~flag;
-
+
return 0;
}
@@ -307,7 +307,7 @@ static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void
PyErr_SetString(PyExc_TypeError, "bpy.app.debug_value can only be set to a whole number");
return -1;
}
-
+
G.debug_value = param;
WM_main_add_notifier(NC_WINDOW, NULL);
@@ -406,7 +406,7 @@ static void py_struct_seq_getset_init(void)
PyObject *BPY_app_struct(void)
{
PyObject *ret;
-
+
PyStructSequence_InitType(&BlenderAppType, &app_info_desc);
ret = make_app_info();
diff --git a/source/blender/python/intern/bpy_capi_utils.c b/source/blender/python/intern/bpy_capi_utils.c
index 7232e4ea821..f873a8a762b 100644
--- a/source/blender/python/intern/bpy_capi_utils.c
+++ b/source/blender/python/intern/bpy_capi_utils.c
@@ -88,21 +88,21 @@ bool BPy_errors_to_report_ex(ReportList *reports, const bool use_full, const boo
if (!PyErr_Occurred())
return 1;
-
+
/* less hassle if we allow NULL */
if (reports == NULL) {
PyErr_Print();
PyErr_Clear();
return 1;
}
-
+
if (use_full) {
pystring = PyC_ExceptionBuffer();
}
else {
pystring = PyC_ExceptionBuffer_Simple();
}
-
+
if (pystring == NULL) {
BKE_report(reports, RPT_ERROR, "Unknown py-exception, could not convert");
return 0;
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index c8ce7b2f770..215a64a4449 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -285,7 +285,7 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, c
for (dvar = driver->variables.first, i = 0; dvar; dvar = dvar->next) {
PyTuple_SET_ITEM(expr_vars, i++, PyUnicode_FromString(dvar->name));
}
-
+
driver->flag &= ~DRIVER_FLAG_RENAMEVAR;
}
else {
@@ -342,7 +342,7 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, c
fprintf(stderr, "\nBPY_driver_eval() - Error while evaluating PyDriver:\n");
targets_ok = 0;
}
-
+
fprintf(stderr, "\tBPY_driver_eval() - couldn't add variable '%s' to namespace\n", dvar->name);
// BPy_errors_to_report(NULL); // TODO - reports
PyErr_Print();
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 7156bed0c2b..5f51f2ac152 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -74,6 +74,7 @@
#include "../generic/bgl.h"
#include "../generic/blf_py_api.h"
#include "../generic/idprop_py_api.h"
+#include "../generic/imbuf_py_api.h"
#include "../gawain/gwn_py_api.h"
#include "../bmesh/bmesh_py_api.h"
#include "../mathutils/mathutils.h"
@@ -221,6 +222,7 @@ static struct _inittab bpy_internal_modules[] = {
{"_gawain", BPyInit_gawain},
{"bgl", BPyInit_bgl},
{"blf", BPyInit_blf},
+ {"imbuf", BPyInit_imbuf},
{"bmesh", BPyInit_bmesh},
#if 0
{"bmesh.types", BPyInit_bmesh_types},
@@ -291,7 +293,7 @@ void BPY_python_start(int argc, const char **argv)
PySys_SetObject("argv", py_argv);
Py_DECREF(py_argv);
}
-
+
/* Initialize thread support (also acquires lock) */
PyEval_InitThreads();
#else
@@ -330,7 +332,7 @@ void BPY_python_start(int argc, const char **argv)
BPy_init_modules();
bpy_import_init(PyEval_GetBuiltins());
-
+
pyrna_alloc_types();
#ifndef WITH_PYTHON_MODULE
@@ -349,7 +351,7 @@ void BPY_python_end(void)
/* finalizing, no need to grab the state, except when we are a module */
gilstate = PyGILState_Ensure();
-
+
/* free other python data. */
pyrna_free_types();
@@ -696,7 +698,7 @@ bool BPY_execute_string_ex(bContext *C, const char *expr, bool use_eval)
PyC_MainModule_Restore(main_mod);
bpy_context_clear(C, &gilstate);
-
+
return ok;
}
@@ -730,7 +732,7 @@ void BPY_modules_load_user(bContext *C)
G.f |= G_SCRIPT_AUTOEXEC_FAIL;
BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Text '%s'", text->id.name + 2);
- printf("scripts disabled for \"%s\", skipping '%s'\n", bmain->name, text->id.name + 2);
+ printf("scripts disabled for \"%s\", skipping '%s'\n", BKE_main_blendfile_path(bmain), text->id.name + 2);
}
}
else {
@@ -880,7 +882,7 @@ static void bpy_module_delay_init(PyObject *bpy_proxy)
argv[0] = filename_abs;
argv[1] = NULL;
-
+
// printf("module found %s\n", argv[0]);
main_python_enter(argc, argv);
@@ -909,14 +911,14 @@ PyMODINIT_FUNC
PyInit_bpy(void)
{
PyObject *bpy_proxy = PyModule_Create(&bpy_proxy_def);
-
+
/* Problem:
* 1) this init function is expected to have a private member defined - 'md_def'
* but this is only set for C defined modules (not py packages)
* so we cant return 'bpy_package_py' as is.
*
* 2) there is a 'bpy' C module for python to load which is basically all of blender,
- * and there is scripts/bpy/__init__.py,
+ * and there is scripts/bpy/__init__.py,
* we may end up having to rename this module so there is no naming conflict here eg:
* 'from blender import bpy'
*
@@ -926,13 +928,13 @@ PyInit_bpy(void)
/* assign an object which is freed after __file__ is assigned */
dealloc_obj *dob;
-
+
/* assign dummy type */
dealloc_obj_Type.tp_name = "dealloc_obj";
dealloc_obj_Type.tp_basicsize = sizeof(dealloc_obj);
dealloc_obj_Type.tp_dealloc = dealloc_obj_dealloc;
dealloc_obj_Type.tp_flags = Py_TPFLAGS_DEFAULT;
-
+
if (PyType_Ready(&dealloc_obj_Type) < 0)
return NULL;
diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.c
index 0ca46f9b20e..d60c44e702a 100644
--- a/source/blender/python/intern/bpy_library_load.c
+++ b/source/blender/python/intern/bpy_library_load.c
@@ -205,7 +205,7 @@ static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *
BLI_strncpy(ret->relpath, filename, sizeof(ret->relpath));
BLI_strncpy(ret->abspath, filename, sizeof(ret->abspath));
- BLI_path_abs(ret->abspath, bmain->name);
+ BLI_path_abs(ret->abspath, BKE_main_blendfile_path(bmain));
ret->blo_handle = NULL;
ret->flag = ((is_link ? FILE_LINK : 0) |
diff --git a/source/blender/python/intern/bpy_library_write.c b/source/blender/python/intern/bpy_library_write.c
index 9ca6092eab3..ead10efb212 100644
--- a/source/blender/python/intern/bpy_library_write.c
+++ b/source/blender/python/intern/bpy_library_write.c
@@ -107,7 +107,7 @@ static PyObject *bpy_lib_write(PyObject *UNUSED(self), PyObject *args, PyObject
}
BLI_strncpy(filepath_abs, filepath, FILE_MAX);
- BLI_path_abs(filepath_abs, G.main->name);
+ BLI_path_abs(filepath_abs, BKE_main_blendfile_path_from_global());
BKE_blendfile_write_partial_begin(bmain_src);
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 0cadbc30a9f..4652da2018c 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -79,7 +79,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
/* XXX Todo, work out a better solution for passing on context,
* could make a tuple from self and pack the name and Context into it... */
bContext *C = (bContext *)BPy_GetContext();
-
+
if (C == NULL) {
PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any operators");
return NULL;
@@ -87,7 +87,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
if (!PyArg_ParseTuple(args, "s|Os:_bpy.ops.poll", &opname, &context_dict, &context_str))
return NULL;
-
+
ot = WM_operatortype_find(opname, true);
if (ot == NULL) {
@@ -108,7 +108,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
return NULL;
}
}
-
+
if (context_dict == NULL || context_dict == Py_None) {
context_dict = NULL;
}
@@ -123,10 +123,10 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
context_dict_back = CTX_py_dict_get(C);
CTX_py_dict_set(C, (void *)context_dict);
Py_XINCREF(context_dict); /* so we done loose it */
-
+
/* main purpose of thsi function */
ret = WM_operator_poll_context((bContext *)C, ot, context) ? Py_True : Py_False;
-
+
/* restore with original context dict, probably NULL but need this for nested operator calls */
Py_XDECREF(context_dict);
CTX_py_dict_set(C, (void *)context_dict_back);
@@ -154,12 +154,12 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
/* XXX Todo, work out a better solution for passing on context,
* could make a tuple from self and pack the name and Context into it... */
bContext *C = (bContext *)BPy_GetContext();
-
+
if (C == NULL) {
PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any operators");
return NULL;
}
-
+
if (!PyArg_ParseTuple(args, "sO|O!si:_bpy.ops.call",
&opname, &context_dict, &PyDict_Type, &kw, &context_str, &is_undo))
{
@@ -174,7 +174,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
"could not be found", opname);
return NULL;
}
-
+
if (!pyrna_write_check()) {
PyErr_Format(PyExc_RuntimeError,
"Calling operator \"bpy.ops.%s\" error, "
@@ -259,7 +259,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
PySys_WriteStdout("%s: %s\n", report->typestr, report->message);
}
}
-
+
BKE_reports_clear(reports);
if ((reports->flag & RPT_FREE) == 0) {
MEM_freeN(reports);
@@ -330,7 +330,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
PyErr_SetString(PyExc_RuntimeError, "Context is None, cant get the string representation of this object.");
return NULL;
}
-
+
if (!PyArg_ParseTuple(
args, "s|O!O&O&:_bpy.ops.as_string",
&opname, &PyDict_Type, &kw,
@@ -400,7 +400,7 @@ static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
PointerRNA ptr;
const char *opname = _PyUnicode_AsString(value);
BPy_StructRNA *pyrna = NULL;
-
+
if (opname == NULL) {
PyErr_SetString(PyExc_TypeError, "_bpy.ops.get_rna() expects a string argument");
return NULL;
@@ -410,7 +410,7 @@ static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
PyErr_Format(PyExc_KeyError, "_bpy.ops.get_rna(\"%s\") not found", opname);
return NULL;
}
-
+
/* type */
//RNA_pointer_create(NULL, &RNA_Struct, ot->srna, &ptr);
@@ -418,7 +418,7 @@ static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
WM_operator_properties_create_ptr(&ptr, ot);
WM_operator_properties_sanitize(&ptr, 0);
-
+
pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr);
#ifdef PYRNA_FREE_SUPPORT
pyrna->freeptr = true;
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index d3eddff4b9a..d0b0331430d 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -366,7 +366,7 @@ static void bpy_prop_boolean_set_cb(struct PointerRNA *ptr, struct PropertyRNA *
Py_DECREF(ret);
}
-
+
if (use_gil)
PyGILState_Release(gilstate);
@@ -1329,7 +1329,7 @@ static int icon_id_from_name(const char *name)
}
}
}
-
+
return 0;
}
@@ -1631,7 +1631,7 @@ static void bpy_prop_callback_assign_boolean(struct PropertyRNA *prop, PyObject
{
BooleanPropertyGetFunc rna_get_cb = NULL;
BooleanPropertySetFunc rna_set_cb = NULL;
-
+
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1653,7 +1653,7 @@ static void bpy_prop_callback_assign_boolean_array(struct PropertyRNA *prop, PyO
{
BooleanArrayPropertyGetFunc rna_get_cb = NULL;
BooleanArrayPropertySetFunc rna_set_cb = NULL;
-
+
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1675,7 +1675,7 @@ static void bpy_prop_callback_assign_int(struct PropertyRNA *prop, PyObject *get
{
IntPropertyGetFunc rna_get_cb = NULL;
IntPropertySetFunc rna_set_cb = NULL;
-
+
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1697,7 +1697,7 @@ static void bpy_prop_callback_assign_int_array(struct PropertyRNA *prop, PyObjec
{
IntArrayPropertyGetFunc rna_get_cb = NULL;
IntArrayPropertySetFunc rna_set_cb = NULL;
-
+
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1719,7 +1719,7 @@ static void bpy_prop_callback_assign_float(struct PropertyRNA *prop, PyObject *g
{
FloatPropertyGetFunc rna_get_cb = NULL;
FloatPropertySetFunc rna_set_cb = NULL;
-
+
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1741,7 +1741,7 @@ static void bpy_prop_callback_assign_float_array(struct PropertyRNA *prop, PyObj
{
FloatArrayPropertyGetFunc rna_get_cb = NULL;
FloatArrayPropertySetFunc rna_set_cb = NULL;
-
+
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1764,7 +1764,7 @@ static void bpy_prop_callback_assign_string(struct PropertyRNA *prop, PyObject *
StringPropertyGetFunc rna_get_cb = NULL;
StringPropertyLengthFunc rna_length_cb = NULL;
StringPropertySetFunc rna_set_cb = NULL;
-
+
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1788,7 +1788,7 @@ static void bpy_prop_callback_assign_enum(struct PropertyRNA *prop, PyObject *ge
EnumPropertyGetFunc rna_get_cb = NULL;
EnumPropertyItemFunc rna_itemf_cb = NULL;
EnumPropertySetFunc rna_set_cb = NULL;
-
+
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1815,7 +1815,7 @@ static void bpy_prop_callback_assign_enum(struct PropertyRNA *prop, PyObject *ge
RNA_def_property_enum_funcs_runtime(prop, rna_get_cb, rna_set_cb, rna_itemf_cb);
}
-/* this define runs at the start of each function and deals with
+/* this define runs at the start of each function and deals with
* returning a deferred property (to be registered later) */
#define BPY_PROPDEF_HEAD(_func) \
if (PyTuple_GET_SIZE(args) == 1) { \
@@ -2166,7 +2166,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
bpy_prop_callback_assign_boolean_array(prop, get_cb, set_cb);
RNA_def_property_duplicate_pointers(srna, prop);
}
-
+
Py_RETURN_NONE;
}
@@ -2801,7 +2801,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
StructRNA *srna;
BPY_PROPDEF_HEAD(EnumProperty);
-
+
if (srna) {
const char *id = NULL, *name = NULL, *description = "";
PyObject *def = NULL;
@@ -3195,7 +3195,7 @@ PyObject *BPY_rna_props(void)
{
PyObject *submodule;
PyObject *submodule_dict;
-
+
submodule = PyModule_Create(&props_module);
PyDict_SetItemString(PyImport_GetModuleDict(), props_module.m_name, submodule);
@@ -3203,7 +3203,7 @@ PyObject *BPY_rna_props(void)
* module with a new ref like PyDict_New, since they are passed to
* PyModule_AddObject which steals a ref */
Py_INCREF(submodule);
-
+
/* api needs the PyObjects internally */
submodule_dict = PyModule_GetDict(submodule);
@@ -3220,6 +3220,6 @@ PyObject *BPY_rna_props(void)
ASSIGN_STATIC(PointerProperty);
ASSIGN_STATIC(CollectionProperty);
ASSIGN_STATIC(RemoveProperty);
-
+
return submodule;
}
diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c
index 3bbeaea2674..7903f92265b 100644
--- a/source/blender/python/intern/bpy_rna_anim.c
+++ b/source/blender/python/intern/bpy_rna_anim.c
@@ -40,11 +40,12 @@
#include "ED_keyframing.h"
#include "ED_keyframes_edit.h"
-#include "BKE_report.h"
-#include "BKE_context.h"
#include "BKE_animsys.h"
+#include "BKE_context.h"
#include "BKE_fcurve.h"
+#include "BKE_global.h"
#include "BKE_idcode.h"
+#include "BKE_report.h"
#include "RNA_access.h"
#include "RNA_enum_types.h"
@@ -234,13 +235,13 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
struct Depsgraph *depsgraph = CTX_data_depsgraph(BPy_GetContext());
ReportList reports;
short result = 0;
-
+
PointerRNA ptr = self->ptr;
PropertyRNA *prop = NULL;
const char *prop_name;
-
+
BKE_reports_init(&reports, RPT_STORE);
-
+
/* Retrieve the property identifier from the full path, since we can't get it any other way */
prop_name = strrchr(path_full, '.');
if ((prop_name >= path_full) &&
@@ -248,21 +249,21 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
{
prop = RNA_struct_find_property(&ptr, prop_name + 1);
}
-
+
if (prop) {
NlaStrip *strip = (NlaStrip *)ptr.data;
FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), index);
-
+
result = insert_keyframe_direct(depsgraph, &reports, ptr, prop, fcu, cfra, keytype, options);
}
else {
BKE_reportf(&reports, RPT_ERROR, "Could not resolve path (%s)", path_full);
}
MEM_freeN((void *)path_full);
-
+
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
return NULL;
-
+
return PyBool_FromLong(result);
}
else {
@@ -272,7 +273,7 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
BKE_reports_init(&reports, RPT_STORE);
- result = insert_keyframe(depsgraph, &reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, keytype, options);
+ result = insert_keyframe(G.main, depsgraph, &reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, keytype, options);
MEM_freeN((void *)path_full);
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
@@ -322,13 +323,13 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
*/
ReportList reports;
short result = 0;
-
+
PointerRNA ptr = self->ptr;
PropertyRNA *prop = NULL;
const char *prop_name;
-
+
BKE_reports_init(&reports, RPT_STORE);
-
+
/* Retrieve the property identifier from the full path, since we can't get it any other way */
prop_name = strrchr(path_full, '.');
if ((prop_name >= path_full) &&
@@ -336,14 +337,14 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
{
prop = RNA_struct_find_property(&ptr, prop_name + 1);
}
-
+
if (prop) {
ID *id = ptr.id.data;
NlaStrip *strip = (NlaStrip *)ptr.data;
FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), index);
-
+
BLI_assert(fcu != NULL); /* NOTE: This should be true, or else we wouldn't be able to get here */
-
+
if (BKE_fcurve_is_protected(fcu)) {
BKE_reportf(&reports, RPT_WARNING,
"Not deleting keyframe for locked F-Curve for NLA Strip influence on %s - %s '%s'",
@@ -356,7 +357,7 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
*/
bool found = false;
int i;
-
+
/* try to find index of beztriple to get rid of */
i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found);
if (found) {
@@ -370,10 +371,10 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
BKE_reportf(&reports, RPT_ERROR, "Could not resolve path (%s)", path_full);
}
MEM_freeN((void *)path_full);
-
+
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
return NULL;
-
+
return PyBool_FromLong(result);
}
else {
@@ -425,7 +426,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
BKE_reports_init(&reports, RPT_STORE);
- result = ANIM_add_driver(&reports, (ID *)self->ptr.id.data, path_full, index,
+ result = ANIM_add_driver(&reports, (ID *)self->ptr.id.data, path_full, index,
CREATEDRIVER_WITH_FMODIFIER, DRIVER_TYPE_PYTHON);
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
@@ -451,7 +452,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr);
ret = pyrna_struct_CreatePyObject(&tptr);
}
-
+
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
}
else {
@@ -504,7 +505,7 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
return NULL;
-
+
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
return PyBool_FromLong(result);
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c
index ed9d1e9c0e5..571ee0edea2 100644
--- a/source/blender/python/intern/bpy_rna_array.c
+++ b/source/blender/python/intern/bpy_rna_array.c
@@ -277,10 +277,10 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA
* dimsize[1] = 4
* dimsize[2] = 5
* lvalue_dim = 0, totdim = 3
- *
+ *
* arr[2][3] = x
* lvalue_dim = 1
- *
+ *
* arr[2][3][4] = x
* lvalue_dim = 2 */
for (i = lvalue_dim; i < totdim; i++)
@@ -805,7 +805,7 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr,
*
* x = arr[2]
* index = 0 + 2 * 4 * 5
- *
+ *
* x = arr[2][3]
* index = offset + 3 * 5 */
diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c
index 6b8684c7acd..45d556d68e9 100644
--- a/source/blender/python/intern/bpy_rna_callback.c
+++ b/source/blender/python/intern/bpy_rna_callback.c
@@ -93,7 +93,7 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args)
if (!PyArg_ParseTuple(args, "OO!|s:bpy_struct.callback_add", &cb_func, &PyTuple_Type, &cb_args, &cb_event_str))
return NULL;
-
+
if (!PyCallable_Check(cb_func)) {
PyErr_SetString(PyExc_TypeError, "callback_add(): first argument isn't callable");
return NULL;
diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c
index 06f3143ec46..e77470c070e 100644
--- a/source/blender/python/intern/gpu.c
+++ b/source/blender/python/intern/gpu.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/python/intern/gpu_offscreen.c b/source/blender/python/intern/gpu_offscreen.c
index a8ec828c13f..a65469ea739 100644
--- a/source/blender/python/intern/gpu_offscreen.c
+++ b/source/blender/python/intern/gpu_offscreen.c
@@ -35,6 +35,8 @@
#include "WM_types.h"
+#include "BKE_global.h"
+
#include "ED_screen.h"
#include "GPU_framebuffer.h"
diff --git a/source/blender/python/intern/stubs.c b/source/blender/python/intern/stubs.c
index 3b3a4d6d2fe..53adb8f2165 100644
--- a/source/blender/python/intern/stubs.c
+++ b/source/blender/python/intern/stubs.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/python/mathutils/CMakeLists.txt b/source/blender/python/mathutils/CMakeLists.txt
index f70f893aeac..adf7c85d7c9 100644
--- a/source/blender/python/mathutils/CMakeLists.txt
+++ b/source/blender/python/mathutils/CMakeLists.txt
@@ -18,7 +18,7 @@
#
# ***** END GPL LICENSE BLOCK *****
-set(INC
+set(INC
.
../../blenlib
../../blenkernel
diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h
index d2fbe6a04d5..f7c8d7eebeb 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.h
+++ b/source/blender/python/mathutils/mathutils_Matrix.h
@@ -1,4 +1,4 @@
-/*
+/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
diff --git a/source/blender/python/mathutils/mathutils_interpolate.c b/source/blender/python/mathutils/mathutils_interpolate.c
index c8cb71874db..720fac7c276 100644
--- a/source/blender/python/mathutils/mathutils_interpolate.c
+++ b/source/blender/python/mathutils/mathutils_interpolate.c
@@ -60,10 +60,10 @@ static PyObject *M_Interpolate_poly_3d_calc(PyObject *UNUSED(self), PyObject *ar
float fp[3];
float (*vecs)[3];
Py_ssize_t len;
-
+
PyObject *point, *veclist, *ret;
int i;
-
+
if (!PyArg_ParseTuple(
args, "OO!:poly_3d_calc",
&veclist,
@@ -71,27 +71,27 @@ static PyObject *M_Interpolate_poly_3d_calc(PyObject *UNUSED(self), PyObject *ar
{
return NULL;
}
-
+
if (BaseMath_ReadCallback((VectorObject *)point) == -1)
return NULL;
-
+
fp[0] = ((VectorObject *)point)->vec[0];
fp[1] = ((VectorObject *)point)->vec[1];
if (((VectorObject *)point)->size > 2)
fp[2] = ((VectorObject *)point)->vec[2];
else
fp[2] = 0.0f; /* if its a 2d vector then set the z to be zero */
-
+
len = mathutils_array_parse_alloc_v(((float **)&vecs), 3, veclist, __func__);
if (len == -1) {
return NULL;
}
-
+
if (len) {
float *weights = MEM_mallocN(sizeof(float) * len, __func__);
-
+
interp_weights_poly_v3(weights, vecs, len, fp);
-
+
ret = PyList_New(len);
for (i = 0; i < len; i++) {
PyList_SET_ITEM(ret, i, PyFloat_FromDouble(weights[i]));
diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c
index 1fb6d306f96..839d1ffc588 100644
--- a/source/blender/python/mathutils/mathutils_noise.c
+++ b/source/blender/python/mathutils/mathutils_noise.c
@@ -61,11 +61,11 @@
* This is a faster version by taking Shawn Cokus's optimization,
* Matthe Bellew's simplification, Isaku Wada's real version.
*
- * Before using, initialize the state by using init_genrand(seed)
+ * Before using, initialize the state by using init_genrand(seed)
* or init_by_array(init_key, key_length).
*
* Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
- * All rights reserved.
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -78,8 +78,8 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * 3. The names of its contributors may not be used to endorse or promote
- * products derived from this software without specific prior written
+ * 3. The names of its contributors may not be used to endorse or promote
+ * products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
@@ -671,7 +671,7 @@ static PyObject *M_Noise_hybrid_multi_fractal(PyObject *UNUSED(self), PyObject *
if (mathutils_array_parse(vec, 3, 3, value, "hybrid_multi_fractal: invalid 'position' arg") == -1)
return NULL;
-
+
return PyFloat_FromDouble(mg_HybridMultiFractal(vec[0], vec[1], vec[2], H, lac, oct, ofs, gn, nb));
}
diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt
index 0f0060c7578..d3fef51e9e9 100644
--- a/source/blender/render/CMakeLists.txt
+++ b/source/blender/render/CMakeLists.txt
@@ -24,7 +24,7 @@
# ***** END GPL LICENSE BLOCK *****
-set(INC
+set(INC
extern/include
intern/include
../blenkernel
@@ -44,7 +44,7 @@ set(INC
)
set(INC_SYS
-
+ ${GLEW_INCLUDE_PATH}
)
set(SRC
diff --git a/source/blender/render/extern/include/RE_bake.h b/source/blender/render/extern/include/RE_bake.h
index 542af91c4bf..e7f446f07a7 100644
--- a/source/blender/render/extern/include/RE_bake.h
+++ b/source/blender/render/extern/include/RE_bake.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/render/extern/include/RE_engine.h b/source/blender/render/extern/include/RE_engine.h
index 59a754fcde4..2de355b92a5 100644
--- a/source/blender/render/extern/include/RE_engine.h
+++ b/source/blender/render/extern/include/RE_engine.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -93,14 +93,14 @@ typedef struct RenderEngineType {
int flag;
void (*update)(struct RenderEngine *engine, struct Main *bmain, struct Depsgraph *depsgraph);
- void (*render_to_image)(struct RenderEngine *engine, struct Depsgraph *depsgraph);
+ void (*render)(struct RenderEngine *engine, struct Depsgraph *depsgraph);
void (*bake)(struct RenderEngine *engine, struct Depsgraph *depsgraph,
struct Object *object, const int pass_type,
const int pass_filter, const int object_id, const struct BakePixel *pixel_array, const int num_pixels,
const int depth, void *result);
void (*view_update)(struct RenderEngine *engine, const struct bContext *context);
- void (*render_to_view)(struct RenderEngine *engine, const struct bContext *context);
+ void (*view_draw)(struct RenderEngine *engine, const struct bContext *context);
void (*update_script_node)(struct RenderEngine *engine, struct bNodeTree *ntree, struct bNode *node);
void (*update_render_passes)(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer);
diff --git a/source/blender/render/extern/include/RE_multires_bake.h b/source/blender/render/extern/include/RE_multires_bake.h
index 901c1c1d05d..25a87969b58 100644
--- a/source/blender/render/extern/include/RE_multires_bake.h
+++ b/source/blender/render/extern/include/RE_multires_bake.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h
index 056e236f60e..55638471883 100644
--- a/source/blender/render/extern/include/RE_pipeline.h
+++ b/source/blender/render/extern/include/RE_pipeline.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -103,11 +103,11 @@ typedef struct RenderPass {
/* after render, the Combined pass is in combined, for renderlayers read from files it is a real pass */
typedef struct RenderLayer {
struct RenderLayer *next, *prev;
-
+
/* copy of RenderData */
char name[RE_MAXNAME];
int layflag, passflag, pass_xor;
-
+
/* MULTIVIEW_TODO: acolrect and scolrect are not supported by multiview at the moment.
* If they are really required they should be in RenderView instead */
@@ -121,16 +121,16 @@ typedef struct RenderLayer {
void *exrhandle;
ListBase passes;
-
+
} RenderLayer;
typedef struct RenderResult {
struct RenderResult *next, *prev;
-
+
/* target image size */
int rectx, recty;
short crop, sample_nr;
-
+
/* the following rect32, rectf and rectz buffers are for temporary storage only, for RenderResult structs
* created in #RE_AcquireResultImage - which do not have RenderView */
@@ -140,25 +140,25 @@ typedef struct RenderResult {
float *rectf;
/* if this exists, a copy of one of layers, or result of composited layers */
float *rectz;
-
+
/* coordinates within final image (after cropping) */
rcti tilerect;
/* offset to apply to get a border render in full image */
int xof, yof;
-
+
/* the main buffers */
ListBase layers;
-
+
/* multiView maps to a StringVector in OpenEXR */
ListBase views; /* RenderView */
/* allowing live updates: */
volatile rcti renrect;
volatile RenderLayer *renlay;
-
+
/* optional saved endresult on disk */
int do_exr_tile;
-
+
/* for render results in Image, verify validity for sequences */
int framenr;
@@ -311,6 +311,11 @@ void RE_draw_lock_cb (struct Render *re, void *handle, void (*f)(void *handle,
void RE_test_break_cb (struct Render *re, void *handle, int (*f)(void *handle));
void RE_current_scene_update_cb(struct Render *re, void *handle, void (*f)(void *handle, struct Scene *scene));
+void RE_gl_context_create(Render *re);
+void RE_gl_context_destroy(Render *re);
+void *RE_gl_context_get(Render *re);
+void *RE_gwn_context_get(Render *re);
+
/* should move to kernel once... still unsure on how/where */
float RE_filter_value(int type, float x);
diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h
index 3b4b9262465..22a202ee675 100644
--- a/source/blender/render/extern/include/RE_render_ext.h
+++ b/source/blender/render/extern/include/RE_render_ext.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h
index 0d354c27e3a..52d4961352d 100644
--- a/source/blender/render/extern/include/RE_shader_ext.h
+++ b/source/blender/render/extern/include/RE_shader_ext.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/render/intern/include/initrender.h b/source/blender/render/intern/include/initrender.h
index e7ff3c7097c..b8732e7cc5c 100644
--- a/source/blender/render/intern/include/initrender.h
+++ b/source/blender/render/intern/include/initrender.h
@@ -31,7 +31,7 @@
#ifndef __INITRENDER_H__
-#define __INITRENDER_H__
+#define __INITRENDER_H__
/* Functions */
diff --git a/source/blender/render/intern/include/render_result.h b/source/blender/render/intern/include/render_result.h
index 9a1b1b5abe8..eebecc53101 100644
--- a/source/blender/render/intern/include/render_result.h
+++ b/source/blender/render/intern/include/render_result.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h
index 8308b5e76e4..34535fba1e0 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/include/render_types.h
@@ -52,10 +52,10 @@ struct Main;
/* this is handed over to threaded hiding/passes/shading engine */
typedef struct RenderPart {
struct RenderPart *next, *prev;
-
+
RenderResult *result; /* result of part rendering */
ListBase fullresult; /* optional full sample buffers */
-
+
rcti disprect; /* part coordinates within total picture */
int rectx, recty; /* the size */
int nr; /* nr is partnr */
@@ -74,10 +74,10 @@ struct Render {
struct Render *next, *prev;
char name[RE_MAXNAME];
int slot;
-
+
/* state settings */
short flag, ok, result_ok;
-
+
/* result of rendering */
RenderResult *result;
/* if render with single-layer option, other rendered layers are stored here */
@@ -88,29 +88,29 @@ struct Render {
* write lock, all external code must use a read lock. internal code is assumed
* to not conflict with writes, so no lock used for that */
ThreadRWMutex resultmutex;
-
+
/* window size, display rect, viewplane */
int winx, winy; /* buffer width and height with percentage applied
* without border & crop. convert to long before multiplying together to avoid overflow. */
rcti disprect; /* part within winx winy */
rctf viewplane; /* mapped on winx winy */
-
+
/* final picture width and height (within disprect) */
int rectx, recty;
-
- /* real maximum size of parts after correction for minimum
+
+ /* real maximum size of parts after correction for minimum
* partx*xparts can be larger than rectx, in that case last part is smaller */
int partx, party;
-
+
/* Camera transform, only used by Freestyle. */
float viewmat[4][4], viewinv[4][4];
float viewmat_orig[4][4]; /* for incremental render */
float winmat[4][4];
-
+
/* clippping */
float clipsta;
float clipend;
-
+
/* main, scene, and its full copy of renderdata and world */
struct Main *main;
Scene *scene;
@@ -119,13 +119,13 @@ struct Render {
int active_view_layer;
struct Object *camera_override;
unsigned int lay, layer_override;
-
+
ThreadRWMutex partsmutex;
ListBase parts;
-
+
/* render engine */
struct RenderEngine *engine;
-
+
#ifdef WITH_FREESTYLE
struct Main *freestyle_bmain;
ListBase freestyle_renders;
@@ -140,23 +140,27 @@ struct Render {
void *duh;
void (*current_scene_update)(void *handle, struct Scene *scene);
void *suh;
-
+
void (*stats_draw)(void *handle, RenderStats *ri);
void *sdh;
void (*progress)(void *handle, float i);
void *prh;
-
+
void (*draw_lock)(void *handle, int i);
void *dlh;
int (*test_break)(void *handle);
void *tbh;
-
+
RenderStats i;
struct ReportList *reports;
void **movie_ctx_arr;
char viewname[MAX_NAME];
+
+ /* TODO replace by a whole draw manager. */
+ void *gl_context;
+ void *gwn_context;
};
/* **************** defines ********************* */
diff --git a/source/blender/render/intern/include/renderpipeline.h b/source/blender/render/intern/include/renderpipeline.h
index 68fbc01b914..7a409d2dc1c 100644
--- a/source/blender/render/intern/include/renderpipeline.h
+++ b/source/blender/render/intern/include/renderpipeline.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/render/intern/include/zbuf.h b/source/blender/render/intern/include/zbuf.h
index 1a93fc6c3b2..0654a4f8df6 100644
--- a/source/blender/render/intern/include/zbuf.h
+++ b/source/blender/render/intern/include/zbuf.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -36,7 +36,7 @@
/* span fill in method, is also used to localize data for zbuffering */
typedef struct ZSpan {
int rectx, recty; /* range for clipping */
-
+
int miny1, maxy1, miny2, maxy2; /* actual filled in range */
const float *minp1, *maxp1, *minp2, *maxp2; /* vertex pointers detect min/max range in */
float *span1, *span2;
diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c
index 7655645f1e7..6e4336f80ea 100644
--- a/source/blender/render/intern/source/external_engine.c
+++ b/source/blender/render/intern/source/external_engine.c
@@ -112,17 +112,17 @@ void RE_engines_register(RenderEngineType *render_type)
RenderEngineType *RE_engines_find(const char *idname)
{
RenderEngineType *type;
-
+
type = BLI_findstring(&R_engines, idname, offsetof(RenderEngineType, idname));
if (!type)
type = BLI_findstring(&R_engines, "BLENDER_EEVEE", offsetof(RenderEngineType, idname));
-
+
return type;
}
bool RE_engine_is_external(Render *re)
{
- return (re->engine && re->engine->type && re->engine->type->render_to_image);
+ return (re->engine && re->engine->type && re->engine->type->render);
}
bool RE_engine_is_opengl(RenderEngineType *render_type)
@@ -320,7 +320,7 @@ int RE_engine_test_break(RenderEngine *engine)
if (re)
return re->test_break(re->tbh);
-
+
return 0;
}
@@ -497,7 +497,7 @@ static void engine_depsgraph_init(RenderEngine *engine, ViewLayer *view_layer)
engine->depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER);
DEG_debug_name_set(engine->depsgraph, "RENDER");
- BKE_scene_graph_update_tagged(engine->depsgraph, bmain);
+ BKE_scene_graph_update_for_newframe(engine->depsgraph, bmain);
}
static void engine_depsgraph_free(RenderEngine *engine)
@@ -513,6 +513,10 @@ void RE_engine_frame_set(RenderEngine *engine, int frame, float subframe)
return;
}
+#ifdef WITH_PYTHON
+ BPy_BEGIN_ALLOW_THREADS;
+#endif
+
Render *re = engine->re;
double cfra = (double)frame + (double)subframe;
@@ -520,15 +524,11 @@ void RE_engine_frame_set(RenderEngine *engine, int frame, float subframe)
BKE_scene_frame_set(re->scene, cfra);
BKE_scene_graph_update_for_newframe(engine->depsgraph, re->main);
-#ifdef WITH_PYTHON
- BPy_BEGIN_ALLOW_THREADS;
-#endif
+ BKE_scene_camera_switch_update(re->scene);
#ifdef WITH_PYTHON
BPy_END_ALLOW_THREADS;
#endif
-
- BKE_scene_camera_switch_update(re->scene);
}
/* Bake */
@@ -632,7 +632,7 @@ int RE_engine_render(Render *re, int do_all)
bool persistent_data = (re->r.mode & R_PERSISTENT_DATA) != 0;
/* verify if we can render */
- if (!type->render_to_image)
+ if (!type->render)
return 0;
if ((re->r.scemode & R_BUTS_PREVIEW) && !(type->flag & RE_USE_PREVIEW))
return 0;
@@ -719,7 +719,7 @@ int RE_engine_render(Render *re, int do_all)
re->draw_lock(re->dlh, 0);
}
- if (type->render_to_image) {
+ if (type->render) {
FOREACH_VIEW_LAYER_TO_RENDER_BEGIN(re, view_layer_iter)
{
if (re->draw_lock) {
@@ -737,7 +737,7 @@ int RE_engine_render(Render *re, int do_all)
re->draw_lock(re->dlh, 0);
}
- type->render_to_image(engine, engine->depsgraph);
+ type->render(engine, engine->depsgraph);
engine_depsgraph_free(engine);
}
@@ -776,7 +776,7 @@ int RE_engine_render(Render *re, int do_all)
if (BKE_reports_contain(re->reports, RPT_ERROR))
G.is_break = true;
-
+
#ifdef WITH_FREESTYLE
if (re->r.mode & R_EDGE_FRS)
RE_RenderFreestyleExternal(re);
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
index db28a5db531..1e9ad79e599 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/source/imagetexture.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -32,7 +32,7 @@
#include <fcntl.h>
#include <math.h>
#include <float.h>
-#ifndef WIN32
+#ifndef WIN32
#include <unistd.h>
#else
#include <io.h>
@@ -67,7 +67,7 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max
static void ibuf_get_color(float col[4], struct ImBuf *ibuf, int x, int y)
{
int ofs = y * ibuf->x + x;
-
+
if (ibuf->rect_float) {
if (ibuf->channels==4) {
const float *fp= ibuf->rect_float + 4*ofs;
@@ -105,15 +105,15 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
int xi, yi; /* original values */
texres->tin= texres->ta= texres->tr= texres->tg= texres->tb= 0.0f;
-
+
/* we need to set retval OK, otherwise texture code generates normals itself... */
retval= texres->nor ? 3 : 1;
-
+
/* quick tests */
if (ibuf==NULL && ima==NULL)
return retval;
if (ima) {
-
+
/* hack for icon render */
if (skip_load_image && !BKE_image_has_loaded_ibuf(ima))
return retval;
@@ -127,7 +127,7 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
BKE_image_pool_release_ibuf(ima, ibuf, pool);
return retval;
}
-
+
/* setup mapping */
if (tex->imaflag & TEX_IMAROT) {
fy= texvec[0];
@@ -137,10 +137,10 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
fx= texvec[0];
fy= texvec[1];
}
-
+
if (tex->extend == TEX_CHECKER) {
int xs, ys;
-
+
xs= (int)floor(fx);
ys= (int)floor(fy);
fx-= xs;
@@ -205,7 +205,7 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
if (y<0) y+= ibuf->y;
}
}
-
+
/* keep this before interpolation [#29761] */
if (ima) {
if ((tex->imaflag & TEX_USEALPHA) && (ima->flag & IMA_IGNORE_ALPHA) == 0) {
@@ -232,7 +232,7 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
else { /* no filtering */
ibuf_get_color(&texres->tr, ibuf, x, y);
}
-
+
if (texres->nor) {
if (tex->imaflag & TEX_NORMALMAP) {
/* qdn: normal from color
@@ -283,7 +283,7 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
else {
texres->ta = texres->tin = 1.0;
}
-
+
if (tex->flag & TEX_NEGALPHA) {
texres->ta = 1.0f - texres->ta;
}
@@ -301,7 +301,7 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
BKE_image_pool_release_ibuf(ima, ibuf, pool);
BRICONTRGB;
-
+
return retval;
}
@@ -327,9 +327,9 @@ static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
newrct->xmin = rf->xmin+(x2-x1);
newrct->ymin = rf->ymin;
newrct->ymax = rf->ymax;
-
+
if (newrct->xmin ==newrct->xmax) (*count)--;
-
+
rf->xmin = x1;
}
}
@@ -489,7 +489,7 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres)
else {
div= texres->tr= texres->tg= texres->tb= texres->ta= 0.0;
for (y=starty; y<=endy; y++) {
-
+
muly= 1.0;
if (starty==endy) {
@@ -499,10 +499,10 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres)
if (y==starty) muly= 1.0f-(rf->ymin - y);
if (y==endy) muly= (rf->ymax - y);
}
-
+
if (startx==endx) {
mulx= muly;
-
+
ibuf_get_color(col, ibuf, startx, y);
texres->ta+= mulx*col[3];
@@ -518,7 +518,7 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres)
if (x==endx) mulx*= (rf->xmax - x);
ibuf_get_color(col, ibuf, x, y);
-
+
if (mulx==1.0f) {
texres->ta+= col[3];
texres->tr+= col[0];
@@ -573,7 +573,7 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max
rf->ymax = maxy*(ibuf->y);
texr.talpha= texres->talpha; /* is read by boxsample_clip */
-
+
if (imapextend) {
CLAMP(rf->xmin, 0.0f, ibuf->x-1);
CLAMP(rf->xmax, 0.0f, ibuf->x-1);
@@ -608,7 +608,7 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max
tot= texres->tr= texres->tb= texres->tg= texres->ta= 0.0;
while (count--) {
boxsampleclip(ibuf, rf, &texr);
-
+
opp= square_rctf(rf);
tot+= opp;
@@ -629,7 +629,7 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max
boxsampleclip(ibuf, rf, texres);
if (texres->talpha==0) texres->ta= 1.0;
-
+
if (alphaclip!=1.0f) {
/* premul it all */
texres->tr*= alphaclip;
@@ -637,7 +637,7 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max
texres->tb*= alphaclip;
texres->ta*= alphaclip;
}
-}
+}
/*-----------------------------------------------------------------------------------------------------------------
* from here, some functions only used for the new filtering */
@@ -874,7 +874,7 @@ static void image_mipmap_test(Tex *tex, ImBuf *ibuf)
{
if (tex->imaflag & TEX_MIPMAP) {
if ((ibuf->flags & IB_fields) == 0) {
-
+
if (ibuf->mipmap[0] && (ibuf->userflags & IB_MIPMAP_INVALID)) {
BLI_thread_lock(LOCK_IMAGE);
if (ibuf->userflags & IB_MIPMAP_INVALID) {
@@ -885,7 +885,7 @@ static void image_mipmap_test(Tex *tex, ImBuf *ibuf)
}
if (ibuf->mipmap[0] == NULL) {
BLI_thread_lock(LOCK_IMAGE);
- if (ibuf->mipmap[0] == NULL)
+ if (ibuf->mipmap[0] == NULL)
IMB_makemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP);
BLI_thread_unlock(LOCK_IMAGE);
}
@@ -895,7 +895,7 @@ static void image_mipmap_test(Tex *tex, ImBuf *ibuf)
}
}
}
-
+
}
static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], float dxt[2], float dyt[2], TexResult *texres, struct ImagePool *pool, const bool skip_load_image)
@@ -946,7 +946,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
/* mipmap test */
image_mipmap_test(tex, ibuf);
-
+
if (ima) {
if ((tex->imaflag & TEX_USEALPHA) && (ima->flag & IMA_IGNORE_ALPHA) == 0) {
if ((tex->imaflag & TEX_CALCALPHA) == 0) {
@@ -1281,7 +1281,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
else
texres->tin = texres->ta;
if (tex->flag & TEX_NEGALPHA) texres->ta = 1.f - texres->ta;
-
+
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { /* normal from color */
/* The invert of the red channel is to make
* the normal map compliant with the outside world.
@@ -1312,7 +1312,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
BKE_image_pool_release_ibuf(ima, ibuf, pool);
BRICONTRGB;
-
+
return retval;
}
@@ -1334,10 +1334,10 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
return imagewraposa_aniso(tex, ima, ibuf, texvec, dxt, dyt, texres, pool, skip_load_image);
texres->tin= texres->ta= texres->tr= texres->tg= texres->tb= 0.0f;
-
+
/* we need to set retval OK, otherwise texture code generates normals itself... */
retval = texres->nor ? 3 : 1;
-
+
/* quick tests */
if (ibuf==NULL && ima==NULL)
return retval;
@@ -1346,7 +1346,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
/* hack for icon render */
if (skip_load_image && !BKE_image_has_loaded_ibuf(ima))
return retval;
-
+
ibuf = BKE_image_pool_acquire_ibuf(ima, &tex->iuser, pool);
ima->flag|= IMA_USED_FOR_RENDER;
@@ -1356,7 +1356,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
BKE_image_pool_release_ibuf(ima, ibuf, pool);
return retval;
}
-
+
/* mipmap test */
image_mipmap_test(tex, ibuf);
@@ -1367,9 +1367,9 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
}
}
}
-
+
texr.talpha= texres->talpha;
-
+
if (tex->imaflag & TEX_IMAROT) {
fy= texvec[0];
fx= texvec[1];
@@ -1378,7 +1378,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
fx= texvec[0];
fy= texvec[1];
}
-
+
/* pixel coordinates */
minx = min_fff(dxt[0], dyt[0], dxt[0] + dyt[0]);
@@ -1389,7 +1389,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
/* tex_sharper has been removed */
minx= (maxx-minx)/2.0f;
miny= (maxy-miny)/2.0f;
-
+
if (tex->imaflag & TEX_FILTER_MIN) {
/* make sure the filtersize is minimal in pixels (normal, ref map can have miniature pixel dx/dy) */
float addval= (0.5f * tex->filtersize) / (float) MIN2(ibuf->x, ibuf->y);
@@ -1402,7 +1402,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
else if (tex->filtersize!=1.0f) {
minx*= tex->filtersize;
miny*= tex->filtersize;
-
+
dxt[0]*= tex->filtersize;
dxt[1]*= tex->filtersize;
dyt[0]*= tex->filtersize;
@@ -1410,13 +1410,13 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
}
if (tex->imaflag & TEX_IMAROT) SWAP(float, minx, miny);
-
+
if (minx>0.25f) minx= 0.25f;
else if (minx<0.00001f) minx= 0.00001f; /* side faces of unit-cube */
if (miny>0.25f) miny= 0.25f;
else if (miny<0.00001f) miny= 0.00001f;
-
+
/* repeat and clip */
imaprepeat= (tex->extend==TEX_REPEAT);
imapextend= (tex->extend==TEX_EXTEND);
@@ -1430,10 +1430,10 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
if (tex->extend == TEX_CHECKER) {
int xs, ys, xs1, ys1, xs2, ys2, boundary;
-
+
xs= (int)floor(fx);
ys= (int)floor(fy);
-
+
/* both checkers available, no boundary exceptions, checkerdist will eat aliasing */
if ( (tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN) ) {
fx-= xs;
@@ -1447,7 +1447,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
return retval;
}
else {
-
+
xs1= (int)floor(fx-minx);
ys1= (int)floor(fy-miny);
xs2= (int)floor(fx+minx);
@@ -1479,14 +1479,14 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
if (tex->flag & TEX_CHECKER_ODD) {
if ((xs1+ys) & 1) fx-= xs2;
else fx-= xs1;
-
+
if ((ys1+xs) & 1) fy-= ys2;
else fy-= ys1;
}
if (tex->flag & TEX_CHECKER_EVEN) {
if ((xs1+ys) & 1) fx-= xs1;
else fx-= xs2;
-
+
if ((ys1+xs) & 1) fy-= ys1;
else fy-= ys2;
}
@@ -1525,7 +1525,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
if (fx>1.0f) fx -= (int)(fx);
else if (fx<0.0f) fx+= 1-(int)(fx);
}
-
+
if (imapextend) {
if (fy>1.0f) fy = 1.0f;
else if (fy<0.0f) fy= 0.0f;
@@ -1540,18 +1540,18 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
if (tex->imaflag & TEX_MIPMAP) {
ImBuf *previbuf, *curibuf;
float bumpscale;
-
+
dx = minx;
dy = miny;
maxd = max_ff(dx, dy);
if (maxd > 0.5f) maxd = 0.5f;
pixsize = 1.0f / (float) MIN2(ibuf->x, ibuf->y);
-
+
bumpscale= pixsize/maxd;
if (bumpscale>1.0f) bumpscale= 1.0f;
else bumpscale*=bumpscale;
-
+
curmap= 0;
previbuf= curibuf= ibuf;
while (curmap < IMB_MIPMAP_LEVELS && ibuf->mipmap[curmap]) {
@@ -1567,12 +1567,12 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
if (minx < 0.5f / ibuf->x) minx = 0.5f / ibuf->x;
if (miny < 0.5f / ibuf->y) miny = 0.5f / ibuf->y;
}
-
+
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)==0) {
/* a bit extra filter */
//minx*= 1.35f;
//miny*= 1.35f;
-
+
boxsample(curibuf, fx-minx, fy-miny, fx+minx, fy+miny, texres, imaprepeat, imapextend);
val1= texres->tr+texres->tg+texres->tb;
boxsample(curibuf, fx-minx+dxt[0], fy-miny+dxt[1], fx+minx+dxt[0], fy+miny+dxt[1], &texr, imaprepeat, imapextend);
@@ -1583,11 +1583,11 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
/* don't switch x or y! */
texres->nor[0]= (val1-val2);
texres->nor[1]= (val1-val3);
-
+
if (previbuf!=curibuf) { /* interpolate */
-
+
boxsample(previbuf, fx-minx, fy-miny, fx+minx, fy+miny, &texr, imaprepeat, imapextend);
-
+
/* calc rgb */
dx= 2.0f*(pixsize-maxd)/pixsize;
if (dx>=1.0f) {
@@ -1601,16 +1601,16 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
texres->tr= dy*texres->tr+ dx*texr.tr;
texres->ta= dy*texres->ta+ dx*texr.ta;
}
-
+
val1= dy*val1+ dx*(texr.tr + texr.tg + texr.tb);
boxsample(previbuf, fx-minx+dxt[0], fy-miny+dxt[1], fx+minx+dxt[0], fy+miny+dxt[1], &texr, imaprepeat, imapextend);
val2= dy*val2+ dx*(texr.tr + texr.tg + texr.tb);
boxsample(previbuf, fx-minx+dyt[0], fy-miny+dyt[1], fx+minx+dyt[0], fy+miny+dyt[1], &texr, imaprepeat, imapextend);
val3= dy*val3+ dx*(texr.tr + texr.tg + texr.tb);
-
+
texres->nor[0]= (val1-val2); /* vals have been interpolated above! */
texres->nor[1]= (val1-val3);
-
+
if (dx<1.0f) {
dy= 1.0f-dx;
texres->tb= dy*texres->tb+ dx*texr.tb;
@@ -1632,9 +1632,9 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
if (previbuf!=curibuf) { /* interpolate */
boxsample(previbuf, minx, miny, maxx, maxy, &texr, imaprepeat, imapextend);
-
+
fx= 2.0f*(pixsize-maxd)/pixsize;
-
+
if (fx>=1.0f) {
texres->ta= texr.ta; texres->tb= texr.tb;
texres->tg= texr.tg; texres->tr= texr.tr;
@@ -1672,7 +1672,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
else
boxsample(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, texres, imaprepeat, imapextend);
}
-
+
if (tex->imaflag & TEX_CALCALPHA) {
texres->ta = texres->tin = texres->ta * max_fff(texres->tr, texres->tg, texres->tb);
}
@@ -1681,7 +1681,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
}
if (tex->flag & TEX_NEGALPHA) texres->ta= 1.0f-texres->ta;
-
+
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) {
/* qdn: normal from color
* The invert of the red channel is to make
@@ -1705,7 +1705,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
BKE_image_pool_release_ibuf(ima, ibuf, pool);
BRICONTRGB;
-
+
return retval;
}
@@ -1713,16 +1713,16 @@ void image_sample(Image *ima, float fx, float fy, float dx, float dy, float resu
{
TexResult texres;
ImBuf *ibuf = BKE_image_pool_acquire_ibuf(ima, NULL, pool);
-
+
if (UNLIKELY(ibuf == NULL)) {
zero_v4(result);
return;
}
-
+
texres.talpha = true; /* boxsample expects to be initialized */
boxsample(ibuf, fx, fy, fx + dx, fy + dy, &texres, 0, 1);
copy_v4_v4(result, &texres.tr);
-
+
ima->flag|= IMA_USED_FOR_RENDER;
BKE_image_pool_release_ibuf(ima, ibuf, pool);
@@ -1737,11 +1737,11 @@ void ibuf_sample(ImBuf *ibuf, float fx, float fy, float dx, float dy, float resu
AFD.dyt[0] = dy; AFD.dyt[1] = dy;
//copy_v2_v2(AFD.dxt, dx);
//copy_v2_v2(AFD.dyt, dy);
-
+
AFD.intpol = 1;
AFD.extflag = TXC_EXTD;
ewa_eval(&texres, ibuf, fx, fy, &AFD);
-
+
copy_v4_v4(result, &texres.tr);
}
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 4274d641674..9611a8a7452 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -66,9 +66,9 @@ static float filt_quadratic(float x)
static float filt_cubic(float x)
{
float x2 = x * x;
-
+
if (x < 0.0f) x = -x;
-
+
if (x < 1.0f) return 0.5f * x * x2 - x2 + 2.0f / 3.0f;
if (x < 2.0f) return (2.0f - x) * (2.0f - x) * (2.0f - x) / 6.0f;
return 0.0f;
@@ -78,7 +78,7 @@ static float filt_cubic(float x)
static float filt_catrom(float x)
{
float x2 = x * x;
-
+
if (x < 0.0f) x = -x;
if (x < 1.0f) return 1.5f * x2 * x - 2.5f * x2 + 1.0f;
if (x < 2.0f) return -0.5f * x2 * x + 2.5f * x2 - 4.0f * x + 2.0f;
@@ -108,34 +108,34 @@ static float filt_mitchell(float x) /* Mitchell & Netravali's two-param cubic */
float RE_filter_value(int type, float x)
{
float gaussfac = 1.6f;
-
+
x = ABS(x);
-
+
switch (type) {
case R_FILTER_BOX:
if (x > 1.0f) return 0.0f;
return 1.0f;
-
+
case R_FILTER_TENT:
if (x > 1.0f) return 0.0f;
return 1.0f - x;
-
+
case R_FILTER_GAUSS:
{
const float two_gaussfac2 = 2.0f * gaussfac * gaussfac;
x *= 3.0f * gaussfac;
return 1.0f / sqrtf((float)M_PI * two_gaussfac2) * expf(-x*x / two_gaussfac2);
}
-
+
case R_FILTER_MITCH:
return filt_mitchell(x * gaussfac);
-
+
case R_FILTER_QUAD:
return filt_quadratic(x * gaussfac);
-
+
case R_FILTER_CUBIC:
return filt_cubic(x * gaussfac);
-
+
case R_FILTER_CATROM:
return filt_catrom(x * gaussfac);
}
@@ -221,20 +221,20 @@ void RE_parts_init(Render *re)
{
int nr, xd, yd, partx, party, xparts, yparts;
int xminb, xmaxb, yminb, ymaxb;
-
+
RE_parts_free(re);
-
+
/* this is render info for caller, is not reset when parts are freed! */
re->i.totpart = 0;
re->i.curpart = 0;
re->i.partsdone = 0;
-
+
/* just for readable code.. */
xminb = re->disprect.xmin;
yminb = re->disprect.ymin;
xmaxb = re->disprect.xmax;
ymaxb = re->disprect.ymax;
-
+
RE_parts_clamp(re);
partx = re->partx;
@@ -242,17 +242,17 @@ void RE_parts_init(Render *re)
/* part count */
xparts = (re->rectx + partx - 1) / partx;
yparts = (re->recty + party - 1) / party;
-
+
for (nr = 0; nr < xparts * yparts; nr++) {
rcti disprect;
int rectx, recty;
-
+
xd = (nr % xparts);
yd = (nr - xd) / xparts;
-
+
disprect.xmin = xminb + xd * partx;
disprect.ymin = yminb + yd * party;
-
+
/* ensure we cover the entire picture, so last parts go to end */
if (xd < xparts - 1) {
disprect.xmax = disprect.xmin + partx;
@@ -260,21 +260,21 @@ void RE_parts_init(Render *re)
disprect.xmax = xmaxb;
}
else disprect.xmax = xmaxb;
-
+
if (yd < yparts - 1) {
disprect.ymax = disprect.ymin + party;
if (disprect.ymax > ymaxb)
disprect.ymax = ymaxb;
}
else disprect.ymax = ymaxb;
-
+
rectx = BLI_rcti_size_x(&disprect);
recty = BLI_rcti_size_y(&disprect);
-
+
/* so, now can we add this part? */
if (rectx > 0 && recty > 0) {
RenderPart *pa = MEM_callocN(sizeof(RenderPart), "new part");
-
+
pa->disprect = disprect;
pa->rectx = rectx;
pa->recty = recty;
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 4b8415bd8c1..54fb4251a3b 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -94,6 +94,9 @@
#include "RE_pipeline.h"
#include "RE_render_ext.h"
+#include "../../../windowmanager/WM_api.h" /* XXX */
+#include "../../../intern/gawain/gawain/gwn_context.h"
+
#ifdef WITH_FREESTYLE
# include "FRS_freestyle.h"
#endif
@@ -137,7 +140,7 @@
/* here we store all renders */
static struct {
ListBase renderlist;
-} RenderGlobal = {{NULL, NULL}};
+} RenderGlobal = {{NULL, NULL}};
/* ********* alloc and free ******** */
@@ -424,10 +427,10 @@ void RE_AcquireResultImage(Render *re, RenderResult *rr, const int view_id)
if (re->result) {
RenderLayer *rl;
RenderView *rv;
-
+
rr->rectx = re->result->rectx;
rr->recty = re->result->recty;
-
+
/* actview view */
rv = RE_RenderViewGetById(re->result, view_id);
rr->have_combined = (rv->rectf != NULL);
@@ -494,7 +497,7 @@ Render *RE_NewRender(const char *name)
/* only one render per name exists */
re = RE_GetRender(name);
if (re == NULL) {
-
+
/* new render data struct */
re = MEM_callocN(sizeof(Render), "new render");
BLI_addtail(&RenderGlobal.renderlist, re);
@@ -502,7 +505,7 @@ Render *RE_NewRender(const char *name)
BLI_rw_mutex_init(&re->resultmutex);
BLI_rw_mutex_init(&re->partsmutex);
}
-
+
RE_InitRenderCB(re);
return re;
@@ -574,10 +577,10 @@ void RE_FreeRender(Render *re)
/* main dbase can already be invalid now, some database-free code checks it */
re->main = NULL;
re->scene = NULL;
-
+
render_result_free(re->result);
render_result_free(re->pushedresult);
-
+
BLI_remlink(&RenderGlobal.renderlist, re);
MEM_freeN(re);
}
@@ -715,7 +718,7 @@ void RE_InitState(Render *re, Render *source, RenderData *rd,
bool had_freestyle = (re->r.mode & R_EDGE_FRS) != 0;
re->ok = true; /* maybe flag */
-
+
re->i.starttime = PIL_check_seconds_timer();
/* copy render data and render layers for thread safety */
@@ -753,7 +756,7 @@ void RE_InitState(Render *re, Render *source, RenderData *rd,
}
re->r.scemode = check_mode_full_sample(&re->r);
-
+
if (single_layer) {
int index = BLI_findindex(render_layers, single_layer);
if (index != -1) {
@@ -761,11 +764,11 @@ void RE_InitState(Render *re, Render *source, RenderData *rd,
re->r.scemode |= R_SINGLE_LAYER;
}
}
-
+
/* if preview render, we try to keep old result */
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- if (re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW)) {
+ if (re->r.scemode & R_BUTS_PREVIEW) {
if (had_freestyle || (re->r.mode & R_EDGE_FRS)) {
/* freestyle manipulates render layers so always have to free */
render_result_free(re->result);
@@ -794,7 +797,7 @@ void RE_InitState(Render *re, Render *source, RenderData *rd,
}
}
else {
-
+
/* make empty render result, so display callbacks can initialize */
render_result_free(re->result);
re->result = MEM_callocN(sizeof(RenderResult), "new render result");
@@ -803,15 +806,11 @@ void RE_InitState(Render *re, Render *source, RenderData *rd,
render_result_view_new(re->result, "");
}
- eEvaluationMode mode = (re->r.scemode & R_VIEWPORT_PREVIEW) ? DAG_EVAL_PREVIEW : DAG_EVAL_RENDER;
- /* This mode should have been set in the Depsgraph immediately when it was created. */
- (void)mode;
-
/* ensure renderdatabase can use part settings correct */
RE_parts_clamp(re);
BLI_rw_mutex_unlock(&re->resultmutex);
-
+
RE_init_threadcount(re);
RE_point_density_fix_linking();
@@ -925,7 +924,7 @@ void render_update_anim_renderdata(Render *re, RenderData *rd, ListBase *render_
void RE_SetWindow(Render *re, const rctf *viewplane, float clipsta, float clipend)
{
/* re->ok flag? */
-
+
re->viewplane = *viewplane;
re->clipsta = clipsta;
re->clipend = clipend;
@@ -934,13 +933,13 @@ void RE_SetWindow(Render *re, const rctf *viewplane, float clipsta, float clipen
perspective_m4(re->winmat,
re->viewplane.xmin, re->viewplane.xmax,
re->viewplane.ymin, re->viewplane.ymax, re->clipsta, re->clipend);
-
+
}
void RE_SetOrtho(Render *re, const rctf *viewplane, float clipsta, float clipend)
{
/* re->ok flag? */
-
+
re->viewplane = *viewplane;
re->clipsta = clipsta;
re->clipend = clipend;
@@ -961,7 +960,7 @@ void RE_SetView(Render *re, float mat[4][4])
void RE_GetViewPlane(Render *re, rctf *r_viewplane, rcti *r_disprect)
{
*r_viewplane = re->viewplane;
-
+
/* make disprect zero when no border render, is needed to detect changes in 3d view render */
if (re->r.mode & R_BORDER) {
*r_disprect = re->disprect;
@@ -1020,6 +1019,40 @@ void RE_test_break_cb(Render *re, void *handle, int (*f)(void *handle))
re->tbh = handle;
}
+/* ********* GL Context ******** */
+
+void RE_gl_context_create(Render *re)
+{
+ /* Needs to be created in the main ogl thread. */
+ re->gl_context = WM_opengl_context_create();
+}
+
+void RE_gl_context_destroy(Render *re)
+{
+ /* Needs to be called from the thread which used the ogl context for rendering. */
+ if (re->gwn_context) {
+ GWN_context_active_set(re->gwn_context);
+ GWN_context_discard(re->gwn_context);
+ re->gwn_context = NULL;
+ }
+ if (re->gl_context) {
+ WM_opengl_context_dispose(re->gl_context);
+ re->gl_context = NULL;
+ }
+}
+
+void *RE_gl_context_get(Render *re)
+{
+ return re->gl_context;
+}
+
+void *RE_gwn_context_get(Render *re)
+{
+ if (re->gwn_context == NULL) {
+ re->gwn_context = GWN_context_create();
+ }
+ return re->gwn_context;
+}
/* ********* add object data (later) ******** */
@@ -1028,7 +1061,7 @@ void RE_test_break_cb(Render *re, void *handle, int (*f)(void *handle))
#if 0
void RE_AddObject(Render *UNUSED(re), Object *UNUSED(ob))
{
-
+
}
#endif
@@ -1121,9 +1154,9 @@ static void do_render(Render *re)
/* now use renderdata and camera to set viewplane */
RE_SetCamera(re, camera);
-
+
do_render_3d(re);
-
+
/* when border render, check if we have to insert it in black */
render_result_uncrop(re);
}
@@ -1136,7 +1169,7 @@ static void render_scene(Render *re, Scene *sce, int cfra)
{
Render *resc = RE_NewSceneRender(sce);
int winx = re->winx, winy = re->winy;
-
+
sce->r.cfra = cfra;
BKE_scene_camera_switch_update(sce);
@@ -1146,7 +1179,7 @@ static void render_scene(Render *re, Scene *sce, int cfra)
winx = (sce->r.size * sce->r.xsch) / 100;
winy = (sce->r.size * sce->r.ysch) / 100;
}
-
+
/* initial setup */
RE_InitState(resc, re, &sce->r, &sce->view_layers, NULL, winx, winy, &re->disprect);
@@ -1157,7 +1190,7 @@ static void render_scene(Render *re, Scene *sce, int cfra)
resc->main = re->main;
resc->scene = sce;
resc->lay = sce->lay;
-
+
/* ensure scene has depsgraph, base flags etc OK */
BKE_scene_set_background(re->main, sce);
@@ -1170,7 +1203,7 @@ static void render_scene(Render *re, Scene *sce, int cfra)
resc->sdh = re->sdh;
resc->current_scene_update = re->current_scene_update;
resc->suh = re->suh;
-
+
do_render(resc);
}
@@ -1179,11 +1212,11 @@ static int composite_needs_render(Scene *sce, int this_scene)
{
bNodeTree *ntree = sce->nodetree;
bNode *node;
-
+
if (ntree == NULL) return 1;
if (sce->use_nodes == false) return 1;
if ((sce->r.scemode & R_DOCOMP) == 0) return 1;
-
+
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == CMP_NODE_R_LAYERS && (node->flag & NODE_MUTED) == 0)
if (this_scene == 0 || node->id == NULL || node->id == &sce->id)
@@ -1301,12 +1334,11 @@ static void tag_dependend_object_for_render(Scene *scene, Object *object)
break;
case PART_DRAW_GR:
if (part->dup_group != NULL) {
- FOREACH_COLLECTION_BASE_RECURSIVE_BEGIN(part->dup_group, base)
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(part->dup_group, ob)
{
- Object *ob = base->object;
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
- FOREACH_COLLECTION_BASE_RECURSIVE_END
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
break;
}
@@ -1334,14 +1366,14 @@ static void tag_scenes_for_render(Render *re)
{
bNode *node;
Scene *sce;
-
+
for (sce = re->main->scene.first; sce; sce = sce->id.next) {
sce->id.tag &= ~LIB_TAG_DOIT;
#ifdef DEPSGRAPH_WORKAROUND_HACK
tag_dependend_objects_for_render(re->main, sce);
#endif
}
-
+
#ifdef WITH_FREESTYLE
if (re->freestyle_bmain) {
for (sce = re->freestyle_bmain->scene.first; sce; sce = sce->id.next) {
@@ -1359,9 +1391,9 @@ static void tag_scenes_for_render(Render *re)
tag_dependend_objects_for_render(re->main, re->scene);
#endif
}
-
+
if (re->scene->nodetree == NULL) return;
-
+
/* check for render-layers nodes using other scenes, we tag them LIB_TAG_DOIT */
for (node = re->scene->nodetree->nodes.first; node; node = node->next) {
node->flag &= ~NODE_TEST;
@@ -1397,7 +1429,7 @@ static void tag_scenes_for_render(Render *re)
}
}
}
-
+
}
static void ntree_render_scenes(Render *re)
@@ -1406,15 +1438,15 @@ static void ntree_render_scenes(Render *re)
int cfra = re->scene->r.cfra;
Scene *restore_scene = re->scene;
bool scene_changed = false;
-
+
if (re->scene->nodetree == NULL) return;
-
+
tag_scenes_for_render(re);
#ifdef DEPSGRAPH_WORKAROUND_GROUP_HACK
tag_collections_for_render(re);
#endif
-
+
/* now foreach render-result node tagged we do a full render */
/* results are stored in a way compisitor will find it */
for (node = re->scene->nodetree->nodes.first; node; node = node->next) {
@@ -1426,7 +1458,7 @@ static void ntree_render_scenes(Render *re)
scene_changed |= scene != restore_scene;
render_scene(re, scene, cfra);
node->flag &= ~NODE_TEST;
-
+
nodeUpdate(restore_scene->nodetree, node);
}
}
@@ -1531,10 +1563,10 @@ static void do_render_composite(Render *re)
{
bNodeTree *ntree = re->scene->nodetree;
int update_newframe = 0;
-
+
/* INIT seeding, compositor can use random texture */
BLI_srandom(re->r.cfra);
-
+
if (composite_needs_render(re->scene, 1)) {
/* save memory... free all cached images */
ntreeFreeCache(ntree);
@@ -1550,7 +1582,7 @@ static void do_render_composite(Render *re)
/* ensure new result gets added, like for regular renders */
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
-
+
render_result_free(re->result);
if ((re->r.mode & R_CROP) == 0) {
render_result_disprect_to_full_resolution(re);
@@ -1558,30 +1590,30 @@ static void do_render_composite(Render *re)
re->result = render_result_new(re, &re->disprect, 0, RR_USE_MEM, RR_ALL_LAYERS, RR_ALL_VIEWS);
BLI_rw_mutex_unlock(&re->resultmutex);
-
+
/* scene render process already updates animsys */
update_newframe = 1;
}
-
+
/* swap render result */
if (re->r.scemode & R_SINGLE_LAYER) {
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
render_result_single_layer_end(re);
BLI_rw_mutex_unlock(&re->resultmutex);
}
-
+
if (!re->test_break(re->tbh)) {
-
+
if (ntree) {
ntreeCompositTagRender(re->scene);
ntreeCompositTagAnimated(ntree);
}
-
+
if (ntree && re->scene->use_nodes && re->r.scemode & R_DOCOMP) {
/* checks if there are render-result nodes that need scene */
if ((re->r.scemode & R_SINGLE_LAYER) == 0)
ntree_render_scenes(re);
-
+
if (!re->test_break(re->tbh)) {
ntree->stats_draw = render_composit_stats;
ntree->test_break = re->test_break;
@@ -1589,16 +1621,16 @@ static void do_render_composite(Render *re)
ntree->sdh = re;
ntree->tbh = re->tbh;
ntree->prh = re->prh;
-
+
if (update_newframe) {
/* If we have consistent depsgraph now would be a time to update them. */
}
-
+
RenderView *rv;
for (rv = re->result->views.first; rv; rv = rv->next) {
ntreeCompositExecTree(re->scene, ntree, &re->r, true, G.background == 0, &re->scene->view_settings, &re->scene->display_settings, rv->name);
}
-
+
ntree->stats_draw = NULL;
ntree->test_break = NULL;
ntree->progress = NULL;
@@ -1651,15 +1683,15 @@ int RE_seq_render_active(Scene *scene, RenderData *rd)
Sequence *seq;
ed = scene->ed;
-
+
if (!(rd->scemode & R_DOSEQ) || !ed || !ed->seqbase.first)
return 0;
-
+
for (seq = ed->seqbase.first; seq; seq = seq->next) {
if (seq->type != SEQ_TYPE_SOUND_RAM)
return 1;
}
-
+
return 0;
}
@@ -1678,7 +1710,12 @@ static void do_render_seq(Render *re)
if (recurs_depth == 0) {
/* otherwise sequencer animation isn't updated */
- BKE_animsys_evaluate_all_animation(re->main, re->scene, (float)cfra); // XXX, was BKE_scene_frame_get(re->scene)
+ /* TODO(sergey): Currently depsgraph is only used to check whether it is an active
+ * edit window or not to deal with unkeyed changes. We don't have depsgraph here yet,
+ * but we also dont' deal with unkeyed changes. But still nice to get proper depsgraph
+ * within tjhe render pipeline, somehow.
+ */
+ BKE_animsys_evaluate_all_animation(re->main, NULL, re->scene, (float)cfra); // XXX, was BKE_scene_frame_get(re->scene)
}
recurs_depth++;
@@ -1697,8 +1734,13 @@ static void do_render_seq(Render *re)
tot_views = BKE_scene_multiview_num_views_get(&re->r);
ibuf_arr = MEM_mallocN(sizeof(ImBuf *) * tot_views, "Sequencer Views ImBufs");
+ /* TODO(sergey): Currently depsgraph is only used to check whether it is an active
+ * edit window or not to deal with unkeyed changes. We don't have depsgraph here yet,
+ * but we also dont' deal with unkeyed changes. But still nice to get proper depsgraph
+ * within tjhe render pipeline, somehow.
+ */
BKE_sequencer_new_render_data(
- re->main, re->scene,
+ re->main, NULL, re->scene,
re_x, re_y, 100, true,
&context);
@@ -1788,7 +1830,7 @@ static void do_render_all_options(Render *re)
re->i.starttime = PIL_check_seconds_timer();
/* ensure no images are in memory from previous animated sequences */
- BKE_image_all_free_anim_ibufs(re->r.cfra);
+ BKE_image_all_free_anim_ibufs(re->main, re->r.cfra);
BKE_sequencer_all_free_anim_ibufs(re->r.cfra);
if (RE_engine_render(re, 1)) {
@@ -1800,18 +1842,18 @@ static void do_render_all_options(Render *re)
do_render_seq(re);
render_seq = true;
}
-
+
re->stats_draw(re->sdh, &re->i);
re->display_update(re->duh, re->result, NULL);
}
else {
do_render_composite(re);
}
-
+
re->i.lastframetime = PIL_check_seconds_timer() - re->i.starttime;
-
+
re->stats_draw(re->sdh, &re->i);
-
+
/* save render result stamp if needed */
if (re->result != NULL) {
camera = RE_GetCamera(re);
@@ -1965,7 +2007,7 @@ static int check_composite_output(Scene *scene)
bool RE_is_rendering_allowed(Scene *scene, ViewLayer *single_layer, Object *camera_override, ReportList *reports)
{
int scemode = check_mode_full_sample(&scene->r);
-
+
if (scene->r.mode & R_BORDER) {
if (scene->r.border.xmax <= scene->r.border.xmin ||
scene->r.border.ymax <= scene->r.border.ymin)
@@ -1974,30 +2016,30 @@ bool RE_is_rendering_allowed(Scene *scene, ViewLayer *single_layer, Object *came
return 0;
}
}
-
+
if (scemode & (R_EXR_TILE_FILE | R_FULL_SAMPLE)) {
char str[FILE_MAX];
-
+
render_result_exr_file_path(scene, "", 0, str);
-
+
if (!BLI_file_is_writable(str)) {
BKE_report(reports, RPT_ERROR, "Cannot save render buffers, check the temp default path");
return 0;
}
}
-
+
if (scemode & R_DOCOMP) {
if (scene->use_nodes) {
if (!scene->nodetree) {
BKE_report(reports, RPT_ERROR, "No node tree in scene");
return 0;
}
-
+
if (!check_composite_output(scene)) {
BKE_report(reports, RPT_ERROR, "No render output node in scene");
return 0;
}
-
+
if (scemode & R_FULL_SAMPLE) {
if (composite_needs_render(scene, 0) == 0) {
BKE_report(reports, RPT_ERROR, "Full sample AA not supported without 3D rendering");
@@ -2006,12 +2048,12 @@ bool RE_is_rendering_allowed(Scene *scene, ViewLayer *single_layer, Object *came
}
}
}
-
+
/* check valid camera, without camera render is OK (compo, seq) */
if (!check_valid_camera(scene, camera_override, reports)) {
return 0;
}
-
+
/* get panorama & ortho, only after camera is set */
BKE_camera_object_mode(&scene->r, camera_override ? camera_override : scene->camera);
@@ -2088,19 +2130,19 @@ static int render_initialize_from_main(Render *re, RenderData *rd, Main *bmain,
{
int winx, winy;
rcti disprect;
-
+
/* r.xsch and r.ysch has the actual view window size
* r.border is the clipping rect */
-
+
/* calculate actual render result and display size */
winx = (rd->size * rd->xsch) / 100;
winy = (rd->size * rd->ysch) / 100;
-
+
/* we always render smaller part, inserting it in larger image is compositor bizz, it uses disprect for it */
if (scene->r.mode & R_BORDER) {
disprect.xmin = rd->border.xmin * winx;
disprect.xmax = rd->border.xmax * winx;
-
+
disprect.ymin = rd->border.ymin * winy;
disprect.ymax = rd->border.ymax * winy;
}
@@ -2109,7 +2151,7 @@ static int render_initialize_from_main(Render *re, RenderData *rd, Main *bmain,
disprect.xmax = winx;
disprect.ymax = winy;
}
-
+
re->main = bmain;
re->scene = scene;
re->camera_override = camera_override;
@@ -2124,7 +2166,7 @@ static int render_initialize_from_main(Render *re, RenderData *rd, Main *bmain,
re->disprect = disprect;
return 1;
}
-
+
/* check all scenes involved */
tag_scenes_for_render(re);
@@ -2143,17 +2185,17 @@ static int render_initialize_from_main(Render *re, RenderData *rd, Main *bmain,
ViewLayer *view_layer = BKE_view_layer_context_active_PLACEHOLDER(scene);
update_physics_cache(re, scene, view_layer, anim_init);
}
-
+
if (single_layer || scene->r.scemode & R_SINGLE_LAYER) {
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
render_result_single_layer_begin(re);
BLI_rw_mutex_unlock(&re->resultmutex);
}
-
+
RE_InitState(re, NULL, &scene->r, &scene->view_layers, single_layer, winx, winy, &disprect);
if (!re->ok) /* if an error was printed, abort */
return 0;
-
+
/* initstate makes new result, have to send changed tags around */
ntreeCompositTagRender(re->scene);
@@ -2161,7 +2203,7 @@ static int render_initialize_from_main(Render *re, RenderData *rd, Main *bmain,
re->display_init(re->dih, re->result);
re->display_clear(re->dch, re->result);
-
+
return 1;
}
@@ -2178,9 +2220,9 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, ViewLayer *single_la
/* ugly global still... is to prevent preview events and signal subsurfs etc to make full resol */
G.is_rendering = true;
-
+
scene->r.cfra = frame;
-
+
if (render_initialize_from_main(re, &scene->r, bmain, scene, single_layer,
camera_override, lay_override, 0, 0))
{
@@ -2198,7 +2240,7 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, ViewLayer *single_la
else {
char name[FILE_MAX];
BKE_image_path_from_imformat(
- name, scene->r.pic, bmain->name, scene->r.cfra,
+ name, scene->r.pic, BKE_main_blendfile_path(bmain), scene->r.cfra,
&scene->r.im_format, (scene->r.scemode & R_EXTENSION) != 0, false, NULL);
/* reports only used for Movie */
@@ -2214,6 +2256,9 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, ViewLayer *single_la
BLI_callback_exec(re->main, (ID *)scene, G.is_break ? BLI_CB_EVT_RENDER_CANCEL : BLI_CB_EVT_RENDER_COMPLETE);
+ /* Destroy the opengl context in the correct thread. */
+ RE_gl_context_destroy(re);
+
/* UGLY WARNING */
G.is_rendering = false;
}
@@ -2457,18 +2502,18 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie
BLI_strncpy(name, name_override, sizeof(name));
else
BKE_image_path_from_imformat(
- name, scene->r.pic, bmain->name, scene->r.cfra,
+ name, scene->r.pic, BKE_main_blendfile_path(bmain), scene->r.cfra,
&scene->r.im_format, (scene->r.scemode & R_EXTENSION) != 0, true, NULL);
/* write images as individual images or stereo */
ok = RE_WriteRenderViewsImage(re->reports, &rres, scene, true, name);
}
-
+
RE_ReleaseResultImageViews(re, &rres);
render_time = re->i.lastframetime;
re->i.lastframetime = PIL_check_seconds_timer() - re->i.starttime;
-
+
BLI_timecode_string_from_time_simple(name, sizeof(name), re->i.lastframetime);
printf(" Time: %s", name);
@@ -2479,7 +2524,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie
BLI_timecode_string_from_time_simple(name, sizeof(name), re->i.lastframetime - render_time);
printf(" (Saving: %s)\n", name);
-
+
fputc('\n', stdout);
fflush(stdout); /* needed for renderd !! (not anymore... (ton)) */
@@ -2614,7 +2659,12 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
{
float ctime = BKE_scene_frame_get(scene);
AnimData *adt = BKE_animdata_from_id(&scene->id);
- BKE_animsys_evaluate_animdata(scene, &scene->id, adt, ctime, ADT_RECALC_ALL);
+ /* TODO(sergey): Currently depsgraph is only used to check whether it is an active
+ * edit window or not to deal with unkeyed changes. We don't have depsgraph here yet,
+ * but we also dont' deal with unkeyed changes. But still nice to get proper depsgraph
+ * within tjhe render pipeline, somehow.
+ */
+ BKE_animsys_evaluate_animdata(NULL, scene, &scene->id, adt, ctime, ADT_RECALC_ALL);
}
/* only border now, todo: camera lens. (ton) */
@@ -2632,7 +2682,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
if (is_movie == false) {
if (scene->r.mode & (R_NO_OVERWRITE | R_TOUCH))
BKE_image_path_from_imformat(
- name, scene->r.pic, bmain->name, scene->r.cfra,
+ name, scene->r.pic, BKE_main_blendfile_path(bmain), scene->r.cfra,
&scene->r.im_format, (scene->r.scemode & R_EXTENSION) != 0, true, NULL);
if (scene->r.mode & R_NO_OVERWRITE) {
@@ -2698,10 +2748,10 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
/* run callbacs before rendering, before the scene is updated */
BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_PRE);
-
+
do_render_all_options(re);
totrendered++;
-
+
if (re->test_break(re->tbh) == 0) {
if (!G.is_break)
if (!do_write_image_or_movie(re, bmain, scene, mh, totvideos, NULL))
@@ -2709,7 +2759,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
}
else
G.is_break = true;
-
+
if (G.is_break == true) {
/* remove touched file */
if (is_movie == false) {
@@ -2738,7 +2788,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
}
}
}
-
+
break;
}
@@ -2748,12 +2798,12 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
}
}
}
-
+
/* end movie */
if (is_movie) {
re_movie_free_all(re, mh, totvideos);
}
-
+
if (totskipped && totrendered == 0)
BKE_report(re->reports, RPT_INFO, "No frames rendered, skipped to not overwrite");
@@ -2764,6 +2814,9 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
BLI_callback_exec(re->main, (ID *)scene, G.is_break ? BLI_CB_EVT_RENDER_CANCEL : BLI_CB_EVT_RENDER_COMPLETE);
BKE_sound_reset_scene_specs(scene);
+ /* Destroy the opengl context in the correct thread. */
+ RE_gl_context_destroy(re);
+
/* UGLY WARNING */
G.is_rendering = false;
}
@@ -2797,16 +2850,16 @@ bool RE_ReadRenderResult(Scene *scene, Scene *scenode)
int winx, winy;
bool success;
rcti disprect;
-
+
/* calculate actual render result and display size */
winx = (scene->r.size * scene->r.xsch) / 100;
winy = (scene->r.size * scene->r.ysch) / 100;
-
+
/* only in movie case we render smaller part */
if (scene->r.mode & R_BORDER) {
disprect.xmin = scene->r.border.xmin * winx;
disprect.xmax = scene->r.border.xmax * winx;
-
+
disprect.ymin = scene->r.border.ymin * winy;
disprect.ymax = scene->r.border.ymax * winy;
}
@@ -2815,17 +2868,17 @@ bool RE_ReadRenderResult(Scene *scene, Scene *scenode)
disprect.xmax = winx;
disprect.ymax = winy;
}
-
+
if (scenode)
scene = scenode;
-
+
/* get render: it can be called from UI with draw callbacks */
re = RE_GetSceneRender(scene);
if (re == NULL)
re = RE_NewSceneRender(scene);
RE_InitState(re, NULL, &scene->r, &scene->view_layers, NULL, winx, winy, &disprect);
re->scene = scene;
-
+
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
success = render_result_exr_file_cache_read(re);
BLI_rw_mutex_unlock(&re->resultmutex);
@@ -2835,7 +2888,7 @@ bool RE_ReadRenderResult(Scene *scene, Scene *scenode)
return success;
}
-void RE_init_threadcount(Render *re)
+void RE_init_threadcount(Render *re)
{
re->r.threads = BKE_render_num_threads(&re->r);
}
@@ -2999,7 +3052,7 @@ RenderPass *RE_create_gp_pass(RenderResult *rr, const char *layername, const cha
rl->rectx = rr->rectx;
rl->recty = rr->recty;
}
-
+
/* clear previous pass if exist or the new image will be over previous one*/
RenderPass *rp = RE_pass_find_by_name(rl, RE_PASSNAME_COMBINED, viewname);
if (rp) {
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
index 53359c305dc..c025a1fdef7 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -102,7 +102,7 @@ static void point_data_pointers(PointDensity *pd,
const int totpoint = pd->totpoints;
float *data = pd->point_data;
int offset = 0;
-
+
if (data_used & POINT_DATA_VEL) {
if (r_data_velocity)
*r_data_velocity = data + offset;
@@ -112,7 +112,7 @@ static void point_data_pointers(PointDensity *pd,
if (r_data_velocity)
*r_data_velocity = NULL;
}
-
+
if (data_used & POINT_DATA_LIFE) {
if (r_data_life)
*r_data_life = data + offset;
@@ -122,7 +122,7 @@ static void point_data_pointers(PointDensity *pd,
if (r_data_life)
*r_data_life = NULL;
}
-
+
if (data_used & POINT_DATA_COLOR) {
if (r_data_color)
*r_data_color = data + offset;
@@ -283,19 +283,19 @@ static void pointdensity_cache_vertex_color(PointDensity *pd, Object *UNUSED(ob)
const MLoopCol *mcol;
char layername[MAX_CUSTOMDATA_LAYER_NAME];
int i;
-
+
BLI_assert(data_color);
-
+
if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPCOL))
return;
CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPCOL, pd->vertex_attribute_name, layername);
mcol = CustomData_get_layer_named(&mesh->ldata, CD_MLOOPCOL, layername);
if (!mcol)
return;
-
+
/* Stores the number of MLoops using the same vertex, so we can normalize colors. */
int *mcorners = MEM_callocN(sizeof(int) * pd->totpoints, "point density corner count");
-
+
for (i = 0; i < totloop; i++) {
int v = mloop[i].v;
@@ -310,7 +310,7 @@ static void pointdensity_cache_vertex_color(PointDensity *pd, Object *UNUSED(ob)
++mcorners[v];
}
-
+
/* Normalize colors by averaging over mcorners.
* All the corners share the same vertex, ie. occupy the same point in space.
*/
@@ -318,7 +318,7 @@ static void pointdensity_cache_vertex_color(PointDensity *pd, Object *UNUSED(ob)
if (mcorners[i] > 0)
mul_v3_fl(&data_color[i*3], 1.0f / mcorners[i]);
}
-
+
MEM_freeN(mcorners);
}
@@ -328,9 +328,9 @@ static void pointdensity_cache_vertex_weight(PointDensity *pd, Object *ob, Mesh
const MDeformVert *mdef, *dv;
int mdef_index;
int i;
-
+
BLI_assert(data_color);
-
+
mdef = CustomData_get_layer(&mesh->vdata, CD_MDEFORMVERT);
if (!mdef)
return;
@@ -339,11 +339,11 @@ static void pointdensity_cache_vertex_weight(PointDensity *pd, Object *ob, Mesh
mdef_index = ob->actdef - 1;
if (mdef_index < 0)
return;
-
+
for (i = 0, dv = mdef; i < totvert; ++i, ++dv, data_color += 3) {
MDeformWeight *dw;
int j;
-
+
for (j = 0, dw = dv->dw; j < dv->totweight; ++j, ++dw) {
if (dw->def_nr == mdef_index) {
copy_v3_fl(data_color, dw->weight);
@@ -357,9 +357,9 @@ static void pointdensity_cache_vertex_normal(PointDensity *pd, Object *UNUSED(ob
{
MVert *mvert = mesh->mvert, *mv;
int i;
-
+
BLI_assert(data_color);
-
+
for (i = 0, mv = mvert; i < pd->totpoints; i++, mv++, data_color += 3) {
normal_short_to_float_v3(data_color, mv->no);
}
@@ -413,7 +413,7 @@ static void pointdensity_cache_object(PointDensity *pd,
BLI_bvhtree_insert(pd->point_tree, i, co, 1);
}
-
+
switch (pd->ob_color_source) {
case TEX_PD_COLOR_VERTCOL:
pointdensity_cache_vertex_color(pd, ob, mesh, data_color);
@@ -506,7 +506,7 @@ static float density_falloff(PointDensityRangeData *pdr, int index, float square
{
const float dist = (pdr->squared_radius - squared_dist) / pdr->squared_radius * 0.5f;
float density = 0.0f;
-
+
switch (pdr->falloff_type) {
case TEX_PD_FALLOFF_STD:
density = dist;
@@ -536,12 +536,12 @@ static float density_falloff(PointDensityRangeData *pdr, int index, float square
density = dist;
break;
}
-
+
if (pdr->density_curve && dist != 0.0f) {
curvemapping_initialize(pdr->density_curve);
density = curvemapping_evaluateF(pdr->density_curve, 0, density / dist) * dist;
}
-
+
return density;
}
@@ -666,7 +666,7 @@ static void pointdensity_color(PointDensity *pd, TexResult *texres, float age, c
if (pd->source == TEX_PD_PSYS) {
float rgba[4];
-
+
switch (pd->color_source) {
case TEX_PD_COLOR_PARTAGE:
if (pd->coba) {
@@ -681,7 +681,7 @@ static void pointdensity_color(PointDensity *pd, TexResult *texres, float age, c
case TEX_PD_COLOR_PARTSPEED:
{
float speed = len_v3(vec) * pd->speed_scale;
-
+
if (pd->coba) {
if (BKE_colorband_evaluate(pd->coba, speed, rgba)) {
texres->talpha = true;
@@ -704,7 +704,7 @@ static void pointdensity_color(PointDensity *pd, TexResult *texres, float age, c
}
else {
float rgba[4];
-
+
switch (pd->ob_color_source) {
case TEX_PD_COLOR_VERTCOL:
texres->talpha = true;
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index ba12eac3efa..e0cacdf4b8f 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -95,7 +95,7 @@ void render_result_free(RenderResult *res)
if (rl->acolrect) MEM_freeN(rl->acolrect);
if (rl->scolrect) MEM_freeN(rl->scolrect);
if (rl->display_buffer) MEM_freeN(rl->display_buffer);
-
+
while (rl->passes.first) {
RenderPass *rpass = rl->passes.first;
if (rpass->rect) MEM_freeN(rpass->rect);
@@ -128,13 +128,13 @@ void render_result_free(RenderResult *res)
void render_result_free_list(ListBase *lb, RenderResult *rr)
{
RenderResult *rrnext;
-
+
for (; rr; rr = rrnext) {
rrnext = rr->next;
-
+
if (lb && lb->first)
BLI_remlink(lb, rr);
-
+
render_result_free(rr);
}
}
@@ -206,7 +206,7 @@ static RenderPass *render_layer_add_pass(RenderResult *rr, RenderLayer *rl, int
const int view_id = BLI_findstringindex(&rr->views, viewname, offsetof(RenderView, name));
RenderPass *rpass = MEM_callocN(sizeof(RenderPass), name);
size_t rectsize = ((size_t)rr->rectx) * rr->recty * channels;
-
+
rpass->channels = channels;
rpass->rectx = rl->rectx;
rpass->recty = rl->recty;
@@ -216,7 +216,7 @@ static RenderPass *render_layer_add_pass(RenderResult *rr, RenderLayer *rl, int
BLI_strncpy(rpass->chan_id, chan_id, sizeof(rpass->chan_id));
BLI_strncpy(rpass->view, viewname, sizeof(rpass->view));
set_pass_full_name(rpass->fullname, rpass->name, -1, rpass->view, rpass->chan_id);
-
+
if (rl->exrhandle) {
int a;
for (a = 0; a < channels; a++) {
@@ -227,13 +227,13 @@ static RenderPass *render_layer_add_pass(RenderResult *rr, RenderLayer *rl, int
else {
float *rect;
int x;
-
+
rpass->rect = MEM_mapallocN(sizeof(float) * rectsize, name);
if (rpass->rect == NULL) {
MEM_freeN(rpass);
return NULL;
}
-
+
if (STREQ(rpass->name, RE_PASSNAME_VECTOR)) {
/* initialize to max speed */
rect = rpass->rect;
@@ -267,13 +267,13 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
RenderLayer *rl;
RenderView *rv;
int rectx, recty;
-
+
rectx = BLI_rcti_size_x(partrct);
recty = BLI_rcti_size_y(partrct);
-
+
if (rectx <= 0 || recty <= 0)
return NULL;
-
+
rr = MEM_callocN(sizeof(RenderResult), "new render result");
rr->rectx = rectx;
rr->recty = recty;
@@ -286,7 +286,7 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
rr->tilerect.xmax = partrct->xmax - re->disprect.xmin;
rr->tilerect.ymin = partrct->ymin - re->disprect.ymin;
rr->tilerect.ymax = partrct->ymax - re->disprect.ymin;
-
+
if (savebuffers) {
rr->do_exr_tile = true;
}
@@ -304,14 +304,14 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
rl = MEM_callocN(sizeof(RenderLayer), "new render layer");
BLI_addtail(&rr->layers, rl);
-
+
BLI_strncpy(rl->name, view_layer->name, sizeof(rl->name));
rl->layflag = view_layer->layflag;
rl->passflag = view_layer->passflag; /* for debugging: view_layer->passflag | SCE_PASS_RAYHITS; */
rl->pass_xor = view_layer->pass_xor;
rl->rectx = rectx;
rl->recty = recty;
-
+
if (rr->do_exr_tile) {
rl->display_buffer = MEM_mapallocN((size_t)rectx * recty * sizeof(unsigned int),
"Combined display space rgba");
@@ -412,7 +412,7 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
if (BLI_listbase_is_empty(&rr->layers) && !(layername && layername[0])) {
rl = MEM_callocN(sizeof(RenderLayer), "new render layer");
BLI_addtail(&rr->layers, rl);
-
+
rl->rectx = rectx;
rl->recty = recty;
@@ -439,15 +439,15 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
/* note, this has to be in sync with scene.c */
rl->layflag = 0x7FFF; /* solid ztra halo strand */
rl->passflag = SCE_PASS_COMBINED;
-
+
re->active_view_layer = 0;
}
-
+
/* border render; calculate offset for use in compositor. compo is centralized coords */
/* XXX obsolete? I now use it for drawing border render offset (ton) */
rr->xof = re->disprect.xmin + BLI_rcti_cent_x(&re->disprect) - (re->winx / 2);
rr->yof = re->disprect.ymin + BLI_rcti_cent_y(&re->disprect) - (re->winy / 2);
-
+
return rr;
}
@@ -554,7 +554,7 @@ static void *ml_addlayer_cb(void *base, const char *str)
{
RenderResult *rr = base;
RenderLayer *rl;
-
+
rl = MEM_callocN(sizeof(RenderLayer), "new render layer");
BLI_addtail(&rr->layers, rl);
@@ -676,7 +676,7 @@ RenderResult *render_result_new_from_exr(void *exrhandle, const char *colorspace
rr->rectx = rectx;
rr->recty = recty;
-
+
IMB_exr_multilayer_convert(exrhandle, rr, ml_addview_cb, ml_addlayer_cb, ml_addpass_cb);
for (rl = rr->layers.first; rl; rl = rl->next) {
@@ -695,7 +695,7 @@ RenderResult *render_result_new_from_exr(void *exrhandle, const char *colorspace
}
}
}
-
+
return rr;
}
@@ -740,16 +740,16 @@ static void do_merge_tile(RenderResult *rr, RenderResult *rrpart, float *target,
{
int y, tilex, tiley;
size_t ofs, copylen;
-
+
copylen = tilex = rrpart->rectx;
tiley = rrpart->recty;
-
+
if (rrpart->crop) { /* filters add pixel extra */
tile += pixsize * (rrpart->crop + ((size_t)rrpart->crop) * tilex);
-
+
copylen = tilex - 2 * rrpart->crop;
tiley -= 2 * rrpart->crop;
-
+
ofs = (((size_t)rrpart->tilerect.ymin) + rrpart->crop) * rr->rectx + (rrpart->tilerect.xmin + rrpart->crop);
target += pixsize * ofs;
}
@@ -776,7 +776,7 @@ void render_result_merge(RenderResult *rr, RenderResult *rrpart)
{
RenderLayer *rl, *rlp;
RenderPass *rpass, *rpassp;
-
+
for (rl = rr->layers.first; rl; rl = rl->next) {
rlp = RE_GetRenderLayer(rrpart, rl->name);
if (rlp) {
@@ -956,7 +956,7 @@ void render_result_single_layer_begin(Render *re)
/* officially pushed result should be NULL... error can happen with do_seq */
RE_FreeRenderResult(re->pushedresult);
-
+
re->pushedresult = re->result;
re->result = NULL;
}
@@ -980,10 +980,10 @@ void render_result_single_layer_end(Render *re)
if (re->pushedresult->rectx == re->result->rectx && re->pushedresult->recty == re->result->recty) {
/* find which layer in re->pushedresult should be replaced */
rl = re->result->layers.first;
-
+
/* render result should be empty after this */
BLI_remlink(&re->result->layers, rl);
-
+
/* reconstruct render result layers */
for (nr = 0, view_layer = re->view_layers.first; view_layer; view_layer = view_layer->next, nr++) {
if (nr == re->active_view_layer) {
@@ -1010,9 +1010,9 @@ static void save_render_result_tile(RenderResult *rr, RenderResult *rrpart, cons
RenderLayer *rlp, *rl;
RenderPass *rpassp;
int offs, partx, party;
-
+
BLI_thread_lock(LOCK_IMAGE);
-
+
for (rlp = rrpart->layers.first; rlp; rlp = rlp->next) {
rl = RE_GetRenderLayer(rr, rlp->name);
@@ -1042,7 +1042,7 @@ static void save_render_result_tile(RenderResult *rr, RenderResult *rrpart, cons
xstride, xstride * rrpart->rectx, rpassp->rect + a + xstride * offs);
}
}
-
+
}
party = rrpart->tilerect.ymin + rrpart->crop;
@@ -1068,7 +1068,7 @@ void render_result_save_empty_result_tiles(Render *re)
RenderPart *pa;
RenderResult *rr;
RenderLayer *rl;
-
+
for (rr = re->result; rr; rr = rr->next) {
for (rl = rr->layers.first; rl; rl = rl->next) {
for (pa = re->parts.first; pa; pa = pa->next) {
@@ -1112,7 +1112,7 @@ void render_result_exr_file_end(Render *re)
rr->do_exr_tile = false;
}
-
+
render_result_free_list(&re->fullresult, re->result);
re->result = NULL;
@@ -1130,8 +1130,8 @@ void render_result_exr_file_merge(RenderResult *rr, RenderResult *rrpart, const
void render_result_exr_file_path(Scene *scene, const char *layname, int sample, char *filepath)
{
char name[FILE_MAXFILE + MAX_ID_NAME + MAX_ID_NAME + 100];
- const char *fi = BLI_path_basename(G.main->name);
-
+ const char *fi = BLI_path_basename(BKE_main_blendfile_path_from_global());
+
if (sample == 0) {
BLI_snprintf(name, sizeof(name), "%s_%s_%s.exr", fi, scene->id.name + 2, layname);
}
@@ -1194,7 +1194,7 @@ int render_result_exr_file_read_path(RenderResult *rr, RenderLayer *rl_single, c
for (rl = rr->layers.first; rl; rl = rl->next) {
if (rl_single && rl_single != rl)
continue;
-
+
/* passes are allocated in sync */
for (rpass = rl->passes.first; rpass; rpass = rpass->next) {
const int xstride = rpass->channels;
@@ -1224,10 +1224,11 @@ static void render_result_exr_file_cache_path(Scene *sce, const char *root, char
char path_hexdigest[33];
/* If root is relative, use either current .blend file dir, or temp one if not saved. */
- if (G.main->name[0]) {
- BLI_split_dirfile(G.main->name, dirname, filename, sizeof(dirname), sizeof(filename));
+ const char *blendfile_path = BKE_main_blendfile_path_from_global();
+ if (blendfile_path[0] != '\0') {
+ BLI_split_dirfile(blendfile_path, dirname, filename, sizeof(dirname), sizeof(filename));
BLI_replace_extension(filename, sizeof(filename), ""); /* strip '.blend' */
- BLI_hash_md5_buffer(G.main->name, strlen(G.main->name), path_digest);
+ BLI_hash_md5_buffer(blendfile_path, strlen(blendfile_path), path_digest);
}
else {
BLI_strncpy(dirname, BKE_tempdir_base(), sizeof(dirname));
@@ -1291,7 +1292,7 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd, const int vi
/* float factor for random dither, imbuf takes care of it */
ibuf->dither = rd->dither_intensity;
-
+
/* prepare to gamma correct to sRGB color space
* note that sequence editor can generate 8bpc render buffers
*/
@@ -1332,7 +1333,7 @@ void RE_render_result_rect_from_ibuf(RenderResult *rr, RenderData *UNUSED(rd), I
if (!rv->rectf)
rv->rectf = MEM_mallocN(4 * sizeof(float) * rr->rectx * rr->recty, "render_seq rectf");
-
+
memcpy(rv->rectf, ibuf->rect_float, 4 * sizeof(float) * rr->rectx * rr->recty);
/* TSK! Since sequence render doesn't free the *rr render result, the old rect32
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index 79d13ecab5b..99da5b3ca01 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -95,7 +95,7 @@ static void tex_normal_derivate(Tex *tex, TexResult *texres)
float col[4];
if (BKE_colorband_evaluate(tex->coba, texres->tin, col)) {
float fac0, fac1, fac2, fac3;
-
+
fac0= (col[0]+col[1]+col[2]);
BKE_colorband_evaluate(tex->coba, texres->nor[0], col);
fac1= (col[0]+col[1]+col[2]);
@@ -103,11 +103,11 @@ static void tex_normal_derivate(Tex *tex, TexResult *texres)
fac2= (col[0]+col[1]+col[2]);
BKE_colorband_evaluate(tex->coba, texres->nor[2], col);
fac3= (col[0]+col[1]+col[2]);
-
+
texres->nor[0]= (fac0 - fac1) / 3.0f;
texres->nor[1]= (fac0 - fac2) / 3.0f;
texres->nor[2]= (fac0 - fac3) / 3.0f;
-
+
return;
}
}
@@ -173,7 +173,7 @@ static int blend(Tex *tex, const float texvec[3], TexResult *texres)
static int clouds(Tex *tex, const float texvec[3], TexResult *texres)
{
int rv = TEX_INT;
-
+
texres->tin = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
if (texres->nor!=NULL) {
@@ -181,7 +181,7 @@ static int clouds(Tex *tex, const float texvec[3], TexResult *texres)
texres->nor[0] = BLI_gTurbulence(tex->noisesize, texvec[0] + tex->nabla, texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
texres->nor[1] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1] + tex->nabla, texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
texres->nor[2] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2] + tex->nabla, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
-
+
tex_normal_derivate(tex, texres);
rv |= TEX_NOR;
}
@@ -215,7 +215,7 @@ static float tex_sin(float a)
static float tex_saw(float a)
{
const float b = 2*M_PI;
-
+
int n = (int)(a / b);
a -= n*b;
if (a < 0) a += b;
@@ -227,9 +227,9 @@ static float tex_tri(float a)
{
const float b = 2*M_PI;
const float rmax = 1.0;
-
+
a = rmax - 2.0f*fabsf(floorf((a*(1.0f/b))+0.5f) - (a*(1.0f/b)));
-
+
return a;
}
@@ -244,9 +244,9 @@ static float wood_int(Tex *tex, float x, float y, float z)
waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */
waveform[1] = tex_saw;
waveform[2] = tex_tri;
-
+
if ((wf>TEX_TRI) || (wf<TEX_SIN)) wf=0; /* check to be sure noisebasis2 is initialized ahead of time */
-
+
if (wt==TEX_BAND) {
wi = waveform[wf]((x + y + z)*10.0f);
}
@@ -261,7 +261,7 @@ static float wood_int(Tex *tex, float x, float y, float z)
wi = tex->turbul*BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
wi = waveform[wf](sqrtf(x*x + y*y + z*z)*20.0f + wi);
}
-
+
return wi;
}
@@ -275,7 +275,7 @@ static int wood(Tex *tex, const float texvec[3], TexResult *texres)
texres->nor[0] = wood_int(tex, texvec[0] + tex->nabla, texvec[1], texvec[2]);
texres->nor[1] = wood_int(tex, texvec[0], texvec[1] + tex->nabla, texvec[2]);
texres->nor[2] = wood_int(tex, texvec[0], texvec[1], texvec[2] + tex->nabla);
-
+
tex_normal_derivate(tex, texres);
rv |= TEX_NOR;
}
@@ -291,16 +291,16 @@ static float marble_int(Tex *tex, float x, float y, float z)
float n, mi;
short wf = tex->noisebasis2; /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */
short mt = tex->stype; /* marble type: TEX_SOFT=0, TEX_SHARP=1,TEX_SHAPER=2 */
-
+
float (*waveform[3])(float); /* create array of pointers to waveform functions */
waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */
waveform[1] = tex_saw;
waveform[2] = tex_tri;
-
+
if ((wf>TEX_TRI) || (wf<TEX_SIN)) wf=0; /* check to be sure noisebasis2 isn't initialized ahead of time */
-
+
n = 5.0f * (x + y + z);
-
+
mi = n + tex->turbul * BLI_gTurbulence(tex->noisesize, x, y, z, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
if (mt>=TEX_SOFT) { /* TEX_SOFT always true */
@@ -327,9 +327,9 @@ static int marble(Tex *tex, const float texvec[3], TexResult *texres)
texres->nor[0] = marble_int(tex, texvec[0] + tex->nabla, texvec[1], texvec[2]);
texres->nor[1] = marble_int(tex, texvec[0], texvec[1] + tex->nabla, texvec[2]);
texres->nor[2] = marble_int(tex, texvec[0], texvec[1], texvec[2] + tex->nabla);
-
+
tex_normal_derivate(tex, texres);
-
+
rv |= TEX_NOR;
}
@@ -397,8 +397,8 @@ static int magic(Tex *tex, const float texvec[3], TexResult *texres)
if (turb!=0.0f) {
turb*= 2.0f;
- x/= turb;
- y/= turb;
+ x/= turb;
+ y/= turb;
z/= turb;
}
texres->tr = 0.5f - x;
@@ -406,10 +406,10 @@ static int magic(Tex *tex, const float texvec[3], TexResult *texres)
texres->tb = 0.5f - z;
texres->tin= (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb);
-
+
BRICONTRGB;
texres->ta = 1.0f;
-
+
return TEX_RGB;
}
@@ -420,9 +420,9 @@ static int stucci(Tex *tex, const float texvec[3], TexResult *texres)
{
float nor[3], b2, ofs;
int retval= TEX_INT;
-
+
b2= BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
-
+
ofs= tex->turbul/200.0f;
if (tex->stype) ofs*=(b2*b2);
@@ -431,27 +431,27 @@ static int stucci(Tex *tex, const float texvec[3], TexResult *texres)
nor[2] = BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2]+ofs, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
texres->tin= nor[2];
-
+
if (texres->nor) {
-
+
copy_v3_v3(texres->nor, nor);
tex_normal_derivate(tex, texres);
-
+
if (tex->stype==TEX_WALLOUT) {
texres->nor[0]= -texres->nor[0];
texres->nor[1]= -texres->nor[1];
texres->nor[2]= -texres->nor[2];
}
-
+
retval |= TEX_NOR;
}
-
+
if (tex->stype==TEX_WALLOUT)
texres->tin= 1.0f-texres->tin;
-
+
if (texres->tin<0.0f)
texres->tin= 0.0f;
-
+
return retval;
}
@@ -477,7 +477,7 @@ static float mg_mFractalOrfBmTex(Tex *tex, const float texvec[3], TexResult *tex
texres->nor[0] = tex->ns_outscale*mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
texres->nor[1] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
texres->nor[2] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2] + offs, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
-
+
tex_normal_derivate(tex, texres);
rv |= TEX_NOR;
}
@@ -507,7 +507,7 @@ static float mg_ridgedOrHybridMFTex(Tex *tex, const float texvec[3], TexResult *
texres->nor[0] = tex->ns_outscale*mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
texres->nor[1] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
texres->nor[2] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2] + offs, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
-
+
tex_normal_derivate(tex, texres);
rv |= TEX_NOR;
}
@@ -532,7 +532,7 @@ static float mg_HTerrainTex(Tex *tex, const float texvec[3], TexResult *texres)
texres->nor[0] = tex->ns_outscale*mg_HeteroTerrain(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
texres->nor[1] = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
texres->nor[2] = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1], texvec[2] + offs, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
-
+
tex_normal_derivate(tex, texres);
rv |= TEX_NOR;
}
@@ -630,7 +630,7 @@ static float voronoiTex(Tex *tex, const float texvec[3], TexResult *texres)
texres->nor[1] = sc * fabsf(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]);
voronoi(texvec[0], texvec[1], texvec[2] + offs, da, pa, tex->vn_mexp, tex->vn_distm);
texres->nor[2] = sc * fabsf(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]);
-
+
tex_normal_derivate(tex, texres);
rv |= TEX_NOR;
}
@@ -640,7 +640,7 @@ static float voronoiTex(Tex *tex, const float texvec[3], TexResult *texres)
texres->ta = 1.0;
return (rv | TEX_RGB);
}
-
+
BRICONT;
return rv;
@@ -653,20 +653,20 @@ static int texnoise(Tex *tex, TexResult *texres, int thread)
{
float div=3.0;
int val, ran, loop, shift = 29;
-
+
ran= BLI_rng_thread_rand(random_tex_array, thread);
-
+
loop= tex->noisedepth;
/* start from top bits since they have more variance */
val= ((ran >> shift) & 3);
-
+
while (loop--) {
- shift -= 2;
+ shift -= 2;
val *= ((ran >> shift) & 3);
div *= 3.0f;
}
-
+
texres->tin= ((float)val)/div;
BRICONT;
@@ -679,7 +679,7 @@ static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1
{
float x1, y1, z1, nor[3];
int ret;
-
+
if (n==NULL) {
nor[0]= x; nor[1]= y; nor[2]= z; /* use local render coord */
}
@@ -690,7 +690,7 @@ static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1
x1 = fabsf(nor[0]);
y1 = fabsf(nor[1]);
z1 = fabsf(nor[2]);
-
+
if (z1>=x1 && z1>=y1) {
*adr1 = (x + 1.0f) / 2.0f;
*adr2 = (y + 1.0f) / 2.0f;
@@ -719,13 +719,13 @@ static void do_2d_mapping(
Tex *tex;
float fx, fy, fac1, area[8];
int ok, proj, areaflag= 0, wrap;
-
+
/* mtex variables localized, only cubemap doesn't cooperate yet... */
wrap= mtex->mapping;
tex= mtex->tex;
if (!(dxt && dyt)) {
-
+
if (wrap==MTEX_FLAT) {
fx = (texvec[0] + 1.0f) / 2.0f;
fy = (texvec[1] + 1.0f) / 2.0f;
@@ -735,15 +735,15 @@ static void do_2d_mapping(
else {
cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
}
-
+
/* repeat */
if (tex->extend==TEX_REPEAT) {
if (tex->xrepeat>1) {
float origf= fx *= tex->xrepeat;
-
+
if (fx>1.0f) fx -= (int)(fx);
else if (fx<0.0f) fx+= 1-(int)(fx);
-
+
if (tex->flag & TEX_REPEAT_XMIR) {
int orig= (int)floor(origf);
if (orig & 1)
@@ -752,10 +752,10 @@ static void do_2d_mapping(
}
if (tex->yrepeat>1) {
float origf= fy *= tex->yrepeat;
-
+
if (fy>1.0f) fy -= (int)(fy);
else if (fy<0.0f) fy+= 1-(int)(fy);
-
+
if (tex->flag & TEX_REPEAT_YMIR) {
int orig= (int)floor(origf);
if (orig & 1)
@@ -777,7 +777,7 @@ static void do_2d_mapping(
texvec[1]= fy;
}
else {
-
+
if (wrap==MTEX_FLAT) {
fx= (texvec[0] + 1.0f) / 2.0f;
fy= (texvec[1] + 1.0f) / 2.0f;
@@ -854,55 +854,55 @@ static void do_2d_mapping(
dyt[2] *= 0.5f;
}
-
+
/* if area, then reacalculate dxt[] and dyt[] */
if (areaflag) {
- fx= area[0];
+ fx= area[0];
fy= area[1];
dxt[0]= area[2]-fx;
dxt[1]= area[3]-fy;
dyt[0]= area[4]-fx;
dyt[1]= area[5]-fy;
}
-
+
/* repeat */
if (tex->extend==TEX_REPEAT) {
float max= 1.0f;
if (tex->xrepeat>1) {
float origf= fx *= tex->xrepeat;
-
+
/* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */
if (tex->texfilter == TXF_BOX) {
if (fx>1.0f) fx -= (int)(fx);
else if (fx<0.0f) fx+= 1-(int)(fx);
-
+
if (tex->flag & TEX_REPEAT_XMIR) {
int orig= (int)floor(origf);
if (orig & 1)
fx= 1.0f-fx;
}
}
-
+
max= tex->xrepeat;
-
+
dxt[0]*= tex->xrepeat;
dyt[0]*= tex->xrepeat;
}
if (tex->yrepeat>1) {
float origf= fy *= tex->yrepeat;
-
+
/* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */
if (tex->texfilter == TXF_BOX) {
if (fy>1.0f) fy -= (int)(fy);
else if (fy<0.0f) fy+= 1-(int)(fy);
-
+
if (tex->flag & TEX_REPEAT_YMIR) {
int orig= (int)floor(origf);
if (orig & 1)
fy= 1.0f-fy;
}
}
-
+
if (max<tex->yrepeat)
max= tex->yrepeat;
@@ -913,7 +913,7 @@ static void do_2d_mapping(
dxt[2]*= max;
dyt[2]*= max;
}
-
+
}
/* crop */
if (tex->cropxmin!=0.0f || tex->cropxmax!=1.0f) {
@@ -928,7 +928,7 @@ static void do_2d_mapping(
dxt[1]*= fac1;
dyt[1]*= fac1;
}
-
+
texvec[0]= fx;
texvec[1]= fy;
@@ -953,7 +953,7 @@ static int multitex(Tex *tex,
int retval = 0; /* return value, int:0, col:1, nor:2, everything:3 */
texres->talpha = false; /* is set when image texture returns alpha (considered premul) */
-
+
if (use_nodes && tex->use_nodes && tex->nodetree) {
const float cfra = 1.0f; /* This was only set for Blender Internal render before. */
retval = ntreeTexExecTree(tex->nodetree, texres, texvec, dxt, dyt, osatex, thread,
@@ -1072,7 +1072,7 @@ static int multitex_nodes_intern(Tex *tex,
if (mtex)
which_output= mtex->which_output;
-
+
if (tex->type==TEX_IMAGE) {
int rgbnor;
@@ -1093,7 +1093,7 @@ static int multitex_nodes_intern(Tex *tex,
if (mtex->mapto & (MAP_COL)) {
ImBuf *ibuf = BKE_image_pool_acquire_ibuf(tex->ima, &tex->iuser, pool);
-
+
/* don't linearize float buffers, assumed to be linear */
if (ibuf != NULL &&
ibuf->rect_float == NULL &&
@@ -1110,12 +1110,12 @@ static int multitex_nodes_intern(Tex *tex,
/* we don't have mtex, do default flat 2d projection */
MTex localmtex;
float texvec_l[3], dxt_l[3], dyt_l[3];
-
+
localmtex.mapping= MTEX_FLAT;
localmtex.tex= tex;
localmtex.object= NULL;
localmtex.texco= TEXCO_ORCO;
-
+
copy_v3_v3(texvec_l, texvec);
if (dxt && dyt) {
copy_v3_v3(dxt_l, dxt);
@@ -1125,7 +1125,7 @@ static int multitex_nodes_intern(Tex *tex,
zero_v3(dxt_l);
zero_v3(dyt_l);
}
-
+
do_2d_mapping(&localmtex, texvec_l, NULL, dxt_l, dyt_l);
rgbnor = multitex(tex,
texvec_l,
@@ -1244,7 +1244,7 @@ int multitex_ext_safe(Tex *tex, float texvec[3], TexResult *texres, struct Image
void texture_rgb_blend(float in[3], const float tex[3], const float out[3], float fact, float facg, int blendtype)
{
float facm;
-
+
switch (blendtype) {
case MTEX_BLEND:
fact*= facg;
@@ -1254,7 +1254,7 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
in[1]= (fact*tex[1] + facm*out[1]);
in[2]= (fact*tex[2] + facm*out[2]);
break;
-
+
case MTEX_MUL:
fact*= facg;
facm= 1.0f-fact;
@@ -1274,7 +1274,7 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
case MTEX_OVERLAY:
fact*= facg;
facm= 1.0f-fact;
-
+
if (out[0] < 0.5f)
in[0] = out[0] * (facm + 2.0f*fact*tex[0]);
else
@@ -1288,7 +1288,7 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
else
in[2] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[2])) * (1.0f - out[2]);
break;
-
+
case MTEX_SUB:
fact= -fact;
ATTR_FALLTHROUGH;
@@ -1302,7 +1302,7 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
case MTEX_DIV:
fact*= facg;
facm= 1.0f-fact;
-
+
if (tex[0]!=0.0f)
in[0]= facm*out[0] + fact*out[0]/tex[0];
if (tex[1]!=0.0f)
@@ -1323,7 +1323,7 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
case MTEX_DARK:
fact*= facg;
facm= 1.0f-fact;
-
+
in[0] = min_ff(out[0], tex[0])*fact + out[0]*facm;
in[1] = min_ff(out[1], tex[1])*fact + out[1]*facm;
in[2] = min_ff(out[2], tex[2])*fact + out[2]*facm;
@@ -1336,7 +1336,7 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
in[1] = max_ff(fact * tex[1], out[1]);
in[2] = max_ff(fact * tex[2], out[2]);
break;
-
+
case MTEX_BLEND_HUE:
fact*= facg;
copy_v3_v3(in, out);
@@ -1357,16 +1357,16 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
copy_v3_v3(in, out);
ramp_blend(MA_RAMP_COLOR, in, fact, tex);
break;
- case MTEX_SOFT_LIGHT:
- fact*= facg;
+ case MTEX_SOFT_LIGHT:
+ fact*= facg;
copy_v3_v3(in, out);
ramp_blend(MA_RAMP_SOFT, in, fact, tex);
- break;
- case MTEX_LIN_LIGHT:
- fact*= facg;
+ break;
+ case MTEX_LIN_LIGHT:
+ fact*= facg;
copy_v3_v3(in, out);
ramp_blend(MA_RAMP_LINEAR, in, fact, tex);
- break;
+ break;
}
}
@@ -1376,7 +1376,7 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
int flip= (facg < 0.0f);
facg= fabsf(facg);
-
+
fact*= facg;
facm= 1.0f-fact;
if (flip) SWAP(float, fact, facm);
@@ -1429,19 +1429,19 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
if (col > out) in= col; else in= out;
break;
- case MTEX_SOFT_LIGHT:
+ case MTEX_SOFT_LIGHT:
scf=1.0f - (1.0f - tex) * (1.0f - out);
in= facm*out + fact * ((1.0f - out) * tex * out) + (out * scf);
- break;
+ break;
- case MTEX_LIN_LIGHT:
+ case MTEX_LIN_LIGHT:
if (tex > 0.5f)
in = out + fact*(2.0f*(tex - 0.5f));
- else
+ else
in = out + fact*(2.0f*tex - 1.0f);
break;
}
-
+
return in;
}
@@ -1459,26 +1459,26 @@ int externtex(const MTex *mtex,
TexResult texr;
float dxt[3], dyt[3], texvec[3];
int rgb;
-
+
tex= mtex->tex;
if (tex==NULL) return 0;
texr.nor= NULL;
-
+
/* placement */
if (mtex->projx) texvec[0]= mtex->size[0]*(vec[mtex->projx-1]+mtex->ofs[0]);
else texvec[0]= mtex->size[0]*(mtex->ofs[0]);
-
+
if (mtex->projy) texvec[1]= mtex->size[1]*(vec[mtex->projy-1]+mtex->ofs[1]);
else texvec[1]= mtex->size[1]*(mtex->ofs[1]);
-
+
if (mtex->projz) texvec[2]= mtex->size[2]*(vec[mtex->projz-1]+mtex->ofs[2]);
else texvec[2]= mtex->size[2]*(mtex->ofs[2]);
-
+
/* texture */
if (tex->type==TEX_IMAGE) {
do_2d_mapping(mtex, texvec, NULL, dxt, dyt);
}
-
+
rgb = multitex(tex,
texvec,
dxt, dyt,
@@ -1489,7 +1489,7 @@ int externtex(const MTex *mtex,
skip_load_image,
texnode_preview,
true);
-
+
if (rgb) {
texr.tin = IMB_colormanagement_get_luminance(&texr.tr);
}
@@ -1498,7 +1498,7 @@ int externtex(const MTex *mtex,
texr.tg= mtex->g;
texr.tb= mtex->b;
}
-
+
*tin= texr.tin;
*tr= texr.tr;
*tg= texr.tg;
diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c
new file mode 100644
index 00000000000..2daa4123536
--- /dev/null
+++ b/source/blender/render/intern/source/voxeldata.c
@@ -0,0 +1,571 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Raul Fernandez Hernandez (Farsthary), Matt Ebb.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/render/intern/source/voxeldata.c
+ * \ingroup render
+ */
+
+
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#ifdef WIN32
+#include "BLI_winstuff.h"
+#endif
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+#include "BLI_blenlib.h"
+#include "BLI_threads.h"
+#include "BLI_voxel.h"
+#include "BLI_utildefines.h"
+
+#include "BLT_translation.h"
+
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
+#include "BKE_cloth.h"
+#include "BKE_global.h"
+#include "BKE_image.h"
+#include "BKE_main.h"
+#include "BKE_modifier.h"
+
+#include "smoke_API.h"
+#include "BPH_mass_spring.h"
+
+#include "DNA_texture_types.h"
+#include "DNA_object_force_types.h"
+#include "DNA_object_types.h"
+#include "DNA_particle_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_smoke_types.h"
+
+
+#include "render_types.h"
+#include "texture.h"
+#include "voxeldata.h"
+
+static bool is_vd_res_ok(VoxelData *vd)
+{
+ /* arbitrary large value so corrupt headers don't break */
+ const int min = 1, max = 100000;
+ return (vd->resol[0] >= min && vd->resol[0] <= max) &&
+ (vd->resol[1] >= min && vd->resol[1] <= max) &&
+ (vd->resol[2] >= min && vd->resol[2] <= max);
+}
+
+/* use size_t because the result may exceed INT_MAX */
+static size_t vd_resol_size(VoxelData *vd)
+{
+ return (size_t)vd->resol[0] * (size_t)vd->resol[1] * (size_t)vd->resol[2];
+}
+
+static int load_frame_blendervoxel(VoxelData *vd, FILE *fp, int frame)
+{
+ const size_t size = vd_resol_size(vd);
+ size_t offset = sizeof(VoxelDataHeader);
+
+ if (is_vd_res_ok(vd) == false)
+ return 0;
+
+ vd->dataset = MEM_mapallocN(sizeof(float) * size, "voxel dataset");
+ if (vd->dataset == NULL) return 0;
+
+ if (fseek(fp, frame * size * sizeof(float) + offset, 0) == -1)
+ return 0;
+ if (fread(vd->dataset, sizeof(float), size, fp) != size)
+ return 0;
+
+ vd->cachedframe = frame;
+ vd->ok = 1;
+ return 1;
+}
+
+static int load_frame_raw8(VoxelData *vd, FILE *fp, int frame)
+{
+ const size_t size = vd_resol_size(vd);
+ size_t i;
+ char *data_c;
+
+ if (is_vd_res_ok(vd) == false)
+ return 0;
+
+ vd->dataset = MEM_mapallocN(sizeof(float) * size, "voxel dataset");
+ if (vd->dataset == NULL) return 0;
+ data_c = (char *)MEM_mallocN(sizeof(char) * size, "temporary voxel file reading storage");
+ if (data_c == NULL) {
+ MEM_freeN(vd->dataset);
+ vd->dataset = NULL;
+ return 0;
+ }
+
+ if (fseek(fp, (frame - 1) * size * sizeof(char), 0) == -1) {
+ MEM_freeN(data_c);
+ MEM_freeN(vd->dataset);
+ vd->dataset = NULL;
+ return 0;
+ }
+ if (fread(data_c, sizeof(char), size, fp) != size) {
+ MEM_freeN(data_c);
+ MEM_freeN(vd->dataset);
+ vd->dataset = NULL;
+ return 0;
+ }
+
+ for (i = 0; i < size; i++) {
+ vd->dataset[i] = (float)data_c[i] / 255.f;
+ }
+ MEM_freeN(data_c);
+
+ vd->cachedframe = frame;
+ vd->ok = 1;
+ return 1;
+}
+
+static void load_frame_image_sequence(VoxelData *vd, Tex *tex)
+{
+ ImBuf *ibuf;
+ Image *ima = tex->ima;
+ ImageUser *tiuser = &tex->iuser;
+ ImageUser iuser = *(tiuser);
+ int x = 0, y = 0, z = 0;
+ const float *rf;
+
+ if (!ima) return;
+ if (iuser.frames == 0) return;
+
+ ima->source = IMA_SRC_SEQUENCE;
+ iuser.framenr = 1 + iuser.offset;
+
+ /* find the first valid ibuf and use it to initialize the resolution of the data set */
+ /* need to do this in advance so we know how much memory to allocate */
+ ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
+ while (!ibuf && (iuser.framenr < iuser.frames)) {
+ iuser.framenr++;
+ ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
+ }
+ if (!ibuf) return;
+ if (!ibuf->rect_float) IMB_float_from_rect(ibuf);
+
+ vd->flag |= TEX_VD_STILL;
+ vd->resol[0] = ibuf->x;
+ vd->resol[1] = ibuf->y;
+ vd->resol[2] = iuser.frames;
+ vd->dataset = MEM_mapallocN(sizeof(float) * vd_resol_size(vd), "voxel dataset");
+
+ for (z = 0; z < iuser.frames; z++) {
+ /* get a new ibuf for each frame */
+ if (z > 0) {
+ iuser.framenr++;
+ BKE_image_release_ibuf(ima, ibuf, NULL);
+ ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
+ if (!ibuf) break;
+ if (!ibuf->rect_float) IMB_float_from_rect(ibuf);
+ }
+ rf = ibuf->rect_float;
+
+ for (y = 0; y < ibuf->y; y++) {
+ for (x = 0; x < ibuf->x; x++) {
+ /* currently averaged to monchrome */
+ vd->dataset[BLI_VOXEL_INDEX(x, y, z, vd->resol)] = (rf[0] + rf[1] + rf[2]) / 3.0f;
+ rf += 4;
+ }
+ }
+
+ BKE_image_free_anim_ibufs(ima, iuser.framenr);
+ }
+
+ BKE_image_release_ibuf(ima, ibuf, NULL);
+
+ vd->ok = 1;
+ return;
+}
+
+static int read_voxeldata_header(FILE *fp, struct VoxelData *vd)
+{
+ VoxelDataHeader *h = (VoxelDataHeader *)MEM_mallocN(sizeof(VoxelDataHeader), "voxel data header");
+
+ rewind(fp);
+ if (fread(h, sizeof(VoxelDataHeader), 1, fp) != 1) {
+ MEM_freeN(h);
+ return 0;
+ }
+
+ vd->resol[0] = h->resolX;
+ vd->resol[1] = h->resolY;
+ vd->resol[2] = h->resolZ;
+
+ MEM_freeN(h);
+ return 1;
+}
+
+static void init_frame_smoke(VoxelData *vd, int cfra)
+{
+#ifdef WITH_SMOKE
+ Object *ob;
+ ModifierData *md;
+
+ vd->dataset = NULL;
+ if (vd->object == NULL) return;
+ ob = vd->object;
+
+ /* draw code for smoke */
+ if ((md = (ModifierData *)modifiers_findByType(ob, eModifierType_Smoke))) {
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+ SmokeDomainSettings *sds = smd->domain;
+
+ if (sds && sds->fluid) {
+ BLI_rw_mutex_lock(sds->fluid_mutex, THREAD_LOCK_READ);
+
+ if (!sds->fluid) {
+ BLI_rw_mutex_unlock(sds->fluid_mutex);
+ return;
+ }
+
+ if (cfra < sds->point_cache[0]->startframe)
+ ; /* don't show smoke before simulation starts, this could be made an option in the future */
+ else if (vd->smoked_type == TEX_VD_SMOKEHEAT) {
+ size_t totRes;
+ size_t i;
+ float *heat;
+
+ if (!smoke_has_heat(sds->fluid)) {
+ BLI_rw_mutex_unlock(sds->fluid_mutex);
+ return;
+ }
+
+ copy_v3_v3_int(vd->resol, sds->res);
+ totRes = vd_resol_size(vd);
+ vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data");
+ /* get heat data */
+ heat = smoke_get_heat(sds->fluid);
+
+ /* scale heat values from -2.0-2.0 to 0.0-1.0 */
+ for (i = 0; i < totRes; i++) {
+ vd->dataset[i] = (heat[i] + 2.0f) / 4.0f;
+ }
+ }
+ else if (vd->smoked_type == TEX_VD_SMOKEVEL) {
+ size_t totRes;
+ size_t i;
+ float *xvel, *yvel, *zvel;
+
+ copy_v3_v3_int(vd->resol, sds->res);
+ totRes = vd_resol_size(vd);
+ vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data");
+ /* get velocity data */
+ xvel = smoke_get_velocity_x(sds->fluid);
+ yvel = smoke_get_velocity_y(sds->fluid);
+ zvel = smoke_get_velocity_z(sds->fluid);
+
+ /* map velocities between 0 and 0.3f */
+ for (i = 0; i < totRes; i++) {
+ vd->dataset[i] = sqrtf(xvel[i] * xvel[i] + yvel[i] * yvel[i] + zvel[i] * zvel[i]) * 3.0f;
+ }
+
+ }
+ else if (vd->smoked_type == TEX_VD_SMOKEFLAME) {
+ size_t totRes;
+ float *flame;
+
+ if (sds->flags & MOD_SMOKE_HIGHRES) {
+ if (!smoke_turbulence_has_fuel(sds->wt)) {
+ BLI_rw_mutex_unlock(sds->fluid_mutex);
+ return;
+ }
+ smoke_turbulence_get_res(sds->wt, vd->resol);
+ flame = smoke_turbulence_get_flame(sds->wt);
+ }
+ else {
+ if (!smoke_has_fuel(sds->fluid)) {
+ BLI_rw_mutex_unlock(sds->fluid_mutex);
+ return;
+ }
+ copy_v3_v3_int(vd->resol, sds->res);
+ flame = smoke_get_flame(sds->fluid);
+ }
+
+ /* always store copy, as smoke internal data can change */
+ totRes = vd_resol_size(vd);
+ vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data");
+ memcpy(vd->dataset, flame, sizeof(float)*totRes);
+ }
+ else {
+ size_t totCells;
+ int depth = 4;
+ vd->data_type = TEX_VD_RGBA_PREMUL;
+
+ /* data resolution */
+ if (sds->flags & MOD_SMOKE_HIGHRES) {
+ smoke_turbulence_get_res(sds->wt, vd->resol);
+ }
+ else {
+ copy_v3_v3_int(vd->resol, sds->res);
+ }
+
+ /* TODO: is_vd_res_ok(rvd) doesnt check this resolution */
+ totCells = vd_resol_size(vd) * depth;
+ /* always store copy, as smoke internal data can change */
+ vd->dataset = MEM_mapallocN(sizeof(float) * totCells, "smoke data");
+
+ if (sds->flags & MOD_SMOKE_HIGHRES) {
+ if (smoke_turbulence_has_colors(sds->wt)) {
+ smoke_turbulence_get_rgba(sds->wt, vd->dataset, 1);
+ }
+ else {
+ smoke_turbulence_get_rgba_from_density(sds->wt, sds->active_color, vd->dataset, 1);
+ }
+ }
+ else {
+ if (smoke_has_colors(sds->fluid)) {
+ smoke_get_rgba(sds->fluid, vd->dataset, 1);
+ }
+ else {
+ smoke_get_rgba_from_density(sds->fluid, sds->active_color, vd->dataset, 1);
+ }
+ }
+ } /* end of fluid condition */
+
+ BLI_rw_mutex_unlock(sds->fluid_mutex);
+ }
+ }
+
+ vd->ok = 1;
+
+#else // WITH_SMOKE
+ (void)vd;
+ (void)cfra;
+
+ vd->dataset = NULL;
+#endif
+}
+
+static void init_frame_hair(VoxelData *vd, int UNUSED(cfra))
+{
+ Object *ob;
+ ModifierData *md;
+
+ vd->dataset = NULL;
+ if (vd->object == NULL) return;
+ ob = vd->object;
+
+ if ((md = (ModifierData *)modifiers_findByType(ob, eModifierType_ParticleSystem))) {
+ ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
+
+ if (pmd->psys && pmd->psys->clmd) {
+ vd->ok |= BPH_cloth_solver_get_texture_data(ob, pmd->psys->clmd, vd);
+ }
+ }
+}
+
+void cache_voxeldata(Tex *tex, int scene_frame)
+{
+ VoxelData *vd = tex->vd;
+ FILE *fp;
+ int curframe;
+ char path[sizeof(vd->source_path)];
+
+ /* only re-cache if dataset needs updating */
+ if ((vd->flag & TEX_VD_STILL) || (vd->cachedframe == scene_frame))
+ if (vd->ok) return;
+
+ /* clear out old cache, ready for new */
+ if (vd->dataset) {
+ MEM_freeN(vd->dataset);
+ vd->dataset = NULL;
+ }
+ /* reset data_type */
+ vd->data_type = TEX_VD_INTENSITY;
+
+ if (vd->flag & TEX_VD_STILL)
+ curframe = vd->still_frame;
+ else
+ curframe = scene_frame;
+
+ BLI_strncpy(path, vd->source_path, sizeof(path));
+
+ /* each type is responsible for setting to true */
+ vd->ok = false;
+
+ switch (vd->file_format) {
+ case TEX_VD_IMAGE_SEQUENCE:
+ load_frame_image_sequence(vd, tex);
+ return;
+ case TEX_VD_SMOKE:
+ init_frame_smoke(vd, scene_frame);
+ return;
+ case TEX_VD_HAIR:
+ init_frame_hair(vd, scene_frame);
+ return;
+ case TEX_VD_BLENDERVOXEL:
+ BLI_path_abs(path, BKE_main_blendfile_path_from_global());
+ fp = BLI_fopen(path, "rb");
+ if (!fp) return;
+
+ if (read_voxeldata_header(fp, vd))
+ load_frame_blendervoxel(vd, fp, curframe - 1);
+
+ fclose(fp);
+ return;
+ case TEX_VD_RAW_8BIT:
+ BLI_path_abs(path, BKE_main_blendfile_path_from_global());
+ fp = BLI_fopen(path, "rb");
+ if (!fp) return;
+
+ load_frame_raw8(vd, fp, curframe);
+ fclose(fp);
+ return;
+ }
+}
+
+void make_voxeldata(struct Render *re)
+{
+ Tex *tex;
+
+ re->i.infostr = IFACE_("Loading voxel datasets");
+ re->stats_draw(re->sdh, &re->i);
+
+ /* XXX: should be doing only textures used in this render */
+ for (tex = re->main->tex.first; tex; tex = tex->id.next) {
+ if (tex->id.us && tex->type == TEX_VOXELDATA) {
+ cache_voxeldata(tex, re->r.cfra);
+ }
+ }
+
+ re->i.infostr = NULL;
+ re->stats_draw(re->sdh, &re->i);
+
+}
+
+int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texres)
+{
+ VoxelData *vd = tex->vd;
+ float co[3], offset[3] = {0.5, 0.5, 0.5}, a;
+ int retval = (vd->data_type == TEX_VD_RGBA_PREMUL) ? TEX_RGB : TEX_INT;
+ int depth = (vd->data_type == TEX_VD_RGBA_PREMUL) ? 4 : 1;
+ int ch;
+
+ if (vd->dataset == NULL) {
+ texres->tin = 0.0f;
+ return 0;
+ }
+
+ /* scale lookup from 0.0-1.0 (original location) to -1.0, 1.0, consistent with image texture tex coords */
+ /* in implementation this works backwards, bringing sample locations from -1.0, 1.0
+ * to the range 0.0, 1.0, before looking up in the voxel structure. */
+ copy_v3_v3(co, texvec);
+ mul_v3_fl(co, 0.5f);
+ add_v3_v3(co, offset);
+
+ /* co is now in the range 0.0, 1.0 */
+ switch (vd->extend) {
+ case TEX_CLIP:
+ {
+ if ((co[0] < 0.f || co[0] > 1.f) || (co[1] < 0.f || co[1] > 1.f) || (co[2] < 0.f || co[2] > 1.f)) {
+ texres->tin = 0.f;
+ return retval;
+ }
+ break;
+ }
+ case TEX_REPEAT:
+ {
+ co[0] = co[0] - floorf(co[0]);
+ co[1] = co[1] - floorf(co[1]);
+ co[2] = co[2] - floorf(co[2]);
+ break;
+ }
+ case TEX_EXTEND:
+ {
+ CLAMP(co[0], 0.f, 1.f);
+ CLAMP(co[1], 0.f, 1.f);
+ CLAMP(co[2], 0.f, 1.f);
+ break;
+ }
+ }
+
+ for (ch = 0; ch < depth; ch++) {
+ float *dataset = vd->dataset + ch*vd->resol[0]*vd->resol[1]*vd->resol[2];
+ float *result = &texres->tin;
+
+ if (vd->data_type == TEX_VD_RGBA_PREMUL) {
+ switch (ch) {
+ case 0:
+ result = &texres->tr;
+ break;
+ case 1:
+ result = &texres->tg;
+ break;
+ case 2:
+ result = &texres->tb;
+ break;
+ }
+ }
+
+ switch (vd->interp_type) {
+ case TEX_VD_NEARESTNEIGHBOR:
+ *result = BLI_voxel_sample_nearest(dataset, vd->resol, co);
+ break;
+ case TEX_VD_LINEAR:
+ *result = BLI_voxel_sample_trilinear(dataset, vd->resol, co);
+ break;
+ case TEX_VD_QUADRATIC:
+ *result = BLI_voxel_sample_triquadratic(dataset, vd->resol, co);
+ break;
+ case TEX_VD_TRICUBIC_CATROM:
+ case TEX_VD_TRICUBIC_BSPLINE:
+ *result = BLI_voxel_sample_tricubic(dataset, vd->resol, co, (vd->interp_type == TEX_VD_TRICUBIC_BSPLINE));
+ break;
+ }
+ }
+
+ a = texres->tin;
+ texres->tin *= vd->int_multiplier;
+ BRICONT;
+
+ if (vd->data_type == TEX_VD_RGBA_PREMUL) {
+ /* unmultiply */
+ if (a>0.001f) {
+ texres->tr /= a;
+ texres->tg /= a;
+ texres->tb /= a;
+ }
+ texres->talpha = 1;
+ }
+ else {
+ texres->tr = texres->tin;
+ texres->tg = texres->tin;
+ texres->tb = texres->tin;
+ }
+
+ texres->ta = texres->tin;
+ BRICONTRGB;
+
+ return retval;
+}
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index 3837383c4c7..436ee590f5c 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -54,10 +54,10 @@
void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty)
{
memset(zspan, 0, sizeof(ZSpan));
-
+
zspan->rectx= rectx;
zspan->recty= recty;
-
+
zspan->span1= MEM_mallocN(recty*sizeof(float), "zspan");
zspan->span2= MEM_mallocN(recty*sizeof(float), "zspan");
}
@@ -85,27 +85,27 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
float *span;
float xx1, dx0, xs0;
int y, my0, my2;
-
+
if (v1[1]<v2[1]) {
minv= v1; maxv= v2;
}
else {
minv= v2; maxv= v1;
}
-
+
my0= ceil(minv[1]);
my2= floor(maxv[1]);
-
+
if (my2<0 || my0>= zspan->recty) return;
-
+
/* clip top */
if (my2>=zspan->recty) my2= zspan->recty-1;
/* clip bottom */
if (my0<0) my0= 0;
-
+
if (my0>my2) return;
/* if (my0>my2) should still fill in, that way we get spans that skip nicely */
-
+
xx1= maxv[1]-minv[1];
if (xx1>FLT_EPSILON) {
dx0= (minv[0]-maxv[0])/xx1;
@@ -115,7 +115,7 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
dx0 = 0.0f;
xs0 = min_ff(minv[0], maxv[0]);
}
-
+
/* empty span */
if (zspan->maxp1 == NULL) {
span= zspan->span1;
@@ -158,9 +158,9 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
}
}
-/*-----------------------------------------------------------*/
+/*-----------------------------------------------------------*/
/* Functions */
-/*-----------------------------------------------------------*/
+/*-----------------------------------------------------------*/
/* scanconvert for strand triangles, calls func for each x, y coordinate and gives UV barycentrics and z */
@@ -170,30 +170,30 @@ void zspan_scanconvert(ZSpan *zspan, void *handle, float *v1, float *v2, float *
float u, v, uxd, uyd, vxd, vyd, uy0, vy0, xx1;
const float *span1, *span2;
int i, j, x, y, sn1, sn2, rectx = zspan->rectx, my0, my2;
-
+
/* init */
zbuf_init_span(zspan);
-
+
/* set spans */
zbuf_add_to_span(zspan, v1, v2);
zbuf_add_to_span(zspan, v2, v3);
zbuf_add_to_span(zspan, v3, v1);
-
+
/* clipped */
if (zspan->minp2==NULL || zspan->maxp2==NULL) return;
-
+
my0 = max_ii(zspan->miny1, zspan->miny2);
my2 = min_ii(zspan->maxy1, zspan->maxy2);
-
+
// printf("my %d %d\n", my0, my2);
if (my2<my0) return;
-
+
/* ZBUF DX DY, in floats still */
x1= v1[0]- v2[0];
x2= v2[0]- v3[0];
y1= v1[1]- v2[1];
y2= v2[1]- v3[1];
-
+
z1= 1.0f; /* (u1 - u2) */
z2= 0.0f; /* (u2 - u3) */
@@ -213,28 +213,28 @@ void zspan_scanconvert(ZSpan *zspan, void *handle, float *v1, float *v2, float *
x0= y1*z2-z1*y2;
y0= z1*x2-x1*z2;
-
+
xx1= (x0*v1[0] + y0*v1[1])/z0;
vxd= -(double)x0/(double)z0;
vyd= -(double)y0/(double)z0;
vy0= ((double)my2)*vyd + (double)xx1;
-
+
/* correct span */
span1= zspan->span1+my2;
span2= zspan->span2+my2;
-
+
for (i = 0, y = my2; y >= my0; i++, y--, span1--, span2--) {
-
+
sn1= floor(min_ff(*span1, *span2));
sn2= floor(max_ff(*span1, *span2));
- sn1++;
-
+ sn1++;
+
if (sn2>=rectx) sn2= rectx-1;
if (sn1<0) sn1= 0;
-
+
u = (((double)sn1 * uxd) + uy0) - (i * uyd);
v = (((double)sn1 * vxd) + vy0) - (i * vyd);
-
+
for (j = 0, x = sn1; x <= sn2; j++, x++) {
func(handle, x, y, u + (j * uxd), v + (j * vxd));
}
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index d941ef02ee0..267aa448dc3 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -142,7 +142,7 @@ enum {
struct wmWindow *WM_window_open(struct bContext *C, const struct rcti *rect);
struct wmWindow *WM_window_open_temp(struct bContext *C, int x, int y, int sizex, int sizey, int type);
void WM_window_set_dpi(wmWindow *win);
-
+
bool WM_stereo3d_enabled(struct wmWindow *win, bool only_fullscreen_test);
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index a34862caf0d..9390db400d2 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -58,9 +58,9 @@ void WM_keyconfig_update_operatortype(void);
void WM_keymap_init (struct bContext *C);
void WM_keymap_free (struct wmKeyMap *keymap);
-wmKeyMapItem *WM_keymap_verify_item(struct wmKeyMap *keymap, const char *idname, int type,
+wmKeyMapItem *WM_keymap_verify_item(struct wmKeyMap *keymap, const char *idname, int type,
int val, int modifier, int keymodifier);
-wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, const char *idname, int type,
+wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, const char *idname, int type,
int val, int modifier, int keymodifier);
wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, const char *idname, int type,
int val, int modifier, int keymodifier);
@@ -79,7 +79,7 @@ wmKeyMap *WM_keymap_active(struct wmWindowManager *wm, struct wmKeyMap *keymap);
wmKeyMap *WM_keymap_guess_opname(const struct bContext *C, const char *opname);
bool WM_keymap_remove(struct wmKeyConfig *keyconfig, struct wmKeyMap *keymap);
bool WM_keymap_poll(struct bContext *C, struct wmKeyMap *keymap);
-
+
wmKeyMapItem *WM_keymap_item_find_id(struct wmKeyMap *keymap, int id);
int WM_keymap_item_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2);
diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h
index 2eb07d68afa..30470e17ed4 100644
--- a/source/blender/windowmanager/WM_toolsystem.h
+++ b/source/blender/windowmanager/WM_toolsystem.h
@@ -51,6 +51,9 @@ struct bToolRef *WM_toolsystem_ref_find(struct WorkSpace *workspace, const bTool
bool WM_toolsystem_ref_ensure(
struct WorkSpace *workspace, const bToolKey *tkey,
struct bToolRef **r_tref);
+struct bToolRef *WM_toolsystem_ref_set_by_name(
+ bContext *C, struct WorkSpace *workspace, const bToolKey *tkey,
+ const char *name, bool cycle);
struct bToolRef_Runtime *WM_toolsystem_runtime_from_context(struct bContext *C);
struct bToolRef_Runtime *WM_toolsystem_runtime_find(struct WorkSpace *workspace, const bToolKey *tkey);
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 825948a13a9..929617aab04 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -200,6 +200,7 @@ typedef enum eOperatorPropTags {
#define KM_RELEASE 2
#define KM_CLICK 3
#define KM_DBL_CLICK 4
+#define KM_CLICK_DRAG 5
/* ************** UI Handler ***************** */
@@ -211,14 +212,14 @@ typedef enum eOperatorPropTags {
typedef struct wmNotifier {
struct wmNotifier *next, *prev;
-
+
struct wmWindowManager *wm;
struct wmWindow *window;
-
+
unsigned int category, data, subtype, action;
-
+
void *reference;
-
+
} wmNotifier;
@@ -335,7 +336,7 @@ typedef struct wmNotifier {
/* NC_TEXT Text */
#define ND_CURSOR (50<<16)
#define ND_DISPLAY (51<<16)
-
+
/* NC_ANIMATION Animato */
#define ND_KEYFRAME (70<<16)
#define ND_KEYFRAME_PROP (71<<16)
@@ -433,7 +434,7 @@ typedef struct wmGesture {
uint is_active : 1;
/* Use for gestures that support both immediate or delayed activation. */
uint wait_for_input : 1;
-
+
void *customdata;
/* customdata for border is a recti */
/* customdata for circle is recti, (xmin, ymin) is center, xmax radius */
@@ -451,7 +452,7 @@ typedef struct wmGesture {
/* event comes from eventmanager and from keymap */
typedef struct wmEvent {
struct wmEvent *next, *prev;
-
+
short type; /* event code itself (short, is also in keymap) */
short val; /* press, release, scrollvalue */
int x, y; /* mouse pointer position, screen coord */
@@ -468,13 +469,14 @@ typedef struct wmEvent {
int prevx, prevy;
double prevclicktime;
int prevclickx, prevclicky;
-
+
/* modifier states */
short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
short keymodifier; /* rawkey modifier */
-
+
/* set in case a KM_PRESS went by unhandled */
char check_click;
+ char check_drag;
char is_motion_absolute;
/* keymap item, set by handler (weak?) */
@@ -488,7 +490,7 @@ typedef struct wmEvent {
short customdatafree;
int pad2;
void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */
-
+
} wmEvent;
/* ************** custom wmEvent data ************** */
@@ -527,17 +529,17 @@ typedef enum { /* Timer flags */
typedef struct wmTimer {
struct wmTimer *next, *prev;
-
+
struct wmWindow *win; /* window this timer is attached to (optional) */
double timestep; /* set by timer user */
int event_type; /* set by timer user, goes to event system */
wmTimerFlags flags; /* Various flags controlling timer options, see below. */
void *customdata; /* set by timer user, to allow custom values */
-
+
double duration; /* total running time in seconds */
double delta; /* time since previous step in seconds */
-
+
double ltime; /* internal, last time timer was activated */
double ntime; /* internal, next time we want to activate the timer */
double stime; /* internal, when the timer started */
@@ -653,16 +655,16 @@ typedef enum wmDragFlags {
typedef struct wmDrag {
struct wmDrag *next, *prev;
-
+
int icon, type; /* type, see WM_DRAG defines above */
void *poin;
char path[1024]; /* FILE_MAX */
double value;
-
+
struct ImBuf *imb; /* if no icon but imbuf should be drawn around cursor */
float scale;
int sx, sy;
-
+
char opname[200]; /* if set, draws operator name*/
unsigned int flags;
} wmDrag;
@@ -671,13 +673,13 @@ typedef struct wmDrag {
/* allocation and free is on startup and exit */
typedef struct wmDropBox {
struct wmDropBox *next, *prev;
-
+
/* test if the dropbox is active, then can print optype name */
int (*poll)(struct bContext *, struct wmDrag *, const wmEvent *);
/* before exec, this copies drag info to wmDrop properties */
void (*copy)(struct wmDrag *, struct wmDropBox *);
-
+
/* if poll survives, operator is called */
wmOperatorType *ot; /* not saved in file, so can be pointer */
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index a0ad3950e6b..6a42bf26a97 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -106,7 +106,7 @@ void WM_operator_free(wmOperator *op)
WM_operator_free(opm);
}
}
-
+
MEM_freeN(op);
}
@@ -192,11 +192,11 @@ void wm_operator_register(bContext *C, wmOperator *op)
void WM_operator_stack_clear(wmWindowManager *wm)
{
wmOperator *op;
-
+
while ((op = BLI_pophead(&wm->operators))) {
WM_operator_free(op);
}
-
+
WM_main_add_notifier(NC_WM | ND_HISTORY, NULL);
}
@@ -372,7 +372,7 @@ void WM_keymap_init(bContext *C)
wm->addonconf = WM_keyconfig_new(wm, "Blender Addon");
if (!wm->userconf)
wm->userconf = WM_keyconfig_new(wm, "Blender User");
-
+
/* initialize only after python init is done, for keymaps that
* use python operators */
if (CTX_py_init_get(C) && (wm->initialized & WM_KEYMAP_IS_INITIALIZED) == 0) {
@@ -394,8 +394,9 @@ void WM_keymap_init(bContext *C)
void WM_check(bContext *C)
{
+ Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
-
+
/* wm context */
if (wm == NULL) {
wm = CTX_data_main(C)->wm.first;
@@ -424,7 +425,7 @@ void WM_check(bContext *C)
/* case: fileread */
/* note: this runs in bg mode to set the screen context cb */
if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) {
- ED_screens_initialize(wm);
+ ED_screens_initialize(bmain, wm);
wm->initialized |= WM_WINDOW_IS_INITIALIZED;
}
}
@@ -433,7 +434,7 @@ void wm_clear_default_size(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win;
-
+
/* wm context */
if (wm == NULL) {
wm = CTX_data_main(C)->wm.first;
@@ -443,7 +444,7 @@ void wm_clear_default_size(bContext *C)
if (wm == NULL || BLI_listbase_is_empty(&wm->windows)) {
return;
}
-
+
for (win = wm->windows.first; win; win = win->next) {
win->sizex = 0;
win->sizey = 0;
@@ -489,7 +490,7 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
WM_window_set_active_workspace(win, NULL); /* prevent draw clear to use screen */
wm_window_free(C, wm, win);
}
-
+
while ((op = BLI_pophead(&wm->operators))) {
WM_operator_free(op);
}
@@ -507,7 +508,7 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
BLI_freelistN(&wm->paintcursors);
WM_drag_free_list(&wm->drags);
-
+
wm_reports_free(wm);
if (wm->undo_stack) {
@@ -537,16 +538,16 @@ void WM_main(bContext *C)
wm_event_do_refresh_wm_and_depsgraph(C);
while (1) {
-
+
/* get events from ghost, handle window events, add to window queues */
- wm_window_process_events(C);
-
+ wm_window_process_events(C);
+
/* per window, all events to the window, screen, area and region handlers */
wm_event_do_handlers(C);
-
+
/* events have left notes about changes, we handle and cache it */
wm_event_do_notifiers(C);
-
+
/* execute cached changes draw */
wm_draw_update(C);
}
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index d5f67d81f18..f13dac9cb4c 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -41,7 +41,7 @@
#include "BLI_sys_types.h"
#include "DNA_listBase.h"
-#include "DNA_userdef_types.h"
+#include "DNA_userdef_types.h"
#include "DNA_workspace_types.h"
#include "BKE_context.h"
@@ -58,7 +58,7 @@
/* Some simple ghost <-> blender conversions */
-static GHOST_TStandardCursor convert_cursor(int curs)
+static GHOST_TStandardCursor convert_cursor(int curs)
{
switch (curs) {
default:
@@ -79,23 +79,23 @@ static GHOST_TStandardCursor convert_cursor(int curs)
}
}
-static void window_set_custom_cursor(wmWindow *win, unsigned char mask[16][2],
+static void window_set_custom_cursor(wmWindow *win, unsigned char mask[16][2],
unsigned char bitmap[16][2], int hotx, int hoty)
{
GHOST_SetCustomCursorShape(win->ghostwin, bitmap, mask, hotx, hoty);
}
-static void window_set_custom_cursor_ex(wmWindow *win, BCursor *cursor, int useBig)
+static void window_set_custom_cursor_ex(wmWindow *win, BCursor *cursor, int useBig)
{
if (useBig) {
- GHOST_SetCustomCursorShapeEx(win->ghostwin,
+ GHOST_SetCustomCursorShapeEx(win->ghostwin,
(GHOST_TUns8 *)cursor->big_bm, (GHOST_TUns8 *)cursor->big_mask,
cursor->big_sizex, cursor->big_sizey,
cursor->big_hotx, cursor->big_hoty,
cursor->fg_color, cursor->bg_color);
}
else {
- GHOST_SetCustomCursorShapeEx(win->ghostwin,
+ GHOST_SetCustomCursorShapeEx(win->ghostwin,
(GHOST_TUns8 *)cursor->small_bm, (GHOST_TUns8 *)cursor->small_mask,
cursor->small_sizex, cursor->small_sizey,
cursor->small_hotx, cursor->small_hoty,
@@ -132,12 +132,12 @@ void WM_cursor_set(wmWindow *win, int curs)
#endif
GHOST_SetCursorVisibility(win->ghostwin, 1);
-
+
if (curs == CURSOR_STD && win->modalcursor)
curs = win->modalcursor;
-
+
win->cursor = curs;
-
+
/* detect if we use system cursor or Blender cursor */
if (curs >= BC_GHOST_CURSORS) {
GHOST_SetCursorShape(win->ghostwin, convert_cursor(curs));
@@ -196,7 +196,7 @@ void WM_cursor_wait(bool val)
if (!G.background) {
wmWindowManager *wm = G.main->wm.first;
wmWindow *win = wm ? wm->windows.first : NULL;
-
+
for (; win; win = win->next) {
if (val) {
WM_cursor_modal_set(win, BC_WAITCURSOR);
@@ -214,7 +214,7 @@ void WM_cursor_wait(bool val)
void WM_cursor_grab_enable(wmWindow *win, bool wrap, bool hide, int bounds[4])
{
/* Only grab cursor when not running debug.
- * It helps not to get a stuck WM when hitting a breakpoint
+ * It helps not to get a stuck WM when hitting a breakpoint
* */
GHOST_TGrabCursorMode mode = GHOST_kGrabNormal;
@@ -222,7 +222,7 @@ void WM_cursor_grab_enable(wmWindow *win, bool wrap, bool hide, int bounds[4])
wm_cursor_position_to_ghost(win, &bounds[0], &bounds[1]);
wm_cursor_position_to_ghost(win, &bounds[2], &bounds[3]);
}
-
+
if (hide) {
mode = GHOST_kGrabHide;
}
@@ -311,12 +311,12 @@ void WM_cursor_time(wmWindow *win, int nr)
unsigned char mask[16][2];
unsigned char bitmap[16][2] = {{0}};
int i, idx;
-
+
if (win->lastcursor == 0)
win->lastcursor = win->cursor;
-
+
memset(&mask, 0xFF, sizeof(mask));
-
+
/* print number bottom right justified */
for (idx = 3; nr && idx >= 0; idx--) {
const char *digit = number_bitmaps[nr % 10];
@@ -327,7 +327,7 @@ void WM_cursor_time(wmWindow *win, int nr)
bitmap[i + y * 8][x] = digit[i];
nr /= 10;
}
-
+
window_set_custom_cursor(win, mask, bitmap, 7, 7);
}
@@ -441,7 +441,7 @@ BEGIN_CURSOR_BLOCK
};
BlenderCursor[BC_NS_ARROWCURSOR] = &NSArrowCursor;
-
+
END_CURSOR_BLOCK
/********************** EW_ARROW Cursor *************************/
BEGIN_CURSOR_BLOCK
@@ -462,7 +462,7 @@ BEGIN_CURSOR_BLOCK
static BCursor EWArrowCursor = {
/*small*/
ew_sbm, ew_smsk,
- 16, 16,
+ 16, 16,
7, 6,
/*big*/
NULL, NULL,
@@ -532,7 +532,7 @@ BEGIN_CURSOR_BLOCK
static BCursor WaitCursor = {
/*small*/
wait_sbm, wait_smsk,
- 16, 16,
+ 16, 16,
7, 7,
/*big*/
wait_lbm, wait_lmsk,
@@ -601,7 +601,7 @@ BEGIN_CURSOR_BLOCK
static BCursor CrossCursor = {
/*small*/
cross_sbm, cross_smsk,
- 16, 16,
+ 16, 16,
7, 7,
/*big*/
cross_lbm, cross_lmsk,
@@ -633,7 +633,7 @@ BEGIN_CURSOR_BLOCK
static BCursor EditCrossCursor = {
/*small*/
editcross_sbm, editcross_smsk,
- 16, 16,
+ 16, 16,
9, 8,
/*big*/
NULL, NULL,
@@ -666,7 +666,7 @@ BEGIN_CURSOR_BLOCK
static BCursor BoxSelCursor = {
/*small*/
box_sbm, box_smsk,
- 16, 16,
+ 16, 16,
9, 8,
/*big*/
NULL, NULL,
@@ -738,7 +738,7 @@ BEGIN_CURSOR_BLOCK
static BCursor KnifeCursor = {
/*small*/
knife_sbm, knife_smsk,
- 16, 16,
+ 16, 16,
0, 15,
/*big*/
knife_lbm, knife_lmsk,
@@ -751,7 +751,7 @@ BEGIN_CURSOR_BLOCK
BlenderCursor[BC_KNIFECURSOR] = &KnifeCursor;
END_CURSOR_BLOCK
-
+
/********************** Loop Select Cursor ***********************/
BEGIN_CURSOR_BLOCK
@@ -814,7 +814,7 @@ BEGIN_CURSOR_BLOCK
static BCursor VLoopCursor = {
/*small*/
vloop_sbm, vloop_smsk,
- 16, 16,
+ 16, 16,
0, 0,
/*big*/
vloop_lbm, vloop_lmsk,
@@ -827,7 +827,7 @@ BEGIN_CURSOR_BLOCK
BlenderCursor[BC_VLOOPCURSOR] = &VLoopCursor;
END_CURSOR_BLOCK
-
+
/********************** TextEdit Cursor ***********************/
BEGIN_CURSOR_BLOCK
@@ -848,7 +848,7 @@ BEGIN_CURSOR_BLOCK
static BCursor TextEditCursor = {
/*small*/
textedit_sbm, textedit_smsk,
- 16, 16,
+ 16, 16,
9, 8,
/*big*/
NULL, NULL,
@@ -887,7 +887,7 @@ BEGIN_CURSOR_BLOCK
static BCursor PaintBrushCursor = {
/*small*/
paintbrush_sbm, paintbrush_smsk,
- 16, 16,
+ 16, 16,
0, 15,
/*big*/
NULL, NULL,
@@ -1060,7 +1060,7 @@ BEGIN_CURSOR_BLOCK
0x7e, 0x00, 0x3f, 0x00, 0x0c, 0x00, 0x04, 0x00,
};
-
+
static BCursor EyedropperCursor = {
/*small*/
eyedropper_sbm, eyedropper_smsk,
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c
index 05d9689565c..16ed51cbd80 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2010 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -69,29 +69,29 @@ static ListBase dropboxes = {NULL, NULL};
typedef struct wmDropBoxMap {
struct wmDropBoxMap *next, *prev;
-
+
ListBase dropboxes;
short spaceid, regionid;
char idname[KMAP_MAX_NAME];
-
+
} wmDropBoxMap;
/* spaceid/regionid is zero for window drop maps */
ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
{
wmDropBoxMap *dm;
-
+
for (dm = dropboxes.first; dm; dm = dm->next)
if (dm->spaceid == spaceid && dm->regionid == regionid)
if (STREQLEN(idname, dm->idname, KMAP_MAX_NAME))
return &dm->dropboxes;
-
+
dm = MEM_callocN(sizeof(struct wmDropBoxMap), "dropmap list");
BLI_strncpy(dm->idname, idname, KMAP_MAX_NAME);
dm->spaceid = spaceid;
dm->regionid = regionid;
BLI_addtail(&dropboxes, dm);
-
+
return &dm->dropboxes;
}
@@ -101,31 +101,31 @@ wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, int (*poll)(bContext
void (*copy)(wmDrag *, wmDropBox *))
{
wmDropBox *drop = MEM_callocN(sizeof(wmDropBox), "wmDropBox");
-
+
drop->poll = poll;
drop->copy = copy;
drop->ot = WM_operatortype_find(idname, 0);
drop->opcontext = WM_OP_INVOKE_DEFAULT;
-
+
if (drop->ot == NULL) {
MEM_freeN(drop);
printf("Error: dropbox with unknown operator: %s\n", idname);
return NULL;
}
WM_operator_properties_alloc(&(drop->ptr), &(drop->properties), idname);
-
+
BLI_addtail(lb, drop);
-
+
return drop;
}
void wm_dropbox_free(void)
{
wmDropBoxMap *dm;
-
+
for (dm = dropboxes.first; dm; dm = dm->next) {
wmDropBox *drop;
-
+
for (drop = dm->dropboxes.first; drop; drop = drop->next) {
if (drop->ptr) {
WM_operator_properties_free(drop->ptr);
@@ -134,7 +134,7 @@ void wm_dropbox_free(void)
}
BLI_freelistN(&dm->dropboxes);
}
-
+
BLI_freelistN(&dropboxes);
}
@@ -145,10 +145,10 @@ wmDrag *WM_event_start_drag(struct bContext *C, int icon, int type, void *poin,
{
wmWindowManager *wm = CTX_wm_manager(C);
wmDrag *drag = MEM_callocN(sizeof(struct wmDrag), "new drag");
-
+
/* keep track of future multitouch drag too, add a mousepointer id or so */
/* if multiple drags are added, they're drawn as list */
-
+
BLI_addtail(&wm->drags, drag);
drag->flags = flags;
drag->icon = icon;
@@ -158,7 +158,7 @@ wmDrag *WM_event_start_drag(struct bContext *C, int icon, int type, void *poin,
else
drag->poin = poin;
drag->value = value;
-
+
return drag;
}
@@ -211,13 +211,13 @@ static const char *wm_dropbox_active(bContext *C, wmDrag *drag, const wmEvent *e
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
const char *name;
-
+
name = dropbox_active(C, &win->handlers, drag, event);
if (name) return name;
-
+
name = dropbox_active(C, &sa->handlers, drag, event);
if (name) return name;
-
+
name = dropbox_active(C, &ar->handlers, drag, event);
if (name) return name;
@@ -234,16 +234,16 @@ static void wm_drop_operator_options(bContext *C, wmDrag *drag, const wmEvent *e
/* for multiwin drags, we only do this if mouse inside */
if (event->x < 0 || event->y < 0 || event->x > winsize_x || event->y > winsize_y)
return;
-
+
drag->opname[0] = 0;
-
+
/* check buttons (XXX todo rna and value) */
if (UI_but_active_drop_name(C)) {
BLI_strncpy(drag->opname, IFACE_("Paste name"), sizeof(drag->opname));
}
else {
const char *opname = wm_dropbox_active(C, drag, event);
-
+
if (opname) {
BLI_strncpy(drag->opname, opname, sizeof(drag->opname));
// WM_cursor_modal_set(win, CURSOR_COPY);
@@ -259,7 +259,7 @@ void wm_drags_check_ops(bContext *C, const wmEvent *event)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmDrag *drag;
-
+
for (drag = wm->drags.first; drag; drag = drag->next) {
wm_drop_operator_options(C, drag, event);
}
@@ -312,25 +312,25 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
wmDrag *drag;
const int winsize_y = WM_window_pixels_y(win);
int cursorx, cursory, x, y;
-
+
cursorx = win->eventstate->x;
cursory = win->eventstate->y;
if (rect) {
rect->xmin = rect->xmax = cursorx;
rect->ymin = rect->ymax = cursory;
}
-
+
/* XXX todo, multiline drag draws... but maybe not, more types mixed wont work well */
glEnable(GL_BLEND);
for (drag = wm->drags.first; drag; drag = drag->next) {
int iconsize = UI_DPI_ICON_SIZE;
int padding = 4 * UI_DPI_FAC;
-
+
/* image or icon */
if (drag->imb) {
x = cursorx - drag->sx / 2;
y = cursory - drag->sy / 2;
-
+
if (rect)
drag_rect_minmax(rect, x, y, x + drag->sx, y + drag->sy);
else {
@@ -343,13 +343,13 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
else {
x = cursorx - 2 * padding;
y = cursory - 2 * UI_DPI_FAC;
-
+
if (rect)
drag_rect_minmax(rect, x, y, x + iconsize, y + iconsize);
else
UI_icon_draw_aspect(x, y, drag->icon, 1.0f / UI_DPI_FAC, 0.8);
}
-
+
/* item name */
if (drag->imb) {
x = cursorx - drag->sx / 2;
@@ -359,7 +359,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
x = cursorx + 10 * UI_DPI_FAC;
y = cursory + 1 * UI_DPI_FAC;
}
-
+
if (rect) {
int w = UI_fontstyle_string_width(fstyle, wm_drag_name(drag));
drag_rect_minmax(rect, x, y, x + w, y + iconsize);
@@ -368,7 +368,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
const unsigned char col[] = {255, 255, 255, 255};
UI_fontstyle_draw_simple(fstyle, x, y, wm_drag_name(drag), col);
}
-
+
/* operator name with roundbox */
if (drag->opname[0]) {
if (drag->imb) {
@@ -389,14 +389,14 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
y = (cursory - iconsize) - padding;
}
}
-
+
if (rect) {
int w = UI_fontstyle_string_width(fstyle, wm_drag_name(drag));
drag_rect_minmax(rect, x, y, x + w, y + iconsize);
}
- else
+ else
wm_drop_operator_draw(drag->opname, x, y);
-
+
}
}
glDisable(GL_BLEND);
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index af70b3f1a5b..5efe9330f52 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -50,6 +50,7 @@
#include "BKE_context.h"
#include "BKE_image.h"
+#include "BKE_main.h"
#include "BKE_screen.h"
#include "BKE_scene.h"
#include "BKE_workspace.h"
@@ -118,7 +119,7 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar)
}
-static bool wm_draw_region_stereo_set(ScrArea *sa, ARegion *ar, eStereoViews sview)
+static bool wm_draw_region_stereo_set(Main *bmain, ScrArea *sa, ARegion *ar, eStereoViews sview)
{
/* We could detect better when stereo is actually needed, by inspecting the
* image in the image editor and sequencer. */
@@ -149,7 +150,7 @@ static bool wm_draw_region_stereo_set(ScrArea *sa, ARegion *ar, eStereoViews svi
{
SpaceNode *snode = sa->spacedata.first;
if ((snode->flag & SNODE_BACKDRAW) && ED_node_is_compositor(snode)) {
- Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ima->eye = sview;
return true;
}
@@ -251,7 +252,7 @@ static void wm_draw_callbacks(wmWindow *win)
/************************* Region drawing. ********************************
- *
+ *
* Each region draws into its own framebuffer, which is then blit on the
* window draw buffer. This helps with fast redrawing if only some regions
* change. It also means we can share a single context for multiple windows,
@@ -488,6 +489,7 @@ GPUViewport *WM_draw_region_get_bound_viewport(ARegion *ar)
static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
{
+ Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
bScreen *screen = WM_window_get_active_screen(win);
@@ -512,7 +514,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
CTX_wm_region_set(C, ar);
bool use_viewport = wm_region_use_viewport(sa, ar);
- if (stereo && wm_draw_region_stereo_set(sa, ar, STEREO_LEFT_ID)) {
+ if (stereo && wm_draw_region_stereo_set(bmain, sa, ar, STEREO_LEFT_ID)) {
wm_draw_region_buffer_create(ar, true, use_viewport);
for (int view = 0; view < 2; view++) {
@@ -522,7 +524,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
}
else {
sview = STEREO_RIGHT_ID;
- wm_draw_region_stereo_set(sa, ar, sview);
+ wm_draw_region_stereo_set(bmain, sa, ar, sview);
}
wm_draw_region_bind(ar, view);
@@ -755,7 +757,7 @@ static bool wm_draw_update_test_window(wmWindow *win)
if (do_draw)
return true;
-
+
if (screen->do_refresh)
return true;
if (screen->do_draw)
@@ -766,7 +768,7 @@ static bool wm_draw_update_test_window(wmWindow *win)
return true;
if (screen->do_draw_drag)
return true;
-
+
return false;
}
@@ -788,7 +790,7 @@ void wm_draw_update(bContext *C)
#endif
GPU_free_unused_buffers();
-
+
for (win = wm->windows.first; win; win = win->next) {
#ifdef WIN32
GHOST_TWindowState state = GHOST_GetWindowState(win->ghostwin);
@@ -806,7 +808,7 @@ void wm_draw_update(bContext *C)
bScreen *screen = WM_window_get_active_screen(win);
CTX_wm_window_set(C, win);
-
+
/* sets context window+screen */
wm_window_make_drawable(wm, win);
@@ -818,7 +820,7 @@ void wm_draw_update(bContext *C)
screen->do_draw_gesture = false;
screen->do_draw_paintcursor = false;
screen->do_draw_drag = false;
-
+
wm_window_swap_buffers(win);
CTX_wm_window_set(C, NULL);
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index c800370a85d..ffef33d344a 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -105,7 +105,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA
wmEvent *wm_event_add_ex(wmWindow *win, const wmEvent *event_to_add, const wmEvent *event_to_add_after)
{
wmEvent *event = MEM_mallocN(sizeof(wmEvent), "wmEvent");
-
+
*event = *event_to_add;
update_tablet_data(win, event);
@@ -157,7 +157,7 @@ void wm_event_free(wmEvent *event)
void wm_event_free_all(wmWindow *win)
{
wmEvent *event;
-
+
while ((event = BLI_pophead(&win->queue))) {
wm_event_free(event);
}
@@ -180,7 +180,7 @@ static bool wm_test_duplicate_notifier(wmWindowManager *wm, unsigned int type, v
for (note = wm->queue.first; note; note = note->next)
if ((note->category | note->data | note->subtype | note->action) == type && note->reference == reference)
return 1;
-
+
return 0;
}
@@ -194,17 +194,17 @@ void WM_event_add_notifier(const bContext *C, unsigned int type, void *reference
return;
note = MEM_callocN(sizeof(wmNotifier), "notifier");
-
+
note->wm = wm;
BLI_addtail(&note->wm->queue, note);
-
+
note->window = CTX_wm_window(C);
-
+
note->category = type & NOTE_CATEGORY;
note->data = type & NOTE_DATA;
note->subtype = type & NOTE_SUBTYPE;
note->action = type & NOTE_ACTION;
-
+
note->reference = reference;
}
@@ -218,15 +218,15 @@ void WM_main_add_notifier(unsigned int type, void *reference)
return;
note = MEM_callocN(sizeof(wmNotifier), "notifier");
-
+
note->wm = wm;
BLI_addtail(&note->wm->queue, note);
-
+
note->category = type & NOTE_CATEGORY;
note->data = type & NOTE_DATA;
note->subtype = type & NOTE_SUBTYPE;
note->action = type & NOTE_ACTION;
-
+
note->reference = reference;
}
@@ -353,7 +353,7 @@ void wm_event_do_notifiers(bContext *C)
wmWindowManager *wm = CTX_wm_manager(C);
wmNotifier *note, *next;
wmWindow *win;
-
+
if (wm == NULL)
return;
@@ -363,9 +363,9 @@ void wm_event_do_notifiers(bContext *C)
for (win = wm->windows.first; win; win = win->next) {
Scene *scene = WM_window_get_active_scene(win);
bool do_anim = false;
-
+
CTX_wm_window_set(C, win);
-
+
for (note = wm->queue.first; note; note = next) {
next = note->next;
@@ -443,7 +443,7 @@ void wm_event_do_notifiers(bContext *C)
}
}
}
-
+
/* the notifiers are sent without context, to keep it clean */
while ((note = BLI_pophead(&wm->queue))) {
for (win = wm->windows.first; win; win = win->next) {
@@ -484,7 +484,7 @@ void wm_event_do_notifiers(bContext *C)
}
}
}
-
+
MEM_freeN(note);
}
#endif /* if 1 (postpone disabling for in favor of message-bus), eventually. */
@@ -517,8 +517,8 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, const wmEven
static bool do_wheel_ui = true;
const bool is_wheel = ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE, MOUSEPAN);
int retval;
-
- /* UI code doesn't handle return values - it just always returns break.
+
+ /* UI code doesn't handle return values - it just always returns break.
* to make the DBL_CLICK conversion work, we just don't send this to UI, except mouse clicks */
if (((handler->flag & WM_HANDLER_ACCEPT_DBL_CLICK) == 0) &&
(event->type != LEFTMOUSE) &&
@@ -526,7 +526,7 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, const wmEven
{
return WM_HANDLER_CONTINUE;
}
-
+
/* UI is quite aggressive with swallowing events, like scrollwheel */
/* I realize this is not extremely nice code... when UI gets keymaps it can be maybe smarter */
if (do_wheel_ui == false) {
@@ -535,7 +535,7 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, const wmEven
else if (wm_event_always_pass(event) == 0)
do_wheel_ui = true;
}
-
+
/* we set context to where ui handler came from */
if (handler->ui_area) CTX_wm_area_set(C, handler->ui_area);
if (handler->ui_region) CTX_wm_region_set(C, handler->ui_region);
@@ -555,14 +555,14 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, const wmEven
CTX_wm_region_set(C, NULL);
CTX_wm_menu_set(C, NULL);
}
-
+
if (retval == WM_UI_HANDLER_BREAK)
return WM_HANDLER_BREAK;
-
+
/* event not handled in UI, if wheel then we temporarily disable it */
if (is_wheel)
do_wheel_ui = false;
-
+
return WM_HANDLER_CONTINUE;
}
@@ -593,14 +593,14 @@ static void wm_handler_ui_cancel(bContext *C)
int WM_operator_poll(bContext *C, wmOperatorType *ot)
{
wmOperatorTypeMacro *otmacro;
-
+
for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) {
wmOperatorType *ot_macro = WM_operatortype_find(otmacro->idname, 0);
-
+
if (0 == WM_operator_poll(C, ot_macro))
return 0;
}
-
+
/* python needs operator type, so we added exception for it */
if (ot->pyop_poll)
return ot->pyop_poll(C, ot);
@@ -807,7 +807,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, bool ca
CTX_wm_region_set(C, ar_prev);
}
}
-
+
if (retval & OPERATOR_FINISHED) {
CLOG_STR_INFO_N(WM_LOG_OPERATORS, 1, WM_operator_pystring(C, op, false, true));
@@ -885,15 +885,15 @@ static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, cons
{
wmWindowManager *wm = CTX_wm_manager(C);
int retval = OPERATOR_CANCELLED;
-
+
CTX_wm_operator_poll_msg_set(C, NULL);
-
+
if (op == NULL || op->type == NULL)
return retval;
-
+
if (0 == WM_operator_poll(C, op->type))
return retval;
-
+
if (op->type->exec) {
if (op->type->flag & OPTYPE_UNDO) {
wm->op_undo_depth++;
@@ -912,13 +912,13 @@ static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, cons
wm->op_undo_depth--;
}
}
-
+
/* XXX Disabled the repeat check to address part 2 of #31840.
* Carefully checked all calls to wm_operator_exec and WM_operator_repeat, don't see any reason
* why this was needed, but worth to note it in case something turns bad. (mont29) */
if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED) /* && repeat == 0 */)
wm_operator_reports(C, op, retval, false);
-
+
if (retval & OPERATOR_FINISHED) {
wm_operator_finished(C, op, repeat, store && wm->op_undo_depth == 0);
}
@@ -928,9 +928,9 @@ static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, cons
WM_operator_free(op);
}
}
-
+
return retval | OPERATOR_HANDLED;
-
+
}
/* simply calls exec with basic checks */
@@ -1033,11 +1033,11 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot,
{
/* XXX operatortype names are static still. for debug */
wmOperator *op = MEM_callocN(sizeof(wmOperator), ot->idname);
-
+
/* XXX adding new operator could be function, only happens here now */
op->type = ot;
BLI_strncpy(op->idname, ot->idname, OP_MAX_TYPENAME);
-
+
/* initialize properties, either copy or create */
op->ptr = MEM_callocN(sizeof(PointerRNA), "wmOperatorPtrRNA");
if (properties && properties->data) {
@@ -1057,20 +1057,20 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot,
op->reports = MEM_mallocN(sizeof(ReportList), "wmOperatorReportList");
BKE_reports_init(op->reports, RPT_STORE | RPT_FREE);
}
-
+
/* recursive filling of operator macro list */
if (ot->macro.first) {
static wmOperator *motherop = NULL;
wmOperatorTypeMacro *otmacro;
int root = 0;
-
+
/* ensure all ops are in execution order in 1 list */
if (motherop == NULL) {
motherop = op;
root = 1;
}
-
+
/* if properties exist, it will contain everything needed */
if (properties) {
otmacro = ot->macro.first;
@@ -1106,11 +1106,11 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot,
opm->opm = motherop; /* pointer to mom, for modal() */
}
}
-
+
if (root)
motherop = NULL;
}
-
+
WM_operator_properties_sanitize(op->ptr, 0);
return op;
@@ -1250,7 +1250,7 @@ static int wm_operator_invoke(
wmWindowManager *wm = CTX_wm_manager(C);
wmOperator *op = wm_operator_create(wm, ot, properties, reports); /* if reports == NULL, they'll be initialized */
const bool is_nested_call = (wm->op_undo_depth != 0);
-
+
if (event != NULL) {
op->flag |= OP_IS_INVOKE;
}
@@ -1380,7 +1380,7 @@ static int wm_operator_invoke(
/**
* #WM_operator_name_call is the main accessor function
* this is for python to access since its done the operator lookup
- *
+ *
* invokes operator in context
*/
static int wm_operator_call_internal(
@@ -1388,7 +1388,7 @@ static int wm_operator_call_internal(
const short context, const bool poll_only)
{
wmEvent *event;
-
+
int retval;
CTX_wm_operator_poll_msg_set(C, NULL);
@@ -1421,39 +1421,39 @@ static int wm_operator_call_internal(
}
switch (context) {
-
+
case WM_OP_EXEC_REGION_WIN:
- case WM_OP_INVOKE_REGION_WIN:
+ case WM_OP_INVOKE_REGION_WIN:
case WM_OP_EXEC_REGION_CHANNELS:
case WM_OP_INVOKE_REGION_CHANNELS:
case WM_OP_EXEC_REGION_PREVIEW:
case WM_OP_INVOKE_REGION_PREVIEW:
{
/* forces operator to go to the region window/channels/preview, for header menus
- * but we stay in the same region if we are already in one
+ * but we stay in the same region if we are already in one
*/
ARegion *ar = CTX_wm_region(C);
ScrArea *area = CTX_wm_area(C);
int type = RGN_TYPE_WINDOW;
-
+
switch (context) {
case WM_OP_EXEC_REGION_CHANNELS:
case WM_OP_INVOKE_REGION_CHANNELS:
type = RGN_TYPE_CHANNELS;
break;
-
+
case WM_OP_EXEC_REGION_PREVIEW:
case WM_OP_INVOKE_REGION_PREVIEW:
type = RGN_TYPE_PREVIEW;
break;
-
+
case WM_OP_EXEC_REGION_WIN:
- case WM_OP_INVOKE_REGION_WIN:
+ case WM_OP_INVOKE_REGION_WIN:
default:
type = RGN_TYPE_WINDOW;
break;
}
-
+
if (!(ar && ar->regiontype == type) && area) {
ARegion *ar1;
if (type == RGN_TYPE_WINDOW) {
@@ -1466,12 +1466,12 @@ static int wm_operator_call_internal(
if (ar1)
CTX_wm_region_set(C, ar1);
}
-
+
retval = wm_operator_invoke(C, ot, event, properties, reports, poll_only, true);
-
+
/* set region back */
CTX_wm_region_set(C, ar);
-
+
return retval;
}
case WM_OP_EXEC_AREA:
@@ -1506,7 +1506,7 @@ static int wm_operator_call_internal(
return wm_operator_invoke(C, ot, event, properties, reports, poll_only, true);
}
}
-
+
return 0;
}
@@ -1582,7 +1582,7 @@ int WM_operator_call_py(
if (!is_undo && wm) wm->op_undo_depth++;
retval = wm_operator_call_internal(C, ot, properties, reports, context, false);
-
+
if (!is_undo && wm && (wm == CTX_wm_manager(C))) wm->op_undo_depth--;
return retval;
@@ -1602,7 +1602,7 @@ static void wm_handler_op_context(bContext *C, wmEventHandler *handler, const wm
{
wmWindow *win = CTX_wm_window(C);
bScreen *screen = CTX_wm_screen(C);
-
+
if (screen && handler->op) {
if (handler->op_area == NULL)
CTX_wm_area_set(C, NULL);
@@ -1659,7 +1659,7 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers)
{
wmEventHandler *handler;
wmWindowManager *wm = CTX_wm_manager(C);
-
+
/* C is zero on freeing database, modal handlers then already were freed */
while ((handler = BLI_pophead(handlers))) {
if (handler->op) {
@@ -1667,7 +1667,7 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers)
if (handler->op->type->cancel) {
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
-
+
wm_handler_op_context(C, handler, win->eventstate);
if (handler->op->type->flag & OPTYPE_UNDO)
@@ -1689,7 +1689,7 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers)
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
ARegion *menu = CTX_wm_menu(C);
-
+
if (handler->ui_area) CTX_wm_area_set(C, handler->ui_area);
if (handler->ui_region) CTX_wm_region_set(C, handler->ui_region);
if (handler->ui_menu) CTX_wm_menu_set(C, handler->ui_menu);
@@ -1722,7 +1722,7 @@ int WM_userdef_event_map(int kmitype)
case WHEELINMOUSE:
return (U.uiflag & USER_WHEELZOOMDIR) ? WHEELDOWNMOUSE : WHEELUPMOUSE;
}
-
+
return kmitype;
}
@@ -1768,13 +1768,13 @@ static int wm_eventmatch(const wmEvent *winevent, wmKeyMapItem *kmi)
if (winevent->val == KM_PRESS) { /* prevent double clicks */
/* NOT using ISTEXTINPUT anymore because (at least on Windows) some key codes above 255
* could have printable ascii keys - BUG [#30479] */
- if (ISKEYBOARD(winevent->type) && (winevent->ascii || winevent->utf8_buf[0])) return 1;
+ if (ISKEYBOARD(winevent->type) && (winevent->ascii || winevent->utf8_buf[0])) return 1;
}
if (kmitype != KM_ANY) {
if (ELEM(kmitype, TABLET_STYLUS, TABLET_ERASER)) {
const wmTabletData *wmtab = winevent->tablet_data;
-
+
if (wmtab == NULL)
return 0;
else if (winevent->type != LEFTMOUSE) /* tablet events can occur on hover + keypress */
@@ -1789,10 +1789,10 @@ static int wm_eventmatch(const wmEvent *winevent, wmKeyMapItem *kmi)
return 0;
}
}
-
+
if (kmi->val != KM_ANY)
if (winevent->val != kmi->val) return 0;
-
+
/* modifiers also check bits, so it allows modifier order */
if (kmi->shift != KM_ANY)
if (winevent->shift != kmi->shift && !(winevent->shift & kmi->shift)) return 0;
@@ -1802,12 +1802,12 @@ static int wm_eventmatch(const wmEvent *winevent, wmKeyMapItem *kmi)
if (winevent->alt != kmi->alt && !(winevent->alt & kmi->alt)) return 0;
if (kmi->oskey != KM_ANY)
if (winevent->oskey != kmi->oskey && !(winevent->oskey & kmi->oskey)) return 0;
-
+
/* only keymap entry with keymodifier is checked, means all keys without modifier get handled too. */
/* that is currently needed to make overlapping events work (when you press A - G fast or so). */
if (kmi->keymodifier)
if (winevent->keymodifier != kmi->keymodifier) return 0;
-
+
return 1;
}
@@ -1825,12 +1825,12 @@ static void wm_event_modalkeymap(const bContext *C, wmOperator *op, wmEvent *eve
for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
if (wm_eventmatch(event, kmi)) {
-
+
event->prevtype = event->type;
event->prevval = event->val;
event->type = EVT_MODAL_MAP;
event->val = kmi->propvalue;
-
+
break;
}
}
@@ -1883,7 +1883,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
wmEvent *event, PointerRNA *properties)
{
int retval = OPERATOR_PASS_THROUGH;
-
+
/* derived, modal or blocking operator */
if (handler->op) {
wmOperator *op = handler->op;
@@ -1911,7 +1911,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
/* warning, after this call all context data and 'event' may be freed. see check below */
retval = ot->modal(C, op, event);
OPERATOR_RETVAL_CHECK(retval);
-
+
/* when this is _not_ the case the modal modifier may have loaded
* a new blend file (demo mode does this), so we have to assume
* the event, operator etc have all been freed. - campbell */
@@ -1979,7 +1979,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
bool use_last_properties = true;
PointerRNA tool_properties = {{0}};
bool use_tool_properties = (handler->keymap_tool != NULL);
-
+
if (use_tool_properties) {
WM_toolsystem_ref_properties_init_for_keymap(handler->keymap_tool, &tool_properties, properties, ot);
properties = &tool_properties;
@@ -2058,11 +2058,11 @@ static int wm_handler_fileselect_do(bContext *C, ListBase *handlers, wmEventHand
sfile->op = handler->op;
ED_fileselect_set_params(sfile);
-
+
action = WM_HANDLER_BREAK;
break;
}
-
+
case EVT_FILESELECT_EXEC:
case EVT_FILESELECT_CANCEL:
case EVT_FILESELECT_EXTERNAL_CANCEL:
@@ -2150,11 +2150,11 @@ static int wm_handler_fileselect_do(bContext *C, ListBase *handlers, wmEventHand
wm->op_undo_depth++;
handler->op->type->cancel(C, handler->op);
-
+
if (handler->op->type->flag & OPTYPE_UNDO)
wm->op_undo_depth--;
}
-
+
WM_operator_free(handler->op);
}
@@ -2166,19 +2166,19 @@ static int wm_handler_fileselect_do(bContext *C, ListBase *handlers, wmEventHand
break;
}
}
-
+
return action;
}
static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHandler *handler, const wmEvent *event)
{
int action = WM_HANDLER_CONTINUE;
-
+
if (event->type != EVT_FILESELECT)
return action;
if (handler->op != (wmOperator *)event->customdata)
return action;
-
+
return wm_handler_fileselect_do(C, handlers, handler, event->val);
}
@@ -2239,7 +2239,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
for (handler = handlers->first; handler && handlers->first; handler = nexthandler) {
nexthandler = handler->next;
-
+
/* during this loop, ui handlers for nested menus can tag multiple handlers free */
if (handler->flag & WM_HANDLER_DO_FREE) {
/* pass */
@@ -2247,7 +2247,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
else if (handler_boundbox_test(handler, event)) { /* optional boundbox */
/* in advance to avoid access to freed event on window close */
always_pass = wm_event_always_pass(event);
-
+
/* modal+blocking handler */
if (handler->flag & WM_HANDLER_BLOCKING)
action |= WM_HANDLER_BREAK;
@@ -2272,7 +2272,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
event->keymap_idname = kmi->idname;
action |= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr);
-
+
if (action & WM_HANDLER_BREAK) {
/* not always_pass here, it denotes removed handler */
CLOG_INFO(WM_LOG_HANDLERS, 2, "handled! '%s'", kmi->idname);
@@ -2315,24 +2315,24 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
if (event->custom == EVT_DATA_DRAGDROP) {
ListBase *lb = (ListBase *)event->customdata;
wmDrag *drag;
-
+
for (drag = lb->first; drag; drag = drag->next) {
if (drop->poll(C, drag, event)) {
drop->copy(drag, drop);
-
+
/* free the drags before calling operator */
WM_drag_free_list(lb);
event->customdata = NULL;
event->custom = 0;
-
+
WM_operator_name_call_ptr(C, drop->ot, drop->opcontext, drop->ptr);
action |= WM_HANDLER_BREAK;
-
+
/* XXX fileread case */
if (CTX_wm_window(C) == NULL)
return action;
-
+
/* escape from drag loop, got freed */
break;
}
@@ -2491,7 +2491,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
break;
}
}
-
+
/* XXX fileread case, if the wm is freed then the handler's
* will have been too so the code below need not run. */
if (CTX_wm_window(C) == NULL) {
@@ -2499,8 +2499,8 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
}
/* XXX code this for all modal ops, and ensure free only happens here */
-
- /* modal ui handler can be tagged to be freed */
+
+ /* modal ui handler can be tagged to be freed */
if (BLI_findindex(handlers, handler) != -1) { /* could be freed already by regular modal ops */
if (handler->flag & WM_HANDLER_DO_FREE) {
BLI_remlink(handlers, handler);
@@ -2521,26 +2521,56 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
{
int action = wm_handlers_do_intern(C, event, handlers);
-
+
/* fileread case */
if (CTX_wm_window(C) == NULL)
return action;
- if (!ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE, EVENT_NONE) && !ISTIMER(event->type)) {
+ if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
+ if (event->check_drag) {
+ wmWindow *win = CTX_wm_window(C);
+ if ((abs(event->x - win->eventstate->prevclickx)) >= U.tweak_threshold ||
+ (abs(event->y - win->eventstate->prevclicky)) >= U.tweak_threshold)
+ {
+ short val = event->val;
+ short type = event->type;
+ event->val = KM_CLICK_DRAG;
+ event->type = win->eventstate->type;
+
+ CLOG_INFO(WM_LOG_HANDLERS, 1, "handling PRESS_DRAG");
+
+ action |= wm_handlers_do_intern(C, event, handlers);
+
+ event->val = val;
+ event->type = type;
+
+ win->eventstate->check_click = 0;
+ win->eventstate->check_drag = 0;
+ }
+ }
+ }
+ else if (ISMOUSE_BUTTON(event->type) || ISKEYBOARD(event->type)) {
+ /* All events that don't set wmEvent.prevtype must be ignored. */
/* test for CLICK events */
if (wm_action_not_handled(action)) {
wmWindow *win = CTX_wm_window(C);
-
- /* eventstate stores if previous event was a KM_PRESS, in case that
+
+ /* eventstate stores if previous event was a KM_PRESS, in case that
* wasn't handled, the KM_RELEASE will become a KM_CLICK */
-
- if (win && event->val == KM_PRESS) {
- win->eventstate->check_click = true;
+
+ if (win != NULL) {
+ if (event->val == KM_PRESS) {
+ win->eventstate->check_click = true;
+ win->eventstate->check_drag = true;
+ }
+ else if (event->val == KM_RELEASE) {
+ win->eventstate->check_drag = false;
+ }
}
-
+
if (win && win->eventstate->prevtype == event->type) {
-
+
if ((event->val == KM_RELEASE) &&
(win->eventstate->prevval == KM_PRESS) &&
(win->eventstate->check_click == true))
@@ -2551,19 +2581,20 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
event->val = KM_CLICK;
CLOG_INFO(WM_LOG_HANDLERS, 1, "handling CLICK");
-
+
action |= wm_handlers_do_intern(C, event, handlers);
event->val = KM_RELEASE;
}
else {
win->eventstate->check_click = 0;
+ win->eventstate->check_drag = 0;
}
}
else if (event->val == KM_DBL_CLICK) {
event->val = KM_PRESS;
action |= wm_handlers_do_intern(C, event, handlers);
-
+
/* revert value if not handled */
if (wm_action_not_handled(action)) {
event->val = KM_DBL_CLICK;
@@ -2578,7 +2609,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
win->eventstate->check_click = 0;
}
}
-
+
return action;
}
@@ -2595,7 +2626,7 @@ static ScrArea *area_event_inside(bContext *C, const int xy[2])
{
wmWindow *win = CTX_wm_window(C);
bScreen *screen = CTX_wm_screen(C);
-
+
if (screen) {
ED_screen_areas_iter(win, screen, sa) {
if (BLI_rcti_isect_pt_v(&sa->totrct, xy))
@@ -2610,7 +2641,7 @@ static ARegion *region_event_inside(bContext *C, const int xy[2])
bScreen *screen = CTX_wm_screen(C);
ScrArea *area = CTX_wm_area(C);
ARegion *ar;
-
+
if (screen && area)
for (ar = area->regionbase.first; ar; ar = ar->next)
if (BLI_rcti_isect_pt_v(&ar->winrct, xy))
@@ -2635,22 +2666,22 @@ static void wm_paintcursor_tag(bContext *C, wmPaintCursor *pc, ARegion *ar)
static void wm_paintcursor_test(bContext *C, const wmEvent *event)
{
wmWindowManager *wm = CTX_wm_manager(C);
-
+
if (wm->paintcursors.first) {
ARegion *ar = CTX_wm_region(C);
-
+
if (ar)
wm_paintcursor_tag(C, wm->paintcursors.first, ar);
-
+
/* if previous position was not in current region, we have to set a temp new context */
if (ar == NULL || !BLI_rcti_isect_pt_v(&ar->winrct, &event->prevx)) {
ScrArea *sa = CTX_wm_area(C);
-
+
CTX_wm_area_set(C, area_event_inside(C, &event->prevx));
CTX_wm_region_set(C, region_event_inside(C, &event->prevx));
wm_paintcursor_tag(C, wm->paintcursors.first, CTX_wm_region(C));
-
+
CTX_wm_area_set(C, sa);
CTX_wm_region_set(C, ar);
}
@@ -2664,7 +2695,7 @@ static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *even
if (BLI_listbase_is_empty(&wm->drags)) {
return;
}
-
+
if (event->type == MOUSEMOVE || ISKEYMODIFIER(event->type)) {
screen->do_draw_drag = true;
}
@@ -2675,20 +2706,20 @@ static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *even
}
else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
event->type = EVT_DROP;
-
+
/* create customdata, first free existing */
if (event->customdata) {
if (event->customdatafree)
MEM_freeN(event->customdata);
}
-
+
event->custom = EVT_DATA_DRAGDROP;
event->customdata = &wm->drags;
event->customdatafree = 1;
-
+
/* clear drop icon */
screen->do_draw_drag = true;
-
+
/* restore cursor (disabled, see wm_dragdrop.c) */
// WM_cursor_modal_restore(win);
}
@@ -2738,12 +2769,12 @@ void wm_event_do_handlers(bContext *C)
if (scene) {
int is_playing_sound = BKE_sound_scene_playing(scene);
-
+
if (is_playing_sound != -1) {
bool is_playing_screen;
CTX_wm_window_set(C, win);
CTX_data_scene_set(C, scene);
-
+
is_playing_screen = (ED_screen_animation_playing(wm) != NULL);
if (((is_playing_sound == 1) && (is_playing_screen == 0)) ||
@@ -2751,7 +2782,7 @@ void wm_event_do_handlers(bContext *C)
{
ED_screen_animation_play(C, -1, 1);
}
-
+
if (is_playing_sound == 0) {
const float time = BKE_sound_sync_scene(scene);
if (isfinite(time)) {
@@ -2764,14 +2795,14 @@ void wm_event_do_handlers(bContext *C)
}
}
}
-
+
CTX_data_scene_set(C, NULL);
CTX_wm_screen_set(C, NULL);
CTX_wm_window_set(C, NULL);
}
}
}
-
+
while ( (event = win->queue.first) ) {
int action = WM_HANDLER_CONTINUE;
@@ -2805,16 +2836,16 @@ void wm_event_do_handlers(bContext *C)
/* we let modal handlers get active area/region, also wm_paintcursor_test needs it */
CTX_wm_area_set(C, area_event_inside(C, &event->x));
CTX_wm_region_set(C, region_event_inside(C, &event->x));
-
+
/* MVC demands to not draw in event handlers... but we need to leave it for ogl selecting etc */
wm_window_make_drawable(wm, win);
-
+
wm_region_mouse_co(C, event);
/* first we do priority handlers, modal + some limited keymaps */
action |= wm_handlers_do(C, event, &win->modalhandlers);
-
+
/* fileread case */
if (CTX_wm_window(C) == NULL)
return;
@@ -2830,13 +2861,13 @@ void wm_event_do_handlers(bContext *C)
/* check dragging, creates new event or frees, adds draw tag */
wm_event_drag_test(wm, win, event);
-
+
/* builtin tweak, if action is break it removes tweak */
wm_tweakevent_test(C, event, action);
if ((action & WM_HANDLER_BREAK) == 0) {
ARegion *ar;
-
+
/* Note: setting subwin active should be done here, after modal handlers have been done */
if (event->type == MOUSEMOVE) {
/* state variables in screen, cursors. Also used in wm_draw.c, fails for modal handlers though */
@@ -2871,7 +2902,7 @@ void wm_event_do_handlers(bContext *C)
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (wm_event_inside_i(event, &ar->winrct)) {
CTX_wm_region_set(C, ar);
-
+
/* call even on non mouse events, since the */
wm_region_mouse_co(C, event);
@@ -2945,7 +2976,7 @@ void wm_event_do_handlers(bContext *C)
/* NOTE: do not escape on WM_HANDLER_BREAK, mousemove needs handled for previous area */
}
}
-
+
if ((action & WM_HANDLER_BREAK) == 0) {
/* also some non-modal handlers need active area/region */
CTX_wm_area_set(C, area_event_inside(C, &event->x));
@@ -2969,9 +3000,9 @@ void wm_event_do_handlers(bContext *C)
/* unlink and free here, blender-quit then frees all */
BLI_remlink(&win->queue, event);
wm_event_free(event);
-
+
}
-
+
/* only add mousemove when queue was read entirely */
if (win->addmousemove && win->eventstate) {
wmEvent tevent = *(win->eventstate);
@@ -2982,7 +3013,7 @@ void wm_event_do_handlers(bContext *C)
wm_event_add(win, &tevent);
win->addmousemove = 0;
}
-
+
CTX_wm_window_set(C, NULL);
}
@@ -2997,10 +3028,10 @@ void WM_event_fileselect_event(wmWindowManager *wm, void *ophandle, int eventval
{
/* add to all windows! */
wmWindow *win;
-
+
for (win = wm->windows.first; win; win = win->next) {
wmEvent event = *win->eventstate;
-
+
event.type = EVT_FILESELECT;
event.val = eventval;
event.customdata = ophandle; // only as void pointer type check
@@ -3027,7 +3058,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
/* only allow 1 file selector open per window */
for (handler = win->modalhandlers.first; handler; handler = handlernext) {
handlernext = handler->next;
-
+
if (handler->type == WM_HANDLER_FILESELECT) {
bScreen *screen = CTX_wm_screen(C);
bool cancel_handler = true;
@@ -3052,16 +3083,16 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
}
}
}
-
+
handler = MEM_callocN(sizeof(wmEventHandler), "fileselect handler");
-
+
handler->type = WM_HANDLER_FILESELECT;
handler->op = op;
handler->op_area = CTX_wm_area(C);
handler->op_region = CTX_wm_region(C);
-
+
BLI_addhead(&win->modalhandlers, handler);
-
+
/* check props once before invoking if check is available
* ensures initial properties are valid */
if (op->type->check) {
@@ -3083,7 +3114,7 @@ wmEventHandler *WM_event_add_modal_handler(bContext *C, wmOperator *op)
{
wmEventHandler *handler = MEM_callocN(sizeof(wmEventHandler), "event modal handler");
wmWindow *win = CTX_wm_window(C);
-
+
/* operator was part of macro */
if (op->opm) {
/* give the mother macro to the handler */
@@ -3093,11 +3124,11 @@ wmEventHandler *WM_event_add_modal_handler(bContext *C, wmOperator *op)
}
else
handler->op = op;
-
+
handler->op_area = CTX_wm_area(C); /* means frozen screen context for modal handlers! */
handler->op_region = CTX_wm_region(C);
handler->op_region_type = handler->op_region ? handler->op_region->regiontype : -1;
-
+
BLI_addhead(&win->modalhandlers, handler);
return handler;
@@ -3144,7 +3175,7 @@ wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap
for (handler = handlers->first; handler; handler = handler->next)
if (handler->keymap == keymap)
return handler;
-
+
handler = MEM_callocN(sizeof(wmEventHandler), "event keymap handler");
BLI_addtail(handlers, handler);
handler->keymap = keymap;
@@ -3156,20 +3187,20 @@ wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap
wmEventHandler *WM_event_add_keymap_handler_priority(ListBase *handlers, wmKeyMap *keymap, int UNUSED(priority))
{
wmEventHandler *handler;
-
+
WM_event_remove_keymap_handler(handlers, keymap);
-
+
handler = MEM_callocN(sizeof(wmEventHandler), "event keymap handler");
BLI_addhead(handlers, handler);
handler->keymap = keymap;
-
+
return handler;
}
wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, wmKeyMap *keymap, const rcti *bblocal, const rcti *bbwin)
{
wmEventHandler *handler = WM_event_add_keymap_handler(handlers, keymap);
-
+
if (handler) {
handler->bblocal = bblocal;
handler->bbwin = bbwin;
@@ -3180,7 +3211,7 @@ wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, wmKeyMap *key
void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap)
{
wmEventHandler *handler;
-
+
for (handler = handlers->first; handler; handler = handler->next) {
if (handler->keymap == keymap) {
BLI_remlink(handlers, handler);
@@ -3221,9 +3252,9 @@ wmEventHandler *WM_event_add_ui_handler(
BLI_assert((flag & WM_HANDLER_DO_FREE) == 0);
handler->flag = flag;
-
+
BLI_addhead(handlers, handler);
-
+
return handler;
}
@@ -3234,7 +3265,7 @@ void WM_event_remove_ui_handler(
void *userdata, const bool postpone)
{
wmEventHandler *handler;
-
+
for (handler = handlers->first; handler; handler = handler->next) {
if ((handler->ui_handle == ui_handle) &&
(handler->ui_remove == ui_remove) &&
@@ -3279,13 +3310,13 @@ wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase *dropb
for (handler = handlers->first; handler; handler = handler->next)
if (handler->dropboxes == dropboxes)
return handler;
-
+
handler = MEM_callocN(sizeof(wmEventHandler), "dropbox handler");
-
+
/* dropbox stored static, no free or copy */
handler->dropboxes = dropboxes;
BLI_addhead(handlers, handler);
-
+
return handler;
}
@@ -3316,7 +3347,7 @@ static void WM_event_remove_handler(ListBase *handlers, wmEventHandler *handler)
void WM_event_add_mousemove(const bContext *C)
{
wmWindow *window = CTX_wm_window(C);
-
+
window->addmousemove = 1;
}
@@ -3324,7 +3355,7 @@ void WM_event_add_mousemove(const bContext *C)
/* for modal callbacks, check configuration for how to interpret exit with tweaks */
bool WM_event_is_modal_tweak_exit(const wmEvent *event, int tweak_event)
{
- /* if the release-confirm userpref setting is enabled,
+ /* if the release-confirm userpref setting is enabled,
* tweak events can be canceled when mouse is released
*/
if (U.flag & USER_RELEASECONFIRM) {
@@ -3353,13 +3384,13 @@ bool WM_event_is_modal_tweak_exit(const wmEvent *event, int tweak_event)
if (event->val != KM_RELEASE)
return 1;
}
-
+
return 0;
}
/* ********************* ghost stuff *************** */
-static int convert_key(GHOST_TKey key)
+static int convert_key(GHOST_TKey key)
{
if (key >= GHOST_kKeyA && key <= GHOST_kKeyZ) {
return (AKEY + ((int) key - GHOST_kKeyA));
@@ -3438,7 +3469,7 @@ static int convert_key(GHOST_TKey key)
case GHOST_kKeyMediaStop: return MEDIASTOP;
case GHOST_kKeyMediaFirst: return MEDIAFIRST;
case GHOST_kKeyMediaLast: return MEDIALAST;
-
+
default:
return UNKNOWNKEY; /* GHOST_kKeyUnknown */
}
@@ -3450,11 +3481,11 @@ static void wm_eventemulation(wmEvent *event)
/* Store last mmb/rmb event value to make emulation work when modifier keys
* are released first. This really should be in a data structure somewhere. */
static int emulating_event = EVENT_NONE;
-
+
/* middlemouse and rightmouse emulation */
if (U.flag & USER_TWOBUTTONMOUSE) {
if (event->type == LEFTMOUSE) {
-
+
if (event->val == KM_PRESS && event->alt) {
event->type = MIDDLEMOUSE;
event->alt = 0;
@@ -3480,9 +3511,9 @@ static void wm_eventemulation(wmEvent *event)
emulating_event = EVENT_NONE;
}
}
-
+
}
-
+
/* numpad emulation */
if (U.flag & USER_NONUMPAD) {
switch (event->type) {
@@ -3507,16 +3538,16 @@ static void wm_eventemulation(wmEvent *event)
static void update_tablet_data(wmWindow *win, wmEvent *event)
{
const GHOST_TabletData *td = GHOST_GetTabletData(win->ghostwin);
-
+
/* if there's tablet data from an active tablet device then add it */
if ((td != NULL) && td->Active != GHOST_kTabletModeNone) {
struct wmTabletData *wmtab = MEM_mallocN(sizeof(wmTabletData), "customdata tablet");
-
+
wmtab->Active = (int)td->Active;
wmtab->Pressure = td->Pressure;
wmtab->Xtilt = td->Xtilt;
wmtab->Ytilt = td->Ytilt;
-
+
event->tablet_data = wmtab;
// printf("%s: using tablet %.5f\n", __func__, wmtab->Pressure);
}
@@ -3559,40 +3590,40 @@ static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *g
static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *win, wmEvent *event)
{
int mx = event->x, my = event->y;
-
+
if (wm->windows.first == wm->windows.last)
return NULL;
-
+
/* in order to use window size and mouse position (pixels), we have to use a WM function */
-
+
/* check if outside, include top window bar... */
if (mx < 0 || my < 0 || mx > WM_window_pixels_x(win) || my > WM_window_pixels_y(win) + 30) {
wmWindow *owin;
wmEventHandler *handler;
-
+
/* let's skip windows having modal handlers now */
/* potential XXX ugly... I wouldn't have added a modalhandlers list (introduced in rev 23331, ton) */
for (handler = win->modalhandlers.first; handler; handler = handler->next)
if (handler->ui_handle || handler->op)
return NULL;
-
+
/* to desktop space */
mx += (int) (U.pixelsize * win->posx);
my += (int) (U.pixelsize * win->posy);
-
+
/* check other windows to see if it has mouse inside */
for (owin = wm->windows.first; owin; owin = owin->next) {
-
+
if (owin != win) {
int posx = (int) (U.pixelsize * owin->posx);
int posy = (int) (U.pixelsize * owin->posy);
-
+
if (mx - posx >= 0 && owin->posy >= 0 &&
mx - posx <= WM_window_pixels_x(owin) && my - posy <= WM_window_pixels_y(owin))
{
event->x = mx - (int)(U.pixelsize * owin->posx);
event->y = my - (int)(U.pixelsize * owin->posy);
-
+
return owin;
}
}
@@ -3671,7 +3702,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
copy_v2_v2_int(&evt->x, &event_new->x);
evt->is_motion_absolute = event_new->is_motion_absolute;
}
-
+
/* also add to other window if event is there, this makes overdraws disappear nicely */
/* it remaps mousecoord to other window in event */
owin = wm_event_cursor_other_windows(wm, win, &event);
@@ -3688,7 +3719,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
oevt->is_motion_absolute = event_new->is_motion_absolute;
}
}
-
+
break;
}
case GHOST_kEventTrackpad:
@@ -3712,11 +3743,11 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
event.x = evt->x = pd->x;
event.y = evt->y = pd->y;
event.val = KM_NOTHING;
-
+
/* Use prevx/prevy so we can calculate the delta later */
event.prevx = event.x - pd->deltaX;
event.prevy = event.y - (-pd->deltaY);
-
+
wm_event_add(win, &event);
break;
}
@@ -3725,10 +3756,10 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
case GHOST_kEventButtonUp:
{
GHOST_TEventButtonData *bd = customdata;
-
+
/* get value and type from ghost */
event.val = (type == GHOST_kEventButtonDown) ? KM_PRESS : KM_RELEASE;
-
+
if (bd->button == GHOST_kButtonMaskLeft)
event.type = LEFTMOUSE;
else if (bd->button == GHOST_kButtonMaskRight)
@@ -3743,9 +3774,9 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
event.type = BUTTON7MOUSE;
else
event.type = MIDDLEMOUSE;
-
+
wm_eventemulation(&event);
-
+
/* copy previous state to prev event state (two old!) */
evt->prevval = evt->val;
evt->prevtype = evt->type;
@@ -3756,14 +3787,14 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
if (win->active == 0) {
int cx, cy;
-
+
/* entering window, update mouse pos. (ghost sends win-activate *after* the mouseclick in window!) */
wm_get_cursor_position(win, &cx, &cy);
event.x = evt->x = cx;
event.y = evt->y = cy;
}
-
+
/* double click test */
if (wm_event_is_double_click(&event, evt)) {
CLOG_INFO(WM_LOG_HANDLERS, 1, "Send double click");
@@ -3774,23 +3805,23 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
evt->prevclickx = event.x;
evt->prevclicky = event.y;
}
-
+
/* add to other window if event is there (not to both!) */
owin = wm_event_cursor_other_windows(wm, win, &event);
if (owin) {
wmEvent oevent = *(owin->eventstate);
-
+
oevent.x = event.x;
oevent.y = event.y;
oevent.type = event.type;
oevent.val = event.val;
-
+
wm_event_add(owin, &oevent);
}
else {
wm_event_add(win, &event);
}
-
+
break;
}
/* keyboard */
@@ -3803,9 +3834,9 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
event.ascii = kd->ascii;
memcpy(event.utf8_buf, kd->utf8_buf, sizeof(event.utf8_buf)); /* might be not null terminated*/
event.val = (type == GHOST_kEventKeyDown) ? KM_PRESS : KM_RELEASE;
-
+
wm_eventemulation(&event);
-
+
/* copy previous state to prev event state (two old!) */
evt->prevval = evt->val;
evt->prevtype = evt->type;
@@ -3813,7 +3844,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
/* copy to event state */
evt->val = event.val;
evt->type = event.type;
-
+
/* exclude arrow keys, esc, etc from text input */
if (type == GHOST_kEventKeyUp) {
event.ascii = '\0';
@@ -3887,19 +3918,19 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
CLOG_INFO(WM_LOG_HANDLERS, 1, "Send double click");
evt->val = event.val = KM_DBL_CLICK;
}
-
+
/* this case happens on holding a key pressed, it should not generate
* press events events with the same key as modifier */
if (event.keymodifier == event.type)
event.keymodifier = 0;
-
+
/* this case happens with an external numpad, and also when using 'dead keys' (to compose complex latin
* characters e.g.), it's not really clear why.
* Since it's impossible to map a key modifier to an unknown key, it shouldn't harm to clear it. */
if (event.keymodifier == UNKNOWNKEY) {
evt->keymodifier = event.keymodifier = 0;
}
-
+
/* if test_break set, it catches this. Do not set with modifier presses. XXX Keep global for now? */
if ((event.type == ESCKEY && event.val == KM_PRESS) &&
/* check other modifiers because ms-windows uses these to bring up the task manager */
@@ -3907,31 +3938,34 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
{
G.is_break = true;
}
-
+
/* double click test - only for press */
if (event.val == KM_PRESS) {
- evt->prevclicktime = PIL_check_seconds_timer();
- evt->prevclickx = event.x;
- evt->prevclicky = event.y;
+ /* Don't reset timer & location when holding the key generates repeat events. */
+ if ((evt->prevtype != event.type) || (evt->prevval != KM_PRESS)) {
+ evt->prevclicktime = PIL_check_seconds_timer();
+ evt->prevclickx = event.x;
+ evt->prevclicky = event.y;
+ }
}
-
+
wm_event_add(win, &event);
-
+
break;
}
-
+
case GHOST_kEventWheel:
{
GHOST_TEventWheelData *wheelData = customdata;
-
+
if (wheelData->z > 0)
event.type = WHEELUPMOUSE;
else
event.type = WHEELDOWNMOUSE;
-
+
event.val = KM_PRESS;
wm_event_add(win, &event);
-
+
break;
}
case GHOST_kEventTimer:
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 7fb115a1f28..3aaec875627 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -152,27 +152,27 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
{
wmWindowManager *wm;
wmWindow *win, *active_win;
-
+
*wmlist = G.main->wm;
BLI_listbase_clear(&G.main->wm);
-
+
active_win = CTX_wm_window(C);
/* first wrap up running stuff */
/* code copied from wm_init_exit.c */
for (wm = wmlist->first; wm; wm = wm->id.next) {
-
+
WM_jobs_kill_all(wm);
-
+
for (win = wm->windows.first; win; win = win->next) {
-
+
CTX_wm_window_set(C, win); /* needed by operator close callbacks */
WM_event_remove_handlers(C, &win->handlers);
WM_event_remove_handlers(C, &win->modalhandlers);
ED_screen_exit(C, win, WM_window_get_active_screen(win));
}
}
-
+
/* reset active window */
CTX_wm_window_set(C, active_win);
@@ -215,6 +215,7 @@ static void wm_window_match_keep_current_wm(
const bool load_ui,
ListBase *r_new_wm_list)
{
+ Main *bmain = CTX_data_main(C);
wmWindowManager *wm = current_wm_list->first;
bScreen *screen = NULL;
@@ -236,7 +237,7 @@ static void wm_window_match_keep_current_wm(
}
else {
WorkSpaceLayout *layout_old = WM_window_get_active_layout(win);
- WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(workspace, layout_old, win);
+ WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(bmain, workspace, layout_old, win);
WM_window_set_active_layout(win, workspace, layout_new);
}
@@ -339,8 +340,8 @@ static void wm_window_match_do(
static void wm_init_userdef(Main *bmain, const bool read_userdef_from_memory)
{
/* versioning is here */
- UI_init_userdef();
-
+ UI_init_userdef(bmain);
+
MEM_CacheLimiter_set_maximum(((size_t)U.memcachelimit) * 1024 * 1024);
BKE_sound_init(bmain);
@@ -506,7 +507,7 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
addons_loaded = true;
}
#else
- UNUSED_VARS(use_userdef);
+ UNUSED_VARS(is_startup_file, use_userdef);
#endif /* WITH_PYTHON */
WM_operatortype_last_properties_clear_all();
@@ -569,7 +570,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
/* it throws error box when file doesn't exist and returns -1 */
/* note; it should set some error message somewhere... (ton) */
retval = wm_read_exotic(filepath);
-
+
/* we didn't succeed, now try to read Blender file */
if (retval == BKE_READ_EXOTIC_OK_BLEND) {
int G_f = G.f;
@@ -578,12 +579,16 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
/* put aside screens to match with persistent windows later */
/* also exit screens and editors */
wm_window_match_init(C, &wmbase);
-
+
/* confusing this global... */
G.relbase_valid = 1;
retval = BKE_blendfile_read(C, filepath, reports, 0);
+
+ /* BKE_file_read sets new Main into context. */
+ Main *bmain = CTX_data_main(C);
+
/* when loading startup.blend's, we can be left with a blank path */
- if (G.main->name[0]) {
+ if (BKE_main_blendfile_path(bmain)) {
G.save_over = 1;
}
else {
@@ -599,14 +604,14 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
}
/* match the read WM with current WM */
- wm_window_match_do(C, &wmbase, &G.main->wm, &G.main->wm);
+ wm_window_match_do(C, &wmbase, &bmain->wm, &bmain->wm);
WM_check(C); /* opens window(s), checks keymaps */
if (retval == BKE_BLENDFILE_READ_OK_USERPREFS) {
/* in case a userdef is read from regular .blend */
- wm_init_userdef(G.main, false);
+ wm_init_userdef(bmain, false);
}
-
+
if (retval != BKE_BLENDFILE_READ_FAIL) {
if (do_history) {
wm_history_file_update();
@@ -672,6 +677,7 @@ int wm_homefile_read(
bool use_factory_settings, bool use_empty_data, bool use_userdef,
const char *filepath_startup_override, const char *app_template_override)
{
+ Main *bmain = G.main; /* Context does not always have valid main pointer here... */
ListBase wmbase;
bool success = false;
@@ -863,16 +869,18 @@ int wm_homefile_read(
* can remove this eventually, only in a 2.53 and older, now its not written */
G.fileflags &= ~G_FILE_RELATIVE_REMAP;
- if (use_userdef) {
+ bmain = CTX_data_main(C);
+
+ if (use_userdef) {
/* check userdef before open window, keymaps etc */
- wm_init_userdef(CTX_data_main(C), read_userdef_from_memory);
+ wm_init_userdef(bmain, read_userdef_from_memory);
}
-
+
/* match the read WM with current WM */
- wm_window_match_do(C, &wmbase, &G.main->wm, &G.main->wm);
+ wm_window_match_do(C, &wmbase, &bmain->wm, &bmain->wm);
WM_check(C); /* opens window(s), checks keymaps */
- G.main->name[0] = '\0';
+ bmain->name[0] = '\0';
/* start with save preference untitled.blend */
G.save_over = 0;
@@ -913,7 +921,7 @@ void wm_history_file_read(void)
num++;
}
}
-
+
BLI_file_free_lines(lines);
}
@@ -969,16 +977,18 @@ static void wm_history_file_write(void)
static void wm_history_file_update(void)
{
RecentFile *recent;
+ const char *blendfile_name = BKE_main_blendfile_path_from_global();
/* no write history for recovered startup files */
- if (G.main->name[0] == 0)
+ if (blendfile_name[0] == '\0') {
return;
+ }
recent = G.recent_files.first;
/* refresh recent-files.txt of recent opened files, when current file was changed */
- if (!(recent) || (BLI_path_cmp(recent->filepath, G.main->name) != 0)) {
+ if (!(recent) || (BLI_path_cmp(recent->filepath, blendfile_name) != 0)) {
- recent = wm_file_history_find(G.main->name);
+ recent = wm_file_history_find(blendfile_name);
if (recent) {
BLI_remlink(&G.recent_files, recent);
}
@@ -988,7 +998,7 @@ static void wm_history_file_update(void)
recent_next = recent->next;
wm_history_file_free(recent);
}
- recent = wm_history_file_new(G.main->name);
+ recent = wm_history_file_new(blendfile_name);
}
/* add current file to the beginning of list */
@@ -998,7 +1008,7 @@ static void wm_history_file_update(void)
wm_history_file_write();
/* also update most recent files on System */
- GHOST_addToSystemRecentFiles(G.main->name);
+ GHOST_addToSystemRecentFiles(blendfile_name);
}
}
@@ -1066,7 +1076,7 @@ static ImBuf *blend_file_thumb(const bContext *C, Scene *scene, bScreen *screen,
/* add pretty overlay */
IMB_thumb_overlay_blend(ibuf->rect, ibuf->x, ibuf->y, aspect);
-
+
thumb = BKE_main_thumbnail_from_imbuf(NULL, ibuf);
}
else {
@@ -1074,10 +1084,10 @@ static ImBuf *blend_file_thumb(const bContext *C, Scene *scene, bScreen *screen,
fprintf(stderr, "blend_file_thumb failed to create thumbnail: %s\n", err_out);
thumb = NULL;
}
-
+
/* must be freed by caller */
*thumb_pt = thumb;
-
+
return ibuf;
}
@@ -1087,7 +1097,7 @@ bool write_crash_blend(void)
char path[FILE_MAX];
int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on crash file */
- BLI_strncpy(path, G.main->name, sizeof(path));
+ BLI_strncpy(path, BKE_main_blendfile_path_from_global(), sizeof(path));
BLI_replace_extension(path, sizeof(path), "_crash.blend");
if (BLO_write_file(G.main, path, fileflags, NULL, NULL)) {
printf("written: %s\n", path);
@@ -1104,6 +1114,7 @@ bool write_crash_blend(void)
*/
static int wm_file_write(bContext *C, const char *filepath, int fileflags, ReportList *reports)
{
+ Main *bmain = CTX_data_main(C);
Library *li;
int len;
int ret = -1;
@@ -1111,7 +1122,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
ImBuf *ibuf_thumb = NULL;
len = strlen(filepath);
-
+
if (len == 0) {
BKE_report(reports, RPT_ERROR, "Path is empty, cannot save");
return ret;
@@ -1121,7 +1132,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
BKE_report(reports, RPT_ERROR, "Path too long, cannot save");
return ret;
}
-
+
/* Check if file write permission is ok */
if (BLI_exists(filepath) && !BLI_file_is_writable(filepath)) {
BKE_reportf(reports, RPT_ERROR, "Cannot save blend file, path '%s' is not writable", filepath);
@@ -1131,9 +1142,9 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
/* note: used to replace the file extension (to ensure '.blend'),
* no need to now because the operator ensures,
* its handy for scripts to save to a predefined name without blender editing it */
-
+
/* send the OnSave event */
- for (li = G.main->library.first; li; li = li->id.next) {
+ for (li = bmain->library.first; li; li = li->id.next) {
if (BLI_path_cmp(li->filepath, filepath) == 0) {
BKE_reportf(reports, RPT_ERROR, "Cannot overwrite used library '%.240s'", filepath);
return ret;
@@ -1141,12 +1152,12 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
}
/* Call pre-save callbacks befores writing preview, that way you can generate custom file thumbnail... */
- BLI_callback_exec(G.main, NULL, BLI_CB_EVT_SAVE_PRE);
+ BLI_callback_exec(bmain, NULL, BLI_CB_EVT_SAVE_PRE);
/* blend file thumbnail */
/* save before exit_editmode, otherwise derivedmeshes for shared data corrupt #27765) */
/* Main now can store a .blend thumbnail, usefull for background mode or thumbnail customization. */
- main_thumb = thumb = CTX_data_main(C)->blen_thumb;
+ main_thumb = thumb = bmain->blen_thumb;
if ((U.flag & USER_SAVE_PREVIEWS) && BLI_thread_is_main()) {
ibuf_thumb = blend_file_thumb(C, CTX_data_scene(C), CTX_wm_screen(C), &thumb);
}
@@ -1154,32 +1165,32 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
/* operator now handles overwrite checks */
if (G.fileflags & G_AUTOPACK) {
- packAll(G.main, reports, false);
+ packAll(bmain, reports, false);
}
/* don't forget not to return without! */
WM_cursor_wait(1);
-
+
ED_editors_flush_edits(C, false);
fileflags |= G_FILE_HISTORY; /* write file history */
/* first time saving */
/* XXX temp solution to solve bug, real fix coming (ton) */
- if ((G.main->name[0] == '\0') && !(fileflags & G_FILE_SAVE_COPY)) {
- BLI_strncpy(G.main->name, filepath, sizeof(G.main->name));
+ if ((BKE_main_blendfile_path(bmain)[0] == '\0') && !(fileflags & G_FILE_SAVE_COPY)) {
+ BLI_strncpy(bmain->name, filepath, sizeof(bmain->name));
}
/* XXX temp solution to solve bug, real fix coming (ton) */
- G.main->recovered = 0;
-
+ bmain->recovered = 0;
+
if (BLO_write_file(CTX_data_main(C), filepath, fileflags, reports, thumb)) {
const bool do_history = (G.background == false) && (CTX_wm_manager(C)->op_undo_depth == 0);
if (!(fileflags & G_FILE_SAVE_COPY)) {
G.relbase_valid = 1;
- BLI_strncpy(G.main->name, filepath, sizeof(G.main->name)); /* is guaranteed current file */
-
+ BLI_strncpy(bmain->name, filepath, sizeof(bmain->name)); /* is guaranteed current file */
+
G.save_over = 1; /* disable untitled.blend convention */
}
@@ -1190,7 +1201,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
wm_history_file_update();
}
- BLI_callback_exec(G.main, NULL, BLI_CB_EVT_SAVE_POST);
+ BLI_callback_exec(bmain, NULL, BLI_CB_EVT_SAVE_POST);
/* run this function after because the file cant be written before the blend is */
if (ibuf_thumb) {
@@ -1224,7 +1235,7 @@ void wm_autosave_location(char *filepath)
#endif
if (G.main && G.relbase_valid) {
- const char *basename = BLI_path_basename(G.main->name);
+ const char *basename = BLI_path_basename(BKE_main_blendfile_path_from_global());
int len = strlen(basename) - 6;
BLI_snprintf(path, sizeof(path), "%.*s.blend", len, basename);
}
@@ -1264,7 +1275,7 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w
wmWindow *win;
wmEventHandler *handler;
char filepath[FILE_MAX];
-
+
WM_event_remove_timer(wm, NULL, wm->autosavetimer);
/* if a modal operator is running, don't autosave, but try again in 10 seconds */
@@ -1313,7 +1324,7 @@ void wm_autosave_timer_ended(wmWindowManager *wm)
void wm_autosave_delete(void)
{
char filename[FILE_MAX];
-
+
wm_autosave_location(filename);
if (BLI_exists(filename)) {
@@ -1754,7 +1765,8 @@ struct FileRuntime {
static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- const char *openname = G.main->name;
+ Main *bmain = CTX_data_main(C);
+ const char *openname = BKE_main_blendfile_path(bmain);
if (CTX_wm_window(C) == NULL) {
/* in rare cases this could happen, when trying to invoke in background
@@ -1893,6 +1905,7 @@ void WM_OT_open_mainfile(wmOperatorType *ot)
static int wm_revert_mainfile_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
bool success;
char filepath[FILE_MAX];
@@ -1903,7 +1916,7 @@ static int wm_revert_mainfile_exec(bContext *C, wmOperator *op)
else
G.f &= ~G_SCRIPT_AUTOEXEC;
- BLI_strncpy(filepath, G.main->name, sizeof(filepath));
+ BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath));
success = wm_file_read_opwrap(C, filepath, op->reports, !(G.f & G_SCRIPT_AUTOEXEC));
if (success) {
@@ -1941,6 +1954,7 @@ void WM_OT_revert_mainfile(wmOperatorType *ot)
void WM_recover_last_session(bContext *C, ReportList *reports)
{
+ Main *bmain = CTX_data_main(C);
char filepath[FILE_MAX];
BLI_make_file_string("/", filepath, BKE_tempdir_base(), BLENDER_QUIT_FILE);
@@ -1953,8 +1967,9 @@ void WM_recover_last_session(bContext *C, ReportList *reports)
G.fileflags &= ~G_FILE_RECOVER;
/* XXX bad global... fixme */
- if (G.main->name[0])
+ if (BKE_main_blendfile_path(bmain)[0] != '\0') {
G.file_loaded = 1; /* prevents splash to show */
+ }
else {
G.relbase_valid = 0;
G.save_over = 0; /* start with save preference untitled.blend */
@@ -2053,20 +2068,21 @@ static void save_set_compress(wmOperator *op)
}
}
-static void save_set_filepath(wmOperator *op)
+static void save_set_filepath(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
PropertyRNA *prop;
char name[FILE_MAX];
prop = RNA_struct_find_property(op->ptr, "filepath");
if (!RNA_property_is_set(op->ptr, prop)) {
/* if not saved before, get the name of the most recently used .blend file */
- if (G.main->name[0] == 0 && G.recent_files.first) {
+ if (BKE_main_blendfile_path(bmain)[0] == '\0' && G.recent_files.first) {
struct RecentFile *recent = G.recent_files.first;
BLI_strncpy(name, recent->filepath, FILE_MAX);
}
else {
- BLI_strncpy(name, G.main->name, FILE_MAX);
+ BLI_strncpy(name, bmain->name, FILE_MAX);
}
wm_filepath_default(name);
@@ -2078,7 +2094,7 @@ static int wm_save_as_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent
{
save_set_compress(op);
- save_set_filepath(op);
+ save_set_filepath(C, op);
WM_event_add_fileselect(C, op);
@@ -2088,6 +2104,7 @@ static int wm_save_as_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent
/* function used for WM_OT_save_mainfile too */
static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
char path[FILE_MAX];
int fileflags;
@@ -2097,7 +2114,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", path);
}
else {
- BLI_strncpy(path, G.main->name, FILE_MAX);
+ BLI_strncpy(path, BKE_main_blendfile_path(bmain), FILE_MAX);
wm_filepath_default(path);
}
@@ -2193,7 +2210,7 @@ static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *U
return OPERATOR_CANCELLED;
save_set_compress(op);
- save_set_filepath(op);
+ save_set_filepath(C, op);
/* if we're saving for the first time and prefer relative paths - any existing paths will be absolute,
* enable the option to remap paths to avoid confusion [#37240] */
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index ddc4533f228..c7d55b290f5 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -115,7 +115,7 @@ static int wm_link_append_invoke(bContext *C, wmOperator *op, const wmEvent *UNU
}
else if (G.relbase_valid) {
char path[FILE_MAX];
- BLI_strncpy(path, G.main->name, sizeof(G.main->name));
+ BLI_strncpy(path, BKE_main_blendfile_path_from_global(), sizeof(path));
BLI_parent_dir(path);
RNA_string_set(op->ptr, "filepath", path);
}
@@ -333,7 +333,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
BKE_reportf(op->reports, RPT_ERROR, "'%s': nothing indicated", path);
return OPERATOR_CANCELLED;
}
- else if (BLI_path_cmp(bmain->name, libname) == 0) {
+ else if (BLI_path_cmp(BKE_main_blendfile_path(bmain), libname) == 0) {
BKE_reportf(op->reports, RPT_ERROR, "'%s': cannot use current file as library", path);
return OPERATOR_CANCELLED;
}
@@ -372,7 +372,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
if (view_layer && RNA_boolean_get(op->ptr, "autoselect")) {
BKE_view_layer_base_deselect_all(view_layer);
}
-
+
/* tag everything, all untagged data can be made local
* its also generally useful to know what is new
*
@@ -531,18 +531,18 @@ void WM_OT_link(wmOperatorType *ot)
ot->name = "Link from Library";
ot->idname = "WM_OT_link";
ot->description = "Link from a Library .blend file";
-
+
ot->invoke = wm_link_append_invoke;
ot->exec = wm_link_append_exec;
ot->poll = wm_link_append_poll;
-
+
ot->flag |= OPTYPE_UNDO;
WM_operator_properties_filesel(
ot, FILE_TYPE_FOLDER | FILE_TYPE_BLENDER | FILE_TYPE_BLENDERLIB, FILE_LOADLIB, FILE_OPENFILE,
WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME | WM_FILESEL_RELPATH | WM_FILESEL_FILES,
FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
-
+
wm_link_append_properties_common(ot, true);
}
@@ -580,7 +580,7 @@ static int wm_lib_relocate_invoke(bContext *C, wmOperator *op, const wmEvent *UN
char lib_name[MAX_NAME];
RNA_string_get(op->ptr, "library", lib_name);
- lib = (Library *)BKE_libblock_find_name_ex(CTX_data_main(C), ID_LI, lib_name);
+ lib = (Library *)BKE_libblock_find_name(CTX_data_main(C), ID_LI, lib_name);
if (lib) {
if (lib->parent) {
@@ -822,7 +822,7 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
char lib_name[MAX_NAME];
RNA_string_get(op->ptr, "library", lib_name);
- lib = (Library *)BKE_libblock_find_name_ex(CTX_data_main(C), ID_LI, lib_name);
+ lib = (Library *)BKE_libblock_find_name(CTX_data_main(C), ID_LI, lib_name);
if (lib) {
Main *bmain = CTX_data_main(C);
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 2c3583a9f02..144bb38ae76 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -63,20 +63,20 @@ wmGesture *WM_gesture_new(bContext *C, const wmEvent *event, int type)
wmGesture *gesture = MEM_callocN(sizeof(wmGesture), "new gesture");
wmWindow *window = CTX_wm_window(C);
ARegion *ar = CTX_wm_region(C);
-
+
BLI_addtail(&window->gesture, gesture);
-
+
gesture->type = type;
gesture->event_type = event->type;
gesture->winrct = ar->winrct;
gesture->userdata_free = true; /* Free if userdata is set. */
gesture->modal_state = GESTURE_MODAL_NOP;
-
+
if (ELEM(type, WM_GESTURE_RECT, WM_GESTURE_CROSS_RECT, WM_GESTURE_TWEAK,
WM_GESTURE_CIRCLE, WM_GESTURE_STRAIGHTLINE))
{
rcti *rect = MEM_callocN(sizeof(rcti), "gesture rect new");
-
+
gesture->customdata = rect;
rect->xmin = event->x - gesture->winrct.xmin;
rect->ymin = event->y - gesture->winrct.ymin;
@@ -96,14 +96,14 @@ wmGesture *WM_gesture_new(bContext *C, const wmEvent *event, int type)
lasso[1] = event->y - gesture->winrct.ymin;
gesture->points = 1;
}
-
+
return gesture;
}
void WM_gesture_end(bContext *C, wmGesture *gesture)
{
wmWindow *win = CTX_wm_window(C);
-
+
if (win->tweak == gesture)
win->tweak = NULL;
BLI_remlink(&win->gesture, gesture);
@@ -117,7 +117,7 @@ void WM_gesture_end(bContext *C, wmGesture *gesture)
void WM_gestures_remove(bContext *C)
{
wmWindow *win = CTX_wm_window(C);
-
+
while (win->gesture.first)
WM_gesture_end(C, win->gesture.first);
}
@@ -141,7 +141,7 @@ int wm_gesture_evaluate(wmGesture *gesture)
else if (theta == -1) val = EVT_GESTURE_SE;
else if (theta == -2) val = EVT_GESTURE_S;
else if (theta == -3) val = EVT_GESTURE_SW;
-
+
#if 0
/* debug */
if (val == 1) printf("tweak north\n");
@@ -421,7 +421,7 @@ void wm_gesture_draw(wmWindow *win)
for (; gt; gt = gt->next) {
/* all in subwindow space */
wmViewport(&gt->winrct);
-
+
if (gt->type == WM_GESTURE_RECT)
wm_gesture_draw_rect(gt);
// else if (gt->type == WM_GESTURE_TWEAK)
@@ -448,7 +448,7 @@ void wm_gesture_draw(wmWindow *win)
void wm_gesture_tag_redraw(bContext *C)
{
bScreen *screen = CTX_wm_screen(C);
-
+
if (screen)
screen->do_draw_gesture = true;
}
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 1dd2185b982..c5a57147dd6 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -186,6 +186,8 @@ void WM_init_opengl(void)
GPU_set_anisotropic(U.anisotropic_filter);
GPU_set_gpu_mipmapping(U.use_gpu_mipmap);
+ GPU_pass_cache_init();
+
#ifdef WITH_OPENSUBDIV
BKE_subsurf_osd_init();
#endif
@@ -195,7 +197,7 @@ void WM_init_opengl(void)
/* only called once, for startup */
void WM_init(bContext *C, int argc, const char **argv)
{
-
+
if (!G.background) {
wm_ghost_init(C); /* note: it assigns C to ghost! */
wm_init_cursor_data();
@@ -222,12 +224,12 @@ void WM_init(bContext *C, int argc, const char **argv)
BKE_spacedata_callback_id_remap_set(ED_spacedata_id_remap); /* screen.c */
DEG_editors_set_update_cb(ED_render_id_flush_update,
ED_render_scene_update);
-
+
ED_spacetypes_init(); /* editors/space_api/spacetype.c */
-
+
ED_file_init(); /* for fsmenu */
ED_node_init_butfuncs();
-
+
BLF_init();
BLT_lang_init();
@@ -293,11 +295,11 @@ void WM_init(bContext *C, int argc, const char **argv)
/* allow a path of "", this is what happens when making a new file */
#if 0
- if (G.main->name[0] == 0)
+ if (BKE_main_blendfile_path_from_global()[0] == '\0')
BLI_make_file_string("/", G.main->name, BKE_appdir_folder_default(), "untitled.blend");
#endif
- BLI_strncpy(G.lib, G.main->name, FILE_MAX);
+ BLI_strncpy(G.lib, BKE_main_blendfile_path_from_global(), sizeof(G.lib));
#ifdef WITH_COMPOSITOR
if (1) {
@@ -305,7 +307,7 @@ void WM_init(bContext *C, int argc, const char **argv)
COM_linker_hack = COM_execute;
}
#endif
-
+
/* load last session, uses regular file reading so it has to be in end (after init py etc) */
if (U.uiflag2 & USER_KEEP_SESSION) {
/* calling WM_recover_last_session(C, NULL) has been moved to creator.c */
@@ -338,7 +340,7 @@ void WM_init_splash(bContext *C)
if ((U.uiflag & USER_SPLASH_DISABLE) == 0) {
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *prevwin = CTX_wm_window(C);
-
+
if (wm->windows.first) {
CTX_wm_window_set(C, wm->windows.first);
WM_operator_name_call(C, "WM_OT_splash", WM_OP_INVOKE_DEFAULT, NULL);
@@ -351,10 +353,10 @@ void WM_init_splash(bContext *C)
static void free_openrecent(void)
{
struct RecentFile *recent;
-
+
for (recent = G.recent_files.first; recent; recent = recent->next)
MEM_freeN(recent->filepath);
-
+
BLI_freelistN(&(G.recent_files));
}
@@ -437,11 +439,11 @@ void WM_exit_ext(bContext *C, const bool do_python)
}
}
}
-
+
WM_jobs_kill_all(wm);
for (win = wm->windows.first; win; win = win->next) {
-
+
CTX_wm_window_set(C, win); /* needed by operator close callbacks */
WM_event_remove_handlers(C, &win->handlers);
WM_event_remove_handlers(C, &win->modalhandlers);
@@ -462,13 +464,13 @@ void WM_exit_ext(bContext *C, const bool do_python)
ED_undosys_type_free();
free_openrecent();
-
+
BKE_mball_cubeTable_free();
-
+
/* render code might still access databases */
RE_FreeAllRender();
RE_engines_exit();
-
+
ED_preview_free_dbase(); /* frees a Main dbase, before BKE_blender_free! */
if (C && wm)
@@ -478,7 +480,7 @@ void WM_exit_ext(bContext *C, const bool do_python)
BKE_tracking_clipboard_free();
BKE_mask_clipboard_free();
BKE_vfont_clipboard_free();
-
+
#ifdef WITH_COMPOSITOR
COM_deinitialize();
#endif
@@ -492,7 +494,7 @@ void WM_exit_ext(bContext *C, const bool do_python)
GPU_exit();
}
-
+
BKE_blender_free(); /* blender.c, does entire library and spacetypes */
// free_matcopybuf();
ANIM_fcurves_copybuf_free();
@@ -521,11 +523,11 @@ void WM_exit_ext(bContext *C, const bool do_python)
BLF_free_unifont_mono();
BLT_lang_free();
#endif
-
+
ANIM_keyingset_infos_exit();
-
+
// free_txt_data();
-
+
#ifdef WITH_PYTHON
/* option not to close python so we can use 'atexit' */
@@ -549,11 +551,11 @@ void WM_exit_ext(bContext *C, const bool do_python)
BKE_blender_userdef_data_free(&U, false);
RNA_exit(); /* should be after BPY_python_end so struct python slots are cleared */
-
+
wm_ghost_exit();
CTX_free(C);
-
+
GHOST_DisposeSystemPaths();
DNA_sdna_current_free();
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index f9fe787ed2d..3a4195ae1ae 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -78,10 +78,10 @@
struct wmJob {
struct wmJob *next, *prev;
-
+
/* job originating from, keep track of this when deleting windows */
wmWindow *win;
-
+
/* should store entire own context, for start, update, free */
void *customdata;
/* to prevent cpu overhead, use this one which only gets called when job really starts, not in thread */
@@ -95,14 +95,14 @@ struct wmJob {
void (*free)(void *);
/* gets called when job is stopped, not in thread */
void (*endjob)(void *);
-
+
/* running jobs each have own timer */
double timestep;
wmTimer *wt;
/* the notifier event timers should send */
unsigned int note, endnote;
-
-
+
+
/* internal */
void *owner;
int flag;
@@ -115,7 +115,7 @@ struct wmJob {
/* once running, we store this separately */
void *run_customdata;
void (*run_free)(void *);
-
+
/* we use BLI_threads api, but per job only 1 thread runs */
ListBase threads;
@@ -152,7 +152,7 @@ static void wm_job_main_thread_yield(wmJob *wm_job)
static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type)
{
wmJob *wm_job;
-
+
if (owner && job_type) {
for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next)
if (wm_job->owner == owner && wm_job->job_type == job_type)
@@ -168,7 +168,7 @@ static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type)
if (wm_job->job_type == job_type)
return wm_job;
}
-
+
return NULL;
}
@@ -183,7 +183,7 @@ static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type)
wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag, int job_type)
{
wmJob *wm_job = wm_job_find(wm, owner, job_type);
-
+
if (wm_job == NULL) {
wm_job = MEM_callocN(sizeof(wmJob), "new job");
@@ -198,7 +198,7 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *
WM_job_main_thread_lock_acquire(wm_job);
}
/* else: a running job, be careful */
-
+
/* prevent creating a job with an invalid type */
BLI_assert(wm_job->job_type != WM_JOB_TYPE_ANY);
@@ -209,7 +209,7 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *
bool WM_jobs_test(wmWindowManager *wm, void *owner, int job_type)
{
wmJob *wm_job;
-
+
/* job can be running or about to run (suspended) */
for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) {
if (wm_job->owner == owner) {
@@ -227,10 +227,10 @@ bool WM_jobs_test(wmWindowManager *wm, void *owner, int job_type)
float WM_jobs_progress(wmWindowManager *wm, void *owner)
{
wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
-
+
if (wm_job && wm_job->flag & WM_JOB_PROGRESS)
return wm_job->progress;
-
+
return 0.0;
}
@@ -248,30 +248,30 @@ double WM_jobs_starttime(wmWindowManager *wm, void *owner)
char *WM_jobs_name(wmWindowManager *wm, void *owner)
{
wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
-
+
if (wm_job)
return wm_job->name;
-
+
return NULL;
}
void *WM_jobs_customdata(wmWindowManager *wm, void *owner)
{
wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
-
+
if (wm_job)
return WM_jobs_customdata_get(wm_job);
-
+
return NULL;
}
void *WM_jobs_customdata_from_type(wmWindowManager *wm, int job_type)
{
wmJob *wm_job = wm_job_find(wm, NULL, job_type);
-
+
if (wm_job)
return WM_jobs_customdata_get(wm_job);
-
+
return NULL;
}
@@ -301,7 +301,7 @@ void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void (*free)(void *
/* pending job? just free */
if (wm_job->customdata)
wm_job->free(wm_job->customdata);
-
+
wm_job->customdata = customdata;
wm_job->free = free;
@@ -333,10 +333,10 @@ void WM_jobs_callbacks(wmJob *wm_job,
static void *do_job_thread(void *job_v)
{
wmJob *wm_job = job_v;
-
+
wm_job->startjob(wm_job->run_customdata, &wm_job->stop, &wm_job->do_update, &wm_job->progress);
wm_job->ready = true;
-
+
return NULL;
}
@@ -345,7 +345,7 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test)
{
wmJob *wm_job;
bool suspend = false;
-
+
/* job added with suspend flag, we wait 1 timer step before activating it */
if (test->flag & WM_JOB_SUSPEND) {
suspend = true;
@@ -358,12 +358,12 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test)
if (wm_job == test || !wm_job->running) {
continue;
}
-
+
/* if new job is not render, then check for same startjob */
if (0 == (test->flag & WM_JOB_EXCL_RENDER))
if (wm_job->startjob != test->startjob)
continue;
-
+
/* if new job is render, any render job should be stopped */
if (test->flag & WM_JOB_EXCL_RENDER)
if (0 == (wm_job->flag & WM_JOB_EXCL_RENDER))
@@ -378,7 +378,7 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test)
}
}
}
-
+
/* Possible suspend ourselves, waiting for other jobs, or de-suspend. */
test->suspended = suspend;
// if (suspend) printf("job suspended: %s\n", test->name);
@@ -396,11 +396,11 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
// printf("job started a running job, ending... %s\n", wm_job->name);
}
else {
-
+
if (wm_job->customdata && wm_job->startjob) {
-
+
wm_jobs_test_suspend_stop(wm, wm_job);
-
+
if (wm_job->suspended == false) {
/* copy to ensure proper free in end */
wm_job->run_customdata = wm_job->customdata;
@@ -408,20 +408,20 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
wm_job->free = NULL;
wm_job->customdata = NULL;
wm_job->running = true;
-
+
if (wm_job->initjob)
wm_job->initjob(wm_job->run_customdata);
-
+
wm_job->stop = false;
wm_job->ready = false;
wm_job->progress = 0.0;
// printf("job started: %s\n", wm_job->name);
-
+
BLI_threadpool_init(&wm_job->threads, do_job_thread, 1);
BLI_threadpool_insert(&wm_job->threads, wm_job);
}
-
+
/* restarted job has timer already */
if (wm_job->wt == NULL)
wm_job->wt = WM_event_add_timer(wm, wm_job->win, TIMERJOBS, wm_job->timestep);
@@ -456,14 +456,14 @@ static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *wm_job)
if (wm_job->endjob)
wm_job->endjob(wm_job->run_customdata);
}
-
+
if (wm_job->wt)
WM_event_remove_timer(wm, wm_job->win, wm_job->wt);
if (wm_job->customdata)
wm_job->free(wm_job->customdata);
if (wm_job->run_customdata)
wm_job->run_free(wm_job->run_customdata);
-
+
/* remove wm_job */
wm_job_free(wm, wm_job);
}
@@ -472,17 +472,17 @@ static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *wm_job)
void WM_jobs_kill_all(wmWindowManager *wm)
{
wmJob *wm_job;
-
+
while ((wm_job = wm->jobs.first))
wm_jobs_kill_job(wm, wm_job);
-
+
}
/* wait until every job ended, except for one owner (used in undo to keep screen job alive) */
void WM_jobs_kill_all_except(wmWindowManager *wm, void *owner)
{
wmJob *wm_job, *next_job;
-
+
for (wm_job = wm->jobs.first; wm_job; wm_job = next_job) {
next_job = wm_job->next;
@@ -495,7 +495,7 @@ void WM_jobs_kill_all_except(wmWindowManager *wm, void *owner)
void WM_jobs_kill_type(struct wmWindowManager *wm, void *owner, int job_type)
{
wmJob *wm_job, *next_job;
-
+
for (wm_job = wm->jobs.first; wm_job; wm_job = next_job) {
next_job = wm_job->next;
@@ -509,7 +509,7 @@ void WM_jobs_kill_type(struct wmWindowManager *wm, void *owner, int job_type)
void WM_jobs_stop(wmWindowManager *wm, void *owner, void *startjob)
{
wmJob *wm_job;
-
+
for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) {
if (wm_job->owner == owner || wm_job->startjob == startjob) {
if (wm_job->running) {
@@ -523,7 +523,7 @@ void WM_jobs_stop(wmWindowManager *wm, void *owner, void *startjob)
void WM_jobs_kill(wmWindowManager *wm, void *owner, void (*startjob)(void *, short int *, short int *, float *))
{
wmJob *wm_job;
-
+
wm_job = wm->jobs.first;
while (wm_job) {
if (wm_job->owner == owner || wm_job->startjob == startjob) {
@@ -542,7 +542,7 @@ void WM_jobs_kill(wmWindowManager *wm, void *owner, void (*startjob)(void *, sho
void wm_jobs_timer_ended(wmWindowManager *wm, wmTimer *wt)
{
wmJob *wm_job;
-
+
for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) {
if (wm_job->wt == wt) {
wm_jobs_kill_job(wm, wm_job);
@@ -557,18 +557,18 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
wmJob *wm_job, *wm_jobnext;
float total_progress = 0.f;
float jobs_progress = 0;
-
+
for (wm_job = wm->jobs.first; wm_job; wm_job = wm_jobnext) {
wm_jobnext = wm_job->next;
-
+
if (wm_job->wt == wt) {
-
+
/* running threads */
if (wm_job->threads.first) {
/* let threads get temporary lock over main thread if needed */
wm_job_main_thread_yield(wm_job);
-
+
/* always call note and update when ready */
if (wm_job->do_update || wm_job->ready) {
if (wm_job->update)
@@ -580,7 +580,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
WM_event_add_notifier(C, NC_WM | ND_JOB, NULL);
wm_job->do_update = false;
}
-
+
if (wm_job->ready) {
if (wm_job->endjob)
wm_job->endjob(wm_job->run_customdata);
@@ -589,7 +589,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
wm_job->run_free(wm_job->run_customdata);
wm_job->run_customdata = NULL;
wm_job->run_free = NULL;
-
+
// if (wm_job->stop) printf("job ready but stopped %s\n", wm_job->name);
// else printf("job finished %s\n", wm_job->name);
@@ -603,10 +603,10 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
WM_job_main_thread_lock_release(wm_job);
BLI_threadpool_end(&wm_job->threads);
WM_job_main_thread_lock_acquire(wm_job);
-
+
if (wm_job->endnote)
WM_event_add_notifier(C, wm_job->endnote, NULL);
-
+
WM_event_add_notifier(C, NC_WM | ND_JOB, NULL);
/* new job added for wm_job? */
@@ -617,7 +617,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
else {
WM_event_remove_timer(wm, wm_job->win, wm_job->wt);
wm_job->wt = NULL;
-
+
/* remove wm_job */
wm_job_free(wm, wm_job);
}
@@ -640,8 +640,8 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
}
}
}
-
-
+
+
/* if there are running jobs, set the global progress indicator */
if (jobs_progress > 0) {
wmWindow *win;
@@ -656,7 +656,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
for (win = wm->windows.first; win; win = win->next)
WM_progress_clear(win);
}
-
+
}
bool WM_jobs_has_running(wmWindowManager *wm)
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index f2387846fd2..67493454e8f 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -1,11 +1,11 @@
/*
- *
+ *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,7 +19,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -238,7 +238,7 @@ static wmKeyMapDiffItem *wm_keymap_diff_item_copy(wmKeyMapDiffItem *kmdi)
kmdin->add_item = wm_keymap_item_copy(kmdi->add_item);
if (kmdi->remove_item)
kmdin->remove_item = wm_keymap_item_copy(kmdi->remove_item);
-
+
return kmdin;
}
@@ -261,7 +261,7 @@ static void wm_keymap_diff_item_free(wmKeyMapDiffItem *kmdi)
wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname)
{
wmKeyConfig *keyconf;
-
+
keyconf = MEM_callocN(sizeof(wmKeyConfig), "wmKeyConfig");
BLI_strncpy(keyconf->idname, idname, sizeof(keyconf->idname));
BLI_addtail(&wm->keyconfigs, keyconf);
@@ -316,7 +316,7 @@ static wmKeyConfig *WM_keyconfig_active(wmWindowManager *wm)
keyconf = BLI_findstring(&wm->keyconfigs, U.keyconfigstr, offsetof(wmKeyConfig, idname));
if (keyconf)
return keyconf;
-
+
/* otherwise use default */
return wm->defaultconf;
}
@@ -457,16 +457,16 @@ static void keymap_item_set_id(wmKeyMap *keymap, wmKeyMapItem *kmi)
wmKeyMapItem *WM_keymap_verify_item(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
{
wmKeyMapItem *kmi;
-
+
for (kmi = keymap->items.first; kmi; kmi = kmi->next)
if (STREQLEN(kmi->idname, idname, OP_MAX_TYPENAME))
break;
if (kmi == NULL) {
kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
-
+
BLI_addtail(&keymap->items, kmi);
BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME);
-
+
keymap_item_set_id(keymap, kmi);
keymap_event_set(kmi, type, val, modifier, keymodifier);
@@ -479,7 +479,7 @@ wmKeyMapItem *WM_keymap_verify_item(wmKeyMap *keymap, const char *idname, int ty
wmKeyMapItem *WM_keymap_add_item(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
{
wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
-
+
BLI_addtail(&keymap->items, kmi);
BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME);
@@ -557,7 +557,7 @@ static wmKeyMapItem *wm_keymap_find_item_equals(wmKeyMap *km, wmKeyMapItem *need
for (kmi = km->items.first; kmi; kmi = kmi->next)
if (wm_keymap_item_equals(kmi, needle))
return kmi;
-
+
return NULL;
}
@@ -568,7 +568,7 @@ static wmKeyMapItem *wm_keymap_find_item_equals_result(wmKeyMap *km, wmKeyMapIte
for (kmi = km->items.first; kmi; kmi = kmi->next)
if (wm_keymap_item_equals_result(kmi, needle))
return kmi;
-
+
return NULL;
}
@@ -731,7 +731,7 @@ static wmKeyMap *wm_keymap_patch_update(ListBase *lb, wmKeyMap *defaultmap, wmKe
/* add to list */
BLI_addtail(lb, km);
-
+
return km;
}
@@ -779,7 +779,7 @@ static void wm_keymap_diff_update(ListBase *lb, wmKeyMap *defaultmap, wmKeyMap *
/* ****************** storage in WM ************ */
-/* name id's are for storing general or multiple keymaps,
+/* name id's are for storing general or multiple keymaps,
* space/region ids are same as DNA_space_types.h */
/* gets freed in wm.c */
@@ -791,21 +791,21 @@ wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int
if (km->spaceid == spaceid && km->regionid == regionid)
if (STREQLEN(idname, km->idname, KMAP_MAX_NAME))
return km;
-
+
return NULL;
}
wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
{
wmKeyMap *km = WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
-
+
if (km == NULL) {
km = wm_keymap_new(idname, spaceid, regionid);
BLI_addtail(&keyconf->keymaps, km);
WM_keyconfig_update_tag(km, NULL);
}
-
+
return km;
}
@@ -838,19 +838,19 @@ wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, const char *idname, const Enu
}
}
}
-
+
return km;
}
wmKeyMap *WM_modalkeymap_get(wmKeyConfig *keyconf, const char *idname)
{
wmKeyMap *km;
-
+
for (km = keyconf->keymaps.first; km; km = km->next)
if (km->flag & KEYMAP_MODAL)
if (STREQLEN(idname, km->idname, KMAP_MAX_NAME))
break;
-
+
return km;
}
@@ -858,10 +858,10 @@ wmKeyMap *WM_modalkeymap_get(wmKeyConfig *keyconf, const char *idname)
wmKeyMapItem *WM_modalkeymap_add_item(wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value)
{
wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
-
+
BLI_addtail(&km->items, kmi);
kmi->propvalue = value;
-
+
keymap_event_set(kmi, type, val, modifier, keymodifier);
keymap_item_set_id(km, kmi);
@@ -1129,7 +1129,7 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
/* skip disabled keymap items [T38447] */
if (kmi->flag & KMI_INACTIVE)
continue;
-
+
if (STREQ(kmi->idname, opname) && WM_key_event_string(kmi->type, false)[0]) {
if (is_hotkey) {
if (!ISHOTKEY(kmi->type))
@@ -1197,7 +1197,7 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
}
}
}
-
+
/* ensure un-initialized keymap is never used */
if (r_keymap) *r_keymap = NULL;
return NULL;
@@ -1231,7 +1231,7 @@ static wmKeyMapItem *wm_keymap_item_find_props(
if (sa) {
if (!(ar && ar->regiontype == RGN_TYPE_WINDOW))
ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
-
+
if (ar)
found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, is_strict, is_hotkey, r_keymap);
}
@@ -1447,7 +1447,7 @@ static bool wm_keymap_test_and_clear_update(wmKeyMap *km)
{
wmKeyMapItem *kmi;
int update;
-
+
update = (km->flag & KEYMAP_UPDATE);
km->flag &= ~KEYMAP_UPDATE;
@@ -1455,7 +1455,7 @@ static bool wm_keymap_test_and_clear_update(wmKeyMap *km)
update = update || (kmi->flag & KMI_UPDATE);
kmi->flag &= ~KMI_UPDATE;
}
-
+
return (update != 0);
}
@@ -1513,7 +1513,7 @@ void WM_keyconfig_update(wmWindowManager *wm)
if (wm_keymap_update_flag == 0)
return;
-
+
/* update operator properties for non-modal user keymaps */
for (km = U.user_keymaps.first; km; km = km->next) {
if ((km->flag & KEYMAP_MODAL) == 0) {
@@ -1586,7 +1586,7 @@ wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap)
if (!keymap)
return NULL;
-
+
/* first user defined keymaps */
km = WM_keymap_list_find(&wm->userconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
@@ -1678,13 +1678,13 @@ void WM_keymap_restore_to_default(wmKeyMap *keymap, bContext *C)
wmKeyMapItem *WM_keymap_item_find_id(wmKeyMap *keymap, int id)
{
wmKeyMapItem *kmi;
-
+
for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
if (kmi->id == id) {
return kmi;
}
}
-
+
return NULL;
}
@@ -1708,7 +1708,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
wmKeyMap *km = NULL;
SpaceLink *sl = CTX_wm_space_data(C);
-
+
/* Window */
if (STRPREFIX(opname, "WM_OT")) {
km = WM_keymap_find_all(C, "Window", 0, 0);
@@ -1735,8 +1735,8 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
{
km = WM_keymap_find_all(C, "Window", 0, 0);
}
-
-
+
+
/* 3D View */
else if (STRPREFIX(opname, "VIEW3D_OT")) {
km = WM_keymap_find_all(C, "3D View", sl->spacetype, 0);
@@ -1756,11 +1756,11 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
{
km = WM_keymap_find_all(C, "Object Mode", 0, 0);
}
-
+
/* Editing Modes */
else if (STRPREFIX(opname, "MESH_OT")) {
km = WM_keymap_find_all(C, "Mesh", 0, 0);
-
+
/* some mesh operators are active in object mode too, like add-prim */
if (km && !WM_keymap_poll((bContext *)C, km)) {
km = WM_keymap_find_all(C, "Object Mode", 0, 0);
@@ -1770,7 +1770,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
STRPREFIX(opname, "SURFACE_OT"))
{
km = WM_keymap_find_all(C, "Curve", 0, 0);
-
+
/* some curve operators are active in object mode too, like add-prim */
if (km && !WM_keymap_poll((bContext *)C, km)) {
km = WM_keymap_find_all(C, "Object Mode", 0, 0);
@@ -1798,7 +1798,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
}
else if (STRPREFIX(opname, "MBALL_OT")) {
km = WM_keymap_find_all(C, "Metaball", 0, 0);
-
+
/* some mball operators are active in object mode too, like add-prim */
if (km && !WM_keymap_poll((bContext *)C, km)) {
km = WM_keymap_find_all(C, "Object Mode", 0, 0);
@@ -1939,7 +1939,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
break;
}
}
-
+
return km;
}
diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c
index 72e4ff1d83a..8e2f41c49e0 100644
--- a/source/blender/windowmanager/intern/wm_operator_props.c
+++ b/source/blender/windowmanager/intern/wm_operator_props.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 7cf1fe3bdfa..20c4d2700aa 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -252,15 +252,15 @@ static int wm_macro_exec(bContext *C, wmOperator *op)
{
wmOperator *opm;
int retval = OPERATOR_FINISHED;
-
+
wm_macro_start(op);
for (opm = op->macro.first; opm; opm = opm->next) {
-
+
if (opm->type->exec) {
retval = opm->type->exec(C, opm);
OPERATOR_RETVAL_CHECK(retval);
-
+
if (retval & OPERATOR_FINISHED) {
MacroData *md = op->customdata;
md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */
@@ -273,7 +273,7 @@ static int wm_macro_exec(bContext *C, wmOperator *op)
CLOG_WARN(WM_LOG_OPERATORS, "'%s' cant exec macro", opm->type->idname);
}
}
-
+
return wm_macro_end(op, retval);
}
@@ -291,7 +291,7 @@ static int wm_macro_invoke_internal(bContext *C, wmOperator *op, const wmEvent *
OPERATOR_RETVAL_CHECK(retval);
BLI_movelisttolist(&op->reports->list, &opm->reports->list);
-
+
if (retval & OPERATOR_FINISHED) {
MacroData *md = op->customdata;
md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */
@@ -314,7 +314,7 @@ static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
wmOperator *opm = op->opm;
int retval = OPERATOR_FINISHED;
-
+
if (opm == NULL) {
CLOG_ERROR(WM_LOG_OPERATORS, "macro error, calling NULL modal()");
}
@@ -389,20 +389,20 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *nam
{
wmOperatorType *ot;
const char *i18n_context;
-
+
if (WM_operatortype_find(idname, true)) {
CLOG_ERROR(WM_LOG_OPERATORS, "operator %s exists, cannot create macro", idname);
return NULL;
}
-
+
ot = MEM_callocN(sizeof(wmOperatorType), "operatortype");
ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties);
-
+
ot->idname = idname;
ot->name = name;
ot->description = description;
ot->flag = OPTYPE_MACRO | flag;
-
+
ot->exec = wm_macro_exec;
ot->invoke = wm_macro_invoke;
ot->modal = wm_macro_modal;
@@ -411,7 +411,7 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *nam
if (!ot->description) /* XXX All ops should have a description but for now allow them not to. */
ot->description = UNDOCUMENTED_OPERATOR_TIP;
-
+
RNA_def_struct_ui_text(ot->srna, ot->name, ot->description);
RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
/* Use i18n context from ext.srna if possible (py operators). */
@@ -479,7 +479,7 @@ wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char
static void wm_operatortype_free_macro(wmOperatorType *ot)
{
wmOperatorTypeMacro *otmacro;
-
+
for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) {
if (otmacro->ptr) {
WM_operator_properties_free(otmacro->ptr);
@@ -598,7 +598,7 @@ void WM_operator_py_idname(char *to, const char *from)
const char *sep = strstr(from, "_OT_");
if (sep) {
int ofs = (sep - from);
-
+
/* note, we use ascii tolower instead of system tolower, because the
* latter depends on the locale, and can lead to idname mismatch */
memcpy(to, from, sizeof(char) * ofs);
@@ -1317,7 +1317,7 @@ int WM_operator_confirm_message_ex(bContext *C, wmOperator *op,
layout = UI_popup_menu_layout(pup);
uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0, NULL);
UI_popup_menu_end(C, pup);
-
+
return OPERATOR_INTERFACE;
}
@@ -1408,6 +1408,7 @@ void WM_operator_last_properties_ensure(wmOperatorType *ot, PointerRNA *ptr)
*/
ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short idcode)
{
+ Main *bmain = CTX_data_main(C);
ID *id = NULL;
/* check input variables */
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
@@ -1420,7 +1421,7 @@ ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short i
errno = 0;
if (idcode == ID_IM) {
- id = (ID *)BKE_image_load_exists_ex(path, &exists);
+ id = (ID *)BKE_image_load_exists_ex(bmain, path, &exists);
}
else {
BLI_assert(0);
@@ -1435,10 +1436,8 @@ ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short i
if (is_relative_path ) {
if (exists == false) {
- Main *bmain = CTX_data_main(C);
-
if (idcode == ID_IM) {
- BLI_path_rel(((Image *)id)->name, bmain->name);
+ BLI_path_rel(((Image *)id)->name, BKE_main_blendfile_path(bmain));
}
else {
BLI_assert(0);
@@ -1449,7 +1448,7 @@ ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short i
else if (RNA_struct_property_is_set(op->ptr, "name")) {
char name[MAX_ID_NAME - 2];
RNA_string_get(op->ptr, "name", name);
- id = BKE_libblock_find_name(idcode, name);
+ id = BKE_libblock_find_name(bmain, idcode, name);
if (!id) {
BKE_reportf(op->reports, RPT_ERROR, "%s '%s' not found",
BKE_idcode_to_name(idcode), name);
@@ -1523,7 +1522,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
}
-
+
UI_block_bounds_set_popup(block, 4, 0, 0);
return block;
@@ -1589,10 +1588,10 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData)
UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_NUMSELECT);
layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style);
-
+
uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
-
+
/* clear so the OK button is left alone */
UI_block_func_set(block, NULL, NULL, NULL);
@@ -1664,7 +1663,7 @@ static void wm_operator_ui_popup_ok(struct bContext *C, void *arg, int retval)
if (op && retval > 0)
WM_operator_call_ex(C, op, true);
-
+
MEM_freeN(data);
}
@@ -1740,7 +1739,7 @@ int WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent *UNUSED(e
int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, int height)
{
wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_props_dialog_popup");
-
+
data->op = op;
data->width = width;
data->height = height;
@@ -1764,7 +1763,7 @@ int WM_operator_redo_popup(bContext *C, wmOperator *op)
BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Operator redo '%s': wrong context", op->type->idname);
return OPERATOR_CANCELLED;
}
-
+
UI_popup_block_invoke(C, wm_block_create_redo, op);
return OPERATOR_CANCELLED;
@@ -1792,11 +1791,11 @@ static void WM_OT_debug_menu(wmOperatorType *ot)
ot->name = "Debug Menu";
ot->idname = "WM_OT_debug_menu";
ot->description = "Open a popup to set the debug level";
-
+
ot->invoke = wm_debug_menu_invoke;
ot->exec = wm_debug_menu_exec;
ot->poll = WM_operator_winactive;
-
+
RNA_def_int(ot->srna, "debug_value", 0, SHRT_MIN, SHRT_MAX, "Debug Value", "", -10000, 10000);
}
@@ -1899,7 +1898,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
/* Builds made from tag only shows tag sha */
BLI_snprintf(hash_buf, sizeof(hash_buf), "Hash: %s", build_hash);
BLI_snprintf(date_buf, sizeof(date_buf), "Date: %s %s", build_commit_date, build_commit_time);
-
+
BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.pixelsize * U.dpi);
hash_width = (int)BLF_width(style->widgetlabel.uifont_id, hash_buf, sizeof(hash_buf)) + U.widget_unit;
date_width = (int)BLF_width(style->widgetlabel.uifont_id, date_buf, sizeof(date_buf)) + U.widget_unit;
@@ -2012,9 +2011,9 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
UI_but_flag_enable(but, 1);
}
#endif /* WITH_BUILDINFO */
-
+
layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, U.pixelsize * 480, U.pixelsize * 110, 0, style);
-
+
UI_block_emboss_set(block, UI_EMBOSS);
/* show the splash menu (containing interaction presets), using python */
if (mt) {
@@ -2023,10 +2022,10 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
// wmWindowManager *wm = CTX_wm_manager(C);
// uiItemM(layout, C, "USERPREF_MT_keyconfigs", U.keyconfigstr, ICON_NONE);
}
-
+
UI_block_emboss_set(block, UI_EMBOSS_PULLDOWN);
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
-
+
split = uiLayoutSplit(layout, 0.0f, false);
col = uiLayoutColumn(split, false);
uiItemL(col, IFACE_("Links"), ICON_NONE);
@@ -2072,21 +2071,21 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
uiItemS(col);
uiItemO(col, NULL, ICON_RECOVER_LAST, "WM_OT_recover_last_session");
uiItemL(col, "", ICON_NONE);
-
+
mt = WM_menutype_find("USERPREF_MT_splash_footer", false);
if (mt) {
UI_menutype_draw(C, mt, uiLayoutColumn(layout, false));
}
UI_block_bounds_set_centered(block, 0);
-
+
return block;
}
static int wm_splash_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
{
UI_popup_block_invoke(C, wm_block_create_splash, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -2095,7 +2094,7 @@ static void WM_OT_splash(wmOperatorType *ot)
ot->name = "Splash Screen";
ot->idname = "WM_OT_splash";
ot->description = "Open the splash screen with release info";
-
+
ot->invoke = wm_splash_invoke;
ot->poll = WM_operator_winactive;
}
@@ -2115,26 +2114,26 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *userdata)
wmWindow *win = CTX_wm_window(C);
uiBlock *block;
uiBut *but;
-
+
block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU);
-
+
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, init_data->size[0], UI_UNIT_Y, 0, 0, "");
UI_but_func_operator_search(but);
-
+
/* fake button, it holds space for search items */
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - init_data->size[1],
init_data->size[0], init_data->size[1], NULL, 0, 0, 0, 0, NULL);
-
+
UI_block_bounds_set_popup(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */
-
+
wm_event_init_from_window(win, &event);
event.type = EVT_BUT_OPEN;
event.val = KM_PRESS;
event.customdata = but;
event.customdatafree = false;
wm_event_add(win, &event);
-
+
return block;
}
@@ -2153,7 +2152,7 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv
};
UI_popup_block_invoke(C, wm_block_search_menu, &data);
-
+
return OPERATOR_INTERFACE;
}
@@ -2182,7 +2181,7 @@ static void WM_OT_search_menu(wmOperatorType *ot)
ot->name = "Search Menu";
ot->idname = "WM_OT_search_menu";
ot->description = "Pop-up a search menu over all available operators in current context";
-
+
ot->invoke = wm_search_menu_invoke;
ot->exec = wm_search_menu_exec;
ot->poll = wm_search_menu_poll;
@@ -2247,8 +2246,9 @@ static int wm_call_panel_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "name", idname);
const int space_type = RNA_enum_get(op->ptr, "space_type");
const int region_type = RNA_enum_get(op->ptr, "region_type");
+ const bool keep_open = RNA_boolean_get(op->ptr, "keep_open");
- return UI_popover_panel_invoke(C, space_type, region_type, idname, true, op->reports);
+ return UI_popover_panel_invoke(C, space_type, region_type, idname, keep_open, op->reports);
}
static void WM_OT_call_panel(wmOperatorType *ot)
@@ -2262,9 +2262,16 @@ static void WM_OT_call_panel(wmOperatorType *ot)
ot->flag = OPTYPE_INTERNAL;
- RNA_def_string(ot->srna, "name", NULL, BKE_ST_MAXNAME, "Name", "Name of the menu");
- RNA_def_enum(ot->srna, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Space Type", "");
- RNA_def_enum(ot->srna, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
+ PropertyRNA *prop;
+
+ prop = RNA_def_string(ot->srna, "name", NULL, BKE_ST_MAXNAME, "Name", "Name of the menu");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_enum(ot->srna, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Space Type", "");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_enum(ot->srna, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna, "keep_open", true, "Keep Open", "");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/* ************ window / screen operator definitions ************** */
@@ -2365,7 +2372,7 @@ static void WM_OT_console_toggle(wmOperatorType *ot)
ot->name = CTX_N_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Toggle System Console");
ot->idname = "WM_OT_console_toggle";
ot->description = N_("Toggle System Console");
-
+
ot->exec = wm_console_toggle_exec;
ot->poll = WM_operator_winactive;
}
@@ -2383,20 +2390,20 @@ void *WM_paint_cursor_activate(wmWindowManager *wm, int (*poll)(bContext *C),
wmPaintCursorDraw draw, void *customdata)
{
wmPaintCursor *pc = MEM_callocN(sizeof(wmPaintCursor), "paint cursor");
-
+
BLI_addtail(&wm->paintcursors, pc);
-
+
pc->customdata = customdata;
pc->poll = poll;
pc->draw = draw;
-
+
return pc;
}
void WM_paint_cursor_end(wmWindowManager *wm, void *handle)
{
wmPaintCursor *pc;
-
+
for (pc = wm->paintcursors.first; pc; pc = pc->next) {
if (pc == (wmPaintCursor *)handle) {
BLI_remlink(&wm->paintcursors, pc);
@@ -2439,7 +2446,7 @@ static void radial_control_update_header(wmOperator *op, bContext *C)
char msg[UI_MAX_DRAW_STR];
ScrArea *sa = CTX_wm_area(C);
Scene *scene = CTX_data_scene(C);
-
+
if (sa) {
if (hasNumInput(&rc->num_input)) {
char num_str[NUM_STR_REP_LEN];
@@ -2556,7 +2563,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
RNA_property_float_get_array(fill_ptr, fill_prop, col);
}
-
+
Gwn_VertFormat *format = immVertexFormat();
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -2593,10 +2600,10 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
immAttrib2f(texCoord, 1, 0);
immVertex2f(pos, radius, -radius);
-
+
immAttrib2f(texCoord, 1, 1);
immVertex2f(pos, radius, radius);
-
+
immAttrib2f(texCoord, 0, 1);
immVertex2f(pos, -radius, radius);
@@ -2612,7 +2619,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
immUniformColor3fvAlpha(col, alpha);
imm_draw_circle_fill_2d(pos, 0.0f, 0.0f, radius, 40);
}
-
+
immUnbindProgram();
}
@@ -2627,7 +2634,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void
short strdrawlen = 0;
float strwidth, strheight;
float r1 = 0.0f, r2 = 0.0f, rmin = 0.0, tex_radius, alpha;
- float zoom[2], col[3] = {1, 1, 1};
+ float zoom[2], col[3] = {1, 1, 1};
switch (rc->subtype) {
case PROP_NONE:
@@ -2801,7 +2808,7 @@ static int radial_control_get_path(
return 0;
}
}
-
+
/* check property's array length */
if (*r_prop && (len = RNA_property_array_length(r_ptr, *r_prop)) != req_length) {
MEM_freeN(str);
@@ -2850,7 +2857,7 @@ static int radial_control_get_properties(bContext *C, wmOperator *op)
/* data path is required */
if (!rc->prop)
return 0;
-
+
if (!radial_control_get_path(&ctx_ptr, op, "rotation_path", &rc->rot_ptr, &rc->rot_prop, 0, RC_PROP_REQUIRE_FLOAT))
return 0;
if (!radial_control_get_path(&ctx_ptr, op, "color_path", &rc->col_ptr, &rc->col_prop, 3, RC_PROP_REQUIRE_FLOAT))
@@ -2885,7 +2892,7 @@ static int radial_control_get_properties(bContext *C, wmOperator *op)
{
return 0;
}
-
+
if (!radial_control_get_path(&ctx_ptr, op, "image_id", &rc->image_id_ptr, NULL, 0, 0))
return 0;
else if (rc->image_id_ptr.data) {
@@ -3008,7 +3015,7 @@ static void radial_control_cancel(bContext *C, wmOperator *op)
if (sa) {
ED_area_headerprint(sa, NULL);
}
-
+
WM_paint_cursor_end(wm, rc->cursor);
/* restore original paint cursors */
@@ -3049,10 +3056,10 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even
if (numValue < 0.0f)
numValue += 2.0f * (float)M_PI;
}
-
+
CLAMP(numValue, rc->min_value, rc->max_value);
new_value = numValue;
-
+
radial_control_set_value(rc, new_value);
rc->current_value = new_value;
radial_control_update_header(op, C);
@@ -3203,9 +3210,9 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even
CLAMP(numValue, rc->min_value, rc->max_value);
new_value = numValue;
-
+
radial_control_set_value(rc, new_value);
-
+
rc->current_value = new_value;
radial_control_update_header(op, C);
return OPERATOR_RUNNING_MODAL;
@@ -3409,7 +3416,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
a = 0;
}
}
-
+
time_delta = (PIL_check_seconds_timer() - time_start) * 1000;
RNA_enum_description(redraw_timer_type_items, type, &infostr);
@@ -3419,7 +3426,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
BKE_reportf(op->reports, RPT_WARNING,
"%d x %s: %.4f ms, average: %.8f ms",
iter_steps, infostr, time_delta, time_delta / iter_steps);
-
+
return OPERATOR_FINISHED;
}
@@ -3453,7 +3460,7 @@ static void WM_OT_memory_statistics(wmOperatorType *ot)
ot->name = "Memory Statistics";
ot->idname = "WM_OT_memory_statistics";
ot->description = "Print memory statistics to the console";
-
+
ot->exec = memory_statistics_exec;
}
@@ -3818,21 +3825,21 @@ static void gesture_straightline_modal_keymap(wmKeyConfig *keyconf)
{GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Gesture Straight Line");
-
+
/* this function is called for each spacetype, only needs to add map once */
if (keymap && keymap->modal_items) return;
-
+
keymap = WM_modalkeymap_add(keyconf, "Gesture Straight Line", modal_items);
-
+
/* items for modal map */
WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL);
WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, GESTURE_MODAL_CANCEL);
-
+
WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_BEGIN);
WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_SELECT);
-
+
/* assign map to operators */
WM_modalkeymap_assign(keymap, "IMAGE_OT_sample_line");
WM_modalkeymap_assign(keymap, "PAINT_OT_weight_gradient");
@@ -3860,7 +3867,7 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf)
/* items for modal map */
WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL);
-
+
/* Note: cancel only on press otherwise you cannot map this to RMB-gesture */
WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL);
WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_SELECT);
@@ -3872,10 +3879,10 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf)
/* any unhandled leftclick release handles select */
WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_BEGIN);
WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_SELECT);
-
+
WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_BEGIN);
WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, 0, 0, GESTURE_MODAL_DESELECT);
-
+
/* assign map to operators */
WM_modalkeymap_assign(keymap, "ACTION_OT_select_border");
WM_modalkeymap_assign(keymap, "ANIM_OT_channels_select_border");
@@ -3929,7 +3936,7 @@ static void gesture_zoom_border_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, GESTURE_MODAL_CANCEL);
WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_BEGIN);
- WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, 0, 0, GESTURE_MODAL_IN);
+ WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, 0, 0, GESTURE_MODAL_IN);
WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_BEGIN);
WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, 0, 0, GESTURE_MODAL_OUT);
@@ -3945,7 +3952,7 @@ void wm_window_keymap(wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_find(keyconf, "Window", 0, 0);
wmKeyMapItem *kmi;
-
+
/* note, this doesn't replace existing keymap items */
WM_keymap_verify_item(keymap, "WM_OT_window_new", WKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
#ifdef __APPLE__
@@ -3957,7 +3964,7 @@ void wm_window_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "WM_OT_quit_blender", QKEY, KM_PRESS, KM_OSKEY, 0);
#endif
WM_keymap_add_item(keymap, "WM_OT_read_homefile", NKEY, KM_PRESS, KM_CTRL, 0);
- WM_keymap_add_item(keymap, "WM_OT_save_homefile", UKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "WM_OT_save_homefile", UKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_menu(keymap, "INFO_MT_file_open_recent", OKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
WM_keymap_add_item(keymap, "WM_OT_open_mainfile", OKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "WM_OT_open_mainfile", F1KEY, KM_PRESS, 0, 0);
@@ -3982,9 +3989,7 @@ void wm_window_keymap(wmKeyConfig *keyconf)
/* menus that can be accessed anywhere in blender */
-#if 0 /* Now double-tap via toolbar. */
- WM_keymap_verify_item(keymap, "WM_OT_search_menu", SPACEKEY, KM_PRESS, 0, 0);
-#endif
+ WM_keymap_verify_item(keymap, "WM_OT_search_menu", ACCENTGRAVEKEY, KM_RELEASE, 0, 0);
#ifdef WITH_INPUT_NDOF
WM_keymap_add_menu(keymap, "USERPREF_MT_ndof_settings", NDOF_BUTTON_MENU, KM_PRESS, 0, 0);
@@ -4032,7 +4037,7 @@ void wm_window_keymap(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", F12KEY, KM_PRESS, KM_SHIFT, 0);
RNA_string_set(kmi->ptr, "data_path", "area.type");
RNA_string_set(kmi->ptr, "value", "DOPESHEET_EDITOR");
-
+
#ifdef WITH_INPUT_NDOF
/* ndof speed */
const char *data_path = "user_preferences.inputs.ndof_sensitivity";
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index d6a1eb81981..d93d51df105 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -101,7 +101,7 @@ typedef struct PlayState {
/* window and viewport size */
int win_x, win_y;
-
+
/* current zoom level */
float zoom;
@@ -122,7 +122,7 @@ typedef struct PlayState {
bool loading;
/* x/y image flip */
bool draw_flip[2];
-
+
int fstep;
/* current picture */
@@ -134,7 +134,7 @@ typedef struct PlayState {
/* saves passing args */
struct ImBuf *curframe_ibuf;
-
+
/* restarts player for file drop */
char dropped_file[FILE_MAX];
} PlayState;
@@ -946,13 +946,13 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
{
GHOST_TEventButtonData *bd = GHOST_GetEventData(evt);
int cx, cy, sizex, sizey, inside_window;
-
+
GHOST_GetCursorPosition(g_WS.ghost_system, &cx, &cy);
GHOST_ScreenToClient(g_WS.ghost_window, cx, cy, &cx, &cy);
playanim_window_get_size(&sizex, &sizey);
inside_window = (cx >= 0 && cx < sizex && cy >= 0 && cy <= sizey);
-
+
if (bd->button == GHOST_kButtonMaskLeft) {
if (type == GHOST_kEventButtonDown) {
if (inside_window) {
@@ -1016,23 +1016,23 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
case GHOST_kEventWindowMove:
{
float zoomx, zoomy;
-
+
playanim_window_get_size(&ps->win_x, &ps->win_y);
GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
zoomx = (float) ps->win_x / ps->ibufx;
zoomy = (float) ps->win_y / ps->ibufy;
-
+
/* zoom always show entire image */
ps->zoom = MIN2(zoomx, zoomy);
-
+
/* zoom steps of 2 for speed */
ps->zoom = floor(ps->zoom + 0.5f);
if (ps->zoom < 1.0f) ps->zoom = 1.0f;
-
+
glViewport(0, 0, ps->win_x, ps->win_y);
glScissor(0, 0, ps->win_x, ps->win_y);
-
+
playanim_gl_matrix();
ptottime = 0.0;
@@ -1049,11 +1049,11 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
case GHOST_kEventDraggingDropDone:
{
GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt);
-
+
if (ddd->dataType == GHOST_kDragnDropTypeFilenames) {
GHOST_TStringArray *stra = ddd->data;
int a;
-
+
for (a = 0; a < stra->count; a++) {
BLI_strncpy(ps->dropped_file, (char *)stra->strings[a], sizeof(ps->dropped_file));
ps->go = false;
@@ -1120,7 +1120,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
int sfra = -1;
int efra = -1;
int totblock;
-
+
PlayState ps = {0};
/* ps.doubleb = true;*/ /* UNUSED */
@@ -1271,14 +1271,14 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
ps.ibufx = ibuf->x;
ps.ibufy = ibuf->y;
-
+
ps.win_x = ps.ibufx;
ps.win_y = ps.ibufy;
if (maxwinx % ibuf->x) maxwinx = ibuf->x * (1 + (maxwinx / ibuf->x));
if (maxwiny % ibuf->y) maxwiny = ibuf->y * (1 + (maxwiny / ibuf->y));
-
+
glClearColor(0.1, 0.1, 0.1, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
@@ -1547,7 +1547,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
BLI_strncpy(filepath, ps.dropped_file, sizeof(filepath));
return filepath;
}
-
+
IMB_exit();
BKE_images_exit();
DEG_free_node_types();
@@ -1560,7 +1560,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
MEM_printmemlist();
#endif
}
-
+
return NULL;
}
diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c
index 89a12206a66..f55eee69f71 100644
--- a/source/blender/windowmanager/intern/wm_subwindow.c
+++ b/source/blender/windowmanager/intern/wm_subwindow.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index d734fee05ae..cee5079a02f 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -186,7 +186,7 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
Main *bmain = CTX_data_main(C);
/* Currently only brush data-blocks supported. */
- struct Brush *brush = (struct Brush *)BKE_libblock_find_name(ID_BR, tref_rt->data_block);
+ struct Brush *brush = (struct Brush *)BKE_libblock_find_name(bmain, ID_BR, tref_rt->data_block);
if (brush) {
wmWindowManager *wm = bmain->wm.first;
@@ -461,23 +461,52 @@ static void toolsystem_refresh_screen_from_active_tool(
}
}
-static void toolsystem_reinit_with_toolref(
- bContext *C, WorkSpace *workspace, bToolRef *tref)
+bToolRef *WM_toolsystem_ref_set_by_name(
+ bContext *C, WorkSpace *workspace, const bToolKey *tkey,
+ const char *name, bool cycle)
{
wmOperatorType *ot = WM_operatortype_find("WM_OT_tool_set_by_name", false);
/* On startup, Python operatores are not yet loaded. */
if (ot == NULL) {
- return;
+ return NULL;
}
PointerRNA op_props;
WM_operator_properties_create_ptr(&op_props, ot);
- RNA_string_set(&op_props, "name", tref->idname);
- RNA_enum_set(&op_props, "space_type", tref->space_type);
+ RNA_string_set(&op_props, "name", name);
+
+ /* Will get from context if not set. */
+ bToolKey tkey_from_context;
+ if (tkey == NULL) {
+ Scene *scene = CTX_data_scene(C);
+ ScrArea *sa = CTX_wm_area(C);
+ WM_toolsystem_key_from_context(workspace, scene, sa, &tkey_from_context);
+ tkey = &tkey_from_context;
+ }
+
+ RNA_enum_set(&op_props, "space_type", tkey->space_type);
+ RNA_boolean_set(&op_props, "cycle", cycle);
+
WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &op_props);
WM_operator_properties_free(&op_props);
- Main *bmain = CTX_data_main(C);
- toolsystem_refresh_screen_from_active_tool(bmain, workspace, tref);
+ bToolRef *tref = WM_toolsystem_ref_find(workspace, tkey);
+
+ if (tref) {
+ Main *bmain = CTX_data_main(C);
+ toolsystem_refresh_screen_from_active_tool(bmain, workspace, tref);
+ }
+
+ return (tref && STREQ(tref->idname, name)) ? tref : NULL;
+}
+
+static void toolsystem_reinit_with_toolref(
+ bContext *C, WorkSpace *workspace, bToolRef *tref)
+{
+ bToolKey tkey = {
+ .space_type = tref->space_type,
+ .mode = tref->mode,
+ };
+ WM_toolsystem_ref_set_by_name(C, workspace, &tkey, tref->idname, false);
}
/**
@@ -512,7 +541,7 @@ void WM_toolsystem_update_from_context_view3d(bContext *C)
bool WM_toolsystem_active_tool_is_brush(const bContext *C)
{
bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C);
- return tref_rt->data_block[0] != '\0';
+ return tref_rt && (tref_rt->data_block[0] != '\0');
}
/* Follow wmMsgNotifyFn spec */
diff --git a/source/blender/windowmanager/intern/wm_tooltip.c b/source/blender/windowmanager/intern/wm_tooltip.c
index 83d620d1522..6096317b582 100644
--- a/source/blender/windowmanager/intern/wm_tooltip.c
+++ b/source/blender/windowmanager/intern/wm_tooltip.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 0c3d2544bb4..e1528551c12 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * The Original Code is Copyright (C) 2007 Blender Foundation but based
+ * The Original Code is Copyright (C) 2007 Blender Foundation but based
* on ghostwinlay.c (C) 2001-2002 by NaN Holding BV
* All rights reserved.
*
@@ -35,7 +35,7 @@
#include <stdio.h>
#include <string.h>
-#include "DNA_listBase.h"
+#include "DNA_listBase.h"
#include "DNA_screen_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_workspace_types.h"
@@ -85,6 +85,8 @@
#include "GPU_framebuffer.h"
#include "GPU_init_exit.h"
#include "GPU_immediate.h"
+#include "GPU_material.h"
+#include "GPU_texture.h"
#include "BLF_api.h"
#include "UI_resources.h"
@@ -112,7 +114,7 @@ static struct WMInitStruct {
int windowstate;
WinOverrideFlag override_flag;
-
+
bool native_pixels;
} wm_init_state = {0, 0, 0, 0, GHOST_kWindowStateNormal, 0, true};
@@ -124,7 +126,7 @@ void wm_get_screensize(int *r_width, int *r_height)
{
unsigned int uiwidth;
unsigned int uiheight;
-
+
GHOST_GetMainDisplayDimensions(g_system, &uiwidth, &uiheight);
*r_width = uiwidth;
*r_height = uiheight;
@@ -146,9 +148,9 @@ void wm_get_desktopsize(int *r_width, int *r_height)
static void wm_window_check_position(rcti *rect)
{
int width, height, d;
-
+
wm_get_screensize(&width, &height);
-
+
if (rect->xmin < 0) {
rect->xmax -= rect->xmin;
rect->xmin = 0;
@@ -167,7 +169,7 @@ static void wm_window_check_position(rcti *rect)
rect->ymax -= d;
rect->ymin -= d;
}
-
+
if (rect->xmin < 0) rect->xmin = 0;
if (rect->ymin < 0) rect->ymin = 0;
}
@@ -193,12 +195,12 @@ static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win)
}
}
-/* including window itself, C can be NULL.
+/* including window itself, C can be NULL.
* ED_screen_exit should have been called */
void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
{
wmTimer *wt, *wtnext;
-
+
/* update context */
if (C) {
WM_event_remove_handlers(C, &win->handlers);
@@ -216,7 +218,7 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
if (wt->win == win && wt->event_type == TIMERJOBS)
wm_jobs_timer_ended(wm, wt);
}
-
+
/* timer removing, need to call this api function */
for (wt = wm->timers.first; wt; wt = wtnext) {
wtnext = wt->next;
@@ -225,7 +227,7 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
}
if (win->eventstate) MEM_freeN(win->eventstate);
-
+
wm_event_free_all(win);
wm_ghostwindow_destroy(wm, win);
@@ -240,11 +242,11 @@ static int find_free_winid(wmWindowManager *wm)
{
wmWindow *win;
int id = 1;
-
+
for (win = wm->windows.first; win; win = win->next)
if (id <= win->winid)
id = win->winid + 1;
-
+
return id;
}
@@ -287,6 +289,7 @@ static wmWindow *wm_window_new_test(bContext *C)
/* part of wm_window.c api */
wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_layout)
{
+ Main *bmain = CTX_data_main(C);
wmWindow *win_dst = wm_window_new(C);
WorkSpace *workspace = WM_window_get_active_workspace(win_src);
WorkSpaceLayout *layout_old = WM_window_get_active_layout(win_src);
@@ -300,7 +303,7 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_la
win_dst->scene = scene;
WM_window_set_active_workspace(win_dst, workspace);
- layout_new = duplicate_layout ? ED_workspace_layout_duplicate(workspace, layout_old, win_dst) : layout_old;
+ layout_new = duplicate_layout ? ED_workspace_layout_duplicate(bmain, workspace, layout_old, win_dst) : layout_old;
WM_window_set_active_layout(win_dst, workspace, layout_new);
*win_dst->stereo3d_format = *win_src->stereo3d_format;
@@ -373,6 +376,7 @@ static void wm_block_confirm_quit_save(bContext *C, void *arg_block, void *UNUSE
/* Build the confirm dialog UI */
static uiBlock *block_create_confirm_quit(struct bContext *C, struct ARegion *ar, void *UNUSED(arg1))
{
+ Main *bmain = CTX_data_main(C);
uiStyle *style = UI_style_get();
uiBlock *block = UI_block_begin(C, ar, "confirm_quit_popup", UI_EMBOSS);
@@ -386,11 +390,11 @@ static uiBlock *block_create_confirm_quit(struct bContext *C, struct ARegion *ar
/* Text and some vertical space */
{
char *message;
- if (G.main->name[0] == '\0') {
+ if (BKE_main_blendfile_path(bmain)[0] == '\0') {
message = BLI_strdup(IFACE_("This file has not been saved yet. Save before closing?"));
}
else {
- const char *basename = BLI_path_basename(G.main->name);
+ const char *basename = BLI_path_basename(BKE_main_blendfile_path(bmain));
message = BLI_sprintfN(IFACE_("Save changes to \"%s\" before closing?"), basename);
}
uiItemL(layout, message, ICON_ERROR);
@@ -483,7 +487,7 @@ void wm_quit_with_optional_confirmation_prompt(bContext *C, wmWindow *win)
void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
{
wmWindow *tmpwin;
-
+
/* first check if we have to quit (there are non-temp remaining windows) */
for (tmpwin = wm->windows.first; tmpwin; tmpwin = tmpwin->next) {
if (tmpwin == win)
@@ -501,7 +505,7 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
WorkSpaceLayout *layout = BKE_workspace_active_layout_get(win->workspace_hook);
BLI_remlink(&wm->windows, win);
-
+
CTX_wm_window_set(C, win); /* needed by handlers */
WM_event_remove_handlers(C, &win->handlers);
WM_event_remove_handlers(C, &win->modalhandlers);
@@ -545,9 +549,10 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
}
else if (win->ghostwin) {
/* this is set to 1 if you don't have startup.blend open */
- if (G.save_over && G.main->name[0]) {
- char str[sizeof(G.main->name) + 24];
- BLI_snprintf(str, sizeof(str), "Blender%s [%s%s]", wm->file_saved ? "" : "*", G.main->name,
+ if (G.save_over && BKE_main_blendfile_path_from_global()[0]) {
+ char str[sizeof(((Main *)NULL)->name) + 24];
+ BLI_snprintf(str, sizeof(str), "Blender%s [%s%s]", wm->file_saved ? "" : "*",
+ BKE_main_blendfile_path_from_global(),
G.main->recovered ? " (Recovered)" : "");
GHOST_SetTitle(win->ghostwin, str);
}
@@ -558,7 +563,7 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
* and to give hint of unsaved changes for a user warning mechanism
* in case of OS application terminate request (e.g. OS Shortcut Alt+F4, Cmd+Q, (...), or session end) */
GHOST_SetWindowModifiedState(win->ghostwin, (GHOST_TUns8) !wm->file_saved);
-
+
}
}
@@ -624,7 +629,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
GHOST_WindowHandle ghostwin;
GHOST_GLSettings glSettings = {0};
int scr_w, scr_h, posy;
-
+
/* a new window is created when pageflip mode is required for a window */
if (win->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP)
glSettings.flags |= GHOST_glStereoVisual;
@@ -635,7 +640,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
wm_get_screensize(&scr_w, &scr_h);
posy = (scr_h - win->posy - win->sizey);
-
+
ghostwin = GHOST_CreateWindow(g_system, title,
win->posx, posy, win->sizex, win->sizey,
(GHOST_TWindowState)win->windowstate,
@@ -651,16 +656,16 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
gpu_batch_presets_reset();
win->gwnctx = GWN_context_create();
-
+
/* the new window has already been made drawable upon creation */
wm->windrawable = win;
/* needed so we can detect the graphics card below */
GPU_init();
-
+
win->ghostwin = ghostwin;
GHOST_SetWindowUserData(ghostwin, win); /* pointer back */
-
+
wm_window_ensure_eventstate(win);
/* store actual window size in blender window */
@@ -672,7 +677,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
win->sizey = GHOST_GetHeightRectangle(bounds);
}
GHOST_DisposeRectangle(bounds);
-
+
#ifndef __APPLE__
/* set the state here, so minimized state comes up correct on windows */
GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate);
@@ -683,16 +688,15 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) {
glClear(GL_COLOR_BUFFER_BIT);
}
-
+
/* needed here, because it's used before it reads userdef */
WM_window_set_dpi(win);
-
+
wm_window_swap_buffers(win);
-
+
//GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified);
-
+
/* standard state vars for window */
- glEnable(GL_SCISSOR_TEST);
GPU_state_init();
}
}
@@ -714,7 +718,7 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm)
{
wmKeyMap *keymap;
wmWindow *win;
-
+
BLI_assert(G.background == false);
/* no commandline prefsize? then we set this.
@@ -723,7 +727,7 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm)
*/
if (wm_init_state.size_x == 0) {
wm_get_screensize(&wm_init_state.size_x, &wm_init_state.size_y);
-
+
/* note!, this isnt quite correct, active screen maybe offset 1000s if PX,
* we'd need a wm_get_screensize like function that gives offset,
* in practice the window manager will likely move to the correct monitor */
@@ -741,7 +745,7 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm)
wm_init_state.size_y -= WM_WIN_INIT_PAD * 2;
#endif
}
-
+
for (win = wm->windows.first; win; win = win->next) {
if (win->ghostwin == NULL) {
if ((win->sizex == 0) || (wm_init_state.override_flag & WIN_OVERRIDE_GEOM)) {
@@ -772,13 +776,13 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm)
/* add keymap handlers (1 handler for all keys in map!) */
keymap = WM_keymap_find(wm->defaultconf, "Window", 0, 0);
WM_event_add_keymap_handler(&win->handlers, keymap);
-
+
keymap = WM_keymap_find(wm->defaultconf, "Screen", 0, 0);
WM_event_add_keymap_handler(&win->handlers, keymap);
keymap = WM_keymap_find(wm->defaultconf, "Screen Editing", 0, 0);
WM_event_add_keymap_handler(&win->modalhandlers, keymap);
-
+
/* add drop boxes */
{
ListBase *lb = WM_dropboxmap_find("Window", 0, 0);
@@ -821,7 +825,7 @@ wmWindow *WM_window_open(bContext *C, const rcti *rect)
{
wmWindow *win_prev = CTX_wm_window(C);
wmWindow *win = wm_window_new(C);
-
+
win->posx = rect->xmin;
win->posy = rect->ymin;
win->sizex = BLI_rcti_size_x(rect);
@@ -872,16 +876,16 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
/* changes rect to fit within desktop */
wm_window_check_position(&rect);
-
+
/* test if we have a temp screen already */
for (win = CTX_wm_manager(C)->windows.first; win; win = win->next)
if (WM_window_is_temp_screen(win))
break;
-
+
/* add new window? */
if (win == NULL) {
win = wm_window_new(C);
-
+
win->posx = rect.xmin;
win->posy = rect.ymin;
}
@@ -904,7 +908,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
if (screen == NULL) {
/* add new screen layout */
WorkSpace *workspace = WM_window_get_active_workspace(win);
- WorkSpaceLayout *layout = ED_workspace_layout_add(workspace, win, "temp");
+ WorkSpaceLayout *layout = ED_workspace_layout_add(bmain, workspace, win, "temp");
screen = BKE_workspace_layout_screen_get(layout);
WM_window_set_active_layout(win, workspace, layout);
@@ -933,7 +937,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
/* ensure it shows the right spacetype editor */
sa = screen->areabase.first;
CTX_wm_area_set(C, sa);
-
+
if (type == WM_WINDOW_RENDER) {
ED_area_newspace(C, sa, SPACE_IMAGE, false);
}
@@ -943,26 +947,26 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
else {
ED_area_newspace(C, sa, SPACE_USERPREF, false);
}
-
+
ED_screen_change(C, screen);
ED_screen_refresh(CTX_wm_manager(C), win); /* test scale */
-
+
/* do additional setup for specific editor type */
if (type == WM_WINDOW_DRIVERS) {
/* Configure editor - mode, tabs, framing */
SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first;
sipo->mode = SIPO_MODE_DRIVERS;
-
+
ARegion *ar_props = BKE_area_find_region_type(sa, RGN_TYPE_UI);
if (ar_props) {
UI_panel_category_active_set(ar_props, "Drivers");
-
+
ar_props->flag &= ~RGN_FLAG_HIDDEN;
/* XXX: Adjust width of this too? */
-
+
ED_region_visibility_change_update(C, ar_props);
}
-
+
ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
if (ar_main) {
/* XXX: Ideally we recenter based on the range instead... */
@@ -970,11 +974,11 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
ar_main->v2d.tot.ymin = -2.0f;
ar_main->v2d.tot.xmax = 2.0f;
ar_main->v2d.tot.ymax = 2.0f;
-
+
ar_main->v2d.cur = ar_main->v2d.tot;
}
}
-
+
if (sa->spacetype == SPACE_IMAGE)
title = IFACE_("Blender Render");
else if (ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_USERPREF))
@@ -1029,6 +1033,7 @@ static WorkSpaceLayout *wm_window_new_find_layout(wmOperator *op, WorkSpace *wor
/* new window operator callback */
int wm_window_new_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
wmWindow *win_src = CTX_wm_window(C);
WorkSpace *workspace = WM_window_get_active_workspace(win_src);
WorkSpaceLayout *layout_new = wm_window_new_find_layout(op, workspace);
@@ -1038,7 +1043,7 @@ int wm_window_new_exec(bContext *C, wmOperator *op)
if ((win_dst = wm_window_new_test(C))) {
if (screen_new->winid) {
/* layout/screen is already used, duplicate it */
- layout_new = ED_workspace_layout_duplicate(workspace, layout_new, win_dst);
+ layout_new = ED_workspace_layout_duplicate(bmain, workspace, layout_new, win_dst);
screen_new = BKE_workspace_layout_screen_get(layout_new);
}
/* New window with a different screen but same workspace */
@@ -1129,7 +1134,7 @@ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op))
GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateNormal);
return OPERATOR_FINISHED;
-
+
}
@@ -1138,10 +1143,10 @@ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op))
void wm_cursor_position_from_ghost(wmWindow *win, int *x, int *y)
{
float fac = GHOST_GetNativePixelSize(win->ghostwin);
-
+
GHOST_ScreenToClient(win->ghostwin, *x, *y, x, y);
*x *= fac;
-
+
*y = (win->sizey - 1) - *y;
*y *= fac;
}
@@ -1171,11 +1176,11 @@ typedef enum {
} modifierKeyType;
/* check if specified modifier key type is pressed */
-static int query_qual(modifierKeyType qual)
+static int query_qual(modifierKeyType qual)
{
GHOST_TModifierKeyMask left, right;
int val = 0;
-
+
switch (qual) {
case SHIFT:
left = GHOST_kModifierKeyLeftShift;
@@ -1194,15 +1199,15 @@ static int query_qual(modifierKeyType qual)
right = GHOST_kModifierKeyRightAlt;
break;
}
-
+
GHOST_GetModifierKeyState(g_system, left, &val);
if (!val)
GHOST_GetModifierKeyState(g_system, right, &val);
-
+
return val;
}
-void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win)
+void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win)
{
BLI_assert(GPU_framebuffer_current_get() == 0);
@@ -1256,7 +1261,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
wmWindowManager *wm = CTX_wm_manager(C);
GHOST_TEventType type = GHOST_GetEventType(evt);
int time = GHOST_GetEventTime(evt);
-
+
if (type == GHOST_kEventQuit) {
WM_exit(C);
}
@@ -1264,7 +1269,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
GHOST_WindowHandle ghostwin = GHOST_GetEventWindow(evt);
GHOST_TEventDataPtr data = GHOST_GetEventData(evt);
wmWindow *win;
-
+
/* Ghost now can call this function for life resizes, but it should return if WM didn't initialize yet.
* Can happen on file read (especially full size window) */
if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) {
@@ -1285,12 +1290,12 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
else {
win = GHOST_GetWindowUserData(ghostwin);
}
-
+
switch (type) {
case GHOST_kEventWindowDeactivate:
wm_event_add_ghostevent(wm, win, type, time, data);
win->active = 0; /* XXX */
-
+
/* clear modifiers for inactive windows */
win->eventstate->alt = 0;
win->eventstate->ctrl = 0;
@@ -1299,7 +1304,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
win->eventstate->keymodifier = 0;
break;
- case GHOST_kEventWindowActivate:
+ case GHOST_kEventWindowActivate:
{
GHOST_TEventKeyData kdata;
wmEvent event;
@@ -1315,10 +1320,10 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
#endif
wm->winactive = win; /* no context change! c->wm->windrawable is drawable, or for area queues */
-
+
win->active = 1;
// window_handle(win, INPUTCHANGE, win->active);
-
+
/* bad ghost support for modifier keys... so on activate we set the modifiers again */
/* TODO: This is not correct since a modifier may be held when a window is activated...
@@ -1387,15 +1392,15 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
/* keymodifier zero, it hangs on hotkeys that open windows otherwise */
win->eventstate->keymodifier = 0;
-
+
/* entering window, update mouse pos. but no event */
wm_get_cursor_position(win, &wx, &wy);
win->eventstate->x = wx;
win->eventstate->y = wy;
-
+
win->addmousemove = 1; /* enables highlighted buttons */
-
+
wm_window_make_drawable(wm, win);
/* window might be focused by mouse click in configuration of window manager
@@ -1426,7 +1431,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
if (G.debug & G_DEBUG_EVENTS) {
printf("%s: ghost redraw %d\n", __func__, win->winid);
}
-
+
wm_window_make_drawable(wm, win);
WM_event_add_notifier(C, NC_WINDOW, NULL);
@@ -1445,18 +1450,18 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
}
WM_window_set_dpi(win);
-
+
/* win32: gives undefined window size when minimized */
if (state != GHOST_kWindowStateMinimized) {
GHOST_RectangleHandle client_rect;
int l, t, r, b, scr_w, scr_h;
int sizex, sizey, posx, posy;
-
+
client_rect = GHOST_GetClientBounds(win->ghostwin);
GHOST_GetRectangle(client_rect, &l, &t, &r, &b);
-
+
GHOST_DisposeRectangle(client_rect);
-
+
wm_get_desktopsize(&scr_w, &scr_h);
sizex = r - l;
sizey = b - t;
@@ -1467,8 +1472,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
* Ghost sometimes send size or move events when the window hasn't changed.
* One case of this is using compiz on linux. To alleviate the problem
* we ignore all such event here.
- *
- * It might be good to eventually do that at Ghost level, but that is for
+ *
+ * It might be good to eventually do that at Ghost level, but that is for
* another time.
*/
if (win->sizex != sizex ||
@@ -1511,12 +1516,12 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
win->posx, win->posy, win->sizex, win->sizey);
}
}
-
+
wm_window_make_drawable(wm, win);
BKE_icon_changed(screen->id.icon_id);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL);
-
+
#if defined(__APPLE__) || defined(WIN32)
/* OSX and Win32 don't return to the mainloop while resize */
wm_event_do_notifiers(C);
@@ -1547,19 +1552,19 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
PointerRNA props_ptr;
wmWindow *oldWindow;
const char *path = GHOST_GetEventData(evt);
-
+
if (path) {
wmOperatorType *ot = WM_operatortype_find("WM_OT_open_mainfile", false);
/* operator needs a valid window in context, ensures
* it is correctly set */
oldWindow = CTX_wm_window(C);
CTX_wm_window_set(C, win);
-
+
WM_operator_properties_create_ptr(&props_ptr, ot);
RNA_string_set(&props_ptr, "filepath", path);
WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &props_ptr);
WM_operator_properties_free(&props_ptr);
-
+
CTX_wm_window_set(C, oldWindow);
}
break;
@@ -1569,53 +1574,53 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
wmEvent event;
GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt);
int wx, wy;
-
+
/* entering window, update mouse pos */
wm_get_cursor_position(win, &wx, &wy);
win->eventstate->x = wx;
win->eventstate->y = wy;
-
+
wm_event_init_from_window(win, &event); /* copy last state, like mouse coords */
-
+
/* activate region */
event.type = MOUSEMOVE;
event.prevx = event.x;
event.prevy = event.y;
-
+
wm->winactive = win; /* no context change! c->wm->windrawable is drawable, or for area queues */
win->active = 1;
-
+
wm_event_add(win, &event);
-
-
+
+
/* make blender drop event with custom data pointing to wm drags */
event.type = EVT_DROP;
event.val = KM_RELEASE;
event.custom = EVT_DATA_DRAGDROP;
event.customdata = &wm->drags;
event.customdatafree = 1;
-
+
wm_event_add(win, &event);
-
+
/* printf("Drop detected\n"); */
-
+
/* add drag data to wm for paths: */
-
+
if (ddd->dataType == GHOST_kDragnDropTypeFilenames) {
GHOST_TStringArray *stra = ddd->data;
int a, icon;
-
+
for (a = 0; a < stra->count; a++) {
printf("drop file %s\n", stra->strings[a]);
/* try to get icon type from extension */
icon = ED_file_extension_icon((char *)stra->strings[a]);
-
+
WM_event_start_drag(C, icon, WM_DRAG_PATH, stra->strings[a], 0.0, WM_DRAG_NOP);
/* void poin should point to string, it makes a copy */
break; /* only one drop element supported now */
}
}
-
+
break;
}
case GHOST_kEventNativeResolutionChange:
@@ -1645,7 +1650,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
case GHOST_kEventTrackpad:
{
GHOST_TEventTrackpadData *pd = data;
-
+
wm_cursor_position_from_ghost(win, &pd->x, &pd->y);
wm_event_add_ghostevent(wm, win, type, time, data);
break;
@@ -1653,7 +1658,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
case GHOST_kEventCursorMove:
{
GHOST_TEventCursorData *cd = data;
-
+
wm_cursor_position_from_ghost(win, &cd->x, &cd->y);
wm_event_add_ghostevent(wm, win, type, time, data);
break;
@@ -1681,7 +1686,7 @@ static int wm_window_timer(const bContext *C)
wmWindow *win;
double time = PIL_check_seconds_timer();
int retval = 0;
-
+
for (wt = wm->timers.first; wt; wt = wtnext) {
wtnext = wt->next; /* in case timer gets removed */
win = wt->win;
@@ -1702,7 +1707,7 @@ static int wm_window_timer(const bContext *C)
else if (win) {
wmEvent event;
wm_event_init_from_window(win, &event);
-
+
event.type = wt->event_type;
event.val = KM_NOTHING;
event.keymodifier = 0;
@@ -1718,7 +1723,7 @@ static int wm_window_timer(const bContext *C)
return retval;
}
-void wm_window_process_events(const bContext *C)
+void wm_window_process_events(const bContext *C)
{
int hasevent;
@@ -1728,7 +1733,7 @@ void wm_window_process_events(const bContext *C)
if (hasevent)
GHOST_DispatchEvents(g_system);
-
+
hasevent |= wm_window_timer(C);
/* no event, we sleep 5 milliseconds */
@@ -1736,7 +1741,7 @@ void wm_window_process_events(const bContext *C)
PIL_sleep_ms(5);
}
-void wm_window_process_events_nosleep(void)
+void wm_window_process_events_nosleep(void)
{
if (GHOST_ProcessEvents(g_system, 0))
GHOST_DispatchEvents(g_system);
@@ -1755,10 +1760,10 @@ void wm_window_testbreak(void)
*/
if ((curtime - ltime) > 0.05) {
int hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
-
+
if (hasevent)
GHOST_DispatchEvents(g_system);
-
+
ltime = curtime;
}
}
@@ -1775,13 +1780,13 @@ void wm_ghost_init(bContext *C)
if (C != NULL) {
consumer = GHOST_CreateEventConsumer(ghost_event_proc, C);
}
-
+
g_system = GHOST_CreateSystem();
if (C != NULL) {
GHOST_AddEventConsumer(g_system, consumer);
}
-
+
if (wm_init_state.native_pixels) {
GHOST_UseNativePixels();
}
@@ -1802,7 +1807,7 @@ void wm_ghost_exit(void)
void WM_event_timer_sleep(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer, bool do_sleep)
{
wmTimer *wt;
-
+
for (wt = wm->timers.first; wt; wt = wt->next)
if (wt == timer)
break;
@@ -1821,9 +1826,9 @@ wmTimer *WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type,
wt->stime = wt->ltime;
wt->timestep = timestep;
wt->win = win;
-
+
BLI_addtail(&wm->timers, wt);
-
+
return wt;
}
@@ -1848,23 +1853,23 @@ wmTimer *WM_event_add_timer_notifier(wmWindowManager *wm, wmWindow *win, unsigne
void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
{
wmTimer *wt;
-
+
/* extra security check */
for (wt = wm->timers.first; wt; wt = wt->next)
if (wt == timer)
break;
if (wt) {
wmWindow *win;
-
+
if (wm->reports.reporttimer == wt)
wm->reports.reporttimer = NULL;
-
+
BLI_remlink(&wm->timers, wt);
if (wt->customdata != NULL && (wt->flags & WM_TIMER_NO_FREE_CUSTOM_DATA) == 0) {
MEM_freeN(wt->customdata);
}
MEM_freeN(wt);
-
+
/* there might be events in queue with this timer as customdata */
for (win = wm->windows.first; win; win = win->next) {
wmEvent *event;
@@ -1901,7 +1906,7 @@ static char *wm_clipboard_text_get_ex(bool selection, int *r_len,
*r_len = 0;
return NULL;
}
-
+
/* always convert from \r\n to \n */
p2 = newbuf = MEM_mallocN(strlen(buf) + 1, __func__);
@@ -1927,7 +1932,7 @@ static char *wm_clipboard_text_get_ex(bool selection, int *r_len,
*p2 = '\0';
free(buf); /* ghost uses regular malloc */
-
+
*r_len = (p2 - newbuf);
return newbuf;
@@ -1959,16 +1964,16 @@ void WM_clipboard_text_set(const char *buf, bool selection)
const char *p;
char *p2, *newbuf;
int newlen = 0;
-
+
for (p = buf; *p; p++) {
if (*p == '\n')
newlen += 2;
else
newlen++;
}
-
+
newbuf = MEM_callocN(newlen + 1, "WM_clipboard_text_set");
-
+
for (p = buf, p2 = newbuf; *p; p++, p2++) {
if (*p == '\n') {
*(p2++) = '\r'; *p2 = '\n';
@@ -1978,7 +1983,7 @@ void WM_clipboard_text_set(const char *buf, bool selection)
}
}
*p2 = '\0';
-
+
GHOST_putClipboard((GHOST_TInt8 *)newbuf, selection);
MEM_freeN(newbuf);
#else
@@ -2007,30 +2012,26 @@ void wm_window_get_position(wmWindow *win, int *r_pos_x, int *r_pos_y)
*r_pos_y = win->posy;
}
-void wm_window_set_size(wmWindow *win, int width, int height)
+void wm_window_set_size(wmWindow *win, int width, int height)
{
GHOST_SetClientSize(win->ghostwin, width, height);
}
-void wm_window_lower(wmWindow *win)
+void wm_window_lower(wmWindow *win)
{
GHOST_SetWindowOrder(win->ghostwin, GHOST_kWindowOrderBottom);
}
-void wm_window_raise(wmWindow *win)
+void wm_window_raise(wmWindow *win)
{
GHOST_SetWindowOrder(win->ghostwin, GHOST_kWindowOrderTop);
}
void wm_window_swap_buffers(wmWindow *win)
{
-#ifdef WIN32
- glDisable(GL_SCISSOR_TEST);
- GHOST_SwapWindowBuffers(win->ghostwin);
- glEnable(GL_SCISSOR_TEST);
-#else
+ GPU_texture_orphans_delete(); /* XXX should be done elsewhere. */
+ GPU_material_orphans_delete(); /* XXX Amen to that. */
GHOST_SwapWindowBuffers(win->ghostwin);
-#endif
}
void wm_window_set_swap_interval (wmWindow *win, int interval)
@@ -2124,13 +2125,13 @@ float WM_cursor_pressure(const struct wmWindow *win)
int WM_window_pixels_x(const wmWindow *win)
{
float f = GHOST_GetNativePixelSize(win->ghostwin);
-
+
return (int)(f * (float)win->sizex);
}
int WM_window_pixels_y(const wmWindow *win)
{
float f = GHOST_GetNativePixelSize(win->ghostwin);
-
+
return (int)(f * (float)win->sizey);
}
diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h
index 073adef177c..c92691eb65e 100644
--- a/source/blender/windowmanager/wm.h
+++ b/source/blender/windowmanager/wm.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -41,7 +41,7 @@ typedef struct wmPaintCursor {
struct wmPaintCursor *next, *prev;
void *customdata;
-
+
int (*poll)(struct bContext *C);
void (*draw)(bContext *C, int, int, void *customdata);
} wmPaintCursor;
@@ -54,7 +54,7 @@ extern void wm_close_and_free_all(bContext *C, ListBase *);
extern void wm_add_default(struct Main *bmain, bContext *C);
extern void wm_clear_default_size(bContext *C);
-
+
/* register to windowmanager for redo or macro */
void wm_operator_register(bContext *C, wmOperator *op);
diff --git a/source/blender/windowmanager/wm_cursors.h b/source/blender/windowmanager/wm_cursors.h
index c695a12f52c..939409f9511 100644
--- a/source/blender/windowmanager/wm_cursors.h
+++ b/source/blender/windowmanager/wm_cursors.h
@@ -39,12 +39,12 @@ void wm_init_cursor_data(void);
/* old cursors */
enum {
CURSOR_FACESEL = BC_GHOST_CURSORS,
- CURSOR_WAIT,
- CURSOR_EDIT,
- CURSOR_X_MOVE,
- CURSOR_Y_MOVE,
- CURSOR_HELP,
- CURSOR_STD,
+ CURSOR_WAIT,
+ CURSOR_EDIT,
+ CURSOR_X_MOVE,
+ CURSOR_Y_MOVE,
+ CURSOR_HELP,
+ CURSOR_STD,
CURSOR_NONE,
CURSOR_PENCIL,
CURSOR_COPY
@@ -57,21 +57,21 @@ typedef struct BCursor {
char *small_bm;
char *small_mask;
- char small_sizex;
- char small_sizey;
- char small_hotx;
- char small_hoty;
+ char small_sizex;
+ char small_sizey;
+ char small_hotx;
+ char small_hoty;
- char *big_bm;
+ char *big_bm;
char *big_mask;
- char big_sizex;
- char big_sizey;
- char big_hotx;
- char big_hoty;
+ char big_sizex;
+ char big_sizey;
+ char big_hotx;
+ char big_hoty;
- char fg_color;
- char bg_color;
+ char fg_color;
+ char bg_color;
} BCursor;
@@ -101,7 +101,7 @@ enum {
enum {
BC_BLACK = 0,
- BC_WHITE,
+ BC_WHITE,
BC_RED,
BC_BLUE,
BC_GREEN,
diff --git a/source/blender/windowmanager/wm_draw.h b/source/blender/windowmanager/wm_draw.h
index 096d241eb64..3761cd043a2 100644
--- a/source/blender/windowmanager/wm_draw.h
+++ b/source/blender/windowmanager/wm_draw.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h
index 3ff853a5576..b9b41b0b685 100644
--- a/source/blender/windowmanager/wm_event_system.h
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index e327bd81d81..be648628079 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -29,7 +29,7 @@
* These define have its origin at sgi, where all device defines were written down in device.h.
* Blender copied the conventions quite some, and expanded it with internal new defines (ton)
*
- */
+ */
#ifndef __WM_EVENT_TYPES_H__
@@ -92,7 +92,7 @@ enum {
WM_IME_COMPOSITE_EVENT = 0x0015,
/* IME event, GHOST_kEventImeCompositionEnd in ghost */
WM_IME_COMPOSITE_END = 0x0016,
-
+
/* Tablet/Pen Specific Events */
TABLET_STYLUS = 0x001a,
TABLET_ERASER = 0x001b,
@@ -368,6 +368,13 @@ enum {
/* test whether the event is a mouse button */
#define ISMOUSE(event_type) ((event_type) >= LEFTMOUSE && (event_type) <= BUTTON7MOUSE)
+#define ISMOUSE_WHEEL(event_type) ((event_type) >= WHEELUPMOUSE && (event_type) <= WHEELOUTMOUSE)
+#define ISMOUSE_GESTURE(event_type) ((event_type) >= MOUSEPAN && (event_type) <= MOUSEROTATE)
+#define ISMOUSE_BUTTON(event_type) \
+ (ELEM(event_type, \
+ LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE, ACTIONMOUSE, SELECTMOUSE, \
+ BUTTON4MOUSE, BUTTON5MOUSE, BUTTON6MOUSE, BUTTON7MOUSE))
+
/* test whether the event is tweak event */
#define ISTWEAK(event_type) ((event_type) >= EVT_TWEAK_L && (event_type) <= EVT_GESTURE)
diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h
index 6f63e55e8ab..4e87202ef5f 100644
--- a/source/blender/windowmanager/wm_files.h
+++ b/source/blender/windowmanager/wm_files.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h
index b0c7021c496..436cf66df85 100644
--- a/source/blender/windowmanager/wm_window.h
+++ b/source/blender/windowmanager/wm_window.h
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 77afdf17e68..c2fd990f451 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -459,7 +459,9 @@ int main(
WM_keymap_init(C);
/* Called on load, however Python is not yet initialized, so call again here. */
- WM_toolsystem_init(C);
+ if (!G.background) {
+ WM_toolsystem_init(C);
+ }
#ifdef WITH_FREESTYLE
/* initialize Freestyle */
diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index 95565b034e9..657ea3f1eb3 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -586,9 +586,8 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo
BLI_argsPrintArgDoc(ba, "--");
- printf("\n");
- printf("Experimental Features:\n");
- BLI_argsPrintArgDoc(ba, "--disable-copy-on-write");
+ //printf("\n");
+ //printf("Experimental Features:\n");
/* Other options _must_ be last (anything not handled will show here) */
printf("\n");
@@ -1289,16 +1288,6 @@ static int arg_handle_threads_set(int argc, const char **argv, void *UNUSED(data
}
}
-static const char arg_handle_use_copy_on_write_doc[] =
-"\n\tUse new dependency graph"
-;
-static int arg_handle_use_copy_on_write(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
-{
- printf("Disabling copy on write. Only use for testing whether something else is at fault\n");
- DEG_depsgraph_disable_copy_on_write();
- return 0;
-}
-
static const char arg_handle_verbosity_set_doc[] =
"<verbose>\n"
"\tSet logging verbosity level."
@@ -1604,8 +1593,9 @@ static int arg_handle_python_text_run(int argc, const char **argv, void *data)
/* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
if (argc > 1) {
+ Main *bmain = CTX_data_main(C);
/* Make the path absolute because its needed for relative linked blends to be found */
- struct Text *text = (struct Text *)BKE_libblock_find_name(ID_TXT, argv[1]);
+ struct Text *text = (struct Text *)BKE_libblock_find_name(bmain, ID_TXT, argv[1]);
bool ok;
if (text) {
@@ -1896,8 +1886,6 @@ void main_args_setup(bContext *C, bArgs *ba)
BLI_argsAdd(ba, 1, NULL, "--debug-gpu-shaders",
CB_EX(arg_handle_debug_mode_generic_set, gpumem), (void *)G_DEBUG_GPU_SHADERS);
- BLI_argsAdd(ba, 1, NULL, "--disable-copy-on-write", CB(arg_handle_use_copy_on_write), NULL);
-
BLI_argsAdd(ba, 1, NULL, "--verbose", CB(arg_handle_verbosity_set), NULL);
BLI_argsAdd(ba, 1, NULL, "--factory-startup", CB(arg_handle_factory_startup_set), NULL);
diff --git a/source/tools b/source/tools
-Subproject 88a1758d2d2e862cc69c08b5b40a4e75f71592d
+Subproject 9d7d338cb25a071f9646cf9ba16f17004c963f7
diff --git a/tests/gtests/alembic/abc_export_test.cc b/tests/gtests/alembic/abc_export_test.cc
index dab1e3ae040..c950084ef64 100644
--- a/tests/gtests/alembic/abc_export_test.cc
+++ b/tests/gtests/alembic/abc_export_test.cc
@@ -16,9 +16,8 @@ extern "C" {
class TestableAbcExporter : public AbcExporter {
public:
TestableAbcExporter(Main *bmain,
- Scene *scene, Depsgraph *depsgraph,
const char *filename, ExportSettings &settings)
- : AbcExporter(bmain, scene, depsgraph, filename, settings)
+ : AbcExporter(bmain, filename, settings)
{
}
@@ -57,7 +56,10 @@ protected:
/* TODO(sergey): Pass scene layer somehow? */
ViewLayer *view_layer = (ViewLayer *)scene.view_layers.first;
- depsgraph = DEG_graph_new(&scene, view_layer, DAG_EVAL_VIEWPORT);
+ settings.depsgraph = depsgraph = DEG_graph_new(&scene, view_layer, DAG_EVAL_VIEWPORT);
+
+ settings.scene = &scene;
+ settings.view_layer = view_layer;
exporter = NULL;
}
@@ -72,7 +74,7 @@ protected:
// Call after setting up the settings.
void createExporter()
{
- exporter = new TestableAbcExporter(bmain, &scene, depsgraph, "somefile.abc", settings);
+ exporter = new TestableAbcExporter(bmain, "somefile.abc", settings);
}
};
diff --git a/tests/gtests/blenlib/BLI_heap_test.cc b/tests/gtests/blenlib/BLI_heap_test.cc
index 82acdabd7eb..dd0bc3451ce 100644
--- a/tests/gtests/blenlib/BLI_heap_test.cc
+++ b/tests/gtests/blenlib/BLI_heap_test.cc
@@ -40,7 +40,7 @@ TEST(heap, One)
const char *in = "test";
heap = BLI_heap_new();
-
+
BLI_heap_insert(heap, 0.0f, (void *)in);
EXPECT_FALSE(BLI_heap_is_empty(heap));
EXPECT_EQ(BLI_heap_len(heap), 1);
diff --git a/tests/python/bl_pyapi_mathutils.py b/tests/python/bl_pyapi_mathutils.py
index 9ca0376192a..b2d3d79fd56 100644
--- a/tests/python/bl_pyapi_mathutils.py
+++ b/tests/python/bl_pyapi_mathutils.py
@@ -127,7 +127,7 @@ class MatrixTesting(unittest.TestCase):
(0, 0, 0, 1)))
vec = Vector((1, 2, 3))
-
+
prod_mat_vec = Vector((7, 12, 4))
prod_vec_mat = Vector((1, 12, 5))
diff --git a/tests/python/collada/animation/test_animation_simple.py b/tests/python/collada/animation/test_animation_simple.py
index 6686d429261..bdfae03aafb 100644
--- a/tests/python/collada/animation/test_animation_simple.py
+++ b/tests/python/collada/animation/test_animation_simple.py
@@ -113,37 +113,37 @@ class MeshExportTest4(AbstractColladaTest):
test = "suzannes_parent_inverse_sample_10_matrix"
reference_dae = self.testdir / Path("%s.dae" % test)
outfile = tempdir / Path("%s_out.dae" % test)
-
+
bpy.ops.wm.collada_export(filepath="%s" % str(outfile),
- check_existing=True,
- filemode=8,
- display_type='DEFAULT',
- sort_method='FILE_SORT_ALPHA',
- apply_modifiers=True,
- export_mesh_type=0,
- export_mesh_type_selection='view',
- selected=True,
- include_children=True,
- include_armatures=True,
- include_shapekeys=False,
- deform_bones_only=False,
- include_animations=True,
- sample_animations=True,
- sampling_rate=10,
- active_uv_only=False,
- use_texture_copies=True,
- triangulate=False,
- use_object_instantiation=True,
- use_blender_profile=True,
- sort_by_name=False,
- export_transformation_type=0,
- export_transformation_type_selection='matrix',
- export_texture_type=0,
- export_texture_type_selection='mat',
- open_sim=False,
- limit_precision=True,
+ check_existing=True,
+ filemode=8,
+ display_type='DEFAULT',
+ sort_method='FILE_SORT_ALPHA',
+ apply_modifiers=True,
+ export_mesh_type=0,
+ export_mesh_type_selection='view',
+ selected=True,
+ include_children=True,
+ include_armatures=True,
+ include_shapekeys=False,
+ deform_bones_only=False,
+ include_animations=True,
+ sample_animations=True,
+ sampling_rate=10,
+ active_uv_only=False,
+ use_texture_copies=True,
+ triangulate=False,
+ use_object_instantiation=True,
+ use_blender_profile=True,
+ sort_by_name=False,
+ export_transformation_type=0,
+ export_transformation_type_selection='matrix',
+ export_texture_type=0,
+ export_texture_type_selection='mat',
+ open_sim=False,
+ limit_precision=True,
keep_bind_info=False)
-
+
# Now check the resulting Collada file.
if not self.checkdae(reference_dae, outfile):
self.fail()
@@ -154,37 +154,37 @@ class MeshExportTest3(AbstractColladaTest):
test = "suzannes_parent_inverse_sample_10_channels"
reference_dae = self.testdir / Path("%s.dae" % test)
outfile = tempdir / Path("%s_out.dae" % test)
-
+
bpy.ops.wm.collada_export(filepath="%s" % str(outfile),
- check_existing=True,
- filemode=8,
- display_type='DEFAULT',
- sort_method='FILE_SORT_ALPHA',
- apply_modifiers=True,
- export_mesh_type=0,
- export_mesh_type_selection='view',
- selected=True,
- include_children=True,
- include_armatures=True,
- include_shapekeys=False,
- deform_bones_only=False,
- include_animations=True,
- sample_animations=True,
- sampling_rate=10,
- active_uv_only=False,
- use_texture_copies=True,
- triangulate=False,
- use_object_instantiation=True,
- use_blender_profile=True,
- sort_by_name=False,
- export_transformation_type=0,
- export_transformation_type_selection='transrotloc',
- export_texture_type=0,
- export_texture_type_selection='mat',
- open_sim=False,
- limit_precision=True,
+ check_existing=True,
+ filemode=8,
+ display_type='DEFAULT',
+ sort_method='FILE_SORT_ALPHA',
+ apply_modifiers=True,
+ export_mesh_type=0,
+ export_mesh_type_selection='view',
+ selected=True,
+ include_children=True,
+ include_armatures=True,
+ include_shapekeys=False,
+ deform_bones_only=False,
+ include_animations=True,
+ sample_animations=True,
+ sampling_rate=10,
+ active_uv_only=False,
+ use_texture_copies=True,
+ triangulate=False,
+ use_object_instantiation=True,
+ use_blender_profile=True,
+ sort_by_name=False,
+ export_transformation_type=0,
+ export_transformation_type_selection='transrotloc',
+ export_texture_type=0,
+ export_texture_type_selection='mat',
+ open_sim=False,
+ limit_precision=True,
keep_bind_info=False)
-
+
# Now check the resulting Collada file.
if not self.checkdae(reference_dae, outfile):
self.fail()
@@ -195,37 +195,37 @@ class MeshExportTest2(AbstractColladaTest):
test = "suzannes_parent_inverse_keyframes_matrix"
reference_dae = self.testdir / Path("%s.dae" % test)
outfile = tempdir / Path("%s_out.dae" % test)
-
+
bpy.ops.wm.collada_export(filepath="%s" % str(outfile),
- check_existing=True,
- filemode=8,
- display_type='DEFAULT',
- sort_method='FILE_SORT_ALPHA',
- apply_modifiers=True,
- export_mesh_type=0,
- export_mesh_type_selection='view',
- selected=True,
- include_children=True,
- include_armatures=True,
- include_shapekeys=False,
- deform_bones_only=False,
- include_animations=True,
- sample_animations=False,
- sampling_rate=1,
- active_uv_only=False,
- use_texture_copies=True,
- triangulate=False,
- use_object_instantiation=True,
- use_blender_profile=True,
- sort_by_name=False,
- export_transformation_type=0,
- export_transformation_type_selection='matrix',
- export_texture_type=0,
- export_texture_type_selection='mat',
- open_sim=False,
- limit_precision=True,
+ check_existing=True,
+ filemode=8,
+ display_type='DEFAULT',
+ sort_method='FILE_SORT_ALPHA',
+ apply_modifiers=True,
+ export_mesh_type=0,
+ export_mesh_type_selection='view',
+ selected=True,
+ include_children=True,
+ include_armatures=True,
+ include_shapekeys=False,
+ deform_bones_only=False,
+ include_animations=True,
+ sample_animations=False,
+ sampling_rate=1,
+ active_uv_only=False,
+ use_texture_copies=True,
+ triangulate=False,
+ use_object_instantiation=True,
+ use_blender_profile=True,
+ sort_by_name=False,
+ export_transformation_type=0,
+ export_transformation_type_selection='matrix',
+ export_texture_type=0,
+ export_texture_type_selection='mat',
+ open_sim=False,
+ limit_precision=True,
keep_bind_info=False)
-
+
# Now check the resulting Collada file.
if not self.checkdae(reference_dae, outfile):
self.fail()
@@ -236,45 +236,45 @@ class MeshExportTest1(AbstractColladaTest):
test = "suzannes_parent_inverse_keyframes_channels"
reference_dae = self.testdir / Path("%s.dae" % test)
outfile = tempdir / Path("%s_out.dae" % test)
-
+
bpy.ops.wm.collada_export(filepath="%s" % str(outfile),
- check_existing=True,
- filemode=8,
- display_type='DEFAULT',
- sort_method='FILE_SORT_ALPHA',
- apply_modifiers=True,
- export_mesh_type=0,
- export_mesh_type_selection='view',
- selected=True,
- include_children=True,
- include_armatures=True,
- include_shapekeys=False,
- deform_bones_only=False,
- include_animations=True,
- sample_animations=False,
- sampling_rate=1,
- active_uv_only=False,
- use_texture_copies=True,
- triangulate=False,
- use_object_instantiation=True,
- use_blender_profile=True,
- sort_by_name=False,
- export_transformation_type=0,
- export_transformation_type_selection='transrotloc',
- export_texture_type=0,
- export_texture_type_selection='mat',
- open_sim=False,
- limit_precision=True,
+ check_existing=True,
+ filemode=8,
+ display_type='DEFAULT',
+ sort_method='FILE_SORT_ALPHA',
+ apply_modifiers=True,
+ export_mesh_type=0,
+ export_mesh_type_selection='view',
+ selected=True,
+ include_children=True,
+ include_armatures=True,
+ include_shapekeys=False,
+ deform_bones_only=False,
+ include_animations=True,
+ sample_animations=False,
+ sampling_rate=1,
+ active_uv_only=False,
+ use_texture_copies=True,
+ triangulate=False,
+ use_object_instantiation=True,
+ use_blender_profile=True,
+ sort_by_name=False,
+ export_transformation_type=0,
+ export_transformation_type_selection='transrotloc',
+ export_texture_type=0,
+ export_texture_type_selection='mat',
+ open_sim=False,
+ limit_precision=True,
keep_bind_info=False)
-
+
# Now check the resulting Collada file.
if not self.checkdae(reference_dae, outfile):
self.fail()
-
+
if __name__ == '__main__':
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
parser = argparse.ArgumentParser()
parser.add_argument('--testdir', required=True)
args, remaining = parser.parse_known_args()
- unittest.main(argv=sys.argv[0:1]+remaining) \ No newline at end of file
+ unittest.main(argv=sys.argv[0:1]+remaining)
diff --git a/tests/python/collada/mesh/test_mesh_simple.py b/tests/python/collada/mesh/test_mesh_simple.py
index f592160f6aa..213c6177fde 100644
--- a/tests/python/collada/mesh/test_mesh_simple.py
+++ b/tests/python/collada/mesh/test_mesh_simple.py
@@ -113,7 +113,7 @@ class MeshExportTest(AbstractColladaTest):
test = "mesh_simple_001"
reference_dae = self.testdir / Path("%s.dae" % test)
outfile = tempdir / Path("%s_out.dae" % test)
-
+
bpy.ops.wm.collada_export(filepath="%s" % str(outfile),
check_existing=True,
filemode=8,
@@ -141,7 +141,7 @@ class MeshExportTest(AbstractColladaTest):
open_sim=False,
limit_precision=False,
keep_bind_info=False)
-
+
# Now check the resulting Collada file.
if not self.checkdae(reference_dae, outfile):
self.fail()
@@ -151,4 +151,4 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--testdir', required=True)
args, remaining = parser.parse_known_args()
- unittest.main(argv=sys.argv[0:1]+remaining) \ No newline at end of file
+ unittest.main(argv=sys.argv[0:1]+remaining)
diff --git a/tests/python/ffmpeg_tests.py b/tests/python/ffmpeg_tests.py
index 9493d6f7a17..70677677667 100755
--- a/tests/python/ffmpeg_tests.py
+++ b/tests/python/ffmpeg_tests.py
@@ -60,7 +60,7 @@ class AbstractFFmpegSequencerTest(AbstractFFmpegTest):
class FPSDetectionTest(AbstractFFmpegSequencerTest):
def test_T51153(self):
self.assertAlmostEqual(
- self.get_movie_file_fps('T51153_bad_clip_2.mts'),
+ self.get_movie_file_fps('T51153_bad_clip_2.mts'),
29.97,
places=2)
diff --git a/tests/python/modules/test_utils.py b/tests/python/modules/test_utils.py
index 55ef882c49c..c4496c3e3ac 100755
--- a/tests/python/modules/test_utils.py
+++ b/tests/python/modules/test_utils.py
@@ -61,7 +61,7 @@ class AbstractBlenderRunnerTest(unittest.TestCase):
# Set in a subclass
blender: pathlib.Path = None
testdir: pathlib.Path = None
-
+
def run_blender(self, filepath: str, python_script: str, timeout: int=300) -> str:
"""Runs Blender by opening a blendfile and executing a script.
diff --git a/tests/python/rna_array.py b/tests/python/rna_array.py
index f9777a5b438..dda13d2c3ae 100644
--- a/tests/python/rna_array.py
+++ b/tests/python/rna_array.py
@@ -23,7 +23,7 @@ class TestArray(unittest.TestCase):
test.farr= (1.0, 2.0, 3.0)
test.iarr= (7, 8, 9)
test.barr= (False, True, False)
-
+
# test access
# test slice access, negative indices
def test_access(self):
@@ -40,7 +40,7 @@ class TestArray(unittest.TestCase):
def test_access_fail(self):
for arr in (test.farr, test.iarr, test.barr):
self.assertRaises(IndexError, lambda : arr[4])
-
+
# test assignment of a whole array
def test_assign_array(self):
# should accept int as float
@@ -83,7 +83,7 @@ class TestArray(unittest.TestCase):
for i in range(len(arr)):
val= rand_func()
arr[i] = val
-
+
self.assertEqual(arr[i], val)
# float prop should accept also int
@@ -92,7 +92,7 @@ class TestArray(unittest.TestCase):
test.farr[i] = val
self.assertEqual(test.farr[i], float(val))
- #
+ #
def test_assign_item_fail(self):
def assign_bad_index(arr):
@@ -100,12 +100,12 @@ class TestArray(unittest.TestCase):
def assign_bad_type(arr):
arr[1] = "123"
-
+
for arr in [test.farr, test.iarr, test.barr]:
self.assertRaises(IndexError, assign_bad_index, arr)
# not testing bool because bool allows not only (True|False)
- for arr in [test.farr, test.iarr]:
+ for arr in [test.farr, test.iarr]:
self.assertRaises(TypeError, assign_bad_type, arr)
def test_dynamic_assign_array(self):
@@ -118,7 +118,7 @@ class TestArray(unittest.TestCase):
def test_dynamic_assign_array_fail(self):
# could also test too big length here
-
+
def assign_empty_list(arr):
setattr(test, arr, ())
@@ -236,7 +236,7 @@ def make_random_array(len, rand_func):
arr= []
for i in range(len):
arr.append(rand_func())
-
+
return arr
def make_random_2d_array(dimsize, rand_func):
diff --git a/tests/python/view_layer/CMakeLists.txt b/tests/python/view_layer/CMakeLists.txt
index 69f7af20ad2..cec839a3efc 100644
--- a/tests/python/view_layer/CMakeLists.txt
+++ b/tests/python/view_layer/CMakeLists.txt
@@ -18,7 +18,7 @@
#
# ***** END GPL LICENSE BLOCK *****
-# --env-system-scripts allows to run without the install target.
+# --env-system-scripts allows to run without the install target.
# Use '--write-blend=/tmp/test.blend' to view output
@@ -43,7 +43,7 @@ else()
set(TEST_BLENDER_EXE ${EXECUTABLE_OUTPUT_PATH}/blender)
endif()
-# for testing with valgrind prefix: valgrind --track-origins=yes --error-limit=no
+# for testing with valgrind prefix: valgrind --track-origins=yes --error-limit=no
set(TEST_BLENDER_EXE ${TEST_BLENDER_EXE} --background -noaudio --factory-startup --env-system-scripts ${CMAKE_SOURCE_DIR}/release/scripts)